Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cats
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BDC
cats
Commits
7e1db93c
Commit
7e1db93c
authored
1 year ago
by
Andreas Gattringer
Browse files
Options
Downloads
Patches
Plain Diff
reduce array access code points in overlay translation
parent
219e02dc
No related branches found
No related tags found
1 merge request
!1
preparations for multi-scale simulations
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cats/overlays/overlay_exclusion.c
+7
-5
7 additions, 5 deletions
src/cats/overlays/overlay_exclusion.c
src/cats/overlays/overlay_resources.c
+7
-8
7 additions, 8 deletions
src/cats/overlays/overlay_resources.c
with
14 additions
and
13 deletions
src/cats/overlays/overlay_exclusion.c
+
7
−
5
View file @
7e1db93c
...
...
@@ -110,17 +110,19 @@ struct cats_2d_array_char *translate_exclusion(const struct cats_2d_array_double
for
(
cats_dt_coord
row
=
0
;
row
<
rows
;
row
++
)
{
for
(
cats_dt_coord
col
=
0
;
col
<
cols
;
col
++
)
{
const
int32_t
val
=
(
int32_t
)
round
(
data
->
data
[
row
][
col
]);
// converter [translate_exclusion]
const
int32_t
in_val
=
(
int32_t
)
round
(
data
->
data
[
row
][
col
]);
// converter [translate_exclusion]
char
out_val
;
if
(
val
==
0
)
{
result
->
data
[
row
][
col
]
=
OL_EXCLUSION_NOT_EXCLUDED
;
// converter [translate_exclusion]
if
(
in_
val
==
0
)
{
out_val
=
OL_EXCLUSION_NOT_EXCLUDED
;
}
else
if
(
isnan
(
data
->
data
[
row
][
col
]))
{
result
->
data
[
row
][
col
]
=
OL_EXCLUSION_NAN
;
// converter [translate_exclusion]
out_val
=
OL_EXCLUSION_NAN
;
count
+=
1
;
}
else
{
result
->
data
[
row
][
col
]
=
OL_EXCLUSION_EXCLUDED
;
// converter [translate_exclusion]
out_val
=
OL_EXCLUSION_EXCLUDED
;
count
+=
1
;
}
result
->
data
[
row
][
col
]
=
out_val
;
// converter [translate_exclusion]
}
}
...
...
This diff is collapsed.
Click to expand it.
src/cats/overlays/overlay_resources.c
+
7
−
8
View file @
7e1db93c
#include
<assert.h>
#include
<math.h>
#include
"overlay_resources.h"
#include
"memory/arrays.h"
...
...
@@ -14,15 +13,15 @@ struct cats_2d_array_double *translate_resources(const struct cats_2d_array_doub
for
(
cats_dt_coord
row
=
0
;
row
<
rows
;
row
++
)
{
for
(
cats_dt_coord
col
=
0
;
col
<
cols
;
col
++
)
{
double
value
=
data
->
data
[
row
][
col
];
// converter [translate_resources]
double
in_value
=
data
->
data
[
row
][
col
];
// converter [translate_resources]
double
out_value
;
if
(
isnan
(
value
))
{
result
->
data
[
row
][
col
]
=
0
.
0
;
// converter [translate_resources]
if
(
isnan
(
in_
value
))
{
out_value
=
0
.
0
;
}
else
{
if
(
value
<
0
)
value
=
0
;
result
->
data
[
row
][
col
]
=
value
;
// converter [translate_resources]
}
if
(
in_value
<
0
)
in_value
=
0
;
out_value
=
in_value
;
}
result
->
data
[
row
][
col
]
=
out_value
;
// converter [translate_resources]
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment