Qt中使用NumCpp

 

一、NumCpp简介

https://github.com/dpilger26/NumCpp/tree/master

 

 

二、下载使用

mkdir includes
git clone https://codechina.csdn.net/mirrors/dpilger26/NumCpp.git
mv NumCpp/include/* ./includes

wget https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.zip
unzip boost_1_75_0.zip
mv boost_1_75_0/boost includes

 

Qt中使用NumCpp_第1张图片

 

在Qt项目.pro文件中加入两行

CONFIG += c++14

INCLUDEPATH += $$PWD/includes

 

示例:

#-------------------------------------------------
#
# Project created by QtCreator 2021-02-05T16:00:19
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = OpenglSample
TEMPLATE = app

CONFIG += c++14

SOURCES += main.cpp\
        mainwindow.cpp \


HEADERS  += mainwindow.h \


FORMS    += mainwindow.ui


INCLUDEPATH += $$PWD/includes

 

三、测试

main.cpp

#include "mainwindow.h"
#include 
#include "NumCpp.hpp"
#include 

int main(int argc, char *argv[])
{
    nc::NdArray a = {
    {1, 2}, {3, 4}};
    nc::NdArray b = {
    {1, 2}, {3, 4}};
    nc::NdArray c = a * b;
    std::cout << c[0] << std::endl;

//    QApplication a(argc, argv);
//    MainWindow w;
//    w.show();

//    return a.exec();
}

 

参考:    https://zhuanlan.zhihu.com/p/341485401

你可能感兴趣的:(QT学习之路,NumCpp,Qt,C++14)