[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN TooN.h internal/operators.hh matrix.h mcla...
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN TooN.h internal/operators.hh matrix.h mcla... |
Date: |
Sat, 07 Feb 2009 15:36:47 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 09/02/07 15:36:47
Modified files:
. : TooN.h
Added files:
internal : operators.hh
Removed files:
. : matrix.h mclasses.hh operators.h
Log message:
Rearrangement of files, and remove dead files.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/TooN.h?cvsroot=toon&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/TooN/matrix.h?cvsroot=toon&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/TooN/mclasses.hh?cvsroot=toon&r1=1.10&r2=0
http://cvs.savannah.gnu.org/viewcvs/TooN/operators.h?cvsroot=toon&r1=1.4&r2=0
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/operators.hh?cvsroot=toon&rev=1.1
Patches:
Index: TooN.h
===================================================================
RCS file: /cvsroot/toon/TooN/TooN.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- TooN.h 3 Feb 2009 18:04:30 -0000 1.18
+++ TooN.h 7 Feb 2009 15:36:46 -0000 1.19
@@ -33,6 +33,6 @@
#include <TooN/internal/matrix.hh>
#include <TooN/internal/make_vector.hh>
- #include <TooN/operators.h>
+ #include <TooN/internal/operators.hh>
}
#endif
Index: internal/operators.hh
===================================================================
RCS file: internal/operators.hh
diff -N internal/operators.hh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ internal/operators.hh 7 Feb 2009 15:36:47 -0000 1.1
@@ -0,0 +1,94 @@
+//-*- c++ -*-
+
+//////////////////////////////////////////////////////////////////////////////////////////////
+// Operators
+//////////////////////////////////////////////////////////////////////////////////////////////
+
+
+// Dot product Vector * Vector
+template<int Size1, typename Precision1, typename Base1,
+ int Size2, typename Precision2, typename Base2>
+double operator*(const Vector<Size1, Precision1, Base1>& v1,
+ const Vector<Size2, Precision2, Base2>& v2){
+ SizeMismatch<Size1, Size2>:: test(v1.size(),v2.size());
+ const int s=v1.size();
+ double result=0;
+ for(int i=0; i<s; i++){
+ result+=v1[i]*v2[i];
+ }
+ return result;
+}
+
+// operator += Vector
+template<int Size1, typename Precision1, typename Base1,
+ int Size2, typename Precision2, typename Base2>
+Vector<Size1, Precision1, Base1>& operator += (Vector<Size1, Precision1,
Base1>& lhs,
+ const Vector<Size2, Precision2,
Base2>& rhs){
+ SizeMismatch<Size1,Size2>::test(lhs.size(),rhs.size());
+ const int s=lhs.size();
+ for(int i=0; i<s; i++){
+ lhs[i]+=rhs[i];
+ }
+ return lhs;
+}
+
+// operator -= Vector
+template<int Size1, typename Base1, typename Precision1,
+ int Size2, typename Precision2, typename Base2>
+Vector<Size1, Precision1, Base1>& operator -= (Vector<Size1, Precision1,
Base1>& lhs,
+ const Vector<Size2, Precision2,
Base2>& rhs){
+ SizeMismatch<Size1,Size2>::test(lhs.size(),rhs.size());
+ const int s=lhs.size();
+ for(int i=0; i<s; i++){
+ lhs[i]-=rhs[i];
+ }
+ return lhs;
+}
+
+// operator *= double
+template<int Size, typename Precision, typename Base>
+Vector<Size, Precision, Base>& operator *= (Vector<Size, Precision, Base>&
lhs, double rhs){
+ const int s=lhs.size();
+ for(int i=0; i<s; i++){
+ lhs[i]*=rhs;
+ }
+ return lhs;
+}
+
+// operator /= double
+template<int Size, typename Precision, typename Base>
+Vector<Size, Precision, Base>& operator /= (Vector<Size, Precision, Base>&
lhs, double rhs){
+ const int s=lhs.size();
+ for(int i=0; i<s; i++){
+ lhs[i]/=rhs;
+ }
+ return lhs;
+}
+
+// output operator <<
+template <int Size, typename Precision, typename Base>
+inline std::ostream& operator<< (std::ostream& os, const
Vector<Size,Precision,Base>& v){
+ for(int i=0; i<v.size(); i++){
+ os << v[i] << " ";
+ }
+ return os;
+}
+
+
+template<int Rows, int Cols, typename Precision, class Base>
+inline std::ostream& operator<< (std::ostream& os, const Matrix<Rows, Cols,
Precision, Base>& m){
+ for(int i=0; i < m.num_rows(); i++)
+ {
+ for(int j=0; j < m.num_cols(); j++)
+ {
+ if(j != 0)
+ os << " ";
+ os << m(i,j);
+ }
+ os << std::endl;
+ }
+ return os;
+}
+
+
+
Index: matrix.h
===================================================================
RCS file: matrix.h
diff -N matrix.h
--- matrix.h 7 Jan 2009 14:23:52 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,87 +0,0 @@
-// -*- c++ -*-
-
-
-
-
-
-
-
-
-template<int Rows, int Cols>
-class MatrixAllocator{
-
-
-
-
-};
-
-
-
-
-
-
-template<int Rows, int Cols>
-struct RowMajor{
-
- // has to handle operator[row] and operator(row,col)
-
- Vector<Cols,SDVBase<Cols,1> > operator[](int row){
- return Vector<Cols,SDVBase<Cols,1> >(my_data+Cols*row);
- }
-
- const Vector<Cols,SDVBase<Cols,1> > operator[](int row) const {
- return Vector<Cols,SDVBase<Cols,1> >(my_data+Cols*row);
- }
-
- double& operator()(int row, int col){
- return my_data[row*Cols+col];
- }
- const double& operator()(int row, int col) const {
- return my_data[row*Cols+col];
- }
-};
-
-template<int Rows, int Cols>
-struct ColMajor {
-
- // has to handle operator[row] and operator(row,col)
-
-};
-
-
-
-template<int Stride>
-struct StrideM {
- template <int Rows, int Cols>
- struct RowMajor{
-
- };
- template <int Rows, int Cols>
- struct ColMajor{
-
-
- };
-};
-
-
-
-template <int Stride>
-struct MStride {
- template <int Rows, int Cols>
- struct RowMajor{
- // in here goes the maths to compute Matrix(r,c) etc.
- };
- struct ColMajor{
- // in here goes the maths to compute Matrix(r,c) etc.
- };
-};
-
-
-// can now make a matrix of form
-// Matrix<Rows, Cols, MStride<Stride>::RowMajor>
-
-
-
-
-template <int Rows, int Cols, template<int R, int C> Layout = RowMajor>
-class Matrix : public Layout<Rows, Cols>;
Index: mclasses.hh
===================================================================
RCS file: mclasses.hh
diff -N mclasses.hh
--- mclasses.hh 12 Dec 2007 15:59:43 -0000 1.10
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,143 +0,0 @@
-
-/*
- Copyright (C) 2005 Tom Drummond
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc.
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-#ifndef __MCLASSES_HH
-#define __MCLASSES_HH
-
-
-
-template <int Rows, int Cols, class Layout>
-class Matrix : public FixedMatrix<Rows, Cols, FixedMAccessor<Rows, Cols,
Layout, typename SizeTraits<Rows*Cols>::get_zone> > {
- public:
- inline Matrix(){}
-
- // construction from 1 and 2 dimensional c-style arrays
- inline Matrix(const double d[Rows*Cols]){*this = (reinterpret_cast<const
FixedMatrix<Rows,Cols,FixedMAccessor<Rows,Cols,RowMajor,Stack<Rows*Cols> >
>&>(*d));}
- inline Matrix(const double d[Rows][Cols]){*this = (reinterpret_cast<const
FixedMatrix<Rows,Cols,FixedMAccessor<Rows,Cols,RowMajor,Stack<Rows*Cols> >
>&>(*d));}
-
- // construction from a fixed Matrix
- template <class Accessor>
- inline Matrix(const FixedMatrix<Rows,Cols,Accessor>& m){
- FixedMatrix<Rows,Cols, FixedMAccessor<Rows, Cols, Layout, typename
SizeTraits<Rows*Cols>::get_zone> >::operator=(m);
- }
-
- // construction from a dynamic Matrix
- template <class Accessor>
- inline Matrix(const DynamicMatrix<Accessor>& m){
- assert(m.num_rows()==Rows && m.num_cols() == Cols);
- FixedMatrix<Rows,Cols, FixedMAccessor<Rows, Cols, Layout, typename
SizeTraits<Rows*Cols>::get_zone> >::operator=(m);
- }
-
- // constructor from 1-ary operator
- template <class Arg, class Op>
- Matrix(const Arg& arg, const Operator<Op>&){Op::eval(*this,arg);}
-
- // constructor from 2-ary operator
- template <class LHS, class RHS, class Op>
- Matrix(const LHS& lhs, const RHS& rhs, const
Operator<Op>&){Op::eval(*this,lhs,rhs);}
-
-
-
-};
-
-template <class Layout>
-class Matrix<General, General, Layout> : public
DynamicMatrix<DynamicMAccessor<Layout> > {
- friend struct MSizer;
- public:
- inline Matrix(){
- this->my_num_rows = 0;
- this->my_num_cols = 0;
- this->my_values = NULL;
- }
-
- inline Matrix(int num_rows, int num_cols){
- this->my_num_rows = num_rows;
- this->my_num_cols = num_cols;
- this->my_values = new double[num_rows*num_cols];
- }
-
- inline ~Matrix(){
- delete[] this->my_values;}
-
- // construction from a double*
- inline Matrix(int num_rows, int num_cols, const double* data){
- this->my_num_rows=num_rows;
- this->my_num_cols = num_cols;
- this->my_values = new double[num_rows*num_cols];
- RefMatrix<RowMajor> temp (num_rows,num_cols,data);
- DynamicMatrix<DynamicMAccessor<Layout> >::operator=(temp);
- }
-
- // construction from a general Matrix
- template <class Accessor>
- inline Matrix(const MatrixBase<Accessor>& from){
- this->my_num_rows = from.num_rows();
- this->my_num_cols = from.num_cols();
- this->my_values = new double [this->my_num_rows*this->my_num_cols];
- DynamicMatrix<DynamicMAccessor<Layout> >::operator=(from);
- }
-
- inline void resize(int rows, int cols)
- {
- if(rows != this->my_num_rows || cols != this->my_num_cols)
- {
- delete[] this->my_values;
- this->my_num_rows = rows;
- this->my_num_cols = cols;
- this->my_values = new
double[this->my_num_rows*this->my_num_cols];
- }
- }
-
- template <class Accessor> inline void assign(const MatrixBase<Accessor>&
m) {
- resize(m.num_rows(),m.num_cols());
- DynamicMatrix<DynamicMAccessor<Layout> >::operator=(m);
- }
-
- // copy construction
- inline Matrix(const Matrix<General,General,Layout>& from){
- this->my_num_rows = from.my_num_rows;
- this->my_num_cols = from.my_num_cols;
- this->my_values = new double[this->my_num_rows*this->my_num_cols];
- DynamicMatrix<DynamicMAccessor<Layout> >::operator=(from);
- }
-
- // constructor from 1-ary operator
- template <class Arg, class Op>
- Matrix(const Arg& arg, const Operator<Op>&){
- Op::eval(*this,arg);
- }
-
- // constructor from 2-ary operator
- template <class LHS, class RHS, class Op>
- Matrix(const LHS& lhs, const RHS& rhs, const Operator<Op>&){
- Op::eval(*this,lhs,rhs);
- }
-};
-
-
-
-struct MSizer {
- template<class Layout>
- static inline void set_size(Matrix<General,General,Layout>& ret, int rows,
int cols){
- ret.set(rows, cols, new double[rows*cols]);
- }
-};
-
-
-#endif
Index: operators.h
===================================================================
RCS file: operators.h
diff -N operators.h
--- operators.h 7 Feb 2009 15:32:56 -0000 1.4
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,94 +0,0 @@
-//-*- c++ -*-
-
-//////////////////////////////////////////////////////////////////////////////////////////////
-// Operators
-//////////////////////////////////////////////////////////////////////////////////////////////
-
-
-// Dot product Vector * Vector
-template<int Size1, typename Precision1, typename Base1,
- int Size2, typename Precision2, typename Base2>
-double operator*(const Vector<Size1, Precision1, Base1>& v1,
- const Vector<Size2, Precision2, Base2>& v2){
- SizeMismatch<Size1, Size2>:: test(v1.size(),v2.size());
- const int s=v1.size();
- double result=0;
- for(int i=0; i<s; i++){
- result+=v1[i]*v2[i];
- }
- return result;
-}
-
-// operator += Vector
-template<int Size1, typename Precision1, typename Base1,
- int Size2, typename Precision2, typename Base2>
-Vector<Size1, Precision1, Base1>& operator += (Vector<Size1, Precision1,
Base1>& lhs,
- const Vector<Size2, Precision2,
Base2>& rhs){
- SizeMismatch<Size1,Size2>::test(lhs.size(),rhs.size());
- const int s=lhs.size();
- for(int i=0; i<s; i++){
- lhs[i]+=rhs[i];
- }
- return lhs;
-}
-
-// operator -= Vector
-template<int Size1, typename Base1, typename Precision1,
- int Size2, typename Precision2, typename Base2>
-Vector<Size1, Precision1, Base1>& operator -= (Vector<Size1, Precision1,
Base1>& lhs,
- const Vector<Size2, Precision2,
Base2>& rhs){
- SizeMismatch<Size1,Size2>::test(lhs.size(),rhs.size());
- const int s=lhs.size();
- for(int i=0; i<s; i++){
- lhs[i]-=rhs[i];
- }
- return lhs;
-}
-
-// operator *= double
-template<int Size, typename Precision, typename Base>
-Vector<Size, Precision, Base>& operator *= (Vector<Size, Precision, Base>&
lhs, double rhs){
- const int s=lhs.size();
- for(int i=0; i<s; i++){
- lhs[i]*=rhs;
- }
- return lhs;
-}
-
-// operator /= double
-template<int Size, typename Precision, typename Base>
-Vector<Size, Precision, Base>& operator /= (Vector<Size, Precision, Base>&
lhs, double rhs){
- const int s=lhs.size();
- for(int i=0; i<s; i++){
- lhs[i]/=rhs;
- }
- return lhs;
-}
-
-// output operator <<
-template <int Size, typename Precision, typename Base>
-inline std::ostream& operator<< (std::ostream& os, const
Vector<Size,Precision,Base>& v){
- for(int i=0; i<v.size(); i++){
- os << v[i] << " ";
- }
- return os;
-}
-
-
-template<int Rows, int Cols, typename Precision, class Base>
-inline std::ostream& operator<< (std::ostream& os, const Matrix<Rows, Cols,
Precision, Base>& m){
- for(int i=0; i < m.num_rows(); i++)
- {
- for(int j=0; j < m.num_cols(); j++)
- {
- if(j != 0)
- os << " ";
- os << m(i,j);
- }
- os << std::endl;
- }
- return os;
-}
-
-
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN TooN.h internal/operators.hh matrix.h mcla...,
Edward Rosten <=