Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
librelaxisloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Klemm, Carl Philipp
librelaxisloader
Commits
34a1526c
Commit
34a1526c
authored
Mar 11, 2024
by
Carl Philipp Klemm
Browse files
Options
Downloads
Patches
Plain Diff
add functions that allow the user to convert rlx_spectras to flat arrays
parent
530bddb5
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
relaxisloader.c
+50
-0
50 additions, 0 deletions
relaxisloader.c
relaxisloader/relaxisloader.h
+26
-0
26 additions, 0 deletions
relaxisloader/relaxisloader.h
with
76 additions
and
0 deletions
relaxisloader.c
+
50
−
0
View file @
34a1526c
...
@@ -323,6 +323,54 @@ int* rlx_get_spectra_ids(struct rlxfile* file, const struct rlx_project* project
...
@@ -323,6 +323,54 @@ int* rlx_get_spectra_ids(struct rlxfile* file, const struct rlx_project* project
return
ids
;
return
ids
;
}
}
int
rlx_get_float_arrays
(
const
struct
rlx_spectra
*
spectra
,
float
**
re
,
float
**
im
,
float
**
omega
)
{
*
re
=
malloc
(
sizeof
(
float
)
*
spectra
->
length
);
if
(
!*
re
)
return
-
103
;
*
im
=
malloc
(
sizeof
(
float
)
*
spectra
->
length
);
if
(
!*
im
)
return
-
103
;
*
omega
=
malloc
(
sizeof
(
float
)
*
spectra
->
length
);
if
(
!*
omega
)
return
-
103
;
for
(
size_t
i
=
0
;
i
<
spectra
->
length
;
++
i
)
{
(
*
re
)[
i
]
=
spectra
->
datapoints
[
i
].
re
;
(
*
im
)[
i
]
=
spectra
->
datapoints
[
i
].
im
;
(
*
omega
)[
i
]
=
spectra
->
datapoints
[
i
].
omega
;
}
return
0
;
}
int
rlx_get_double_arrays
(
const
struct
rlx_spectra
*
spectra
,
double
**
re
,
double
**
im
,
double
**
omega
)
{
*
re
=
malloc
(
sizeof
(
double
)
*
spectra
->
length
);
if
(
!*
re
)
return
-
103
;
*
im
=
malloc
(
sizeof
(
double
)
*
spectra
->
length
);
if
(
!*
im
)
return
-
103
;
*
omega
=
malloc
(
sizeof
(
double
)
*
spectra
->
length
);
if
(
!*
omega
)
return
-
103
;
for
(
size_t
i
=
0
;
i
<
spectra
->
length
;
++
i
)
{
(
*
re
)[
i
]
=
spectra
->
datapoints
[
i
].
re
;
(
*
im
)[
i
]
=
spectra
->
datapoints
[
i
].
im
;
(
*
omega
)[
i
]
=
spectra
->
datapoints
[
i
].
omega
;
}
return
0
;
}
struct
rlx_fitparam
**
rlx_get_fit_parameters
(
struct
rlxfile
*
file
,
const
struct
rlx_project
*
project
,
int
id
,
size_t
*
length
)
struct
rlx_fitparam
**
rlx_get_fit_parameters
(
struct
rlxfile
*
file
,
const
struct
rlx_project
*
project
,
int
id
,
size_t
*
length
)
{
{
(
void
)
project
;
(
void
)
project
;
...
@@ -394,6 +442,8 @@ const char* rlx_get_errnum_str(int errnum)
...
@@ -394,6 +442,8 @@ const char* rlx_get_errnum_str(int errnum)
return
"Project contains no spectra"
;
return
"Project contains no spectra"
;
if
(
errnum
==
-
102
)
if
(
errnum
==
-
102
)
return
"Tried to load non existing spectra"
;
return
"Tried to load non existing spectra"
;
if
(
errnum
==
-
103
)
return
"Out of memory"
;
return
"Unkown error"
;
return
"Unkown error"
;
}
}
This diff is collapsed.
Click to expand it.
relaxisloader/relaxisloader.h
+
26
−
0
View file @
34a1526c
...
@@ -190,6 +190,32 @@ int* rlx_get_spectra_ids(struct rlxfile* file, const struct rlx_project* project
...
@@ -190,6 +190,32 @@ int* rlx_get_spectra_ids(struct rlxfile* file, const struct rlx_project* project
*/
*/
struct
rlx_spectra
*
rlx_get_spectra
(
struct
rlxfile
*
file
,
const
struct
rlx_project
*
project
,
int
id
);
struct
rlx_spectra
*
rlx_get_spectra
(
struct
rlxfile
*
file
,
const
struct
rlx_project
*
project
,
int
id
);
/**
* @brief transforms a rlx_spectra struct into a set of newly allocated arrays, float version.
*
* If this function encounters an error it will return NULL and set an error at rlx_get_errnum.
*
* @param spectra the spectra to convert
* @param re an array with the real part of the spectra will be allocated here. To be freed by free().
* @param im an array with the imaginary part of the spectra will be allocated here. To be freed by free().
* @param omega an array with the omega values of the spectra will be allocated here. To be freed by free().
* @return 0 if successful or an error number < 0 interpertable by rlx_get_errnum_str otherwise, no allocations will be performed on error.
*/
int
rlx_get_float_arrays
(
const
struct
rlx_spectra
*
spectra
,
float
**
re
,
float
**
im
,
float
**
omega
);
/**
* @brief transforms a rlx_spectra struct into a set of newly allocated arrays, double version.
*
* If this function encounters an error it will return NULL and set an error at rlx_get_errnum.
*
* @param spectra the spectra to convert
* @param re an array with the real part of the spectra will be allocated here. To be freed by free().
* @param im an array with the imaginary part of the spectra will be allocated here. To be freed by free().
* @param omega an array with the omega values of the spectra will be allocated here. To be freed by free().
* @return 0 if successful or an error number < 0 interpertable by rlx_get_errnum_str otherwise, no allocations will be performed on error.
*/
int
rlx_get_double_arrays
(
const
struct
rlx_spectra
*
spectra
,
double
**
re
,
double
**
im
,
double
**
omega
);
/**
/**
* @brief Loads the parameters for a given spectra id from file
* @brief Loads the parameters for a given spectra id from file
*
*
...
...
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