12 std::cout << v <<
"\n";
20 for (
int i = 0; i <
lenth; i++)
ets[i]= *(abd +i);
25 for (
int i = 0; i <
lenth; i++)
ets[i] = a;
30 for (
int i = 0; i <
lenth; i++)
ets[i] = v[i];
40 for (
int i = 0; i <
lenth; i++)
ets[i] = v[i];
47 for (
int i = 0; i <
lenth; i++)
ets[i] += v[i];
53 for (
int i = 0; i <
lenth; i++)
ets[i] -= v[i];
80 for (
int i =0; i < v.
lenth; i++ ) {
82 if (i%10 == 9) s <<
"\n";
88 double norm = std::abs(
ets[0]);
89 for (
int i = 1; i <
lenth; i++) {
90 double vi = std::abs(
ets[i]);
91 if (norm < 100) norm = std::sqrt(norm*norm + vi*vi);
94 norm *= std::sqrt(1.0 + tm*tm);
101 double norm = std::abs(
ets[0]);
102 for (
int i = 1; i <
lenth; i++)
103 if (norm < std::abs(
ets[i])) norm = std::abs(
ets[i]);
109 for (
int i = 0; i < v.
lenth; i++) tm[i] = scalar*v[i];
117 for (
int i = 0; i < sz; i++)
123 if (scalar == 0)
error(
"division by zero in vector-scalar division");
124 return (1.0/scalar)*v;
130 double tm = v1[0]*v2[0];
131 for (
int i = 1; i < sz; i++) tm += v1[i]*v2[i];
141 for (
int i = 0; i <
nrows; i++) {
143 for (
int j = 0; j <
ncols; j++)
ets[i][j] = dbp[i][j];
149 for (
int i = 0; i<
nrows; i++) {
151 for (
int j = 0; j <
ncols; j++)
ets[i][j] = a;
157 for (
int i = 0; i<
nrows; i++) {
159 for (
int j = 0; j <
ncols; j++)
ets[i][j] = mat[i][j];
164 for (
int i = 0; i<
nrows; i++)
delete[]
ets[i];
171 for (
int i = 0; i <
nrows; i++)
172 for (
int j = 0; j <
ncols; j++)
ets[i][j] = mat[i][j];
179 for (
int i = 0; i <
nrows; i++)
180 for (
int j = 0; j <
ncols; j++)
ets[i][j] += mat[i][j];
186 for (
int i = 0; i <
nrows; i++)
187 for (
int j = 0; j <
ncols; j++)
ets[i][j] -= mat[i][j];
207 error(
"Mtx::op*(Vtr): Error: Mat. and vec. sizes do not match.");
209 for (
int i = 0; i <
nrows; i++)
210 for (
int j = 0; j <
ncols; j++) tm[i] +=
ets[i][j]*v[j];
217 error(
"op*(Vtr, Mtx): Error: Mat. and vec. size do no match.");
219 for (
int i=0; i<mat.
ncols; i++)
220 for (
int j=0; j<v.
lenth; j++)
221 res[i] = v.
ets[j] * mat.
ets[j][i];
228 error(
"bad matrix sizes");
238 error(
"Mtx::getcol(): Bad vector size.");
239 for (
int i = 0; i <
nrows; i++)
246 error(
"Mtx::getcol(): Bad vector size.");
247 for (
int i = 0; i <
nrows; i++)
253 for (
int i = 0; i <
nrows; i++)
254 for (
int j = 0; j <
ncols; j++)
261 std::cerr <<
"Mtx::transpose(): Error: Matrix dim."
266 for (
int i=0; i<
nrows; i++)
267 for (
int j=0; j<
ncols; j++)
268 dest(j, i) =
ets[i][j];
274 for (
int i = 0; i < mat.
rows(); i++) {
276 for(
int j = 0; j < mat.
cols(); j++) {
277 s.setf(std::ios_base::fixed, std::ios_base::floatfield);
282 s <<
" |" << std::endl;
292 error(
"Mtx::op*=: Bad matrix sizes.");
294 for (
int i = 0; i <
nrows; i++)
295 for (
int j = 0; j < mat.
ncols; j++)
296 for (
int k = 0; k <
ncols; k++)
297 tmp(i,j) +=
ets[i][k] * mat.
ets[k][j];
306 std::cerr <<
"Mtx::QRdecomp(): Error: Bad matrix size.";
316 tmp =
new double* [tmprows];
317 for (
int i=0; i<tmprows; i++) {
318 tmp[i] =
new double [tmpcols];
319 for (
int j=0; j<tmpcols; j++)
320 tmp[i][j] =
ets[j][i];
322 Mat_DP QT(tmprows,tmpcols);
326 for (
int i=0; i<tmprows; i++) {
328 for (
int k=0; k<tmpcols; k++)
329 norm += tmp[i][k]*tmp[i][k];
330 norm = std::sqrt(norm);
332 for (
int k=0; k<tmpcols; k++)
333 QT.
ets[i][k] = tmp[i][k] / norm;
335 for (
int j=i+1; j<tmprows; j++) {
337 for (
int k=0; k<tmpcols; k++)
338 dot += QT.
ets[i][k]*tmp[j][k];
340 for (
int k=0; k<tmpcols; k++)
341 tmp[j][k] = tmp[j][k] - dot*QT.
ets[i][k];
347 for (
int i=0; i<tmprows; i++)
356 std::cerr <<
"Mtx::QRdecomp(): Error: Bad matrix size.";
363 tmp =
new double* [
nrows];
364 for (
int i=0; i<
nrows; i++) {
365 tmp[i] =
new double [
ncols];
366 for (
int j=0; j<
ncols; j++)
367 tmp[i][j] =
ets[i][j];
372 for (
int i=0; i<
ncols; i++) {
374 for (
int k=0; k<
nrows; k++)
375 norm += tmp[k][i]*tmp[k][i];
376 norm = std::sqrt(norm);
378 for (
int k=0; k<
nrows; k++)
379 Q.
ets[k][i] = tmp[k][i] / norm;
381 for (
int j=i+1; j<
ncols; j++) {
383 for (
int k=0; k<
nrows; k++)
384 dot += Q.
ets[k][i]*tmp[k][j];
386 for (
int k=0; k<
nrows; k++)
387 tmp[k][j] = tmp[k][j] - dot*Q.
ets[k][i];
391 for (
int i=0; i<
nrows; i++)