예제 #1
0
	void AutoMatrix::removeColumn ( const size_t col ) {
		const size_t
			rows = countRows(),
			cols = countColumns();
		for ( size_t i = col + 1; i < cols; ++i ) {
			const Vector colSource = columnVector( i );
			Vector colTarget = columnVector( i - 1 );
			colTarget.copy( colSource );
		}
		upSize( rows, cols - 1 );
	}
예제 #2
0
const Vector<T> TriDiagonalMatrix<T>::getColumn(const int column) const
{
  if(column < 0 || column >= numColumns())
  {
    throw std::invalid_argument("Column number is invalid");
  }

  Vector<T> columnVector(numColumns());

  for(int i = 0; i < columnVector.numTerms(); i++)
  {
    columnVector[i] = 0;
  }

  if(column == 0)
  {
    columnVector[0] = data[1][column];
    columnVector[1] = data[0][column];
  }
  else if(column == numColumns() - 1)
  {
    columnVector[column - 1] = data[2][column - 1];
    columnVector[column] = data[1][column];
  }
  else
  {
    columnVector[column - 1] = data[2][column - 1];
    columnVector[column] = data[1][column];
    columnVector[column + 1] = data[0][column];
  }
  return columnVector;
}
예제 #3
0
TableSummary::TableSummary(tableVector const &tables, columnVector const &summaryColumns)
{
	Table *sumTable;
	Filter filter;

	for (tableVector::const_iterator it = tables.begin(); it != tables.end(); it++) {
		sumTable = (*it)->createTableCopy();

		if (sumTable == NULL) continue;

		sumTable->aggregate(columnVector(), summaryColumns, filter, true);
		
		Cursor *cur = sumTable->createCursor();
		if (cur->next()) { /* summary table has some lines (is not filtered out) */
			for (auto col: summaryColumns) {
				Values val;
				std::string name = col->getSummaryType() + col->getSelectName();
				if (cur->getColumn(name,  val, 0)) { /* add value if available  */
//					std::cout << name << " " << val.toDouble() << std::endl;
					if (col->isAvgSummary()) {
						this->values[name] += (val.toDouble(0) * (*it)->nRows());
						this->occurences[name] += (*it)->nRows();
					} else {
						this->values[name] += val.toDouble(0);
					}
				}
			}
		}
		delete cur;

		delete sumTable;
	}
	
	for (auto colpair: this->occurences) {
//		std::cout << colpair.first << ": " << this->values[colpair.first] << "/" << colpair.second << std::endl;
		this->values[colpair.first] /= (double) colpair.second;
	}
}
예제 #4
0
	Vector AutoMatrix::newColumn () {
		const size_t col = countColumns();
		upSize( countRows(), col + 1 );
		return columnVector( col );
	}