Blas.h

Go to the documentation of this file.
00001 //Copyright (c) 2004-2005, Baris Sumengen
00002 //All rights reserved.
00003 //
00004 // CIMPL Matrix Performance Library
00005 //
00006 //Redistribution and use in source and binary
00007 //forms, with or without modification, are
00008 //permitted provided that the following
00009 //conditions are met:
00010 //
00011 //    * No commercial use is allowed. 
00012 //    This software can only be used
00013 //    for non-commercial purposes. This 
00014 //    distribution is mainly intended for
00015 //    academic research and teaching.
00016 //    * Redistributions of source code must
00017 //    retain the above copyright notice, this
00018 //    list of conditions and the following
00019 //    disclaimer.
00020 //    * Redistributions of binary form must
00021 //    mention the above copyright notice, this
00022 //    list of conditions and the following
00023 //    disclaimer in a clearly visible part 
00024 //    in associated product manual, 
00025 //    readme, and web site of the redistributed 
00026 //    software.
00027 //    * Redistributions in binary form must
00028 //    reproduce the above copyright notice,
00029 //    this list of conditions and the
00030 //    following disclaimer in the
00031 //    documentation and/or other materials
00032 //    provided with the distribution.
00033 //    * The name of Baris Sumengen may not be
00034 //    used to endorse or promote products
00035 //    derived from this software without
00036 //    specific prior written permission.
00037 //
00038 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
00039 //HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
00040 //EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
00041 //NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00042 //MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00043 //PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00044 //CONTRIBUTORS BE LIABLE FOR ANY
00045 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00046 //EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00047 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00048 //OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00049 //DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00050 //HOWEVER CAUSED AND ON ANY THEORY OF
00051 //LIABILITY, WHETHER IN CONTRACT, STRICT
00052 //LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00053 //OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00054 //OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00055 //POSSIBILITY OF SUCH DAMAGE.
00056 
00057 
00058 
00059 #pragma once
00060 #ifndef BLAS_H
00061 #define BLAS_H
00062 
00063 #include "./cimpl.h"
00064 using namespace CIMPL;
00065 
00066 
00067 #include <cmath>
00068 
00069 
00070 
00072 namespace Blas
00073 {
00074 
00075 // BLAS LEVEL 1
00076 
00078          float Asum(Vector<float>& x);
00079          double Asum(Vector<double>& x);
00080          float Asum(Vector<ComplexFloat>& x);
00081          double Asum(Vector<ComplexDouble>& x);
00082 
00084          void Axpy(float alpha, Vector<float>& x, Vector<float>& y);
00085          void Axpy(double alpha, Vector<double>& x, Vector<double>& y);
00086          void Axpy(ComplexFloat alpha, Vector<ComplexFloat>& x, Vector<ComplexFloat>& y);
00087          void Axpy(ComplexDouble alpha, Vector<ComplexDouble>& x, Vector<ComplexDouble>& y);
00088 
00090          void Copy(Vector<float>& x, Vector<float>& y);
00091          void Copy(Vector<double>& x, Vector<double>& y);
00092          void Copy(Vector<ComplexFloat>& x, Vector<ComplexFloat>& y);
00093          void Copy(Vector<ComplexDouble>& x, Vector<ComplexDouble>& y);
00094 
00096          float Dot(Vector<float>& x, Vector<float>& y);
00097          double Dot(Vector<double>& x, Vector<double>& y);
00098          ComplexFloat Dot(Vector<ComplexFloat>& x, Vector<ComplexFloat>& y, bool conjugated);
00099          ComplexDouble Dot(Vector<ComplexDouble>& x, Vector<ComplexDouble>& y, bool conjugated);
00100          ComplexFloat Dot(Vector<ComplexFloat>& x, Vector<ComplexFloat>& y);
00101          ComplexDouble Dot(Vector<ComplexDouble>& x, Vector<ComplexDouble>& y);
00102 
00105          float Nrm2(Vector<float>& x);
00106          double Nrm2(Vector<double>& x);
00107          float Nrm2(Vector<ComplexFloat>& x);
00108          double Nrm2(Vector<ComplexDouble>& x);
00109 
00112          void Rot(Vector<float>& x, Vector<float>& y, const float c, const float s);
00113          void Rot(Vector<double>& x, Vector<double>& y, const double c, const double s);
00114          void Rot(Vector<ComplexFloat>& x, Vector<ComplexFloat>& y, const float c, const float s);
00115          void Rot(Vector<ComplexDouble>& x, Vector<ComplexDouble>& y, const double c, const double s);
00116 
00117 
00119          void Rotg(float& a, float& b, float& c, float& s);
00120          void Rotg(double& a, double& b, double& c, double& s);
00121          void Rotg(ComplexFloat& a, ComplexFloat& b, float& c, ComplexFloat& s);
00122          void Rotg(ComplexDouble& a, ComplexDouble& b, double& c, ComplexDouble& s);
00123 
00124 
00125 
00152          void Rotm(Vector<float>& x, Vector<float>& y, float* param);
00153          void Rotm(Vector<double>& x, Vector<double>& y, double* param);
00154 
00155 
00157          void Rotmg(float& d1, float& d2, float& b1, float& b2, float* param);
00158          void Rotmg(double& d1, double& d2, double& b1, double& b2, double* param);
00159 
00160 
00162          void Scal(float alpha, Vector<float>& x);
00163          void Scal(double alpha, Vector<double>& x);
00164          void Scal(float alpha, Vector<ComplexFloat>& x);
00165          void Scal(double alpha, Vector<ComplexDouble>& x);
00166          void Scal(ComplexFloat alpha, Vector<ComplexFloat>& x);
00167          void Scal(ComplexDouble alpha, Vector<ComplexDouble>& x);
00168 
00170          void Swap(Vector<float>& x, Vector<float>& y);
00171          void Swap(Vector<double>& x, Vector<double>& y);
00172          void Swap(Vector<ComplexFloat>& x, Vector<ComplexFloat>& y);
00173          void Swap(Vector<ComplexDouble>& x, Vector<ComplexDouble>& y);
00174 
00175 
00177          int IAmax(Vector<float>& x);
00178          int IAmax(Vector<double>& x);
00179          int IAmax(Vector<ComplexFloat>& x);
00180          int IAmax(Vector<ComplexDouble>& x);
00181 
00182 
00184          int IAmin(Vector<float>& x);
00185          int IAmin(Vector<double>& x);
00186          int IAmin(Vector<ComplexFloat>& x);
00187          int IAmin(Vector<ComplexDouble>& x);
00188 
00189 
00190 
00191 // BLAS LEVEL 2
00192 
00193 
00195          Vector<float> Gemv(Matrix<float>& A, Vector<float>& x);
00196          Vector<double> Gemv(Matrix<double>& A, Vector<double>& x);
00197          Vector<ComplexFloat> Gemv(Matrix<ComplexFloat>& A, Vector<ComplexFloat>& x);
00198          Vector<ComplexDouble> Gemv(Matrix<ComplexDouble>& A, Vector<ComplexDouble>& x);
00199 
00203          void Ger(float alpha, Vector<float>& x, Vector<float>& y, Matrix<float>& A);
00204          void Ger(double alpha, Vector<double>& x, Vector<double>& y, Matrix<double>& A);
00205          void Ger(ComplexFloat alpha, Vector<ComplexFloat>& x, Vector<ComplexFloat>& y, Matrix<ComplexFloat>& A);
00206          void Ger(ComplexDouble alpha, Vector<ComplexDouble>& x, Vector<ComplexDouble>& y, Matrix<ComplexDouble>& A);
00207          void Ger(ComplexFloat alpha, Vector<ComplexFloat> x, Vector<ComplexFloat> y, Matrix<ComplexFloat>& A, bool conjugated);
00208          void Ger(ComplexDouble alpha, Vector<ComplexDouble>& x, Vector<ComplexDouble>& y, Matrix<ComplexDouble>& A, bool conjugated);
00209         
00210         
00212          Vector<float> Symv(Matrix<float>& A, Vector<float> x);
00213          Vector<double> Symv(Matrix<double>& A, Vector<double> x);
00214          
00215          Vector<ComplexFloat> Hemv(Matrix<ComplexFloat>& A, Vector<ComplexFloat>& x);
00216          Vector<ComplexDouble> Hemv(Matrix<ComplexDouble>& A, Vector<ComplexDouble>& x);
00217 
00222          void Syr(float alpha, Vector<float>& x, Matrix<float>& A);
00223          void Syr(double alpha, Vector<double>& x, Matrix<double>& A);
00224          
00225          void Her(float alpha, Vector<ComplexFloat>& x, Matrix<ComplexFloat>& A);
00226          void Her(double alpha, Vector<ComplexDouble>& x, Matrix<ComplexDouble>& A);
00227 
00228 
00233          void Syr2(float alpha, Vector<float>& x, Vector<float>& y, Matrix<float>& A);
00234          void Syr2(double alpha, Vector<double>& x, Vector<double>& y, Matrix<double>& A);
00235          
00236          void Her2(ComplexFloat alpha, Vector<ComplexFloat>& x, Vector<ComplexFloat>& y, Matrix<ComplexFloat>& A);
00237          void Her2(ComplexDouble alpha, Vector<ComplexDouble>& x, Vector<ComplexDouble>& y, Matrix<ComplexDouble>& A);
00238 
00239 
00240 
00242          Vector<float> Trmv(Matrix<float>& A, Vector<float>& x);
00243          Vector<double> Trmv(Matrix<double>& A, Vector<double>& x);
00244          Vector<ComplexFloat> Trmv(Matrix<ComplexFloat>& A, Vector<ComplexFloat>& x);
00245          Vector<ComplexDouble> Trmv(Matrix<ComplexDouble>& A, Vector<ComplexDouble>& x);
00246         
00248          Vector<float> Trsv(Matrix<float>& A, Vector<float>& b);
00249          Vector<double> Trsv(Matrix<double>& A, Vector<double>& b);
00250          Vector<ComplexFloat> Trsv(Matrix<ComplexFloat>& A, Vector<ComplexFloat>& b);
00251          Vector<ComplexDouble> Trsv(Matrix<ComplexDouble>& A, Vector<ComplexDouble>& b);
00252         
00253 
00254 
00255 
00256 
00257 
00258 
00259 
00260 // BLAS LEVEL 3
00261 
00265         
00266          Matrix<float> Gemm(Matrix<float>& A, Matrix<float>& B);
00267          Matrix<double> Gemm(Matrix<double>& A, Matrix<double>& B);
00268          Matrix<ComplexFloat> Gemm(Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& B);
00269          Matrix<ComplexDouble> Gemm(Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& B);
00270 
00271         
00272         // Hemm, Symm: Hermitian, symmetric (A is sym. or hermitian)  m*m
00274          Matrix<float> Symm(Matrix<float>& A, Matrix<float>& B);
00275          Matrix<double> Symm(Matrix<double>& A, Matrix<double>& B);
00276          Matrix<ComplexFloat> Symm(Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& B);
00277          Matrix<ComplexDouble> Symm(Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& B);
00278          
00279 
00280          Matrix<float> Symm(Matrix<float>& A, Matrix<float>& B, bool orderReversed);
00281          Matrix<double> Symm(Matrix<double>& A, Matrix<double>& B, bool orderReversed);
00282          Matrix<ComplexFloat> Symm(Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& B, bool orderReversed);
00283          Matrix<ComplexDouble> Symm(Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& B, bool orderReversed);
00284          
00285          Matrix<ComplexFloat> Hemm(Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& B);
00286          Matrix<ComplexDouble> Hemm(Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& B);
00287          Matrix<ComplexFloat> Hemm(Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& B, bool orderReversed);
00288          Matrix<ComplexDouble> Hemm(Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& B, bool orderReversed);
00289 
00290 
00294         
00295          void Syrk(float alpha, Matrix<float>& A, Matrix<float>& C);
00296          void Syrk(double alpha, Matrix<double>& A, Matrix<double>& C);
00297          void Syrk(ComplexFloat alpha, Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& C);
00298          void Syrk(ComplexDouble alpha, Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& C);
00299 
00300 
00304 
00305          void Syr2k(float alpha, Matrix<float>& A, Matrix<float>& B, Matrix<float>& C);
00306          void Syr2k(double alpha, Matrix<double>& A, Matrix<double>& B, Matrix<double>& C);
00307          void Syr2k(ComplexFloat alpha, Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& B, Matrix<ComplexFloat>& C);
00308          void Syr2k(ComplexDouble alpha, Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& B, Matrix<ComplexDouble>& C);
00309 
00310 
00311         // Herk: rank k update of an hermitian matrix
00314 
00315          void Herk(float alpha, Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& C);
00316          void Herk(double alpha, Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& C);
00317 
00318         // Her2k: rank 2k update of an hermitian matrix
00321 
00322          void Her2k(ComplexFloat alpha, Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& B, Matrix<ComplexFloat>& C);
00323          void Her2k(ComplexDouble alpha, Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& B, Matrix<ComplexDouble>& C);
00324 
00325 
00326         // Trmm: Triangular (A is triangular) m*m
00328          Matrix<float> Trmm(Matrix<float>& A, Matrix<float>& B);
00329          Matrix<double> Trmm(Matrix<double>& A, Matrix<double>& B);
00330          Matrix<ComplexFloat> Trmm(Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& B);
00331          Matrix<ComplexDouble> Trmm(Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& B);
00332 
00333         // Trsm: Solve a triangular system of equations with a triangular coefficient matrix
00335          Matrix<float> Trsm(Matrix<float>& A, Matrix<float>& B);
00336          Matrix<double> Trsm(Matrix<double>& A, Matrix<double>& B);
00337          Matrix<ComplexFloat> Trsm(Matrix<ComplexFloat>& A, Matrix<ComplexFloat>& B);
00338          Matrix<ComplexDouble> Trsm(Matrix<ComplexDouble>& A, Matrix<ComplexDouble>& B);
00339 
00340 
00341 };
00342 
00343 
00344 
00345 
00346 #endif
00347 
00348 
00349 
00350 
00351 
00352 
00353 
00354 
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362 

Generated on Thu Jan 20 08:43:39 2005 for CIMPL by  doxygen 1.3.9.1