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
857641c8
Verified
Commit
857641c8
authored
Jul 17, 2021
by
Justin Carpentier
Browse files
core: add fillwithscalar method
parent
42e4faa3
Pipeline
#15229
failed with stage
in 13 minutes and 4 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/eigenpy/register.hpp
View file @
857641c8
...
...
@@ -85,7 +85,8 @@ namespace eigenpy
PyArray_NonzeroFunc
*
nonzero
,
PyArray_CopySwapFunc
*
copyswap
,
PyArray_CopySwapNFunc
*
copyswapn
,
PyArray_DotFunc
*
dotfunc
);
PyArray_DotFunc
*
dotfunc
,
PyArray_FillWithScalarFunc
*
fillwithscalar
);
static
Register
&
instance
();
...
...
include/eigenpy/user-type.hpp
View file @
857641c8
...
...
@@ -24,6 +24,8 @@ 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
fillwithscalar
(
void
*
buffer_
,
npy_intp
length
,
void
*
value
,
void
*
arr
);
// static void cast(void * /*from*/, void * /*to*/, npy_intp /*n*/, void * /*fromarr*/, void * /*toarr*/) {};
};
...
...
@@ -170,6 +172,19 @@ namespace eigenpy
*
static_cast
<
T
*>
(
op
)
=
res
;
}
inline
static
int
fillwithscalar
(
void
*
buffer_
,
npy_intp
length
,
void
*
value
,
void
*
/*arr*/
)
{
T
r
=
*
(
T
*
)
value
;
T
*
buffer
=
(
T
*
)
buffer_
;
npy_intp
i
;
for
(
i
=
0
;
i
<
length
;
i
++
)
{
buffer
[
i
]
=
r
;
}
return
0
;
}
// static void cast(void * from, void * to, npy_intp n, void * fromarr, void * toarr)
// {
// }
...
...
@@ -201,6 +216,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_FillWithScalarFunc
*
fillwithscalar
=
&
internal
::
SpecialMethods
<
Scalar
>::
fillwithscalar
;
// PyArray_CastFunc * cast = &internal::SpecialMethods<Scalar>::cast;
int
code
=
Register
::
registerNewType
(
py_type_ptr
,
...
...
@@ -209,7 +225,8 @@ namespace eigenpy
internal
::
OffsetOf
<
Scalar
>::
value
,
getitem
,
setitem
,
nonzero
,
copyswap
,
copyswapn
,
dotfunc
);
dotfunc
,
fillwithscalar
);
call_PyArray_RegisterCanCast
(
call_PyArray_DescrFromType
(
NPY_OBJECT
),
code
,
NPY_NOSCALAR
);
...
...
src/register.cpp
View file @
857641c8
...
...
@@ -42,7 +42,8 @@ namespace eigenpy
PyArray_NonzeroFunc
*
nonzero
,
PyArray_CopySwapFunc
*
copyswap
,
PyArray_CopySwapNFunc
*
copyswapn
,
PyArray_DotFunc
*
dotfunc
)
PyArray_DotFunc
*
dotfunc
,
PyArray_FillWithScalarFunc
*
fillwithscalar
)
{
namespace
bp
=
boost
::
python
;
bp
::
list
bases
(
bp
::
handle
<>
(
bp
::
borrowed
(
py_type_ptr
->
tp_bases
)));
...
...
@@ -81,6 +82,7 @@ namespace eigenpy
funcs
.
copyswap
=
copyswap
;
funcs
.
copyswapn
=
copyswapn
;
funcs
.
dotfunc
=
dotfunc
;
funcs
.
fillwithscalar
=
fillwithscalar
;
// f->cast = cast;
const
int
code
=
call_PyArray_RegisterDataType
(
descr_ptr
);
...
...
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