OLD | NEW |
1 /*********************************************************************** | 1 /*********************************************************************** |
2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. | 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved. |
3 Redistribution and use in source and binary forms, with or without | 3 Redistribution and use in source and binary forms, with or without |
4 modification, are permitted provided that the following conditions | 4 modification, are permitted provided that the following conditions |
5 are met: | 5 are met: |
6 - Redistributions of source code must retain the above copyright notice, | 6 - Redistributions of source code must retain the above copyright notice, |
7 this list of conditions and the following disclaimer. | 7 this list of conditions and the following disclaimer. |
8 - Redistributions in binary form must reproduce the above copyright | 8 - Redistributions in binary form must reproduce the above copyright |
9 notice, this list of conditions and the following disclaimer in the | 9 notice, this list of conditions and the following disclaimer in the |
10 documentation and/or other materials provided with the distribution. | 10 documentation and/or other materials provided with the distribution. |
(...skipping 19 matching lines...) Expand all Loading... |
30 #endif | 30 #endif |
31 | 31 |
32 #include "main_FLP.h" | 32 #include "main_FLP.h" |
33 #include "tuning_parameters.h" | 33 #include "tuning_parameters.h" |
34 | 34 |
35 /********************************************************************** | 35 /********************************************************************** |
36 * LDL Factorisation. Finds the upper triangular matrix L and the diagonal | 36 * LDL Factorisation. Finds the upper triangular matrix L and the diagonal |
37 * Matrix D (only the diagonal elements returned in a vector)such that | 37 * Matrix D (only the diagonal elements returned in a vector)such that |
38 * the symmetric matric A is given by A = L*D*L'. | 38 * the symmetric matric A is given by A = L*D*L'. |
39 **********************************************************************/ | 39 **********************************************************************/ |
40 static inline void silk_LDL_FLP( | 40 static OPUS_INLINE void silk_LDL_FLP( |
41 silk_float *A, /* I/O Pointer to Symetric Square Matrix
*/ | 41 silk_float *A, /* I/O Pointer to Symetric Square Matrix
*/ |
42 opus_int M, /* I Size of Matrix
*/ | 42 opus_int M, /* I Size of Matrix
*/ |
43 silk_float *L, /* I/O Pointer to Square Upper triangular M
atrix */ | 43 silk_float *L, /* I/O Pointer to Square Upper triangular M
atrix */ |
44 silk_float *Dinv /* I/O Pointer to vector holding the invers
e diagonal elements of D */ | 44 silk_float *Dinv /* I/O Pointer to vector holding the invers
e diagonal elements of D */ |
45 ); | 45 ); |
46 | 46 |
47 /********************************************************************** | 47 /********************************************************************** |
48 * Function to solve linear equation Ax = b, when A is a MxM lower | 48 * Function to solve linear equation Ax = b, when A is a MxM lower |
49 * triangular matrix, with ones on the diagonal. | 49 * triangular matrix, with ones on the diagonal. |
50 **********************************************************************/ | 50 **********************************************************************/ |
51 static inline void silk_SolveWithLowerTriangularWdiagOnes_FLP( | 51 static OPUS_INLINE void silk_SolveWithLowerTriangularWdiagOnes_FLP( |
52 const silk_float *L, /* I Pointer to Lower Triangular Matrix
*/ | 52 const silk_float *L, /* I Pointer to Lower Triangular Matrix
*/ |
53 opus_int M, /* I Dim of Matrix equation
*/ | 53 opus_int M, /* I Dim of Matrix equation
*/ |
54 const silk_float *b, /* I b Vector
*/ | 54 const silk_float *b, /* I b Vector
*/ |
55 silk_float *x /* O x Vector
*/ | 55 silk_float *x /* O x Vector
*/ |
56 ); | 56 ); |
57 | 57 |
58 /********************************************************************** | 58 /********************************************************************** |
59 * Function to solve linear equation (A^T)x = b, when A is a MxM lower | 59 * Function to solve linear equation (A^T)x = b, when A is a MxM lower |
60 * triangular, with ones on the diagonal. (ie then A^T is upper triangular) | 60 * triangular, with ones on the diagonal. (ie then A^T is upper triangular) |
61 **********************************************************************/ | 61 **********************************************************************/ |
62 static inline void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( | 62 static OPUS_INLINE void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( |
63 const silk_float *L, /* I Pointer to Lower Triangular Matrix
*/ | 63 const silk_float *L, /* I Pointer to Lower Triangular Matrix
*/ |
64 opus_int M, /* I Dim of Matrix equation
*/ | 64 opus_int M, /* I Dim of Matrix equation
*/ |
65 const silk_float *b, /* I b Vector
*/ | 65 const silk_float *b, /* I b Vector
*/ |
66 silk_float *x /* O x Vector
*/ | 66 silk_float *x /* O x Vector
*/ |
67 ); | 67 ); |
68 | 68 |
69 /********************************************************************** | 69 /********************************************************************** |
70 * Function to solve linear equation Ax = b, when A is a MxM | 70 * Function to solve linear equation Ax = b, when A is a MxM |
71 * symmetric square matrix - using LDL factorisation | 71 * symmetric square matrix - using LDL factorisation |
72 **********************************************************************/ | 72 **********************************************************************/ |
(...skipping 29 matching lines...) Expand all Loading... |
102 ****************************************************/ | 102 ****************************************************/ |
103 for( i = 0; i < M; i++ ) { | 103 for( i = 0; i < M; i++ ) { |
104 T[ i ] = T[ i ] * Dinv[ i ]; | 104 T[ i ] = T[ i ] * Dinv[ i ]; |
105 } | 105 } |
106 /**************************************************** | 106 /**************************************************** |
107 x = inv(L') * inv(D) * T | 107 x = inv(L') * inv(D) * T |
108 *****************************************************/ | 108 *****************************************************/ |
109 silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( &L[ 0 ][ 0 ], M, T, x )
; | 109 silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( &L[ 0 ][ 0 ], M, T, x )
; |
110 } | 110 } |
111 | 111 |
112 static inline void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( | 112 static OPUS_INLINE void silk_SolveWithUpperTriangularFromLowerWdiagOnes_FLP( |
113 const silk_float *L, /* I Pointer to Lower Triangular Matrix
*/ | 113 const silk_float *L, /* I Pointer to Lower Triangular Matrix
*/ |
114 opus_int M, /* I Dim of Matrix equation
*/ | 114 opus_int M, /* I Dim of Matrix equation
*/ |
115 const silk_float *b, /* I b Vector
*/ | 115 const silk_float *b, /* I b Vector
*/ |
116 silk_float *x /* O x Vector
*/ | 116 silk_float *x /* O x Vector
*/ |
117 ) | 117 ) |
118 { | 118 { |
119 opus_int i, j; | 119 opus_int i, j; |
120 silk_float temp; | 120 silk_float temp; |
121 const silk_float *ptr1; | 121 const silk_float *ptr1; |
122 | 122 |
123 for( i = M - 1; i >= 0; i-- ) { | 123 for( i = M - 1; i >= 0; i-- ) { |
124 ptr1 = matrix_adr( L, 0, i, M ); | 124 ptr1 = matrix_adr( L, 0, i, M ); |
125 temp = 0; | 125 temp = 0; |
126 for( j = M - 1; j > i ; j-- ) { | 126 for( j = M - 1; j > i ; j-- ) { |
127 temp += ptr1[ j * M ] * x[ j ]; | 127 temp += ptr1[ j * M ] * x[ j ]; |
128 } | 128 } |
129 temp = b[ i ] - temp; | 129 temp = b[ i ] - temp; |
130 x[ i ] = temp; | 130 x[ i ] = temp; |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 static inline void silk_SolveWithLowerTriangularWdiagOnes_FLP( | 134 static OPUS_INLINE void silk_SolveWithLowerTriangularWdiagOnes_FLP( |
135 const silk_float *L, /* I Pointer to Lower Triangular Matrix
*/ | 135 const silk_float *L, /* I Pointer to Lower Triangular Matrix
*/ |
136 opus_int M, /* I Dim of Matrix equation
*/ | 136 opus_int M, /* I Dim of Matrix equation
*/ |
137 const silk_float *b, /* I b Vector
*/ | 137 const silk_float *b, /* I b Vector
*/ |
138 silk_float *x /* O x Vector
*/ | 138 silk_float *x /* O x Vector
*/ |
139 ) | 139 ) |
140 { | 140 { |
141 opus_int i, j; | 141 opus_int i, j; |
142 silk_float temp; | 142 silk_float temp; |
143 const silk_float *ptr1; | 143 const silk_float *ptr1; |
144 | 144 |
145 for( i = 0; i < M; i++ ) { | 145 for( i = 0; i < M; i++ ) { |
146 ptr1 = matrix_adr( L, i, 0, M ); | 146 ptr1 = matrix_adr( L, i, 0, M ); |
147 temp = 0; | 147 temp = 0; |
148 for( j = 0; j < i; j++ ) { | 148 for( j = 0; j < i; j++ ) { |
149 temp += ptr1[ j ] * x[ j ]; | 149 temp += ptr1[ j ] * x[ j ]; |
150 } | 150 } |
151 temp = b[ i ] - temp; | 151 temp = b[ i ] - temp; |
152 x[ i ] = temp; | 152 x[ i ] = temp; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 static inline void silk_LDL_FLP( | 156 static OPUS_INLINE void silk_LDL_FLP( |
157 silk_float *A, /* I/O Pointer to Symetric Square Matrix
*/ | 157 silk_float *A, /* I/O Pointer to Symetric Square Matrix
*/ |
158 opus_int M, /* I Size of Matrix
*/ | 158 opus_int M, /* I Size of Matrix
*/ |
159 silk_float *L, /* I/O Pointer to Square Upper triangular M
atrix */ | 159 silk_float *L, /* I/O Pointer to Square Upper triangular M
atrix */ |
160 silk_float *Dinv /* I/O Pointer to vector holding the invers
e diagonal elements of D */ | 160 silk_float *Dinv /* I/O Pointer to vector holding the invers
e diagonal elements of D */ |
161 ) | 161 ) |
162 { | 162 { |
163 opus_int i, j, k, loop_count, err = 1; | 163 opus_int i, j, k, loop_count, err = 1; |
164 silk_float *ptr1, *ptr2; | 164 silk_float *ptr1, *ptr2; |
165 double temp, diag_min_value; | 165 double temp, diag_min_value; |
166 silk_float v[ MAX_MATRIX_SIZE ], D[ MAX_MATRIX_SIZE ]; /* temp arrays*/ | 166 silk_float v[ MAX_MATRIX_SIZE ], D[ MAX_MATRIX_SIZE ]; /* temp arrays*/ |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 temp += ptr2[ k ] * v[ k ]; | 198 temp += ptr2[ k ] * v[ k ]; |
199 } | 199 } |
200 matrix_ptr( L, i, j, M ) = ( silk_float )( ( ptr1[ i ] - temp )
* Dinv[ j ] ); | 200 matrix_ptr( L, i, j, M ) = ( silk_float )( ( ptr1[ i ] - temp )
* Dinv[ j ] ); |
201 ptr2 += M; /* go to next column*/ | 201 ptr2 += M; /* go to next column*/ |
202 } | 202 } |
203 } | 203 } |
204 } | 204 } |
205 silk_assert( err == 0 ); | 205 silk_assert( err == 0 ); |
206 } | 206 } |
207 | 207 |
OLD | NEW |