Skip to content
Snippets Groups Projects
Commit 4fe66f96 authored by Oliver Sander's avatar Oliver Sander
Browse files

For a some more conformance with the usual C-habits:

Introduced index operator[],  operator() is deprecated now.

[[Imported from SVN: r1287]]
parent 3fdd98dd
No related branches found
No related tags found
No related merge requests found
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef __DUNE_MATRIX_HH__
#define __DUNE_MATRIX_HH__
#ifndef DUNE_MATRIX_HH
#define DUNE_MATRIX_HH
#include <vector>
#include <assert.h>
......@@ -10,6 +10,7 @@
namespace Dune {
/** \brief A generic dynamic matrix
\ingroup Common
*/
template<class T>
class Matrix
......@@ -42,23 +43,36 @@ namespace Dune {
}
/** \brief The index operator */
T& operator()(int row, int col) {
T& operator()(int row, int col) DUNE_DEPRECATED {
assert(0<=row && row<rows_ && 0<=col && col<cols_);
return data[row*cols_ + col];
}
/** \brief The const index operator */
const T& operator()(int row, int col) const {
const T& operator()(int row, int col) const DUNE_DEPRECATED {
assert(0<=row && row<rows_ && 0<=col && col<cols_);
return data[row*cols_ + col];
}
/** \brief The index operator */
T* operator[](int row) {
assert(0<=row && row<rows_);
return &data[row*cols_];
}
/** \brief The const index operator */
const T* operator[](int row) const {
assert(0<=row && row<rows_);
return &data[row*cols_];
}
/** \brief Send the matrix content to the screen*/
void print() const {
for (int row=0; row<rows_; row++) {
for (int col=0; col<cols_; col++)
printf("%g ", (*this)(row, col));
std::cout << (*this)[row][col] << " ";
printf("\n");
std::cout << std::endl;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment