VOID Matrix2<T>::SetElement(SIZE_T i, SIZE_T j, T& V) { Assert( i < Rows() ); Assert( j < Columns() ); m_M[i*Columns() + j] = V; }
T& Matrix2<T>::operator () (SIZE_T i, SIZE_T j) { Assert( i < Rows() ); Assert( j < Columns() ); return m_M[i*Columns() + j]; }
RecursiveBacktrackerMaze::RecursiveBacktrackerMaze(int x, int y) : Maze(x,y) , marked_(Columns(), Rows()) , cell_count_((Columns()-2) * (Rows()-2) - 1) { marked_.Mark(start_); backtracker_.push(start_); }
std::string Table::Data(unsigned int row, unsigned int col) const { if (row < Rows() && col < Columns()) { return m_data.at(Columns() * row + col); } return ""; }
double Matrix::mean(){ double mean = 0; for (int i = 0; i < Columns(); i++) for (int j = 0; j < Rows(); j++){ mean += get(i, j); } mean /= Columns() * Rows(); return mean; }
void DenseMatrix::ToHostMatrix(float** mat, int* rows, int* cols) const { // TODO(dalexander): make sure SWIG client deallocates this memory -- use %newobject flag matrix<lfloat, row_major> rowMajorPeer(*this); *mat = new float[Rows() * Columns()]; std::copy(rowMajorPeer.data().begin(), rowMajorPeer.data().end(), *mat); *rows = Rows(); *cols = Columns(); }
WilsonsMaze::WilsonsMaze(int x, int y) : Maze(x,y) , marked_(Columns(), Rows()) , paths_(Columns(), std::vector<Cell::Direction>(Rows(), Cell::Direction::RIGHT)) { for (int i = 1; i < (Columns() - 1); i++) for (int j = 1; j < (Rows() - 1); j++) outside_cells_.push_back(Point(i,j)); marked_.Mark(start_); }
void SparseMatrix::ToHostMatrix(float** mat, int* rows, int* cols) const { *mat = new float[Rows() * Columns()]; *rows = Rows(); *cols = Columns(); for (int i = 0; i < Rows(); i++) { for (int j = 0; j < Columns(); j++) { (*mat)[i * Columns() + j] = Get(i, j); } } }
void SparseMatrix::ToHostMatrix(float** mat, int* rows, int* cols) const { const float nan = std::numeric_limits<float>::quiet_NaN(); *mat = new float[Rows() * Columns()]; *rows = Rows(); *cols = Columns(); for (int i = 0; i < Rows(); i++) { for (int j = 0; j < Columns(); j++) { (*mat)[i * Columns() + j] = IsAllocated(i, j) ? Get(i, j) : nan; } } }
VOID Matrix2<T>::SetColumn(SIZE_T j, T& V) { Assert( j < Columns() ); for (SIZE_T i=0; i<Rows(); i++) (*this)(i,j) = V; }
VOID Matrix2<T>::SetColumn(SIZE_T j, CONST Vector2<T>& V) { Assert( j < Columns() ); for (SIZE_T i=0; i<Rows(); i++) (*this)(i,j) = V(i); }
VOID Matrix2<T>::SetRow(SIZE_T i, CONST Vector2<T>& V) { Assert( i < Rows() ); for (SIZE_T j=0; j<Columns(); j++) (*this)(i,j) = V(j); }
VOID Matrix2<T>::SetRow(SIZE_T i, T& V) { Assert( i < Rows() ); for (SIZE_T j=0; j<Columns(); j++) (*this)(i,j) = V; }
// //////////////////////////////////////////////////////////////////////////// ResultInfoColumnsSet &OdbcHandleStmt::GetResultInfoColumns( ResultInfoColumnsSet &out_list, const char *CatalogName, const char *SchemaName, const char *TableName, const char *ColumnName, OdbcThrowFlags::Flags throw_flags) const { ResultInfoColumnsSet tmp_list; try { Columns(CatalogName, SchemaName, TableName, ColumnName, throw_flags); SQLSMALLINT col_count; NumResultCols(&col_count); SQLRETURN row_return_code; ResultInfoColumnsRaw raw_data; raw_data.Bind(*this, col_count); while (SQL_SUCCEEDED(row_return_code = Fetch())) { tmp_list.insert(raw_data); raw_data.Clear(); } } catch (const std::exception &except) { MLB::Utility::Rethrow(except, "Unable to load column information: " + std::string(except.what())); } out_list.swap(tmp_list); return(out_list); }
/** * @brief Converts a GSL matrix to a TNT-based matrix * * Convenience method to convert to GSLMatrix type * * @param m GSL matrix to convert * * @return GSLUtility::GSLMatrix TNT-based matrix */ GSLUtility::GSLMatrix GSLUtility::gslToGSL(const gsl_matrix *m) const { size_t nrows = Rows(m); size_t ncols = Columns(m); GSLMatrix Nm(nrows, ncols); for(size_t i = 0 ; i < nrows ; i++) { for(size_t j = 0 ; j < ncols ; j++) { Nm[i][j] = gsl_matrix_get(m, i, j); } } return (Nm); }
Lookup_Size::Lookup_Size (int rows, int columns) { row_range = NULL; row_size = 0; wrap_flag = true; min_size = 0; max_size = MIDNIGHT; Rows (rows); Columns (columns); }
Vector<V, I> NumericMatrix<V, I, S>::Row(I row) const { // Return row. Overloads Matrix::Row() to return Vector instead of Array //return Vector<V, I>(Matrix<V, I, S>::Row(row)); // We make a copy in this version Vector<V,I> result(Columns(), MinColumnIndex()); for (I j = result.MinIndex(); j <= result.MaxIndex(); ++j) { result[j] = (*this)(row, j); } return result; }
int SparseMatrix::UsedEntries() const { // use column ranges int filledEntries = 0; for (int col = 0; col < Columns(); ++col) { int start, end; boost::tie(start, end) = UsedRowRange(col); filledEntries += (end - start); } return filledEntries; }
/** * @brief Converts TNT-based matrix to GSL matrix * * Convenience method to convert TNT-based matrix to a GSL matrix. * * @param m TNT-based matrix to convert * @param gm Optional GSL matrix of same size to copy data to * * @return gsl_matrix* Pointer to GSL matrix copy */ gsl_matrix *GSLUtility::GSLTogsl(const GSLUtility::GSLMatrix &m, gsl_matrix *gm) const { if(gm == 0) { gm = gsl_matrix_alloc(m.dim1(), m.dim2()); } else if((Rows(gm) != (size_t) m.dim1()) && (Columns(gm) != (size_t) m.dim2())) { ostringstream mess; mess << "Size of NL matrix (" << m.dim1() << "," << m.dim2() << ") not same as GSL matrix (" << Rows(gm) << "," << Columns(gm) << ")"; throw IException(IException::Programmer, mess.str().c_str(), _FILEINFO_); } for(int i = 0 ; i < m.dim1() ; i++) { for(int j = 0 ; j < m.dim2() ; j++) { gsl_matrix_set(gm, i, j, m[i][j]); } } return (gm); }
QVariant ConnList::headerData(int section, Qt::Orientation, int role) const { if (role != Qt::DisplayRole) return {}; switch (Columns(section)) { case Columns::Status: return "Status"; case Columns::Server: return "Server"; case Columns::Data: return "Data"; case Columns::Kbs: return "Speed"; case Columns::Desc: return "Description"; case Columns::LAST: Q_ASSERT(false); } return {}; }
template <class V, class I, class S> NumericMatrix<V, I, S> NumericMatrix<V, I, S>::Transpose() const { // Switch rows and columns NumericMatrix<V, I, S> result(Columns(), Rows()); for (I i = result.MinRowIndex(); i <= result.MaxRowIndex(); ++i) { for (I j = result.MinColumnIndex(); j<= result.MaxColumnIndex(); ++j) { result(i,j) = (*this)(j,i); } } return result; }
void erase_columns (FCS& Result, std::vector<std::size_t> const& zColumns) { std::set<std::size_t> Columns (zColumns.begin (), zColumns.end ()); typename FCS::parameter_type Parameter; for (std::size_t i=0; i<Result.Head.Parameter.size (); ++i) if (Columns.end () == Columns.find (i+1)) Parameter.push_back (Result.Head.Parameter[i]); Result.Head.Parameter = Parameter; typename FCS::data_type Data (Result.Data.size ()); for (std::size_t i=0; i<Result.Data.size (); ++i) for (std::size_t j=0; j<Result.Data[i].size (); ++j) if (Columns.end () == Columns.find (j+1)) Data[i].push_back (Result.Data[i][j]); Result.Data = Data; }
NumericMatrix<V, I, S> NumericMatrix<V, I, S>::operator - (const NumericMatrix<V, I, S>& m) const { // Subtract the elements // Create new matrix with same size and same starting index NumericMatrix<V, I, S> result(Rows(), Columns(), MinRowIndex(), MinColumnIndex()); print(result); // Add all elements for (I r1 = MinRowIndex(); r1<=MaxRowIndex(); r1++) { for (I c1=MinColumnIndex(); c1<=MaxColumnIndex(); c1++) result(r1, c1) = (*this)(r1, c1) - m(r1, c1); } // Return the result return result; }
NumericMatrix<V, I, S> NumericMatrix<V, I, S>::operator - () const { // Unary minus // Create new matrix with same size and same starting index NumericMatrix<V, I, S> result(Rows(), Columns(), MinRowIndex(), MinColumnIndex()); // Copy all elements negative for (I r=MinRowIndex(); r<=MaxRowIndex(); r++) { for (I c=MinColumnIndex(); c<=MaxColumnIndex(); c++) { result(r,c) = -(*this)(r,c); } } // Return the result return result; }
bool Board::checkNeighborhood(std::pair< char, int > first, std::pair< char, int > second) { // not moving must be valid as well if (first.first == second.first && first.second == second.second) return true; int row = ((int) second.first) - 64; // moving over more than one row index if (((int)first.first)-((int)second.first) < -1 || ((int)first.first)-((int)second.first) > 1) return false; // jumping diagonally else if (((int)first.first)-((int)second.first) != 0 && first.second != second.second) return false; // exceeding boundaries if (row < 0 || row > Rows()) return false; if (((int) first.second)-((int) second.second) < -1 || ((int) first.second)-((int) second.second) > 1) return false; else if (((int)first.second)-((int)second.second) != 0 && first.first != second.first) return false; if (second.second < 0 || second.second > Columns()) return false; return true; }
bool SideWinderMaze::HasNext() const { return (i_ <= Columns() - 2); }
/** Returns the total number of elements in a GSL matrix */ size_t GSLUtility::size(const gsl_matrix *m) const { return (Rows(m) * Columns(m)); }
void WrapperDLL::Tool_Columns(void* self,int count){ auto self_ = (Tool*)self; auto arg0 = count; self_->Columns(arg0); };
I Matrix<V, I, S>::MaxColumnIndex() const { // Return the maximum column index return m_columnstart + Columns() - 1; }
// visualisation is very huebsch now void Board::visualise(std::pair<char, int> Pl1, std::pair<char, int> Pl2, std::pair<char, int> Pl3, std::pair<char, int> Pl4) { // ich bin ein Fan von deklarierten Variablen int i, j, k; char c; // 1.Zeile: Spaltennummern, jede Zelle soll alle Spielernummern anthalten können std::cout << " "; for (i=0; i < Columns(); i++) { if(i<10) {std::cout << " " << i << " ";} else {std::cout << " " << i << " ";} } std::cout << std::endl; // dann kommen die weiteren Zeilen, Zeilennummer am Anfang ist hübscher, aber kostet etwas mehr Aufwand // ausserdem machen wir jede Zeile 2 breit, damit alle Spielernummern reinpassen for( i = 0; i < b->nRows(); i=i+2) { // produzieren in jedem schleifendurchlauf eine zwischenzeile und eine "spielerzeile" // Zwischenzeile std:: cout << " "; for(j=1; j< b->nColumns(); j=j+2) { // uncomment ! to draw almost all walls, as well in line 132 if(/*!*/(b->at(i,j))) { std::cout << "+-----"; } else { std::cout << "+ "; } } std:: cout << "+" << std::endl; // Und jetzt eine Spielerzeile // Aufgrund der Konstruktion eine Abfrage obs die Überhaupt gibt if(i==(b->nRows()-1)) break; // Setzen Beschriftung in c c = (int)'A'+i/2; // Wollen die Zeilen 2 breit haben for(k=0; k<2 ; k++) { if(k==0) std:: cout << " " << c << " "; if(k==1) std:: cout << " "; for(j=0; j<b->nColumns(); j++) { // Wand oder leer if(!(j%2)) { if(/*!*/(b->at(i+1,j))) {std:: cout << "|";} else {std::cout << " ";} } // Spielfeld else { if(k==0) { if((Pl1.first==c)&&((Pl1.second*2+1)==j)) {std::cout << " 1";} else { if ((CurrentTarget.first==c)&&((CurrentTarget.second)*2+1==j)) {std::cout << " +";} else {std::cout << " ";} } std::cout << " "; if((Pl2.first==c)&&((Pl2.second*2+1)==j)) {std::cout << "2 ";} else { if ((CurrentTarget.first==c)&&((CurrentTarget.second)*2+1==j)) {std::cout << "+ ";} else {std::cout << " ";} } } else { if((Pl3.first==c)&&((Pl3.second*2+1)==j)) {std::cout << " 3";} else { if ((CurrentTarget.first==c)&&((CurrentTarget.second)*2+1==j)) {std::cout << " +";} else {std::cout << " ";} } std::cout << " "; if((Pl4.first==c)&&((Pl4.second*2+1)==j)) {std::cout << "4 ";} else { if ((CurrentTarget.first==c)&&((CurrentTarget.second)*2+1==j)) {std::cout << "+ ";} else {std::cout << " ";} } } } } std:: cout << std::endl; } } }