本文整理汇总了C++中Matrix::GetColumns方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::GetColumns方法的具体用法?C++ Matrix::GetColumns怎么用?C++ Matrix::GetColumns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix::GetColumns方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: C
Matrix Matrix::operator*(Matrix oper)
{
float *B = oper.GetMatrix();
int RB = oper.GetRows();
int CB = oper.GetColumns();
Matrix C(oper.GetColumns(), GetColumns());
int CSize = C.GetColumns()*C.GetRows();
int Columns = C.GetColumns();
float *Result = C.GetMatrix();
Result[0] = A[0]*B[0] + A[1]*B[3] + A[2]*B[6];
Result[1] = A[0]*B[1] + A[1]*B[4] + A[2]*B[7];
Result[2] = A[0]*B[2] + A[1]*B[5] + A[2]*B[8];
Result[3] = A[3]*B[0] + A[4]*B[3] + A[5]*B[6];
Result[4] = A[3]*B[1] + A[4]*B[4] + A[5]*B[7];
Result[5] = A[3]*B[2] + A[4]*B[5] + A[5]*B[8];
Result[6] = A[6]*B[0] + A[7]*B[3] + A[8]*B[6];
Result[7] = A[6]*B[1] + A[7]*B[4] + A[8]*B[7];
Result[8] = A[6]*B[2] + A[7]*B[5] + A[8]*B[8];
return C;
}
示例2: PrintMatrix
void PrintMatrix(Matrix input, int MAX_X, int MAX_Y)
{
std::ofstream myfile;
myfile.open("example.txt");
myfile << "P1\n";
myfile << MAX_X << " " << MAX_Y << "\n";
int test = input.GetColumns();
int position = 0;
bool noMorePoints = false;
for (int i = 0; i < MAX_Y; i++)
{
for (int j = 0; j < MAX_X; j++)
{
if (!noMorePoints)
{
int XPosition = input.GetVal(0, position);
int YPosition = input.GetVal(1, position);
if (XPosition == i && YPosition == j)
{
myfile << "1 ";
position++;
}
else
{
myfile << "0 ";
}
if (position >= input.GetColumns())
{
noMorePoints = true;
}
}
else
{
myfile << "0 ";
}
}
myfile << "\n";
}
myfile.close();
}
示例3: GetRows
Matrix<char, float> Matrix<char, float>::operator*(const Matrix<char, float> & p_matrix) const
{
Matrix<char, float> matrix;
std::vector<char> rows = GetRows(), columns = GetColumns();
std::vector<char> _rows = p_matrix.GetRows(), _columns = p_matrix.GetColumns();
for(int i = 0; i < rows.size(); ++i)
{
for(int j = 0; j < _columns.size(); ++j)
{
matrix.m_values[Coord(rows[i], _columns[j])] = 0;
for(int k = 0; k < columns.size(); ++k)
{
matrix.m_values[Coord(rows[i], _columns[j])] += GetValue(rows[i], columns[k])*p_matrix.GetValue(_rows[k], _columns[j]);
}
}
}
return matrix;
}