toon-members
[Top][All Lists]
Advanced

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

[Toon-members] TooN internal/foreign_matrix.hh internal/vector...


From: Tom Drummond
Subject: [Toon-members] TooN internal/foreign_matrix.hh internal/vector...
Date: Sun, 12 Apr 2009 01:23:47 +0000

CVSROOT:        /cvsroot/toon
Module name:    TooN
Changes by:     Tom Drummond <twd20>    09/04/12 01:23:47

Modified files:
        internal       : foreign_matrix.hh vector.hh 
        test           : test_foreign.cc 

Log message:
        added wrapping foreign data for Vectors into foreign_matrix
        which now needs to be renamed

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/foreign_matrix.hh?cvsroot=toon&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/vector.hh?cvsroot=toon&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/TooN/test/test_foreign.cc?cvsroot=toon&r1=1.4&r2=1.5

Patches:
Index: internal/foreign_matrix.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/foreign_matrix.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- internal/foreign_matrix.hh  12 Apr 2009 01:08:00 -0000      1.3
+++ internal/foreign_matrix.hh  12 Apr 2009 01:23:46 -0000      1.4
@@ -5,12 +5,25 @@
 // Helper classes for matrices constructed as references to foreign data
 //
 
-namespace Reference
+struct Reference
 {
 
+       template<int Size, typename Precision>
+       struct VLayout
+               : public Internal::GenericVBase<Size, Precision, 1, 
Internal::VectorSlice<Size, Precision> >
+       {
+
+               VLayout(Precision* p, int sz=0)
+                       : Internal::GenericVBase<Size, Precision, 1, 
Internal::VectorSlice<Size, Precision> >(p, sz, 0)
+               {}
+       };
+
+
        struct RowMajor
        {
-               template<int Rows, int Cols, class Precision> struct MLayout: 
public Internal::GenericMBase<Rows, Cols, Precision, (Cols==-1?-2:Cols), 1, 
Internal::MatrixSlice<Rows, Cols, Precision> >
+               template<int Rows, int Cols, class Precision>
+               struct MLayout
+                       : public Internal::GenericMBase<Rows, Cols, Precision, 
(Cols==-1?-2:Cols), 1, Internal::MatrixSlice<Rows, Cols, Precision> >
                {
                        MLayout(Precision* p, int r=0, int c=0)
                                : Internal::GenericMBase<Rows,Cols,Precision, 
(Cols==-1?-2:Cols), 1, Internal::MatrixSlice<Rows, Cols, Precision> > (p, r, c, 
0, 0)
@@ -27,7 +40,7 @@
                        {}
                };
        };
-}
+};
 
 template<int R, int C, typename Precision=double, class 
Type=Reference::RowMajor> struct Wrap
 {

Index: internal/vector.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/vector.hh,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- internal/vector.hh  12 Apr 2009 01:08:01 -0000      1.35
+++ internal/vector.hh  12 Apr 2009 01:23:47 -0000      1.36
@@ -6,8 +6,12 @@
   // class but they don't generate errors unless the user tries to use one of 
them
   // although the error message may be less than helpful - maybe this can be 
changed?
        inline Vector(){}
-       // inline Vector(Precision* data) : Base::template VLayout<Size, 
Precision> (data) {}
        inline Vector(int size_in) : Base::template VLayout<Size, 
Precision>(size_in) {}
+
+       inline Vector(Precision* data) : Base::template VLayout<Size, 
Precision> (data) {}
+       inline Vector(Precision* data, int size_in) : Base::template 
VLayout<Size, Precision> (data, size_in) {}
+
+       // internal constructor
        inline Vector(Precision* data_in, int size_in, int stride_in, 
Internal::Slicing) : Base::template VLayout<Size, Precision>(data_in, size_in, 
stride_in) {}
        
        using Base::template VLayout<Size, Precision>::size;

Index: test/test_foreign.cc
===================================================================
RCS file: /cvsroot/toon/TooN/test/test_foreign.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- test/test_foreign.cc        11 Apr 2009 05:23:16 -0000      1.4
+++ test/test_foreign.cc        12 Apr 2009 01:23:47 -0000      1.5
@@ -30,4 +30,8 @@
        cout << Wrap<Dynamic,3,double,Reference::ColMajor>::wrap(data,2) << 
endl;
        cout << Wrap<Dynamic, 
Dynamic,double,Reference::ColMajor>::wrap(data,2,3) << endl;
 
+
+       cout << Vector<6,double,Reference> (data) << endl;
+       cout << Vector<-1,double,Reference> (data,6) << endl;
+
 };




reply via email to

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