Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
matrix_regression.cc
1  /*************************************************************************/
2  /* */
3  /* Centre for Speech Technology Research */
4  /* University of Edinburgh, UK */
5  /* Copyright (c) 1996,1997 */
6  /* All Rights Reserved. */
7  /* Permission is hereby granted, free of charge, to use and distribute */
8  /* this software and its documentation without restriction, including */
9  /* without limitation the rights to use, copy, modify, merge, publish, */
10  /* distribute, sublicense, and/or sell copies of this work, and to */
11  /* permit persons to whom this work is furnished to do so, subject to */
12  /* the following conditions: */
13  /* 1. The code must retain the above copyright notice, this list of */
14  /* conditions and the following disclaimer. */
15  /* 2. Any modifications must be clearly marked as such. */
16  /* 3. Original authors' names are not deleted. */
17  /* 4. The authors' names are not used to endorse or promote products */
18  /* derived from this software without specific prior written */
19  /* permission. */
20  /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
21  /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
22  /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
23  /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
24  /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
25  /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
26  /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
27  /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
28  /* THIS SOFTWARE. */
29  /* */
30  /*************************************************************************/
31  /* */
32  /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
33  /* Date: Tue Jul 22 1997 */
34  /* --------------------------------------------------------------------- */
35  /* Example of matrix class use. */
36  /* */
37  /*************************************************************************/
38 
39 #include <cstdlib>
40 #include <iostream>
41 #include "EST_TMatrix.h"
42 #include "EST_String.h"
43 
44 
45 /**@name matrix_example
46  *
47  * some stuff about matrices
48  *
49  * @see EST_TMatrix
50  */
51 //@{
52 
53 int main(void)
54 {
55  EST_TMatrix<int> m(5,5);
56 
57  cout << "EST_TVector<int> size = " << sizeof(EST_TVector<int>) << " bytes.\n";
58  cout << "EST_TMatrix<int> size = " << sizeof(EST_TMatrix<int>) << " bytes.\n";
59 
60  for(int i=0; i<m.num_rows(); i++)
61  for(int j=0; j<m.num_columns(); j++)
62  m.a(i,j) = i*100+j;
63 
64  cout << "Initial Matrix\n";
65  m.save("-");
66  cout << "\n";
67 
68  m.resize(m.num_rows(), m.num_columns());
69 
70  cout << "Same Sized Matrix\n";
71  m.save("-");
72  cout << "\n";
73 
74  m.resize(m.num_rows()*2, m.num_columns()*2);
75 
76  cout << "Double Sized Matrix\n";
77  m.save("-");
78  cout << "\n";
79 
80  for(int i2=0; i2<m.num_rows(); i2++)
81  for(int j2=0; j2<m.num_columns(); j2++)
82  m.a(i2,j2) = i2*1000+j2;
83 
84  cout << "Reset Matrix\n";
85  m.save("-");
86  cout << "\n";
87 
88  m.resize(m.num_rows()/2, m.num_columns()/2);
89 
90  cout << "Half Sized Matrix\n";
91  m.save("-");
92  cout << "\n";
93 
94  EST_TVector<int> v(5);
95 
96  for(int i7=0; i7<v.num_columns(); i7++)
97  v[i7] = i7;
98 
99  cout << v << "\n";
100 
101  v.resize(5);
102 
103  cout << v << "\n";
104 
105  v.resize(10);
106 
107  cout << v << "\n";
108 
109  for(int i8=0; i8<v.num_columns(); i8++)
110  v[i8] = 500 + i8;
111 
112  cout << v << "\n";
113 
114  v.resize(5, 0);
115 
116  return(0);
117 }
118 
119 //@}
120