By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,915 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,915 IT Pros & Developers. It's quick & easy.

fabs problem on matrix variable

P: n/a
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]);

Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
sa************@hotmail.com wrote:
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]);


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][i],
or pass a reference: void func(std::vector<std::vector<double>> &a)

--
imalone
Jul 23 '05 #2

P: n/a
sa************@hotmail.com wrote:
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]);


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

try the following declaration:

void func(std::vector<std::vector<double> > &a)
Jul 23 '05 #3

P: n/a
Ian Malone wrote:
or pass a reference: void func(std::vector<std::vector<double>> &a)


Sorry inner declaration <std::vector<double> >
not <std::vector<double>>

--
imalone
Jul 23 '05 #4

P: n/a
That is an easier solution.

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.