SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SparseInverseCovariance.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Copyright (C) 2009-2011 Jun Liu, Jieping Ye
8  * Copyright (C) 2012 Sergey Lisitsyn
9  */
10 
12 #include <shogun/base/Parameter.h>
14 
15 using namespace shogun;
16 
18  CSGObject(), m_lasso_max_iter(1000),
19  m_max_iter(1000), m_f_gap(1e-6), m_x_gap(1e-4),
20  m_xtol(1e-4)
21 {
22  register_parameters();
23 }
24 
26 {
27 }
28 
29 void CSparseInverseCovariance::register_parameters()
30 {
31  SG_ADD(&m_lasso_max_iter,"lasso_max_iter",
32  "maximum iteration of LASSO step",MS_NOT_AVAILABLE);
33  SG_ADD(&m_max_iter,"max_iter","maximum total iteration",
35  SG_ADD(&m_f_gap,"f_gap","f gap",MS_NOT_AVAILABLE);
36  SG_ADD(&m_x_gap,"x_gap","x gap",MS_NOT_AVAILABLE);
37  SG_ADD(&m_xtol,"xtol","xtol",MS_NOT_AVAILABLE);
38 }
39 
41 {
43 
44  int32_t n = S.num_cols;
45  float64_t sum_S = 0.0;
46  for (int32_t i=0; i<n; i++)
47  sum_S += S(i,i);
48 
49  float64_t* Theta = SG_CALLOC(float64_t, n*n);
50  float64_t* W = SG_CALLOC(float64_t, n*n);
51 
52  invCov(Theta, W, S.matrix, lambda_c, sum_S, n, m_lasso_max_iter,
54 
55  SG_FREE(W);
56  return SGMatrix<float64_t>(Theta,n,n);
57 }
index_t num_cols
Definition: SGMatrix.h:378
index_t num_rows
Definition: SGMatrix.h:376
#define ASSERT(x)
Definition: SGIO.h:201
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
double float64_t
Definition: common.h:50
void invCov(double *Theta, double *W, double *S, double lambda, double sum_S, int n, int LassoMaxIter, double fGap, double xGap, int maxIter, double xtol)
Definition: invCov.cpp:171
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
SGMatrix< float64_t > estimate(SGMatrix< float64_t > S, float64_t lambda_c)
#define SG_ADD(...)
Definition: SGObject.h:81

SHOGUN Machine Learning Toolbox - Documentation