SphinxBase  5prealpha
matrix.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1997-2000 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * This work was supported in part by funding from the Defense Advanced
19  * Research Projects Agency and the National Science Foundation of the
20  * United States of America, and the CMU Sphinx Speech Consortium.
21  *
22  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * ====================================================================
35  *
36  */
37 /*********************************************************************
38  *
39  * File: matrix.h
40  *
41  * Description: Matrix and linear algebra functions
42  *
43  * Author:
44  *
45  *********************************************************************/
46 
47 #ifndef MATRIX_H
48 #define MATRIX_H
49 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 #if 0
64 /* Fool Emacs. */
65 }
66 #endif
67 
68 /* Win32/WinCE DLL gunk */
69 #include <sphinxbase/sphinxbase_export.h>
70 #include <sphinxbase/prim_type.h>
71 
72 
80 SPHINXBASE_EXPORT void norm_3d(float32 ***arr, uint32 d1, uint32 d2, uint32 d3);
81 
90 SPHINXBASE_EXPORT void
91 accum_3d(float32 ***out, float32 ***in, uint32 d1, uint32 d2, uint32 d3);
92 
98 SPHINXBASE_EXPORT void band_nz_1d(float32 *v, uint32 d1, float32 band);
99 
108 SPHINXBASE_EXPORT void floor_nz_3d(float32 ***m, uint32 d1, uint32 d2, uint32 d3, float32 floor);
109 
116 SPHINXBASE_EXPORT void floor_nz_1d(float32 *v, uint32 d1, float32 floor);
117 
130 SPHINXBASE_EXPORT
131 float64 determinant(float32 **a, int32 len);
132 
148 SPHINXBASE_EXPORT
149 int32 invert(float32 **out_ainv, float32 **a, int32 len);
150 
162 SPHINXBASE_EXPORT
163 int32 solve(float32 **a, float32 *b,
164  float32 *out_x, int32 n);
165 
174 SPHINXBASE_EXPORT
175 void outerproduct(float32 **out_a, float32 *x, float32 *y, int32 len);
176 
184 SPHINXBASE_EXPORT
185 void matrixmultiply(float32 **out_c, /* = */
186  float32 **a, /* * */ float32 **b,
187  int32 n);
188 
195 SPHINXBASE_EXPORT
196 void scalarmultiply(float32 **inout_a, float32 x, int32 n);
197 
204 SPHINXBASE_EXPORT
205 void matrixadd(float32 **inout_a, float32 **b, int32 n);
206 
207 #if 0
208 { /* Fool indent. */
209 #endif
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #endif /* MATRIX_H */
SPHINXBASE_EXPORT int32 solve(float32 **a, float32 *b, float32 *out_x, int32 n)
Solve (if possible) a positive-definite system of linear equations AX=B for X.
Definition: matrix.c:159
SPHINXBASE_EXPORT void outerproduct(float32 **out_a, float32 *x, float32 *y, int32 len)
Calculate the outer product of two vectors.
Definition: matrix.c:281
SPHINXBASE_EXPORT void accum_3d(float32 ***out, float32 ***in, uint32 d1, uint32 d2, uint32 d3)
Floor 3-d array.
Definition: matrix.c:78
Basic type definitions used in Sphinx.
SPHINXBASE_EXPORT int32 invert(float32 **out_ainv, float32 **a, int32 len)
Invert (if possible) a positive definite matrix with QR algorithm.
Definition: matrix.c:153
SPHINXBASE_EXPORT void matrixadd(float32 **inout_a, float32 **b, int32 n)
Add A += B.
Definition: matrix.c:309
SPHINXBASE_EXPORT void band_nz_1d(float32 *v, uint32 d1, float32 band)
Ensures that non-zero values x such that -band &lt; x &lt; band, band &gt; 0 are set to -band if x &lt; 0 and ban...
Definition: matrix.c:127
SPHINXBASE_EXPORT float64 determinant(float32 **a, int32 len)
Calculate the determinant of a positive definite matrix.
Definition: matrix.c:147
SPHINXBASE_EXPORT void matrixmultiply(float32 **out_c, float32 **a, float32 **b, int32 n)
Multiply C=AB where A and B are symmetric matrices.
Definition: matrix.c:166
SPHINXBASE_EXPORT void scalarmultiply(float32 **inout_a, float32 x, int32 n)
Multiply a symmetric matrix by a constant in-place.
Definition: matrix.c:295
SPHINXBASE_EXPORT void floor_nz_1d(float32 *v, uint32 d1, float32 floor)
Floor 1-d array.
Definition: matrix.c:114
SPHINXBASE_EXPORT void norm_3d(float32 ***arr, uint32 d1, uint32 d2, uint32 d3)
Norm an array.
Definition: matrix.c:50
SPHINXBASE_EXPORT void floor_nz_3d(float32 ***m, uint32 d1, uint32 d2, uint32 d3, float32 floor)
Floor 3-d array.
Definition: matrix.c:96