non-class type ‘ *(double*)

Hi guys, i have this code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86


#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
#include<cmath>
#include<sstream>

using namespace std;
string convertDoub(double number);

typedef struct CMAT{double el[9]; } cmat;
inline void matrixProd(cmat *am(double el[]), cmat *bm(double el[]), cmat *cm(double el[]));

//inline void matrixProd(cmat *am, cmat *bm, cmat *cm);
void amatrix(ifstream *rf, int frames, int residues, ofstream *amat)
{
double a[3][3], d[3][3], c[3][3], r[3][3], p[3][3];

//typedef struct CMAT{double xx; double xy; double xz; double yx; double yy; double yz; double zx; double zy; double zz} cmat;


cmat cm[residues];

cmat pm[residues];

string s;

		c[0][0] = 1;
		c[0][1] = 0;
		c[0][2] = 0;

		c[1][0] = 0;
		c[1][1] = 1;
		c[1][2] = 0;

		c[2][0] = 0;
		c[2][1] = 0;
		c[2][2] = 1;

		for(int resid = 0; resid < residues; resid++)
		{

		rf[0] >> cm[resid].el[0] >> cm[resid].el[1] >> cm[resid].el[2];
		rf[0] >> cm[resid].el[3] >> cm[resid].el[4] >> cm[resid].el[5];
		rf[0] >> cm[resid].el[6] >> cm[resid].el[7] >> cm[resid].el[8];	
 
		rf[0] >> pm[resid].el[0] >> pm[resid].el[1] >> pm[resid].el[2];
		rf[0] >> pm[resid].el[3] >> pm[resid].el[4] >> pm[resid].el[5];
		rf[0] >> pm[resid].el[6] >> pm[resid].el[7] >> pm[resid].el[8];     	

		}
	}
}

string convertDoub(double number)
{
   stringstream ss;     //create a stringstream
   ss << number;        //add number to the stream
   return (ss.str());   //return a string with the contents of the stream
}
inline void matrixProd(cmat *am(double el[]), cmat *bm(double el[]), cmat *cm(double el[]))
//inline void matrixProd(cmat *am, cmat *bm, cmat *cm)
{
double sum;
	
	for(int i = 0; i < 3 ; i++)
	{
		for(int k = 0; k < 3; k++)
		{
			sum = 0.0;

			for(int j = 0; j < 3 ; j++)
			{
				sum  = sum + am->el[0][3*i+j] * bm->el[0][3*j+k];
			}
			cm->el[0][3*i+k] = sum;
		}
	}
	
}




i have this error compiling


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15




amatrix.h:186: error: request for member ‘el’ in ‘* am’, which is of non-class type ‘cmat*(double*)’
amatrix.h:186: error: request for member ‘el’ in ‘* bm’, which is of non-class type ‘cmat*(double*)’
amatrix.h:188: error: request for member ‘el’ in ‘* cm’, which is of non-class type ‘cmat*(double*)’










any suggestion?
What were you thinking when you wrote cmat *am(double el[])?
Argument declarations are mostly of form "Type Name". Here Type is cmat* and Name is am, bm or cm. Where did the parentheses come from?
the object cmat contains a double called em , that is..double el[9].

I was trying to crate a poiter to this type of object but I'm not really sure to how recall it in gunction matProd, since I have to operate on the elements contained in cmat..
You declared that with the CMAT struct. Now it is just cmat* am. You could also write CMAT* am - that typedef doesn't do anything useful here. The tradition of wraping things in a typedef comes from C, where you'd have to write struct CMAT* am if you didn't.

Another thing I just noticed. cm->el is an array of 9 doubles, but you use it as if it was a 2d array.
Last edited on
Topic archived. No new replies allowed.