Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
spm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
solverstack
spm
Commits
f9dcaba6
Commit
f9dcaba6
authored
6 years ago
by
Mathieu Faverge
Browse files
Options
Downloads
Patches
Plain Diff
Add new sort function for IJV format
parent
93aa1b7e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/z_spm.c
+2
-2
2 additions, 2 deletions
src/z_spm.c
src/z_spm.h
+2
-1
2 additions, 1 deletion
src/z_spm.h
src/z_spm_integer.c
+65
-4
65 additions, 4 deletions
src/z_spm_integer.c
with
69 additions
and
7 deletions
src/z_spm.c
+
2
−
2
View file @
f9dcaba6
...
...
@@ -65,7 +65,7 @@ z_spmSort( spmatrix_t *spm )
#else
sortptr
[
0
]
=
rowptr
;
sortptr
[
1
]
=
values
;
z_spmIntSortAsc
(
sortptr
,
size
);
z_spmInt
Flt
SortAsc
(
sortptr
,
size
);
#endif
rowptr
+=
size
;
values
+=
size
;
...
...
@@ -81,7 +81,7 @@ z_spmSort( spmatrix_t *spm )
#else
sortptr
[
0
]
=
colptr
;
sortptr
[
1
]
=
values
;
z_spmIntSortAsc
(
sortptr
,
size
);
z_spmInt
Flt
SortAsc
(
sortptr
,
size
);
#endif
colptr
+=
size
;
values
+=
size
;
...
...
This diff is collapsed.
Click to expand it.
src/z_spm.h
+
2
−
1
View file @
f9dcaba6
...
...
@@ -23,7 +23,8 @@
/**
* Integer routines
*/
void
z_spmIntSortAsc
(
void
**
const
pbase
,
const
spm_int_t
n
);
void
z_spmIntFltSortAsc
(
void
**
const
pbase
,
const
spm_int_t
n
);
void
z_spmIntIntFltSortAsc
(
void
**
const
pbase
,
const
spm_int_t
n
);
/**
* Conversion routines
...
...
This diff is collapsed.
Click to expand it.
src/z_spm_integer.c
+
65
−
4
View file @
f9dcaba6
...
...
@@ -22,7 +22,7 @@
/**
*******************************************************************************
*
* @fn void z_spmIntSortAsc(void ** const pbase, const spm_int_t n)
* @fn void z_spmInt
Flt
SortAsc(void ** const pbase, const spm_int_t n)
* @ingroup spm_dev_integer
* @brief Sort 2 arrays simultaneously, the first array is an array of
* spm_int_t and used as key for sorting. The second array is an array of
...
...
@@ -40,9 +40,9 @@
*******************************************************************************
*/
#ifndef DOXYGEN_SHOULD_SKIP_THIS
static
size_t
intsortsize
[
2
]
=
{
sizeof
(
spm_int_t
),
sizeof
(
spm_complex64_t
)
};
#define INTSORTNAME z_spmIntSortAsc
#define INTSORTSIZE(x) (intsortsize[x])
static
size_t
intsortsize
_if
[
2
]
=
{
sizeof
(
spm_int_t
),
sizeof
(
spm_complex64_t
)
};
#define INTSORTNAME z_spmInt
Flt
SortAsc
#define INTSORTSIZE(x) (intsortsize
_if
[x])
#define INTSORTNTAB 2
#define INTSORTSWAP(p,q) do { \
spm_int_t t; \
...
...
@@ -68,3 +68,64 @@ static size_t intsortsize[2] = { sizeof(spm_int_t), sizeof(spm_complex64_t) };
#undef INTSORTNTAB
#endif
/* DOXYGEN_SHOULD_SKIP_THIS */
/**
*******************************************************************************
*
* @fn void z_spmIntIntFltSortAsc(void ** const pbase, const spm_int_t n)
* @ingroup spm_dev_integer
* @brief Sort 2 arrays simultaneously, the first array is an array of
* spm_int_t and used as key for sorting. The second array is an array of
* spm_complex64_t.
*
*******************************************************************************
*
* @param[inout] pbase
* Couple of pointers to an array of integers and to an array of
* spm_complex64_t to sort.
*
* @param[in] n
* The number of elements in the array.
*
*******************************************************************************
*/
#ifndef DOXYGEN_SHOULD_SKIP_THIS
static
size_t
intsortsize_iif
[
3
]
=
{
sizeof
(
spm_int_t
),
sizeof
(
spm_int_t
),
sizeof
(
spm_complex64_t
)
};
#define INTSORTNAME z_spmIntIntFltSortAsc
#define INTSORTSIZE(x) (intsortsize_iif[x])
#define INTSORTNTAB 3
#define INTSORTSWAP(p,q) do { \
spm_int_t t; \
long disp_p = (((spm_int_t*)p)-((spm_int_t*)base_ptr)); \
long disp_q = (((spm_int_t*)q)-((spm_int_t*)base_ptr)); \
spm_int_t * intptr = *(pbase+1); \
spm_complex64_t * fltptr = *(pbase+2); \
spm_complex64_t f; \
/* swap integers */
\
t = *((spm_int_t *) (p)); \
*((spm_int_t *) (p)) = *((spm_int_t *) (q)); \
*((spm_int_t *) (q)) = t; \
/* swap on second integer array */
\
t = intptr[disp_p]; \
intptr[disp_p] = intptr[disp_q]; \
intptr[disp_q] = t; \
/* swap corresponding values */
\
f = fltptr[disp_p]; \
fltptr[disp_p] = fltptr[disp_q]; \
fltptr[disp_q] = f; \
} while (0)
static
inline
int
intsortcmp_iif
(
void
**
const
pbase
,
spm_int_t
*
p
,
spm_int_t
*
q
)
{
spm_int_t
*
int1ptr
=
pbase
[
0
];
spm_int_t
*
int2ptr
=
pbase
[
1
];
return
(
(
*
p
<
*
q
)
||
((
*
p
==
*
q
)
&&
(
int2ptr
[
p
-
int1ptr
]
<
int2ptr
[
q
-
int1ptr
]
))
);
}
#define INTSORTCMP(p,q) intsortcmp_iif( pbase, (spm_int_t*)p, (spm_int_t*)q )
#include
"integer_sort_mtypes.c"
#undef INTSORTNAME
#undef INTSORTSIZE
#undef INTSORTSWAP
#undef INTSORTCMP
#undef INTSORTNTAB
#endif
/* DOXYGEN_SHOULD_SKIP_THIS */
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