Edinburgh Speech Tools  2.1-release
vec_mat_aux.cc
Go to the documentation of this file.
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1995,1996 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* Author : Simon King */
34 /* Date : April 1995 */
35 /*-----------------------------------------------------------------------*/
36 /* EST_FMatrix Class auxiliary functions */
37 /* */
38 /*=======================================================================*/
39 #include "EST_FMatrix.h"
40 #include "EST_system.h"
41 #include <cstdlib>
42 #include <climits>
43 #include "EST_unix.h"
44 #include "EST_math.h"
45 #include <ctime>
46 
47 using namespace std;
48 
50  EST_FVector &co_effs, int order)
51 {
52  EST_FVector weights;
53  weights.resize(x.n());
54  for(ssize_t i=0; i<x.n(); ++i)
55  weights[i] = 1.0;
56 
57  return polynomial_fit(x,y,co_effs,weights,order);
58 }
59 
61  EST_FVector &weights, int order)
62 {
63 
64  if(x.n() != y.n()){
65  cerr << "polynomial_fit : x and y must have same dimension" << endl;
66  return false;
67  }
68 
69  if(weights.n() != y.n()){
70  cerr << "polynomial_fit : weights must have same dimension as x and y" << endl;
71  return false;
72  }
73 
74  if(x.n() <= order){
75  cerr << "polynomial_fit : x and y must have at least order+1 elements"
76  << endl;
77  return false;
78  }
79 
80 
81  // matrix of basis function values
82  EST_FMatrix A;
83  A.resize(x.n(),order+1);
84 
85  EST_FVector y1;
86  y1.resize(y.n());
87 
88  for(ssize_t row=0;row<y.n();row++)
89  {
90  y1[row] = y[row] * weights[row];
91  for(ssize_t col=0;col<=order;col++){
92  A(row,col) = pow(x[row],(float)col) * weights[row];
93 
94  }
95  }
96 
97  // could call pseudo_inverse, but save a bit by doing
98  // it here since we need transpose(A) anyway
99 
100  EST_FMatrix At, At_A, At_A_inv;
101  int singularity=-2;
102 
103  transpose(A,At);
104  multiply(At,A,At_A);
105 
106  // error check
107  if(!inverse(At_A,At_A_inv,singularity))
108  {
109  cerr << "polynomial_fit : inverse failed (";
110  if(singularity == -2)
111  cerr << "unspecified reason)" << endl;
112  else if(singularity == -1)
113  cerr << "non-square !!)" << endl;
114  else
115  {
116  cerr << "singularity at point : " << singularity;
117  cerr << " = " << x[singularity] << "," << y[singularity];
118  cerr << " )" << endl;
119  }
120  return false;
121  }
122 
123  EST_FVector At_y1 = At * y1;
124  co_effs = At_A_inv * At_y1;
125  return true;
126 
127 }
128 
129 float matrix_max(const EST_FMatrix &a)
130 {
131  ssize_t i, j;
132  float v = INT_MIN;
133 
134  for (i = 0; i < a.num_rows(); ++i)
135  for (j = 0; j < a.num_columns(); ++j)
136  if (a.a_no_check(i, j) > v)
137  v = a.a_no_check(i, j);
138 
139  return v;
140 }
141 
142 int square(const EST_FMatrix &a)
143 {
144  return a.num_rows() == a.num_columns();
145 }
146 // add all elements in matrix.
147 float sum(const EST_FMatrix &a)
148 {
149  ssize_t i, j;
150  float t = 0.0;
151  for (i = 0; i < a.num_rows(); ++i)
152  for (j = 0; j < a.num_columns(); ++j)
153  t += a.a_no_check(i, j);
154  return t;
155 }
156 
157 // set all elements not on the diagonal to zero.
159 {
160  ssize_t i;
161  EST_FMatrix b(a, 0); // initialise and fill b with zeros
162 
163  if (a.num_rows() != a.num_columns())
164  {
165  cerr << "diagonalise: non-square matrix ";
166  return b;
167  }
168 
169  for (i = 0; i < a.num_rows(); ++i)
170  b(i, i) = a.a_no_check(i, i);
171 
172  return b;
173 }
174 
175 // set all elements not on the diagonal to zero.
177 {
178  // NB - will work on non-square matrices without warning
179  ssize_t i,j;
180 
181  for (i = 0; i < a.num_rows(); ++i)
182  for (j = 0; j < a.num_columns(); ++j)
183  if(i != j)
184  a.a_no_check(i, j) = 0;
185 }
186 
188 {
189  ssize_t i, j, I, J;
190  ssize_t n = a.num_rows() - 1;
191  EST_FMatrix s(n, n);
192 
193  for (i = I = 0; i < n; ++i, ++I)
194  {
195  if (I == row)
196  ++I;
197  for (j = J = 0; j < n; ++j, ++J)
198  {
199  if (J == col)
200  ++J;
201  s(i, j) = a.a(I, J);
202  }
203  }
204 
205  // cout << "sub: row " << row << " col " << col << "\n" << s;
206 
207  return s;
208 }
209 
211 {
212  EST_FMatrix s(1, a.num_columns());
213  ssize_t i;
214 
215  for (i = 0; i < a.num_columns(); ++i)
216  s(0, i) = a.a(row, i);
217 
218  return s;
219 }
220 
222 {
223  EST_FMatrix s(a.num_rows(), 1);
224  ssize_t i;
225 
226  for (i = 0; i < a.num_rows(); ++i)
227  s(i, 0) = a.a(i, col);
228 
229  return s;
230 }
231 
233 {
234  EST_FMatrix b(a, 0);
235  ssize_t i, j;
236 
237  for (i = 0; i < a.num_rows(); ++i)
238  for (j = i; j < a.num_rows(); ++j)
239  b(j, i) = a.a(j, i);
240 
241  return b;
242 }
243 
245 {
246  ssize_t i, j;
247  b.resize(a.num_columns(), a.num_rows());
248 
249  for (i = 0; i < b.num_rows(); ++i)
250  for (j = 0; j < b.num_columns(); ++j)
251  b.a_no_check(i, j) = a.a_no_check(j, i);
252 }
253 
255 {
256  ssize_t i, j, n;
257  n = a.num_columns();
258  EST_FMatrix t(n, n);
259 
260  for (i = 0; i < n; ++i)
261  for (j = 0; j < n; ++j)
262  t(n - i - 1, n - j - 1) = a.a(i, j);
263 
264  return t;
265 }
266 
267 
268 // changed name from abs as it causes on at least on POSIX machine
269 // where int abs(int) is a macro
271 {
272  ssize_t i, j;
273  EST_FMatrix b(a, 0);
274 
275  for (i = 0; i < a.num_rows(); ++i)
276  for (j = 0; j < a.num_columns(); ++j)
277  b.a_no_check(i, j) = fabs(a.a_no_check(i, j));
278 
279  return b;
280 }
281 
282 static void row_swap(ssize_t from, ssize_t to, EST_FMatrix &a)
283 {
284  ssize_t i;
285  float f;
286 
287  if (from == to)
288  return;
289 
290  for (i=0; i < a.num_columns(); i++)
291  {
292  f = a.a_no_check(to,i);
293  a.a_no_check(to,i) = a.a_no_check(from,i);
294  a.a_no_check(from,i) = f;
295  }
296 }
297 
298 int inverse(const EST_FMatrix &a,EST_FMatrix &inv)
299 {
300  int singularity=0;
301  return inverse(a,inv,singularity);
302 }
303 
304 int inverse(const EST_FMatrix &a,EST_FMatrix &inv,int &singularity)
305 {
306 
307  // Used to use a function written by Richard Tobin (in C) but
308  // we no longer need C functionality any more. This algorithm
309  // follows that in "Introduction to Algorithms", Cormen, Leiserson
310  // and Rivest (p759) and the term Gauss-Jordon is used for some part,
311  // As well as looking back at Richard's.
312  // This also keeps a record of which rows are which from the original
313  // so that it can return which column actually has the singularity
314  // in it if it fails to find an inverse.
315  ssize_t i, j, k;
316  ssize_t n = a.num_rows();
317  EST_FMatrix b = a; // going to destructively manipulate b to get inv
318  EST_FMatrix pos; // the original position
319  float biggest,s;
320  ssize_t r=0,this_row,all_zeros;
321 
322  singularity = -1;
323  if (a.num_rows() != a.num_columns())
324  return FALSE;
325 
326  // Make the inverse the identity matrix.
327  inv.resize(n,n);
328  pos.resize(n,1);
329  for (i=0; i<n; i++)
330  for (j=0; j<n; j++)
331  inv.a_no_check(i,j) = 0.0;
332  for (i=0; i<n; i++)
333  {
334  inv.a_no_check(i,i) = 1.0;
335  pos.a_no_check(i,0) = (float)i;
336  }
337 
338  // Manipulate b to make it into the identity matrix, while performing
339  // the same manipulation on inv. Once b becomes the identity inv will
340  // be the inverse (unless theres a singularity)
341 
342  for (i=0; i<n; i++)
343  {
344  // Find the absolute largest val in this col as the next to
345  // manipulate.
346  biggest = 0.0;
347  r = 0;
348  for (j=i; j<n; j++)
349  {
350  if (fabs(b.a_no_check(j,i)) > biggest)
351  {
352  r = j;
353  biggest = fabs(b.a_no_check(j,i));
354  }
355  }
356 
357  if (biggest == 0.0) // oops found a singularity
358  {
359  singularity = (int)pos.a_no_check(i,0);
360  return FALSE;
361  }
362 
363  // Swap current with biggest
364  this_row = (int)pos.a_no_check(i,0); // in case we need this number
365  row_swap(r,i,b);
366  row_swap(r,i,inv);
367  row_swap(r,i,pos);
368 
369  // Make b(i,i) = 1
370  s = b(i,i);
371  for (k=0; k<n; k++)
372  {
373  b.a_no_check(i,k) /= s;
374  inv.a_no_check(i,k) /= s;
375  }
376 
377  // make rest in col(i) 0
378  for (j=0; j<n; j++)
379  {
380  if (j==i) continue;
381  s = b.a_no_check(j,i);
382  all_zeros = TRUE;
383  for (k=0; k<n; k++)
384  {
385  b.a_no_check(j,k) -= b.a_no_check(i,k) * s;
386  if (b.a_no_check(j,k) != 0)
387  all_zeros = FALSE;
388  inv.a_no_check(j,k) -= inv.a_no_check(i,k) * s;
389  }
390  if (all_zeros)
391  {
392  // printf("singularity between (internal) columns %d %d\n",
393  // this_row,j);
394  // always identify greater row so linear regression
395  // can preserve intercept in column 0
396  singularity = ((this_row > j) ? this_row : j);
397  return FALSE;
398  }
399  }
400  }
401 
402  return TRUE;
403 }
404 
406 {
407  int singularity=0;
408  return pseudo_inverse(a,inv,singularity);
409 }
410 
411 int pseudo_inverse(const EST_FMatrix &a, EST_FMatrix &inv,int &singularity)
412 {
413  // for non-square matrices
414  // useful for solving linear eqns
415  // (e.g. polynomial fitting)
416 
417  // is it square ?
418  if( a.num_rows() == a.num_columns() )
419  return inverse(a,inv,singularity);
420 
421  if( a.num_rows() < a.num_columns() )
422  return FALSE;
423 
424  EST_FMatrix a_trans,atrans_a,atrans_a_inverse;
425 
426  transpose(a,a_trans);
427  multiply(a_trans,a,atrans_a);
428  if (!inverse(atrans_a,atrans_a_inverse,singularity))
429  return FALSE;
430  multiply(atrans_a_inverse,a_trans,inv);
431 
432  return TRUE;
433 }
434 
435 
436 float determinant(const EST_FMatrix &a)
437 {
438  ssize_t i, j;
439  ssize_t n = a.num_rows();
440  float det;
441  if (!square(a))
442  {
443  cerr << "Tried to take determinant of non-square matrix\n";
444  return 0.0;
445  }
446 
447  EST_FVector A(n);
448 
449  if (n == 2) // special case of 2x2 determinant
450  return (a.a_no_check(0,0) * a.a_no_check(1,1)) -
451  (a.a_no_check(0,1) * a.a_no_check(1,0));
452 
453  float p;
454 
455  // create cofactor matrix
456  j = 1;
457  for (i = 0; i < n; ++i)
458  {
459  p = (float)(i + j + 2); // because i & j should start at 1
460  // cout << "power " <<p << endl;
461  A[i] = pow((float)-1.0, p) * determinant(sub(a, i, j));
462  }
463  // cout << "cofactor " << A;
464 
465  // sum confactor and original matrix
466  det = 0.0;
467  for (i = 0; i < n; ++i)
468  det += a.a_no_check(i, j) * A[i];
469 
470  return det;
471 }
472 
473 void eye(EST_FMatrix &a, const ssize_t n)
474 {
475  ssize_t i,j;
476  a.resize(n,n);
477  for (i=0; i<n; i++)
478  {
479  for (j=0; j<n; j++)
480  a.a_no_check(i,j) = 0.0;
481 
482  a.a_no_check(i,i) = 1.0;
483  }
484 }
485 
486 void eye(EST_FMatrix &a)
487 {
488  ssize_t i,n;
489  n=a.num_rows();
490  if(n != a.num_columns())
491  {
492  cerr << "Can't make non-square identity matrix !" << endl;
493  return;
494  }
495 
496  a.fill(0.0);
497  for (i=0; i<n; i++)
498  a.a_no_check(i,i) = 1.0;
499 }
500 
502 {
503  // a + b
504  ssize_t a_len = a.length();
505  EST_FVector ans( a_len );
506 
507  if(a_len != b.length()){
508  cerr << "Can't add vectors of differing lengths !" << endl;
509  ans.resize(0);
510  return ans;
511  };
512 
513  for( ssize_t i=0; i<a_len; i++ )
514  ans.a_no_check(i) = a.a_no_check(i) + b.a_no_check(i);
515 
516  return ans;
517 }
518 
520 {
521  // a - b
522  ssize_t a_len = a.length();
523  EST_FVector ans( a_len );
524 
525  if(a_len != b.length()){
526  cerr << "Can't subtract vectors of differing lengths !" << endl;
527  ans.resize(0);
528  return ans;
529  };
530 
531  for( ssize_t i=0; i<a_len; i++ )
532  ans.a_no_check(i) = a.a_no_check(i) - b.a_no_check(i);
533 
534  return ans;
535 }
536 
538 {
539 
540  EST_FVector ans;
541  if(a.num_rows() != a.num_columns())
542  {
543  cerr << "Can't extract diagonal of non-square matrix !" << endl;
544  return ans;
545  }
546  ssize_t i;
547  ans.resize(a.num_rows());
548  for(i=0;i<a.num_rows();i++)
549  ans.a_no_check(i) = a.a_no_check(i,i);
550 
551  return ans;
552 }
553 
554 float polynomial_value(const EST_FVector &coeffs, const float x)
555 {
556  float y=0;
557 
558  for(ssize_t i=0;i<coeffs.length();i++)
559  y += coeffs.a_no_check(i) * pow(x,(float)i);
560 
561  return y;
562 }
563 
565 {
566  // uses include enforcing symmetry
567  // of covariance matrices (to compensate
568  // for rounding errors)
569 
570  float f;
571 
572  if(a.num_columns() != a.num_rows())
573  {
574  cerr << "Can't symmetrize non-square matrix !" << endl;
575  return;
576  }
577 
578  // no need to look at entries on the diagonal !
579  for(ssize_t i=0;i<a.num_rows();i++)
580  for(ssize_t j=i+1;j<a.num_columns();j++)
581  {
582  f = 0.5 * (a.a_no_check(i,j) + a.a_no_check(j,i));
583  a.a_no_check(i,j) = a.a_no_check(j,i) = f;
584  }
585 }
586 
587 void
589 {
590  v.resize(M.num_rows() * M.num_columns());
591  ssize_t i,j,k=0;
592  for(i=0;i<M.num_rows();i++)
593  for(j=0;j<M.num_columns();j++)
594  v.a_no_check(k++) = M(i,j);
595 }
596 
597 
598 void
599 make_random_matrix(EST_FMatrix &M, const float scale)
600 {
601 
602  float r;
603  for(ssize_t row=0;row<M.num_rows();row++)
604  for(ssize_t col=0;col<M.num_columns();col++)
605  {
606  r = scale * ((double)rand()/(double)RAND_MAX);
607  M.a_no_check(row,col) = r;
608  }
609 }
610 
611 void
612 make_random_vector(EST_FVector &V, const float scale)
613 {
614 
615  float r;
616  for(ssize_t i=0;i<V.length();i++)
617  {
618  r = scale * ((double)rand()/(double)RAND_MAX);
619  V.a_no_check(i) = r;
620  }
621 }
622 
623 void
625 {
626  if(M.num_rows() != M.num_columns())
627  {
628  cerr << "Can't make non-square symmetric matrix !" << endl;
629  return;
630  }
631 
632  float r;
633 
634  for(ssize_t row=0;row<M.num_rows();row++)
635  for(ssize_t col=0;col<=row;col++)
636  {
637  r = scale * ((double)rand()/(double)RAND_MAX);
638  M.a_no_check(row,col) = r;
639  M.a_no_check(col,row) = r;
640  }
641 }
642 
643 void
645 {
646  if(M.num_rows() != M.num_columns())
647  {
648  cerr << "Can't make non-square symmetric matrix !" << endl;
649  return;
650  }
651 
652  M.fill(0.0);
653  for(ssize_t row=0;row<M.num_rows();row++)
654  M.a_no_check(row,row) = scale * ((double)rand()/(double)RAND_MAX);
655 
656 
657 }
658 
659 void
661 {
662  if(t.length() != T.num_rows())
663  {
664  cerr << "Can't make polynomial basis function : dimension mismatch !" << endl;
665  cerr << "t.length()=" << t.length();
666  cerr << " T.num_rows()=" << T.num_rows() << endl;
667  return;
668  }
669  for(ssize_t row=0;row<T.num_rows();row++)
670  for(ssize_t col=0;col<T.num_columns();col++)
671  T.a_no_check(row,col) = pow(t[row],(float)col);
672 
673 }
674 
675 ssize_t
676 floor_matrix(EST_FMatrix &M, const float floor)
677 {
678  ssize_t i,j,k=0;
679  for(i=0;i<M.num_rows();i++)
680  for(j=0;j<M.num_columns();j++)
681  if(M.a_no_check(i,j) < floor)
682  {
683  M.a_no_check(i,j) = floor;
684  k++;
685  }
686  return k;
687 }
688 
690 cov_prod(const EST_FVector &v1,const EST_FVector &v2)
691 {
692  // form matrix of vector product, e.g. for covariance
693  // treat first arg as a column vector and second as a row vector
694 
695  EST_FMatrix m;
696  m.resize(v1.length(),v2.length());
697 
698  for(ssize_t i=0;i<v1.length();i++)
699  for(ssize_t j=0;j<v2.length();j++)
700  m.a_no_check(i,j) = v1.a_no_check(i) * v2.a_no_check(j);
701 
702  return m;
703 }
704 
705 void est_seed()
706 {
707 #if !defined(SYSTEM_IS_WIN32)
708  unsigned int seed;
709  struct timeval tp;
710  struct timezone tzp;
711  gettimeofday(&tp,&tzp);
712  seed = getpid() * (tp.tv_usec&0x7fff);
713  cerr << "seed: " << seed << endl;
714  srand(seed);
715 #else
716  srand(time(NULL));
717 #endif
718 }
719 
720 #if 0
721 void est_seed48()
722 {
723  unsigned short seed;
724  struct timeval tp;
725  struct timezone tzp;
726  gettimeofday(&tp,&tzp);
727  seed = (getpid()&0x7f) * (tp.tv_usec&0xff);
728  cerr << "seed48: " << seed << endl;
729  seed48(&seed);
730 }
731 #endif
EST_FVector subtract(const EST_FVector &a, const EST_FVector &b)
elementwise subtract
Definition: vec_mat_aux.cc:519
int square(const EST_FMatrix &a)
Definition: vec_mat_aux.cc:142
EST_FMatrix diagonalise(const EST_FMatrix &a)
extract leading diagonal as a matrix
Definition: vec_mat_aux.cc:158
ssize_t floor_matrix(EST_FMatrix &M, const float floor)
Definition: vec_mat_aux.cc:676
EST_FMatrix row(const EST_FMatrix &a, ssize_t row)
Definition: vec_mat_aux.cc:210
ssize_t num_columns() const
return number of columns
Definition: EST_TMatrix.h:179
A vector class for floating point numbers. EST_FVector x should be used instead of float *x wherever ...
Definition: EST_FMatrix.h:119
void est_seed()
the user should use est_seed to seed the random number generator
Definition: vec_mat_aux.cc:705
INLINE const T & a_no_check(ssize_t n) const
read-only const access operator: without bounds checking
Definition: EST_TVector.h:254
float polynomial_value(const EST_FVector &coeffs, const float x)
Definition: vec_mat_aux.cc:554
ssize_t num_rows() const
return number of rows
Definition: EST_TMatrix.h:177
EST_FMatrix triangulate(const EST_FMatrix &a)
Definition: vec_mat_aux.cc:232
int ssize_t
const T & a(ssize_t row, ssize_t col) const
Definition: EST_TMatrix.h:196
EST_FMatrix cov_prod(const EST_FVector &v1, const EST_FVector &v2)
matrix product of two vectors (#rows = length of first vector, #cols = length of second vector) ...
Definition: vec_mat_aux.cc:690
bool polynomial_fit(EST_FVector &x, EST_FVector &y, EST_FVector &co_effs, int order)
least squares fit
Definition: vec_mat_aux.cc:49
void make_random_vector(EST_FVector &V, const float scale)
all elements are randomised
Definition: vec_mat_aux.cc:612
void eye(EST_FMatrix &a, const ssize_t n)
some useful matrix creators make an identity matrix of dimension n
Definition: vec_mat_aux.cc:473
void fill(const T &v)
fill matrix with value v
Definition: EST_TMatrix.cc:314
void symmetrize(EST_FMatrix &a)
enforce symmetry
Definition: vec_mat_aux.cc:564
float matrix_max(const EST_FMatrix &a)
find largest element
Definition: vec_mat_aux.cc:129
EST_FVector add(const EST_FVector &a, const EST_FVector &b)
elementwise add
Definition: vec_mat_aux.cc:501
INLINE ssize_t length() const
number of items in vector.
Definition: EST_TVector.h:249
EST_FMatrix sub(const EST_FMatrix &a, ssize_t row, ssize_t col)
Definition: vec_mat_aux.cc:187
void inplace_diagonalise(EST_FMatrix &a)
inplace diagonalise
Definition: vec_mat_aux.cc:176
EST_FVector diagonal(const EST_FMatrix &a)
extract leading diagonal as a vector
Definition: vec_mat_aux.cc:537
void make_poly_basis_function(EST_FMatrix &T, EST_FVector t)
Definition: vec_mat_aux.cc:660
#define RAND_MAX
Definition: EST_math.h:151
void multiply(const EST_DMatrix &a, const EST_DMatrix &b, EST_DMatrix &ab)
Definition: EST_DMatrix.cc:293
#define FALSE
Definition: EST_bool.h:119
float time(const EST_Item &item)
Definition: EST_item_aux.cc:82
int pseudo_inverse(const EST_FMatrix &a, EST_FMatrix &inv)
pseudo inverse (for non-square matrices)
Definition: vec_mat_aux.cc:405
NULL
Definition: EST_WFST.cc:55
void make_random_symmetric_matrix(EST_FMatrix &M, const float scale)
used for covariance
Definition: vec_mat_aux.cc:624
f
Definition: EST_item_aux.cc:48
void transpose(const EST_FMatrix &a, EST_FMatrix &b)
exchange rows and columns
Definition: vec_mat_aux.cc:244
getString int
Definition: EST_item_aux.cc:50
EST_FMatrix column(const EST_FMatrix &a, ssize_t col)
Definition: vec_mat_aux.cc:221
EST_FMatrix fmatrix_abs(const EST_FMatrix &a)
Definition: vec_mat_aux.cc:270
void make_random_diagonal_matrix(EST_FMatrix &M, const float scale)
used for variance
Definition: vec_mat_aux.cc:644
INLINE const T & a_no_check(ssize_t row, ssize_t col) const
const access with no bounds check, care recommend
Definition: EST_TMatrix.h:182
void resize(int rows, int cols, int set=1)
resize matrix
float determinant(const EST_FMatrix &a)
Definition: vec_mat_aux.cc:436
float sum(const EST_FMatrix &a)
sum of elements
Definition: vec_mat_aux.cc:147
#define TRUE
Definition: EST_bool.h:118
INLINE ssize_t n() const
number of items in vector.
Definition: EST_TVector.h:251
void make_random_matrix(EST_FMatrix &M, const float scale)
all elements are randomised
Definition: vec_mat_aux.cc:599
EST_FMatrix backwards(EST_FMatrix &a)
Definition: vec_mat_aux.cc:254
int inverse(const EST_FMatrix &a, EST_FMatrix &inv)
inverse
Definition: vec_mat_aux.cc:298
void resize(int n, int set=1)
resize vector
void stack_matrix(const EST_FMatrix &M, EST_FVector &v)
stack columns on top of each other to make a vector
Definition: vec_mat_aux.cc:588
void est_seed48()