Browse Source

moved algebra stuff to core and modified the rest

Erik Rodner 13 năm trước cách đây
mục cha
commit
ff2019f198
55 tập tin đã thay đổi với 81 bổ sung3346 xóa
  1. 2 0
      cbaselib/ImageInfo.cpp
  2. 1 1
      classifier/fpclassifier/logisticregression/FPCSMLR.h
  3. 5 5
      classifier/fpclassifier/logisticregression/SLR.cpp
  4. 1 1
      classifier/fpclassifier/logisticregression/SLR.h
  5. 2 2
      classifier/kernelclassifier/GPLaplaceOptimizationProblem.cpp
  6. 2 2
      classifier/kernelclassifier/KCGPLaplaceOneVsAll.cpp
  7. 2 2
      classifier/kernelclassifier/KCGPRegOneVsAll.cpp
  8. 2 2
      classifier/kernelclassifier/KCOneVsAll.cpp
  9. 0 417
      math/algebra/AlgebraTools.cpp
  10. 0 51
      math/algebra/AlgebraTools.h
  11. 0 85
      math/algebra/CholeskyRobust.cpp
  12. 0 51
      math/algebra/CholeskyRobust.h
  13. 0 119
      math/algebra/CholeskyRobustAuto.cpp
  14. 0 43
      math/algebra/CholeskyRobustAuto.h
  15. 0 97
      math/algebra/EigValues.cpp
  16. 0 199
      math/algebra/EigValues.cpp.refactor
  17. 0 90
      math/algebra/EigValues.h
  18. 0 323
      math/algebra/GMSparse2.cpp
  19. 0 155
      math/algebra/GMSparse2.h
  20. 0 81
      math/algebra/GenericMatrix.cpp
  21. 0 107
      math/algebra/GenericMatrix.h
  22. 0 8
      math/algebra/Makefile
  23. 0 103
      math/algebra/Makefile.inc
  24. 0 7
      math/algebra/libdepend.inc
  25. 0 88
      math/algebra/progs/Makefile.inc
  26. 0 74
      math/algebra/progs/calcKernelMatrixProperties.cpp
  27. 0 1
      math/algebra/progs/libdepend.inc
  28. 0 89
      math/algebra/tests/Makefile.inc
  29. 0 134
      math/algebra/tests/TestEigenValue.cpp
  30. 0 48
      math/algebra/tests/TestEigenValue.h
  31. 0 111
      math/algebra_trlan/EigValuesTRLAN.cpp
  32. 0 58
      math/algebra_trlan/EigValuesTRLAN.h
  33. 0 69
      math/algebra_trlan/Eigenproblem.cpp
  34. 0 59
      math/algebra_trlan/Eigenproblem.h
  35. 0 8
      math/algebra_trlan/Makefile
  36. 0 103
      math/algebra_trlan/Makefile.inc
  37. 0 2
      math/algebra_trlan/libdepend.inc
  38. 0 88
      math/algebra_trlan/progs/Makefile.inc
  39. 0 51
      math/algebra_trlan/progs/testTRLAN.cpp
  40. 3 9
      math/ftransform/FTransform.cpp
  41. 4 8
      math/ftransform/FTransform.h
  42. 32 169
      math/ftransform/PCA.cpp
  43. 5 10
      math/ftransform/PCA.h
  44. 1 4
      math/ftransform/libdepend.inc
  45. 5 5
      math/kernels/KernelData.cpp
  46. 2 2
      math/kernels/KernelData.h
  47. 1 1
      math/kernels/libdepend.inc
  48. 1 1
      math/pdf/PDFGaussian.cpp
  49. 1 1
      math/pdf/libdepend.inc
  50. 0 192
      math/progs/testEigenvalues.cpp
  51. 3 4
      optimization/quadprog/QuadProg++.cpp
  52. 1 1
      optimization/quadprog/libdepend.inc
  53. 2 2
      regression/gpregression/GPRegressionOptimizationProblem.cpp
  54. 2 2
      regression/gpregression/RegGaussianProcess.cpp
  55. 1 1
      regression/gpregression/modelselcrit/GPMSCLooEstimates.cpp

+ 2 - 0
cbaselib/ImageInfo.cpp

@@ -308,6 +308,8 @@ ImageInfo::loadCategoryInfo(QDomElement *anElement)
 	label.setCategoryName(labelName);
 	label.setColor(color);
 	labels_.push_back(label);
+
+  return true;
 }
 
 //! A protected member parsing string data and returning a BoundingBox from it

+ 1 - 1
classifier/fpclassifier/logisticregression/FPCSMLR.h

@@ -13,7 +13,7 @@
 #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
 #include "vislearning/classifier/fpclassifier/logisticregression/SLR.h"
 #include "vislearning/cbaselib/FeaturePool.h"
