gvector.h

来自「一个由Mike Gashler完成的机器学习方面的includes neural」· C头文件 代码 · 共 94 行

H
94
字号
/*	Copyright (C) 2006, Mike Gashler	This library is free software; you can redistribute it and/or	modify it under the terms of the GNU Lesser General Public	License as published by the Free Software Foundation; either	version 2.1 of the License, or (at your option) any later version.	see http://www.gnu.org/copyleft/lesser.html*/#ifndef __GVECTOR_H__#define __GVECTOR_H__class GVector{protected:	double* m_pData;	int m_nSize;	bool m_bDeleteData;public:	GVector();	GVector(int nSize);	GVector(double* pData, int nSize, bool bTakeOwnership);	~GVector();	// Computes the dot product of two vectors	static double ComputeDotProduct(const double* pA, const double* pB, int nSize);	// Computes the dot product of (pTarget - pOrigin) with pVector	static double ComputeDotProduct(const double* pOrigin, const double* pTarget, const double* pVector, int nSize);	// Computes the squared magnitude of the vector	static double ComputeSquaredMagnitude(const double* pVector, int nSize);	// Computes the magnitude in L-Norm space (l=1 is manhattan distance, l=2 is Euclidean distance, etc.)	static double LNormComputeMagnitude(double l, const double* pVector, int nSize);	// Computes the squared distance between two vectors	static double ComputeSquaredDistance(double* pA, double* pB, int nSize);	// Computes the cosine of the angle between two vectors (the origin is the vertex)	static double ComputeCorrelation(const double* pA, const double* pB, int nDims);	// Normalizes this vector to a magnitude of 1	static void Normalize(double* pVector, int nSize);	// Normalizes in L-Norm space (l=1 is manhattan distance, l=2 is Euclidean distance, etc.)	static void LNormNormalize(double l, double* pVector, int nSize);	// Returns the index of the max value in pVector. If multiple elements have	// have an equivalent max value, it selects randomely from those elements	static int FindMax(double* pVector, int nSize);	// Makes a random normalized vector	static void GetRandomVector(double* pOutVector, int nSize);	// Returns true iff pVector is on the positive side of a surface	// with a normal vector pNormal at pCenter	static bool TestPivot(double* pCenter, double* pNormal, double* pVector, int nDims);	// Adds pSource to pDest	static void Add(double* pDest, double* pSource, int nDims);	// Subtracts pSource from pDest	static void Subtract(double* pDest, double* pSource, int nDims);	// Multiplies pVector by dScalar	static void Multiply(double* pVector, double dScalar, int nDims);	// Sets the vector to all zeros	static void SetToZero(double* pVector, int nDims);	// Returns the specified number of indexes of the most eccentric points in sorted order, where the most	// eccentric points are defined as the local-maxes of the local-maxes of the ..., and the local-mins of	// the local-mins of the ...	static void GetMostEccentricPoints(int* pOutPoints, int nPoints, double* pVector, int nDims);	// Interpolates (morphs) a set of indexes from one function to another. pInIndexes, pCorrIndexes1,	// and pCorrIndexes2 are all expected to be in sorted order. All indexes should be >= 0 and < nDims.	// fRatio is the interpolation ratio such that if fRatio is zero, all indexes left unchanged, and	// as fRatio approaches one, the indexes are interpolated linearly such that each index in pCorrIndexes1	// is interpolated linearly to the corresponding index in pCorrIndexes2. If the two extremes are not	// in the list of corresponding indexes, the ends may drift.	static void InterpolateIndexes(int nIndexes, double* pInIndexes, double* pOutIndexes, float fRatio, int nCorrIndexes, double* pCorrIndexes1, double* pCorrIndexes2);protected:	static void GetMostEccentricMaxs(int* pOutPoints, int nPoints, bool bMax, double* pVector, int nDims);};#endif // __GVECTOR_H__

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?