File: pcaPP.cpp

package info (click to toggle)
r-cran-pcapp 1.9-73-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 800 kB
  • sloc: cpp: 5,961; ansic: 917; sh: 13; makefile: 2
file content (39 lines) | stat: -rw-r--r-- 901 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "pcaPP.h"
#include "qnn.h"

	double mom2 (const SVecD &v)
	{
		double dRet = 0 ;

		EO<SOP::Apa_sqr_B>::SVc (dRet, v) ;

		return dRet / v.size () ;
	}

	double ApplyMethod (const SCVecD &v, const int nMethod)
	{
		ASSERT_TEMPRANGE (10, 10) ;
		SVecD temp (tempRef (10), v.size ()) ;	//	2do: should be copied by the constructor!
		temp.Copy_NC (v) ;

		return ApplyMethod_V (!temp, nMethod) ;
	}

	double ApplyMethod_V (const SVVecD &v, const int nMethod)
	{
		//VT:10.10.2016 - fix compilation warning - uninitialized variable.
		//
		double dRet = 0;
		int nSize = v.size () ;

		switch (nMethod)
		{
			case 0:	sd (dRet, v) ; break ;
			case 1: dRet = mad_V (*v) ; break ;
			case 2: qn (dRet, v.GetData (), nSize) ; break ;
			case 3: dRet = medianabs_V (*v) * 1.482602218505602 ; break ;
//			case 4: sd_st (dRet, v) ; break ;
			case 5: dRet = mom2 (v) ; break ;
		}
		return dRet ;
	}