[Genabel-commits] r1703 - pkg/ProbABEL/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Apr 27 23:47:25 CEST 2014
Author: lckarssen
Date: 2014-04-27 23:47:25 +0200 (Sun, 27 Apr 2014)
New Revision: 1703
Modified:
pkg/ProbABEL/src/eigen_mematrix.cpp
pkg/ProbABEL/src/eigen_mematrix.h
Log:
Following Maarten's example: adding more const goodness to ProbABEL's eigen_mematrix code.
Modified: pkg/ProbABEL/src/eigen_mematrix.cpp
===================================================================
--- pkg/ProbABEL/src/eigen_mematrix.cpp 2014-04-27 21:44:09 UTC (rev 1702)
+++ pkg/ProbABEL/src/eigen_mematrix.cpp 2014-04-27 21:47:25 UTC (rev 1703)
@@ -36,7 +36,7 @@
//
template<class DT>
-mematrix<DT>::mematrix(int nr, int nc)
+mematrix<DT>::mematrix(const int nr, const int nc)
{
if (nr <= 0)
{
@@ -149,7 +149,7 @@
}
template<class DT>
-mematrix<DT> mematrix<DT>::operator*(DT multiplyer)
+mematrix<DT> mematrix<DT>::operator*(const DT multiplyer)
{
// MatrixXd add = MatrixXd::Constant(nrow, ncol, toadd);
mematrix<DT> temp(nrow, ncol);
@@ -202,7 +202,7 @@
// operations
//
template<class DT>
-void mematrix<DT>::reinit(int nr, int nc)
+void mematrix<DT>::reinit(const int nr, const int nc)
{
// if (nelements > 0)
// delete[] data;
@@ -226,7 +226,7 @@
}
template<class DT>
-DT mematrix<DT>::get(int nr, int nc)
+DT mematrix<DT>::get(const int nr, const int nc) const
{
#ifndef NDEBUG
if (nc < 0 || nc > ncol -1)
@@ -247,7 +247,7 @@
}
template<class DT>
-void mematrix<DT>::put(DT value, int nr, int nc)
+void mematrix<DT>::put(const DT value, const int nr, const int nc)
{
#ifndef NDEBUG
if (nc < 0 || nc > ncol -1)
@@ -267,7 +267,7 @@
}
template<class DT>
-DT mematrix<DT>::column_mean(int nc)
+DT mematrix<DT>::column_mean(const int nc) const
{
if (nc >= ncol || nc < 0)
{
@@ -288,7 +288,7 @@
}
template<class DT>
-void mematrix<DT>::print(void)
+void mematrix<DT>::print(void) const
{
std::cout << "nrow=" << nrow << "; ncol=" << ncol
<< "; nelements=" << nelements << "\n";
Modified: pkg/ProbABEL/src/eigen_mematrix.h
===================================================================
--- pkg/ProbABEL/src/eigen_mematrix.h 2014-04-27 21:44:09 UTC (rev 1702)
+++ pkg/ProbABEL/src/eigen_mematrix.h 2014-04-27 21:47:25 UTC (rev 1703)
@@ -44,7 +44,7 @@
nrow = ncol = nelements = 0;
data.resize(1, 1);
}
- mematrix(int nr, int nc);
+ mematrix(const int nr, const int nc);
mematrix(const mematrix &M);
~mematrix()
{
@@ -53,33 +53,33 @@
}
mematrix & operator=(const mematrix &M);
- DT & operator[](int i);
+ DT & operator[](const int i);
// mematrix operator+(DT toadd);
mematrix operator+(const mematrix &M);
- mematrix operator-(DT toadd);
+ mematrix operator-(const DT toadd);
mematrix operator-(const mematrix &M);
- mematrix operator*(DT toadd);
+ mematrix operator*(const DT toadd);
mematrix operator*(const mematrix &M);
mematrix operator*(const mematrix *M);
void delete_column(const int delcol);
void delete_row(const int delrow);
- void reinit(int nr, int nc);
+ void reinit(const int nr, const int nc);
- unsigned int getnrow(void)
+ unsigned int getnrow(void) const
{
return nrow;
}
- unsigned int getncol(void)
+ unsigned int getncol(void) const
{
return ncol;
}
- DT get(int nr, int nc);
- void put(DT value, int nr, int nc);
- DT column_mean(int nc);
- DT column_sum(int nc);
- void print(void);
+ DT get(const int nr, const int nc) const;
+ void put(const DT value, const int nr, const int nc);
+ DT column_mean(const int nc) const;
+ DT column_sum(const int nc);
+ void print(void) const;
};
#endif
More information about the Genabel-commits
mailing list