1 #include "../include/Matematica.h" 8 fprintf(stderr,
"Matrice] ");
9 vfprintf(stderr, s, args);
10 fprintf(stderr,
"\n");
31 Shout(
"Matrice(row,col)");
37 data = (
double *)calloc(NSize,
sizeof(
double));
40 Shout(
"Matrice(row,col)");
45 data = (
double *)malloc(
sizeof(
double));
49 Shout(
"Matrice(row=col)");
55 data = (
double *)calloc(NSize,
sizeof(
double));
58 Shout(
"Matrice(row,col)");
62 NSize = NCol*NRow*NZed;
64 data = (
double *)calloc(NSize,
sizeof(
double));
67 Shout(
"Matrice(SPLINE)");
71 data = (
double *)calloc(NSize,
sizeof(
double));
72 double MenoDue = - .75*Wg.
a3 + 1.5*Wg.
a4;
74 double MenoUno = -.5*Wg.
a1 + Wg.
a2 + 1.5*Wg.
a3 - 6.*Wg.
a4;
76 double Zero = Wg.
a0 - 2.*Wg.
a2 + 9.*Wg.
a4;
78 double PiuUno = .5*Wg.
a1 + Wg.
a2 - 1.5*Wg.
a3 - 6.*Wg.
a4;
80 double PiuDue = .75*Wg.
a3 + 1.5*Wg.
a4;
83 for(
int r=0;r<NCol;r++){
84 data[NRow*0+r] = MenoUno;
85 data[NRow*1+r] = Zero;
86 data[NRow*2+r] = PiuUno;
88 for(
int r=0;r<NRow;r++)
89 for(
int c=0;c<NCol;c++)
91 Norm += ASS(
data[NRow*c+r]);
92 for(
int r=0;r<NRow;r++)
93 for(
int c=0;c<NCol;c++)
94 data[NRow*c+r] /= Norm*.5;
100 double c = cos(Angle);
101 double s = sin(Angle);
104 for(
int d=0;d<3;d++){
105 Norm += SQR(Axis[d]);
107 Norm = Norm > 0. ? sqrt(Norm) : 1.;
108 double x = Axis[0]/Norm;
109 double y = Axis[1]/Norm;
110 double z = Axis[2]/Norm;
116 data = (
double *)calloc(NSize,
sizeof(
double));
117 data[NRow*0+0] = t*x*x + c;
118 data[NRow*0+1] = t*x*y + z*s;
119 data[NRow*0+2] = t*x*z - y*s;
122 data[NRow*1+0] = t*x*y - z*s;
123 data[NRow*1+1] = t*y*y + c;
124 data[NRow*1+2] = t*y*z + x*s;
127 data[NRow*2+0] = t*x*z + y*s;
128 data[NRow*2+1] = t*y*z - x*s;
129 data[NRow*2+2] = t*z*z + c;
140 data = (
double *)calloc(NSize,
sizeof(
double));
141 data[NRow*0+0] = t*x*x + c;
142 data[NRow*0+1] = t*x*y + z*s;
143 data[NRow*0+2] = t*x*z - y*s;
145 data[NRow*1+0] = t*x*y - z*s;
146 data[NRow*1+1] = t*y*y + c;
147 data[NRow*1+2] = t*y*z + x*s;
149 data[NRow*2+0] = t*x*z + y*s;
150 data[NRow*2+1] = t*y*z - x*s;
151 data[NRow*2+2] = t*z*z + c;
161 data = (
double *)calloc(NSize,
sizeof(
double));
163 data[NRow*0+1] = 2.*q.
x*q.
y + 2.*q.
w*q.
z;
164 data[NRow*0+2] = 2.*q.
x*q.
z - 2.*q.
w*q.
y;
167 data[NRow*1+0] = 2.*q.
x*q.
y - 2.*q.
w*q.
z;
169 data[NRow*1+2] = 2.*q.
y*q.
z + 2.*q.
w*q.
x;
172 data[NRow*2+0] = 2.*q.
x*q.
z + 2.*q.
w*q.
y;
173 data[NRow*2+1] = 2.*q.
y*q.
z - 2.*q.
w*q.
x;
185 data = (
double *)calloc(NSize,
sizeof(
double));
186 data[NRow*0+0] = 1. - 2.*SQR(q.
y) - 2.*SQR(q.
z);
187 data[NRow*0+1] = 2.*q.
x*q.
y + 2.*q.
w*q.
z;
188 data[NRow*0+2] = 2.*q.
x*q.
z - 2.*q.
w*q.
y;
190 data[NRow*1+0] = 2.*q.
x*q.
y - 2.*q.
w*q.
z;
191 data[NRow*1+1] = 1. - 2.*SQR(q.
x) - 2.*SQR(q.
z);
192 data[NRow*1+2] = 2.*q.
y*q.
z + 2.*q.
w*q.
x;
194 data[NRow*2+0] = 2.*q.
x*q.
z + 2.*q.
w*q.
y;
195 data[NRow*2+1] = 2.*q.
y*q.
z - 2.*q.
w*q.
x;
196 data[NRow*2+2] = 1. - 2.*SQR(q.
x) - 2.*SQR(q.
y);
201 double CR = cos(Roll);
202 double SR = sin(Roll);
203 double CP = cos(Pitch);
204 double SP = sin(Pitch);
205 double CY = cos(Yaw);
206 double SY = sin(Yaw);
212 data = (
double *)calloc(NSize,
sizeof(
double));
213 data[NRow*0+0] = CY*CP;
214 data[NRow*0+1] = SY*CP;
215 data[NRow*0+2] = -SP;
218 data[NRow*1+0] = CY*SP*SR - SY*CR;
219 data[NRow*1+1] = SY*SP*SR + CY*CR;
220 data[NRow*1+2] = CP*SR;
223 data[NRow*2+0] = CY*SP*CR + SY*SR;
224 data[NRow*2+1] = SY*SP*CR - CY*SR;
225 data[NRow*2+2] = CP*CR;
256 data = (
double *)calloc(NSize,
sizeof(
double));
257 data[NRow*0+0] = CR*CP;
258 data[NRow*0+1] = SR*CP;
259 data[NRow*0+2] = -SP;
261 data[NRow*1+0] = CR*SP*SY - SR*CY;
262 data[NRow*1+1] = SR*SP*SY + CR*SY;
263 data[NRow*1+2] = CP*SY;
265 data[NRow*2+0] = CR*SP*CY+SR*SY;
266 data[NRow*2+1] = SR*SP*CY-CR*SY;
267 data[NRow*2+2] = CR*CY;
277 data = (
double *)calloc(NSize,
sizeof(
double));
278 for(
int c=0;c<NCol;c++)
279 for(
int r=0;r<NRow;r++)
280 data[NRow*c+r] = M[NRow*c+r];
283 Shout(
"Matrice(SPLINE,dim)");
287 data = (
double *)calloc(NSize,
sizeof(
double));
296 for(
int r=0;r<NRow;r++)
297 for(
int c=0;c<NCol;c++)
298 data[NRow*c+r] = Max*drand48();
301 Shout(
"Matrice(SPLINE,dim)");
302 double MenoDue = - .75*Wg.
a3 + 2.*Wg.
a4;
304 MenoDue -= 1./12.*Wg.
a2;
305 double MenoUno = -.5*Wg.
a1 + Wg.
a2 + 1.5*Wg.
a3 - 8.*Wg.
a4;
307 MenoUno += 1./3.*Wg.
a2;
308 double Zero = Wg.
a0 - 2.*Wg.
a2 + 12.*Wg.
a4;
311 double PiuUno = .5*Wg.
a1 + Wg.
a2 - 1.5*Wg.
a3 - 8.*Wg.
a4;
313 PiuUno += 1./3.*Wg.
a2;
314 double PiuDue = .75*Wg.
a3 + 2.*Wg.
a4;
316 PiuDue -= 1./12.*Wg.
a2;
319 for(
int r=0;r<NCol;r++){
320 data[NRow*0+r] = MenoDue;
321 data[NRow*1+r] = MenoUno;
322 data[NRow*2+r] = Zero;
323 data[NRow*3+r] = PiuUno;
324 data[NRow*4+r] = PiuDue;
329 data[NRow*0+r] = MenoDue;
330 data[NRow*1+r] = MenoUno;
331 data[NRow*2+r] = Zero;
332 data[NRow*3+r] = PiuUno;
333 data[NRow*4+r] = PiuDue;
337 data[NRow*0+r] = MenoDue;
338 data[NRow*1+r] = MenoUno;
339 data[NRow*2+r] = Zero;
340 data[NRow*3+r] = PiuUno;
341 data[NRow*4+r] = PiuDue;
343 data[NRow*c+0] = MenoDue;
344 data[NRow*c+1] = MenoUno;
345 data[NRow*c+2] += Zero;
346 data[NRow*c+3] = PiuUno;
347 data[NRow*c+4] = PiuDue;
350 for(
int r=0;r<NCol;r++){
351 data[NRow*0+r] = MenoDue;
352 data[NRow*1+r] = MenoUno;
353 data[NRow*2+r] = Zero;
354 data[NRow*3+r] = PiuUno;
355 data[NRow*4+r] = PiuDue;
361 printf(
"I don't know the expresion for matrices of NRow != 5\n");
365 printf(
"I don't know the expresion for matrices of NRow != 5\n");
368 Set(0,0,2.);
Set(0,1,4.);
Set(0,2,5.);
Set(0,3,4.);
Set(0,4,2.);
369 Set(1,0,4.);
Set(1,1,9.);
Set(1,2,12.);
Set(1,3,9.);
Set(1,4,4.);
370 Set(2,0,5.);
Set(2,1,12.);
Set(2,2,15.);
Set(2,3,12.);
Set(2,4,5.);
371 Set(3,0,4.);
Set(3,1,9.);
Set(3,2,12.);
Set(3,3,9.);
Set(3,4,4.);
372 Set(4,0,2.);
Set(4,1,4.);
Set(4,2,5.);
Set(4,3,4.);
Set(4,4,2.);
379 for(
int r=0;r<NRow;r++){
380 double x = CutOff*(r-Half)/(
double)NRow;
381 for(
int c=0;c<NCol;c++){
382 double y = CutOff*(c-Half)/(
double)NCol;
383 for(
int q=0;q<NCol;q++){
384 double z = CutOff*(q-Half)/(
double)NCol;
385 double r2 = SQR(x) + SQR(y) + SQR(z);
386 double Gauss = exp(-r2*.5/SQR(Sigma));
387 data[(NRow*c+r)*NCol+q] = Gauss;
394 for(
int r=0;r<NRow;r++){
395 double x = CutOff*(r-Half)/(
double)NRow;
396 for(
int c=0;c<NCol;c++){
397 double y = CutOff*(c-Half)/(
double)NCol;
398 double r2 = SQR(x) + SQR(y);
399 double Gauss = exp(-r2*.5/SQR(Sigma));
400 data[NRow*c+r] = Gauss;
406 for(
int r=0;r<NRow;r++){
407 double x = CutOff*(r-Half)/(
double)NRow;
409 double Gauss = exp(-r2*.5/SQR(Sigma));
417 if(NRow != 5 && NCol != 5){
418 printf(
"Invalid number of rows and cols %dx%d != 7x7\n",NRow,NCol);
458 if ( (row>=NRow) || (row<0) )
459 { printf(
"Values %d %d out of range %d %d\n",row,NRow);
466 if ( (row>=NRow) || (col>=NCol)
467 || (row<0) || (col<0) )
468 { printf(
"Values %d %d out of range %d %d\n",row,col,NRow,NCol);
471 return data[ NRow*col+row ];
474 return data[ (NRow*col+row)*NCol+zed ];
478 if ( (row >= NRow) || (column >= NCol)
479 || (row<0) || (column<0) )
return false;
481 data[ NRow*column + row ] = newvalue;
486 if ( (row >= NRow) || (column >= NCol)
487 || (row<0) || (column<0) )
return false;
489 data[ NRow*column + row ] += Value;
494 for(
int q=0;q<NZed;q++){
496 for(
int r=0;r<NRow;r++){
498 for(
int c=0;c<NCol;c++){
499 printf(
"%.2g ",
data[(NRow*c+r)*NCol+q]);
509 for(
int r=0;r<NRow;r++){
510 printf(
"%.2g ",
data[r]);
516 for(
int r=0;r<NRow;r++){
518 for(
int c=0;c<NCol;c++){
519 printf(
"%.2g ",
data[NRow*c+r]);
527 int worstdiagonal = 0;
528 double maxunitydeviation = 0.0;
529 double currentunitydeviation;
530 for (
int i = 0; i < NRow; i++ ) {
531 currentunitydeviation =
data[i+i*NRow] - 1.;
532 if ( currentunitydeviation < 0.0) currentunitydeviation *= -1.;
533 if ( currentunitydeviation > maxunitydeviation ) {
534 maxunitydeviation = currentunitydeviation;
538 int worstoffdiagonalrow = 0;
539 int worstoffdiagonalcolumn = 0;
540 double maxzerodeviation = 0.0;
541 double currentzerodeviation ;
542 for (
int i = 0; i < NRow; i++ ) {
543 for (
int j = 0; j < NRow; j++ ) {
544 if ( i == j )
continue;
545 currentzerodeviation =
data[i+j*NRow];
546 if ( currentzerodeviation < 0.0) currentzerodeviation *= -1.0;
547 if ( currentzerodeviation > maxzerodeviation ) {
548 maxzerodeviation = currentzerodeviation;
549 worstoffdiagonalrow = i;
550 worstoffdiagonalcolumn = j;
555 cout <<
"Worst diagonal value deviation from unity: " 556 << maxunitydeviation <<
" at row/column " << worstdiagonal << endl;
557 cout <<
"Worst off-diagonal value deviation from zero: " 558 << maxzerodeviation <<
" at row = " << worstoffdiagonalrow
559 <<
", column = " << worstoffdiagonalcolumn << endl;
567 for (
int i = 0; i < NRow; i++ )
568 for (
int j = 0; j < NRow; j++ ) {
570 double leftvalue, rightvalue;
572 for (
int c = 0; c < NRow; c++) {
573 left.
getvalue(i,c,leftvalue,success);
574 right.
getvalue(c,j,rightvalue,success);
575 sum += leftvalue * rightvalue;
586 for (
int i = 0; i < NRow; i++ )
587 for (
int j = 0; j < NRow; j++ ) {
591 data[i+j*NRow] = value;
607 if ( (row>=NRow) || (column>=NCol)
608 || (row<0) || (column<0) )
612 returnvalue =
data[ row + column*NRow ];
616 #ifdef MATR_DEBUG //CHECKIT 617 if (NRow <= 0)
return;
618 if (NRow == 1)
return;
620 for (
int i=1; i < NRow; i++)
data[i] /=
data[0];
621 for (
int i=1; i < NRow; i++) {
622 for (
int j=i; j < NRow; j++) {
624 for (
int k = 0; k < i; k++)
625 sum +=
data[j+k*NRow] *
data[k+i*NRow];
626 data[j+i*NRow] -= sum;
628 if (i == NRow-1)
continue;
629 for (
int j=i+1; j < NRow; j++) {
631 for (
int k = 0; k < i; k++)
632 sum +=
data[i+k*NRow]*
data[k+j*NRow];
634 (
data[i+j*NRow]-sum) /
data[i+i*NRow];
637 for (
int i = 0; i < NRow; i++ )
638 for (
int j = i; j < NRow; j++ ) {
642 for (
int k = i; k < j; k++ )
645 data[j+i*NRow] = x /
data[j+j*NRow];
647 for (
int i = 0; i < NRow; i++ )
648 for (
int j = i; j < NRow; j++ ) {
649 if ( i == j )
continue;
651 for (
int k = i; k < j; k++ )
652 sum +=
data[k+j*NRow]*( (i==k) ? 1.0 :
data[i+k*NRow] );
653 data[i+j*NRow] = -sum;
655 for (
int i = 0; i < NRow; i++ )
656 for (
int j = 0; j < NRow; j++ ) {
658 for (
int k = ((i>j)?i:j); k < NRow; k++ )
659 sum += ((j==k)?1.0:
data[j+k*NRow])*
data[k+i*NRow];
660 data[j+i*NRow] = sum;
670 double *AlmostKnown = (
double *)calloc(NCol,
sizeof(
double));
671 if(!AlmostKnown) {printf(
"Not allocated\n");
return 0;}
673 for(
int r = 0; r < NRow ; r ++){
677 for(
int j = 0; j < NCol ; j ++){
678 for(
int i = 0; i <= j ; i++){
680 for (
int k = 0; k <= i - 1; k++) {
681 Upper.
Add(i,j,-Lower.
Val(i,k)*Upper.
Val(k,j));
684 for (
int i = j + 1; i < NCol ; i++) {
686 for (
int k = 0; k <= j - 1; k ++) {
687 Lower.
Add(i,j,-Lower.
Val(i,k)*Upper.
Val(k,j));
689 double Diag = POS(Upper.
Val(j,j)) > 0. ? Lower.
Val(i,j)/Upper.
Val(j,j) : 1.;
694 for(
int r=0;r<NRow;r++){
695 AlmostKnown[r] = Known[r];
696 for(
int c=r-1;c>=0;c--){
697 AlmostKnown[r] -= AlmostKnown[c]*Lower.
Val(r,c);
700 if(POS(Lower.
Val(r,r))> 0.)
701 AlmostKnown[r] /= POS(Lower.
Val(r,r))>0. ? Lower.
Val(r,r) : 1.;
707 for(
int r=NRow-1;r>=0;r--){
708 UnKnown[r] = AlmostKnown[r];
709 for(
int c=r+1;c<NCol;c++){
710 UnKnown[r] -= UnKnown[c]*Upper.
Val(r,c);
713 if(POS(Upper.
Val(r,r))> 0.)
714 UnKnown[r] /= Upper.
Val(r,r);
725 for(
int r=0;r<NRow;r++){
726 for(
int c=0;c<NCol;c++){
727 UnKnown[r] += Known[c]*
data[r+c*NRow];
736 for (
int r = 0; r < NCol ; r ++) {
740 for (
int j = 0; j < NCol ; j ++) {
741 for (
int i = 0; i <= j ; i++) {
743 for (
int k = 0; k <= i - 1; k++) {
744 Upper.
Add(i,j,-Lower.
Val(i,k)*Upper.
Val(k,j));
747 for (
int i = j + 1; i < NCol ; i++) {
749 for (
int k = 0; k <= j - 1; k ++) {
750 Lower.
Add(i,j,-Lower.
Val(i,k)*Upper.
Val(k,j));
752 Lower.
Set(i,j,Lower.
Val(i,j)/Upper.
Val(j,j));
756 for(
int r=0;r<NCol;r++)
757 Det *= Upper.
Val(r,r);
762 double *Temp = (
double *)calloc(NCol*NRow,
sizeof(
double));
763 for(
int r=0;r<NRow;r++){
764 for(
int c=0;c<NCol;c++){
765 Temp[r+c*NRow] =
data[r+c*NRow];
768 for(
int r=0;r<NRow;r++){
769 for(
int c=0;c<NCol;c++){
770 data[r+c*NRow] = Temp[c+r*NRow];
777 for(
int r=0;r<NRow;r++){
778 for(
int c=0;c<NCol;c++){
787 for(
int r=0;r<NRow;r++){
788 for(
int c=0;c<NCol;c++){
789 if(Max <
data[r+c*NRow])
790 Max =
data[r+c*NRow];
791 if(Min >
data[r+c*NRow])
792 Min =
data[r+c*NRow];
795 if(fabs(Min) > 0.0e-5){
796 for(
int r=0;r<NRow;r++)
797 for(
int c=0;c<NCol;c++)
798 data[r+c*NRow] =
data[r+c*NRow]/(Max-Min)-Min;
802 for(
int r=0;r<NRow;r++)
803 for(
int c=0;c<NCol;c++)
804 data[r+c*NRow] =
data[r+c*NRow]/Max;
808 for(
int s=0;s<NSize;s++)
815 for(
int r=0;r<NRow;r++)
816 for(
int c=0;c<NCol;c++)
820 if(NCol != A.NCol || NRow != A.NCol){
821 printf(
"Incompatible matrices. Dim: %d/%d\n",NSize,A.NSize);
825 for(
int r=0;r<NRow;r++)
826 for(
int c=0;c<NCol;c++)
831 if(NCol != A.NRow || NRow != A.NCol){
832 printf(
"Incompatible matrices. Dim: %d/%d\n",NSize,A.NSize);
836 for(
int r=0;r<NRow;r++)
837 for(
int c=0;c<A.NCol;c++){
839 for(
int i=0;i<NRow;i++)
841 Temp += Resp.
data[r+i*NRow]*A.
data[i+c*NRow];
848 if(NRow != A.NRow || NCol != A.NCol){
849 printf(
"Incompatible matrices. Dim: %d/%d\n",NSize,A.NSize);
852 for(
int r=0;r<NRow;r++)
853 for(
int c=0;c<NCol;c++)
858 for(
int r=0;r<NRow;r++)
859 for(
int c=0;c<NCol;c++)
860 data[r+c*NRow] *= Molt;
864 assert( NCol == A.NRow || NRow == A.NCol);
865 printf(
"Still to be written!!!\n");
871 printf(
"Incompatible matrices. Dim: %d/%d\n",NSize,u.
NDim);
875 for(
int r=0;r<NRow;r++){
877 for(
int c=0;c<NCol;c++)
878 Temp +=
data[r+c*NRow]*u.
x[c];
884 if(B.NCol != A.NRow || B.NRow != A.NCol){
885 printf(
"Incompatible matrices. Dim: %d/%d\n",B.NSize,A.NSize);
888 for(
int r=0;r<A.NRow;r++)
889 for(
int c=0;c<B.NCol;c++){
891 for(
int i=0;i<A.NRow;i++)
892 Temp += A.
Val(r,i)*B.
Val(i,c);
897 if(NCol != A.NRow || NRow != A.NCol){
898 printf(
"Incompatible matrices. Dim: %d/%d\n",NSize,A.NSize);
901 for(
int r=0;r<A.NRow;r++)
902 for(
int c=0;c<NCol;c++){
904 for(
int i=0;i<A.NRow;i++)
905 Temp += A.
Val(r,i)*
Val(i,c);
911 for(
int r=0;r<NRow;r++){
913 for(
int c=0;c<NCol;c++)
914 Temp += A.
data[r+c*NRow]*v.
x[c];
921 for(
int r=0;r<NRow;r++){
923 for(
int c=0;c<NCol;c++)
924 Temp +=
data[r+c*NRow]*v.
x[c];
930 for(
int r=0;r<NRow;r++){
932 for(
int c=0;c<NCol;c++)
933 Temp +=
data[r+c*NRow]*v.
x[c];
952 double *Plot2 = (
double *)calloc(NGrid,
sizeof(
double));
953 int NMat2 = (int)
pNRow()/2;
954 for(
int gx=0;gx<NGrid;gx++){
955 if(gx <= NMat2 || gx >= NGrid - NMat2){
956 Plot2[gx] = Plot[gx];
959 for(
int mx=0;mx<
pNRow();mx++){
960 int g1x = gx + mx - NMat2;
962 Plot2[gx] = Plot[gx];
966 Plot2[gx] = Plot[gx];
969 Plot2[gx] += Plot[g1x]*
Val(mx);
972 for(
int gx=0;gx<NGrid;gx++){
973 Plot[gx] = Plot2[gx];
979 double *Plot2 = (
double *)calloc(NGrid,
sizeof(
double));
980 int NMat2 = (int)
pNRow()/2;
981 for(
int gx=0;gx<NGrid;gx++){
982 if(gx <= NMat2 || gx >= NGrid - NMat2){
983 Plot2[gx] = Plot[gx];
986 for(
int mx=0;mx<
pNRow();mx++){
987 int g1x = gx + mx - NMat2;
988 if(g1x >= NGrid) g1x -= NGrid;
989 if(g1x < 0) g1x + NGrid;
990 Plot2[gx] += Plot[g1x]*
Val(mx);
993 for(
int gx=0;gx<NGrid;gx++){
994 Plot[gx] = Plot2[gx];
1000 double *Plot2 = (
double *)calloc(SQR(NGrid),
sizeof(double));
1001 int NMat2 = (int)
pNCol()/2;
1002 for(
int gx=0;gx<NGrid;gx++){
1003 for(
int gy=0;gy<NGrid;gy++){
1004 for(
int mx=0;mx<
pNRow();mx++){
1005 int g1x = gx + mx - NMat2;
1007 Plot2[gx*NGrid+gy] = Plot[gx*NGrid+gy];
1011 Plot2[gx*NGrid+gy] = Plot[gx*NGrid+gy];
1014 for(
int my=0;my<
pNCol();my++){
1015 int g1y = gy + my - NMat2;
1017 Plot2[gx*NGrid+gy] = Plot[gx*NGrid+gy];
1021 Plot2[gx*NGrid+gy] = Plot[gx*NGrid+gy];
1024 Plot2[gx*NGrid+gy] += Plot[g1x*NGrid+g1y]*
Val(mx,my);
1029 for(
int gx=0;gx<NGrid;gx++){
1030 for(
int gy=0;gy<NGrid;gy++){
1031 Plot[gx*NGrid+gy] = Plot2[gx*NGrid+gy];
1038 double *Plot2 = (
double *)calloc(SQR(NGrid),
sizeof(double));
1039 int NMat2 = (int)
pNCol()/2;
1040 for(
int gx=0;gx<NGrid;gx++){
1041 for(
int gy=0;gy<NGrid;gy++){
1042 for(
int mx=0;mx<
pNRow();mx++){
1043 int g1x = gx + mx - NMat2;
1044 if(g1x >= NGrid)
continue;
1045 if(g1x < 0)
continue;
1046 for(
int my=0;my<
pNCol();my++){
1047 int g1y = gy + my - NMat2;
1048 if(g1y >= NGrid)
continue;
1049 if(g1y < 0)
continue;
1050 Plot2[gx*NGrid+gy] += Plot[g1x*NGrid+g1y]*
Val(mx,my);
1055 for(
int gx=0;gx<NGrid;gx++){
1056 for(
int gy=0;gy<NGrid;gy++){
1057 Plot[gx*NGrid+gy] = Plot2[gx*NGrid+gy];
1064 double *Plot2 = (
double *)calloc(CUBE(NGrid),
sizeof(double));
1065 int NMat2 = (int)
pNCol()/2;
1066 printf(
"NMat2 %d\n",NMat2);
1067 for(
int gx=0;gx<NGrid;gx++){
1068 for(
int gy=0;gy<NGrid;gy++){
1069 for(
int gz=0;gz<NGrid;gz++){
1070 for(
int mx=0;mx<
pNRow();mx++){
1071 int g1x = gx + mx - NMat2;
1072 if(g1x >= NGrid) g1x -= NGrid;
1073 if(g1x < 0) g1x += NGrid;
1074 for(
int my=0;my<
pNCol();my++){
1075 int g1y = gy + my - NMat2;
1076 if(g1y >= NGrid) g1y -= NGrid;
1077 if(g1y < 0) g1y += NGrid;
1078 for(
int mz=0;mz<
pNZed();mz++){
1079 int g1z = gz + mz - NMat2;
1080 if(g1z >= NGrid) g1z -= NGrid;
1081 if(g1z < 0) g1z += NGrid;
1082 Plot2[(gx*NGrid+gy)*NGrid+gz] += Plot[(g1x*NGrid+g1y)*NGrid+g1z]*
Val(mx,my,mz);
1089 for(
int gx=0;gx<NGrid;gx++){
1090 for(
int gy=0;gy<NGrid;gy++){
1091 for(
int gz=0;gz<NGrid;gz++){
1092 Plot[(gx*NGrid+gy)*NGrid+gz] = Plot2[(gx*NGrid+gy)*NGrid+gz];
void FillGaussian5()
Fill the entries for the 5x5 Gauss blur.
double a4
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
int pNCol()
Number of columns.
void RandomFill(double Max)
Fill the entries randomly.
int Solve(double *Known, double *UnKnown)
Solve a system A|b = y.
int getNRow()
Return size.
void copymatrix(Matrice &source)
Copy matrix.
Matrice operator=(Matrice &)
Copy two matrices.
Geometrical operations on vectors.
void CopyOn(Matrice *B)
Copy on a matrix.
void FillDiffOperator(SPLINE Wg, int NDim)
Fill the entries of a differential operator.
void Mult(Matrice &A, Matrice &B)
Multiplication between two matrices.
Matrice operator*(Matrice &A)
Multiplies two matrices.
void ConvoluteMatrix2(double *Plot, int NGrid)
Convolute with a matrix.
double Det()
Computes the determinants.
double * x
Where the data are stored.
void ConvoluteMatrix(double *Plot, int NGrid, int NDim, int IfMinImConv)
Convolute with a matrix.
double x
First basis component.
void ConvoluteMatrix3(double *Plot, int NGrid)
Convolute with a matrix.
void Clear()
Set all the entries to zero.
void Normalize()
Normalize the matrix.
double a3
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
double y
Second basis component.
void Transpose()
Transpose the matrix.
void ConvoluteMatrix1(double *Plot, int NGrid)
Convolute with a matrix.
void Multiply(double Val)
Multiply by a scalar.
double Val(int row)
Returns a value in 1d.
void ConvoluteMatrix2MinImConv(double *Plot, int NGrid)
Convolute with a matrix.
void setNRow(int newNRow)
Set new size.
void settoproduct(Matrice &left, Matrice &right)
Set to product.
bool Add(int row, int col, double Val)
Add the value of the coefficient to the previous one.
void FillGaussian(double Sigma, double CutOff)
Fill the entries for the Gauss blur.
double a2
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
double a1
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
Matrice operator^(Matrice &) const
Tensor product?
Matrice computes the algebric operations on matrices.
bool Set(int row, int column, double Val)
Set a coefficient.
void Apply(double *Known, double *UnKnown)
Apply Ax = y.
int NDim
Dimension allocated.
double w
Forth basis component.
double z
Third basis component.
Matrice operator+(Matrice &)
Sums two matrices.
int pNZed()
Number of zed.
int pNRow()
Number of rows.
void getvalue(int row, int column, double &returnvalue, bool &success)
Return value.
double a0
a0 + a1*x + a2*x^2 + a3*x^3 + a4^4
void FillCanny()
Fill the entries for the Canny edge detector.
void Print()
Print the entries.
void comparetoidentity()
Compare to identity.
double * data
Stored entries.
void Shout(const char *s,...)
Name of the last function called. For debugging.
Matrice(int newNSize)
creates a square Matrice
void ConvoluteMatrix1MinImConv(double *Plot, int NGrid)
Convolute with a matrix.