简体   繁体   English

xtensor-blas 计算不正确

[英]xtensor-blas incorrect computation

I'm trying to use xtensor-blas for the first time.我第一次尝试使用 xtensor-blas。 I've had lots of difficulties linking to it, but finally, I've done that and tried to run the sample programs .我在链接到它时遇到了很多困难,但最后,我做到了,并尝试运行示例程序 However, as the output, I get 0 for the first and 0, -inf for the second.但是,作为 output,我得到第一个为0 0, -inf

I'm using Windows 10 x64 , Clion 2021.1我正在使用Windows 10 x64Clion 2021.1
Installed cmake 3.19.7 , xtensor 0.23.4 , xtensor-blas 0.19.0 , openblas 0.3.13 , lapack 3.6.1 using anaconda使用 anaconda 安装cmake 3.19.7xtensor 0.23.4xtensor-blas 0.19.0openblas 0.3.13anaconda lapack 3.6.1
Compiled using Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe使用Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64\cl.exe

cmake_minimum_required(VERSION 3.19)
project(tstxtensor6)

set(CMAKE_CXX_STANDARD 20)

find_package(xtensor)
find_package(xtensor-blas)
add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(${PROJECT_NAME} xtensor xtensor-blas)
#include <xtensor-blas/xlinalg.hpp>

int main()
{
    {
        xt::xarray<double> a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
        auto d = xt::linalg::det(a);
        std::cout << d << std::endl;  // 6.661338e-16
    }
    {
        xt::xarray<double> a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
        auto d = xt::linalg::slogdet(a);
        std::cout << std::get<0>(d) << ", " << std::get<1>(d) << std::endl;  // 1, -34.9450...
    }
}

The problem is with the example, that uses a singular matrix.问题在于使用奇异矩阵的示例。 Its determinant should be 0 as your code outputs correctly.当您的代码正确输出时,它的行列式应该是 0。

This case was discussed in a pull request for xtensor-blas, and the solution was to change the example.这个案例在 xtensor-blas 的拉取请求中进行了讨论,解决方案是更改示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM