CPPLapack
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Friends
Pages
include
_dssmatrix-
_dssmatrix-_dgematrix.hpp
Go to the documentation of this file.
1
//=============================================================================
2
/*! _dssmatrix+_dgematrix operator */
3
/*
4
inline _dgematrix operator+(const _dssmatrix& matA, const _dgematrix& matB)
5
{CPPL_VERBOSE_REPORT;
6
#ifdef CPPL_DEBUG
7
if(matA.m!=matB.m || matA.n!=matB.n){
8
ERROR_REPORT;
9
std::cerr << "These two matrises can not make a summation." << std::endl
10
<< "Your input was (" << matA.m << "x" << matA.n << ") + (" << matB.m << "x" << matB.n << ")." << std::endl;
11
exit(1);
12
}
13
#endif//CPPL_DEBUG
14
15
for(CPPL_INT c=0; c<matA.vol; c++){
16
matB(matA.indx[c],matA.jndx[c]) += matA.array[c];
17
}
18
19
matA.destroy();
20
return matB;
21
}
22
*/
23
//=============================================================================
24
/*! _dssmatrix-_dgematrix operator */
25
/*
26
inline _dgematrix operator-(const _dssmatrix& matA, const _dgematrix& matB)
27
{CPPL_VERBOSE_REPORT;
28
#ifdef CPPL_DEBUG
29
if(matA.m!=matB.m || matA.n!=matB.n){
30
ERROR_REPORT;
31
std::cerr << "These two matrises can not make a subtraction." << std::endl
32
<< "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
33
exit(1);
34
}
35
#endif//CPPL_DEBUG
36
37
//// change sign ////
38
for(int i=0; i<matB.m*matB.n; i++){
39
matB.array[i] = -matB.array[i];
40
}
41
42
for(CPPL_INT c=0; c<matA.vol; c++){
43
matB(matA.indx[c],matA.jndx[c]) += matA.array[c];
44
}
45
46
matA.destroy();
47
return matB;
48
}
49
*/
50
//=============================================================================
51
/*! _dssmatrix*_dgematrix operator */
52
/*
53
inline _dgematrix operator*(const _dssmatrix& matA, const _dgematrix& matB)
54
{CPPL_VERBOSE_REPORT;
55
#ifdef CPPL_DEBUG
56
if(matA.n!=matB.m){
57
ERROR_REPORT;
58
std::cerr << "These two matrises can not make a product." << std::endl
59
<< "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
60
exit(1);
61
}
62
#endif//CPPL_DEBUG
63
64
dgematrix newmat(matA.m, matB.n);
65
newmat.zero();
66
67
for(CPPL_INT c=0; c<matA.vol; c++){
68
for(CPPL_INT j=0; j<matB.n; j++){
69
newmat(matA.indx[c],j) += matA.array[c]*matB(matA.jndx[c],j);
70
}
71
}
72
73
matA.destroy();
74
matB.destroy();
75
return _(newmat);
76
}
77
*/
Generated by
1.8.6