Debian Codegraph @

tools/physicalModeling/mesh2faust/vega/libraries/matrix/matrixBLAS.cpp

raw symbols SCIP
1 /*************************************************************************
2 * *
3 * Vega FEM Simulation Library Version 3.1 *
4 * *
5 * "matrix" library , Copyright (C) 2007 CMU, 2009 MIT *
6 * All rights reserved. *
7 * *
8 * Code author: Jernej Barbic *
9 * http://www.jernejbarbic.com/code *
10 * Research: Jernej Barbic, Doug L. James, Jovan Popovic *
11 * Funding: NSF, Link Foundation, Singapore-MIT GAMBIT Game Lab *
12 * *
13 * This library is free software; you can redistribute it and/or *
14 * modify it under the terms of the BSD-style license that is *
15 * included with this library in the file LICENSE.txt *
16 * *
17 * This library is distributed in the hope that it will be useful, *
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file *
20 * LICENSE.TXT for more details. *
21 * *
22 *************************************************************************/
23
24 #include "matrixMacros.h"
25 #include "matrixBLAS.h"
26
27 #define BLAS
28
29 #ifdef BLAS
30 #include "matrixBLASOptimized.cpp"
31 #else
32 #include "matrixBLASVanilla.cpp"
33 #endif
34
35 #include "vegalong.h"
36
37 // transposes the matrix (without making a separate copy)
38 template <class real>
39 void InPlaceTransposeMatrix(int m, int n, real * mtx)
40 {
41 real buffer;
42 #define SWAP_ELT(i,j)\
43 buffer = mtx[i];\
44 mtx[i] = mtx[j];\
45 mtx[j] = buffer;
46
47 vegalong M = m;
48 vegalong N = n;
49 vegalong MN = M*N;
50
51 for(vegalong i=0; i< MN; i++)
52 {
53 vegalong current = i;
54 do
55 {
56 // evaluate permutation on 'current'
57 vegalong k = current / N;
58 vegalong l = current % N;
59
60 current = M * l + k;
61 }
62 while(current < i);
63
64 if (current>i)
65 {
66 SWAP_ELT(i,current);
67 //printf("Swap: %d %d .\n",i,current);
68 }
69 }
70 }
71
72 template float * MultiplyMatrices<float>(int m, int p, int n, float * mtx1, float * mtx2, float * output);
73 template double * MultiplyMatrices<double>(int m, int p, int n, double * mtx1, double * mtx2, double * output);
74
75 template float * MultiplyMatricesT<float>(int m, int p, int n, float * mtx1, float * mtx2, float * output);
76 template double * MultiplyMatricesT<double>(int m, int p, int n, double * mtx1, double * mtx2, double * output);
77
78 template float * SumMatrices<float>(int m, int n, float * mtx1, float * mtx2, float * output);
79 template double * SumMatrices<double>(int m, int n, double * mtx1, double * mtx2, double * output);
80
81 template float * SubtractMatrices<float>(int m, int n, float * mtx1, float * mtx2, float * output);
82 template double * SubtractMatrices<double>(int m, int n, double * mtx1, double * mtx2, double * output);
83
84 template float * ScalarMultiplyMatrix<float>(int m, int n, float alpha, float * mtx, float * output);
85 template double * ScalarMultiplyMatrix<double>(int m, int n, double alpha, double * mtx, double * output);
86
87 template void InPlaceTransposeMatrix<double>(int m, int n, double * U);
88 template void InPlaceTransposeMatrix<float>(int m, int n, float * U);
89
90 template double VectorNorm<double>(int m, double * vec);
91 template float VectorNorm<float>(int m, float * vec);