Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
eigenpy
Commits
09e5a5db
Verified
Commit
09e5a5db
authored
Jul 30, 2021
by
Justin Carpentier
Browse files
types: add fill function
parent
ec2e073b
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/eigenpy/register.hpp
View file @
09e5a5db
...
...
@@ -86,6 +86,7 @@ namespace eigenpy
PyArray_CopySwapFunc
*
copyswap
,
PyArray_CopySwapNFunc
*
copyswapn
,
PyArray_DotFunc
*
dotfunc
,
PyArray_FillFunc
*
fill
,
PyArray_FillWithScalarFunc
*
fillwithscalar
);
static
Register
&
instance
();
...
...
include/eigenpy/user-type.hpp
View file @
09e5a5db
...
...
@@ -24,6 +24,7 @@ namespace eigenpy
inline
static
npy_bool
nonzero
(
void
*
/*ip*/
,
void
*
/*array*/
)
/*{ return (npy_bool)false; }*/
;
inline
static
void
dotfunc
(
void
*
/*ip0_*/
,
npy_intp
/*is0*/
,
void
*
/*ip1_*/
,
npy_intp
/*is1*/
,
void
*
/*op*/
,
npy_intp
/*n*/
,
void
*
/*arr*/
);
inline
static
int
fill
(
void
*
data_
,
npy_intp
length
,
void
*
arr
);
inline
static
int
fillwithscalar
(
void
*
buffer_
,
npy_intp
length
,
void
*
value
,
void
*
arr
);
// static void cast(void * /*from*/, void * /*to*/, npy_intp /*n*/, void * /*fromarr*/, void * /*toarr*/) {};
...
...
@@ -205,6 +206,21 @@ namespace eigenpy
// static void cast(void * from, void * to, npy_intp n, void * fromarr, void * toarr)
// {
// }
static
int
fill
(
void
*
data_
,
npy_intp
length
,
void
*
/*arr*/
)
{
// std::cout << "fillwithscalar" << std::endl;
T
*
data
=
static_cast
<
T
*>
(
data_
);
const
T
delta
=
data
[
1
]
-
data
[
0
];
T
r
=
data
[
1
];
npy_intp
i
;
for
(
i
=
2
;
i
<
length
;
i
++
)
{
r
=
r
+
delta
;
data
[
i
]
=
r
;
}
return
0
;
}
};
// struct SpecialMethods<T,NPY_USERDEF>
...
...
@@ -233,6 +249,7 @@ namespace eigenpy
PyArray_CopySwapFunc
*
copyswap
=
&
internal
::
SpecialMethods
<
Scalar
>::
copyswap
;
PyArray_CopySwapNFunc
*
copyswapn
=
reinterpret_cast
<
PyArray_CopySwapNFunc
*>
(
&
internal
::
SpecialMethods
<
Scalar
>::
copyswapn
);
PyArray_DotFunc
*
dotfunc
=
&
internal
::
SpecialMethods
<
Scalar
>::
dotfunc
;
PyArray_FillFunc
*
fill
=
&
internal
::
SpecialMethods
<
Scalar
>::
fill
;
PyArray_FillWithScalarFunc
*
fillwithscalar
=
&
internal
::
SpecialMethods
<
Scalar
>::
fillwithscalar
;
// PyArray_CastFunc * cast = &internal::SpecialMethods<Scalar>::cast;
...
...
@@ -243,6 +260,7 @@ namespace eigenpy
getitem
,
setitem
,
nonzero
,
copyswap
,
copyswapn
,
dotfunc
,
fill
,
fillwithscalar
);
call_PyArray_RegisterCanCast
(
call_PyArray_DescrFromType
(
NPY_OBJECT
),
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment