1 Star 0 Fork 16

淘金小子/NumCpp

forked from Gitee 极速下载/NumCpp 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
base.cpp 961 Bytes
一键复制 编辑 原始数据 按行查看 历史
Tobias Knopp 提交于 2013-10-14 04:23 +08:00 . several changes
#include "catch.hpp"
#include <numcpp.h>
using namespace numcpp;
TEST_CASE( "numcpp/base/sum", "Sum test" )
{
{
auto x = Array<double>({1,2,3,4});
REQUIRE( sum(x) == 10 );
}
{
auto x = Array<double>({1,2,3,4},2,2);
REQUIRE( sum(x) == 10 );
REQUIRE( all( sum(x,1) == array({3, 7}) ) );
REQUIRE( all( sum(x,0) == array({4, 6}) ) );
}
{
auto x = array({1,2,3,4});
auto y = array({1,3,6,10});
REQUIRE( all( cumsum(x) == y ) );
}
}
TEST_CASE( "numcpp/base/rounding", "Rounding tests" )
{
{
auto x = array({1,2,3,4});
auto y = array({1.2,2.4,2.5,3.6});
REQUIRE( all( round(y) == x ) );
}
}
TEST_CASE( "numcpp/base/shuffle", "Shuffle test" )
{
{
auto x = array<int>({1,2,3,4});
auto y = shuffle(x);
REQUIRE( sum(x) == sum(y) );
}
}
TEST_CASE( "numcpp/base/sort", "Sort test" )
{
{
auto x = array<int>({4,2,9,3});
auto y = argsort(x);
print(y);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/quehanwei/numcpp.git
git@gitee.com:quehanwei/numcpp.git
quehanwei
numcpp
NumCpp
master

搜索帮助