对于几乎所有我的数学线性代数工作,我都习惯了Eigen.最近,我发现Boost还提供了一个C++模板类库,它提供了基本线性代数库(Boost :: uBLAS).这让我想知道我是否可以仅使用boost来完成我的所有工作,因为它已经是我的代码的主要库.
仔细看看两者并没有让我更清楚地区分它们:
uBLAS为密集,单位和稀疏向量,密集,同一性,三角形,带状,对称,埃尔米特和稀疏矩阵提供模板化C++类.可以通过范围,切片,适配器类和间接数组构建对向量和矩阵的视图.该库涵盖了矢量和矩阵的常用基本线性代数运算:不同规范的减少,矢量和矩阵的加法和减法,以及矢量的标量,内部和外部乘积,矩阵向量和矩阵矩阵乘积以及三角形求解器的乘法.
...
它支持所有矩阵大小,从小的固定大小矩阵到任意大的密集矩阵,甚至是稀疏矩阵.
它支持所有标准数字类型,包括std :: complex,整数,并且可以轻松扩展为自定义数字类型.
它支持各种矩阵分解和几何特征.
其不受支持的模块生态系统提供了许多专业功能,如非线性优化,矩阵函数,多项式求解器,FFT等等.
...
有没有人对他们的关键差异有更好的了解,我们可以在哪些基础上做出选择?
我正在尝试使用需要 OpenSSl 的静态链接 Poco 库来构建 dll。
当我使用libeay32MDd.lib和ssleay32MDd.lib静态链接构建 Poco 库时,它运行良好,但需要 OpenSSL 的 DLL。如果我使用libeay32MTd.lib和ssleay32MTd.lib,它会抛出以下错误:
libeay32MTd.lib(e_capi.obj) :错误 LNK2019:未解析的外部符号 __imp_CertOpenStore 在函数 capi_open_store 8>libeay32MTd.lib(e_capi.obj) 中引用:错误 LNK2019:未解析的外部符号 __imp_CertClosei3_find_capi3_findlibeMT. obj) :错误 LNK2019:未解析的外部符号 __imp_CertEnumCertificatesInStore 在函数 capi_find_cert 8>libeay32MTd.lib(e_capi.obj) 中引用:错误 LNK2019:未解析的外部符号 __imp_CertFindCertificateIncapi8_obje2019 函数中引用的外部符号未解析的外部符号 __imp_CertDuplicateCertificateContext 在函数 capi_load_ssl_client_cert 8>libeay32MTd.lib(e_capi.obj) 中引用:错误 LNK2019:函数 capi_find_key 8>libeay32MTd.lib(e_capi.obj) 中引用的未解析外部符号 __imp_CertFreeCertificateContext:错误 LNK2019:函数 capi_cert_get_fname 中引用的未解析外部符号 __imp_CertGetCertificateContextProperty
当我试图将一个函数作为一个参数传递给另一个函数时,我用C++遇到了这个奇怪的事情.这里的问题是它有效,但没有给我预期的结果.这是我的代码(msvc2013):
#include <stdio.h> /* printf, NULL */
#include <stdlib.h> /* srand, rand */
#include <time.h> /* time */
#include <iostream>
typedef unsigned int uint32_t;
typedef unsigned char uint8_t;
using namespace std;
#include "stdafx.h"
uint32_t random_color()
{
uint8_t r = rand() % 255;
uint8_t g = rand() % 255;
uint8_t b = rand() % 255;
uint32_t rgb = ((uint32_t)r << 16 | (uint32_t)g << 8 | (uint32_t)b);
return rgb;
}
void print_rgb(uint32_t(*color_generator)() = &random_color)
{
std::cout << color_generator << std::endl;
} …Run Code Online (Sandbox Code Playgroud) 比如,我在代码中有两个向量,我希望使用迭代器擦除向量"data"中的向量"index_to_filter"索引的元素.代码中的虚拟方式只是指出明显的错误.到目前为止,我无法让它工作,也不知道这是否可以成为擦除 - 删除 - 成语?.有没有办法去错过它?
谢谢.
#include <iostream>
#include <vector>
int main()
{
std::vector<int> data{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
std::vector<int> index_to_filter{ 1, 5, 8 };
/* needed result data = { 0, 2, 3, 4, 6, 7, 9 }*/
std::vector<int>::iterator iter = index_to_filter.begin();
while (iter != index_to_filter.end())
{
std::vector<int>::iterator iter_data = data.begin() + *iter;
iter_data = data.erase(iter_data);
iter++;
}
/* Throws : vector erase iterator outside range */
for …Run Code Online (Sandbox Code Playgroud)