本文整理汇总了C++中matrix_type::Resize方法的典型用法代码示例。如果您正苦于以下问题:C++ matrix_type::Resize方法的具体用法?C++ matrix_type::Resize怎么用?C++ matrix_type::Resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matrix_type
的用法示例。
在下文中一共展示了matrix_type::Resize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copy
/**
* 13.
* @brief Copy the contents of a matrix.
* @param[out] A A is overwritten with B.
* @param[in] B The matrix to be copied.
*/
static void copy (matrix_type &A, const matrix_type &B) {
/** Result matrices should always be of the right size */
A.Resize (B.Height(), B.Width());
/** This one is pretty simple, but the order is different */
elem::Copy (B, A);
}
示例2: transpose
/**
* 6.
* @brief Compute the matrix transpose.
* @param[in] A The matrix to be transposed.
* @param[out] B B is overwritten with A^{T}
*/
static void transpose (const matrix_type& A,
matrix_type& B) {
/** Result matrices should always have sufficient space */
B.Resize(A.Width(), A.Height());
/** Compute transpose */
elem::Transpose (A, B);
}
示例3: multiply
/**
* 5.
* @brief Multiply one matrix with another.
* @param[in] A The first matrix
* @param[in] B The second matrix
* @param[out] C C is overwritten with (A*B)
*/
static void multiply (const matrix_type& A,
const matrix_type& B,
matrix_type& C) {
/** Result matrices should always have sufficient space */
C.Resize(A.Height(), B.Width());
/** We have to do a Gemm */
elem::Gemm (elem::NORMAL, elem::NORMAL, 1.0, A, B, 0.0, C);
}
示例4: negation
/**
* 7.
* @brief Compute element-wise negation of a matrix.
* @param[in] A The matrix to be negated.
* @param[out] B B is overwritten with -1.0*A
*/
static void negation (const matrix_type& A,
matrix_type& B) {
/** Result matrices should always have sufficient space */
B.Resize(A.Height(), A.Width());
/** Copy over the matrix */
elem::Copy (A, B);
/** Multiply by -1.0 */
elem::Scal(-1.0, B);
}
示例5: minus
/**
* 4.
* @brief Subtract one matrix from another.
* @param[in] A The first matrix
* @param[in] B The second matrix
* @param[out] C C is overwritten with (A-B)
*/
static void minus (const matrix_type& A,
const matrix_type& B,
matrix_type& C) {
/** Result matrices should always have sufficient space */
C.Resize(A.Height(), A.Width());
/** first copy the matrix over */
elem::Copy (A, C);
/** now, subtract the other matrix in */
elem::Axpy (-1.0, B, C);
}
示例6: elementwiseProduct
/**
* 16.
* @brief Compute the element-wise product of two matrices.
* @param[in] A the first matrix.
* @param[in] B the second matrix.
* @param[out] C the result, which contains A.*B.
*/
static void elementwiseProduct(const matrix_type& A,
const matrix_type& B,
matrix_type& C) {
/** Result matrices should always be of the right size */
C.Resize (A.Height(), A.Width());
/* Get the matrix dimensions */
const int m = A.Height();
const int n = A.Width();
/* Simple element-wise product */
for (int i=0; i<m; ++i)
for (int j=0; j<n; ++j)
C.Set(i, j, (A.Get(i,j)*B.Get(i,j)));
}