本文整理汇总了C++中DoubleMatrix::rows方法的典型用法代码示例。如果您正苦于以下问题:C++ DoubleMatrix::rows方法的具体用法?C++ DoubleMatrix::rows怎么用?C++ DoubleMatrix::rows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix::rows方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MatrixHeatImaging
void MatrixHeatImaging(const DoubleMatrix &m, double minimum, double maximum, QPixmap &pixmap, int width, int height)
{
pixmap = QPixmap(QSize(width, height));
pixmap.fill(Qt::white);
QPainter painter(&pixmap);
unsigned int rows = m.rows();
unsigned int cols = m.cols();
for (unsigned int j=0; j<rows; j++)
{
for (unsigned int i=0; i<cols; i++)
{
double u = m.at(j,i);
double ratio = 0.0;
if (minimum!=maximum)
ratio = 2.0 * (u-minimum) / (maximum - minimum);
int b = int(MAX(0, 255*(1 - ratio)));
int r = int(MAX(0, 255*(ratio - 1)));
int g = 255 - b - r;
QColor c(r, g, b);
painter.setPen(c);
painter.drawPoint(i,height-j-1);
}
}
}
示例2: fopen
void HeatControl2Delta::write(const char *fileName, const DoubleMatrix& m)
{
FILE* f = fopen(fileName, "w");
for (unsigned int j=0; j<m.rows(); j++)
{
for (unsigned int i=0; i<m.cols(); i++)
{
if (i==0)
fprintf(f, "%.10f", m[j][i]);
else
fprintf(f, " %.10f", m[j][i]);
}
fprintf(f, "\n");
}
fclose(f);
}
示例3: main
int main(int argc, char *argv[]) {
string hdr = invocationHeader(argc, argv);
cout << "# " << hdr << endl;
parseArgs(argc, argv);
DoubleMatrix eigvals;
readAsciiMatrix(eigvals_name, eigvals);
DoubleMatrix eigvecs;
readAsciiMatrix(eigvecs_name, eigvecs);
if (modes.empty())
for (uint i=0; i<eigvals.rows(); ++i)
modes.push_back(i);
uint n = modes.size();
uint m = eigvecs.rows();
// V = m x n matrix of eigenvectors
DoubleMatrix V(m, n);
for (uint i=0; i<n; ++i)
for (uint j=0; j<m; ++j)
V(j, i) = eigvecs(j, modes[i]);
// Make a copy and scale by the appropriate eigenvalue,
// remembering that eigenvalues are inverted for ENM,
// or squaring and not inverting in the case of PCA
DoubleMatrix VS = V.copy();
for (uint i=0; i<n; ++i) {
double e = eigvals[modes[i]];
double s = (pca_input) ? (scale * e * e): (scale / e);
for (uint j=0; j<m; ++j)
VS(j, i) *= s;
}
// U = Covariance matrix
DoubleMatrix U = loos::Math::MMMultiply(VS,V,false,true);
// B-factors come from trace of diagonal 3x3 superblocks
vector<double> B;
double prefactor = 8.0 * M_PI * M_PI / 3.0;
for (uint i=0; i<m; i += 3) {
double b = prefactor * (U(i,i) + U(i+1, i+1) + U(i+2, i+2));
B.push_back(b);
cout << boost::format("%-8d %g\n") % (i/3) % b;
}
if (!pdb_name.empty()) {
AtomicGroup model = createSystem(pdb_name);
AtomicGroup subset = selectAtoms(model, selection);
if ((unsigned int)subset.size() != B.size()) {
cerr << boost::format("Error- selection has %d atoms, but %d were expected.\n") % subset.size() % B.size();
exit(-10);
}
for (uint i=0; i<B.size(); ++i)
subset[i]->bfactor(B[i]);
PDB pdb = PDB::fromAtomicGroup(model);
pdb.remarks().add(hdr);
ofstream ofs(out_name.c_str());
ofs << pdb;
}
}
示例4: Solve
/*!
Linear assignment problem solution
[modifies matrix in-place.]
matrix(row,col): row major format assumed.
Assignments are remaining 0 values on 'matrix'
(extra 0 values are replaced with -1)
The correspondence results are stored in the variables
row2colMap and col2rowMap s.t.
row2colMap(r) = c means that col c is assigned to row r
col2rowMap(c) = r means that row r is assigned to column c
@param initMaps if true the row/col maps are init to invalid values,
which help check the mapping by calling CheckMapping()
*/
double Munkres::Solve(const DoubleMatrix& m, UIntVector* row2colMap,
UIntVector* col2rowMap)
{
#ifdef MUNKRES_DEBUG
std::cout << "Munkres input matrix:" << std::endl;
for ( int row = 0 ; row < m.rows() ; row++ )
{
for ( int col = 0 ; col < m.columns() ; col++ ) {
std::cout.width(8);
std::cout << m(row,col) << ",";
}
std::cout << std::endl;
}
std::cout << std::endl;
#endif
bool notdone = true;
int step = 1;
// Copy m, because it need to be modified
matrix = m;
// Z_STAR == 1 == starred, Z_PRIME == 2 == primed
mask_matrix.set_size(matrix.rows(), matrix.columns());
mask_matrix.fill(0);
row_mask = new bool[matrix.rows()];
col_mask = new bool[matrix.columns()];
for ( unsigned i = 0 ; i < matrix.rows() ; i++ ) {
row_mask[i] = false;
}
for ( unsigned i = 0 ; i < matrix.columns() ; i++ ) {
col_mask[i] = false;
}
while ( notdone ) {
switch ( step ) {
case 0:
notdone = false;
break;
case 1:
step = step1();
break;
case 2:
step = step2();
break;
case 3:
step = step3();
break;
case 4:
step = step4();
break;
case 5:
step = step5();
break;
}
}
delete[] row_mask;
delete[] col_mask;
// Store results
/*
for ( unsigned row = 0 ; row < matrix.rows() ; row++ )
for ( unsigned col = 0 ; col < matrix.columns() ; col++ )
if ( mask_matrix(row,col) == Z_STAR )
matrix(row,col) = 0;
else
matrix(row,col) = -1;
#ifdef MUNKRES_DEBUG
std::cout << "Munkres output matrix:" << std::endl;
for ( int row = 0 ; row < matrix.rows() ; row++ ) {
for ( int col = 0 ; col < matrix.columns() ; col++ ) {
std::cout.width(1);
std::cout << matrix(row,col) << ",";
}
std::cout << std::endl;
}
std::cout << std::endl;
//.........这里部分代码省略.........