本文整理汇总了C++中eigen::VectorXd::conservativeResize方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorXd::conservativeResize方法的具体用法?C++ VectorXd::conservativeResize怎么用?C++ VectorXd::conservativeResize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::VectorXd
的用法示例。
在下文中一共展示了VectorXd::conservativeResize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getVector
EReturn getVector(const tinyxml2::XMLElement & xml_vector,
Eigen::VectorXd & eigen_vector)
{
//!< Temporaries
double temp_entry;
int i = 0;
if (!xml_vector.GetText())
{
INDICATE_FAILURE
;
eigen_vector = Eigen::VectorXd(); //!< Null matrix again
return PAR_ERR;
}
std::istringstream text_parser(xml_vector.GetText());
//!< Initialise looping
text_parser >> temp_entry;
while (!(text_parser.fail() || text_parser.bad())) //!< No commenting!
{
eigen_vector.conservativeResize(++i); //!< Allocate storage for this entry (by increasing i)
eigen_vector(i - 1) = temp_entry;
text_parser >> temp_entry;
}
return (i > 0) ? SUCCESS : PAR_ERR;
}
示例2: addVectorBlock
void addVectorBlock( Eigen::VectorXd &matrix, const int block_length ){
assert( 1==matrix.cols() );
int old_size = matrix.rows();
matrix.conservativeResize( old_size+block_length, 1 );
matrix.block( old_size, 0, block_length, 1 ) = Eigen::MatrixXd::Zero( block_length, 1);
}
示例3: append
void append(
Eigen::VectorXd& v,
const Eigen::PlainObjectBase<Derived1>& app)
{
int n = v.size();
if(n <= 0){
v = app;
}else{
assertion(app.cols() == 1 , app.cols());
v.conservativeResize(n + app.size());
for(int i = 0; i < app.size(); i++)
v(n+i) = app(i);
}
}
示例4: deleteVectorBlock
void deleteVectorBlock( Eigen::VectorXd &matrix, const int block_start_index, const int block_length ){
assert( 1==matrix.cols() );
assert( matrix.rows()>=block_start_index+block_length );
int size = matrix.rows();
/*
R
D
M
*/
matrix.block( block_start_index, 0, size-block_start_index-block_length, 1 ) = matrix.block( block_start_index+block_length, 0, size-block_start_index-block_length, 1 );
matrix.conservativeResize( size-block_length, 1 );
}
示例5: return
double L2R_Huber_SVC::predict(const std::string fileNameLibSVMFormat,
Eigen::VectorXd &w) {
Eigen::SparseMatrix<double, 1> vX;
Eigen::ArrayXd vy;
const char *fn = fileNameLibSVMFormat.c_str();
read_LibSVMdata1(fn, vX, vy);
// loadLib(fileNameLibSVMFormat, vX, vy);
int vl = vX.rows();
int vn = vX.cols();
int success = 0;
if (vn != w.size()) {
w.conservativeResize(vn);
}
Eigen::ArrayXd prob = vy * (vX * w).array();
for (int i = 0; i < vl; ++i) {
if (prob.coeffRef(i) >= 0.0)
++success;
}
return (double)success / vl;
}