提问人:Frank Allen 提问时间:7/24/2023 最后编辑:Frank Allen 更新时间:7/25/2023 访问量:49
Matlab mldivide 和 arrayfire 求解
Matlab mldivide and arrayfire solve
问:
我正在尝试使用 arrayfire 将一些 Matlab 代码移植到 c++。在一个地方,Matlab代码是这样的: tmp = (R\v0); 其中 R 是 9x9 复数双精度值,v0 是 9x1 复数双精度值。 在我的 ArrayFire 中,编写的代码如下: af::array tmp = af::solve(R, v0_ndx, AF_MAT_NONE);v0-ndx 是 Arrayfire 案例中的 141 个条目之一。 在这两种情况下,R 数组都是:
(1.0000,0.0000) (0.4330,0.5572) (-0.4989,0.3674) (0.6645,-0.1705) (-0.5022,-0.3560) (0.0136,-0.5150) (0.4447,0.2106) (-0.5152,0.1762) (0.7409,0.2369)
(0.4330,-0.5572) (1.0000,0.0000) (0.2444,0.6848) (0.3885,-0.7665) (-0.5994,0.3623) (-0.4474,-0.4617) (0.5153,-0.2913) (-0.1954,0.6379) (0.7954,-0.4984)
(-0.4989,-0.3674) (0.2444,-0.6848) (1.0000,0.0000) (-0.4839,-0.1905) (0.4046,0.7260) (-0.2262,0.3428) (-0.1181,-0.5652) (0.6709,0.2600) (-0.1537,-0.6409)
(0.6645,0.1705) (0.3885,0.7665) (-0.4839,0.1905) (1.0000,0.0000) (-0.4047,-0.5696) (0.3418,-0.7446) (0.2774,0.3234) (-0.6889,-0.1392) (0.7275,0.4112)
(-0.5022,0.3560) (-0.5994,-0.3623) (0.4046,-0.7260) (-0.4047,0.5696) (1.0000,0.0000) (0.3853,0.5248) (-0.5786,0.0954) (0.5647,-0.4580) (-0.6453,0.0559)
(0.0136,0.5150) (-0.4474,0.4617) (-0.2262,-0.3428) (0.3418,0.7446) (0.3853,-0.5248) (1.0000,0.0000) (-0.2308,0.1934) (-0.0831,-0.7353) (-0.1197,0.6637)
(0.4447,-0.2106) (0.5153,0.2913) (-0.1181,0.5652) (0.2774,-0.3234) (-0.5786,-0.0954) (-0.2308,-0.1934) (1.0000,0.0000) (-0.0868,0.3612) (0.5367,-0.0571)
(-0.5152,-0.1762) (-0.1954,-0.6379) (0.6709,-0.2600) (-0.6889,0.1392) (0.5647,0.4580) (-0.0831,0.7353) (-0.0868,-0.3612) (1.0000,0.0000) (-0.4853,-0.3956)
(0.7409,-0.2369) (0.7954,0.4984) (-0.1537,0.6409) (0.7275,-0.4112) (-0.6453,-0.0559) (-0.1197,-0.6637) (0.5367,0.0571) (-0.4853,0.3956) (1.0000,0.0000)
v0 或 (v0_ndx) 数组为:
(1.0000,0.0000)
(0.8827,0.4699)
(0.1784,-0.9840)
(-0.9616,0.2745)
(-0.5396,0.8419)
(0.9908,-0.1353)
(-0.5675,-0.8234)
(0.8795,-0.4758)
(0.9408,0.3389)
Matlab leftdivide 返回
6.83220363990185 - 10.9619257689701i
40.3356738405241 + 25.0998371535142i
4.83385229841040 - 37.2045139160788i
-44.4504672789456 + 4.68752510309329i
-18.7242610414281 + 10.0126185742854i
13.2133070644273 - 1.29385372118540i
-2.14180173734413 + 12.1355411649223i
-4.16564154531280 - 6.04196278680202i
-2.43069655994337 + 6.59335067976014i
arrayfire 求解返回(使用 AF_MAT_NONE 参数;AF_MAT_LOWER 和 AF_MAT_UPPER 产生更差的结果)
(6.1867,-9.3346)
(31.5626,-5.3650)
(16.7719,-11.4021)
(-31.0820,-10.4292)
(-20.8629,35.2594)
(3.3563,-6.7437)
(-21.9321,-8.4480)
(3.5929,5.8619)
(-2.2422,9.7816)
答: 暂无答案
评论