-#include "vislearning/math/algebra/GMSparse2.h"
+#include "core/algebra/GMSparseVectorMatrix.h"
 
 namespace OBJREC {
 

+ 5 - 5
classifier/fpclassifier/logisticregression/SLR.cpp

@@ -146,9 +146,9 @@ int SLR::stepwise_regression(Examples &x, int classno)
 	int fnum = x.size();
 	
 	// create Datamatrix
-	GMSparse2 X;
+	GMSparseVectorMatrix X;
 	
-	GMSparse2 Y;
+	GMSparseVectorMatrix Y;
 	
 	vector<int> count(2, 0);
 
@@ -266,7 +266,7 @@ int SLR::stepwise_regression(Examples &x, int classno)
 	
 #undef NORMALIZATION
 #ifdef NORMALIZATION
-	GMSparse2 Xred;
+	GMSparseVectorMatrix Xred;
 	Xred.resize(X.rows(), X.cols());
 
 	for(int r = 0; r < (int)Xred.rows(); r++)
@@ -288,7 +288,7 @@ int SLR::stepwise_regression(Examples &x, int classno)
 
 	fnum = X.rows();
 	
-	GMSparse2 xY;
+	GMSparseVectorMatrix xY;
 #ifdef NORMALIZATION
 	Xred.mult(Y, xY, true);
 #else
@@ -298,7 +298,7 @@ int SLR::stepwise_regression(Examples &x, int classno)
 	weight.setDim(fdim);
 
 	// for faster Computing Xw = X*w	
-	GMSparse2 Xw;
+	GMSparseVectorMatrix Xw;
 	X.mult(weight, Xw, false, true);
 	SparseVector S(fnum);
 

+ 1 - 1
classifier/fpclassifier/logisticregression/SLR.h

@@ -11,7 +11,7 @@
 
 #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
 #include "vislearning/cbaselib/FeaturePool.h"
-#include "vislearning/math/algebra/GMSparse2.h"
+#include "core/algebra/GMSparseVectorMatrix.h"
 
 namespace OBJREC {
 

+ 2 - 2
classifier/kernelclassifier/GPLaplaceOptimizationProblem.cpp

@@ -9,8 +9,8 @@
 #include <iostream>
 
 #include "core/vector/Algorithms.h"
-#include "vislearning/math/algebra/CholeskyRobust.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobust.h"
+#include "core/algebra/CholeskyRobustAuto.h"
 
 #include "vislearning/math/kernels/OptimKernelParameterGradInterface.h"
 #include "GPLaplaceOptimizationProblem.h"

+ 2 - 2
classifier/kernelclassifier/KCGPLaplaceOneVsAll.cpp

@@ -15,8 +15,8 @@
 #include "core/optimization/FirstOrderRasmussen.h"
 
 #include "vislearning/classifier/kernelclassifier/GPLaplaceOptimizationProblem.h"
-#include "vislearning/math/algebra/CholeskyRobust.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobust.h"
+#include "core/algebra/CholeskyRobustAuto.h"
 
 #include "KCGPLaplaceOneVsAll.h"
 #include "LHCumulativeGauss.h"

+ 2 - 2
classifier/kernelclassifier/KCGPRegOneVsAll.cpp

@@ -19,8 +19,8 @@
 #include "core/optimization/FirstOrderRasmussen.h"
 
 #include "vislearning/regression/gpregression/GPRegressionOptimizationProblem.h"
-#include "vislearning/math/algebra/CholeskyRobust.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobust.h"
+#include "core/algebra/CholeskyRobustAuto.h"
 
 #include "KCGPRegOneVsAll.h"
 #include <limits>

+ 2 - 2
classifier/kernelclassifier/KCOneVsAll.cpp

@@ -11,8 +11,8 @@
 
 #include "core/vector/Algorithms.h"
 
-#include "vislearning/math/algebra/CholeskyRobust.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobust.h"
+#include "core/algebra/CholeskyRobustAuto.h"
 #include "vislearning/regression/regressionbase/TeachWithInverseKernelMatrix.h"
 
 using namespace std;

+ 0 - 417
math/algebra/AlgebraTools.cpp

@@ -1,417 +0,0 @@
-/**
-* @file AlgebraTools.cpp
-* @brief AlgebraTools Class
-* @author Michael Koch
-* @date 08/19/2008
-
- */
-#ifdef NOVISUAL
-#include <vislearning/nice_nonvis.h>
-#else
-#include <vislearning/nice.h>
-#endif
-
-#include "AlgebraTools.h"
-
-using namespace OBJREC;
-using namespace std;
-using namespace NICE;
-
-
-
-//calculate mean
-
-
-// refactor-nice.pl: check this substitution
-// old: void AlgebraTools::calculateMean(const Matrix &data, Vector &mean)
-void AlgebraTools::calculateMean(const NICE::Matrix &data, NICE::Vector &mean)
-{
-    uint features = data.rows();
-    uint dimension = data.cols();
-    mean = Vector(dimension);
-    for (uint k = 0;k < mean.size();k++)
-    {
-        mean[k] = 0.0;
-    }
-    for (uint r = 0;r < features;r++)
-    {
-        for (uint c = 0;c < dimension;c++)
-        {
-            // refactor-nice.pl: check this substitution
-            // old: if (isnan(data[r][c]) || isinf(data[r][c]))
-            if(isnan(data(r, c)) ||(isnan(data(r, c))))
-            {
-                //strange data
-            }
-            else
-            {
-                // refactor-nice.pl: check this substitution
-                // old: mean[c] = mean[c] + data[r][c];
-                mean[c] = mean[c] + data(r, c);
-            }
-        }
-    }
-    for (uint r = 0;r < mean.size();r++)
-    {
-        if (features > 0)
-        {
-            mean[r] = mean[r] / (double)features;
-        }
-    }
-    //      cout<<"mean-calc"<<mean<<endl;
-}
-
-//calculate mean
-void AlgebraTools::calculateMean(const NICE::Matrix &data, NICE::Vector &mean, NICE::Vector &sigma)
-{
-    uint features = data.rows();
-    uint dimension = data.cols();
-    mean = Vector(dimension);
-    sigma = Vector(dimension);
-
-    for (uint k = 0;k < mean.size();k++)
-    {
-        mean[k] = 0.0;
-        sigma[k] = 0.0;
-    }
-    for (uint r = 0;r < features;r++)
-    {
-        for (uint c = 0;c < dimension;c++)
-        {
-
-            // refactor-nice.pl: check this substitution
-            // old: if (isnan(data[r][c]) || isinf(data[r][c]))
-            if(isnan(data(r, c)) ||(isnan(data(r, c))))
-            {
-                //strange data
-            }
-            else
-            {
-                // refactor-nice.pl: check this substitution
-                // old: mean[c] = mean[c] + data[r][c];
-                mean[c] = mean[c] + data(r, c);
-            }
-
-        }
-    }
-    for (uint k = 0;k < mean.size();k++)
-    {
-        if (features > 0)
-        {
-            mean[k] = mean[k] / (double)features;
-        }
-    }
-    //      cout<<"mean-calc"<<mean<<endl;
-    //calc sigma
-    for (uint r = 0;r < features;r++)
-    {
-        for (uint c = 0;c < dimension;c++)
-        {
-
-            // refactor-nice.pl: check this substitution
-            // old: sigma[c] = sigma[c] + (mean[c] - data[r][c]) * (mean[c] - data[r][c]);
-            sigma[c] = sigma[c] + (mean[c] -data(r, c)) * (mean[c] -data(r, c));
-
-        }
-    }
-    for (uint k = 0;k < sigma.size();k++)
-    {
-        if (features > 0)
-        {
-            sigma[k] = sigma[k] / features;
-            sigma[k] = sqrt(sigma[k]);
-        }
-    }
-}
-
-
-// refactor-nice.pl: check this substitution
-// old: double AlgebraTools::trace(const Matrix &M)
-double AlgebraTools::trace(const NICE::Matrix &M)
-{
-    if (M.cols() != M.rows())
-    {
-        throw("non quadratic Matrix");
-    }
-    else
-    {
-        uint n = M.rows();
-        double sum = 0.0;
-        for (uint i = 0;i < n;i++)
-        {
-            // refactor-nice.pl: check this substitution
-            // old: sum += M[i][i];
-            sum +=M(i, i);
-        }
-        return sum;
-    }
-
-}
-
-
-
-
-
-double AlgebraTools::matrixRowColNorm(const NICE::Matrix &M)
-{
-    //max row norm
-    double maxr = 0.0, maxc = 0.0;
-    for (uint r = 0;r < M.rows();r++)
-    {
-        double sum = 0.0;
-        for (uint c = 0;c < M.cols();c++)
-        {
-            sum +=fabs(M(r, c));
-        }
-        if (r == 0)
-        {
-            maxr = sum;
-        }
-        else
-        {
-            if (sum > maxr)
-            {
-                maxr = sum;
-            }
-        }
-    }
-
-    //max col norm
-    for (uint c = 0;c < M.cols();c++)
-    {
-        double sum = 0.0;
-        for (uint r = 0;r < M.rows();r++)
-        {
-            sum +=fabs(M(r, c));
-        }
-        if (c == 0)
-        {
-            maxc = sum;
-        }
-        else
-        {
-            if (sum > maxc)
-            {
-                maxc = sum;
-            }
-        }
-    }
-    if (maxr > maxc)
-    {
-        return maxr;
-    }
-    else
-    {
-        return maxc;
-    }
-}
-void AlgebraTools::orthogonalize(Matrix &M, bool iterative)
-{
-#if 1
-    fprintf (stderr, "AlgebraTools::orthogonalize: FIX THIS CODE !\n");
-    exit(-1);
-#else
-
-    //iterative
-    if (iterative)
-    {
-        NICE::Vector onevec = Vector(M.rows());
-        for (uint k = 0;k < onevec.size();k++)
-        {
-            onevec[k] = 1.0;
-        }
-        NICE::Matrix One = diag(onevec);
-        NICE::Matrix Mt = M.transpose();
-        NICE::Matrix error;
-	error.multiply (M, Mt);
-	error -= One;
-        double errornorm = matrixRowColNorm(error);
-        double deltaerror = 2.0;
-        //reduceddim
-        while (deltaerror > 1.0e-03)
-        {
-            double norm = matrixRowColNorm(M);
-            if (norm > 0.0)
-            {
-                // refactor: M = (1.0 / norm) * M;
-                M *= (1.0 / norm);
-            }
-            Mt = M.transpose();
-            M = 1.5 * M - 0.5 * ((M * Mt) * M);
-            Mt = M.transpose();
-            //convergencetest
-            error = (M * (Mt) - One);
-
-            deltaerror = errornorm;
-            errornorm = matrixRowColNorm(error);
-            deltaerror = fabs(deltaerror - errornorm);
-
-        }
-    }
-    else
-    {
-        //noniteratve
-        // refactor-nice.pl: check this substitution
-        // old: Matrix D, eigenvectors;
-        NICE::Matrix D, eigenvectors;
-        // refactor-nice.pl: check this substitution
-        // old: Vector eigenvalue;
-        NICE::Vector eigenvalue;
-        // refactor-nice.pl: check this substitution
-        // old: Matrix MMt = M*!M;
-        NICE::Matrix MMt;
-	MMt.multiply ( M, M.transpose() );
-        Eigenvalue(MMt, eigenvalue, eigenvectors);
-        D = diag(eigenvalue);
-        for (int d = 0;d < D.rows();d++)
-        {
-            // refactor-nice.pl: check this substitution
-            // old: if (D[d][d] > 0.0)
-            if(D(d, d) > 0.0)
-            {
-                // refactor-nice.pl: check this substitution
-                // old: D[d][d] = 1.0 / sqrt(D[d][d]);
-                D(d, d) = 1.0 /D(d, d));
-            }
-        }
-        // refactor-nice.pl: check this substitution
-        // old: Matrix Et = !eigenvectors;
-        NICE::Matrix Et = !eigenvectors;
-        // refactor-nice.pl: check this substitution
-        // old: Matrix MMtinvsqrt = eigenvectors * D * Et;
-        NICE::Matrix MMtinvsqrt = eigenvectors * D * Et;
-        M = MMtinvsqrt * M;
-    }
-#endif
-}
-// refactor-nice.pl: check this substitution
-// old: Vector AlgebraTools::meanOfMatrix(const Matrix &M)
-NICE::Vector AlgebraTools::meanOfMatrix(const NICE::Matrix &M)
-{
-#if 1
-    fprintf (stderr, "AlgebraTools:: FIX THIS CODE !\n");
-    exit(-1);
-#else
-    // refactor-nice.pl: check this substitution
-    // old: Vector meanvec = Vector(M.cols());
-    NICE::Vector meanvec = Vector(M.cols());
-    //initialize meanvec
-    for (uint k = 0;k < meanvec.size();k++)
-    {
-        meanvec[k] = 0.0;
-    }
-    //calculate mean
-    for (int f = 0;f < M.rows();f++)
-    {
-        meanvec = M[f] + meanvec;
-    }
-    if (M.rows() > 0)
-    {
-        meanvec = 1.0 / M.rows() * meanvec;
-    }
-    return meanvec;
-#endif
-}
-// refactor-nice.pl: check this substitution
-// old: double AlgebraTools::meanOfVector(const Vector &vec)
-double AlgebraTools::meanOfVector(const NICE::Vector &vec)
-{
-#if 1
-    fprintf (stderr, "AlgebraTools:: FIX THIS CODE !\n");
-    exit(-1);
-#else
-    double mean = 0.0;
-    for (uint k = 0;k < vec.size();k++)
-    {
-        mean += vec[k];
-    }
-    if (vec.size() > 0)
-    {
-        mean /= vec.size();
-    }
-    return mean;
-#endif
-}
-
-// refactor-nice.pl: check this substitution
-// old: Matrix AlgebraTools::vectorToMatrix(const Vector &vec)
-NICE::Matrix AlgebraTools::vectorToMatrix(const NICE::Vector &vec)
-{
-    if (vec.size() > 0)
-    {
-        // refactor-nice.pl: check this substitution
-        // old: Matrix D = Matrix(vec.size(), 1, 0);
-        NICE::Matrix D = Matrix(vec.size(), 1, 0);
-        for (uint k = 0;k < vec.size();k++)
-        {
-            // refactor-nice.pl: check this substitution
-            // old: D[k][0] = vec[k];
-            D(k, 0) = vec[k];
-        }
-        return D;
-    }
-    else
-    {
-        return Matrix();
-    }
-}
-// refactor-nice.pl: check this substitution
-// old: Vector AlgebraTools::matrixToVector(const Matrix &mat)
-NICE::Vector AlgebraTools::matrixToVector(const NICE::Matrix &mat)
-{
-    if (mat.rows() < 1 && mat.cols() < 1)
-    {
-        fprintf(stderr, "Matrix has no entries!");
-    }
-    if (mat.rows() > mat.cols())
-    {
-        // refactor-nice.pl: check this substitution
-        // old: Vector tmp = Vector(mat.rows());
-        NICE::Vector tmp (mat.rows());
-	tmp.set(0.0);
-        for (uint i = 0;i < mat.rows();i++)
-        {
-            // refactor-nice.pl: check this substitution
-            // old: tmp[i] = mat[i][0];
-            tmp[i] =mat(i, 0);
-        }
-        return tmp;
-    }
-    else
-    {
-        // refactor-nice.pl: check this substitution
-        // old: Vector tmp = Vector(mat.cols());
-        NICE::Vector tmp = Vector(mat.cols());
-        for (uint i = 0;i < mat.cols();i++)
-        {
-            // refactor-nice.pl: check this substitution
-            // old: tmp[i] = mat[0][i];
-            tmp[i] =mat(0, i);
-        }
-        return tmp;
-    }
-}
-// refactor-nice.pl: check this substitution
-// old: Matrix AlgebraTools::diag(const Vector &diagonalelements)
-NICE::Matrix AlgebraTools::diag(const NICE::Vector &diagonalelements)
-{
-    if (diagonalelements.size() > 0)
-    {
-        // refactor-nice.pl: check this substitution
-        // old: Matrix D = Matrix(diagonalelements.size(), diagonalelements.size(), 0);
-        NICE::Matrix D (diagonalelements.size(), diagonalelements.size());
-	D.set(0.0);
-        for (uint k = 0;k < diagonalelements.size();k++)
-        {
-            // refactor-nice.pl: check this substitution
-            // old: D[k][k] = diagonalelements[k];
-            D(k, k) = diagonalelements[k];
-        }
-        return D;
-    }
-    else
-    {
-        return Matrix();
-    }
-
-}

+ 0 - 51
math/algebra/AlgebraTools.h

@@ -1,51 +0,0 @@
-/** 
- * @file AlgebraTools.h
- * @brief Algebra Tools
- * @author Michael Koch,Erik Rodner
- * @date 05/20/2009
-
- */
-#ifndef AlgebraToolsINCLUDE
-#define AlgebraToolsINCLUDE
-
-#include <vislearning/nice_nonvis.h>
-
-namespace OBJREC 
-{
-
-class AlgebraTools
-{
-     public:
-     //FIXME: find a better place
-     template<typename T>
-		static T sign(T n);
-          
-     static void calculateMean(const NICE::Matrix &data, NICE::Vector &mean);
-     static void calculateMean(const NICE::Matrix &data,NICE::Vector &mean,NICE::Vector &sigma);
-     static void orthogonalize(NICE::Matrix &M,bool iterative=true);
-     static double trace(const NICE::Matrix &M);
-     static double matrixRowColNorm(const NICE::Matrix &M);
-     static NICE::Matrix vectorToMatrix(const NICE::Vector &vec);
-     static NICE::Vector matrixToVector(const NICE::Matrix &mat);
-      /**
-      * Converting Vector to diagonal Matrix
-      * @param diagonalelements diagonal elements
-      * @return Matrix with diagonal elements
-       */
-     static NICE::Matrix diag(const NICE::Vector &diagonalelements);
-     static double meanOfVector(const NICE::Vector &vec);
-     static NICE::Vector meanOfMatrix(const NICE::Matrix &M);
-};
-
-template<typename T>
-	T AlgebraTools::sign(T n)
-{
-     if (n < 0) return -1;
-     if (n > 0) return 1;
-     return 0;
-}
-
-}
-
-#endif
-

+ 0 - 85
math/algebra/CholeskyRobust.cpp

@@ -1,85 +0,0 @@
-/** 
-* @file CholeskyRobust.cpp
-* @brief robust cholesky decomposition by adding some noise
-* @author Erik Rodner
-* @date 01/06/2010
-
-*/
-#include <iostream>
-
-#include "CholeskyRobust.h"
-#include "core/vector/Algorithms.h"
-
-#ifdef NICE_USELIB_CUDACHOLESKY
-#include "cholesky-gpu/niceinterface/CudaCholeskyNICE.h"
-#endif
-
-using namespace std;
-using namespace NICE;
-using namespace OBJREC;
-		
-		
-CholeskyRobust::CholeskyRobust ( const CholeskyRobust & src )
-	: m_verbose(src.m_verbose), m_noiseStep(src.m_noiseStep),
-	  m_minMatrixLogDeterminant(src.m_minMatrixLogDeterminant),
-	  m_useCuda(src.m_useCuda), m_logDetMatrix(src.m_logDetMatrix)
-{
-}
-
-double CholeskyRobust::robustChol ( const Matrix & A, Matrix & cholA )
-{
-	// this additional memory requirement could be skipped
-	// with a modified cholesky routine
-	Matrix ARegularized (A);
-
-	if ( m_verbose )
-		cerr << "CholeskyRobust::robustChol: Adding noise " << m_noiseStep << endl;
-	ARegularized.addIdentity ( m_noiseStep );
-
-#ifdef NICE_USELIB_CUDACHOLESKY
-	if ( m_useCuda ) 
-		CudaCholeskyNICE::choleskyDecomp ( ARegularized, cholA );
-	else
-#endif
-		choleskyDecompLargeScale ( ARegularized, cholA );
-	
-	m_logDetMatrix = 2*triangleMatrixLogDet ( cholA );
-	if ( m_verbose ) 
-			cerr << "CholeskyRobust::robustChol: Cholesky condition: " << m_logDetMatrix << endl;
-
-	if ( !finite(m_logDetMatrix) )
-	{
-		fthrow(Exception, "The matrix has infinite or not defined log determinant !" );
-	}
-
-	return m_noiseStep;
-}
-
-double CholeskyRobust::robustCholInv ( const Matrix & A, Matrix & invA )
-{
-	Matrix G;
-	double noise = robustChol ( A, G  );
-	if ( m_verbose )
-			cerr << "CholeskyRobust::robustChol: Cholesky inversion" << endl;
-
-	choleskyInvertLargeScale ( G, invA );
-
-	return noise;
-}
-
-
-CholeskyRobust::~CholeskyRobust ()
-{
-}
-
-CholeskyRobust::CholeskyRobust ( bool verbose, double noiseStep, double minMatrixLogDeterminant, bool useCuda ) :
-	m_verbose(verbose), m_noiseStep(noiseStep), m_minMatrixLogDeterminant(minMatrixLogDeterminant), m_useCuda ( useCuda )
-{
-	m_logDetMatrix = m_minMatrixLogDeterminant;
-}
-
-CholeskyRobust *CholeskyRobust::clone(void) const
-{
-	CholeskyRobust *dst = new CholeskyRobust ( *this );
-	return dst;
-}

+ 0 - 51
math/algebra/CholeskyRobust.h

@@ -1,51 +0,0 @@
-/** 
-* @file CholeskyRobust.h
-* @author Erik Rodner
-* @date 01/06/2010
-
-*/
-#ifndef _NICE_OBJREC_CHOLESKYROBUSTINCLUDE
-#define _NICE_OBJREC_CHOLESKYROBUSTINCLUDE
-
-#include <limits>
-#include "core/vector/MatrixT.h"
-
-namespace OBJREC {
-  
-/** @class CholeskyRobust
- * robust cholesky decomposition by adding some noise 
- *
- * @author Erik Rodner
- */
-class CholeskyRobust
-{
-
-    protected:
-		const bool m_verbose;
-		const double m_noiseStep;
-		const double m_minMatrixLogDeterminant;
-		const bool m_useCuda;
-
-		double m_logDetMatrix;
-
-    public:
-  
-  		CholeskyRobust ( bool verbose = true, double noiseStep = 1e-8, double minMatrixLogDeterminant = - std::numeric_limits<double>::max(), bool useCuda = true );
-
-		CholeskyRobust ( const CholeskyRobust & src );
-
-		virtual ~CholeskyRobust ();
-  	
-		virtual double robustChol ( const NICE::Matrix & A, NICE::Matrix & cholA );
-
-		virtual double robustCholInv ( const NICE::Matrix & A, NICE::Matrix & invA );
-
-		double getLastLogDet () const { return m_logDetMatrix; };
-
-		virtual CholeskyRobust *clone(void) const;
-     
-};
-
-}
-
-#endif

+ 0 - 119
math/algebra/CholeskyRobustAuto.cpp

@@ -1,119 +0,0 @@
-/** 
-* @file CholeskyRobustAuto.cpp
-* @brief robust cholesky decomposition by adding some noise
-* @author Erik Rodner
-* @date 01/06/2010
-
-*/
-#include <iostream>
-
-#include "CholeskyRobustAuto.h"
-#include "core/vector/Algorithms.h"
-
-#undef NICE_USELIB_CUDACHOLESKY
-#ifdef NICE_USELIB_CUDACHOLESKY
-#include "cholesky-gpu/niceinterface/CudaCholeskyNICE.h"
-#endif
-
-using namespace std;
-using namespace NICE;
-using namespace OBJREC;
-
-const int maxiterations = 30;
-const bool exponential_noise = true;
-
-CholeskyRobustAuto::CholeskyRobustAuto ( const CholeskyRobustAuto & src )
-	: CholeskyRobust ( src )
-{
-}
-
-double CholeskyRobustAuto::robustChol ( const Matrix & A, Matrix & cholA )
-{
-	// this additional memory requirement could be skipped
-	// with a modified cholesky routine
-	Matrix ARegularized (A);
-
-	if ( m_verbose ) 
-		cerr << "CholeskyRobustAuto::robustChol: A " << A.rows() << " x " << A.cols() << endl;
-
-	int i = 0;
-	double noise = 0.0;
-	double noiseStepExp = m_noiseStep;
-	bool robust = true;
-	do {
-		robust = true;
-
-		if ( m_verbose )
-			cerr << "CholeskyRobustAuto::robustChol: Cholesky decomposition" << endl;
-
-		try {
-			//choleskyDecomp ( ARegularized, cholA );
-			#ifdef NICE_USELIB_CUDACHOLESKY
-			if ( m_useCuda ) 
-				CudaCholeskyNICE::choleskyDecomp ( ARegularized, cholA );
-			else
-			#endif
-				choleskyDecompLargeScale ( ARegularized, cholA );
-#ifdef NICE_USELIB_CUDACHOLESKY
-		} catch ( CudaError & e ) {
-			fthrow(CudaError, e.what() );
-#endif
-		} catch ( Exception ) {
-			if ( m_verbose )
-				cerr << "CholeskyRobustAuto::robustChol: failed!" << endl;
-			robust = false;
-		}
-
-		if ( robust && cholA.containsNaN() ) 
-		{
-			if ( m_verbose )
-				cerr << "CholeskyRobustAuto::robustChol: cholesky matrix contains NaN values" << endl;
-			robust = false; 
-		}
-
-		m_logDetMatrix = m_minMatrixLogDeterminant;
-		if ( robust ) 
-		{
-			m_logDetMatrix = 2*triangleMatrixLogDet ( cholA );
-			if ( m_verbose ) 
-				cerr << "CholeskyRobustAuto::robustChol: Cholesky condition: " << m_logDetMatrix << endl;
-		}
-
-
-		if ( isnan(m_logDetMatrix) || (m_logDetMatrix < m_minMatrixLogDeterminant) ) {	
-			robust = false;
-		}
-
-		if ( !robust ) {	
-			robust = false;
-			if ( m_verbose ) 
-				cerr << "CholeskyRobustAuto::robustChol: Adding noise " << noiseStepExp << endl;
-			ARegularized.addIdentity ( noiseStepExp );
-			noise += noiseStepExp;
-
-			if ( exponential_noise ) 
-				noiseStepExp *= 10.0;
-		}
-
-		i++;
-	} while ( !robust && (i < maxiterations) );
-
-	if ( !robust ) 
-		fthrow( Exception, "Inverse matrix is instable (please adjust the noise step term)" );
-
-	return noise;
-}
-
-CholeskyRobustAuto::~CholeskyRobustAuto ()
-{
-}
-
-CholeskyRobustAuto::CholeskyRobustAuto ( bool verbose, double noiseStep, double minMatrixLogDeterminant, bool useCuda ) :
-	CholeskyRobust ( verbose, noiseStep, minMatrixLogDeterminant, useCuda )
-{
-}
-		
-CholeskyRobustAuto *CholeskyRobustAuto::clone(void) const
-{
-	return new CholeskyRobustAuto ( *this );
-}

+ 0 - 43
math/algebra/CholeskyRobustAuto.h

@@ -1,43 +0,0 @@
-/** 
-* @file CholeskyRobustAuto.h
-* @author Erik Rodner
-* @date 01/06/2010
-
-*/
-#ifndef _NICE_OBJREC_CHOLESKYROBUSTAUTOINCLUDE
-#define _NICE_OBJREC_CHOLESKYROBUSTAUTOINCLUDE
-
-#include <limits>
-#include "core/vector/MatrixT.h"
-
-#include "CholeskyRobust.h"
-
-namespace OBJREC {
-  
-/** @class CholeskyRobustAuto
- * robust cholesky decomposition by adding some noise 
- *
- * @author Erik Rodner
- */
-class CholeskyRobustAuto : public CholeskyRobust
-{
-
-    protected:
-
-    public:
-		CholeskyRobustAuto ( const CholeskyRobustAuto & src );
-  
-  		CholeskyRobustAuto ( bool verbose = true, double noiseStep = 1e-8, double minMatrixLogDeterminant = - std::numeric_limits<double>::max(),
-			bool useCuda = true );
-
-		virtual ~CholeskyRobustAuto ();
-  	
-		virtual double robustChol ( const NICE::Matrix & A, NICE::Matrix & cholA );
-		
-		virtual CholeskyRobustAuto *clone(void) const;
-     
-};
-
-}
-
-#endif

+ 0 - 97
math/algebra/EigValues.cpp

@@ -1,97 +0,0 @@
-/** 
- * @file EigValues.cpp
- * @brief EigValues Class
- * @author Michael Koch
- * @date 08/19/2008
-*/
-
-#ifdef NOVISUAL
-#include <vislearning/nice_nonvis.h>
-#else
-#include <vislearning/nice.h>
-#endif
-     
-#include <iostream>
-     
-#include "EigValues.h"
-
-using namespace OBJREC;
-#define DEBUG_ARNOLDI
-// #undef DEBUG_ARNOLDI
-     
-using namespace std;
-// refactor-nice.pl: check this substitution
-// old: using namespace ice;
-using namespace NICE;
-     
-void EVArnoldi::getEigenvalues(const GenericMatrix &data,Vector &eigenvalues,Matrix &eigenvectors,uint k)
-{
-          
-    if(data.rows()!=data.cols())
-    {
-	throw("EVArnoldi: matrix has to be quadratic");
-    }
-          
-    if(k<=0)
-    {
-       throw("EVArnoldi: please use k>0.");
-    }
-#ifdef DEBUG_ARNOLDI
-    fprintf(stderr,"Initialize Matrices\n");
-#endif
-    uint n=data.cols();
-    NICE::Matrix rmatrix=Matrix(n,k,0);//=eigenvectors
-    NICE::Matrix qmatrix=Matrix(n,k,0);//saves data =eigenvectors
-    eigenvalues.resize(k);
-    NICE::Vector q=Vector(n);
-    NICE::Vector r=Vector(n);
-   
-#ifdef DEBUG_ARNOLDI
-    fprintf(stderr,"Random Initialization\n");
-#endif
-
-    //random initialisation
-    for(uint i=0;i<k;i++)
-	for(uint j=0;j<n;j++)
-	     rmatrix(j, i)=drand48();
-   
-    //reduceddim
-    double delta=1.0;
-    uint iteration=0;
-    while (delta>mindelta &&iteration<maxiterations)
-    {
-	NICE::Vector rold (rmatrix.getColumn(k-1));
-	for(uint reduceddim=0;reduceddim<k;reduceddim++)
-	{
-	     //get Vector r_k of Matrix
-	     q=rmatrix.getColumn(reduceddim);
-	     q.normalizeL2();
-	     // q=r_k/||r_k||
-	     qmatrix.getColumnRef(reduceddim) = q;
-	     
-	     Vector currentCol = rmatrix.getColumnRef(reduceddim); // FIXME
-	     data.multiply(currentCol,q); //r_{k+1}=A*q
-	     
-	     for(uint j=0;j<reduceddim;j++)
-		  rmatrix.getColumnRef(reduceddim) -= qmatrix.getColumn(j)*(qmatrix.getColumn(j).scalarProduct(rmatrix.getColumn(reduceddim)));
-	}
-	//convergence stuff
-	NICE::Vector diff=rold-rmatrix.getColumn(k-1);
-	delta=diff.normL2();
-	iteration++;
-#ifdef DEBUG_ARNOLDI
-	fprintf (stderr, "EVArnoldi: [%d] delta=%f\n", iteration, delta );
-#endif
-    }
-    eigenvectors=rmatrix;
-  
-    for(uint i=0;i<k;i++)
-    {
-	NICE::Vector tmp;
-	eigenvectors.getColumnRef(i).normalizeL2();
-	data.multiply(tmp,eigenvectors.getColumn(i));
-	eigenvalues[i]=tmp.scalarProduct( eigenvectors.getColumn(i) );
-    }
-}
-     
-

+ 0 - 199
math/algebra/EigValues.cpp.refactor

@@ -1,199 +0,0 @@
-/** 
- * @file EigValues.cpp
- * @brief EigValues Class
- * @author Michael Koch
- * @date 08/19/2008
-*/
-#ifdef NOVISUAL
-#include <nice_nonvis.h>
-#else
-#include <nice.h>
-#endif
-    
-#include <core/iceconversion/convertice.h>
-#include <image_nonvis.h>
-
-#include <iostream>
-     
-#include "EigValues.h"
-#include <time.h>
-
-#define DEBUG_ARNOLDI
-     
-using namespace std;
-// refactor-nice.pl: check this substitution
-// old: using namespace ice;
-using namespace NICE;
-     
-void EVArnoldi::getEigenvalues(const GenericMatrix &data,Vector &eigenvalues,Matrix &eigenvectors,uint k)
-{
-    if(data.rows()!=data.cols())
-    {
-	throw("EVArnoldi: matrix has to be quadratic");
-    }
-          
-    if(k<=0)
-    {
-       throw("EVArnoldi: please use k>0.");
-    }
-   
-    uint n=data.cols();
-    ice::Matrix rmatrix (k,n,0);
-    ice::Matrix qmatrix (k,n,0);//saves data =eigenvectors
-    ice::Vector q (n);
-    ice::Vector r (n);
-    
-    eigenvalues.resize(n);
-   
-    srand48(time(NULL));
-    //random initialisation
-    for(uint i=0;i<rmatrix.rows();i++)
-	for(uint j=0;j<rmatrix.cols();j++)
-	     rmatrix[i][j]=drand48();
-   
-    //reduceddim
-    double delta=1.0;
-    uint iteration=0;
-    while (delta>mindelta &&iteration<maxiterations)
-    {
-	ice::Vector rold (rmatrix[k-1]);
-	for(uint reduceddim=0;reduceddim<k;reduceddim++)
-	{
-	     //get Vector r_k of Matrix
-	     q=rmatrix[reduceddim];
-	     q.Normalize();
-	     // q=r_k/||r_k||
-	     qmatrix[reduceddim]=q;
-	     
-	     NICE::Vector tmp;
-	     data.multiply( tmp, NICE::makeEVector(q)); //r_{k+1}=A*q
-	     rmatrix[reduceddim] = NICE::makeIceVectorT(tmp);
-	    
-	     for(uint j=0;j<reduceddim;j++)
-		  rmatrix[reduceddim]=rmatrix[reduceddim]-qmatrix[j]*(qmatrix[j]*rmatrix[reduceddim]);
-	}
-	//convergence stuff
-	ice::Vector diff=rold-rmatrix[k-1];
-	delta=diff.Length();
-	iteration++;
-#ifdef DEBUG_ARNOLDI
-	fprintf (stderr, "EVArnoldi: [%d] delta=%f\n", iteration, delta );
-#endif
-    }
-    eigenvectors = NICE::makeDoubleMatrix ( rmatrix );
-    eigenvectors.transposeInplace();
-  
-    for(uint i=0;i<k;i++)
-    {
-	// refactor-nice.pl: check this substitution
-	// old: Vector tmp;
-	NICE::Vector tmp;
-	eigenvectors.getColumnRef(i).normalizeL2();
-
-	data.multiply(tmp,eigenvectors.getColumn(i));
-	eigenvalues[i] = tmp.scalarProduct (eigenvectors.getColumn(i));
-    }
-}
-     
-#ifdef USE_BROKEN_LANCZOS
-void EVLanczos::getEigenvalues(const GenericMatrix &data,Vector &eigenvalues,Matrix &eigenvectors,uint k)
-{
-    if (data.rows()!=data.cols())
-	throw("Input matrix is not quadratic.");
-     
-    uint n=data.cols();
-    uint m=data.rows();  
-    if(k<=0 ) k=n;
-    uint kint=k;
-    NICE::Matrix wmatrix(kint+1,n,0);
-    NICE::Matrix vmatrix(kint+1,n,0);//saves data =eigenvectors
-    NICE::Matrix t(kint,kint,0);
-    eigenvalues=Vector(k);
-    NICE::Matrix eigenvectorsapprox(k,n,0);
-    NICE::Vector w=Vector(n);
-        
-    // refactor-nice.pl: check this substitution
-    // old: Vector alpha=Vector(kint+1);
-    NICE::Vector alpha=Vector(kint+1);
-    // refactor-nice.pl: check this substitution
-    // old: Vector beta=Vector(kint+1);
-    NICE::Vector beta=Vector(kint+1);
-          
-    //random initialisation ?
-    vmatrix.Set(0.0);
-                    
-    if(n<=0) return;
-
-    for (uint i=0;i<vmatrix[1].size();i++)
-	// refactor-nice.pl: check this substitution
-	// old: vmatrix[1][i]=RandomD();
-	vmatrix(1, i)=RandomD();
-               
-    beta[0]=0;  
-    //iteration
-    double delta=1.0;
-    uint iteration=0;
-    while(delta>mindelta && iteration<maxiterations)
-    {
-	// refactor-nice.pl: check this substitution
-	// old: Vector check=vmatrix[kint];
-	NICE::Vector check=vmatrix[kint];
-	for(uint i=1;i<kint;i++)
-	{
-	    //iteration step
-	    NICE::Vector tmp;
-	    data.multiply(tmp,vmatrix[i]); 
-		     
-	    wmatrix[i]=tmp-(beta[i-1]*vmatrix[i-1]);//w_i=A * v[i] - beta_i * v_(i-1)
-	    alpha[i-1]=wmatrix[i]*vmatrix[i];
-	    wmatrix[i]=wmatrix[i]-(alpha[i-1]*vmatrix[i]);
-	    beta[i]=wmatrix[i].Length();
-	    vmatrix[i+1]=1.0/beta[i]*wmatrix[i];
-			       
-	    t(i-1, i-1)=alpha[i];
-	    if(i>1)
-	    {
-		t(i-1, i-2)=beta[i-1];
-		t(i-2, i-1)=beta[i-1];
-	    }
-	  
-	}
-	// refactor-nice.pl: check this substitution
-	// old: Vector diff=check-vmatrix[kint];
-	NICE::Vector diff=check-vmatrix[kint];
-	delta=diff.Length();
-	iteration++;
-    }
-    cout<<"Lanczos-Iterations:"<<iteration<<"/"<<maxiterations<<"relative Error:"<<delta<<endl;
-    // refactor-nice.pl: check this substitution
-    // old: Vector ice_eigval;
-    NICE::Vector ice_eigval;
-    // refactor-nice.pl: check this substitution
-    // old: Matrix ice_eigvect;
-    NICE::Matrix ice_eigvect;
-    Eigenvalue ( t, ice_eigval, ice_eigvect );
-
-    cerr << ice_eigval << endl;
-	   
-
-    for (uint l=0;l<k;l++)
-	eigenvectorsapprox[l]=vmatrix[l+1];
-
-    eigenvectors=eigenvectorsapprox;
-    for (uint i=0;i<(uint)eigenvectors.rows();i++)
-    {
-	// refactor-nice.pl: check this substitution
-	// old: Vector tmp;
-	NICE::Vector tmp;
-	if ( eigenvectors[i].Length() < 1e-12 )
-	{
-	    cerr << "Lanczos: numerical instability" << endl;
-	} else {
-	    eigenvectors[i].Normalize();
-	}
-	data.multiply(tmp,eigenvectors[i]);
-	eigenvalues[i]=tmp * eigenvectors[i];
-    }
-}
-#endif
-

+ 0 - 90
math/algebra/EigValues.h

@@ -1,90 +0,0 @@
-/** 
-* @file EigValues.h
-* @brief Computing eigenvalues and eigenvectors
-* @author Michael Koch,Erik Rodner
-* @date 08/19/2008
-
-*/
-#ifndef EigValuesINCLUDE
-#define EigValuesINCLUDE
-
-#include <vislearning/nice_nonvis.h>
-
-#include "GenericMatrix.h"
-  
-
-namespace OBJREC {
-
-/** Computing eigenvalues and eigenvectors */
-class EigValues
-{
-
-    protected:
-    
-    public:
-	
-	/**
-         * @param data matrix interface that does allow matrix-vector multiplications
-         * @param k number of eigenvalues/eigenvectors
-         * @param eigenvectors output Eigenvectors as Matrix
-         * @param eigenvalues output Eigenvalues as Vector
-         */
-	virtual void getEigenvalues ( const GenericMatrix &data, NICE::Vector & eigenvalues, NICE::Matrix & eigenvectors, uint k ) = 0;
-
-	virtual ~EigValues() {};
-
-};
-
-#ifdef USE_BROKEN_LANCZOS
-/** BROKEN: lanczos iteration */
-class EVLanczos : public EigValues
-{
-    protected:
-	uint maxiterations;
-	double mindelta;
-
-    public:
-	EVLanczos ( uint _maxiterations = 100, double _mindelta = 0.01 ) 
-	    : maxiterations(_maxiterations), mindelta(_mindelta) {};
-
-
-	/**
-         * Lanczos Iteration, to get k first eigenvectors and eigenvalues
-         * @param data matrix interface that does allow matrix-vector multiplications
-         * @param k number of eigenvalues/eigenvectors
-         * @param eigenvectors output Eigenvectors as Matrix
-         * @param eigenvalues output Eigenvalues as Vector
-         */
-	// refactor-nice.pl: check this substitution
-	// old: void getEigenvalues ( const GenericMatrix &data, Vector & eigenvalues, Matrix & eigenvectors, uint k );	
-	void getEigenvalues ( const GenericMatrix &data, NICE::Vector & eigenvalues, NICE::Matrix & eigenvectors, uint k );	
-};
-#endif
-
-/** arnoldi iteration */
-class EVArnoldi : public EigValues
-{
-    protected:
-	uint maxiterations;
-	double mindelta;
-
-    public:
-	EVArnoldi ( uint _maxiterations = 100, double _mindelta = 0.01 ) 
-	    : maxiterations(_maxiterations), mindelta(_mindelta) {};
-
-	/**
-         * Arnoldi Iteration, to get k first eigenvectors and eigenvalues
-         * @param data matrix interface that does allow matrix-vector multiplications
-         * @param k number of eigenvalues/eigenvectors
-         * @param eigenvectors output Eigenvectors as Matrix
-         * @param eigenvalues output Eigenvalues as Vector
-         */
-	// refactor-nice.pl: check this substitution
-	// old: void getEigenvalues ( const GenericMatrix &data, Vector & eigenvalues, Matrix & eigenvectors, uint k );	
-	void getEigenvalues ( const GenericMatrix &data, NICE::Vector & eigenvalues, NICE::Matrix & eigenvectors, uint k );	
-};
-
-
-} // namespace
-
-#endif

+ 0 - 323
math/algebra/GMSparse2.cpp

@@ -1,323 +0,0 @@
-#include "GMSparse2.h"
-#include <assert.h>
-
-using namespace OBJREC;
-using namespace NICE;
-using namespace std;
-
-GMSparse2::GMSparse2 ( uint _rows, uint _cols ) : m_rows(_rows), m_cols(_cols) 
-{
-	resize(_rows, _cols);
-}
-
-GMSparse2::GMSparse2 ( const NICE::Matrix & iceA, double epsilon)
-{
-	m_rows = iceA.rows();
-	m_cols = iceA.cols();
-	newvectors = true;
-	for(uint r = 0; r < m_rows; r++)
-	{
-		SparseVector *tmp = new SparseVector(m_cols);
-		for(uint c = 0; c < m_cols; c++)
-		{
-			if(fabs(iceA(r ,c)) > epsilon)
-				(*tmp)[c] = iceA(r, c);
-		}
-		A.push_back(tmp);
-	}
-}
-
-GMSparse2::~GMSparse2()
-{
-	clear();
-}
-
-SparseVector & GMSparse2::operator[](int i) const
-{
-	return *A[i];
-}
-
-void GMSparse2::addRow(const NICE::Vector &x)
-{
-	SparseVector *v = new SparseVector(x);
-	m_cols = x.size();
-	v->setDim(m_cols);
-	A.push_back(v);
-	++m_rows;
-}
-		
-void GMSparse2::addRow(SparseVector *x)
-{
-	newvectors = false;
-	A.push_back(x);
-	++m_rows;
-	m_cols = x->getDim();
-}
-		
-void GMSparse2::clear()
-{
-	if(newvectors)
-	{
-		for(uint i = 0; i < A.size(); i++)
-		{
-			delete A[i];
-		}
-	}
-	A.clear();
-}
-		
-void GMSparse2::resize( int _rows, int _cols)
-{
-	m_rows = _rows;
-	m_cols = _cols;
-	newvectors = true;
-	for(uint i = 0; i < m_rows; i++)
-	{
-		SparseVector *tmp = new SparseVector(m_cols);
-		A.push_back(tmp);
-	}
-}
-		
-void GMSparse2::mult2(GMSparse2 &y, GMSparse2 &out, bool transpx, bool transpy)
-{
-	int rowsx, colsx, rowsy, colsy;
-	if(transpx)
-	{
-		colsx = m_rows;
-		rowsx = m_cols;
-	}
-	else
-	{
-		rowsx = m_rows;
-		colsx = m_cols;
-	}
-	
-	if(transpy)
-	{
-		colsy = y.rows();
-		rowsy = y.cols();
-	}
-	else
-	{
-		rowsy = y.rows();
-		colsy = y.cols();
-	}
-	
-	if(rowsy != colsx)
-	{
-		cout << "GMSparse::mult matrix sizes missmatched" << endl;
-		exit(1);
-	}
-	
-	out.resize(rowsx,colsy);
-
-	double xval, yval, val, val2;
-	
-	for(int c = 0; c < colsy; c++)
-	{
-		for(int i = 0; i < rowsy; i++)
-		{
-			if(transpy)
-				yval = y[c].get(i);
-			else
-				yval = y[i].get(c);
-			
-			if(yval != 0.0)
-			{
-				for(int r = 0; r < rowsx; r++)
-				{
-					if(transpx)
-						xval = (*A[i]).get(r);
-					else
-						xval = (*A[r]).get(i);
-					
-					val = out[r].get(c);
-					val2 = val+xval*yval;
-					if(fabs(val2) >  10e-10)
-						out[r][c] = val2;
-					else if(val != 0.0)
-						out[r].erase(c);
-				}
-			}
-		}
-	}
-}
-		
-void GMSparse2::mult(GMSparse2 &y, GMSparse2 &out, bool transpx, bool transpy)
-{
-	int rowsx, colsx, rowsy, colsy;
-	if(transpx)
-	{
-		colsx = m_rows;
-		rowsx = m_cols;
-	}
-	else
-	{
-		rowsx = m_rows;
-		colsx = m_cols;
-	}
-	
-	if(transpy)
-	{
-		colsy = y.rows();
-		rowsy = y.cols();
-	}
-	else
-	{
-		rowsy = y.rows();
-		colsy = y.cols();
-	}
-	
-	if(rowsy != colsx)
-	{
-		cout << "GMSparse::mult matrix sizes missmatched" << endl;
-		exit(1);
-	}
-	
-	out.resize(rowsx,colsy);
-
-	double xval, yval, val;
-	for(int r = 0; r < rowsx; r++)
-	{
-	
-		for(int c = 0; c < colsy; c++)
-		{
-			val = 0.0;
-			for(int i = 0; i < rowsy; i++)
-			{
-				if(transpx)
-					xval = (*A[i]).get(r);
-				else
-					xval = (*A[r]).get(i);
-				
-				if(transpy)
-					yval = y[c].get(i);
-				else
-					yval = y[i].get(c);
-				
-				val+=xval * yval;
-			}
-
-			if(fabs(val) >  10e-7)
-				out[r][c] = val;
-			
-			if(!finite(val*val))
-			{
-				cout << "val " << val << endl;
-				for(int i = 0; i < rowsy; i++)
-				{
-					if(transpx)
-						xval = (*A[i]).get(r);
-					else
-						xval = (*A[r]).get(i);
-				
-					if(transpy)
-						yval = y[c].get(i);
-					else
-						yval = y[i].get(c);
-				
-					val+=xval * yval;
-					cout << " xval: " << xval << " yval " << yval << endl;
-				}
-				getchar();
-			}
-		}
-	}
-	
-	
-}
-
-void GMSparse2::mult(SparseVector &y, GMSparse2 &out, bool transpx, bool transpy)
-{
-	int rowsx, colsx, rowsy, colsy;
-	if(transpx)
-	{
-		colsx = m_rows;
-		rowsx = m_cols;
-	}
-	else
-	{
-		rowsx = m_rows;
-		colsx = m_cols;
-	}
-	
-	if(transpy)
-	{
-		colsy = 1;
-		rowsy = y.getDim();
-	}
-	else
-	{
-		rowsy = 1;
-		colsy = y.getDim();
-	}
-	
-	if(rowsy != colsx)
-	{
-		cout << "GMSparse::mult matrix sizes missmatched" << endl;
-		exit(1);
-	}
-	
-	out.resize(rowsx,colsy);
-
-	double xval, yval, val;
-	for(int r = 0; r < rowsx; r++)
-	{
-	
-		for(int c = 0; c < colsy; c++)
-		{
-			val = 0.0;
-			for(int i = 0; i < rowsy; i++)
-			{
-				if(transpx)
-					xval = (*A[i]).get(r);
-				else
-					xval = (*A[r]).get(i);
-				
-				if(transpy)
-					yval = y.get(i);
-				else
-					yval = y.get(c);
-				
-				val += xval * yval;
-			}
-
-			if(fabs(val) >  10e-7)
-				out[r][c] = val;
-		}
-	}
-}
-
-void GMSparse2::multiply ( NICE::Vector & y, const NICE::Vector & x ) const
-{
-	//FIXME: einbauen
-}
-
-void GMSparse2::store (ostream & os, int format) const
-{
-	os << m_rows << " " << m_cols << " " << A.size() << endl;
-	for(int i = 0; i < (int) A.size(); i++)
-	{
-		A[i]->store(os, format);
-	}
-}
-
-void GMSparse2::restore (istream & is, int format)
-{
-	A.clear();
-	is >> m_rows;
-	is >> m_cols;
-	int size;
-	is >> size;
-	for(int i = 0; i < size; i++)
-	{
-		SparseVector *s = new SparseVector(m_cols);
-		s->restore(is, format);
-		A.push_back(s);
-	}
-}
-
-void GMSparse2::setDel(bool del)
-{
-	newvectors = del;
-}

+ 0 - 155
math/algebra/GMSparse2.h

@@ -1,155 +0,0 @@
-/** 
- * @file GMSparse2.h
- * @brief Sparse Matrix depends on SparseVectors
- * @author Björn Fröhlich
- * @date 05/14/2009
-
- */
-#ifndef GMSPARSE2INCLUDE
-#define GMSPARSE2INCLUDE
-
-#ifdef NOVISUAL
-#include <vislearning/nice_nonvis.h>
-#else
-#include <vislearning/nice.h>
-#endif
-
-#include "vislearning/math/algebra/GenericMatrix.h"
-  
-namespace OBJREC {
-
-class GMSparse2 : public GenericMatrix
-{
-	protected:
-		//! the sparse matrix
-		std::vector<NICE::SparseVector*> A;
-		
-		//! count of rows
-		uint m_rows;
-		
-		//! count of columns
-		uint m_cols;
-		
-		//! are the vectors new ones or came they from somewhere else
-		bool newvectors;
-		
-	public:
-		/**
-		 * simple constructor -> does nothing
-		 */
-		GMSparse2(){resize(0,0);};
-		
-		/**
-		 * constructor which set the rows and cols of the SparseMatrix
-		 * @param _rows 
-		 * @param _cols 
-		 */
-		GMSparse2 ( uint _rows, uint _cols );
-		
-		/**
-		 * converts an ICE::Matrix to a sparse matrix
-		 * @param A input ICE::Matrix
-		 * @param epsilon tolerance value
-		 */
-		GMSparse2 ( const NICE::Matrix & iceA, double epsilon = 1e-9 );
-
-		/**
-		 * simple destructor
-		 */
-		~GMSparse2();
-		
-		/**
-		 * resize the matrix
-		 * @param _rows new count of rows
-		 * @param _cols new count of cols
-		 */
-		void resize( int _rows, int _cols);
-		
-		/**
-		 * clean up
-		 */
-		void clear();
-		
-		/** get the number of rows in A */
-		uint rows() const { return m_rows; };
-
-		/** get the number of columns in A */
-		uint cols() const { return m_cols; };
-
-		/** multiply with a vector: A*x = y */
-		void multiply ( NICE::Vector & y, const NICE::Vector & x ) const;
-		
-		/**
-		 * return the i-th row
-		 * @param i 
-		 * @return SparseVector at row i
-		 */
-		NICE::SparseVector & operator[](int i) const;
-		
-		/**
-		 * restore the information of the sparse matrix
-		 * @param is inputstream
-		 * @param format 
-		 */
-		void restore (std::istream & is, int format = 0);
-		
-		/**
-		 * store the information of the sparse matrix
-		 * @param os outputstream
-		 * @param format 
-		 */
-		void store (std::ostream & os, int format = 0) const;
-		
-		
-		/**
-		 * Should the data be deleted when the destructor is called
-		 * @param del 
-		 */
-		void setDel(bool del = true);
-		
-		/**
-		 * add a new row 
-		 * @param x ICE::Vector
-		 */
-		void addRow(const NICE::Vector &x);
-		
-		/**
-		 * add a new row
-		 * @param x SparseVector
-		 */
-		void addRow(NICE::SparseVector *x);
-		
-		/**
-		 * matrixmultiplication x*y = out
-		 * @param y input
-		 * @param out output
-		 * @param transpx use the transpose of x 
-		 * @param transpy use the transpose of y
-		 * @return z
-		 */
-		void mult(GMSparse2 &y, GMSparse2 & out, bool transpx = false, bool transpy = false);
-		
-		/**
-		 * matrixmultiplication x*y = out
-		 * @param y input Sparse Vector
-		 * @param out output
-		 * @param transpx use the transpose of x 
-		 * @param transpy use the transpose of y
-		 * @return z
-		 */
-		void mult(NICE::SparseVector &y, GMSparse2 & out, bool transpx = false, bool transpy = false);
-		
-		/**
-		 * same like mult, but faster when y ist very sparse and slower if not
-		 * @param y input
-		 * @param out output
-		 * @param transpx use the transpose of x 
-		 * @param transpy use the transpose of y
-		 * @return z
-		 */
-		void mult2(GMSparse2 &y, GMSparse2 & out, bool transpx = false, bool transpy = false);
-};
-
-} // namespace
-
-#endif

+ 0 - 81
math/algebra/GenericMatrix.cpp

@@ -1,81 +0,0 @@
-/** 
-* @file GenericMatrix.cpp
-* @brief matrix interface for indirect matrix multiplications
-* @author Erik Rodner
-* @date 05/14/2009
-
-*/
-
-#include "GenericMatrix.h"
-#include <assert.h>
-
-using namespace OBJREC;
-using namespace NICE;
-using namespace std;
-	
-GMSparse::GMSparse ( const NICE::Matrix & A, double epsilon )
-{
-    m_rows = A.rows();
-    m_cols = A.cols();
-    for ( u_int i = 0 ; i < m_rows ; i++ )
-	for ( u_int j = 0 ; j < m_cols ; j++ )
-	    if (fabs(A(i, j)) > epsilon )
-			this->A.insert ( this->A.begin(), NICE::triplet<int, int, double> ( i, j,A(i, j) ) );		
-}
-
-void GMSparse::multiply ( NICE::Vector & y, const NICE::Vector & x ) const
-{
-    assert ( x.size() == m_cols );
-
-    y.resize( m_rows );
-    y.set(0.0);
-    for ( vector< NICE::triplet<int, int, double> >::const_iterator k = this->A.begin();
-	    k != this->A.end(); k++ )
-    {
-	int i = k->first;
-	int j = k->second;
-	double value = k->third; // = a_ij
-	y[i] += value * x[j];
-    }
-}
-
-GMCovariance::GMCovariance ( const NICE::Matrix *data )
-{
-    this->data = data;
-    m_rows = data->rows();
-    m_cols = m_rows;
-}
-
-void GMCovariance::multiply ( NICE::Vector & y, const NICE::Vector & x ) const
-{
-    assert ( x.size() == data->rows() );
-
-	/*******************************************************************
-	 * d_k = data(:,k) vector k in the data set
-	 * f_k = d_k^T x 
-	 * fSum = \sum_k f_k
-	 * In the following we use the following relationship
-	 * S = \sum_i d_i ( d_i - \mu )^T = \sum_i (d_i - \mu) (d_i - \mu)^T
-	 * Sx = \sum_i d_i ( f_i - fSum/N )
-	 * which seems to be very efficient
-	 * *****************************************************************/
-
-    NICE::Vector f ( data->cols() );
-    f.set(0.0);
-    double fSum = 0.0;
-    for ( uint k = 0 ; k < data->cols() ; k++ )
-    {
-		for ( uint d = 0 ; d < data->rows() ; d++ )
-			f[k] += (*data)(d, k) * x[d];
-		fSum += f[k];
-    }
-    y.resize(x.size());
-    y.set(0.0);
-    int N = data->cols();
-    for ( uint k = 0 ; k < data->cols() ; k++ )
-		for ( int l = 0 ; l < (int)y.size(); l++ )
-			y[l] += ( f[k] - fSum/N ) * ( (*data)(l, k) );
-
-    for ( int i = 0 ; i < (int)y.size() ; i++ )
-		y[i] /= N;
-}

+ 0 - 107
math/algebra/GenericMatrix.h

@@ -1,107 +0,0 @@
-/** 
-* @file GenericMatrix.h
-* @brief matrix interface for indirect matrix multiplications
-* @author Erik Rodner
-* @date 05/14/2009
-
-*/
-#ifndef GENERICMATRIXINCLUDE
-#define GENERICMATRIXINCLUDE
-
-#include "core/basics/triplet.h"
-#include "AlgebraTools.h"
-#include "core/vector/SparseVector.h"
-  
-
-namespace OBJREC {
-
-/** matrix interface for indirect matrix multiplications */
-class GenericMatrix
-{
-
-    protected:
-
-    public:
-
-	/** multiply with a vector: A*x = y */
-	virtual void multiply ( NICE::Vector & y, const NICE::Vector & x ) const  = 0;
-
-	/** get the number of rows in A */
-	virtual uint rows() const = 0;
-
-	/** get the number of columns in A */
-	virtual uint cols() const = 0;
-
-	/** simple destructor */
-	virtual ~GenericMatrix() {};
-     
-};
-
-class GMSlowICE : public GenericMatrix
-{
-    protected:
-	NICE::Matrix A;
-
-    public:
-	GMSlowICE ( const NICE::Matrix & _A ) : A(_A) {};
-    
-	/** get the number of rows in A */
-	uint rows() const { return A.rows(); };
-
-	/** get the number of columns in A */
-	uint cols() const { return A.cols(); };
-
-	/** multiply with a vector: A*x = y */
-	void multiply ( NICE::Vector & y, const NICE::Vector & x ) const
-	{ y.multiply ( A, x ); };
-
-};
-
-class GMSparse : public GenericMatrix
-{
-    protected:
-	std::vector< NICE::triplet<int, int, double> > A;
-	uint m_rows;
-	uint m_cols;
-
-    public:
-	GMSparse ( uint _rows, uint _cols ) : m_rows(_rows), m_cols(_cols) {}
-	GMSparse ( const NICE::Matrix & A, double epsilon = 1e-9 );
-
-	/** get the number of rows in A */
-	uint rows() const { return m_rows; };
-
-	/** get the number of columns in A */
-	uint cols() const { return m_cols; };
-
-	/** multiply with a vector: A*x = y */
-	void multiply ( NICE::Vector & y, const NICE::Vector & x ) const;
-
-};
-
-class GMCovariance : public GenericMatrix
-{
-    protected:
-	const NICE::Matrix *data;
-	uint m_rows;
-	uint m_cols;
-
-    public:
-	GMCovariance ( const NICE::Matrix *data );
-
-	/** get the number of rows in A */
-	uint rows() const { return m_rows; };
-
-	/** get the number of columns in A */
-	uint cols() const { return m_cols; };
-
-	/** multiply with a vector: A*x = y */
-	void multiply ( NICE::Vector & y, const NICE::Vector & x ) const;
-
-};
-
-
-
-} // namespace
-
-#endif

+ 0 - 8
math/algebra/Makefile

@@ -1,8 +0,0 @@
-#TARGETS_FROM:=$(notdir $(patsubst %/,%,$(shell pwd)))/$(TARGETS_FROM)
-#$(info recursivly going up: $(TARGETS_FROM) ($(shell pwd)))
-
-all:
-
-%:
-	$(MAKE) TARGETS_FROM=$(notdir $(patsubst %/,%,$(shell pwd)))/$(TARGETS_FROM) -C .. $@
-

+ 0 - 103
math/algebra/Makefile.inc

@@ -1,103 +0,0 @@
-# LIBRARY-DIRECTORY-MAKEFILE
-# conventions:
-# - all subdirectories containing a "Makefile.inc" are considered sublibraries
-#   exception: "progs/" and "tests/" subdirectories!
-# - all ".C", ".cpp" and ".c" files in the current directory are linked to a
-#   library
-# - the library depends on all sublibraries 
-# - the library name is created with $(LIBNAME), i.e. it will be somehow
-#   related to the directory name and with the extension .a
-#   (e.g. lib1/sublib -> lib1_sublib.a)
-# - the library will be added to the default build list ALL_LIBRARIES
-
-# --------------------------------
-# - remember the last subdirectory
-#
-# set the variable $(SUBDIR) correctly to the current subdirectory. this
-# variable can be used throughout the current makefile.inc. The many 
-# SUBDIR_before, _add, and everything are only required so that we can recover
-# the previous content of SUBDIR before exitting the makefile.inc
-
-SUBDIR_add:=$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
-SUBDIR_before:=$(SUBDIR)
-SUBDIR:=$(strip $(SUBDIR_add))
-SUBDIR_before_$(SUBDIR):=$(SUBDIR_before)
-ifeq "$(SUBDIR)" "./"
-SUBDIR:=
-endif
-
-# ------------------------
-# - include subdirectories
-#
-# note the variables $(SUBDIRS_OF_$(SUBDIR)) are required later on to recover
-# the dependencies automatically. if you handle dependencies on your own, you
-# can also dump the $(SUBDIRS_OF_$(SUBDIR)) variable, and include the
-# makefile.inc of the subdirectories on your own...
-
-SUBDIRS_OF_$(SUBDIR):=$(patsubst %/Makefile.inc,%,$(wildcard $(SUBDIR)*/Makefile.inc))
-include $(SUBDIRS_OF_$(SUBDIR):%=%/Makefile.inc)
-
-# ----------------------------
-# - include local dependencies
-#
-# you can specify libraries needed by the individual objects or by the whole
-# directory. the object specific additional libraries are only considered
-# when compiling the specific object files
-# TODO: update documentation...
-
--include $(SUBDIR)libdepend.inc
-
-$(foreach d,$(filter-out %progs %tests,$(SUBDIRS_OF_$(SUBDIR))),$(eval $(call PKG_DEPEND_INT,$(d))))
-
-# ---------------------------
-# - objects in this directory
-#
-# the use of the variable $(OBJS) is not mandatory. it is mandatory however
-# to update $(ALL_OBJS) in a way that it contains the path and name of
-# all objects. otherwise we can not include the appropriate .d files.
-
-OBJS:=$(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.cpp))) \
-      $(patsubst %.C,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.C))) \
-	  $(shell grep -ls Q_OBJECT $(SUBDIR)*.h | sed -e's@^@/@;s@.*/@$(OBJDIR)moc_@;s@\.h$$@.o@') \
-      $(patsubst %.c,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.c)))
-ALL_OBJS += $(OBJS)
-
-# ----------------------------
-# - binaries in this directory
-#
-# output of binaries in this directory. none of the variables has to be used.
-# but everything you add to $(ALL_LIBRARIES) and $(ALL_BINARIES) will be
-# compiled with `make all`. be sure again to add the files with full path.
-
-LIBRARY_BASENAME:=$(call LIBNAME,$(SUBDIR))
-ifneq "$(SUBDIR)" ""
-ALL_LIBRARIES+=$(LIBDIR)$(LIBRARY_BASENAME).$(LINK_FILE_EXTENSION)
-endif
-
-# ---------------------
-# - binary dependencies
-#
-# there is no way of determining the binary dependencies automatically, so we
-# follow conventions. the current library depends on all sublibraries.
-# all other dependencies have to be added manually by specifying, that the
-# current .pc file depends on some other .pc file. binaries depending on
-# libraries should exclusivelly use the .pc files as well.
-
-ifeq "$(SKIP_BUILD_$(OBJDIR))" "1"
-$(LIBDIR)$(LIBRARY_BASENAME).a:
-else
-$(LIBDIR)$(LIBRARY_BASENAME).a:$(OBJS) \
-	$(call PRINT_INTLIB_DEPS,$(PKGDIR)$(LIBRARY_BASENAME).a,.$(LINK_FILE_EXTENSION))
-endif
-
-$(PKGDIR)$(LIBRARY_BASENAME).pc: \
-	$(call PRINT_INTLIB_DEPS,$(PKGDIR)$(LIBRARY_BASENAME).pc,.pc)
-
-# -------------------
-# - subdir management
-#
-# as the last step, always add this line to correctly recover the subdirectory
-# of the makefile including this one!
-
-SUBDIR:=$(SUBDIR_before_$(SUBDIR))
-

