- 更新一下 source.list
user@starfive:~$ cat /etc/apt/sources.list
#deb https://snapshot.debian.org/archive/debian-ports/20221225T084846Z unstable main
deb https://snapshot.debian.org/archive/debian-ports/20230724T141507Z unstable main
- 下载证书
wget http://ftp.de.debian.org/debian/pool/main/d/debian-ports-archive-keyring/debian-ports-archive-keyring_2024.02.02_all.deb
sudo dpkg -i debian-ports-archive-keyring_2024.02.02_all.deb
- update
sudo apt-get update -y
- 可以升级了
sudo apt-get upgrade -y
- 完成
user@starfive:~$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux trixie/sid"
NAME="Debian GNU/Linux"
VERSION_CODENAME=trixie
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
1.安装开发环境
sudo apt install build-essential cmake
- 安装各种的模块
sudo apt-get install -y libarmadillo-dev libarmadillo11
sudo apt-get install -y libensmallen-dev
sudo apt-get install -y cereal libcereal-dev
- 安装 mlpack
详细信息来看这儿: GitHub - mlpack/mlpack: mlpack: a fast, header-only C++ machine learning library
sudo apt-get install -y libmlpack-dev mlpack-bin
- 写一个测试的代码
user@starfive:/opt/work$ cat my_program.cpp
// This is an interactive demo, so feel free to change the code and click the 'Run' button.
// This simple program uses the mlpack::neighbor::NeighborSearch object
// to find the nearest neighbor of each point in a dataset using the L1 metric,
// and then print the index of the neighbor and the distance of it to stdout.
#include <mlpack.hpp>
using namespace mlpack;
int main()
{
// Load the data from data.csv (hard-coded). Use CLI for simple command-line
// parameter handling.
arma::mat data("0.339406815,0.843176636,0.472701471; \
0.212587646,0.351174901,0.81056695; \
0.160147626,0.255047893,0.04072469; \
0.564535197,0.943435462,0.597070812");
data = data.t();
// Use templates to specify that we want a NeighborSearch object which uses
// the Manhattan distance.
NeighborSearch<NearestNeighborSort, ManhattanDistance> nn(data);
// Create the object we will store the nearest neighbors in.
arma::Mat<size_t> neighbors;
arma::mat distances; // We need to store the distance too.
// Compute the neighbors.
nn.Search(1, neighbors, distances);
// Write each neighbor and distance using Log.
for (size_t i = 0; i < neighbors.n_elem; ++i)
{
std::cout << "Nearest neighbor of point " << i << " is point "
<< neighbors[i] << " and the distance is " << distances[i] << "." << std::endl;
}
return 0;
}
5.编译 { 速度是有点慢 }
user@starfive:/opt/work$ time g++ -O3 -std=c++14 -o my_program my_program.cpp -larmadillo -fopenmp
real 1m8.549s
user 1m6.585s
sys 0m1.878s
- 看看结果
user@starfive:/opt/work$ ./my_program
Nearest neighbor of point 0 is point 3 and the distance is 0.449757.
Nearest neighbor of point 1 is point 2 and the distance is 0.918409.
Nearest neighbor of point 2 is point 1 and the distance is 0.918409.
Nearest neighbor of point 3 is point 0 and the distance is 0.449757.