1 /*
2  *_________________________________________________________________________*
3  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
4  *      DESCRIPTION: SEE READ-ME                                           *
5  *      FILE NAME: virtualmatrix.h                                              *
6  *      AUTHORS: See Author List                                           *
7  *      GRANTS: See Grants List                                            *
8  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
9  *      LICENSE: Please see License Agreement                              *
10  *      DOWNLOAD: Free at www.rpi.edu/~anderk5                             *
11  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
12  *                     Computational Dynamics Lab                          *
13  *                     Rensselaer Polytechnic Institute                    *
14  *                     110 8th St. Troy NY 12180                           *
15  *      CONTACT:        anderk5@rpi.edu                                    *
16  *_________________________________________________________________________*/
17 
18 
19 #ifndef VIRTUALMATRIX_H
20 #define VIRTUALMATRIX_H
21 #include <iostream>
22 
23 enum MatrixType {
24 	MATRIX = 0,
25 	COLMATRIX = 1,
26 	ROWMATRIX = 2,
27 	MAT3X3 = 3,
28 	VECT3 = 4,
29 	MAT6X6 = 5,
30 	VECT6 = 6,
31 	COLMATMAP = 7,
32 	VECT4 = 8,
33 	MAT4X4 = 9
34 };
35 
36 class VirtualMatrix {
37 protected:
38 	int numrows, numcols;
39 public:
40 	VirtualMatrix();
41 	virtual ~VirtualMatrix();
42 	int GetNumRows() const;
43 	int GetNumCols() const;
44 
45 	double& operator() (int i, int j); // array access
46 	double Get(int i, int j) const;
47 	void Set(int i, int j, double value);
48 	double BasicGet(int i, int j) const;
49 	void BasicSet(int i, int j, double value);
50 	void BasicIncrement(int i, int j, double value);
51 
52 	double& operator() (int i); // array access
53 	double Get(int i) const;
54 	void Set(int i, double value);
55 	double BasicGet(int i) const;
56 	void BasicSet(int i, double value);
57 	void BasicIncrement(int i, double value);
58 
59 	virtual void Const(double value) = 0;
60 	virtual MatrixType GetType() const = 0;
61 	virtual void AssignVM(const VirtualMatrix& A) = 0;
62 	void Zeros();
63 	void Ones();
64 	virtual std::ostream& WriteData(std::ostream& c) const;
65 	virtual std::istream& ReadData(std::istream& c);
66 
67 protected:
68 	virtual double& operator_2int(int i, int j) = 0;
69 	virtual double& operator_1int(int i);
70 	virtual double Get_2int(int i, int j) const = 0;
71 	virtual double Get_1int(int i) const ;
72 	virtual void Set_2int(int i, int j, double value) = 0;
73 	virtual void Set_1int(int i, double value);
74 	virtual double BasicGet_2int(int i, int j) const = 0;
75 	virtual double BasicGet_1int(int i) const ;
76 	virtual void BasicSet_2int(int i, int j, double value) = 0;
77 	virtual void BasicSet_1int(int i, double value);
78 	virtual void BasicIncrement_2int(int i, int j, double value) = 0;
79 	virtual void BasicIncrement_1int(int i, double value);
80 
81 };
82 
83 // overloaded operators
84 std::ostream& operator<< (std::ostream& c, const VirtualMatrix& A); // output
85 std::istream& operator>> (std::istream& c, VirtualMatrix& A); // input
86 
87 #endif
88