#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#pragma DATA_SECTION(Y_dist_Whole_Re, ".data_in_DDR3")
#pragma DATA_ALIGN(Y_dist_Whole_Re, 64);
#pragma DATA_SECTION(Y_dist_Whole_Im, ".data_in_DDR3")
#pragma DATA_ALIGN(Y_dist_Whole_Im, 64);
#include "Y_dist_Whole_Re.h"
#include "Y_dist_Whole_Im.h"

#pragma DATA_SECTION(Y_dist_Core0_Re, ".data_in_DDR3")
#pragma DATA_ALIGN(Y_dist_Core0_Re, 64);
double Y_dist_Core0_Re[(98)+1][(1800)+1];
#pragma DATA_SECTION(Y_dist_Core0_Im, ".data_in_DDR3")
#pragma DATA_ALIGN(Y_dist_Core0_Im, 64);
double Y_dist_Core0_Im[(98)+1][(1800)+1];


#pragma DATA_SECTION(void_Pointer, ".data_in_L2")
#pragma DATA_ALIGN(void_Pointer, 64);
#pragma DATA_SECTION(uLLInt_Pointer, ".data_in_L2")
#pragma DATA_ALIGN(uLLInt_Pointer, 64);
#pragma DATA_SECTION(uLLInt_Number, ".data_in_L2")
#pragma DATA_ALIGN(uLLInt_Number, 64);
#pragma DATA_SECTION(sumOfuLLInt_Numbers_Re, ".data_in_L2")
#pragma DATA_ALIGN(sumOfuLLInt_Numbers_Re, 64);
#pragma DATA_SECTION(sumOfuLLInt_Numbers_Im, ".data_in_L2")
#pragma DATA_ALIGN(sumOfuLLInt_Numbers_Im, 64);
#pragma DATA_SECTION(doubleNumbers_Re, ".data_in_L2")
#pragma DATA_ALIGN(doubleNumbers_Re, 64);
#pragma DATA_SECTION(doubleNumbers_Im, ".data_in_L2")
#pragma DATA_ALIGN(doubleNumbers_Im, 64);
#pragma DATA_SECTION(inp_control_sums_Core0_Re, ".data_in_L2")
#pragma DATA_ALIGN(inp_control_sums_Core0_Re, 64);
#pragma DATA_SECTION(inp_control_sums_Core0_Im, ".data_in_L2")
#pragma DATA_ALIGN(inp_control_sums_Core0_Im, 64);

#pragma DATA_SECTION(i_offset, ".data_in_L2")
#pragma DATA_ALIGN(i_offset, 64);
#pragma DATA_SECTION(i, ".data_in_L2")
#pragma DATA_ALIGN(i, 64);
#pragma DATA_SECTION(j, ".data_in_L2")
#pragma DATA_ALIGN(j, 64);

#include "data_in_L2.h"


void main(void)
{
     // 1-dimension arrays to 2-dimension arrays
     i_offset = 0;
		for(i=1; i<=98; i++)
		{
			  for(j=1; j<=1800; j++)
			  {
				  // att!  массивы Y_dist_Whole_Re, Y_dist_Whole_Im  индексируются от нуля!
				  Y_dist_Core0_Re[i][j] = Y_dist_Whole_Re[i_offset];
				  Y_dist_Core0_Im[i][j] = Y_dist_Whole_Im[i_offset];
			   i_offset++;
			  }
		}
		for(i=0; i<=98; i++)
		{
		 Y_dist_Core0_Re[i][0] = 0.0;
		 Y_dist_Core0_Im[i][0] = 0.0;
		}
		for(j=0; j<=1800; j++)
		{
		 Y_dist_Core0_Re[0][j] = 0.0;
		 Y_dist_Core0_Im[0][j] = 0.0;
		}

		// zirro to control sums of input array's rows
		for(i=0; i<=98; i++)
		{
		 inp_control_sums_Core0_Re[i]=0.0;
		 inp_control_sums_Core0_Im[i]=0.0;
		}
	    // convertation of array to unsigned long long format and  calculation of the control sum of rows (in unsigned long long format)
		for(i=1; i<=98; i++)
		{
		  sumOfuLLInt_Numbers_Re=0.0;
		  sumOfuLLInt_Numbers_Im=0.0;
		  for(j=1; j<=909; j++)
		  {
		    doubleNumbers_Re = Y_dist_Core0_Re[i][j];
			void_Pointer = (void *) &doubleNumbers_Re;
			uLLInt_Pointer = (unsigned long long int *) void_Pointer;
			uLLInt_Number = (unsigned long long int) *uLLInt_Pointer;
			sumOfuLLInt_Numbers_Re = sumOfuLLInt_Numbers_Re + uLLInt_Number;

			doubleNumbers_Im = Y_dist_Core0_Im[i][j];
			void_Pointer = (void *) &doubleNumbers_Im;
			uLLInt_Pointer = (unsigned long long int *) void_Pointer;
			uLLInt_Number = (unsigned long long int) *uLLInt_Pointer;

			sumOfuLLInt_Numbers_Im = sumOfuLLInt_Numbers_Im + uLLInt_Number;
		  }
		  inp_control_sums_Core0_Re[i] = sumOfuLLInt_Numbers_Re;
		  inp_control_sums_Core0_Im[i] = sumOfuLLInt_Numbers_Im;
		}

		for(i=1; i<=3; i++)
	    {
		 printf("inp_control_sums_Core0_Re[%d] = %016llX  \r\n",i,inp_control_sums_Core0_Re[i] );
		 printf("inp_control_sums_Core0_Im[%d] = %016llX  \r\n",i,inp_control_sums_Core0_Im[i] );
	    }
		for(i=96; i<=98; i++)
	    {
		 printf("inp_control_sums_Core0_Re[%d] = %016llX  \r\n",i,inp_control_sums_Core0_Re[i] );
		 printf("inp_control_sums_Core0_Im[%d] = %016llX  \r\n",i,inp_control_sums_Core0_Im[i] );
	    }
	
}
