version 1.15, 2005/12/21 23:18:16 |
version 1.16, 2009/11/24 04:34:30 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/engine/mat.c,v 1.14 2005/06/03 07:16:16 saito Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/mat.c,v 1.15 2005/12/21 23:18:16 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "../parse/parse.h" |
#include "../parse/parse.h" |
|
|
pointer *ab,*tb; |
pointer *ab,*tb; |
int a1row,a2row, a3row,a4row, a1col, a2col, a3col, a4col; |
int a1row,a2row, a3row,a4row, a1col, a2col, a3col, a4col; |
int b1row,b2row, b3row,b4row, b1col, b2col, b3col, b4col; |
int b1row,b2row, b3row,b4row, b1col, b2col, b3col, b4col; |
int pflag1, pflag2; |
int pflag1, pflag2, pflag3; |
/* mismach col and row */ |
/* mismach col and row */ |
if ( a->col != b->row ) { |
if ( a->col != b->row ) { |
*c = 0; error("mulmat : size mismatch"); |
*c = 0; error("mulmat : size mismatch"); |
} |
} |
else { |
else { |
pflag1 = 0; pflag2 = 0; |
pflag1 = 0; pflag2 = 0; pflag3 = 0; |
arow = a->row; m = a->col; bcol = b->col; |
arow = a->row; m = a->col; bcol = b->col; |
MKMAT(t,arow,bcol); |
MKMAT(t,arow,bcol); |
/* StrassenSize == 0 or matrix size less then StrassenSize, |
/* StrassenSize == 0 or matrix size less then StrassenSize, |
|
|
pflag2 = 1; |
pflag2 = 1; |
} |
} |
|
|
|
i = bcol/2; |
|
j = bcol - i; |
|
if (i != j) { |
|
bcol++; |
|
pflag3 = 1; |
|
} |
|
|
/* split matrix A and B */ |
/* split matrix A and B */ |
a1row = arow/2; a1col = m/2; |
a1row = arow/2; a1col = m/2; |
MKMAT(a11,a1row,a1col); |
MKMAT(a11,a1row,a1col); |
|
|
b22->body[i-b1row][j-b1col] = b->body[i][j]; |
b22->body[i-b1row][j-b1col] = b->body[i][j]; |
} |
} |
} |
} |
|
|
|
/* extension by zero */ |
|
if (pflag1) { |
|
for (j = 0; j < a1col; j++) { |
|
a21->body[a1row-1][j] = 0; /* null */ |
|
} |
|
for (j = a1col; j < a->col; j++) { |
|
a22->body[a1row-1][j-a1col] = 0; |
|
} |
|
} |
|
if (pflag2) { |
|
for (i = 0; i < a1row; i++) { |
|
a12->body[i][a1col-1] = 0; |
|
} |
|
for (i = a1row; i < a->row; i++) { |
|
a22->body[i-a1row][a1col-1] = 0; |
|
} |
|
for (j = 0; j < b1col; j++) { |
|
b21->body[b1row-1][j] = 0; |
|
} |
|
for (j = b1col; j < b->col; j++) { |
|
b22->body[b1row-1][j-b1col] = 0; |
|
} |
|
} |
|
if (pflag3) { |
|
for (i = 0; i < b1row; i++) { |
|
b12->body[i][b1col-1] = 0; |
|
} |
|
for (i = b1row; i < b->row; i++) { |
|
b22->body[i-b1row][b1col-1] = 0; |
|
} |
|
} |
|
|
/* expand matrix by Strassen-Winograd algorithm */ |
/* expand matrix by Strassen-Winograd algorithm */ |
/* s1=A21+A22 */ |
/* s1=A21+A22 */ |
addmat(vl,a21,a22,&s1); |
addmat(vl,a21,a22,&s1); |