version 1.2, 2003/02/22 07:22:16 |
version 1.3, 2018/03/29 01:32:50 |
|
|
/* |
/* |
* $OpenXM$ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/mattran.c,v 1.2 2003/02/22 07:22:16 saito Exp $ |
*/ |
*/ |
|
|
#include "ca.h" |
#include "ca.h" |
Line 20 static void BodyColExh(MAT, int, int); |
|
Line 20 static void BodyColExh(MAT, int, int); |
|
static void BodyColMulAdd(MAT, int, int, pointer); |
static void BodyColMulAdd(MAT, int, int, pointer); |
|
|
struct ftab mat_tab[] = { |
struct ftab mat_tab[] = { |
{"mfund",MatFund,-5}, |
{"mfund",MatFund,-5}, |
{"rowm",RowMul,3}, |
{"rowm",RowMul,3}, |
{"rowx",RowExh,3}, |
{"rowx",RowExh,3}, |
{"rowa",RowMulAdd,4}, |
{"rowa",RowMulAdd,4}, |
{"colm",ColMul,3}, |
{"colm",ColMul,3}, |
{"colx",ColExh,3}, |
{"colx",ColExh,3}, |
{"cola",ColMulAdd,4}, |
{"cola",ColMulAdd,4}, |
{0,0,0}, |
{0,0,0}, |
}; |
}; |
|
|
static void |
static void |
|
|
NODE arg; |
NODE arg; |
Obj *rp; |
Obj *rp; |
{ |
{ |
MAT mat; |
MAT mat; |
pointer *coe; |
pointer *coe; |
Q rowq, row2q, colq, col2q; |
Q rowq, row2q, colq, col2q; |
int sw, row, row2, col, col2; |
int sw, row, row2, col, col2; |
sw = QTOS( (Q)ARG0(arg) ); |
sw = QTOS( (Q)ARG0(arg) ); |
mat = (MAT)ARG1(arg); |
mat = (MAT)ARG1(arg); |
switch (sw) { |
switch (sw) { |
case 1: |
case 1: |
rowq = (Q)ARG2(arg); |
rowq = (Q)ARG2(arg); |
row = QTOS( rowq ); |
row = QTOS( rowq ); |
coe = (pointer)ARG3(arg); |
coe = (pointer)ARG3(arg); |
BodyRowMul( mat, row, coe ); |
BodyRowMul( mat, row, coe ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
return; |
return; |
case 2: |
case 2: |
rowq = (Q)ARG2(arg); |
rowq = (Q)ARG2(arg); |
row = QTOS( rowq ); |
row = QTOS( rowq ); |
row2q = (Q)ARG3(arg); |
row2q = (Q)ARG3(arg); |
row2 = QTOS( row2q ); |
row2 = QTOS( row2q ); |
BodyRowExh( mat, row, row2 ); |
BodyRowExh( mat, row, row2 ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
return; |
return; |
case 3: |
case 3: |
rowq = (Q)ARG2(arg); |
rowq = (Q)ARG2(arg); |
row = QTOS( rowq ); |
row = QTOS( rowq ); |
row2q = (Q)ARG3(arg); |
row2q = (Q)ARG3(arg); |
row2 = QTOS( row2q ); |
row2 = QTOS( row2q ); |
coe = (pointer)ARG3(arg); |
coe = (pointer)ARG3(arg); |
BodyRowMulAdd( mat, row, row2, coe ); |
BodyRowMulAdd( mat, row, row2, coe ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
return; |
return; |
case 4: |
case 4: |
colq = (Q)ARG2(arg); |
colq = (Q)ARG2(arg); |
col = QTOS( colq ); |
col = QTOS( colq ); |
coe = (pointer)ARG3(arg); |
coe = (pointer)ARG3(arg); |
BodyColMul( mat, col, coe ); |
BodyColMul( mat, col, coe ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
return; |
return; |
case 5: |
case 5: |
colq = (Q)ARG2(arg); |
colq = (Q)ARG2(arg); |
col = QTOS( colq ); |
col = QTOS( colq ); |
col2q = (Q)ARG3(arg); |
col2q = (Q)ARG3(arg); |
col2 = QTOS( col2q ); |
col2 = QTOS( col2q ); |
BodyColExh( mat, col, col2 ); |
BodyColExh( mat, col, col2 ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
return; |
return; |
case 6: |
case 6: |
colq = (Q)ARG2(arg); |
colq = (Q)ARG2(arg); |
col = QTOS( colq ); |
col = QTOS( colq ); |
col2q = (Q)ARG3(arg); |
col2q = (Q)ARG3(arg); |
col2 = QTOS( col2q ); |
col2 = QTOS( col2q ); |
coe = (pointer)ARG3(arg); |
coe = (pointer)ARG3(arg); |
BodyColMulAdd( mat, col, col2, coe ); |
BodyColMulAdd( mat, col, col2, coe ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
default: |
default: |
return; |
return; |
*rp = 0; |
*rp = 0; |
} |
} |
} |
} |
|
|
static void |
static void |
|
|
NODE arg; |
NODE arg; |
Obj *rp; |
Obj *rp; |
{ |
{ |
MAT mat; |
MAT mat; |
Q rowq; |
Q rowq; |
pointer *coe; |
pointer *coe; |
int row; |
int row; |
|
|
mat = (MAT)ARG0(arg); |
mat = (MAT)ARG0(arg); |
rowq = (Q)ARG1(arg); |
rowq = (Q)ARG1(arg); |
row = QTOS( rowq ); |
row = QTOS( rowq ); |
coe = (pointer)ARG2(arg); |
coe = (pointer)ARG2(arg); |
BodyRowMul( mat, row , coe ); |
BodyRowMul( mat, row , coe ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
} |
} |
|
|
static void |
static void |
|
|
NODE arg; |
NODE arg; |
Obj *rp; |
Obj *rp; |
{ |
{ |
MAT mat; |
MAT mat; |
Q QIndexA, QIndexB; |
Q QIndexA, QIndexB; |
int IndexA, IndexB; |
int IndexA, IndexB; |
|
|
mat = (MAT)ARG0(arg); |
mat = (MAT)ARG0(arg); |
QIndexA = (Q)ARG1(arg); |
QIndexA = (Q)ARG1(arg); |
QIndexB = (Q)ARG2(arg); |
QIndexB = (Q)ARG2(arg); |
IndexA = QTOS( QIndexA ); |
IndexA = QTOS( QIndexA ); |
IndexB = QTOS( QIndexB ); |
IndexB = QTOS( QIndexB ); |
BodyRowExh( mat, IndexA, IndexB ); |
BodyRowExh( mat, IndexA, IndexB ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
} |
} |
|
|
static void |
static void |
Line 136 RowMulAdd(arg, rp) |
|
Line 136 RowMulAdd(arg, rp) |
|
NODE arg; |
NODE arg; |
Obj *rp; |
Obj *rp; |
{ |
{ |
MAT mat; |
MAT mat; |
Q QIndexA, QIndexB; |
Q QIndexA, QIndexB; |
int IndexA, IndexB; |
int IndexA, IndexB; |
pointer *coe; |
pointer *coe; |
|
|
mat = (MAT)ARG0(arg); |
mat = (MAT)ARG0(arg); |
QIndexA = (Q)ARG1(arg); |
QIndexA = (Q)ARG1(arg); |
QIndexB = (Q)ARG2(arg); |
QIndexB = (Q)ARG2(arg); |
coe = (pointer)ARG3(arg); |
coe = (pointer)ARG3(arg); |
IndexA = QTOS( QIndexA ); |
IndexA = QTOS( QIndexA ); |
IndexB = QTOS( QIndexB ); |
IndexB = QTOS( QIndexB ); |
BodyRowMulAdd( mat, IndexA, IndexB, coe ); |
BodyRowMulAdd( mat, IndexA, IndexB, coe ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
} |
} |
|
|
static void |
static void |
|
|
NODE arg; |
NODE arg; |
Obj *rp; |
Obj *rp; |
{ |
{ |
MAT mat; |
MAT mat; |
Q QIndex; |
Q QIndex; |
pointer *coe; |
pointer *coe; |
int Index; |
int Index; |
|
|
mat = (MAT)ARG0(arg); |
mat = (MAT)ARG0(arg); |
QIndex = (Q)ARG1(arg); |
QIndex = (Q)ARG1(arg); |
Index = QTOS( QIndex ); |
Index = QTOS( QIndex ); |
coe = (pointer)ARG2(arg); |
coe = (pointer)ARG2(arg); |
BodyColMul( mat, Index , coe ); |
BodyColMul( mat, Index , coe ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
} |
} |
|
|
static void |
static void |
|
|
NODE arg; |
NODE arg; |
Obj *rp; |
Obj *rp; |
{ |
{ |
MAT mat; |
MAT mat; |
Q QIndexA, QIndexB; |
Q QIndexA, QIndexB; |
int IndexA, IndexB; |
int IndexA, IndexB; |
|
|
mat = (MAT)ARG0(arg); |
mat = (MAT)ARG0(arg); |
QIndexA = (Q)ARG1(arg); |
QIndexA = (Q)ARG1(arg); |
QIndexB = (Q)ARG2(arg); |
QIndexB = (Q)ARG2(arg); |
IndexA = QTOS( QIndexA ); |
IndexA = QTOS( QIndexA ); |
IndexB = QTOS( QIndexB ); |
IndexB = QTOS( QIndexB ); |
BodyColExh( mat, IndexA, IndexB ); |
BodyColExh( mat, IndexA, IndexB ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
} |
} |
|
|
static void |
static void |
Line 192 ColMulAdd(arg, rp) |
|
Line 192 ColMulAdd(arg, rp) |
|
NODE arg; |
NODE arg; |
Obj *rp; |
Obj *rp; |
{ |
{ |
MAT mat; |
MAT mat; |
Q QIndexA, QIndexB; |
Q QIndexA, QIndexB; |
int IndexA, IndexB; |
int IndexA, IndexB; |
pointer *coe; |
pointer *coe; |
|
|
mat = (MAT)ARG0(arg); |
mat = (MAT)ARG0(arg); |
QIndexA = (Q)ARG1(arg); |
QIndexA = (Q)ARG1(arg); |
QIndexB = (Q)ARG2(arg); |
QIndexB = (Q)ARG2(arg); |
coe = (pointer)ARG3(arg); |
coe = (pointer)ARG3(arg); |
IndexA = QTOS( QIndexA ); |
IndexA = QTOS( QIndexA ); |
IndexB = QTOS( QIndexB ); |
IndexB = QTOS( QIndexB ); |
BodyColMulAdd( mat, IndexA, IndexB, coe ); |
BodyColMulAdd( mat, IndexA, IndexB, coe ); |
*rp = (Obj)mat; |
*rp = (Obj)mat; |
} |
} |
|
|
static void |
static void |
|
|
int row; |
int row; |
pointer coe; |
pointer coe; |
{ |
{ |
int size, i; |
int size, i; |
pointer *t, *matrow; |
pointer *t, *matrow; |
|
|
size = mat->col; |
size = mat->col; |
matrow = BDY(mat)[row]; |
matrow = BDY(mat)[row]; |
for ( i = 0; i < size; i++ ) { |
for ( i = 0; i < size; i++ ) { |
mulr(CO,(Obj)matrow[i],(Obj)coe,(Obj *)&t); |
mulr(CO,(Obj)matrow[i],(Obj)coe,(Obj *)&t); |
matrow[i]=(Obj)t; |
matrow[i]=(Obj)t; |
} |
} |
} |
} |
|
|
static void |
static void |
Line 229 BodyRowExh( mat, IndexA, IndexB ) |
|
Line 229 BodyRowExh( mat, IndexA, IndexB ) |
|
MAT mat; |
MAT mat; |
int IndexA, IndexB; |
int IndexA, IndexB; |
{ |
{ |
int i, size; |
int i, size; |
pointer *t, *PRowA, *PRowB; |
pointer *t, *PRowA, *PRowB; |
|
|
size = mat->col; |
size = mat->col; |
PRowA = BDY(mat)[IndexA]; |
PRowA = BDY(mat)[IndexA]; |
PRowB = BDY(mat)[IndexB]; |
PRowB = BDY(mat)[IndexB]; |
for ( i = 0; i < size; i++ ) { |
for ( i = 0; i < size; i++ ) { |
t = PRowA[i]; |
t = PRowA[i]; |
PRowA[i] = PRowB[i]; |
PRowA[i] = PRowB[i]; |
PRowB[i] = t; |
PRowB[i] = t; |
} |
} |
} |
} |
|
|
static void |
static void |
|
|
int IndexA, IndexB; |
int IndexA, IndexB; |
pointer coe; |
pointer coe; |
{ |
{ |
int i, size; |
int i, size; |
pointer *t, *PRowA, *PRowB; |
pointer *t, *PRowA, *PRowB; |
|
|
size = mat->col; |
size = mat->col; |
PRowA = BDY(mat)[IndexA]; |
PRowA = BDY(mat)[IndexA]; |
PRowB = BDY(mat)[IndexB]; |
PRowB = BDY(mat)[IndexB]; |
|
|
for ( i = 0; i < size; i++ ) { |
for ( i = 0; i < size; i++ ) { |
mulr( CO, (Obj)PRowB[i], (Obj)coe, (Obj *)&t ); |
mulr( CO, (Obj)PRowB[i], (Obj)coe, (Obj *)&t ); |
addr( CO, (Obj)PRowA[i], (Obj)t, (Obj *)&t ); |
addr( CO, (Obj)PRowA[i], (Obj)t, (Obj *)&t ); |
PRowA[i] = t; |
PRowA[i] = t; |
} |
} |
} |
} |
|
|
static void |
static void |
|
|
int Index; |
int Index; |
pointer coe; |
pointer coe; |
{ |
{ |
int size, i; |
int size, i; |
|
|
size = mat->row; |
size = mat->row; |
for ( i = 0; i < size; i++ ) { |
for ( i = 0; i < size; i++ ) { |
mulr(CO, BDY(mat)[i][Index], (Obj)coe, (Obj *)&BDY(mat)[i][Index]); |
mulr(CO, BDY(mat)[i][Index], (Obj)coe, (Obj *)&BDY(mat)[i][Index]); |
} |
} |
} |
} |
|
|
static void |
static void |
Line 281 BodyColExh( mat, IndexA, IndexB ) |
|
Line 281 BodyColExh( mat, IndexA, IndexB ) |
|
MAT mat; |
MAT mat; |
int IndexA, IndexB; |
int IndexA, IndexB; |
{ |
{ |
int i, size; |
int i, size; |
pointer *t; |
pointer *t; |
|
|
size = mat->row; |
size = mat->row; |
for ( i = 0; i < size; i++ ) { |
for ( i = 0; i < size; i++ ) { |
t = BDY(mat)[i][IndexA]; |
t = BDY(mat)[i][IndexA]; |
BDY(mat)[i][IndexA] = BDY(mat)[i][IndexB]; |
BDY(mat)[i][IndexA] = BDY(mat)[i][IndexB]; |
BDY(mat)[i][IndexB] = t; |
BDY(mat)[i][IndexB] = t; |
} |
} |
} |
} |
|
|
static void |
static void |
|
|
int IndexA, IndexB; |
int IndexA, IndexB; |
pointer coe; |
pointer coe; |
{ |
{ |
int i, size; |
int i, size; |
pointer *t; |
pointer *t; |
|
|
size = mat->row; |
size = mat->row; |
for ( i = 0; i < size; i++ ) { |
for ( i = 0; i < size; i++ ) { |
mulr( CO, BDY(mat)[i][IndexB], coe, (Obj *)&t ); |
mulr( CO, BDY(mat)[i][IndexB], coe, (Obj *)&t ); |
addr( CO, BDY(mat)[i][IndexA], (Obj)t, (Obj *)&BDY(mat)[i][IndexA]); |
addr( CO, BDY(mat)[i][IndexA], (Obj)t, (Obj *)&BDY(mat)[i][IndexA]); |
} |
} |
} |
} |