Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101641981
utility.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Feb 12, 09:08
Size
1 KB
Mime Type
text/x-c
Expires
Fri, Feb 14, 09:08 (2 d)
Engine
blob
Format
Raw Data
Handle
24206647
Attached To
R10834 Project_multiproc
utility.h
View Options
/*
============================================================================
Filename : utility.h
Author : Arash Pourhabibi
============================================================================
*/
#ifndef UTILITYH
#define UTILITYH
struct
timeval
start
,
finish_time
;
void
set_clock
()
{
gettimeofday
(
&
start
,
NULL
);
}
double
elapsed_time
()
{
gettimeofday
(
&
finish_time
,
NULL
);
double
elapsed
=
(
finish_time
.
tv_sec
-
start
.
tv_sec
);
elapsed
+=
(
double
)(
finish_time
.
tv_usec
-
start
.
tv_usec
)
/
1000000.0
;
return
elapsed
;
}
//Initialize the two-dimensional array
void
init
(
double
*
x
,
int
length
)
{
memset
(
x
,
0
,
sizeof
(
double
)
*
length
*
length
);
x
[(
length
/
2
-
1
)
*
length
+
(
length
/
2
-
1
)]
=
1000
;
x
[(
length
/
2
)
*
length
+
(
length
/
2
-
1
)]
=
1000
;
x
[(
length
/
2
-
1
)
*
length
+
(
length
/
2
)]
=
1000
;
x
[(
length
/
2
)
*
length
+
(
length
/
2
)]
=
1000
;
}
//Save the two-dimensional array in a csv file
void
save
(
double
*
x
,
int
length
)
{
ofstream
output_file
;
output_file
.
open
(
"outputmatrix.csv"
);
for
(
int
i
=
0
;
i
<
length
;
i
++
)
{
for
(
int
j
=
0
;
j
<
length
-
1
;
j
++
)
output_file
<<
setprecision
(
4
)
<<
x
[
i
*
length
+
j
]
<<
";"
;
output_file
<<
setprecision
(
4
)
<<
x
[
i
*
length
+
length
-
1
]
<<
";"
<<
endl
;
}
output_file
.
close
();
}
#endif
Event Timeline
Log In to Comment