LINEAR++ library: AFF to LAPACK

◆ dotNxM()

TDmatrix linear::op::dotNxM ( const TDmatrix::Tcoc &  ,
const TDmatrix::Tcoc &   
)

dot product for NxM matrices.

We cannot simply overload the operator*() function. The general libaff array underlying TDmatrix is an NxMxKxL matrix, even if used for an NxM matrix. In most cases this doesn't matter. But with matrix dot products we have to distinguish.

Definition at line 45 of file dot.cc.

References checkNxM(), and LINEAR_assert.

Referenced by main(), and test().

46  {
47  const int dim1=0;
48  const int dim2=1;
49  checkNxM(A);
50  checkNxM(B);
51  LINEAR_assert(A.first(dim2)==B.first(dim1),
52  "size of input matrices does not match!");
53  LINEAR_assert(A.last(dim2)==B.last(dim1),
54  "size of input matrices does not match!");
55  TDmatrix C(aff::Shaper(A.f(dim1),A.l(dim1))(B.f(dim2),B.l(dim2)));
56  for (int i=C.f(dim1); i<= C.l(dim1); ++i)
57  {
58  for (int j=C.f(dim2); j<= C.l(dim2); ++j)
59  {
60  C(i,j)=0.;
61  for (int k=A.f(dim2); k<=A.l(dim2); ++k)
62  {
63  C(i,j)+=A(i,k)*B(k,j);
64  }
65  }
66  }
67  return(C);
68  }
aff::Array< double > TDmatrix
Definition: matrix.h:46
void checkNxM(const TDmatrix::Tcoc &A)
check expected libaff array shape for NxM matrix.
Definition: checknxn.cc:44
#define LINEAR_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:176
Here is the call graph for this function:
Here is the caller graph for this function: