codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
using namespace boost::numeric::ublas; typedef matrix<double> matrix_t; typedef matrix_slice<matrix_t> submatrix; class Tensor : public matrix_t { public: Tensor (const int M, const int N) : matrix_t(M, N) { } Tensor (const matrix_t& t) : matrix_t(t) { } virtual ~Tensor() { } submatrix SubMatrix (const int s1, const int e1, const int s2, const int e2) const; void Print() const; }; // tensor submatrix Tensor::SubMatrix (const int s1, const int e1, const int s2, const int e2) const { return submatrix(*this, slice(s1, 1, e1), slice(s2, 1, e2)); } void Tensor::Print() const { std::cout << *this << std::endl; }
Private
[
?
]
Run code
Submit