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
dgematrix newmat(matB);
16
for(CPPL_INT c=0; c<matA.vol; c++){
17
newmat(matA.indx[c],matA.jndx[c]) += matA.array[c];
18
}
19
20
return _(newmat);
21
}
22
*/
23
24
//=============================================================================
25
/*! dssmatrix-dgematrix operator */
26
/*
27
inline _dgematrix operator-(const dssmatrix& matA, const dgematrix& matB)
28
{CPPL_VERBOSE_REPORT;
29
#ifdef CPPL_DEBUG
30
if(matA.m!=matB.m || matA.n!=matB.n){
31
ERROR_REPORT;
32
std::cerr << "These two matrises can not make a subtraction." << std::endl
33
<< "Your input was (" << matA.m << "x" << matA.n << ") - (" << matB.n << "x" << matB.n << ")." << std::endl;
34
exit(1);
35
}
36
#endif//CPPL_DEBUG
37
38
dgematrix newmat(-matB);
39
for(CPPL_INT c=0; c<matA.vol; c++){
40
newmat(matA.indx[c],matA.jndx[c]) += matA.array[c];
41
}
42
43
return _(newmat);
44
}
45
*/
46
47
//=============================================================================
48
/*! dssmatrix*dgematrix operator */
49
/*
50
inline _dgematrix operator*(const dssmatrix& matA, const dgematrix& matB)
51
{CPPL_VERBOSE_REPORT;
52
#ifdef CPPL_DEBUG
53
if(matA.n!=matB.m){
54
ERROR_REPORT;
55
std::cerr << "These two matrises can not make a product." << std::endl
56
<< "Your input was (" << matA.m << "x" << matA.n << ") * (" << matB.n << "x" << matB.n << ")." << std::endl;
57
exit(1);
58
}
59
#endif//CPPL_DEBUG
60
61
dgematrix newmat(matA.m, matB.n);
62
newmat.zero();
63
64
double *ap(matA.array);
65
CPPL_INT *ip(matA.indx), *kp(matA.jndx), c(0);
66
while(c<matA.vol){
67
for(CPPL_INT j=0; j<matB.n; j++){
68
newmat(*ip,j) +=(*ap)*matB(*kp,j);
69
}
70
if((*ip)!=(*kp)){
71
for(CPPL_INT j=0; j<matB.n; j++){
72
newmat(*kp,j) +=(*ap)*matB(*ip,j);
73
}
74
}
75
ap++; ip++; kp++; c++;
76
}
77
78
return _(newmat);
79
}
80
*/
Generated by
1.8.6