added operator() to change values

release/4.3a0
Manohar Paluri 2010-03-01 18:07:18 +00:00
parent 6073bdb679
commit 8bf8e4dc1f
1 changed files with 33 additions and 29 deletions

View File

@ -10,13 +10,13 @@
namespace tensors { namespace tensors {
/** Rank 2 Tensor */ /** Rank 2 Tensor */
template<int N1, int N2> template<int N1, int N2>
class Tensor2 { class Tensor2 {
protected: protected:
Tensor1<N1> T[N2]; Tensor1<N1> T[N2];
public: public:
/** default constructor */ /** default constructor */
Tensor2() { Tensor2() {
@ -35,7 +35,11 @@ namespace tensors {
T[j] = a(j); T[j] = a(j);
} }
double operator()(int i, int j) const { const double & operator()(int i, int j) const {
return T[j](i);
}
double & operator()(int i, int j) {
return T[j](i); return T[j](i);
} }
@ -44,7 +48,7 @@ namespace tensors {
N2, J> > operator()(Index<N1, I> i, Index<N2, J> j) const { N2, J> > operator()(Index<N1, I> i, Index<N2, J> j) const {
return Tensor2Expression<Tensor2, Index<N1, I> , Index<N2, J> > (*this); return Tensor2Expression<Tensor2, Index<N1, I> , Index<N2, J> > (*this);
} }
}; };
} // namespace tensors } // namespace tensors