WSL/SLF GitLab Repository
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-hydrology
SnowQM
Commits
1a0302e9
Commit
1a0302e9
authored
Feb 09, 2022
by
Adrien Michel
Browse files
Code cleaning
parent
2e55df38
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/snow_days_comparison.cpp
View file @
1a0302e9
...
...
@@ -54,17 +54,13 @@ Rcpp::List snowDaysComparisonCpp(const NumericMatrix data_1,
bool
interrupt
=
false
;
// Convert R object to proper c++ object since R objects are not thread safe
std
::
clock_t
start
;
start
=
std
::
clock
();
const
size_t
num_pixels
=
data_1
.
nrow
();
const
size_t
num_years
=
indices
.
size
();
std
::
vector
<
std
::
vector
<
size_t
>
>
indices_cpp
(
num_years
);
for
(
size_t
i
=
0
;
i
<
num_years
;
++
i
)
{
indices_cpp
[
i
]
=
Rcpp
::
as
<
std
::
vector
<
size_t
>
>
(
indices
[
i
]);
}
const
std
::
vector
<
double
>
data_1_cpp
=
Rcpp
::
as
<
std
::
vector
<
double
>
>
((
data_1
));
const
std
::
vector
<
double
>
data_2_cpp
=
Rcpp
::
as
<
std
::
vector
<
double
>
>
((
data_2
));
...
...
@@ -72,10 +68,6 @@ Rcpp::List snowDaysComparisonCpp(const NumericMatrix data_1,
for
(
size_t
i
=
0
;
i
<
num_pixels
;
++
i
){
out_cpp
[
i
]
=
std
::
vector
<
size_t
>
(
num_years
*
4
);
}
std
::
cout
<<
"copy "
<<
(
std
::
clock
()
-
start
)
/
(
double
)
CLOCKS_PER_SEC
<<
std
::
endl
;
start
=
std
::
clock
();
std
::
vector
<
size_t
>
snow_days_1
(
indices_cpp
[
0
].
size
());
std
::
vector
<
size_t
>
snow_days_2
(
indices_cpp
[
0
].
size
());
...
...
@@ -117,8 +109,6 @@ Rcpp::List snowDaysComparisonCpp(const NumericMatrix data_1,
if
(
interrupt
)
{
throw
interrupt_exception
(
"[I] The computation was interrupted by user"
);
}
std
::
cout
<<
"algo "
<<
(
std
::
clock
()
-
start
)
/
(
double
)
CLOCKS_PER_SEC
<<
std
::
endl
;
start
=
std
::
clock
();
Rcpp
::
List
out
(
num_pixels
);
Rcpp
::
NumericMatrix
content
(
4
,
num_years
);
...
...
@@ -127,8 +117,5 @@ Rcpp::List snowDaysComparisonCpp(const NumericMatrix data_1,
out
(
i
)
=
Rcpp
::
NumericMatrix
(
4
,
num_years
,
out_cpp
[
i
].
begin
()
);
colnames
(
out
(
i
))
=
out_names
;
}
std
::
cout
<<
"out "
<<
(
std
::
clock
()
-
start
)
/
(
double
)
CLOCKS_PER_SEC
<<
std
::
endl
;
return
(
out
);
}
src/snow_season_length.cpp
View file @
1a0302e9
...
...
@@ -98,8 +98,6 @@ Rcpp::NumericMatrix snowSeasonLengthCpp(const NumericMatrix data,
bool
interrupt
=
false
;
// Convert R object to proper c++ object since R objects are not thread safe
std
::
clock_t
start
;
start
=
std
::
clock
();
const
size_t
num_pixels
=
data
.
nrow
();
const
size_t
num_years
=
indices
.
size
();
...
...
@@ -113,9 +111,6 @@ Rcpp::NumericMatrix snowSeasonLengthCpp(const NumericMatrix data,
std
::
vector
<
size_t
>
out_cpp
(
num_pixels
*
num_years
);
std
::
cout
<<
"copy "
<<
(
std
::
clock
()
-
start
)
/
(
double
)
CLOCKS_PER_SEC
<<
std
::
endl
;
start
=
std
::
clock
();
std
::
vector
<
double
>
snow_height
(
366
);
#if defined(_OPENMP)
...
...
@@ -154,15 +149,11 @@ Rcpp::NumericMatrix snowSeasonLengthCpp(const NumericMatrix data,
if
(
interrupt
)
{
throw
interrupt_exception
(
"[I] The computation was interrupted by user"
);
}
std
::
cout
<<
"algo "
<<
(
std
::
clock
()
-
start
)
/
(
double
)
CLOCKS_PER_SEC
<<
std
::
endl
;
start
=
std
::
clock
();
Rcpp
::
NumericMatrix
out
(
num_pixels
,
num_years
,
out_cpp
.
begin
());
Rcpp
::
CharacterVector
out_names
=
Rcpp
::
as
<
CharacterVector
>
(
indices
.
names
());
colnames
(
out
)
=
out_names
;
std
::
cout
<<
"out "
<<
(
std
::
clock
()
-
start
)
/
(
double
)
CLOCKS_PER_SEC
<<
std
::
endl
;
return
(
out
);
}
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