I have a Mat_<long double>
matrix. I need long double
to perform multiplication of large matrices (10x4096 both). But the problem is that passing to function in such way: func(Mat first)
makes the size of element in function 8 bytes though I need 16. But func(Mat_<long double> first)
causes undefined reference to function by linker. So the question is how can I pass Mat_<long double>
to function?
Asked
Active
Viewed 59 times
0

Tehada
- 491
- 1
- 6
- 11
-
are you sure that `long double` is 16 bytes? – Miki Mar 29 '17 at 18:07
-
I beg to differ @tobi303 . It is far less comprehensible after even a single pass of ROT13. Strangely a second pass seems to recover... I wonder how that happened. – user4581301 Mar 29 '17 at 18:08
-
@Tehada: check sizeof(long double) to know how many bits it is on your implementation. It's not a standard size. – Jason Lang Mar 29 '17 at 18:12
-
@JasonLang I already solved! The problem that I forgot to fix prototype of function! – Tehada Mar 29 '17 at 18:14
1 Answers
2
You need to change the prototype of the function to pass diferent parameter type:
Prototype:
func(Mat_<long double> first);
Definition:
func(Mat_<long double> first)
{
..
}
Usage:
Mat_<long double> example;
func(example);
Notes:
Be careful with the use of
long double
, isn't very portable, as different compilers treat it differentlyAlso consider to pass by reference (
Mat_<long double> &
) instead of by val for performance reasons, when you use a big matrix.
-
-
long double isn't very portable however, as different compilers treat it differently. – Jason Lang Mar 29 '17 at 18:18
-