LINEAR++ library: AFF to LAPACK

◆ main()

int main ( int  iargc,
char *  argv[] 
)

Definition at line 113 of file lapacktest.cc.

References DUMP, LAPACKTEST_VERSION, Options::nsize, test(), and Options::verbose.

114 {
115 
116  // define usage information
117  char usage_text[]=
118  {
119  LAPACKTEST_VERSION "\n"
120  "usage: lapacktest [-n n]" "\n"
121  " or: lapacktest --help|-h" "\n"
122  };
123 
124  // define full help text
125  char help_text[]=
126  {
127  "\n"
128  "-v be verbose" "\n"
129  "-n N test system of size NxN" "\n"
130  };
131 
132  // define commandline options
133  using namespace tfxx::cmdline;
134  static Declare options[]=
135  {
136  // 0: print help
137  {"help",arg_no,"-"},
138  // 1: verbose mode
139  {"v",arg_no,"-"},
140  // 2: verbose mode
141  {"n",arg_yes,"3"},
142  {NULL}
143  };
144 
145  // no arguments? print usage...
146  if (iargc<2)
147  {
148  cerr << usage_text << endl;
149  exit(0);
150  }
151 
152  // collect options from commandline
153  Commandline cmdline(iargc, argv, options);
154 
155  // help requested? print full help text...
156  if (cmdline.optset(0))
157  {
158  cerr << usage_text << endl;
159  cerr << help_text << endl;
160  exit(0);
161  }
162 
163  /*
164  // dummy operation: print option settings
165  for (int iopt=0; iopt<2; iopt++)
166  {
167  cout << "option: '" << options[iopt].opt_string << "'" << endl;
168  if (cmdline.optset(iopt)) { cout << " option was set"; }
169  else { cout << "option was not set"; }
170  cout << endl;
171  cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
172  cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
173  cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
174  cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
175  cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
176  cout << " argument (bool): '";
177  if (cmdline.bool_arg(iopt))
178  { cout << "true"; } else { cout << "false"; }
179  cout << "'" << endl;
180  }
181  while (cmdline.extra()) { cout << cmdline.next() << endl; }
182 
183  // dummy operation: print rest of command line
184  while (cmdline.extra()) { cout << cmdline.next() << endl; }
185  */
186 
187  Options opt;
188  opt.verbose=cmdline.optset(1);
189  opt.nsize=cmdline.int_arg(2);
190 
191  /*----------------------------------------------------------------------*/
192 
193  {
194 
195  if (opt.verbose)
196  {
197  cout << "Define system of size " << opt.nsize << "x" << opt.nsize << endl;
198  }
199 
200  Tmatrix M(opt.nsize,opt.nsize);
201  Tmatrix R(opt.nsize,1);
202 
203  // set up random number generator
204  tfxx::numeric::RNGgaussian rng;
205 
206  {
207  // set up system matrix
208  aff::Iterator<Tmatrix> I(M);
209  while (I.valid())
210  {
211  *I = rng();
212  ++I;
213  }
214  }
215 
216  {
217  // set up system vector
218  aff::Iterator<Tmatrix> I(R);
219  while (I.valid())
220  {
221  *I = rng();
222  ++I;
223  }
224  }
225  test(M,R);
226  }
227 
228  /*----------------------------------------------------------------------*/
229 
230  {
231  Tmatrix M(3,3), V(3,1), W(3,2);
232  M(1,1)=1.;
233  M(1,2)=0.4;
234  M(1,3)=0.6;
235  M(2,1)=-0.2;
236  M(2,2)=-1.;
237  M(2,3)=0.7;
238  M(3,1)=-1.;
239  M(3,2)=-0.3;
240  M(3,3)=1.;
241  DUMP(M);
242  V(1)=-80.;
243  V(2)=70.;
244  V(3)=-35.;
245  DUMP(V);
246  test(M,V);
247  W(1,1)=-80.;
248  W(2,1)=70.;
249  W(3,1)=-35.;
250  W(1,2)=0.;
251  W(2,2)=2.;
252  W(3,2)=-3.;
253  DUMP(W);
254  test(M,W);
255  }
256 }
linear::TDmatrix Tmatrix
Definition: lsqexample.cc:56
#define DUMP(M)
Definition: lapacktest.cc:84
#define LAPACKTEST_VERSION
Definition: lapacktest.cc:36
int nsize
Definition: lapacktest.cc:53
bool verbose
Definition: lapacktest.cc:52
void test(const Tmatrix::Tcoc &M, const Tmatrix::Tcoc V)
Definition: lapacktest.cc:89
Here is the call graph for this function: