[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[oMetah-devel] ometah/common matrix.hpp random.hpp
From: |
NoJhan |
Subject: |
[oMetah-devel] ometah/common matrix.hpp random.hpp |
Date: |
Sun, 12 Jun 2005 12:10:26 -0400 |
CVSROOT: /cvsroot/ometah
Module name: ometah
Branch:
Changes by: NoJhan <address@hidden> 05/06/12 16:10:25
Modified files:
common : matrix.hpp random.hpp
Log message:
* corrections of the templates
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/matrix.hpp.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/common/random.hpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
Patches:
Index: ometah/common/matrix.hpp
diff -u ometah/common/matrix.hpp:1.12 ometah/common/matrix.hpp:1.13
--- ometah/common/matrix.hpp:1.12 Thu Jun 9 13:55:44 2005
+++ ometah/common/matrix.hpp Sun Jun 12 16:10:25 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: matrix.hpp,v 1.12 2005/06/09 13:55:44 nojhan Exp $
+ * $Id: matrix.hpp,v 1.13 2005/06/12 16:10:25 nojhan Exp $
* Copyright : Université Paris 12 Val-de-Marne
* (61 avenue du Général de Gaulle, 94010, Créteil, France)
* Author : Johann Dréo <address@hidden>
@@ -226,6 +226,38 @@
return newMat;
}
+//! Calculate the mean vector of a matrix
+template<class T>
+vector<T> mean( vector<vector<T> > mat)
+{
+ vector<T> moyDim;
+ moyDim.reserve(mat.size());
+
+ unsigned int i,a;
+ a=mat.size();
+
+ for(i=0;i<a;i++) {
+ moyDim.push_back( mean(mat[i]) );
+ }
+ return moyDim;
+}
+
+//! Calculate the mean of a vector
+template<class T>
+T mean( vector<T> aVector, int begin=0, int during=0)
+{
+ if (during==0) {
+ during = aVector.size() - begin; // if no end : take all
+ }
+
+ T aSum, aMean;
+
+ aSum = sum(aVector, begin, during); // Sum
+ aMean = aSum / (during - begin); // Mean
+
+ return aMean;
+}
+
//! Calculate a variance-covariance matrix from a list of vector
template<class U>
U varianceCovariance( U pop)
@@ -236,7 +268,7 @@
// centered population
// same size as the initial matrix
- U popMeanCentered = filledMatrix(pop.size(),pop[0].size(), 0.0);
+ U popMeanCentered = matrixFilled(pop.size(),pop[0].size(), 0.0);
// centering
// rows
@@ -266,41 +298,9 @@
return popVar;
}
-//! Calculate the mean vector of a matrix
-template<class T, class U>
-T mean( U mat)
-{
- T moyDim;
- moyDim.reserve(mat.size());
-
- unsigned int i,a;
- a=mat.size();
-
- for(i=0;i<a;i++) {
- moyDim.push_back( mean(mat[i]) );
- }
- return moyDim;
-}
-
-//! Calculate the mean of a vector
-template<class T, class U>
-T mean(U aVector, int begin=0, int during=0)
-{
- if (during==0) {
- during = aVector.size() - begin; // if no end : take all
- }
-
- T aSum, aMean;
-
- aSum = Sum(aVector, begin, during); // Sum
- aMean = aSum / (during - begin); // Mean
-
- return aMean;
-}
-
//! Calculate the sum of a vector
-template<class T, class U>
-T sum(U aVector, int begin=0, int during=0)
+template<class T>
+T sum(vector<T> aVector, int begin=0, int during=0)
{
if (during==0) {
during = aVector.size() - begin;
@@ -308,7 +308,7 @@
T aSum=0;
- for (unsigned int j=begin; j<during; j++) {
+ for (int j=begin; j<during; j++) {
aSum = aSum + aVector[j]; // sum
}//for (j)
@@ -317,14 +317,14 @@
}
//! Calculate the standard deviation of a vector
-template<class T, class U>
-T stdev(U aVector, int begin=0, int during=0)
+template<class T>
+T stdev(vector<T> aVector, int begin=0, int during=0)
{
if (during==0) {
during = aVector.size() - begin;
}
- U deviation;
+ vector<T> deviation;
T aMean, aDev, aStd;
aMean = mean(aVector, begin, during); // mean
Index: ometah/common/random.hpp
diff -u ometah/common/random.hpp:1.6 ometah/common/random.hpp:1.7
--- ometah/common/random.hpp:1.6 Thu Jun 9 14:08:39 2005
+++ ometah/common/random.hpp Sun Jun 12 16:10:25 2005
@@ -1,5 +1,5 @@
/***************************************************************************
- * $Id: random.hpp,v 1.6 2005/06/09 14:08:39 nojhan Exp $
+ * $Id: random.hpp,v 1.7 2005/06/12 16:10:25 nojhan Exp $
* Copyright : Université Paris 12 Val-de-Marne
* (61 avenue du Général de Gaulle, 94010, Créteil, France)
* Author : Johann Dréo <address@hidden>
@@ -122,7 +122,7 @@
T compVar = transpose(tempCompVar)[0];
// addition to the mean
- finalPoint = VectorAddition( means, compVar );
+ finalPoint = addition( means, compVar );
return finalPoint;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [oMetah-devel] ometah/common matrix.hpp random.hpp,
NoJhan <=