forked from swarupgt/Matrix-operations-library
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bools.c
57 lines (52 loc) · 860 Bytes
/
bools.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include "MatrixLibrary.h"
bool isSymmetric(Matrix a)
{
if (compareMatrices(a, transpose(a)))
{
return true;
} else {
return false;
}
}
bool isAntisymmetric(Matrix a)
{
if (compareMatrices(a, scalarMultiply(transpose(a), -1)))
{
return true;
} return false;
}
bool isInvolutary(Matrix a)
{
if (compareMatrices(mulMatrices(a, a), identity(a.r)))
{
return true;
} return false;
}
bool compareMatrices(Matrix a, Matrix b)
{
if (a.r == b.r && a.c == b.c)
{
for (int i = 0; i < a.r; i++)
{
for (int j = 0; j < a.c; j++)
{
if (a.MatPtr[i][j] != b.MatPtr[i][j])
{
return false;
}
}
}
return true;
} else return false;
}
bool isIdempotent(Matrix a)
{
if (compareMatrices(matMul(a,a), a))
{
return true;
} else return false;
}