本文整理汇总了C++中el::Matrix类的典型用法代码示例。如果您正苦于以下问题:C++ Matrix类的具体用法?C++ Matrix怎么用?C++ Matrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Matrix类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SymmetricEuclideanDistanceMatrix
void SymmetricEuclideanDistanceMatrix(El::UpperOrLower uplo, direction_t dir,
T alpha, const El::Matrix<T> &A, T beta, El::Matrix<T> &C) {
T *c = C.Buffer();
int ldC = C.LDim();
if (dir == base::COLUMNS) {
El::Herk(uplo, El::ADJOINT, -2.0 * alpha, A, beta, C);
//El::Gemm(El::ADJOINT, El::NORMAL, T(-2.0) * alpha, A, A, beta, C);
El::Matrix<T> N;
ColumnNrm2(A, N);
T *nn = N.Buffer();;
int n = base::Width(A);
for(El::Int j = 0; j < n; j++)
for(El::Int i = ((uplo == El::UPPER) ? 0 : j);
i < ((uplo == El::UPPER) ? (j + 1) : n); i++)
c[j * ldC + i] += alpha * (nn[i] * nn[i] + nn[j] * nn[j]);
}
// TODO the rest of the cases.
}
开发者ID:TPNguyen,项目名称:libskylark,代码行数:25,代码来源:distance.hpp
示例2: EuclideanDistanceMatrix
void EuclideanDistanceMatrix(direction_t dirA, direction_t dirB, T alpha,
const El::Matrix<T> &A, const El::Matrix<T> &B,
T beta, El::Matrix<T> &C) {
T *c = C.Buffer();
El::Int ldC = C.LDim();
if (dirA == base::COLUMNS && dirB == base::COLUMNS) {
base::Gemm(El::ADJOINT, El::NORMAL, T(-2.0) * alpha, A, B, beta, C);
El::Matrix<T> NA, NB;
ColumnNrm2(A, NA);
ColumnNrm2(B, NB);
T *na = NA.Buffer(), *nb = NB.Buffer();
El::Int m = base::Width(A);
El::Int n = base::Width(B);
for(El::Int j = 0; j < n; j++)
for(El::Int i = 0; i < m; i++)
c[j * ldC + i] += alpha * (na[i] * na[i] + nb[j] * nb[j]);
}
// TODO the rest of the cases.
}
开发者ID:TPNguyen,项目名称:libskylark,代码行数:26,代码来源:distance.hpp
示例3: dump_to_file
void lbann_callback_dump_minibatch_sample_indices::dump_to_file(model *m, Layer *l, int64_t step) {
// Print minibatch sample indices of input layers
auto *input = dynamic_cast<generic_input_layer*>(l);
if (input != nullptr) {
El::Matrix<El::Int>* indices = l->get_sample_indices_per_mb();
if (indices == nullptr
|| indices->Height() == 0
|| indices->Width() == 0) {
return;
}
std::ostringstream s;
s << "mkdir -p " << m_basename;
const int dir= system(s.str().c_str());
if (dir< 0) {
LBANN_ERROR("callback_dump_minibatch_sample_indices is unable to create the target director");
}
const std::string file
= (m_basename
+ _to_string(m->get_execution_mode())
+ "-model" + std::to_string(m->get_comm()->get_trainer_rank())
+ "-rank" + std::to_string(m->get_comm()->get_rank_in_trainer())
+ "-epoch" + std::to_string(m->get_cur_epoch())
+ "-step" + std::to_string(m->get_cur_step())
+ "-" + l->get_name()
+ "-MB_Sample_Indices");
El::Write(*indices, file, El::ASCII);
}
}
开发者ID:LLNL,项目名称:lbann,代码行数:30,代码来源:callback_dump_minibatch_sample_indices.cpp
示例4: L1DistanceMatrix
void L1DistanceMatrix(direction_t dirA, direction_t dirB, T alpha,
const El::Matrix<T> &A, const El::Matrix<T> &B,
T beta, El::Matrix<T> &C) {
// TODO verify sizes
const T *a = A.LockedBuffer();
El::Int ldA = A.LDim();
const T *b = B.LockedBuffer();
El::Int ldB = B.LDim();
T *c = C.Buffer();
El::Int ldC = C.LDim();
El::Int d = A.Height();
/* Not the most efficient way... but mimicking BLAS is too much work! */
if (dirA == base::COLUMNS && dirB == base::COLUMNS) {
for (El::Int j = 0; j < B.Width(); j++)
for (El::Int i = 0; i < A.Width(); i++) {
T v = 0.0;
for (El::Int k = 0; k < d; k++)
v += std::abs(b[j * ldB + k] - a[i * ldA + k]);
c[j * ldC + i] = beta * c[j * ldC + i] + alpha * v;
}
}
// TODO the rest of the cases.
}
开发者ID:TPNguyen,项目名称:libskylark,代码行数:31,代码来源:distance.hpp
示例5: apply_inverse_impl
void apply_inverse_impl(El::Matrix<ValueType>& A,
skylark::sketch::columnwise_tag) const {
ValueType* AA = A.Buffer();
int j;
# ifdef SKYLARK_HAVE_OPENMP
# pragma omp parallel for private(j)
# endif
for (j = 0; j < A.Width(); j++)
ExecuteFun(_plan_inverse, AA + j * A.LDim(), AA + j * A.LDim());
}
开发者ID:TPNguyen,项目名称:libskylark,代码行数:11,代码来源:FUT.hpp
示例6: apply_impl
void apply_impl(El::Matrix<value_type>& A,
skylark::sketch::columnwise_tag) const {
ValueType* AA = A.Buffer();
int j;
# ifdef SKYLARK_HAVE_OPENMP
# pragma omp parallel for private(j)
# endif
for (j = 0; j < A.Width(); j++)
wht_apply(_tree, 1, AA + j * A.LDim());
}
开发者ID:TPNguyen,项目名称:libskylark,代码行数:11,代码来源:FUT.hpp
示例7: SymmetricL1DistanceMatrix
void SymmetricL1DistanceMatrix(El::UpperOrLower uplo, direction_t dir, T alpha,
const El::Matrix<T> &A, T beta, El::Matrix<T> &C) {
const T *a = A.LockedBuffer();
El::Int ldA = A.LDim();
T *c = C.Buffer();
El::Int ldC = C.LDim();
El::Int n = A.Width();
El::Int d = A.Height();
/* Not the most efficient way... but mimicking BLAS is too much work! */
if (dir == base::COLUMNS) {
for (El::Int j = 0; j < n; j++)
for(El::Int i = ((uplo == El::UPPER) ? 0 : j);
i < ((uplo == El::UPPER) ? (j + 1) : n); i++)
for (El::Int i = 0; i < A.Width(); i++) {
T v = 0.0;
for (El::Int k = 0; k < d; k++)
v += std::abs(a[j * ldA + k] - a[i * ldA + k]);
c[j * ldC + i] = beta * c[j * ldC + i] + alpha * v;
}
}
// TODO the rest of the cases.
}
开发者ID:TPNguyen,项目名称:libskylark,代码行数:28,代码来源:distance.hpp
示例8: Gemv
inline void Gemv(El::Orientation oA,
T alpha, const sparse_matrix_t<T>& A, const El::Matrix<T>& x,
T beta, El::Matrix<T>& y) {
// TODO verify sizes etc.
const int* indptr = A.indptr();
const int* indices = A.indices();
const double *values = A.locked_values();
double *yd = y.Buffer();
const double *xd = x.LockedBuffer();
int n = A.width();
if (oA == El::NORMAL) {
El::Scale(beta, y);
# if SKYLARK_HAVE_OPENMP
# pragma omp parallel for
# endif
for(int col = 0; col < n; col++) {
T xv = alpha * xd[col];
for (int j = indptr[col]; j < indptr[col + 1]; j++) {
int row = indices[j];
T val = values[j];
yd[row] += val * xv;
}
}
} else {
# if SKYLARK_HAVE_OPENMP
# pragma omp parallel for
# endif
for(int col = 0; col < n; col++) {
double yv = beta * yd[col];
for (int j = indptr[col]; j < indptr[col + 1]; j++) {
int row = indices[j];
T val = values[j];
yv += alpha * val * xd[row];
}
yd[col] = yv;
}
}
}
开发者ID:TPNguyen,项目名称:libskylark,代码行数:45,代码来源:Gemv.hpp
示例9: Width
int Width(const El::Matrix<T>& A) {
return A.Width();
}
开发者ID:poulson,项目名称:libskylark,代码行数:3,代码来源:query.hpp
示例10: Height
int Height(const El::Matrix<T>& A) {
return A.Height();
}
开发者ID:poulson,项目名称:libskylark,代码行数:3,代码来源:query.hpp
示例11: ColumnView
inline void ColumnView(El::Matrix<T>& A, El::Matrix<T>& B,
int j, int width) {
El::View(A, B, 0, j, B.Height(), width);
}
开发者ID:poulson,项目名称:libskylark,代码行数:4,代码来源:viewing.hpp
示例12: RowView
inline
const El::Matrix<T> RowView(const El::Matrix<T>& B, int i, int height) {
El::Matrix<T> A;
El::LockedView(A, B, i, 0, height, B.Width());
return A;
}
开发者ID:poulson,项目名称:libskylark,代码行数:6,代码来源:viewing.hpp
示例13: max
int max(El::Matrix<double> Y) {
int k = (int) *std::max_element(Y.Buffer(), Y.Buffer() + Y.Height());
return k;
}
开发者ID:TPNguyen,项目名称:libskylark,代码行数:4,代码来源:utils.hpp
注:本文中的el::Matrix类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论