LINEAR++ library: AFF to LAPACK
dot.cc
Go to the documentation of this file.
1 
34 #define LINEAR_DOT_CC_VERSION \
35  "LINEAR_DOT_CC V1.0 "
36 
37 #include <linearxx/operators.h>
38 #include <linearxx/error.h>
39 #include <aff/shaper.h>
40 
41 namespace linear {
42 
43  namespace op {
44 
45  TDmatrix dotNxM(const TDmatrix::Tcoc& A, const TDmatrix::Tcoc& B)
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  }
69 
70  } // namespace op
71 
72 } // namespace linear
73 
74 /* ----- END OF dot.cc ----- */
Exception class for this library (prototypes)
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
matrix and vector operators (prototypes)
TDmatrix dotNxM(const TDmatrix::Tcoc &A, const TDmatrix::Tcoc &B)
dot product for NxM matrices.
Definition: dot.cc:45
Modules of liblinearxx.a.
Definition: error.cc:43
#define LINEAR_assert(C, M)
Check an assertion and report by throwing an exception.
Definition: error.h:176