+ 0 - 7
math/algebra/libdepend.inc

@@ -1,7 +0,0 @@
-$(call PKG_DEPEND_EXT,ICE)
-$(call PKG_DEPEND_EXT,BSE)
-$(call PKG_DEPEND_INT,vislearning/math/mathbase)
-$(call PKG_DEPEND_INT,cholesky-gpu/niceinterface)
-
-
-

+ 0 - 88
math/algebra/progs/Makefile.inc

@@ -1,88 +0,0 @@
-# BINARY-DIRECTORY-MAKEFILE
-# conventions:
-# - there are no subdirectories, they are ignored!
-# - all ".C", ".cpp" and ".c" files in the current directory are considered
-#   independent binaries, and linked as such.
-# - the binaries depend on the library of the parent directory
-# - the binary names are created with $(BINNAME), i.e. it will be more or less
-#   the name of the .o file
-# - all binaries will be added to the default build list ALL_BINARIES
-
-# --------------------------------
-# - remember the last subdirectory
-#
-# set the variable $(SUBDIR) correctly to the current subdirectory. this
-# variable can be used throughout the current makefile.inc. The many 
-# SUBDIR_before, _add, and everything are only required so that we can recover
-# the previous content of SUBDIR before exitting the makefile.inc
-
-SUBDIR_add:=$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
-SUBDIR_before:=$(SUBDIR)
-SUBDIR:=$(strip $(SUBDIR_add))
-SUBDIR_before_$(SUBDIR):=$(SUBDIR_before)
-
-# ------------------------
-# - include subdirectories
-#
-# note the variables $(SUBDIRS_OF_$(SUBDIR)) are required later on to recover
-# the dependencies automatically. if you handle dependencies on your own, you
-# can also dump the $(SUBDIRS_OF_$(SUBDIR)) variable, and include the
-# makefile.inc of the subdirectories on your own...
-
-#SUBDIRS_OF_$(SUBDIR):=$(patsubst %/Makefile.inc,%,$(wildcard $(SUBDIR)*/Makefile.inc))
-#include $(SUBDIRS_OF_$(SUBDIR):%=%/Makefile.inc)
-
-# ----------------------------
-# - include local dependencies
-#
-# include the libdepend.inc file, which gives additional dependencies for the
-# libraries and binaries. additionally, an automatic dependency from the library
-# of the parent directory is added (commented out in the code below).
-
--include $(SUBDIR)libdepend.inc
-
-PARENTDIR:=$(patsubst %/,%,$(dir $(patsubst %/,%,$(SUBDIR))))
-$(eval $(call PKG_DEPEND_INT,$(PARENTDIR)))
-
-# ---------------------------
-# - objects in this directory
-#
-# the use of the variable $(OBJS) is not mandatory. it is mandatory however
-# to update $(ALL_OBJS) in a way that it contains the path and name of
-# all objects. otherwise we can not include the appropriate .d files.
-
-OBJS:=$(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.cpp))) \
-      $(patsubst %.C,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.C))) \
-      $(shell grep -ls Q_OBJECT $(SUBDIR)*.h | sed -e's@^@/@;s@.*/@$(OBJDIR)moc_@;s@\.h$$@.o@') \
-      $(patsubst %.c,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.c)))
-ALL_OBJS += $(OBJS)
-
-# ----------------------------
-# - binaries in this directory
-#
-# output of binaries in this directory. none of the variables has to be used.
-# but everything you add to $(ALL_LIBRARIES) and $(ALL_BINARIES) will be
-# compiled with `make all`. be sure again to add the files with full path.
-
-BINARIES:=$(patsubst %.o,$(BINDIR)%,$(filter-out moc_%,$(notdir $(OBJS))))
-ALL_BINARIES+=$(BINARIES)
-
-# ---------------------
-# - binary dependencies
-#
-# there is no way of determining the binary dependencies automatically, so we
-# follow conventions. each binary depends on the corresponding .o file and
-# on the libraries specified by the INTLIBS/EXTLIBS. these dependencies can be
-# specified manually or they are automatically stored in a .bd file.
-
-$(foreach head,$(wildcard $(SUBDIR)*.h),$(eval $(shell grep -q Q_OBJECT $(head) && echo $(head) | sed -e's@^@/@;s@.*/\(.*\)\.h$$@$(BINDIR)\1:$(OBJDIR)moc_\1.o@')))
--include $(OBJS:%.o=%.bd)
-
-# -------------------
-# - subdir management
-#
-# as the last step, always add this line to correctly recover the subdirectory
-# of the makefile including this one!
-
-SUBDIR:=$(SUBDIR_before_$(SUBDIR))
-

