Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cvode Rust Wrap
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
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.3.
Show more breadcrumbs
InBio
Public
Cvode Rust Wrap
Commits
b1472edb
Commit
b1472edb
authored
4 years ago
by
Arthur Carcano
Browse files
Options
Downloads
Patches
Plain Diff
a few rename
parent
78fda7a2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cvode-wrap/src/lib.rs
+6
-6
6 additions, 6 deletions
cvode-wrap/src/lib.rs
cvode-wrap/src/nvector.rs
+8
-7
8 additions, 7 deletions
cvode-wrap/src/nvector.rs
with
14 additions
and
13 deletions
cvode-wrap/src/lib.rs
+
6
−
6
View file @
b1472edb
...
@@ -10,7 +10,7 @@ use cvode_5_sys::{
...
@@ -10,7 +10,7 @@ use cvode_5_sys::{
};
};
mod
nvector
;
mod
nvector
;
use
nvector
::
NVectorSerial
;
use
nvector
::
NVectorSerial
HeapAlloced
;
pub
type
Realtype
=
realtype
;
pub
type
Realtype
=
realtype
;
pub
type
CVector
=
cvode
::
N_Vector
;
pub
type
CVector
=
cvode
::
N_Vector
;
...
@@ -61,7 +61,7 @@ impl From<NonNull<CvodeMemoryBlock>> for CvodeMemoryBlockNonNullPtr {
...
@@ -61,7 +61,7 @@ impl From<NonNull<CvodeMemoryBlock>> for CvodeMemoryBlockNonNullPtr {
/// See [crate-level](`crate`) documentation for more.
/// See [crate-level](`crate`) documentation for more.
pub
struct
Solver
<
UserData
,
const
N
:
usize
>
{
pub
struct
Solver
<
UserData
,
const
N
:
usize
>
{
mem
:
CvodeMemoryBlockNonNullPtr
,
mem
:
CvodeMemoryBlockNonNullPtr
,
y0
:
NVectorSerial
<
N
>
,
y0
:
NVectorSerial
HeapAlloced
<
N
>
,
sunmatrix
:
SUNMatrix
,
sunmatrix
:
SUNMatrix
,
linsolver
:
SUNLinearSolver
,
linsolver
:
SUNLinearSolver
,
atol
:
AbsTolerance
<
N
>
,
atol
:
AbsTolerance
<
N
>
,
...
@@ -138,7 +138,7 @@ fn check_flag_is_succes(flag: c_int, func_id: &'static str) -> Result<()> {
...
@@ -138,7 +138,7 @@ fn check_flag_is_succes(flag: c_int, func_id: &'static str) -> Result<()> {
pub
enum
AbsTolerance
<
const
SIZE
:
usize
>
{
pub
enum
AbsTolerance
<
const
SIZE
:
usize
>
{
Scalar
(
Realtype
),
Scalar
(
Realtype
),
Vector
(
NVectorSerial
<
SIZE
>
),
Vector
(
NVectorSerial
HeapAlloced
<
SIZE
>
),
}
}
impl
<
const
SIZE
:
usize
>
AbsTolerance
<
SIZE
>
{
impl
<
const
SIZE
:
usize
>
AbsTolerance
<
SIZE
>
{
...
@@ -147,7 +147,7 @@ impl<const SIZE: usize> AbsTolerance<SIZE> {
...
@@ -147,7 +147,7 @@ impl<const SIZE: usize> AbsTolerance<SIZE> {
}
}
pub
fn
vector
(
atol
:
&
[
Realtype
;
SIZE
])
->
Self
{
pub
fn
vector
(
atol
:
&
[
Realtype
;
SIZE
])
->
Self
{
let
atol
=
NVectorSerial
::
new_from
(
atol
);
let
atol
=
NVectorSerial
HeapAlloced
::
new_from
(
atol
);
AbsTolerance
::
Vector
(
atol
)
AbsTolerance
::
Vector
(
atol
)
}
}
}
}
...
@@ -167,7 +167,7 @@ impl<UserData, const N: usize> Solver<UserData, N> {
...
@@ -167,7 +167,7 @@ impl<UserData, const N: usize> Solver<UserData, N> {
let
mem_maybenull
=
unsafe
{
cvode
::
CVodeCreate
(
method
as
c_int
)
};
let
mem_maybenull
=
unsafe
{
cvode
::
CVodeCreate
(
method
as
c_int
)
};
check_non_null
(
mem_maybenull
as
*
mut
CvodeMemoryBlock
,
"CVodeCreate"
)
?
.into
()
check_non_null
(
mem_maybenull
as
*
mut
CvodeMemoryBlock
,
"CVodeCreate"
)
?
.into
()
};
};
let
y0
=
NVectorSerial
::
new_from
(
y0
);
let
y0
=
NVectorSerial
HeapAlloced
::
new_from
(
y0
);
let
matrix
=
{
let
matrix
=
{
let
matrix
=
unsafe
{
let
matrix
=
unsafe
{
cvode_5_sys
::
sunmatrix_dense
::
SUNDenseMatrix
(
cvode_5_sys
::
sunmatrix_dense
::
SUNDenseMatrix
(
...
@@ -244,7 +244,7 @@ impl<UserData, const N: usize> Solver<UserData, N> {
...
@@ -244,7 +244,7 @@ impl<UserData, const N: usize> Solver<UserData, N> {
)
)
};
};
check_flag_is_succes
(
flag
,
"CVode"
)
?
;
check_flag_is_succes
(
flag
,
"CVode"
)
?
;
Ok
((
tret
,
self
.y0
.as_
ref
()))
Ok
((
tret
,
self
.y0
.as_
slice
()))
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
cvode-wrap/src/nvector.rs
+
8
−
7
View file @
b1472edb
...
@@ -2,13 +2,14 @@ use std::{convert::TryInto, intrinsics::transmute, ops::Deref, ptr::NonNull};
...
@@ -2,13 +2,14 @@ use std::{convert::TryInto, intrinsics::transmute, ops::Deref, ptr::NonNull};
use
cvode_5_sys
::{
cvode
::
realtype
,
nvector_serial
};
use
cvode_5_sys
::{
cvode
::
realtype
,
nvector_serial
};
#[repr(transparent)]
#[repr(transparent)]
#[derive(Debug)]
#[derive(Debug)]
pub
struct
NVectorSerial
<
const
SIZE
:
usize
>
{
pub
struct
NVectorSerial
HeapAlloced
<
const
SIZE
:
usize
>
{
inner
:
NonNull
<
nvector_serial
::
_generic_N_Vector
>
,
inner
:
NonNull
<
nvector_serial
::
_generic_N_Vector
>
,
}
}
impl
<
const
SIZE
:
usize
>
Deref
for
NVectorSerial
<
SIZE
>
{
impl
<
const
SIZE
:
usize
>
Deref
for
NVectorSerial
HeapAlloced
<
SIZE
>
{
type
Target
=
nvector_serial
::
_generic_N_Vector
;
type
Target
=
nvector_serial
::
_generic_N_Vector
;
fn
deref
(
&
self
)
->
&
Self
::
Target
{
fn
deref
(
&
self
)
->
&
Self
::
Target
{
...
@@ -16,12 +17,12 @@ impl<const SIZE: usize> Deref for NVectorSerial<SIZE> {
...
@@ -16,12 +17,12 @@ impl<const SIZE: usize> Deref for NVectorSerial<SIZE> {
}
}
}
}
impl
<
const
SIZE
:
usize
>
NVectorSerial
<
SIZE
>
{
impl
<
const
SIZE
:
usize
>
NVectorSerial
HeapAlloced
<
SIZE
>
{
pub
fn
as_
ref
(
&
self
)
->
&
[
realtype
;
SIZE
]
{
pub
fn
as_
slice
(
&
self
)
->
&
[
realtype
;
SIZE
]
{
unsafe
{
transmute
(
nvector_serial
::
N_VGetArrayPointer_Serial
(
self
.as_raw
()))
}
unsafe
{
transmute
(
nvector_serial
::
N_VGetArrayPointer_Serial
(
self
.as_raw
()))
}
}
}
pub
fn
as_mut
(
&
mut
self
)
->
&
mut
[
realtype
;
SIZE
]
{
pub
fn
as_
slice_
mut
(
&
mut
self
)
->
&
mut
[
realtype
;
SIZE
]
{
unsafe
{
transmute
(
nvector_serial
::
N_VGetArrayPointer_Serial
(
self
.as_raw
()))
}
unsafe
{
transmute
(
nvector_serial
::
N_VGetArrayPointer_Serial
(
self
.as_raw
()))
}
}
}
...
@@ -34,7 +35,7 @@ impl<const SIZE: usize> NVectorSerial<SIZE> {
...
@@ -34,7 +35,7 @@ impl<const SIZE: usize> NVectorSerial<SIZE> {
pub
fn
new_from
(
data
:
&
[
realtype
;
SIZE
])
->
Self
{
pub
fn
new_from
(
data
:
&
[
realtype
;
SIZE
])
->
Self
{
let
mut
res
=
Self
::
new
();
let
mut
res
=
Self
::
new
();
res
.as_mut
()
.copy_from_slice
(
data
);
res
.as_
slice_
mut
()
.copy_from_slice
(
data
);
res
res
}
}
...
@@ -43,7 +44,7 @@ impl<const SIZE: usize> NVectorSerial<SIZE> {
...
@@ -43,7 +44,7 @@ impl<const SIZE: usize> NVectorSerial<SIZE> {
}
}
}
}
impl
<
const
SIZE
:
usize
>
Drop
for
NVectorSerial
<
SIZE
>
{
impl
<
const
SIZE
:
usize
>
Drop
for
NVectorSerial
HeapAlloced
<
SIZE
>
{
fn
drop
(
&
mut
self
)
{
fn
drop
(
&
mut
self
)
{
unsafe
{
nvector_serial
::
N_VDestroy
(
self
.as_raw
())
}
unsafe
{
nvector_serial
::
N_VDestroy
(
self
.as_raw
())
}
}
}
...
...
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