Blame view

src/matrix/matrix-common.h 3.37 KB
8dcb6dfcb   Yannick Estève   first commit
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
  // matrix/matrix-common.h
  
  // Copyright 2009-2011  Microsoft Corporation
  
  // See ../../COPYING for clarification regarding multiple authors
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  
  //  http://www.apache.org/licenses/LICENSE-2.0
  
  // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  // MERCHANTABLITY OR NON-INFRINGEMENT.
  // See the Apache 2 License for the specific language governing permissions and
  // limitations under the License.
  #ifndef KALDI_MATRIX_MATRIX_COMMON_H_
  #define KALDI_MATRIX_MATRIX_COMMON_H_
  
  // This file contains some #includes, forward declarations
  // and typedefs that are needed by all the main header
  // files in this directory.
  
  #include "base/kaldi-common.h"
  
  namespace kaldi {
  // this enums equal to CblasTrans and CblasNoTrans constants from CBLAS library
  // we are writing them as literals because we don't want to include here matrix/kaldi-blas.h,
  // which puts many symbols into global scope (like "real") via the header f2c.h 
  typedef enum {
    kTrans    = 112, // = CblasTrans
    kNoTrans  = 111  // = CblasNoTrans
  } MatrixTransposeType;
  
  typedef enum {
    kSetZero,
    kUndefined,
    kCopyData
  } MatrixResizeType;
  
  
  typedef enum {
    kDefaultStride,
    kStrideEqualNumCols,
  } MatrixStrideType;
  
  typedef enum {
    kTakeLower,
    kTakeUpper,
    kTakeMean,
    kTakeMeanAndCheck
  } SpCopyType;
  
  template<typename Real> class VectorBase;
  template<typename Real> class Vector;
  template<typename Real> class SubVector;
  template<typename Real> class MatrixBase;
  template<typename Real> class SubMatrix;
  template<typename Real> class Matrix;
  template<typename Real> class SpMatrix;
  template<typename Real> class TpMatrix;
  template<typename Real> class PackedMatrix;
  template<typename Real> class SparseMatrix;
  
  // these are classes that won't be defined in this
  // directory; they're mostly needed for friend declarations.
  template<typename Real> class CuMatrixBase;
  template<typename Real> class CuSubMatrix;
  template<typename Real> class CuMatrix;
  template<typename Real> class CuVectorBase;
  template<typename Real> class CuSubVector;
  template<typename Real> class CuVector;
  template<typename Real> class CuPackedMatrix;
  template<typename Real> class CuSpMatrix;
  template<typename Real> class CuTpMatrix;
  template<typename Real> class CuSparseMatrix;
  
  class CompressedMatrix;
  class GeneralMatrix;
  
  /// This class provides a way for switching between double and float types.
  template<typename T> class OtherReal { };  // useful in reading+writing routines
                                             // to switch double and float.
  /// A specialized class for switching from float to double.
  template<> class OtherReal<float> {
   public:
    typedef double Real;
  };
  /// A specialized class for switching from double to float.
  template<> class OtherReal<double> {
   public:
    typedef float Real;
  };
  
  
  typedef int32 MatrixIndexT;
  typedef int32 SignedMatrixIndexT;
  typedef uint32 UnsignedMatrixIndexT;
  
  // If you want to use size_t for the index type, do as follows instead:
  //typedef size_t MatrixIndexT;
  //typedef ssize_t SignedMatrixIndexT;
  //typedef size_t UnsignedMatrixIndexT;
  
  }
  
  
  
  #endif  // KALDI_MATRIX_MATRIX_COMMON_H_