+ 0 - 74
math/algebra/progs/calcKernelMatrixProperties.cpp

@@ -1,74 +0,0 @@
-/** 
-* @file calcKernelMatrixProperties.cpp
-* @brief calc some kernel matrix properties
-* @author Erik Rodner
-* @date 01/15/2010
-
-*/
-#include "core/basics/Config.h"
-#include "core/vector/Eigen.h"
-
-using namespace std;
-using namespace NICE;
-
-
-/** 
-    
-    calc some kernel matrix properties 
-    
-*/
-int main (int argc, char **argv)
-{   
-    std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
-
-    Config conf ( argc, argv );
-    
-	string in = conf.gS("main", "in");
-
-	cout << "reading kernel matrix ..." << endl;
-	ifstream ifs ( in.c_str(), ios::in );
-
-	if ( !ifs.good() )
-		fthrow(IOException, "Unable to read " << in << "." );
-
-	Matrix kernelMatrixOrig;
-	ifs >> kernelMatrixOrig;
-
-	ifs.close();
-
-	int norig = kernelMatrixOrig.rows();
-	int morig = kernelMatrixOrig.cols();
-
-	if ( norig != morig )
-		fthrow(Exception, "Kernel matrix has to be quadratic.");
-
-	int size = conf.gI("main", "size", 100 );
-	if ( size > norig ) size = norig;
-	
-	Matrix kernelMatrix ( size, size );
-	for ( int i = 0 ; i < kernelMatrix.rows(); i++ )
-		for ( int j = 0 ; j < kernelMatrix.cols(); j++ )
-			kernelMatrix(i,j) = kernelMatrixOrig(i,j);
-			
-	int n = kernelMatrix.rows();
-	int m = kernelMatrix.cols();
-
-	cout << "size: " << n << " x " << m << " (orig: " << norig << " x " << norig << " )" << endl;
-	cout << "performing eigenvalue decomposition ..." << endl;
-    Vector eigvals (n);
-	eigenvalues ( kernelMatrix, &eigvals );
-
-	double min_lambda = eigvals.Min();
-	double max_lambda = eigvals.Max();
-
-	cout << "smallest eigenvalue: " << min_lambda << endl;
-	cout << "largest eigenvalue: " << max_lambda << endl;
-   
-    double sigma = conf.gD("main", "sigma", 0.01);
-    double upper_bound = 0.5 * sigma * sigma / ( pow(min_lambda,3) );
-	double lower_bound = 0.5 * sigma * sigma / ( pow(min_lambda,3) + sigma*sigma );
-    cout << "inverse approximation bounds (cf. GP Multi-Task Notes): " << lower_bound << " <= |R|_2 <= " <<  upper_bound << endl;
-    
-    
-    return 0;
-}

