| version 1.1.1.1, 1999/10/08 02:12:02 |
version 1.3, 2001/05/04 01:06:24 |
|
|
| |
/* $OpenXM: OpenXM/src/kan96xx/Kan/matrix.c,v 1.2 2000/01/16 07:55:39 takayama Exp $ */ |
| /* matrix.c */ |
/* matrix.c */ |
| #include <stdio.h> |
#include <stdio.h> |
| #include "datatype.h" |
#include "datatype.h" |
|
|
| #include "extern2.h" |
#include "extern2.h" |
| |
|
| #include "matrix.h" /* ind() and ind2() are defined. */ |
#include "matrix.h" /* ind() and ind2() are defined. */ |
| /* You must use n and n2. */ |
/* You must use n and n2. */ |
| |
|
| struct arrayOfPOLY *aaAdd(aa,bb) |
struct arrayOfPOLY *aaAdd(aa,bb) |
| struct arrayOfPOLY *aa,*bb; |
struct arrayOfPOLY *aa,*bb; |
| /* this function has not been tested yet. */ |
/* this function has not been tested yet. */ |
| { |
{ |
| int i; |
int i; |
| POLY *r; |
POLY *r; |
| Line 32 struct arrayOfPOLY *aa,*bb; |
|
| Line 33 struct arrayOfPOLY *aa,*bb; |
|
| } |
} |
| |
|
| struct matrixOfPOLY *aaMult(aa,bb) |
struct matrixOfPOLY *aaMult(aa,bb) |
| struct matrixOfPOLY *aa,*bb; |
struct matrixOfPOLY *aa,*bb; |
| { |
{ |
| POLY *a; |
POLY *a; |
| POLY *b; |
POLY *b; |
| Line 53 struct matrixOfPOLY *aa,*bb; |
|
| Line 54 struct matrixOfPOLY *aa,*bb; |
|
| for (j=0; j<n2; j++) { |
for (j=0; j<n2; j++) { |
| tmp = ZERO; |
tmp = ZERO; |
| for (k=0; k<n; k++) { |
for (k=0; k<n; k++) { |
| tmp = ppAddv(tmp, ppMult( a[ind(i,k)], b[ind2(k,j)])); |
tmp = ppAddv(tmp, ppMult( a[ind(i,k)], b[ind2(k,j)])); |
| } |
} |
| r[ind2(i,j)] = tmp; |
r[ind2(i,j)] = tmp; |
| } |
} |
| Line 68 struct matrixOfPOLY *aa,*bb; |
|
| Line 69 struct matrixOfPOLY *aa,*bb; |
|
| |
|
| /**************** error handler ************************/ |
/**************** error handler ************************/ |
| void errorMatrix(str) |
void errorMatrix(str) |
| char *str; |
char *str; |
| { |
{ |
| fprintf(stderr,"matrix.c: %s\n",str); |
fprintf(stderr,"matrix.c: %s\n",str); |
| exit(10); |
exit(10); |
|
|
| /********************************************************/ |
/********************************************************/ |
| |
|
| struct arrayOfPOLY *newArrayOfPOLY(size) |
struct arrayOfPOLY *newArrayOfPOLY(size) |
| int size; |
int size; |
| /* if size<=0, it returns [0,null]. */ |
/* if size<=0, it returns [0,null]. */ |
| { |
{ |
| struct arrayOfPOLY *ap; |
struct arrayOfPOLY *ap; |
| ap = (struct arrayOfPOLY *)sGC_malloc(sizeof(struct arrayOfPOLY)); |
ap = (struct arrayOfPOLY *)sGC_malloc(sizeof(struct arrayOfPOLY)); |
|
|
| } |
} |
| |
|
| struct matrixOfPOLY *newMatrixOfPOLY(m,n) |
struct matrixOfPOLY *newMatrixOfPOLY(m,n) |
| int m,n; |
int m,n; |
| /* if size<=0, it returns [0,null]. */ |
/* if size<=0, it returns [0,null]. */ |
| { |
{ |
| struct matrixOfPOLY *ap; |
struct matrixOfPOLY *ap; |
| ap = (struct matrixOfPOLY *)sGC_malloc(sizeof(struct matrixOfPOLY)); |
ap = (struct matrixOfPOLY *)sGC_malloc(sizeof(struct matrixOfPOLY)); |
|
|
| |
|
| |
|
| struct arrayOfPOLY *carrayToArrayOfPOLY(a,size) |
struct arrayOfPOLY *carrayToArrayOfPOLY(a,size) |
| POLY a[]; |
POLY a[]; |
| int size; |
int size; |
| /* a[] is read only. */ |
/* a[] is read only. */ |
| { |
{ |
| struct arrayOfPOLY *ans; |
struct arrayOfPOLY *ans; |
| int i; |
int i; |