Skip to content

Commit

Permalink
add Create implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
balos1 committed Jul 18, 2023
1 parent 317bd8a commit fba5fb9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
10 changes: 10 additions & 0 deletions doc/arkode/guide/source/ARKodeSPRKTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ ARKodeSPRKTable functions
+----------------------------------------------+------------------------------------------------------------+


.. c:function:: ARKodeSPRKTable ARKodeSPRKTable_Create(int stages, int q, const sunrealtype* a, const sunrealtype* ahat)
Creates and allocates :c:type:`ARKodeSPRKTable` structure with the specified number of stages and the coefficients provided.
:param stages: The number of stages.
:param q: The order of the method.
:param a: An array of the coefficients for the ``a`` table.
:param ahat: An array of the coefficients for the ``ahat`` table.
:return: :c:type:`ARKodeSPRKTable` structure for the loaded method.
.. c:function:: ARKodeSPRKTable ARKodeSPRKTable_Alloc(int stages)
Allocate memory for an :c:type:`ARKodeSPRKTable` structure with the specified number of stages.
Expand Down
4 changes: 2 additions & 2 deletions include/arkode/arkode_sprk.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ typedef _SUNDIALS_STRUCT_ ARKodeSPRKTableMem* ARKodeSPRKTable;

/* Utility routines to allocate/free/output SPRK structures */
SUNDIALS_EXPORT
ARKodeSPRKTable ARKodeSPRKTable_Create(int s, int q, sunrealtype* a,
sunrealtype* ahat);
ARKodeSPRKTable ARKodeSPRKTable_Create(int s, int q, const sunrealtype* a,
const sunrealtype* ahat);

SUNDIALS_EXPORT
ARKodeSPRKTable ARKodeSPRKTable_Alloc(int stages);
Expand Down
16 changes: 9 additions & 7 deletions src/arkode/arkode_sprk.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,20 +400,22 @@ ARKodeSPRKTable ARKodeSymplecticSofroniou10()
return sprk_table;
}

ARKodeSPRKTable ARKodeSPRKTable_Create(int s, int q, sunrealtype* a,
sunrealtype* ahat)
ARKodeSPRKTable ARKodeSPRKTable_Create(int s, int q, const sunrealtype* a,
const sunrealtype* ahat)
{
int i;
int i = 0;
ARKodeSPRKTable sprk_table = NULL;

ARKodeSPRKTable sprk_table = ARKodeSPRKTable_Alloc(s);
sprk_table = (ARKodeSPRKTable)malloc(sizeof(struct ARKodeSPRKTableMem));
if (!sprk_table) { return NULL; }

sprk_table->q = q;
sprk_table->stages = s;
sprk_table->q = q;

for (i = 0; i < sprk_table->stages; ++i)
for (i = 0; i < s; i++)
{
sprk_table->ahat[i] = ahat[i];
sprk_table->a[i] = a[i];
sprk_table->ahat[i] = ahat[i];
}

return sprk_table;
Expand Down

0 comments on commit fba5fb9

Please sign in to comment.