Exemplo n.º 1
0
void ExtendedTableData::getRows(uint64_t startRow, uint64_t rows, std::vector<DataChunk>& chunks) const {
    DataChunk delimiter((char*)"\t",1);
    DataChunk eol((char*)"\n",1);
    for (uint64_t row = startRow; row < startRow + rows; row++) {
        for (uint32_t col = 0; col < getColCount(); col++) {
            chunks.push_back(getColumn(row,col));
            if (col < getColCount() - 1) {
                chunks.push_back(delimiter);
            }
        }
        chunks.push_back(eol);
    }
}
Exemplo n.º 2
0
Matrix<_Type> invert()
	{
		int size = getRowCount();
		if (size != getColCount()){
			throw MatrixException("Invalid size");
			return *this;
			
		}
	Matrix<_Type> result(size, size, 0);
	_Type det = determinant();
	
	if (det == 0)
	{
		throw MatrixException("Determinant = 0");
		return *this;
		
	}
	_Type temp;
	bool _invert = false;
	for (int i = 0; i < size; i++) {
		for (int j = 0; j < size; j++) {
			temp = _invert ? 0 : 1;
			temp = minor(i, j);
			temp /= det;
			result.put(i, j, temp);
			_invert = !_invert;
			
		}
		
	}
	result = result.transposition();
	return result;
		
	}
