fabs problem on matrix variable

S

sandwich_eater

Using MSVC++ I get error C2665:
'fabs' : none of the 3 overloads can convert parameter 1 from type
'std::allocator<_Ty>::value_type'
with
[
_Ty=std::vector<double>
]

on code containing the following extract.

void func(std::vector<std::vector<double> > *a ...

double s ...

scale = scale + fabs(a[k]);
 
I

Ian Malone

Using MSVC++ I get error C2665:
'fabs' : none of the 3 overloads can convert parameter 1 from type
'std::allocator<_Ty>::value_type'
with
[
_Ty=std::vector<double>
]

on code containing the following extract.

void func(std::vector<std::vector<double> > *a ...

double s ...

scale = scale + fabs(a[k]);


I assume scale/s is a typo.
You're passing a pointer to a vector of vectors and treating
it as a vector of vectors. Dereference it first (*a)[k],
or pass a reference: void func(std::vector<std::vector<double>> &a)
 
R

red floyd

Using MSVC++ I get error C2665:
'fabs' : none of the 3 overloads can convert parameter 1 from type
'std::allocator<_Ty>::value_type'
with
[
_Ty=std::vector<double>
]

on code containing the following extract.

void func(std::vector<std::vector<double> > *a ...

double s ...

scale = scale + fabs(a[k]);


Because a is a pointer to a vector of vectors of double. Hence, a[k]
does not resolve to a double

try the following declaration:

void func(std::vector<std::vector<double> > &a)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,498
Latest member
log5Sshell/alfa5

Latest Threads

Top