Machine Learning Library
CVectorOperations.h
Go to the documentation of this file.
1 /*
2  COPYRIGHT (C) 2003 APPLIED NEUROINFORMATIC GROUP - UNIVERSITY OF BIELEFELD.
3 
4  ALL RIGHTS RESERVED.
5 
6  REDISTRIBUTION AND USE IN SOURCE AND BINARY FORM, WITH OR WITHOUT
7  MODIFICATION, REQUIRE THE PERMISSION OF THE COPYRIGHT HOLDERS.
8 
9  COMMERCIAL USE WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT HOLDERS
10  IS FORBIDDEN
11 
12  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
13  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15  ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
16  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
20  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 */
23 
24 
25 
26 #ifndef __CVECTOROPERATIONS_H
27 #define __CVECTOROPERATIONS_H
28 
29 template<typename T> class CVector;
30 template<typename T> class CSparseVector;
31 template<typename T> class CDenseVector;
32 
33 // forward declaring string doesn't seem to work the usual way
34 #include <string>
35 
36 template<typename T>
38 {
39 public:
40  typedef T (*ScalarFunction)(const CVector<T>& a, const CVector<T>& b);
41  typedef void (*InplaceFunction)(CVector<T>& a, const CVector<T>& b);
42  typedef void (*InplaceFunctionArg)(CVector<T>&, const CVector<T>&, float, float);
43  typedef void (*CopyFunction)(CDenseVector<T>&, const CVector<T>&, const CVector<T>&); // CDenseVector output for now; maybe other types later on
44 
47 
48  // methods to retrieve specific operations
59 
60 
63 
64 protected:
65  int getIndex(const std::type_info&, const std::type_info&) const;
70 
73 
74 private:
75  ScalarFunction scalarProducts[4];
76  ScalarFunction euclideanDistances[4];
77  ScalarFunction coCosineDistances[4];
78  InplaceFunction elementProducts[4];
79  InplaceFunction elementDivisions[4];
80  InplaceFunction elementCopies[4];
81  CopyFunction elementAdditions[4];
82  CopyFunction elementSubtractions[4];
83  InplaceFunctionArg elementAdapts[4];
84 };
85 
86 /*
87  * Local variables:
88  * mode: c++
89  * End:
90  */
91 #endif
InplaceFunction getElementCopy(const CVector< T > &, const CVector< T > &) const
ScalarFunction getScalarProduct(const CVector< T > &, const CVector< T > &) const
ScalarFunction getEuclideanDistance(const CVector< T > &, const CVector< T > &) const
int getIndex(const std::type_info &, const std::type_info &) const
void(* InplaceFunction)(CVector< T > &a, const CVector< T > &b)
Definition: CVectorOperations.h:41
CDenseVector< T > dense
Definition: CVectorOperations.h:46
CopyFunction lookupCopyFunction(const CopyFunction *, const CVector< T > &, const CVector< T > &) const
void(* CopyFunction)(CDenseVector< T > &, const CVector< T > &, const CVector< T > &)
Definition: CVectorOperations.h:43
static CVectorOperations< T > & getInstance()
get Singleton instance
Sparse, immutable vector representation.
Definition: CSparseVector.h:42
CSparseVector< T > sparse
Definition: CVectorOperations.h:45
ScalarFunction lookupScalarFunction(const ScalarFunction *, const CVector< T > &, const CVector< T > &) const
ScalarFunction getCoCosineDistance(const CVector< T > &, const CVector< T > &) const
InplaceFunction getElementDivision(const CVector< T > &, const CVector< T > &) const
CopyFunction getElementAddition(const CVector< T > &, const CVector< T > &) const
T(* ScalarFunction)(const CVector< T > &a, const CVector< T > &b)
Definition: CVectorOperations.h:40
ScalarFunction getCommonProduct(const CVector< T > &, const CVector< T > &) const
Template object for vectors of single and double precision and integer.
Definition: CDenseVector.h:37
templatized vector for numerical applications
Definition: CMatrix.h:39
InplaceFunctionArg getElementAdapt(const CVector< T > &, const CVector< T > &) const
InplaceFunction getElementProduct(const CVector< T > &, const CVector< T > &) const
void(* InplaceFunctionArg)(CVector< T > &, const CVector< T > &, float, float)
Definition: CVectorOperations.h:42
CopyFunction getElementSubtraction(const CVector< T > &, const CVector< T > &) const
InplaceFunction lookupInplaceFunction(const InplaceFunction *, const CVector< T > &, const CVector< T > &) const
InplaceFunctionArg lookupInplaceFunctionArg(const InplaceFunctionArg *, const CVector< T > &, const CVector< T > &) const
Definition: CVectorOperations.h:37