toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN TooN.h internal/diagmatrix.hh


From: Tom Drummond
Subject: [Toon-members] TooN TooN.h internal/diagmatrix.hh
Date: Sat, 25 Apr 2009 15:08:19 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Tom Drummond <twd20>    09/04/25 15:08:19

Modified files:
        .              : TooN.h 
        internal       : diagmatrix.hh 

Log message:
        added operators for diagonal matrices and moved them to after operators 
in TooN.h

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/TooN.h?cvsroot=toon&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/diagmatrix.hh?cvsroot=toon&r1=1.1&r2=1.2

Patches:
Index: TooN.h
===================================================================
RCS file: /cvsroot/toon/TooN/TooN.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- TooN.h      25 Apr 2009 14:53:32 -0000      1.34
+++ TooN.h      25 Apr 2009 15:08:19 -0000      1.35
@@ -91,9 +91,11 @@
        #include <TooN/internal/matrix.hh>
        #include <TooN/internal/reference.hh>
 
-    #include <TooN/internal/diagmatrix.hh>
-
        #include <TooN/internal/make_vector.hh>
        #include <TooN/internal/operators.hh>
+
+    #include <TooN/internal/diagmatrix.hh>
+
 }
+
 #endif

Index: internal/diagmatrix.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/diagmatrix.hh,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- internal/diagmatrix.hh      25 Apr 2009 14:53:32 -0000      1.1
+++ internal/diagmatrix.hh      25 Apr 2009 15:08:19 -0000      1.2
@@ -45,7 +45,7 @@
        inline DiagonalMatrix(const Operator<Op>& op)
                : my_vector (op)
        {
-               op.eval(*this);
+               op.eval(my_vector);
        }
 
        // constructor from arbitrary vector
@@ -67,3 +67,37 @@
 
        Vector<Size,Precision,Base> my_vector;
 };
+
+
+template<int S1, typename P1, typename B1, int S2, typename P2, typename B2>
+inline Vector<Internal::Sizer<S1,S2>::size, typename 
Internal::MultiplyType<P1,P2>::type>
+operator*(const DiagonalMatrix<S1,P1,B1>& d, const Vector<S2,P2,B2>& v){
+       return diagmult(d.my_vector,v);
+}
+
+template<int S1, typename P1, typename B1, int S2, typename P2, typename B2>
+inline Vector<Internal::Sizer<S1,S2>::size, typename 
Internal::MultiplyType<P1,P2>::type>
+operator*( const Vector<S1,P1,B1>& v, const DiagonalMatrix<S2,P2,B2>& d){
+       return diagmult(v,d.my_vector);
+}
+
+// perhaps not the safest way to do this as we're returning the same operator 
used to normally make vectors
+template<int S1, typename P1, typename B1, int S2, typename P2, typename B2>
+inline DiagonalMatrix<Internal::Sizer<S1,S2>::size, typename 
Internal::MultiplyType<P1,P2>::type>
+operator*( const DiagonalMatrix<S1,P1,B1>& d1, const DiagonalMatrix<S2,P2,B2>& 
d2){
+       SizeMismatch<S1,S2>::test(d1.my_vector.size(),d2.my_vector.size());
+       return 
Operator<Internal::VPairwise<Internal::Multiply,S1,P1,B1,S2,P2,B2> 
>(d1.my_vector,d2.my_vector);
+}
+
+template<int R, int C, int Size, typename P1, typename P2, typename B1, 
typename B2>
+Matrix<R, C, typename Internal::MultiplyType<P1,P2>::type>
+operator* (const Matrix<R, C, P1, B1>& m, const DiagonalMatrix<Size, P2, B2>& 
d){
+       return diagmult(m,d.my_vector);
+}
+
+template<int R, int C, typename P1, typename B1, int Size, typename P2, 
typename B2> 
+Matrix<R, C, typename Internal::MultiplyType<P1,P2>::type>
+operator* (const DiagonalMatrix<Size,P1,B1>& d, const Matrix<R,C,P2,B2>& m)
+{
+       return diagmult(d.my_vector, m);
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]