SphinxBase  0.6
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 
143 SPHINXBASE_EXPORT
144 int32 invert(float32 **out_ainv, float32 **a, int32 len);
145 
157 SPHINXBASE_EXPORT
158 int32 solve(float32 **a, float32 *b,
159  float32 *out_x, int32 n);
160 
169 SPHINXBASE_EXPORT
170 void outerproduct(float32 **out_a, float32 *x, float32 *y, int32 len);
171 
179 SPHINXBASE_EXPORT
180 void matrixmultiply(float32 **out_c, /* = */
181  float32 **a, /* * */ float32 **b,
182  int32 n);
183 
190 SPHINXBASE_EXPORT
191 void scalarmultiply(float32 **inout_a, float32 x, int32 n);
192 
199 SPHINXBASE_EXPORT
200 void matrixadd(float32 **inout_a, float32 **b, int32 n);
201 
202 #if 0
203 { /* Fool indent. */
204 #endif
205 #ifdef __cplusplus
206 }
207 #endif
208 
209 #endif /* MATRIX_H */
210 
211 
212 /*
213  * Log record. Maintained by RCS.
214  *
215  * $Log$
216  * Revision 1.4 2004/07/21 17:46:09 egouvea
217  * Changed the license terms to make it the same as sphinx2 and sphinx3.
218  *
219  * Revision 1.3 2001/04/05 20:02:30 awb
220  * *** empty log message ***
221  *
222  * Revision 1.2 2000/09/29 22:35:12 awb
223  * *** empty log message ***
224  *
225  * Revision 1.1 2000/09/24 21:38:30 awb
226  * *** empty log message ***
227  *
228  * Revision 1.1 97/07/16 11:39:10 eht
229  * Initial revision
230  *
231  *
232  */
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:278
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.
Definition: matrix.c:153
SPHINXBASE_EXPORT void matrixadd(float32 **inout_a, float32 **b, int32 n)
Add A += B.
Definition: matrix.c:306
SPHINXBASE_EXPORT void band_nz_1d(float32 *v, uint32 d1, float32 band)
Ensures that non-zero values x such that -band < x < band, band > 0 are set to -band if x < 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:292
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