+ 0 - 1
math/algebra/progs/libdepend.inc

@@ -1 +0,0 @@
-$(call PKG_DEPEND_INT,vislearning/baselib/)

+ 0 - 89
math/algebra/tests/Makefile.inc

@@ -1,89 +0,0 @@
-# BINARY-DIRECTORY-MAKEFILE
-# conventions:
-# - there are no subdirectories, they are ignored!
-# - all ".C", ".cpp" and ".c" files in the current directory are considered
-#   independent binaries, and linked as such.
-# - the binaries depend on the library of the parent directory
-# - the binary names are created with $(BINNAME), i.e. it will be more or less
-#   the name of the .o file
-# - all binaries will be added to the default build list ALL_BINARIES
-
-# --------------------------------
-# - remember the last subdirectory
-#
-# set the variable $(SUBDIR) correctly to the current subdirectory. this
-# variable can be used throughout the current makefile.inc. The many 
-# SUBDIR_before, _add, and everything are only required so that we can recover
-# the previous content of SUBDIR before exitting the makefile.inc
-
-SUBDIR_add:=$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
-SUBDIR_before:=$(SUBDIR)
-SUBDIR:=$(strip $(SUBDIR_add))
-SUBDIR_before_$(SUBDIR):=$(SUBDIR_before)
-
-# ------------------------
-# - include subdirectories
-#
-# note the variables $(SUBDIRS_OF_$(SUBDIR)) are required later on to recover
-# the dependencies automatically. if you handle dependencies on your own, you
-# can also dump the $(SUBDIRS_OF_$(SUBDIR)) variable, and include the
-# makefile.inc of the subdirectories on your own...
-
-#SUBDIRS_OF_$(SUBDIR):=$(patsubst %/Makefile.inc,%,$(wildcard $(SUBDIR)*/Makefile.inc))
-#include $(SUBDIRS_OF_$(SUBDIR):%=%/Makefile.inc)
-
-# ----------------------------
-# - include local dependencies
-#
-# include the libdepend.inc file, which gives additional dependencies for the
-# libraries and binaries. additionally, an automatic dependency from the library
-# of the parent directory is added (commented out in the code below).
-
--include $(SUBDIR)libdepend.inc
-
-PARENTDIR:=$(patsubst %/,%,$(dir $(patsubst %/,%,$(SUBDIR))))
-$(call PKG_DEPEND_INT,$(PARENTDIR))
-$(call PKG_DEPEND_EXT,CPPUNIT)
-
-# ---------------------------
-# - objects in this directory
-#
-# the use of the variable $(OBJS) is not mandatory. it is mandatory however
-# to update $(ALL_OBJS) in a way that it contains the path and name of
-# all objects. otherwise we can not include the appropriate .d files.
-
-OBJS:=$(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.cpp))) \
-      $(patsubst %.C,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.C))) \
-      $(shell grep -ls Q_OBJECT $(SUBDIR)*.h | sed -e's@^@/@;s@.*/@$(OBJDIR)moc_@;s@\.h$$@.o@') \
-      $(patsubst %.c,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.c)))
-ALL_OBJS += $(OBJS)
-
-# ----------------------------
-# - binaries in this directory
-#
-# output of binaries in this directory. none of the variables has to be used.
-# but everything you add to $(ALL_LIBRARIES) and $(ALL_BINARIES) will be
-# compiled with `make all`. be sure again to add the files with full path.
-
-CHECKS:=$(BINDIR)$(call LIBNAME,$(SUBDIR))
-ALL_CHECKS+=$(CHECKS)
-
-# ---------------------
-# - binary dependencies
-#
-# there is no way of determining the binary dependencies automatically, so we
-# follow conventions. each binary depends on the corresponding .o file and
-# on the libraries specified by the INTLIBS/EXTLIBS. these dependencies can be
-# specified manually or they are automatically stored in a .bd file.
-
-$(foreach head,$(wildcard $(SUBDIR)*.h),$(eval $(shell grep -q Q_OBJECT $(head) && echo $(head) | sed -e's@^@/@;s@.*/\(.*\)\.h$$@$(BINDIR)\1:$(OBJDIR)moc_\1.o@')))
-$(eval $(foreach c,$(CHECKS),$(c):$(BUILDDIR)$(CPPUNIT_MAIN_OBJ) $(OBJS) $(call PRINT_INTLIB_DEPS,$(c),.a)))
-
-# -------------------
-# - subdir management
-#
-# as the last step, always add this line to correctly recover the subdirectory
-# of the makefile including this one!
-
-SUBDIR:=$(SUBDIR_before_$(SUBDIR))
-

+ 0 - 134
math/algebra/tests/TestEigenValue.cpp

@@ -1,134 +0,0 @@
-//
-// C++ Implementation: TestEigenValue
-//
-// Description:
-//
-//
-// Author: Michael Koch <Koch.Michael@uni-jena.de>, (C) 2009
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-/**
- * @file TestEigenValue.cpp
- * @brief TestEigenValue
- * @author Michael Koch
- * @date Di Aug 4 2009
- */
-
-#include "TestEigenValue.h"
-#include <string>
-
-#include "core/basics/cppunitex.h"
-#include "core/basics/numerictools.h"
-#include "core/vector/Distance.h"
-
-#include "vislearning/math/algebra/EigValues.h"
-#include "vislearning/math/algebra/AlgebraTools.h"
-#include "vislearning/math/algebra/GenericMatrix.h"
-
-#include "vislearning/nice_nonvis.h"
-
-using namespace std;
-using namespace NICE;
-using namespace OBJREC;
-
-CPPUNIT_TEST_SUITE_REGISTRATION(TestEigenValue);
-
-void TestEigenValue::setUp()
-{
-}
-
-void TestEigenValue::tearDown()
-{
-}
-
-void TestEigenValue::TestEigenValueComputation()
-{
-    uint rows = 3;
-    uint cols = rows;
-    uint k = rows;
-    uint maxiterations =  200;
-    double mindelta = 1e-8;
-    double sparse_prob = 0.0;
-    int trlan_magnitude = 1;
-    bool init_random = true ;
-
-    // refactor-nice.pl: check this substitution
-    // old: Matrix T (rows, cols);
-    NICE::Matrix T(rows, cols);
-    T.set(0.0);
-    if (init_random)
-        srand48(time(NULL));
-
-    // generate random symmetric matrix
-    for (uint i = 0 ; i < rows ; i++)
-        for (uint j = i ; j < cols ; j++)
-        {
-            if (sparse_prob != 0.0)
-                if (drand48() < sparse_prob)
-                    continue;
-            T(i, j) = drand48();
-            T(j, i) = T(i, j);
-        }
-
-    // refactor-nice.pl: check this substitution
-    // old: Vector ice_eigvalues;
-
-
-    EigValues *eig;
-    for (int trlan = 0;trlan <= 1;trlan++) //this is creepy but funny
-    {
-        if (trlan) //this is creepy but saves lot of code
-        {
-#ifdef NICE_USELIB_TRLAN
-            eig = new EigValuesTRLAN(trlan_magnitude);
-#else
-            break;
-#endif
-        }
-        else
-        {
-            eig = new EVArnoldi(maxiterations, mindelta);
-        }
-
-        NICE::Vector eigvalues_dense;
-        NICE::Matrix eigvect_dense;
-        NICE::Vector eigvalues_sparse;
-        NICE::Matrix eigvect_sparse;
-
-        GMSlowICE Tg(T);
-        eig->getEigenvalues(Tg, eigvalues_dense, eigvect_dense, k);
-
-        GMSparse Ts(T);
-        eig->getEigenvalues(Ts, eigvalues_sparse, eigvect_sparse, k);
-
-        // test property
-        NICE::EuclidianDistance<double> eucliddist;
-        for (uint i = 0 ; i < k ; i++)
-        {
-            NICE::Vector v_dense = eigvect_dense.getColumn(i);
-            double lambda_dense = eigvalues_dense[i];
-            NICE::Vector Tv_dense;
-            Tv_dense.multiply(T, v_dense);
-            NICE::Vector lv_dense = v_dense;
-            lv_dense *= lambda_dense;
-            double err_dense = eucliddist(Tv_dense, lv_dense);
-
-            NICE::Vector v_sparse = eigvect_sparse.getColumn(i);
-            double lambda_sparse = eigvalues_sparse[i];
-            NICE::Vector Tv_sparse;
-            Tv_sparse.multiply(T, v_sparse);
-            NICE::Vector lv_sparse = v_sparse;
-            lv_sparse *= lambda_sparse;
-            double err_sparse = eucliddist(Tv_sparse, lv_sparse);
-
-//             cerr << "eigenvalue " << i << endl;
-//             cerr << "lambda (dense) = " << lambda_dense << endl;
-//             cerr << "lambda (sparse) = " << lambda_sparse << endl;
-//             cerr << "||Av - lambda v|| (dense) = " << err_dense << endl;
-//             cerr << "||Av - lambda v|| (sparse) = " << err_sparse << endl;
-            CPPUNIT_ASSERT_DOUBLES_EQUAL_NOT_NAN(0.0,err_dense,1e-4);
-            CPPUNIT_ASSERT_DOUBLES_EQUAL_NOT_NAN(0.0,err_sparse,1e-4);
-        }
-    }
-}

+ 0 - 48
math/algebra/tests/TestEigenValue.h

@@ -1,48 +0,0 @@
-//
-// C++ Interface: TestEigenValue
-//
-// Description: 
-//
-//
-// Author: Michael Koch <Koch.Michael@uni-jena.de>, (C) 2009
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-/** 
- * @file TestEigenValue.h
- * @brief TestEigenValue
- * @author Michael Koch
- * @date Di Aug 4 2009
- */
- 
-
-#ifndef OBJREC_TestEigenValue_H
-#define OBJREC_TestEigenValue_H
-
-
-#include <cppunit/extensions/HelperMacros.h>
-
-/**
- * CppUnit-Testcase. 
- * Tests for EigenValue Operations
- */
-class TestEigenValue : public CppUnit::TestFixture
-{
-     CPPUNIT_TEST_SUITE( TestEigenValue );
-
-    
-     CPPUNIT_TEST( TestEigenValueComputation );
-
-     CPPUNIT_TEST_SUITE_END();
-
-     private:
-
-     public:
-          void setUp();
-          void tearDown();
-          void TestEigenValueComputation();
-       
-};
-
-#endif // _TestEigenValue_H_
-

+ 0 - 111
math/algebra_trlan/EigValuesTRLAN.cpp

@@ -1,111 +0,0 @@
-#include "EigValuesTRLAN.h"
-
-#include <iostream>
-#include <assert.h>
-#define DEBUG_TRLAN
-// #undef DEBUG_TRLAN
-using namespace OBJREC;
-
-using namespace std;
-
-static const GenericMatrix* mat = NULL;
-
-static void op(int* nrow, int* ncol, double* xin, int* ldx, double* xout, int* ldy)
-{
-    NICE::Vector xin_v(xin, *ldy, NICE::VectorBase::external);
-    NICE::Vector xout_v(xout, *ldy, NICE::VectorBase::external);
-    mat->multiply(xout_v, xin_v);
-}
-
-typedef void (*OpFunc)(int* nrow, int* ncol, double* xin, int* ldx, double* xout, int* ldy);
-extern "C" void trlan77_(OpFunc op, int ipar[32], int* nrowl, int* mev, double* eval,
-                             double* evec, int* nrow2, double* wrk, int* lwrk);
-
-EigValuesTRLAN::EigValuesTRLAN(int magnitude,
-                               int restarting_scheme,
-                               double tolerance,
-                               int max_mult,
-                               int mult_flops)
-{
-    this->magnitude = magnitude;
-    this->restarting_scheme = restarting_scheme;
-    this->tolerance = tolerance;
-    this->max_mult = max_mult;
-    this->mult_flops = mult_flops;
-}
-
-// refactor-nice.pl: check this substitution
-// old: void EigValuesTRLAN::getEigenvalues ( const GenericMatrix &data, Vector & eigenvalues, Matrix & eigenvectors, uint k )
-void EigValuesTRLAN::getEigenvalues(const GenericMatrix &data, NICE::Vector & eigenvalues, NICE::Matrix & eigenvectors, uint k)
-{
-#ifdef DEBUG_TRLAN
-    fprintf(stderr, "Starting eigenvalue computation with Lanczos Iteration ...\n");
-#endif
-    assert(data.rows() == data.cols());
-    mat = &data;
-    int mat_size = (int)data.rows();
-
-    if (max_mult <= 0) max_mult = 10 * mat_size;
-    if (mult_flops <= 0) mult_flops = 10 * mat_size;
-    
-    int computed_eigenpairs = k;
-    int ipar[32] = {0, magnitude, computed_eigenpairs, 0, 0, restarting_scheme, max_mult, 0, 1, 99, -1, 98, mult_flops};
-    double* evalbuff = new double[k];
-    memset(evalbuff, 0, k*sizeof(double));
-    double* evecbuff = new double[k*mat_size];
-    memset(evecbuff, 1, k*mat_size*sizeof(double));
-    int ritz_size = (computed_eigenpairs < 3 ? 2 * computed_eigenpairs : computed_eigenpairs + 6);
-    int workspace_size = ritz_size * (ritz_size + 10);
-    double* workspace = new double[workspace_size];
-    workspace[0] = tolerance;
-#ifdef DEBUG_TRLAN
-    fprintf(stderr, "Initialization ready ... Starting TRLAN\n");
-#endif
-    // call lanczos iteration of trlan
-    int kint = k;
-    trlan77_(op, ipar, &mat_size, &kint, evalbuff, evecbuff, &mat_size, workspace, &workspace_size);
-
-    if(ipar[0]!=0)
-    {
-    	fprintf(stderr,"EigValuesTRLAN: Error occured by calling TRLAN Eigenvalue Computation.\n");
-    	fprintf(stderr,"EigValuesTRLAN: %d converged eigenvectors \n",ipar[3]);
-
-    }
-#ifdef DEBUG_TRLAN
-    fprintf(stderr, "TRLAN ready\n");
-#endif
-
-    //copy eigenvectors in evecbuff to stl vector
-    eigenvectors.resize(mat_size, k);
-    eigenvalues.resize(k);
-#ifdef DEBUG_TRLAN
-    fprintf(stderr, "Store results\n");
-#endif
-    if (magnitude < 0)
-    {
-        for (uint i = 0;i < k;i++)
-            for (uint j = 0;j < (uint)mat_size;j++)
-                eigenvectors(j, i) = evecbuff[i*mat_size+j];
-        for (uint i = 0;i < k;i++)
-            eigenvalues[i] = evalbuff[i];
-    }
-    else
-    {
-        for (uint i = 0;i < k;i++)
-            for (uint j = 0;j < (uint)mat_size;j++)
-                eigenvectors(j, k - i - 1) = evecbuff[i*mat_size+j];
-        for (uint i = 0;i < k;i++)
-            eigenvalues[i] = evalbuff[k-i-1];
-
-    }
-#ifdef DEBUG_TRLAN
-    fprintf(stderr, "Clean up\n");
-#endif
-
-    delete[] workspace;
-    delete[] evalbuff;
-    delete[] evecbuff;
-#ifdef DEBUG_TRLAN
-    fprintf(stderr, "Clean up Done\n");
-#endif
-}

+ 0 - 58
math/algebra_trlan/EigValuesTRLAN.h

@@ -1,58 +0,0 @@
-#ifndef EigenproblemINCLUDE
-#define EigenproblemINCLUDE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <vector>
-#include <string.h>
-
-
-#include "vislearning/math/algebra/EigValues.h"
-
-
-namespace OBJREC {
-
-/** Real Symmetric Eigenproblem - no parallel mode,
-    the eigenpairs returned by the method solve are ordered increasingly */
-class EigValuesTRLAN : public EigValues {
-      
-private:
-	int magnitude;
-	int restarting_scheme; 
-	double tolerance; 
-	int max_mult;
-	int mult_flops;
-
-public:
-
-	/** Init the TRLAN lanczos routine with the following parameters:
-           magnitude       -   Specifies the nature of the EigValuesTRLAN: 
-                               find eigenpair with respect to the k largest (magnitude>0) 
-                               or smallest (magnitude<0) eigenvalues
-           restarting_...  -   restarting scheme of TRLAN
-           max_mult        -   maximum number of matrix-vector multiplications to perform
-           tolerance       -   stop criterion (abs. resudual |A*x-lambda*x|?)
-           mult_flops       -  number of flops per matrix multiplication (used for statistics calculation)
-	*/
-	EigValuesTRLAN( int magnitude=1,
-                      int restarting_scheme=1,
-		      double tolerance=1e-8, 
-		      int max_mult=-1,
-                      int mult_flops=-1 );
-
-	~EigValuesTRLAN(){};
-
-	/**
-         * @param data matrix interface that does allow matrix-vector multiplications
-         * @param k number of eigenvalues/eigenvectors
-         * @param eigenvectors output Eigenvectors as Matrix
-         * @param eigenvalues output Eigenvalues as Vector
-         */
-	virtual void getEigenvalues ( const GenericMatrix &data, NICE::Vector & eigenvalues, NICE::Matrix & eigenvectors, uint k );
-};
-
-
-} // namespace
-
-#endif

+ 0 - 69
math/algebra_trlan/Eigenproblem.cpp

@@ -1,69 +0,0 @@
-#include "Eigenproblem.h"
-
-#include <iostream>
-
-using namespace OBJREC;
-
-using namespace std;
-
-	static Eigenproblem* eigen=NULL;
-
-	static void op(int* nrow, int* ncol, double* xin, int* ldx, double* xout, int* ldy){
-		eigen->sparseMult(xin,xout,*ldy);
-	}
-
-	void Eigenproblem::sparseMult(double* xin, double* xout,int ldy){
-		memset(xout,0,ldy*sizeof(double));
-		for(uint i=0;i<mat.size();i++){
-			xout[mat[i].x]+=mat[i].val * xin[mat[i].y];
-		}
-	}
-
-
-	typedef void (*OpFunc) (int* nrow,int* ncol, double* xin,int* ldx, double* xout, int* ldy);
-	extern "C" void trlan77_(OpFunc op, int ipar[32], int* nrowl, int* mev, double* eval, 
-                             double* evec, int* nrow2, double* wrk, int* lwrk);	
-
-	void Eigenproblem::solve(vector<element> mat, int mat_size, vector<double> &evals, 
-                             vector< vector<double> > &evecs, int k, int magnitude,
-                             int restarting_scheme, double tolerance, int max_mult,
-                             int mult_flops){
-	
-		this->mat=mat;
-
-		if(max_mult<=0) max_mult=10*mat_size;
-		if(mult_flops<=0) mult_flops=10*mat_size;
-
-		eigen=this;
-
-		int computed_eigenpairs=k;
-		int ipar[32]={0,magnitude,computed_eigenpairs,0,0,restarting_scheme,max_mult,0,1,99,-1,98,mult_flops};
-		double* evalbuff=new double[k];
-		memset(evalbuff,0,k*sizeof(double));
-		double* evecbuff=new double[k*mat_size];
-		memset(evecbuff,1,k*mat_size*sizeof(double));
-		int ritz_size=(computed_eigenpairs<3 ? 2*computed_eigenpairs : computed_eigenpairs+6);
-		int workspace_size=ritz_size*(ritz_size+10);
-		double* workspace=new double[workspace_size];
-		workspace[0]=tolerance;
-		trlan77_(op,ipar,&mat_size,&k,evalbuff,evecbuff,&mat_size,workspace,&workspace_size);
-		if(ipar[0]!=0)
-		    {
-		    	fprintf(stderr,"EigValuesTRLAN: Error occured by calling TRLAN Eigenvalue Computation.\n");
-		    	fprintf(stderr,"EigValuesTRLAN: %d converged eigenvectors \n",ipar[3]);
-
-		    }
-		//copy eigenvectors in evecbuff to stl vector
-    		for(int i=0;i<k;i++){
-			vector<double> vec;
-			for(int j=0;j<mat_size;j++){
-				vec.push_back(evecbuff[i*mat_size+j]);
-			}
-			evecs.push_back(vec);
-		}
-		for(int i=0;i<k;i++){
-			evals.push_back(evalbuff[i]);
-		}
-		delete[] evalbuff;
-		delete[] evecbuff;           
-	}

+ 0 - 59
math/algebra_trlan/Eigenproblem.h

@@ -1,59 +0,0 @@
-#ifndef EigenproblemINCLUDE
-#define EigenproblemINCLUDE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <vector>
-#include <string.h>
-
-
-typedef struct{
-	uint 	x;
-	uint 	y;
-	double 	val;
-} element;
-
-
-namespace OBJREC {
-
-/** depreceated version: Real Symmetric Eigenproblem - no parallel mode
- the eigenpairs returned by the method solve are ordered increasingly */
-class Eigenproblem{
-      
-private:
-
-public:
-
-	///performs matrix-vector multiplication with sparse matrix this->mat
-	void sparseMult(double* xin, double* yout, int ldy);
-
-	std::vector<element> mat;
-
-	Eigenproblem(){};
-	~Eigenproblem(){};
-
-	/** Solves the user defined eigenproblem with the following parameters:
-           mat             -   Sparse matrix
-           mat_size        -   matrix size, i.e. dim(mat)=mat_size x mat_size
-           evals           -   std::vector of eigenvalues
-           evecs           -   std::vector of k eigenvectors
-           k               -   number of eigenvalues/eigenvectors to compute
-           magnitude       -   Specifies the nature of the eigenproblem: 
-                               find eigenpair with respect to the k largest (magnitude>0) 
-                               or smallest (magnitude<0) eigenvalues
-           restarting_...  -   restarting scheme of TRLAN
-           max_mult        -   maximum number of matrix-vector multiplications to perform
-           tolerance       -   stop criterion (abs. resudual |A*x-lambda*x|?)
-           mult_flops       -  number of flops per matrix multiplication (used for statistics calculation)
-	*/
-	void solve(	std::vector<element> mat, int mat_size, std::vector<double> &evals, 
-                        std::vector< std::vector<double> > &evecs, int k=1, int magnitude=1,
-                        int restarting_scheme=1,double tolerance=1e-8, int max_mult=-1,
-                        int mult_flops=-1);
-};
-
-
-} // namespace
-
-#endif

+ 0 - 8
math/algebra_trlan/Makefile

@@ -1,8 +0,0 @@
-#TARGETS_FROM:=$(notdir $(patsubst %/,%,$(shell pwd)))/$(TARGETS_FROM)
-#$(info recursivly going up: $(TARGETS_FROM) ($(shell pwd)))
-
-all:
-
-%:
-	$(MAKE) TARGETS_FROM=$(notdir $(patsubst %/,%,$(shell pwd)))/$(TARGETS_FROM) -C .. $@
-

+ 0 - 103
math/algebra_trlan/Makefile.inc

@@ -1,103 +0,0 @@
-# LIBRARY-DIRECTORY-MAKEFILE
-# conventions:
-# - all subdirectories containing a "Makefile.inc" are considered sublibraries
-#   exception: "progs/" and "tests/" subdirectories!
-# - all ".C", ".cpp" and ".c" files in the current directory are linked to a
-#   library
-# - the library depends on all sublibraries 
-# - the library name is created with $(LIBNAME), i.e. it will be somehow
-#   related to the directory name and with the extension .a
-#   (e.g. lib1/sublib -> lib1_sublib.a)
-# - the library will be added to the default build list ALL_LIBRARIES
-
-# --------------------------------
-# - remember the last subdirectory
-#
-# set the variable $(SUBDIR) correctly to the current subdirectory. this
-# variable can be used throughout the current makefile.inc. The many 
-# SUBDIR_before, _add, and everything are only required so that we can recover
-# the previous content of SUBDIR before exitting the makefile.inc
-
-SUBDIR_add:=$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
-SUBDIR_before:=$(SUBDIR)
-SUBDIR:=$(strip $(SUBDIR_add))
-SUBDIR_before_$(SUBDIR):=$(SUBDIR_before)
-ifeq "$(SUBDIR)" "./"
-SUBDIR:=
-endif
-
-# ------------------------
-# - include subdirectories
-#
-# note the variables $(SUBDIRS_OF_$(SUBDIR)) are required later on to recover
-# the dependencies automatically. if you handle dependencies on your own, you
-# can also dump the $(SUBDIRS_OF_$(SUBDIR)) variable, and include the
-# makefile.inc of the subdirectories on your own...
-
-SUBDIRS_OF_$(SUBDIR):=$(patsubst %/Makefile.inc,%,$(wildcard $(SUBDIR)*/Makefile.inc))
-include $(SUBDIRS_OF_$(SUBDIR):%=%/Makefile.inc)
-
-# ----------------------------
-# - include local dependencies
-#
-# you can specify libraries needed by the individual objects or by the whole
-# directory. the object specific additional libraries are only considered
-# when compiling the specific object files
-# TODO: update documentation...
-
--include $(SUBDIR)libdepend.inc
-
-$(foreach d,$(filter-out %progs %tests,$(SUBDIRS_OF_$(SUBDIR))),$(eval $(call PKG_DEPEND_INT,$(d))))
-
-# ---------------------------
-# - objects in this directory
-#
-# the use of the variable $(OBJS) is not mandatory. it is mandatory however
-# to update $(ALL_OBJS) in a way that it contains the path and name of
-# all objects. otherwise we can not include the appropriate .d files.
-
-OBJS:=$(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.cpp))) \
-      $(patsubst %.C,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.C))) \
-	  $(shell grep -ls Q_OBJECT $(SUBDIR)*.h | sed -e's@^@/@;s@.*/@$(OBJDIR)moc_@;s@\.h$$@.o@') \
-      $(patsubst %.c,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.c)))
-ALL_OBJS += $(OBJS)
-
-# ----------------------------
-# - binaries in this directory
-#
-# output of binaries in this directory. none of the variables has to be used.
-# but everything you add to $(ALL_LIBRARIES) and $(ALL_BINARIES) will be
-# compiled with `make all`. be sure again to add the files with full path.
-
-LIBRARY_BASENAME:=$(call LIBNAME,$(SUBDIR))
-ifneq "$(SUBDIR)" ""
-ALL_LIBRARIES+=$(LIBDIR)$(LIBRARY_BASENAME).$(LINK_FILE_EXTENSION)
-endif
-
-# ---------------------
-# - binary dependencies
-#
-# there is no way of determining the binary dependencies automatically, so we
-# follow conventions. the current library depends on all sublibraries.
-# all other dependencies have to be added manually by specifying, that the
-# current .pc file depends on some other .pc file. binaries depending on
-# libraries should exclusivelly use the .pc files as well.
-
-ifeq "$(SKIP_BUILD_$(OBJDIR))" "1"
-$(LIBDIR)$(LIBRARY_BASENAME).a:
-else
-$(LIBDIR)$(LIBRARY_BASENAME).a:$(OBJS) \
-	$(call PRINT_INTLIB_DEPS,$(PKGDIR)$(LIBRARY_BASENAME).a,.$(LINK_FILE_EXTENSION))
-endif
-
-$(PKGDIR)$(LIBRARY_BASENAME).pc: \
-	$(call PRINT_INTLIB_DEPS,$(PKGDIR)$(LIBRARY_BASENAME).pc,.pc)
-
-# -------------------
-# - subdir management
-#
-# as the last step, always add this line to correctly recover the subdirectory
-# of the makefile including this one!
-
-SUBDIR:=$(SUBDIR_before_$(SUBDIR))
-

