Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Zeitlhofer
ESE_Zeitlhofer_Bajer
Commits
9f002cd5
Commit
9f002cd5
authored
Jun 17, 2020
by
Mario Bajer
Browse files
code review + projektabgabe notes
parent
7feec40d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Matrix.cpp
View file @
9f002cd5
...
...
@@ -7,7 +7,7 @@
std
::
mutex
m
;
void
Matrix
::
print
(
std
::
ostream
&
a_r0s
){
void
Matrix
::
print
(
std
::
ostream
&
a_r0s
){
// refactor auf z.B: "renderHTML"
for
(
int
i
=
0
;
i
<
this
->
dimx
;
i
++
){
a_r0s
<<
"<p>"
;
for
(
int
j
=
0
;
j
<
this
->
dimy
;
j
++
){
...
...
@@ -18,8 +18,8 @@ void Matrix::print(std::ostream& a_r0s){
}
void
Matrix
::
fillRND
()
{
std
::
mt19937
engine
(
std
::
random_device
{}());
std
::
uniform_int_distribution
<
uint64_t
>
distribution
;
static
std
::
mt19937
engine
(
std
::
random_device
{}());
//static damit nicht bei jedem call neues obj erstellt wird
static
std
::
uniform_int_distribution
<
uint64_t
>
distribution
;
for
(
int
i
=
0
;
i
<
datasize
;
i
++
){
data
[
i
]
=
distribution
(
engine
);
}
...
...
@@ -34,7 +34,7 @@ int Matrix::generateID() {
json
jcreate
;
jcreate
[
"counter"
]
=
0
;
ofstream
ocreate
;
ocreate
.
open
(
configloc
);
ocreate
.
open
(
configloc
);
//abfangen obs auch wirklich aufgegangen is!
ocreate
<<
jcreate
<<
endl
;
ocreate
.
close
();
cout
<<
"<p> config.json did not exist. Created config.json with counter 0"
<<
endl
;
...
...
@@ -54,7 +54,7 @@ int Matrix::generateID() {
return
ID
;
}
int
Matrix
::
saveMatrix
(){
int
Matrix
::
saveMatrix
(){
// sollte mit parameter "folderpath" aufgerufen werden oder geöffnetem stream von außen
ID
=
generateID
();
string
folderpath
=
"Json/"
;
...
...
@@ -63,7 +63,7 @@ int Matrix::saveMatrix(){
ofstream
o
;
o
.
open
(
folderpath
);
o
<<
ID
<<
","
<<
dimx
<<
","
<<
dimy
<<
","
<<
endl
;
o
.
seekp
(
50
,
std
::
ofstream
::
beg
);
o
.
seekp
(
50
,
std
::
ofstream
::
beg
);
// trennung durch newline
for
(
int
i
=
0
;
i
<
datasize
;
i
++
){
unsigned
char
val
[
sizeof
(
uint64_t
)];
memcpy
(
val
,
&
data
[
i
],
sizeof
(
uint64_t
));
...
...
@@ -93,7 +93,7 @@ void Matrix::getmatrixfromfile( const string& path) {
int
i
=
0
;
string
param
;
vector
<
string
>
input
;
while
(
getline
(
in
,
param
,
','
)){
while
(
getline
(
in
,
param
,
','
)){
//sollte static funktion sein die genau diese 7 zeilen ausführt
input
.
push_back
(
param
);
i
++
;
if
(
i
==
3
){
...
...
list.cpp
View file @
9f002cd5
...
...
@@ -51,7 +51,7 @@ int main(){
string
path
=
"Json"
;
for
(
const
auto
&
entry
:
fs
::
directory_iterator
(
path
)){
for
(
const
auto
&
entry
:
fs
::
directory_iterator
(
path
)){
// https://github.com/pantor/inja#loops
vector
<
string
>
rs
=
parseHeader
(
entry
.
path
());
cout
<<
"<tr>"
<<
endl
;
cout
<<
"<td>"
<<
rs
[
0
]
<<
"</td>"
<<
endl
;
...
...
multi.cpp
View file @
9f002cd5
...
...
@@ -8,7 +8,7 @@
#include
<thread>
#define MAX_THREADS 4
void
callMult
(
Matrix
*
a
,
Matrix
*
b
,
Matrix
c
,
size_t
from
,
size_t
to
){
void
callMult
(
Matrix
*
a
,
Matrix
*
b
,
Matrix
c
,
size_t
from
,
size_t
to
){
// c auch als ref!
c
.
threadedmult
(
a
,
b
,
from
,
to
);
}
...
...
@@ -55,7 +55,7 @@ int main(){
auto
start
=
std
::
chrono
::
high_resolution_clock
::
now
();
if
(
stoi
(
matrixA
[
2
])
>=
(
2
*
MAX_THREADS
))
{
for
(
size_t
i
=
0
;
i
<
MAX_THREADS
;
i
++
)
{
matrixthread
[
i
]
=
thread
(
callMult
,
&
a
,
&
b
,
c
,
(
i
*
tsize
),
(
i
*
tsize
)
+
tsize
-
1
);
matrixthread
[
i
]
=
thread
(
callMult
,
&
a
,
&
b
,
c
,
(
i
*
tsize
),
(
i
*
tsize
)
+
tsize
-
1
);
// c als ref
}
for
(
size_t
i
=
0
;
i
<
MAX_THREADS
;
i
++
)
{
matrixthread
[
i
].
join
();
...
...
notmatrix.cpp
View file @
9f002cd5
#include
"notmatrix.hpp"
bool
existsm
(
const
string
&
filename
){
bool
existsm
(
const
string
&
filename
){
// https://en.cppreference.com/w/cpp/filesystem/exists
ifstream
f
(
filename
);
return
f
.
good
();
}
...
...
@@ -16,7 +16,7 @@ void htmlHeader(const string& title){
cout
<<
"</head>"
<<
endl
;
}
string
parseCgiElement
(
Cgicc
formData
,
const
string
&
elementName
){
string
parseCgiElement
(
Cgicc
formData
,
const
string
&
elementName
){
// const Cgicc& für ref
auto
fi
=
formData
.
getElement
(
elementName
);
if
(
!
fi
->
isEmpty
()
&&
fi
!=
(
*
formData
).
end
())
{
return
**
fi
;
...
...
@@ -28,7 +28,7 @@ string parseCgiElement(Cgicc formData, const string& elementName){
}
}
vector
<
string
>
parseHeader
(
filesystem
::
path
filepath
){
vector
<
string
>
parseHeader
(
filesystem
::
path
filepath
){
// const path& // in matrix Klasse verschieben (ist keine util)
ifstream
inFile
(
filepath
);
int
i
=
0
;
string
param
;
...
...
notmatrix.hpp
View file @
9f002cd5
...
...
@@ -38,7 +38,7 @@ string parseCgiElement(Cgicc formData, const string& elementName);
/** @brief Trennt die Header Parameter von den Daten ab und gibt diese als string zurück.
*
* Die Daten werden in folgendem Format gespeichert.
*
id:
{id},
dimx:
{dimx},
dimy:
{dimy}\n
* {id},{dimx},{dimy}\n
* {data}
* Es wird die erste Zeile übergeben und alle per ',' werden nacheinander in den vector gepushed.
*
...
...
show.cpp
View file @
9f002cd5
...
...
@@ -5,7 +5,7 @@
#include
"Matrix.hpp"
#include
"notmatrix.hpp"
int
main
(){
int
main
(){
// idee: schwarz/weiß pixel zur darstellung von matrixelementen mit https://www.w3schools.com/html/html5_canvas.asp
Cgicc
formData
;
htmlHeader
(
"show.cgi"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment