Added some initial data likle Makefiles and .gitignore.

This commit is contained in:
François Coppens 2021-01-26 07:26:54 +01:00
parent 3704856b10
commit d286e0d45e
4 changed files with 59 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.o
SM-MaponiA3

6
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"files.associations": {
"ostream": "cpp",
"new": "cpp"
}
}

12
Makefile Normal file
View File

@ -0,0 +1,12 @@
CC=icc
CXX=icpc
CFLAGS=
DEPS = SM-MaponiA3.cpp
OBJ = SM-MaponiA3.o
%.o: %.c $(DEPS)
$(CXX) -c -o $@ $< $(CFLAGS)
SM-MaponiA3: $(OBJ)
$(CXX) -o $@ $^ $(CFLAGS)

39
SM-MaponiA3.cpp Normal file
View File

@ -0,0 +1,39 @@
// Algorithm 3 from P. Maponi,
// p. 283, doi:10.1016/j.laa.2006.07.007
#include <iostream>
using namespace std;
int M=3;
int N=3;
int main() {
int** A = new int*[N];
for (int i = 0; i < N; i++) {
A[i] = new int[M];
}
A[0][0] = 1;
A[0][1] = 1;
A[0][2] = -1;
A[1][0] = 1;
A[1][1] = 1;
A[1][2] = 0;
A[2][0] = -1;
A[2][1] = 0;
A[2][2] = -1;
for (int i = 0; i < M; i++) {
for (int j = 0; j < N; j++) {
cout << "A["<<i<<"]["<<j<<"] = " << A[i][j] << " ";
}
cout << endl;
}
for (int i = 0; i < N; i++) {
delete [] A[i];
}
delete [] A;
return 0;
}