forked from UNN-ITMM-Software/mp2-lab2-matrix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
place initial version of lab2 template
- Loading branch information
Showing
11 changed files
with
30,753 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
// ННГУ, ВМК, Курс "Методы программирования-2", С++, ООП | ||
// | ||
// utmatrix.h - Copyright (c) Гергель В.П. 07.05.2001 | ||
// Переработано для Microsoft Visual Studio 2008 Сысоевым А.В. (21.04.2015) | ||
// | ||
// Верхнетреугольная матрица - реализация на основе шаблона вектора | ||
|
||
#ifndef __TMATRIX_H__ | ||
#define __TMATRIX_H__ | ||
|
||
#include <iostream> | ||
|
||
using namespace std; | ||
|
||
const int MAX_VECTOR_SIZE = 100000000; | ||
const int MAX_MATRIX_SIZE = 10000; | ||
|
||
// Шаблон вектора | ||
template <class ValType> | ||
class TVector | ||
{ | ||
protected: | ||
ValType *pVector; | ||
int Size; // размер вектора | ||
int StartIndex; // индекс первого элемента вектора | ||
public: | ||
TVector(int s = 10, int si = 0); | ||
TVector(const TVector &v); // конструктор копирования | ||
~TVector(); | ||
int GetSize() { return Size; } // размер вектора | ||
int GetStartIndex(){ return StartIndex; } // индекс первого элемента | ||
ValType& operator[](int pos); // доступ | ||
bool operator==(const TVector &v) const; // сравнение | ||
bool operator!=(const TVector &v) const; // сравнение | ||
TVector& operator=(const TVector &v); // присванивание | ||
|
||
// скалярные операции | ||
TVector operator+(const ValType &val); // прибавить скаляр | ||
TVector operator-(const ValType &val); // вычесть скаляр | ||
TVector operator*(const ValType &val); // умножить на скаляр | ||
|
||
// векторные операции | ||
TVector operator+(const TVector &v); // сложение | ||
TVector operator-(const TVector &v); // вычитание | ||
ValType operator*(const TVector &v); // скалярное произведение | ||
|
||
// ввод-вывод | ||
friend istream& operator>>(istream &in, TVector &v) | ||
{ | ||
for (int i = 0; i < v.Size; i++) | ||
in >> v.pVector[i]; | ||
return in; | ||
} | ||
friend ostream& operator<<(ostream &out, const TVector &v) | ||
{ | ||
for (int i = 0; i < v.Size; i++) | ||
out << v.pVector[i] << ' '; | ||
return out; | ||
} | ||
}; | ||
|
||
template <class ValType> | ||
TVector<ValType>::TVector(int s, int si) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> //конструктор копирования | ||
TVector<ValType>::TVector(const TVector<ValType> &v) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> | ||
TVector<ValType>::~TVector() | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // доступ | ||
ValType& TVector<ValType>::operator[](int pos) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // сравнение | ||
bool TVector<ValType>::operator==(const TVector &v) const | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // сравнение | ||
bool TVector<ValType>::operator!=(const TVector &v) const | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // присваивание | ||
TVector<ValType>& TVector<ValType>::operator=(const TVector &v) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // прибавить скаляр | ||
TVector<ValType> TVector<ValType>::operator+(const ValType &val) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // вычесть скаляр | ||
TVector<ValType> TVector<ValType>::operator-(const ValType &val) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // умножить на скаляр | ||
TVector<ValType> TVector<ValType>::operator*(const ValType &val) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // сложение | ||
TVector<ValType> TVector<ValType>::operator+(const TVector<ValType> &v) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // вычитание | ||
TVector<ValType> TVector<ValType>::operator-(const TVector<ValType> &v) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // скалярное произведение | ||
ValType TVector<ValType>::operator*(const TVector<ValType> &v) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
|
||
// Верхнетреугольная матрица | ||
template <class ValType> | ||
class TMatrix : public TVector<TVector<ValType> > | ||
{ | ||
public: | ||
TMatrix(int s = 10); | ||
TMatrix(const TMatrix &mt); // копирование | ||
TMatrix(const TVector<TVector<ValType> > &mt); // преобразование типа | ||
bool operator==(const TMatrix &mt) const; // сравнение | ||
bool operator!=(const TMatrix &mt) const; // сравнение | ||
TMatrix& operator= (const TMatrix &mt); // присваивание | ||
TMatrix operator+ (const TMatrix &mt); // сложение | ||
TMatrix operator- (const TMatrix &mt); // вычитание | ||
|
||
// ввод / вывод | ||
friend istream& operator>>(istream &in, TMatrix &mt) | ||
{ | ||
for (int i = 0; i < mt.Size; i++) | ||
in >> mt.pVector[i]; | ||
return in; | ||
} | ||
friend ostream & operator<<( ostream &out, const TMatrix &mt) | ||
{ | ||
for (int i = 0; i < mt.Size; i++) | ||
out << mt.pVector[i] << endl; | ||
return out; | ||
} | ||
}; | ||
|
||
template <class ValType> | ||
TMatrix<ValType>::TMatrix(int s): TVector<TVector<ValType> >(s) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // конструктор копирования | ||
TMatrix<ValType>::TMatrix(const TMatrix<ValType> &mt): | ||
TVector<TVector<ValType> >(mt) {} | ||
|
||
template <class ValType> // конструктор преобразования типа | ||
TMatrix<ValType>::TMatrix(const TVector<TVector<ValType> > &mt): | ||
TVector<TVector<ValType> >(mt) {} | ||
|
||
template <class ValType> // сравнение | ||
bool TMatrix<ValType>::operator==(const TMatrix<ValType> &mt) const | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // сравнение | ||
bool TMatrix<ValType>::operator!=(const TMatrix<ValType> &mt) const | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // присваивание | ||
TMatrix<ValType>& TMatrix<ValType>::operator=(const TMatrix<ValType> &mt) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // сложение | ||
TMatrix<ValType> TMatrix<ValType>::operator+(const TMatrix<ValType> &mt) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
template <class ValType> // вычитание | ||
TMatrix<ValType> TMatrix<ValType>::operator-(const TMatrix<ValType> &mt) | ||
{ | ||
} /*-------------------------------------------------------------------------*/ | ||
|
||
// TVector О3 Л2 П4 С6 | ||
// TMatrix О2 Л2 П3 С3 | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// ННГУ, ВМК, Курс "Методы программирования-2", С++, ООП | ||
// | ||
// sample_matrix.cpp - Copyright (c) Гергель В.П. 07.05.2001 | ||
// Переработано для Microsoft Visual Studio 2008 Сысоевым А.В. (20.04.2015) | ||
// | ||
// Тестирование верхнетреугольной матрицы | ||
|
||
#include <iostream> | ||
#include "utmatrix.h" | ||
//--------------------------------------------------------------------------- | ||
|
||
void main() | ||
{ | ||
TMatrix<int> a(5), b(5), c(5); | ||
int i, j; | ||
|
||
setlocale(LC_ALL, "Russian"); | ||
cout << "Тестирование программ поддержки представления треугольных матриц" | ||
<< endl; | ||
for (i = 0; i < 5; i++) | ||
for (j = i; j < 5; j++ ) | ||
{ | ||
a[i][j] = i * 10 + j; | ||
b[i][j] = (i * 10 + j) * 100; | ||
} | ||
c = a + b; | ||
cout << "Matrix a = " << endl << a << endl; | ||
cout << "Matrix b = " << endl << b << endl; | ||
cout << "Matrix c = a + b" << endl << c << endl; | ||
} | ||
//--------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<?xml version="1.0" encoding="windows-1251"?> | ||
<VisualStudioProject | ||
ProjectType="Visual C++" | ||
Version="9,00" | ||
Name="gtest" | ||
ProjectGUID="{60932AFC-7808-48B7-B3BF-F2BC151C0065}" | ||
RootNamespace="gtest" | ||
Keyword="Win32Proj" | ||
TargetFrameworkVersion="196613" | ||
> | ||
<Platforms> | ||
<Platform | ||
Name="Win32" | ||
/> | ||
</Platforms> | ||
<ToolFiles> | ||
</ToolFiles> | ||
<Configurations> | ||
<Configuration | ||
Name="Debug|Win32" | ||
OutputDirectory="$(SolutionDir)$(ConfigurationName)" | ||
IntermediateDirectory="$(ConfigurationName)" | ||
ConfigurationType="4" | ||
CharacterSet="1" | ||
> | ||
<Tool | ||
Name="VCPreBuildEventTool" | ||
/> | ||
<Tool | ||
Name="VCCustomBuildTool" | ||
/> | ||
<Tool | ||
Name="VCXMLDataGeneratorTool" | ||
/> | ||
<Tool | ||
Name="VCWebServiceProxyGeneratorTool" | ||
/> | ||
<Tool | ||
Name="VCMIDLTool" | ||
/> | ||
<Tool | ||
Name="VCCLCompilerTool" | ||
Optimization="0" | ||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GTEST_EXPORTS" | ||
MinimalRebuild="true" | ||
BasicRuntimeChecks="3" | ||
RuntimeLibrary="3" | ||
UsePrecompiledHeader="0" | ||
WarningLevel="3" | ||
DebugInformationFormat="4" | ||
/> | ||
<Tool | ||
Name="VCManagedResourceCompilerTool" | ||
/> | ||
<Tool | ||
Name="VCResourceCompilerTool" | ||
/> | ||
<Tool | ||
Name="VCPreLinkEventTool" | ||
/> | ||
<Tool | ||
Name="VCLibrarianTool" | ||
/> | ||
<Tool | ||
Name="VCALinkTool" | ||
/> | ||
<Tool | ||
Name="VCXDCMakeTool" | ||
/> | ||
<Tool | ||
Name="VCBscMakeTool" | ||
/> | ||
<Tool | ||
Name="VCFxCopTool" | ||
/> | ||
<Tool | ||
Name="VCPostBuildEventTool" | ||
/> | ||
</Configuration> | ||
<Configuration | ||
Name="Release|Win32" | ||
OutputDirectory="$(SolutionDir)$(ConfigurationName)" | ||
IntermediateDirectory="$(ConfigurationName)" | ||
ConfigurationType="4" | ||
CharacterSet="1" | ||
WholeProgramOptimization="1" | ||
> | ||
<Tool | ||
Name="VCPreBuildEventTool" | ||
/> | ||
<Tool | ||
Name="VCCustomBuildTool" | ||
/> | ||
<Tool | ||
Name="VCXMLDataGeneratorTool" | ||
/> | ||
<Tool | ||
Name="VCWebServiceProxyGeneratorTool" | ||
/> | ||
<Tool | ||
Name="VCMIDLTool" | ||
/> | ||
<Tool | ||
Name="VCCLCompilerTool" | ||
Optimization="2" | ||
EnableIntrinsicFunctions="true" | ||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GTEST_EXPORTS" | ||
RuntimeLibrary="2" | ||
EnableFunctionLevelLinking="true" | ||
UsePrecompiledHeader="0" | ||
WarningLevel="3" | ||
DebugInformationFormat="3" | ||
/> | ||
<Tool | ||
Name="VCManagedResourceCompilerTool" | ||
/> | ||
<Tool | ||
Name="VCResourceCompilerTool" | ||
/> | ||
<Tool | ||
Name="VCPreLinkEventTool" | ||
/> | ||
<Tool | ||
Name="VCLibrarianTool" | ||
/> | ||
<Tool | ||
Name="VCALinkTool" | ||
/> | ||
<Tool | ||
Name="VCXDCMakeTool" | ||
/> | ||
<Tool | ||
Name="VCBscMakeTool" | ||
/> | ||
<Tool | ||
Name="VCFxCopTool" | ||
/> | ||
<Tool | ||
Name="VCPostBuildEventTool" | ||
/> | ||
</Configuration> | ||
</Configurations> | ||
<References> | ||
</References> | ||
<Files> | ||
<Filter | ||
Name="Source Files" | ||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" | ||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" | ||
> | ||
<File | ||
RelativePath="..\..\gtest\gtest-all.cc" | ||
> | ||
</File> | ||
</Filter> | ||
<Filter | ||
Name="Header Files" | ||
Filter="h;hpp;hxx;hm;inl;inc;xsd" | ||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" | ||
> | ||
<File | ||
RelativePath="..\..\gtest\gtest.h" | ||
> | ||
</File> | ||
</Filter> | ||
</Files> | ||
<Globals> | ||
</Globals> | ||
</VisualStudioProject> |
Oops, something went wrong.