[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #32502] cov function returns incorrect results
From: |
Ivan |
Subject: |
[Octave-bug-tracker] [bug #32502] cov function returns incorrect results for complex matrices |
Date: |
Wed, 16 Feb 2011 19:19:42 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.98 Safari/534.13 |
Follow-up Comment #2, bug #32502 (project octave):
Here goes octave:
A_r = load("-ascii", "real_input.ascii");
A_i = load("-ascii", "imag_input.ascii");
A = complex(A_r, A_i);
imag(A)
ans =
-0.00000 -0.25112 0.16022 -0.44749 -0.06819 0.23258 -0.05861
-0.06876
0.25112 -0.00000 -0.07418 -0.05551 0.11349 0.01903 0.15368
-0.09032
-0.16022 0.07418 -0.00000 0.28853 -0.07469 -0.16844 0.18365
0.02444
0.44749 0.05551 -0.28853 -0.00000 0.12424 0.04581 -0.23836
0.10005
0.06819 -0.11349 0.07469 -0.12424 -0.00000 0.03534 -0.20799
0.32262
-0.23258 -0.01903 0.16844 -0.04581 -0.03534 -0.00000 -0.34949
0.11833
0.05861 -0.15368 -0.18365 0.23836 0.20799 0.34949 -0.00000
0.15882
0.06876 0.09032 -0.02444 -0.10005 -0.32262 -0.11833 -0.15882
-0.00000
Since matlab is prohibited (and actually I don't have access to it right now),
a C++ code snippet, doing the same (it uses armadillo
<http://arma.sourceforge.net/> library):
#include <armadillo>
#include <iostream>
int main() {
using namespace arma;
mat real_input, imag_input;
real_input.load("data/real_input.ascii", raw_ascii);
imag_input.load("data/imag_input.ascii", raw_ascii);
cx_mat input(real_input, imag_input);
std::cout << imag(cov(input)) << "n";
}
$ g++ test.cc -I../../../contrib -llapack -lblas
$ ./a.out
0 0.2511 -0.1602 0.4475 0.0682 -0.2326 0.0586 0.0688
-0.2511 0 0.0742 0.0555 -0.1135 -0.0190 -0.1537 0.0903
0.1602 -0.0742 0 -0.2885 0.0747 0.1684 -0.1837 -0.0244
-0.4475 -0.0555 0.2885 0 -0.1242 -0.0458 0.2384 -0.1000
-0.0682 0.1135 -0.0747 0.1242 0 -0.0353 0.2080 -0.3226
0.2326 0.0190 -0.1684 0.0458 0.0353 0 0.3495 -0.1183
-0.0586 0.1537 0.1837 -0.2384 -0.2080 -0.3495 0 -0.1588
-0.0688 -0.0903 0.0244 0.1000 0.3226 0.1183 0.1588 0
As you can see this matrix are complex conjugates of each other. Matlab yield
the same result, btw.
(file #22704, file #22705)
_______________________________________________________
Additional Item Attachment:
File name: real_input.ascii Size:1 KB
File name: imag_input.ascii Size:1 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?32502>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/