Exemplo n.º 3
0
std::string DataSet::getRowString() const {
  string ret;

  int nonameCount = 0;
  for (int i = 0; i < getColCount(); i++) {
    if (i > 0) ret += ", ";
    ret += "'";
    const char *fieldName = getFields()[i].name;
    if (fieldName && *fieldName) {
      ret += fieldName;
    } else {
      ret += "Noname";
      ret += boost::lexical_cast<string>(nonameCount++);
    }
    ret += "' => ";
    const char *s = getField(i);
    if (s) {
      ret += "'";
      ret += escape(s);
      ret += "'";
    } else {
      ret += "NULL";
    }
  }
  return ret;
}
Exemplo n.º 4
0
Screen* ScreenMgr::getScreen(ResourceID id){
	uint32_t row = GetRow(id);
	uint32_t col = GetCol(id);
	if ( row-1 >=0 && col-1 >=0 && row -1 < getRowCount() && col -1 < getColCount()){
		return screens_[GetRow(id)-1][GetCol(id)-1];
	}else return 0;
}
Exemplo n.º 5
0
bool CMatrix::checkSymmetric() const{
	UINT Col = getColCount(), Row = getRowCount();
	bool flag = true;
	if (Col == Row)
	{
		UINT i = 0, j;
		while ((i < Row) && flag)
		{
			j = i + 1;
			while (j < Col)
			{
				if ((*this)[i][j] != (*this)[j][i]){
					flag = false;
					break;
				}
				j++;
			} // while (j < Col)
			i++;
		} // while ((i < Row) && flag)
	}
	else
	{
		flag = false;
	}
	
	return flag;
}
Exemplo n.º 6
0
CMatrix CMatrix::operator * (const CMatrix &arg)
{
	auto rows = getRowCount(), cols = arg.getColCount(),
		p = getColCount(), // = RowCount у второй матрицы
		p2 = arg.getRowCount();

	/* избыточно, ввести обработчик */
	if (p == p2) // ширина первой матрицы равна высоте второй?
	{
		CMatrix Res(rows, cols);
			for (auto i = 0; i < rows; i++)
			{
				for (auto j = 0; j < cols; j++)
				{
					for (auto k = 0; k < p; k++)
					{
						Res[i][j] += (*this)[i][k] * arg[k][j];
					}
				}
			}
			return Res;
	}
	else // не равна
	{
		return CMatrix(rows, cols); // возвращаем нулевую матрицу
	}
	
}
Exemplo n.º 7
0
void CMatrix::setSize(int n, int m){
	this->BaseMatrix::resize(n);
	if (n * m != 0 && m != getColCount())
	{
		for (int i = 0; i < n; i++)
			(*this)[i].resize(m);
	}
}
Exemplo n.º 8
0
CMatrix CMatrix::operator * (const TYPE num){
	UINT n = getRowCount(), m = getColCount();
	CMatrix Res(n, m);
	for (UINT i = 0; i < n; i++)
	{
		for (UINT j = 0; j < m; j++)
		{
			Res[i][j] = (*this)[i][j] * num;
		}
	}
	return Res;
}
Exemplo n.º 9
0
CMatrix CMatrix::flip(){
	int Col = getColCount(), Row = getRowCount();
	CMatrix Res(Col, Row);
	for (int i = 0; i < Col; i++)
	{
		for (int j = 0; j < Row; j++)
		{ 
			Res[i][j] = (*this)[j][i];
		}
	}
	return Res;
}
Exemplo n.º 10
0
CMatrix CMatrix::flip(){
	UINT Col = getColCount(), Row = getRowCount();
	CMatrix Res(Row, Col);

	for (UINT i = 0; i < Row; i++)
	{
		for (UINT j = 0; j < Col; j++)
		{ 
			Res[i][j] = (*this)[j][i];
		}
	}
	return Res;
}
Exemplo n.º 11
0
CMatrix CMatrix::operator * (const TYPE num)
{
	auto rows = getRowCount(), cols = getColCount();
	CMatrix Res(rows, cols);
	for (auto i = 0; i < rows; i++)
	{
		for (auto j = 0; j < cols; j++)
		{
			Res[i][j] = (*this)[i][j] * num;
		}
	}
	return Res;
}
Exemplo n.º 12
0
bool SoapExecution::process() {

    if (lastOffset == 0) {
        LOG_DEBUG("process url = " << getUrl()->getUrl());
        LOG_DEBUG("query: '" << getSql() << "'");

        prepareQuery();

        shared_ptr<Event> ev(new ExecutionStateChangeEvent(getId(),"CONNECTED"));
        fireEvent(ev);
    }

    auto source = getInPorts().at(0)->getResult();

    uint64_t row;
    for (row = lastOffset; row < lastOffset + chunkSize; row++) {
        auto range = TableDataFactory::getInstance().range(source,row,chunkSize);
        xmlNodePtr result = inputTemplate.transform(range);
        string response = callServer(getUrl(),as_string(result));
        auto rangeResult = outputTemplate.transform(response);
        if (!resultTable) {
            resultTable = TableDataFactory::getInstance().create("text",rangeResult->getColumns());
        }
        for (uint64_t rrow = 0; rrow < rangeResult->getRowCount(); rrow++) {
            vector<string> rv;
            for (uint32_t rcol = 0; rcol < rangeResult->getColCount(); rcol++) {
                rv.push_back(rangeResult->getValue(rrow,rcol));
            }
            resultTable->addRow(rv);
        }
    }

    shared_ptr<Event> rde(new ReceiveDataEvent(getId(),resultTable->getRowCount()));
    fireEvent(rde);

    if (row >= source->getRowCount()) {
        setResult("",resultTable);
        setState(QueryExecutionState::DONE);
        return true;
    }
    lastOffset = row;
    return false;
}
Exemplo n.º 13
0
// нужен обработчик на неравенство матриц
CMatrix CMatrix::operator * (const CMatrix &arg){
	UINT n = getRowCount(), m = arg.getColCount(),
		p = getColCount(), // = RowCount у второй матрицы
		p2 = arg.getRowCount();

	/* избыточно, ввести обработчик */
	if (p == p2) // ширина первой матрицы равна высоте второй?
	{
		CMatrix Res(n, m);
		for (UINT i = 0; i < n; i++)
		{
			for (UINT j = 0; j < m; j++)
			{
				for (UINT k = 0; k < p; k++)
				{
					Res[i][j] += (*this)[i][k] * arg[k][j];
				}
			}
		}
		return Res;
	}

	// не равна
	{
		std::string
			error, msg, place, reason,
			arg_reason, object;
		error = "Error: length_error: ";
		place = "CMatrix CMatrix::operator * (), size = (";
		reason = std::to_string(rowCount) + ", " + std::to_string(colCount);
		arg_reason = std::to_string(n) + ", " + std::to_string(m);
		object = std::to_string(UINT(this));

		msg =
			error + place + reason + "), arg.size = (" +
			arg_reason + "), Object = " + object;
		throw std::length_error(msg);
	}
	//return CMatrix(n, m); // возвращаем нулевую матрицу
}
Exemplo n.º 14
0
/*
	произведение матрицы на вектор-столбец. (строка на столбец)
	результат - вектор столбец.
*/
CVector CMatrix::operator * (const CVector &arg)
{
	auto rows = getRowCount(), cols = getColCount(),
		size = arg.getSize(); // длина вектора
	if (size == cols) // ширина матрицы свпадает с длиной вектора-столбца?
	{
		CVector Res(rows);
			for (auto i = 0; i < rows; i++)
			{
				for (auto j = 0; j < cols; j++)
				{
					Res[i] += (*this)[i][j] * arg[j];
				}
			}
			return Res;
	}
	else // не совпадает
	{
		return CVector(rows); // возвращаем нулевой вектор
	}
	
}
Exemplo n.º 15
0
// нужен обработчик на неравенство матрицы и вектора
CVector CMatrix::operator * (const CVector &arg){
	UINT n = getRowCount(), m = getColCount(),
		size = arg.getSize(); // длина вектора

	if (size == m) // ширина матрицы свпадает с длиной вектора-столбца?
	{
		CVector Res(n);
		for (UINT i = 0; i < n; i++)
		{
			for (UINT j = 0; j < m; j++)
			{
				Res[i] += (*this)[i][j] * arg[j];
			}
		}
		return Res;
	}

	// не совпадает
	{
		std::string
			error, msg, place, reason,
			arg_reason, object;
		error = "Error: length_error: ";
		place = "CVector CMatrix::operator * (), size = (";
		reason = std::to_string(rowCount) + ", " + std::to_string(colCount);
		arg_reason = std::to_string(size);
		object = std::to_string(UINT(this));

		msg =
			error + place + reason + "), size = " +
			arg_reason + ", Object = " + object;
		throw std::length_error(msg);
	}
	//return CVector(n); // возвращаем нулевой вектор
	
}
Exemplo n.º 16
0
bool CMatrix::checkSquare() const{
	bool Res;
	(getColCount() == getRowCount()) ? Res = true : Res = false;
	return Res;
}