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
b22cad65
Commit
b22cad65
authored
Jul 15, 2014
by
Nicolas Mansard
Committed by
nmansard
Jul 15, 2014
Browse files
First complete version.
parent
023a1502
Changes
10
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
b22cad65
...
...
@@ -19,22 +19,25 @@ IF(Boost_FOUND)
SET
(
Boost_USE_STATIC_RUNTIME OFF
)
FIND_PACKAGE
(
Boost 1.45.0 COMPONENTS python
)
ADD_LIBRARY
(
simple SHARED src/simple.cpp
)
ADD_LIBRARY
(
eigenpy SHARED unittest/libeigenpy.cpp
)
TARGET_LINK_LIBRARIES
(
eigenpy
${
Boost_LIBRARIES
}
)
ADD_LIBRARY
(
simple SHARED unittest/alpha/simple.cpp
)
TARGET_LINK_LIBRARIES
(
simple
${
Boost_LIBRARIES
}
)
ADD_LIBRARY
(
mystring SHARED
src
/mystring.cpp
)
ADD_LIBRARY
(
mystring SHARED
unittest/alpha
/mystring.cpp
)
TARGET_LINK_LIBRARIES
(
mystring
${
Boost_LIBRARIES
}
)
ADD_LIBRARY
(
bnpy SHARED
src
/bnpy.cpp
)
ADD_LIBRARY
(
bnpy SHARED
unittest/alpha
/bnpy.cpp
)
TARGET_LINK_LIBRARIES
(
bnpy
${
Boost_LIBRARIES
}
)
ADD_LIBRARY
(
eigen SHARED
src
/eigen.cpp
)
ADD_LIBRARY
(
eigen SHARED
unittest/alpha
/eigen.cpp
)
TARGET_LINK_LIBRARIES
(
eigen
${
Boost_LIBRARIES
}
libboost_numpy.so
)
ADD_LIBRARY
(
eigenc SHARED
src
/eigenc.cpp
)
ADD_LIBRARY
(
eigenc SHARED
unittest/alpha
/eigenc.cpp
)
TARGET_LINK_LIBRARIES
(
eigenc
${
Boost_LIBRARIES
}
)
ADD_LIBRARY
(
eigentemplate SHARED
src
/eigentemplate.cpp
)
ADD_LIBRARY
(
eigentemplate SHARED
unittest/alpha
/eigentemplate.cpp
)
TARGET_LINK_LIBRARIES
(
eigentemplate
${
Boost_LIBRARIES
}
)
ELSEIF
(
NOT Boost_FOUND
)
...
...
python/alpha.py
0 → 100644
View file @
b22cad65
#!/usr/bin/python
import
numpy
as
np
'''
import libsimple
print libsimple.char()
print libsimple.str()
try:
a = libsimple.eigenvec()
print a
except:
print "Error when calling simple eigenvec"
import libmystring
print libmystring.hello()
print libmystring.size("toto+5")
import libeigen
print libeigen.test()
a = np.matrix([11,2,3,4,5]).T
b = np.array([11,2,3,4,5])
#b = np.array([[15,],[1,],[1,],[1,],[1,],])
#b = np.array([ [[10,2],[3,4]],[[10,2],[3,4]] ])
print "matrix ===> "
libeigen.test2(a)
print "array ===> "
libeigen.test2(b)
'''
import
libeigenpy
# print "===> From C++ to Py"
# print libeigentemplate.test()
# print "===> From Vec C++ to Py"
# print libeigentemplate.testVec()
# print "===> From Py to C++"
a
=
np
.
random
.
random
([
5
,
5
])
for
i
in
range
(
5
):
for
j
in
range
(
5
):
a
[
i
,
j
]
=
i
*
5
+
j
#a = np.random.random([
print
a
libeigentemplate
.
test2
(
a
)
# print "===> From Py::slice to C++"
# b=a[1:5,1:3]
# print b
# libeigentemplate.test2(b)
# print "===> From Py::transpose to C++"
# b=a[1:5,1:3].T
# print b
# libeigentemplate.test2(b)
print
"===> From py::vec to C++ Vec"
v
=
np
.
array
([
range
(
5
),],
np
.
float64
).
T
print
v
libeigentemplate
.
test2Vec
(
v
)
v
=
np
.
array
(
range
(
5
),
np
.
float64
)
print
"v = "
,
v
libeigentemplate
.
test2Vec
(
v
)
v
=
np
.
array
(
range
(
10
),
np
.
float64
)
v2
=
v
[
0
:
10
:
5
]
print
"v2 = "
,
v2
libeigentemplate
.
test2Vec
(
v2
)
'''
import libbnpy
a=libbnpy.array()
print a.__class__
b=libbnpy.matrix()
print b.__class__
'''
python/test_unit.py
View file @
b22cad65
#!/usr/bin/python
import
numpy
as
np
import
libeigenpy
'''
import libsimple
print
"===> From MatrixXd to Py"
print
libeigenpy
.
test
()
print libsimple.char()
print libsimple.str()
try:
a = libsimple.eigenvec()
print a
except:
print "Error when calling simple eigenvec"
print
"===> From VectorXd to Py"
print
libeigenpy
.
testVec
()
import libmystring
print libmystring.hello()
print libmystring.size("toto+5")
import libeigen
print libeigen.test()
a = np.matrix([11,2,3,4,5]).T
b = np.array([11,2,3,4,5])
#b = np.array([[15,],[1,],[1,],[1,],[1,],])
#b = np.array([ [[10,2],[3,4]],[[10,2],[3,4]] ])
print "matrix ===> "
libeigen.test2(a)
print "array ===> "
libeigen.test2(b)
'''
import
libeigentemplate
# print "===> From C++ to Py"
# print libeigentemplate.test()
# print "===> From Vec C++ to Py"
# print libeigentemplate.testVec()
# print "===> From Py to C++"
print
"===> From Py to C++"
a
=
np
.
random
.
random
([
5
,
5
])
for
i
in
range
(
5
):
for
j
in
range
(
5
):
a
[
i
,
j
]
=
i
*
5
+
j
#a = np.random.random([
print
a
libeigentemplate
.
test2
(
a
)
# print "===> From Py::slice to C++"
# b=a[1:5,1:3]
# print b
# libeigentemplate.test2(b)
libeigenpy
.
test2
(
a
)
# print "===> From Py::transpose to C++"
# b=a[1:5,1:3].T
# print b
# libeigentemplate.test2(b)
print
"===> From Py::slice to C++"
b
=
a
[
1
:
5
,
1
:
3
]
print
b
libeigenpy
.
test2
(
b
)
print
"===> From Py::transpose to C++"
b
=
a
[
1
:
5
,
1
:
3
].
T
libeigenpy
.
test2
(
b
)
print
"===> From py::vec to C++ Vec"
v
=
np
.
array
([
range
(
5
),],
np
.
float64
).
T
print
v
libeigentemplate
.
test2Vec
(
v
)
libeigenpy
.
test2Vec
(
v
)
print
"===> From one-dim py::vec to C++ Vec"
v
=
np
.
array
(
range
(
5
),
np
.
float64
)
print
"v = "
,
v
libeigentemplate
.
test2Vec
(
v
)
libeigenpy
.
test2Vec
(
v
)
print
"===> From one-dim sliced py::vec to C++ Vec"
v
=
np
.
array
(
range
(
10
),
np
.
float64
)
v2
=
v
[
0
:
10
:
5
]
print
"v2 = "
,
v2
libeigentemplate
.
test2Vec
(
v2
)
'''
import libbnpy
a=libbnpy.array()
print a.__class__
b=libbnpy.matrix()
print b.__class__
'''
v2
=
v
[
0
:
10
:
3
]
libeigenpy
.
test2Vec
(
v2
)
src
/bnpy.cpp
→
unittest/alpha
/bnpy.cpp
View file @
b22cad65
File moved
src
/eigen.cpp
→
unittest/alpha
/eigen.cpp
View file @
b22cad65
File moved
src
/eigenc.cpp
→
unittest/alpha
/eigenc.cpp
View file @
b22cad65
File moved
src
/eigentemplate.cpp
→
unittest/alpha
/eigentemplate.cpp
View file @
b22cad65
File moved
src
/mystring.cpp
→
unittest/alpha
/mystring.cpp
View file @
b22cad65
File moved
src
/simple.cpp
→
unittest/alpha
/simple.cpp
View file @
b22cad65
File moved
unittest/libeigenpy.cpp
0 → 100644
View file @
b22cad65
#include
"../src/eigenpy.hpp"
Eigen
::
MatrixXd
test
()
{
Eigen
::
MatrixXd
mat
=
Eigen
::
MatrixXd
::
Random
(
3
,
6
);
std
::
cout
<<
"EigenMAt = "
<<
mat
<<
std
::
endl
;
return
mat
;
}
Eigen
::
VectorXd
testVec
()
{
Eigen
::
VectorXd
mat
=
Eigen
::
VectorXd
::
Random
(
6
);
std
::
cout
<<
"EigenVec = "
<<
mat
<<
std
::
endl
;
return
mat
;
}
void
test2
(
Eigen
::
MatrixXd
mat
)
{
std
::
cout
<<
"Test2 mat = "
<<
mat
<<
std
::
endl
;
}
void
test2Vec
(
Eigen
::
VectorXd
v
)
{
std
::
cout
<<
"Test2 vec = "
<<
v
<<
std
::
endl
;
}
BOOST_PYTHON_MODULE
(
libeigenpy
)
{
namespace
bp
=
boost
::
python
;
eigenpy
::
enableEigenPy
();
bp
::
def
(
"test"
,
test
);
bp
::
def
(
"testVec"
,
testVec
);
bp
::
def
(
"test2"
,
test2
);
bp
::
def
(
"test2Vec"
,
test2Vec
);
}
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