<commit_before>/*
	Author <NAME> & <NAME>
	<EMAIL>
	andreas epost
	
	A sequential Jacobi Multigrid iteration program
	Grids are: gridh (finest),
			   grid2h,
			   grid4h,
			   grid8h (coarsest).
*/

/*

Example of a gridSize of 8 (+ boundary)  and its multigrids

									B  B  B  B  B  B  B  B  
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
									B  B  B  B  B  B  B  B  
 
 
    B  B  B  B  B  B  B  B  		 B    B    B    B
 B  0  *  0  *  0  *  0  *  B	   B *    *    *    *    B
 B  *  *  *  *  *  *  *  *  B 		
 B  0  *  0  *  0  *  0  *  B	   B *    *    *    *    B  	
 B  *  *  *  *  *  *  *  *  B		
 B  0  *  0  *  0  *  0  *  B      B *    *    *    *    B 
 B  *  *  *  *  *  *  *  *  B		
 B  0  *  0  *  0  *  0  *  B      B *    *    *    *    B 
 B  *  *  *  *  *  *  *  *  B		
    B  B  B  B  B  B  B  B           B    B    B    B
	
 
    B  B  B  B  	     			   B    B
 B  0  *  0  *  B	  				B  *    *  B
 B  *  *  *  *  B
 B  0  *  0  *  B 				    B  *    *  B
 B  *  *  *  *  B
    B  B  B  B  			           B    B
 

    B  B  							B
 B  0  *  B     				 B  *     B
 B  *  *  B
    B  B  				            B

 
 Example of a grid size of 9 (+ boundary) and its multigrids:
 
										B  B  B  B  B  B  B  B  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
										B  B  B  B  B  B  B  B  B
 
 
    B  B  B  B  B  B  B  B  B		     B     B     B     B     B	
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B 
 B  *  *  *  *  *  *  *  *  *  B
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B
 B  *  *  *  *  *  *  *  *  *  B
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B
 B  *  *  *  *  *  *  *  *  *  B
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B
 B  *  *  *  *  *  *  *  *  *  B
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B 
    B  B  B  B  B  B  B  B  B            B     B     B     B     B
	

   B  B  B  B  B          					  B     B     B
B  0  *  0  *  0  B     				   B  *     *     *  B
B  *  *  *  *  *  B      
B  0  *  0  *  0  B     				   B  *     *     *  B
B  *  *  *  *  *  B 
B  0  *  0  *  0  B    					   B  *     *     *  B
   B  B  B  B  B          					  B     B     B
 
 
   B  B  B									B     B
 B 0  *  0  B						    B	*     *  B
 B *  *  *  B		  
 B 0  *  0  B		 				 	B	*     *  B
   B  B  B									B     B
   
We can see that we need different restriction and interpolation operators for even and uneven
grids. When the grid size is even the on step down courser grid is computed by gridsize/2 +1.
When the grid is uneven it is computed by gridsize/2 + 2. 
  
	
*/
 #include <stdlib.h>
 #include <stdio.h>
 
 #define GRIDSIZE 10
 #define NUMITERS 10
 #define FINERITER 2
 
 void jacobi(double** grid, double** new, int gridSize, int iter);
 void restriction(double** fine, double** coarse, int fineSize, int coarseSize);
 
 int main(int argc, char *argv[]){
	/*gridSize, the grid size for the finest grid, not including boundaries
				the grid size has to be at least 8 or bigger
				
	  numIters, the number of iterations to use for the coarsest grid
				the finer grids has 4 iterations each (specification from Prof. Dr. Vladimir Vlassov). 
	*/
	 
	int gridSizeH, gridSize2H, gridSize4H, gridSize8H, numIters, i, j, k;
	double temp, maxdiff;<commit_msg>additional describing comments<commit_after>/*
	Author <NAME> & <NAME>
	<EMAIL>
	andreas epost
	
	A sequential Jacobi Multigrid iteration program
	Grids are: gridh (finest),
			   grid2h,
			   grid4h,
			   grid8h (coarsest).
*/

/*

Example of a gridSize of 8 (+ boundary)  and its multigrids

									B  B  B  B  B  B  B  B  
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
								 B  *  *  *  *  *  *  *  *  B
									B  B  B  B  B  B  B  B  
 
 
    B  B  B  B  B  B  B  B  		 B    B    B    B
 B  0  *  0  *  0  *  0  *  B	   B *    *    *    *    B
 B  *  *  *  *  *  *  *  *  B 		
 B  0  *  0  *  0  *  0  *  B	   B *    *    *    *    B  	
 B  *  *  *  *  *  *  *  *  B		
 B  0  *  0  *  0  *  0  *  B      B *    *    *    *    B 
 B  *  *  *  *  *  *  *  *  B		
 B  0  *  0  *  0  *  0  *  B      B *    *    *    *    B 
 B  *  *  *  *  *  *  *  *  B		
    B  B  B  B  B  B  B  B           B    B    B    B
	
 
    B  B  B  B  	     			   B    B
 B  0  *  0  *  B	  				B  *    *  B
 B  *  *  *  *  B
 B  0  *  0  *  B 				    B  *    *  B
 B  *  *  *  *  B
    B  B  B  B  			           B    B
 

    B  B  							B
 B  0  *  B     				 B  *     B
 B  *  *  B
    B  B  				            B

 
 Example of a grid size of 9 (+ boundary) and its multigrids:
 
										B  B  B  B  B  B  B  B  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
									 B  *  *  *  *  *  *  *  *  *  B
										B  B  B  B  B  B  B  B  B
 
 
    B  B  B  B  B  B  B  B  B		     B     B     B     B     B	
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B 
 B  *  *  *  *  *  *  *  *  *  B
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B
 B  *  *  *  *  *  *  *  *  *  B
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B
 B  *  *  *  *  *  *  *  *  *  B
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B
 B  *  *  *  *  *  *  *  *  *  B
 B  0  *  0  *  0  *  0  *  0  B      B  *     *     *     *     *  B 
    B  B  B  B  B  B  B  B  B            B     B     B     B     B
	

   B  B  B  B  B          					  B     B     B
B  0  *  0  *  0  B     				   B  *     *     *  B
B  *  *  *  *  *  B      
B  0  *  0  *  0  B     				   B  *     *     *  B
B  *  *  *  *  *  B 
B  0  *  0  *  0  B    					   B  *     *     *  B
   B  B  B  B  B          					  B     B     B
 
 
   B  B  B									B     B
 B 0  *  0  B						    B	*     *  B
 B *  *  *  B		  
 B 0  *  0  B		 				 	B	*     *  B
   B  B  B									B     B
   
We can see that we need different restriction and interpolation operators for even and uneven
grids. When the grid size is even the on step down courser grid is computed by gridsize/2 +1.
When the grid is uneven it is computed by gridsize/2 + 2. 

However when implementing the restriction operator method I have only taken the uneven case
into consideration. This is improvable. The uneven case is choose as it is more
trivial to cover the same spatial space with a courser grid. 
  
	
*/
 #include <stdlib.h>
 #include <stdio.h>
 
 #define GRIDSIZE 10
 #define NUMITERS 10
 #define FINERITER 2
 
 void jacobi(double** grid, double** new, int gridSize, int iter);
 void restriction(double** fine, double** coarse, int fineSize, int coarseSize);
 
 int main(int argc, char *argv[]){
	/*gridSize, the grid size for the finest grid, not including boundaries
				the grid size has to be at least 8 or bigger
				
	  numIters, the number of iterations to use for the coarsest grid
				the finer grids has 4 iterations each (specification from Prof. Dr. <NAME>). 
	*/
	 
	int gridSizeH, gridSize2H, gridSize4H, gridSize8H, numIters, i, j, k;
	double temp, maxdiff;
{'fraction_non_alphanumeric': 0.11068513480089043, 'fraction_numerical': 0.01929260450160772, 'mean_word_length': 0.7695842450765864, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1946814', 'n_tokens_mistral': 4283, 'n_tokens_neox': 3613, 'n_words': 1037}