Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <ctime>
- #include <iostream>
- #include <algorithm>
- #include <cmath>
- #include <conio.h>
- #include <stdio.h>
- #include <Windows.h>
- #include <vector>
- #include <set>
- #include <tuple>
- using namespace std;
- const int MAX_SIZE = 100;
- const double eps = 1e-6;
- struct matrix{
- int x = 0, y = 0;
- double det = 1;
- double a[101][101],b[101][101];
- matrix(){};
- matrix(int x, int y) : x(x), y(y) {
- for (int i = 0; i < y;i++)
- for (int j = 0; j < x; j++)
- scanf("%lf",&this->a[i][j]);
- };
- matrix(double q[101][101], int x, int y) : x(x), y(y){
- for (int i = 0; i < y; i++)
- for (int j = 0; j < x; j++)
- this->a[i][j] = q[i][j];
- }
- void print_matrix(){
- for (int i = 0; i < this->y; i++){
- for (int j = 0; j < this->x; j++)
- printf("%lf ", this->a[i][j]);
- printf("\n");
- }
- printf("\n");
- }
- void transposition(){
- for (int i = 0; i < this->y;i++)
- for (int j = i; j < this->x ; j++)
- {
- double p = this->a[i][j];
- this->a[i][j] = this->a[j][i];
- this->a[j][i] = p;
- }
- swap(this->x, this->y);
- }
- void calc_reverse(){
- this->det = 1;
- for (int i = 0; i < this->y; i++)
- for (int j = 0; j < this->x; j++)
- this->b[i][j] = this->a[i][j];
- for (int i = 0; i < this->y; i++){
- }
- }
- public:
- matrix & operator = (matrix & A2){
- for (int i = 0; i < A2.y; i++)
- for (int j = 0; j < A2.x; j++){
- this->a[i][j] = A2.a[i][j];
- }
- return *this;
- }
- matrix & operator += (matrix & A2){
- if (this->x != A2.x || this->y != A2.y)return *this;
- for (int i = 0; i < this->y; i++)
- for (int j = 0; j < this->x; j++){
- this->a[i][j] += A2.a[i][j];
- }
- return *this;
- }
- matrix & operator *= (matrix & A2){
- if (this->x != A2.y) return *this;
- double buffer[101][101] = { { } };
- for (int i = 0; i < this->y; i++)
- for (int j = 0; j < A2.x; j++)
- for (int q = 0; q < this->x; q++)
- buffer[i][j] += this->a[i][q] * A2.a[q][j];
- for (int i = 0; i < this->y; i++)
- for (int j = 0; j < A2.x; j++) this->a[i][j] = buffer[i][j];
- return *this;
- }
- matrix & operator * (matrix & A2){
- if (this->x != A2.y) return *this;
- double buffer[101][101] = { {} };
- for (int i = 0; i < this->y; i++)
- for (int j = 0; j < A2.x; j++)
- for (int q = 0; q < this->x; q++)
- buffer[i][j] += this->a[i][q] * A2.a[q][j];
- return * new matrix(buffer,A2.x,this->y);
- }
- matrix & operator + (matrix & A2){
- if (this->x != A2.x || this->y != A2.y)return *this;
- double buffer[101][101] = { {} };
- for (int i = 0; i < this->y; i++)
- for (int j = 0; j < this->x; j++){
- buffer[i][j] = this->a[i][j] + A2.a[i][j];
- }
- return *new matrix(buffer, A2.x, this->y);
- }
- };
- matrix pow_matrix(int val, matrix a){
- matrix b = a;
- while (val){
- if (val & 1){
- a *= b;
- val--;
- }
- else{
- a *= a;
- val /= 2;
- }
- return a;
- }
- }
- int main() {
- int n, m, k, l, r;
- scanf("%i %i",&n,&m);
- matrix A(n, m);
- Sleep(10000000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement