OpendTect  6.6
pca.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: Kristofer Tingdahl
8  Date: 4-11-2002
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 
13 -*/
14 
15 #include "algomod.h"
16 #include "arrayndimpl.h"
17 #include "sets.h"
18 #include "trigonometry.h"
19 #include "threadwork.h"
20 
21 template <class T> class Array2D;
22 class SequentialTask;
23 class PCACovarianceCalculator;
24 
72 {
73 public:
74  PCA( int nrvars );
78  virtual ~PCA();
79 
84  template <class IDXABL> void addSample( const IDXABL& sample );
91  bool calculate();
94  float getEigenValue(int idx) const;
101  template <class IDXABL> void getEigenVector(int idx,
102  IDXABL& vec) const;
120 protected:
121  bool tqli( float[], float[], int, ObjectSet<float>&);
122  void tred2( ObjectSet<float>&, int, float[],float[]);
123 
124  const int nrvars_;
130  float* eigenvalues_;
135 };
136 
137 
138 template <class IDXABL> inline
139 void PCA::addSample( const IDXABL& sample )
140 {
141  TypeSet<float>& ownsample = *new TypeSet<float>;
142  for ( int idx=0; idx<nrvars_; idx++ )
143  {
144  const float val = (float) sample[idx];
145  ownsample += val;
146  samplesums_[idx] += val;
147  }
148 
149  samples_ += &ownsample;
150 }
151 
152 template <class IDXABL> inline
153 void PCA::getEigenVector(int idy, IDXABL& vec ) const
154 {
155  for ( int idx=0; idx<nrvars_; idx++ )
156  vec[idx] = covariancematrix_.get(idx, eigenvecindexes_[idy] );
157 }
158 
PCA::~PCA
virtual ~PCA()
PCA::samplesums_
TypeSet< float > samplesums_
Definition: pca.h:127
ObjectSet< float >
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
PCA::covariancematrix_
Array2DImpl< float > covariancematrix_
Definition: pca.h:125
PCA::eigenvalues_
float * eigenvalues_
Definition: pca.h:130
PCA::samples_
ObjectSet< TypeSet< float > > samples_
Definition: pca.h:126
PCA::tasks_
ObjectSet< SequentialTask > tasks_
Definition: pca.h:129
PCA::getEigenValue
float getEigenValue(int idx) const
arrayndimpl.h
threadwork.h
PCA
Performs Pricipal Component Analysis on samples with N variables.
Definition: pca.h:72
PCA::clearAllSamples
void clearAllSamples()
PCA::tqli
bool tqli(float[], float[], int, ObjectSet< float > &)
PCA::eigenvecindexes_
int * eigenvecindexes_
Definition: pca.h:134
PCA::workload_
TypeSet< Threads::Work > workload_
Definition: pca.h:128
PCA::PCA
PCA(int nrvars)
PCA::getEigenVector
void getEigenVector(int idx, IDXABL &vec) const
Definition: pca.h:153
PCA::calculate
bool calculate()
PCA::addSample
void addSample(const IDXABL &sample)
Definition: pca.h:139
Array2DImpl< float >
trigonometry.h
PCA::nrvars_
const int nrvars_
Definition: pca.h:124
PCA::tred2
void tred2(ObjectSet< float > &, int, float[], float[])
sets.h
Array2DImpl::get
T get(int, int) const
Definition: arrayndimpl.h:519
SequentialTask
The generalization of something (e.g. a computation) where the steps must be done in sequence,...
Definition: task.h:125
Array2D
Array2D ( Subclass of ArrayND ) is a two dimensional array.
Definition: arraynd.h:140
TypeSet< float >

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2021