[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN internal/matrix.hh internal/mbase.hh test/...
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN internal/matrix.hh internal/mbase.hh test/... |
Date: |
Wed, 25 Mar 2009 21:47:01 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 09/03/25 21:47:01
Modified files:
internal : matrix.hh mbase.hh
Added files:
test : test_foreign.cc
Log message:
Started work on the foreign data interface to allow TooN objects to be
created which slice foreign data.
Added a new helper classes *MajorContigRef, which are used in the same
way as RowMajor and ColMajor, except they cause matrices to be created
which reference foreign data.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/matrix.hh?cvsroot=toon&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/mbase.hh?cvsroot=toon&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/TooN/test/test_foreign.cc?cvsroot=toon&rev=1.1
Patches:
Index: internal/matrix.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/matrix.hh,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- internal/matrix.hh 25 Mar 2009 21:24:20 -0000 1.18
+++ internal/matrix.hh 25 Mar 2009 21:47:01 -0000 1.19
@@ -24,6 +24,14 @@
:Layout::template Layout<Rows,Cols,Precision>(rows, cols)
{}
+ Matrix(Precision* p, int rows, int cols)
+ :Layout::template Layout<Rows,Cols,Precision>(p, rows, cols)
+ {}
+
+ Matrix(Precision* p)
+ :Layout::template Layout<Rows,Cols,Precision>(p)
+ {}
+
//See vector.hh and allocator.hh for details about why the
//copy constructor should be default.
template <class Op>
Index: internal/mbase.hh
===================================================================
RCS file: /cvsroot/toon/TooN/internal/mbase.hh,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- internal/mbase.hh 6 Mar 2009 16:52:52 -0000 1.20
+++ internal/mbase.hh 25 Mar 2009 21:47:01 -0000 1.21
@@ -57,6 +57,11 @@
//Optional constructors
GenericMBase(){}
+ GenericMBase(Precision* p)
+ :Mem(p)
+ {}
+
+
GenericMBase(Precision* p, int rs, int cs)
:Mem(p),RowStrideHolder<RowStride>(rs),ColStrideHolder<ColStride>(cs) {}
@@ -174,6 +179,42 @@
};
};
+////////////////////////////////////////////////////////////////////////////////
+//
+// Helper classes for matrices constructed as references to foreign data
+//
+
+
+struct RowMajorContigRef
+{
+ template<int Rows, int Cols, class Precision> struct Layout: public
Internal::GenericMBase<Rows, Cols, Precision, (Rows==-1?-2:Rows), 1,
Internal::MatrixSlice<Rows, Cols, Precision> >
+ {
+ //Optional constructors.
+
+ Layout(Precision* p)
+ :Internal::GenericMBase<Rows, Cols, Precision,
(Rows==-1?-2:Rows), 1, Internal::MatrixSlice<Rows, Cols, Precision> >(p)
+ {
+ }
+
+ Layout(Precision* p, int rows, int cols)
+ :Internal::GenericMBase<Rows, Cols, Precision, (Rows == -1 ? -2
: Rows), 1, Internal::MatrixAlloc<Rows, Cols, Precision> >(p, rows, cols)
+ {}
+ };
+};
+struct ColMajorContigRef
+{
+ template<int Rows, int Cols, class Precision> struct Layout: public
Internal::GenericMBase<Rows, Cols, Precision, 1, (Rows==-1?-2:Rows),
Internal::MatrixSlice<Rows, Cols, Precision> >
+ {
+ //Optional constructors.
+ Layout(Precision* p)
+ :Internal::GenericMBase<Rows, Cols, Precision, 1,
(Rows==-1?-2:Rows), Internal::MatrixSlice<Rows, Cols, Precision> >(p)
+ {
+ }
+ Layout(Precision* p, int rows, int cols)
+ :Internal::GenericMBase<Rows, Cols, Precision, 1, (Rows == -1 ?
-2 : Rows), Internal::MatrixAlloc<Rows, Cols, Precision> >(p, rows, cols)
+ {}
+ };
+};
Index: test/test_foreign.cc
===================================================================
RCS file: test/test_foreign.cc
diff -N test/test_foreign.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ test/test_foreign.cc 25 Mar 2009 21:47:01 -0000 1.1
@@ -0,0 +1,21 @@
+#include <TooN/TooN.h>
+#include <TooN/helpers.h>
+
+using namespace std;
+using namespace TooN;
+
+int main()
+{
+ double data[]={1, 2, 3, 4};
+
+ Matrix<2> m = Identity;
+
+ cout << m << endl;
+
+ Matrix<2, 2, double, RowMajorContigRef> n(data);
+
+ cout << n << endl;
+
+ cout << m + n;
+
+};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN internal/matrix.hh internal/mbase.hh test/...,
Edward Rosten <=