Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/formulamatrix.cc
[mareframe] / trunk / gadget / formulamatrix.cc Repository:
ViewVC logotype

Annotation of /trunk/gadget/formulamatrix.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #include "formulamatrix.h"
2 :     #include "gadget.h"
3 :    
4 :     FormulaMatrix::FormulaMatrix(int nr, int nc, Formula initial) {
5 :     int i;
6 :     nrow = nr;
7 :     if (nrow > 0) {
8 :     v = new FormulaVector*[nr];
9 :     for (i = 0; i < nr; i++)
10 :     v[i] = new FormulaVector(nc, initial);
11 :     } else
12 :     v = 0;
13 :     }
14 :    
15 :     FormulaMatrix::FormulaMatrix(int nr, int nc, double initial) {
16 :     int i;
17 :     nrow = nr;
18 :     if (nrow > 0) {
19 :     v = new FormulaVector*[nr];
20 :     for (i = 0; i < nr; i++)
21 :     v[i] = new FormulaVector(nc, initial);
22 :     } else
23 :     v = 0;
24 :     }
25 :    
26 :     FormulaMatrix::~FormulaMatrix() {
27 :     int i;
28 :     if (v != 0) {
29 :     for (i = 0; i < nrow; i++)
30 :     delete v[i];
31 :     delete[] v;
32 :     }
33 :     }
34 :    
35 :     void FormulaMatrix::AddRows(int add, int length, Formula value) {
36 :     if (add <= 0)
37 :     return;
38 :    
39 :     int i;
40 :     if (v == 0) {
41 :     nrow = add;
42 :     v = new FormulaVector*[nrow];
43 :     for (i = 0; i < nrow; i++)
44 :     v[i] = new FormulaVector(length, value);
45 :     } else {
46 :     FormulaVector** vnew = new FormulaVector*[add + nrow];
47 :     for (i = 0; i < nrow; i++)
48 :     vnew[i] = v[i];
49 :     for (i = nrow; i < nrow + add; i++)
50 :     vnew[i] = new FormulaVector(length, value);
51 :     delete[] v;
52 :     v = vnew;
53 :     nrow += add;
54 :     }
55 :     }
56 :    
57 :     void FormulaMatrix::AddRows(int add, int length, double value) {
58 :     if (add <= 0)
59 :     return;
60 :    
61 :     int i;
62 :     if (v == 0) {
63 :     nrow = add;
64 :     v = new FormulaVector*[nrow];
65 :     for (i = 0; i < nrow; i++)
66 :     v[i] = new FormulaVector(length, value);
67 :     } else {
68 :     FormulaVector** vnew = new FormulaVector*[add + nrow];
69 :     for (i = 0; i < nrow; i++)
70 :     vnew[i] = v[i];
71 :     for (i = nrow; i < nrow + add; i++)
72 :     vnew[i] = new FormulaVector(length, value);
73 :     delete[] v;
74 :     v = vnew;
75 :     nrow += add;
76 :     }
77 :     }
78 :    
79 :     void FormulaMatrix::Inform(Keeper* keeper) {
80 :     int i;
81 :     for (i = 0; i < nrow; i++)
82 :     v[i]->Inform(keeper);
83 :     }

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge