Main Page | Namespace List | Class List | File List | Class Members | File Members

MyBlas.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Claudio Attaccalite                             *
00003  *   claudio@freescience.info                                              *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include "MyBlas.h"
00022 
00025 void dgemm(double alpha,DMatrix &A,DMatrix &B,double beta,DMatrix &C)
00026 {
00027 int m=A.dim1();
00028 int n=B.dim2();
00029 int k=B.dim1();
00030 int ldc=C.dim1();
00031 F77_FUNC(dgemm,DGEMM)("N","N",&m,&n,&k,&alpha,A.array(),&m,B.array(),&k,&beta,C.array(),&ldc);
00032 }
00033 
00034 void dgemm_n_t(double alpha,DMatrix &A,DMatrix &B,double beta,DMatrix &C)
00035 {
00036 int m=A.dim1();
00037 int n=B.dim1();
00038 int k=A.dim2();
00039 int ldc=C.dim1();
00040 F77_FUNC(dgemm,DGEMM)("N","T",&m,&n,&k,&alpha,A.array(),&m,B.array(),&n,&beta,C.array(),&ldc);
00041 }
00042 
00043 void dgemm_t_t(double alpha,DMatrix &A,DMatrix &B,double beta,DMatrix &C)
00044 {
00045 int m=A.dim2();
00046 int n=B.dim1();
00047 int k=A.dim1();
00048 int ldc=C.dim1();
00049 F77_FUNC(dgemm,DGEMM)("T","T",&m,&n,&k,&alpha,A.array(),&k,B.array(),&n,&beta,C.array(),&ldc);
00050 }
00051 
00052 void dgemm_t_n(double alpha,DMatrix &A,DMatrix &B,double beta,DMatrix &C)
00053 {
00054 int m=A.dim2();
00055 int k=A.dim1();
00056 int n=B.dim2();
00057 int ldb=B.dim1();
00058 int ldc=C.dim1();
00059 F77_FUNC(dgemm,DGEMM)("T","N",&m,&n,&k,&alpha,A.array(),&k,B.array(),&ldb,&beta,C.array(),&ldc);
00060 }
00061 
00062 
00063 void dgemv(double alpha,DMatrix &A,DVector &X,double beta,DVector &Y)
00064 {
00065 int m=A.dim2();
00066 int n=A.dim1();
00067 int one=1;
00068 F77_FUNC(dgemv,DGEMV)("N",&n,&m,&alpha,A.array(),&n,X.array(),&one,&beta,Y.array(),&one);
00069 }
00070 
00071 void dgemv_t(double alpha,DMatrix &A,DVector &X,double beta,DVector &Y)
00072 {
00073 int n=A.dim2();
00074 int m=A.dim1();
00075 int one=1;
00076 F77_FUNC(dgemv,DGEMV)("T",&m,&n,&alpha,A.array(),&m,X.array(),&one,&beta,Y.array(),&one);
00077 }
00078 
00081 void sgemm(float alpha,SMatrix &A,SMatrix &B,float beta,SMatrix &C)
00082 {
00083 int m=A.dim1();
00084 int n=B.dim2();
00085 int k=B.dim1();
00086 int ldc=C.dim1();
00087 F77_FUNC(sgemm,SGEMM)("N","N",&m,&n,&k,&alpha,A.array(),&m,B.array(),&k,&beta,C.array(),&ldc);
00088 }
00089 
00090 void sgemm_n_t(float alpha,SMatrix &A,SMatrix &B,float beta,SMatrix &C)
00091 {
00092 int m=A.dim1();
00093 int n=B.dim1();
00094 int k=A.dim2();
00095 int ldc=C.dim1();
00096 F77_FUNC(sgemm,SGEMM)("N","T",&m,&n,&k,&alpha,A.array(),&m,B.array(),&n,&beta,C.array(),&ldc);
00097 }
00098 
00099 void sgemm_t_t(float alpha,SMatrix &A,SMatrix &B,float beta,SMatrix &C)
00100 {
00101 int m=A.dim2();
00102 int n=B.dim1();
00103 int k=A.dim1();
00104 int ldc=C.dim1();
00105 F77_FUNC(sgemm,SGEMM)("T","T",&m,&n,&k,&alpha,A.array(),&k,B.array(),&n,&beta,C.array(),&ldc);
00106 }
00107 
00108 void sgemm_t_n(float alpha,SMatrix &A,SMatrix &B,float beta,SMatrix &C)
00109 {
00110 int m=A.dim2();
00111 int k=A.dim1();
00112 int n=B.dim2();
00113 int ldb=B.dim1();
00114 int ldc=C.dim1();
00115 F77_FUNC(sgemm,SGEMM)("T","N",&m,&n,&k,&alpha,A.array(),&k,B.array(),&ldb,&beta,C.array(),&ldc);
00116 }
00117 
00118 void sgemv(float alpha,SMatrix &A,SVector &X,float beta,SVector &Y)
00119 {
00120 int n=A.dim2();
00121 int m=A.dim1();
00122 int one=1;
00123 F77_FUNC(sgemv,SGEMV)("N",&n,&m,&alpha,A.array(),&n,X.array(),&one,&beta,Y.array(),&one);
00124 }
00125 
00126 void sgemv_t(float alpha,SMatrix &A,SVector &X,float beta,SVector &Y)
00127 {
00128 int n=A.dim2();
00129 int m=A.dim1();
00130 int one=1;
00131 F77_FUNC(sgemv,SGEMV)("T",&n,&m,&alpha,A.array(),&n,X.array(),&one,&beta,Y.array(),&one);
00132 }
00133 
00134 
00135 /******** Complex BLAS ***************/
00136 void zgemv(complex<double> alpha,ZMatrix &A,ZVector &X,complex<double> beta,ZVector &Y)
00137 {
00138 int m=A.dim2();
00139 int n=A.dim1();
00140 int one=1;
00141 F77_FUNC(zgemv,ZGEMV)("N",&n,&m,(double*)&alpha,(double*)A.array(),&n,(double*)X.array(),&one,(double*)&beta,(double*)Y.array(),&one);
00142 }
00143 
00144 void zgemv_t(complex<double> alpha,ZMatrix &A,ZVector &X,complex<double> beta,ZVector &Y)
00145 {
00146 int n=A.dim2();
00147 int m=A.dim1();
00148 int one=1;
00149 F77_FUNC(dgemv,DGEMV)("T",&m,&n,(double*)&alpha,(double*)A.array(),&m,(double*)X.array(),&one,(double*)&beta,(double*)Y.array(),&one);
00150 }
00151 
00152 void zgemv_c(complex<double> alpha,ZMatrix &A,ZVector &X,complex<double> beta,ZVector &Y)
00153 {
00154 int n=A.dim2();
00155 int m=A.dim1();
00156 int one=1;
00157 F77_FUNC(dgemv,DGEMV)("C",&m,&n,(double*)&alpha,(double*)A.array(),&m,(double*)X.array(),&one,(double*)&beta,(double*)Y.array(),&one);
00158 }
00159 
00160 void zgemm(complex<double> alpha,ZMatrix &A,ZMatrix &B,complex<double> beta,ZMatrix &C)
00161 {
00162 int m=A.dim1();
00163 int n=B.dim2();
00164 int k=B.dim1();
00165 int ldc=C.dim1();
00166 F77_FUNC(zgemm,ZGEMM)("N","N",&m,&n,&k,(double*)&alpha,(double*)A.array(),&m,(double*)B.array(),&k,(double*)&beta,(double*)C.array(),&ldc);
00167 }
00168 
00169 void zgemm_n_t(complex<double> alpha,ZMatrix &A,ZMatrix &B,complex<double> beta,ZMatrix &C)
00170 {
00171 int m=A.dim1();
00172 int n=B.dim1();
00173 int k=A.dim2();
00174 int ldc=C.dim1();
00175 F77_FUNC(zgemm,ZGEMM)("N","T",&m,&n,&k,(double*)&alpha,(double*)A.array(),&m,(double*)B.array(),&n,(double*)&beta,(double*)C.array(),&ldc);
00176 }
00177 
00178 void zgemm_t_t(complex<double> alpha,ZMatrix &A,ZMatrix &B,complex<double> beta,ZMatrix &C)
00179 {
00180 int m=A.dim2();
00181 int n=B.dim1();
00182 int k=A.dim1();
00183 int ldc=C.dim1();
00184 F77_FUNC(zgemm,ZGEMM)("T","T",&m,&n,&k,(double*)&alpha,(double*)A.array(),&k,(double*)B.array(),&n,(double*)&beta,(double*)C.array(),&ldc);
00185 }
00186 
00187 void zgemm_t_n(complex<double> alpha,ZMatrix &A,ZMatrix &B,complex<double> beta,ZMatrix &C)
00188 {
00189 int m=A.dim2();
00190 int k=A.dim1();
00191 int n=B.dim2();
00192 int ldb=B.dim1();
00193 int ldc=C.dim1();
00194 F77_FUNC(zgemm,ZGEMM)("T","N",&m,&n,&k,(double*)&alpha,(double*)A.array(),&k,(double*)B.array(),&ldb,(double*)&beta,(double*)C.array(),&ldc);
00195 }
00196 /******* More with C *********/
00197 
00198 void zgemm_n_c(complex<double> alpha,ZMatrix &A,ZMatrix &B,complex<double> beta,ZMatrix &C)
00199 {
00200 int m=A.dim1();
00201 int n=B.dim1();
00202 int k=A.dim2();
00203 int ldc=C.dim1();
00204 F77_FUNC(zgemm,ZGEMM)("N","C",&m,&n,&k,(double*)&alpha,(double*)A.array(),&m,(double*)B.array(),&n,(double*)&beta,(double*)C.array(),&ldc);
00205 }
00206 
00207 void zgemm_c_c(complex<double> alpha,ZMatrix &A,ZMatrix &B,complex<double> beta,ZMatrix &C)
00208 {
00209 int m=A.dim2();
00210 int n=B.dim1();
00211 int k=A.dim1();
00212 int ldc=C.dim1();
00213 F77_FUNC(zgemm,ZGEMM)("C","C",&m,&n,&k,(double*)&alpha,(double*)A.array(),&k,(double*)B.array(),&n,(double*)&beta,(double*)C.array(),&ldc);
00214 }
00215 
00216 void zgemm_c_n(complex<double> alpha,ZMatrix &A,ZMatrix &B,complex<double> beta,ZMatrix &C)
00217 {
00218 int m=A.dim2();
00219 int k=A.dim1();
00220 int n=B.dim2();
00221 int ldb=B.dim1();
00222 int ldc=C.dim1();
00223 F77_FUNC(zgemm,ZGEMM)("C","N",&m,&n,&k,(double*)&alpha,(double*)A.array(),&k,(double*)B.array(),&ldb,(double*)&beta,(double*)C.array(),&ldc);
00224 }
00225 
00226 void zgemm_c_t(complex<double> alpha,ZMatrix &A,ZMatrix &B,complex<double> beta,ZMatrix &C)
00227 {
00228 int m=A.dim2();
00229 int n=B.dim1();
00230 int k=A.dim1();
00231 int ldc=C.dim1();
00232 F77_FUNC(zgemm,ZGEMM)("C","T",&m,&n,&k,(double*)&alpha,(double*)A.array(),&k,(double*)B.array(),&n,(double*)&beta,(double*)C.array(),&ldc);
00233 }
00234 
00235 void zgemm_t_c(complex<double> alpha,ZMatrix &A,ZMatrix &B,complex<double> beta,ZMatrix &C)
00236 {
00237 int m=A.dim2();
00238 int n=B.dim1();
00239 int k=A.dim1();
00240 int ldc=C.dim1();
00241 F77_FUNC(zgemm,ZGEMM)("T","C",&m,&n,&k,(double*)&alpha,(double*)A.array(),&k,(double*)B.array(),&n,(double*)&beta,(double*)C.array(),&ldc);
00242 }
00243 

Generated on Wed Aug 16 19:03:50 2006 for MyLapack by  doxygen 1.4.4