00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _math_scmat_mops_h
00029 #define _math_scmat_mops_h
00030
00031 #define D1 32
00032
00033
00034
00035
00036 static inline void
00037 copy_block(double **dest, double **source,
00038 int istart, int ni, int jstart, int nj)
00039 {
00040 int ii,jj;
00041
00042 for (ii=0; ii < ni; ii++) {
00043 double *di = dest[ii];
00044 double *si = &source[istart+ii][jstart];
00045 for (jj=0; jj < nj; jj++)
00046 di[jj] = si[jj];
00047 for (; jj < D1; jj++)
00048 di[jj] = 0;
00049 }
00050
00051 int left=D1-ii;
00052 if (left)
00053 memset(dest[ii], 0, sizeof(double)*left*D1);
00054 }
00055
00056 static inline void
00057 copy_trans_block(double **dest, double **source,
00058 int istart, int ni, int jstart, int nj)
00059 {
00060 int ii,jj;
00061
00062 memset(dest[0], 0, sizeof(double)*D1*D1);
00063
00064 for (jj=0; jj < nj; jj++) {
00065 double *sj = &source[jstart+jj][istart];
00066 for (ii=0; ii < ni; ii++)
00067 dest[ii][jj] = sj[ii];
00068 }
00069 }
00070
00071
00072
00073 static inline void
00074 copy_sym_block(double **dest, double **source,
00075 int istart, int ni, int jstart, int nj)
00076 {
00077 int ii,jj;
00078
00079 for (ii=0; ii < ni; ii++) {
00080 double *di = dest[ii];
00081 double *si = &source[istart+ii][jstart];
00082
00083 if (jstart < istart)
00084 for (jj=0; jj < nj; jj++)
00085 di[jj] = si[jj];
00086 else if (jstart==istart)
00087 for (jj=0; jj <= ii; jj++)
00088 di[jj] = dest[jj][ii] = si[jj];
00089 else
00090 for (jj=0; jj < nj; jj++)
00091 di[jj] = source[jstart+jj][istart+ii];
00092
00093 for (jj=nj; jj < D1; jj++)
00094 di[jj] = 0;
00095 }
00096
00097 int left=D1-ii;
00098 if (left)
00099 memset(dest[ii], 0, sizeof(double)*left*D1);
00100 }
00101
00102 static inline void
00103 return_block(double **dest, double **source,
00104 int istart, int ni, int jstart, int nj)
00105 {
00106 int ii,jj;
00107
00108 for (ii=0; ii < ni; ii++)
00109 for (jj=0; jj < nj; jj++)
00110 dest[istart+ii][jstart+jj] = source[ii][jj];
00111 }
00112
00113
00114 static inline void
00115 mult_block(double **a, double **b, double **c, int ni, int nj, int nk)
00116 {
00117 int ii,jj,kk;
00118 double t00,t10,t20,t30;
00119 double *a0, *a1, *a2, *a3;
00120 double *c0, *c1, *c2, *c3;
00121
00122 for (ii=0; ii < ni; ii += 4) {
00123 a0=a[ii]; a1=a[ii+1]; a2=a[ii+2]; a3=a[ii+3];
00124 c0=c[ii]; c1=c[ii+1]; c2=c[ii+2]; c3=c[ii+3];
00125
00126 for (jj=0; jj < nj; jj++) {
00127 double *bt = b[jj];
00128 t00=c0[jj]; t10=c1[jj]; t20=c2[jj]; t30=c3[jj];
00129
00130 for (kk=0; kk < nk; kk += 2) {
00131 register double b0=bt[kk], b1=bt[kk+1];
00132 t00 += a0[kk]*b0 + a0[kk+1]*b1;
00133 t10 += a1[kk]*b0 + a1[kk+1]*b1;
00134 t20 += a2[kk]*b0 + a2[kk+1]*b1;
00135 t30 += a3[kk]*b0 + a3[kk+1]*b1;
00136 }
00137
00138 c0[jj]=t00;
00139 c1[jj]=t10;
00140 c2[jj]=t20;
00141 c3[jj]=t30;
00142 }
00143 }
00144 }
00145
00146 #endif
00147
00148
00149
00150
00151