本文整理汇总了C++中Matrix::GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::GetBuffer方法的具体用法?C++ Matrix::GetBuffer怎么用?C++ Matrix::GetBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::GetBuffer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eig
void eig(const Matrix& A, Matrix& E) {
Array2D< double > AA(A.row_num(), A.col_num(), const_cast< double* >(A.GetBuffer()));
Eigenvalue< double > eig_core(AA);
Array1D< double > res_eigs;
eig_core.getRealEigenvalues(res_eigs);
assign_mat_ar1d(E, res_eigs);
}
示例2: svd
void svd(const Matrix& A, Matrix& U, Matrix& E, Matrix& V)
{
Array2D<double> AA(A.row_num(), A.col_num(), const_cast< double* >(A.GetBuffer()));
SVD<double> kernel(AA);
Array2D<double> AU, AE, AV;
kernel.getU(AU); kernel.getV(AV); kernel.getS(AE);
assign_mat_ar2d(U, AU);
assign_mat_ar2d(V, AV);
assign_mat_ar2d(E, AE);
}
示例3: calc_dist_matrix_impl
//template< int cdm_method >
norm_tools::dist_stat calc_dist_matrix_impl(const Matrix& data, Matrix& dist, norm_tools::vm_norm_fn_t norm2_fn)
{
//some constant values used
const ulong points_num = data.row_num();
const double mult = 2.0/(points_num * (points_num - 1));
const double mult1 = 1.0/data.row_num();
//resize distance matrix
dist(points_num, points_num);
//statistics
norm_tools::dist_stat stat;
//make a copy of input data
Matrix data_cpy(data.row_num(), data.col_num(), data.GetBuffer());
//locally used matrices
Matrix dist_row(1, data.row_num()), dv, norm;
//mean distance^2
double meand2 = 0, meand2_nn = 0;
//current min distance (between nearest neighbours)
double cur_mind = 0;
for(ulong i = 0; i < points_num - 1; ++i) {
dv <<= data_cpy.GetRows(0);
data_cpy.DelRows(0);
//calc norms^2
norm <<= norm2_fn(dv, data_cpy);
//update mean distance^2
meand2 += mult * norm.Sum();
//update mean nn distance^2
meand2_nn += mult1 * cur_mind * cur_mind;
//calc norm
transform(norm, ptr_fun< double, double >(std::sqrt));
dist_row = 0;
dist_row.SetColumns(norm, i + 1, norm.size());
dist.SetRows(dist_row, i);
//calc mean
stat.mean_ += mult * norm.Sum();
//calc distance to nearest neighbour
cur_mind = norm.Min();
if(i == 0 || cur_mind < stat.min_) stat.min_ = cur_mind;
//update mean distance to nearest neighbour
stat.mean_nn_ += cur_mind * mult1;
}
//fill lower triangle of distance matrix
dist <<= dist + !dist;
//calc mse
stat.mse_ = sqrt(stat.mean_*(meand2/stat.mean_ - stat.mean_));
stat.mse_nn_ = sqrt(stat.mean_nn_*(meand2_nn/stat.mean_nn_ - stat.mean_nn_));
return stat;
}