+ 0 - 2
math/algebra_trlan/libdepend.inc

@@ -1,2 +0,0 @@
-$(call PKG_DEPEND_EXT_ESSENTIAL,TRLAN)
-$(call PKG_DEPEND_INT,vislearning/math/algebra)

+ 0 - 88
math/algebra_trlan/progs/Makefile.inc

@@ -1,88 +0,0 @@
-# BINARY-DIRECTORY-MAKEFILE
-# conventions:
-# - there are no subdirectories, they are ignored!
-# - all ".C", ".cpp" and ".c" files in the current directory are considered
-#   independent binaries, and linked as such.
-# - the binaries depend on the library of the parent directory
-# - the binary names are created with $(BINNAME), i.e. it will be more or less
-#   the name of the .o file
-# - all binaries will be added to the default build list ALL_BINARIES
-
-# --------------------------------
-# - remember the last subdirectory
-#
-# set the variable $(SUBDIR) correctly to the current subdirectory. this
-# variable can be used throughout the current makefile.inc. The many 
-# SUBDIR_before, _add, and everything are only required so that we can recover
-# the previous content of SUBDIR before exitting the makefile.inc
-
-SUBDIR_add:=$(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
-SUBDIR_before:=$(SUBDIR)
-SUBDIR:=$(strip $(SUBDIR_add))
-SUBDIR_before_$(SUBDIR):=$(SUBDIR_before)
-
-# ------------------------
-# - include subdirectories
-#
-# note the variables $(SUBDIRS_OF_$(SUBDIR)) are required later on to recover
-# the dependencies automatically. if you handle dependencies on your own, you
-# can also dump the $(SUBDIRS_OF_$(SUBDIR)) variable, and include the
-# makefile.inc of the subdirectories on your own...
-
-#SUBDIRS_OF_$(SUBDIR):=$(patsubst %/Makefile.inc,%,$(wildcard $(SUBDIR)*/Makefile.inc))
-#include $(SUBDIRS_OF_$(SUBDIR):%=%/Makefile.inc)
-
-# ----------------------------
-# - include local dependencies
-#
-# include the libdepend.inc file, which gives additional dependencies for the
-# libraries and binaries. additionally, an automatic dependency from the library
-# of the parent directory is added (commented out in the code below).
-
--include $(SUBDIR)libdepend.inc
-
-PARENTDIR:=$(patsubst %/,%,$(dir $(patsubst %/,%,$(SUBDIR))))
-$(eval $(call PKG_DEPEND_INT,$(PARENTDIR)))
-
-# ---------------------------
-# - objects in this directory
-#
-# the use of the variable $(OBJS) is not mandatory. it is mandatory however
-# to update $(ALL_OBJS) in a way that it contains the path and name of
-# all objects. otherwise we can not include the appropriate .d files.
-
-OBJS:=$(patsubst %.cpp,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.cpp))) \
-      $(patsubst %.C,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.C))) \
-      $(shell grep -ls Q_OBJECT $(SUBDIR)*.h | sed -e's@^@/@;s@.*/@$(OBJDIR)moc_@;s@\.h$$@.o@') \
-      $(patsubst %.c,$(OBJDIR)%.o,$(notdir $(wildcard $(SUBDIR)*.c)))
-ALL_OBJS += $(OBJS)
-
-# ----------------------------
-# - binaries in this directory
-#
-# output of binaries in this directory. none of the variables has to be used.
-# but everything you add to $(ALL_LIBRARIES) and $(ALL_BINARIES) will be
-# compiled with `make all`. be sure again to add the files with full path.
-
-BINARIES:=$(patsubst %.o,$(BINDIR)%,$(filter-out moc_%,$(notdir $(OBJS))))
-ALL_BINARIES+=$(BINARIES)
-
-# ---------------------
-# - binary dependencies
-#
-# there is no way of determining the binary dependencies automatically, so we
-# follow conventions. each binary depends on the corresponding .o file and
-# on the libraries specified by the INTLIBS/EXTLIBS. these dependencies can be
-# specified manually or they are automatically stored in a .bd file.
-
-$(foreach head,$(wildcard $(SUBDIR)*.h),$(eval $(shell grep -q Q_OBJECT $(head) && echo $(head) | sed -e's@^@/@;s@.*/\(.*\)\.h$$@$(BINDIR)\1:$(OBJDIR)moc_\1.o@')))
--include $(OBJS:%.o=%.bd)
-
-# -------------------
-# - subdir management
-#
-# as the last step, always add this line to correctly recover the subdirectory
-# of the makefile including this one!
-
-SUBDIR:=$(SUBDIR_before_$(SUBDIR))
-

+ 0 - 51
math/algebra_trlan/progs/testTRLAN.cpp

@@ -1,51 +0,0 @@
-/** 
-2009.05.25.
-by M.Kemmler
-*/
-
-#include "vislearning/math/algebra_trlan/Eigenproblem.h"
-#include <iostream>
-#include <fstream>
-
-using namespace OBJREC;
-
-int main (int argc, char **argv)
-{   
-#ifdef NICE_USELIB_TRLAN
-	int N=10;
-	int problem_size=N*N;
-	int eval_nr=N;
-	element e;
-	std::vector<element> sparse_mat;
-	std::vector<double> evals;
-	std::vector< std::vector<double> > evecs;
-	//build sparse matrix
-	for(int i=0;i<N;i++){
-		for(int j=0;j<N;j++){
-			for(int k=i-5;k<i+5;k++){
-				for(int l=j-5;l<j+5;l++){
-					if(k<0||l<0||k>=N||l>=N) continue;
-					e.x=i*N+j;
-					e.y=k*N+l;
-					e.val=1.0/(1.0+i*j+k*l);
-					sparse_mat.push_back(e);
-					e.y=i*N+j;
-					e.x=k*N+l;
-					sparse_mat.push_back(e);
-				}
-			}
-		}
-	}
-
-	Eigenproblem eig;
-	eig.solve(sparse_mat,problem_size,evals,evecs,eval_nr,+1);
-
-	for(int i=0;i<eval_nr;i++){
-		std::cerr << "eigenvalue "<<i+1<<": \n\t"<<evals[i]<<std::endl;
-		std::cerr << "corresponding eigenvector:"<<i+1<<": \n";
-		for(int j=0;j<problem_size;j++) std::cerr << evecs[i][j] << std::endl;
-
-	}
-#endif
-
-}

+ 3 - 9
math/ftransform/FTransform.cpp

@@ -4,21 +4,15 @@
  * @author Michael Koch
  * @date 08/19/2008
      
-      */
-     /** \example testPCA.cpp
+*/
+/** \example testPCA.cpp
  * This is an example of how to use an instance of FTransform the Principal Component Analysis (PCA) class.
       */
-// #ifdef NOVISUAL
-// #include <vislearning/nice_nonvis.h>
-// #else
-// #include <vislearning/nice.h>
-// #endif
      
      
 #include "FTransform.h"
-// #include "vislearning/fourier/FourierLibrary.h"
      
-     // basic file operations
+// basic file operations
 #include <sstream>
 #include <iostream>
 #include <fstream>

+ 4 - 8
math/ftransform/FTransform.h

@@ -1,6 +1,6 @@
 /** 
 * @file FTransform.h
- * @brief FTransform Class Definition
+* @brief FTransform Class Definition
 * @author Michael Koch
 * @date 08/19/2008
 
@@ -8,17 +8,13 @@
 #ifndef FTRANSFORMINCLUDE
 #define FTRANSFORMINCLUDE
 
-#ifdef NOVISUAL
-#include <vislearning/nice_nonvis.h>
-#else
-#include <vislearning/nice.h>
-#endif
-  
 #include "core/basics/Persistent.h"
+#include "core/vector/VectorT.h"
+#include "core/vector/MatrixT.h"
 
 namespace OBJREC {
 
-/** __DESC__ */
+/** Abstract class for feature transformations */
 class FTransform: public NICE::Persistent
 {
 

+ 32 - 169
math/ftransform/PCA.cpp

@@ -12,20 +12,15 @@
 // #define DEBUG
 #undef DEBUG
 
-#include <vislearning/nice_nonvis.h>
-
 #include <iostream>
 #include <math.h>
 #include <vector>
 #include <map>
 
-#include "vislearning/math/algebra/AlgebraTools.h"
-#include "vislearning/math/algebra/GenericMatrix.h"
-#include "vislearning/math/algebra/EigValues.h"
+#include "core/algebra/GenericMatrix.h"
+#include "core/algebra/EigValues.h"
+#include "core/algebra/EigValuesTRLAN.h"
 
-#ifdef NICE_USELIB_TRLAN
-#include "vislearning/math/algebra_trlan/EigValuesTRLAN.h"
-#endif
 // #include "vislearning/fourier/FourierLibrary.h"
 #include "PCA.h"
 #include "vislearning/baselib/Gnuplot.h"
@@ -71,186 +66,61 @@ void PCA::restore(istream & is, int format)
 	is >> mean;
 	is >> targetDimension;
 }
+
 void PCA::store(ostream & os, int format) const
 {
 	os << basis << normalization << mean << targetDimension;
 }
+
 void PCA::clear()
 {
 
 }
 
 void PCA::calculateBasis(const NICE::Matrix &features,
-		const uint targetDimension, const uint mode)
+		const uint targetDimension)
 {
-	calculateBasis(features, targetDimension, mode, false);
+	calculateBasis(features, targetDimension, false);
 }
+
+void PCA::calculateMean ( const NICE::Matrix &features, NICE::Vector & mean )
+{
+  // data vectors are put row-wise in the matrix
+  mean.resize(features.cols());
+  for ( uint i = 0 ; i < features.rows(); i++ )
+    mean = mean + features.getRow(i);
+}
+
 void PCA::calculateBasis(const NICE::Matrix &features,
-		const uint targetDimension, const uint mode, const bool adaptive,
+		const uint targetDimension, const bool adaptive,
 		const double targetRatio)
 {
 	this->targetDimension = targetDimension;
+  // dimension of the feature vectors
 	uint srcFeatureSize = features.cols();
 	uint mindimension = std::min(this->targetDimension, srcFeatureSize);
 
-#ifdef DEBUG
-	cout << "calculateBasis ... stay a while and listen ..." << endl;
-#endif
-
 	NICE::Matrix eigenvectors;
 
 	NICE::Vector eigenvalue;
-#ifdef DEBUG
-	cout << "EigenValue Decomposition Working..." << endl;
-#endif
-	//switch mode: svd, lanczos, broken lanczos, arnoldi
-	//switch eigenvalue decomposition
-	switch (mode)
-	{
-	case 0:
-	{
-#ifndef NICE_USELIB_ICE
-		fthrow(Exception, "PCA: ICE needed for mode 0");
-#else
-#ifdef DEBUG
-		fprintf(stderr, "PCA: warning covariance computation in progress, memory and time consuming ...!\n");
-#endif
-		ice::Matrix sigma;
-		ice::Matrix eigenvectors_ice;
-		ice::Vector eigenvalue_ice;
-		ice::Matrix features_ice(NICE::makeICEMatrix(features));
-
-		Statistics st(srcFeatureSize);
-#ifdef DEBUG
-		fprintf(stderr, "Transform Features ... %d %d \n", features_ice.rows(), features_ice.cols());
-#endif
-		Put(st, features_ice);
-
-		ice::Vector mean_ice = Mean(st);
-		mean = makeEVector(mean_ice);
-#ifdef DEBUG
-		cout << "MEAN: " << mean_ice << endl;
-#endif
-		sigma = Covariance(st);
-#ifdef DEBUG
-		fprintf(stderr, "Covariance Ready \n");
-		fprintf(stderr, "Eigenvalue Computation ... \n");
-#endif
-		Eigenvalue(sigma, eigenvalue_ice, eigenvectors_ice);
-		NICE::Matrix eigenvectors_tmp;
-		eigenvectors_tmp = makeDoubleMatrix(eigenvectors_ice); //bad error
-		eigenvectors.resize(eigenvectors_tmp.rows(), eigenvectors_tmp.cols());
-		eigenvectors = eigenvectors_tmp;
-		eigenvalue = makeEVector(eigenvalue_ice);
-
-#endif
-		break;
-	}
-	case 1:
-	{
-
-#ifdef DEBUG
-		fprintf(stderr, "Calc mean \n");
-#endif
-		AlgebraTools::calculateMean(features, mean);
-#ifdef DEBUG
-		fprintf(stderr, "fastest available method \n");
-		//                cerr<<"mean:"<<mean<<endl;
-#endif
+  
+  calculateMean(features, mean);
 #ifdef NICE_USELIB_TRLAN
-		EigValues *eig = new EigValuesTRLAN();//fast lanczos TRLAN
+  EigValues *eig = new EigValuesTRLAN();//fast lanczos TRLAN
 #else
-		EigValues *eig = new EVArnoldi();//Arnoldi for (srcFeatureSize<n)
-#endif
-		NICE::Matrix features_transpose = features.transpose();
-		GMCovariance C(&features_transpose);
-#ifdef DEBUG
-		fprintf(stderr, "Perform PCA\n");
-		fprintf(stderr, "Matrix size %d %d %d %d \n", features.rows(), features.cols(), C.rows(), C.cols());
+  EigValues *eig = new EVArnoldi();//Arnoldi for (srcFeatureSize<n)
 #endif
-		if (adaptive)
-		{
-			eig->getEigenvalues(C, eigenvalue, eigenvectors, srcFeatureSize);
-		}
-		else
-		{
-			eig->getEigenvalues(C, eigenvalue, eigenvectors, mindimension);
-		}
-
-#ifdef DEBUG
-		fprintf(stderr, "PCA: Computation ready \n");
-		//                cerr<<eigenvectors<<endl;
-#endif
-
-#ifdef DEBUG
-		fprintf(stderr, "PCA: Transpose ready \n");
-		//                cerr<<eigenvectors<<endl;
-
-#endif
-		break;
-	}
-#ifdef USE_BROKEN_LANCZOS
-		case 2:
-		{
-			//Experimental TODO
-#ifdef DEBUG
-			fprintf(stderr, "Calc mean \n");
-#endif
-			AlgebraTools::calculateMean(features, mean);
-#ifdef DEBUG
-			fprintf(stderr, "Lanczos \n");
-#endif
-			EigValues *eig = new EVLanczos(100, 1e-4);
-			GMCovariance C(&features.transpose());
-			if(adaptive)
-			{
-				eig->getEigenvalues(C, eigenvalue, eigenvectors, srcFeatureSize);
-			}
-			else
-			{
-				eig->getEigenvalues(C, eigenvalue, eigenvectors, mindimension); //fast lanczos
-			}
-#ifdef DEBUG
-			fprintf(stderr, "PCA: Computation ready \n");
-#endif
-			break;
-		}
-#endif
-	case 3:
-	{
+  NICE::Matrix features_transpose = features.transpose();
+  GMCovariance C(&features_transpose);
+  if (adaptive)
+  {
+    eig->getEigenvalues(C, eigenvalue, eigenvectors, srcFeatureSize);
+  }
+  else
+  {
+    eig->getEigenvalues(C, eigenvalue, eigenvectors, mindimension);
+  }
 
-#ifdef DEBUG
-		fprintf(stderr, "Calc mean \n");
-#endif
-		AlgebraTools::calculateMean(features, mean);
-#ifdef DEBUG
-		fprintf(stderr, "Arnoldi \n");
-#endif
-		EigValues *eig = new EVArnoldi(100, 1e-4);
-		NICE::Matrix tmppointer = features.transpose();
-		GMCovariance C(&tmppointer);
-		if (adaptive)
-		{
-			eig->getEigenvalues(C, eigenvalue, eigenvectors, srcFeatureSize);
-		}
-		else
-		{
-			eig->getEigenvalues(C, eigenvalue, eigenvectors, mindimension); //fast arnoldi
-		}
-#ifdef DEBUG
-		fprintf(stderr, "PCA: Computation ready \n");
-#endif
-
-#ifdef DEBUG
-		fprintf(stderr, "PCA: Transpose ready \n");
-#endif
-		break;
-	}
-	default:
-		fprintf(stderr, "PCA: Wrong Computation mode: %d!\n", mode);
-		break;
-
-	}
 #ifdef DEBUG
 	fprintf(stderr, "Eigenvalue Decomposition ready \n");
 	cerr << eigenvectors << endl;
@@ -322,15 +192,8 @@ void PCA::calculateBasis(const NICE::Matrix &features,
 	}
 
 #ifdef DEBUG
-	cerr << basis << endl;
-	//     if (mode == 0)
-	//     {
-	//         cout << eigenvectors << endl;
-	//         cout << basis << endl;
-	//         cout << mean << endl;
 	cout << "Eigenvalue-absolute:" << eigenvalue << endl;
 	cout << "Eigenvalue-ratio:" << ratio << endl;
-	//     }
 #endif
 
 }

