[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[oMetah-devel] ometah/common matrix.cpp matrix.hpp
From: |
Johann |
Subject: |
[oMetah-devel] ometah/common matrix.cpp matrix.hpp |
Date: |
Fri, 11 Mar 2005 14:03:51 -0500 |
CVSROOT: /cvsroot/ometah
Module name: ometah
Branch:
Changes by: Johann <address@hidden> 05/03/11 19:03:50
Modified files:
common : matrix.cpp matrix.hpp
Log message:
* trying to solve a link problem
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/matrix.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/matrix.hpp.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: ometah/common/matrix.cpp
diff -u ometah/common/matrix.cpp:1.2 ometah/common/matrix.cpp:1.3
--- ometah/common/matrix.cpp:1.2 Fri Mar 11 10:23:36 2005
+++ ometah/common/matrix.cpp Fri Mar 11 19:03:50 2005
@@ -1,6 +1,5 @@
-
/***************************************************************************
- * $Id: matrix.cpp,v 1.2 2005/03/11 10:23:36 nojhan Exp $
+ * $Id: matrix.cpp,v 1.3 2005/03/11 19:03:50 nojhan Exp $
* Author : Johann Dréo <address@hidden>
****************************************************************************/
@@ -20,6 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+
//! Test if a vector is comprised in bounds
template<class T>
bool isInBounds( T aVector, T mins, T maxs)
@@ -178,14 +178,14 @@
}
//! Transposition of a matrix
-template<class T, class U>
-U transpose( T &mat)
+template<class T>
+T transpose( T &mat)
{
unsigned int iSize=mat.size();
unsigned int jSize=mat[0].size();
- typename U::value_type aVector;
- U newMat;
+ typename T::value_type aVector;
+ T newMat;
unsigned int i, j;
@@ -317,7 +317,7 @@
//! Find the minimum value of a vector
template<class T, class U>
-T min(U aVector, int begin=0, int during=0)
+T minimum(U aVector, int begin=0, int during=0)
{
if (during==0) {
during = aVector.size() - begin;
@@ -334,6 +334,25 @@
return aMin;
}
+//! Find the maximum value of a vector
+template<class T, class U>
+T maximum(U aVector, int begin=0, int during=0)
+{
+ if (during==0) {
+ during = aVector.size() - begin;
+ }
+
+ T aMax = aVector[begin];
+
+ for (unsigned int i=begin+1; i<during; i++) {
+ if ( aVector[i] > aMax ) {
+ aMax = aVector[i];
+ }
+ }
+
+ return aMax;
+}
+
//! Substraction of two vectors, terms by terms
template<class T>
T substraction(T from, T that)
@@ -364,7 +383,7 @@
//! Calculate the absolute values of a vector
template<class T>
-T abs(T aVector)
+T absolute(T aVector)
{
for(unsigned int i=0; i<aVector.size(); i++){
aVector[i] = abs(aVector[i]);
Index: ometah/common/matrix.hpp
diff -u ometah/common/matrix.hpp:1.3 ometah/common/matrix.hpp:1.4
--- ometah/common/matrix.hpp:1.3 Fri Mar 11 10:23:36 2005
+++ ometah/common/matrix.hpp Fri Mar 11 19:03:50 2005
@@ -1,8 +1,7 @@
-
/***************************************************************************
* matrix.hpp
*
- * $Id: matrix.hpp,v 1.3 2005/03/11 10:23:36 nojhan Exp $
+ * $Id: matrix.hpp,v 1.4 2005/03/11 19:03:50 nojhan Exp $
* Author : Johann Dréo <address@hidden>
****************************************************************************/
@@ -25,6 +24,10 @@
#ifndef MATRIX
#define MATRIX
+#include <vector>
+
+using namespace std;
+
//! Test if a vector is comprised in bounds
template<class T>
bool isInBounds( T aVector, T mins, T maxs );
@@ -50,8 +53,8 @@
T cholesky( T A );
//! Transposition of a matrix
-template<class T, class U>
-U transpose( T &mat );
+template<class T>
+T transpose( T &mat );
//! Calculate a variance-covariance matrix from a list of vector
template<class U>
@@ -63,19 +66,23 @@
//! Calculate the mean of a vector
template<class T, class U>
-T mean( U aVector, int Begin=0, int During=0 );
+T mean( U aVector, int begin=0, int during=0 );
//! Calculate the sum of a vector
template<class T, class U>
-T sum( U aVector, int Begin=0, int During=0 );
+T sum( U aVector, int begin=0, int during=0 );
//! Calculate the standard deviation of a vector
template<class T, class U>
-T stdev( U aVector, int Begin=0, int During=0 );
+T stdev( U aVector, int begin=0, int during=0 );
//! Find the minimum value of a vector
template<class T, class U>
-T min( U aVector, int Begin=0, int During=0 );
+T minimum( U aVector, int begin=0, int during=0 );
+
+//! Find the maximum value of a vector
+template<class T, class U>
+T maximum( U aVector, int begin=0, int during=0 );
//! Substraction of two vectors, terms by terms
template<class T>
@@ -87,6 +94,6 @@
//! Calculate the absolute values of a vector
template<class T>
-T abs( T aVector );
+T absolute( T aVector );
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [oMetah-devel] ometah/common matrix.cpp matrix.hpp,
Johann <=