+ 5 - 10
math/ftransform/PCA.h

@@ -8,12 +8,6 @@
 #ifndef PCAINCLUDE
 #define PCAINCLUDE
 
-#ifdef NOVISUAL
-#include <vislearning/nice_nonvis.h>
-#else
-#include <vislearning/nice.h>
-#endif
-
 #include "vislearning/math/ftransform/FTransform.h"
 
 
@@ -27,12 +21,14 @@ class PCA: public FTransform
           NICE::Vector mean;
 
           NICE::Matrix basis;
-		  NICE::Matrix normbasis;
+		      NICE::Matrix normbasis;
 		  
           NICE::Matrix normalization;
           uint targetDimension; 
           uint maxiteration;
           double mindelta; 
+
+          void calculateMean ( const NICE::Matrix &features, NICE::Vector & mean );
  
      public:
        
@@ -50,11 +46,10 @@ class PCA: public FTransform
            * get Basis Vectors of PCA
            * @param features Input Features
            * @param dimension Dimension size / number of principal components 
-           * @param mode Algorithm mode 0=SVD 1=Arnoldi
           * @return Basis Vectors 
           */
-          void calculateBasis(const NICE::Matrix &features,const uint targetDimension,const uint mode=0);
-          void calculateBasis(const NICE::Matrix &features,const uint targetDimension,const uint mode,const bool adaptive,const double targetRatio=1.0);
+          void calculateBasis(const NICE::Matrix &features,const uint targetDimension);
+          void calculateBasis(const NICE::Matrix &features,const uint targetDimension,const bool adaptive,const double targetRatio=1.0);
 		  
 		  /**
 		   * returns the dimension of the transformed features

+ 1 - 4
math/ftransform/libdepend.inc

@@ -1,4 +1 @@
-$(call PKG_DEPEND_EXT,TRLAN)
-$(call PKG_DEPEND_EXT,ICE)
-$(call PKG_DEPEND_INT,vislearning/math/algebra)
-$(call PKG_DEPEND_INT,vislearning/math/algebra_trlan)
+$(call PKG_DEPEND_INT,core/algebra)

+ 5 - 5
math/kernels/KernelData.cpp

@@ -8,8 +8,8 @@
 #include <iostream>
 
 #include "KernelData.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
-#include "vislearning/math/algebra/CholeskyRobust.h"
+#include "core/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobust.h"
 #include "core/vector/Algorithms.h"
 
 #ifdef NICE_USELIB_OPENMP
@@ -79,7 +79,7 @@ void KernelData::initFromConfig ( const Config *conf, const string & section )
 		if ( verbose )
 			std::cerr << "KernelData: using the cholesky method with static regularization" << std::endl;
 
-		cr = new CholeskyRobust ( verbose, noiseStep, minimumLogDet, useCuda );
+		cr = new CholeskyRobust ( verbose, noiseStep, useCuda );
 	}
 }
 
@@ -629,9 +629,9 @@ void KernelData::perform_Rank_2k_Update(const std::vector<int> & rowIndices, con
 		if (verbose)
 		{
 			// we have to consider the entries which are added twice
-			for (int x = 0; x < rowIndices.size(); x++)
+			for (int x = 0; x < (int)rowIndices.size(); x++)
 			{
-				for (int y = x; y < rowIndices.size(); y++)
+				for (int y = x; y < (int)rowIndices.size(); y++)
 				{
 					UV(rowIndices[x] , rowIndices[y]) /= 2.0;
 					if (x!=y)

+ 2 - 2
math/kernels/KernelData.h

@@ -8,7 +8,7 @@
 #define _NICE_OBJREC_KERNELDATAINCLUDE
 
 #include "core/basics/Config.h"
-#include "vislearning/math/algebra/CholeskyRobust.h"
+#include "core/algebra/CholeskyRobust.h"
 #include "core/vector/MatrixT.h"
 
 namespace OBJREC {
@@ -28,7 +28,7 @@ class KernelData
 	protected:
 		bool verbose;
 
-		CholeskyRobust *cr;
+		NICE::CholeskyRobust *cr;
 
     protected:
 		NICE::Matrix kernelMatrix;

+ 1 - 1
math/kernels/libdepend.inc

@@ -1,3 +1,3 @@
 $(call PKG_DEPEND_INT,vislearning/math/mathbase)
 $(call PKG_DEPEND_INT,vislearning/math/distances)
-$(call PKG_DEPEND_INT,vislearning/math/algebra)
+$(call PKG_DEPEND_INT,core/algebra)

+ 1 - 1
math/pdf/PDFGaussian.cpp

@@ -15,7 +15,7 @@
 #include <sys/time.h>
 
 #include "vislearning/math/pdf/PDFGaussian.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobustAuto.h"
 
 #include "core/vector/Algorithms.h"
 #include "core/basics/numerictools.h"

+ 1 - 1
math/pdf/libdepend.inc

@@ -1,2 +1,2 @@
 $(call PKG_DEPEND_INT,vislearning/math/mathbase)
-$(call PKG_DEPEND_INT,vislearning/math/algebra)
+$(call PKG_DEPEND_INT,core/algebra)

+ 0 - 192
math/progs/testEigenvalues.cpp

@@ -1,192 +0,0 @@
-/** 
-* @file testEigenvalues.cpp
-* @brief test eigenvalues
-* @author Erik Rodner
-* @date 05/21/2008
-
-*/
-
-
-#include <vislearning/nice.h>
-
-#ifdef NICE_USELIB_ICE
-
-#include <image_nonvis.h>
-#include <core/iceconversion/convertice.h>
-#include <core/vector/Distance.h>
-
-#include "vislearning/math/algebra/EigValues.h"
-#ifdef NICE_USELIB_TRLAN
-#include "vislearning/math/algebra_trlan/EigValuesTRLAN.h"
-#endif
-#include "core/basics/Config.h"
-
-using namespace OBJREC;
-
-using namespace NICE;
-using namespace std;
-
-
-int main (int argc, char **argv)
-{   
-    std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
-
-    Config conf ( argc, argv );
-    uint rows = conf.gI("main", "n", 2);
-    uint cols = rows;
-    uint k = conf.gI("main", "k", rows);
-    uint maxiterations = conf.gI("main", "maxiterations", 100);
-    double mindelta = conf.gD("main", "mindelta", 1e-4 );
-    double sparse_prob = conf.gD("main", "sparseprob", 0.0 );
-    bool trlan = conf.gB("main", "trlan", false);
-    int trlan_magnitude = conf.gI("main", "trlan_magnitude", 1);
-    bool init_random = conf.gB("main", "init_random", true );
-
-    // refactor-nice.pl: check this substitution
-    // old: Matrix T (rows, cols);
-    NICE::Matrix T (rows, cols);
-    T.set(0.0);
-    if ( init_random )
-	srand48(time(NULL));
-
-    // generate random symmetric matrix
-    for ( uint i = 0 ; i < rows ; i++ )
-	for ( uint j = i ; j < cols ; j++ )
-	{
-	    if ( sparse_prob != 0.0 )
-		if ( drand48() < sparse_prob )
-		    continue;
-	    T(i, j) = drand48();
-	    T(j, i) = T(i, j);
-	}
-
-    // refactor-nice.pl: check this substitution
-    // old: Vector ice_eigvalues;
-    ice::Vector ice_eigvalues;
-    // refactor-nice.pl: check this substitution
-    // old: Matrix ice_eigvect;
-    ice::Matrix ice_eigvect;
-    Eigenvalue ( NICE::makeICEMatrix(T), ice_eigvalues, ice_eigvect );
-
-    EigValues *eig; 
-    
-    if ( ! trlan )
-    {
-		fprintf (stderr, "Eigenvalue method: Arnoldi iteration\n");
-		eig = new EVArnoldi( maxiterations, mindelta );
-    } else {
-#ifdef NICE_USELIB_TRLAN
-		fprintf (stderr, "Eigenvalue method: Lanczos (TRLAN) magn=%d\n", trlan_magnitude);
-		eig = new EigValuesTRLAN(trlan_magnitude);
-#else 
-		fprintf (stderr, "Eigenvalue method: Lanczos (TRLAN) not supported !\n");
-		exit(-1);
-#endif
-    }
-    
-    NICE::Vector eigvalues_dense;
-    NICE::Matrix eigvect_dense;
-    NICE::Vector eigvalues_sparse;
-    NICE::Matrix eigvect_sparse;
-
-    GMSlowICE Tg (T);
-    double start_dense = ice::TimeD();
-    eig->getEigenvalues ( Tg, eigvalues_dense, eigvect_dense, k );
-    double time_dense = ice::TimeD() - start_dense;
-
-    GMSparse Ts (T);
-    double start_sparse = ice::TimeD();
-    eig->getEigenvalues ( Ts, eigvalues_sparse, eigvect_sparse, k );
-    double time_sparse = ice::TimeD() - start_sparse;
-
-    fprintf (stderr, "time: sparse %fs, dense %fs\n", time_sparse, time_dense );
-
-    // test property
-    NICE::EuclidianDistance<double> eucliddist;
-    for ( uint i = 0 ; i < k ; i++ )
-    {
-		NICE::Vector v_dense = eigvect_dense.getColumn(i);
-		double lambda_dense = eigvalues_dense[i];
-		NICE::Vector Tv_dense;
-		Tv_dense.multiply ( T, v_dense );
-		NICE::Vector lv_dense = v_dense;
-		lv_dense *= lambda_dense;
-		double err_dense = eucliddist(Tv_dense, lv_dense);
-		
-		NICE::Vector v_sparse = eigvect_sparse.getColumn(i);
-		double lambda_sparse = eigvalues_sparse[i];
-			NICE::Vector Tv_sparse;
-		Tv_sparse.multiply ( T, v_sparse );
-		NICE::Vector lv_sparse = v_sparse;
-		lv_sparse *= lambda_sparse;
-		double err_sparse = eucliddist(Tv_sparse, lv_sparse);
-
-		ice::Matrix ice_T = makeICEMatrix(T);
-		cerr << T << endl;
-		cerr << ice_T << endl;
-		double err_ice = (ice_T*(!ice_eigvect)[i] - ice_eigvalues[i]*(!ice_eigvect)[i]).Length();
-		cerr << "eigenvalue " << i << endl;
-		cerr << "lambda (dense) = " << lambda_dense << endl;
-		cerr << "lambda (sparse) = " << lambda_sparse << endl;
-		cerr << "lambda (ICE) = " << ice_eigvalues[i] << endl;
-		cerr << "||Av - lambda v|| (dense) = " << err_dense << endl;
-		cerr << "||Av - lambda v|| (sparse) = " << err_sparse << endl;
-		cerr << "||Av - lambda v|| (ICE) = " << err_ice << endl;
-    }
-
-    // test covariance part
-
-    cerr << "------- Covariance Test -------" << endl;
-
-    int n = 2*rows; // number of data elements
-    NICE::Matrix data(rows, n);
-    ice::Statistics stat (rows);
-    for (int i = 0 ; i < n ; i++ )
-    {
-		for ( int j = 0 ; j < (int)rows ; j++ )
-			data(j, i) = drand48() + 100.0;
-
-		Put ( stat, NICE::makeIceVectorT( data.getColumn(i) ) );
-    }
-	cerr << "Mean: " << Mean(stat) << endl;
-    NICE::Matrix cov = NICE::makeDoubleMatrix ( Covariance(stat) );
-
-    GMSlowICE cov_slow ( cov );
-    GMCovariance cov_cov ( &data );
-    NICE::Vector x1t_slow;
-    cov_slow.multiply ( x1t_slow, data.getColumn(0) );
-    cerr << x1t_slow << endl;
-
-    NICE::Vector x1t_cov;
-    cov_cov.multiply ( x1t_cov, data.getColumn(0) );
-    cerr << x1t_cov << endl;
-    
-    cerr << "Difference (simple vector multiplication): " << eucliddist( x1t_slow, x1t_cov ) << endl;
-
-    double start_std = ice::TimeD();
-    eig->getEigenvalues ( cov_slow, eigvalues_dense, eigvect_dense, k );
-    double time_std = ice::TimeD() - start_std;
-
-    NICE::Vector eigvalues_cov;
-    NICE::Matrix eigvect_cov;
-    
-    double start_cov = ice::TimeD();
-    eig->getEigenvalues ( cov_cov, eigvalues_cov, eigvect_cov, k );
-    double time_cov = ice::TimeD() - start_cov;
-
-    cerr << "Eigenvalues (std) = " << eigvalues_dense << endl;
-    cerr << "Eigenvalues (covariance) = " << eigvalues_cov << endl;
-
-    fprintf (stderr, "time: cov %fs, std %fs\n", time_std, time_cov );
-    
-    
-    return 0;
-}
-
-#else
-int main (int argc, char **argv)
-{   
-    throw("no ice installed\n");
-    return 0;
-}
-#endif

+ 3 - 4
optimization/quadprog/QuadProg++.cpp

@@ -35,9 +35,8 @@
 #include <sstream>
 #include <stdexcept>
 #include "vislearning/optimization/quadprog/QuadProg++.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
-#include "vislearning/math/algebra/CholeskyRobust.h"
-#include <vislearning/nice.h>
+#include "core/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobust.h"
 
 //#define TRACE_SOLVER
 namespace QuadProgPP{
@@ -724,7 +723,7 @@ void cholesky_decomposition(Matrix<double>& A)
 	}
 	NICE::Matrix L;
 	L.resize(n,n);
-	OBJREC::CholeskyRobust *cra = new OBJREC::CholeskyRobustAuto(true);
+	NICE::CholeskyRobust *cra = new NICE::CholeskyRobustAuto(true);
 	cra->robustChol ( M, L );
 	//copy back
 	for (i = 0; i < n; i++)

+ 1 - 1
optimization/quadprog/libdepend.inc

@@ -1,3 +1,3 @@
 $(call PKG_DEPEND_INT,core/image)
 $(call PKG_DEPEND_INT,core/imagedisplay)
-$(call PKG_DEPEND_INT,vislearning/math/algebra)
+$(call PKG_DEPEND_INT,core/algebra)

+ 2 - 2
regression/gpregression/GPRegressionOptimizationProblem.cpp

@@ -9,8 +9,8 @@
 #include <iostream>
 
 #include "core/vector/Algorithms.h"
-#include "vislearning/math/algebra/CholeskyRobust.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobust.h"
+#include "core/algebra/CholeskyRobustAuto.h"
 
 #include "vislearning/math/kernels/OptimKernelParameterGradInterface.h"
 #include "GPRegressionOptimizationProblem.h"

+ 2 - 2
regression/gpregression/RegGaussianProcess.cpp

@@ -13,8 +13,8 @@
 #include "core/optimization/FirstOrderRasmussen.h"
 
 #include "core/vector/Algorithms.h"
-#include "vislearning/math/algebra/CholeskyRobust.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobust.h"
+#include "core/algebra/CholeskyRobustAuto.h"
 
 #include "RegGaussianProcess.h"
 #include "GPRegressionOptimizationProblem.h"

+ 1 - 1
regression/gpregression/modelselcrit/GPMSCLooEstimates.cpp

@@ -10,7 +10,7 @@
 #include "GPMSCLooEstimates.h"
 #include "vislearning/cbaselib/ClassificationResults.h"
 #include "vislearning/classifier/kernelclassifier/LikelihoodFunction.h"
-#include "vislearning/math/algebra/CholeskyRobustAuto.h"
+#include "core/algebra/CholeskyRobustAuto.h"
 #include "core/optimization/FirstOrderTrustRegion.h"
 
 #include "core/vector/Algorithms.h"