Skip to content
Snippets Groups Projects
Commit 2f43de15 authored by Jakub Klinkovský's avatar Jakub Klinkovský Committed by Tomáš Oberhuber
Browse files

Fixed Python bindings for StaticVector

parent 322770e9
No related branches found
No related tags found
1 merge request!32Expression templates 2
...@@ -6,20 +6,20 @@ namespace py = pybind11; ...@@ -6,20 +6,20 @@ namespace py = pybind11;
#include "../tnl_indexing.h" #include "../tnl_indexing.h"
// needed for discovery of operator<< for tnlStaticArray
#include <TNL/Containers/StaticArray.h>
template< typename VectorType, typename Scope > template< typename VectorType, typename Scope >
void export_StaticVector( Scope & scope, const char* name ) void export_StaticVector( Scope & scope, const char* name )
{ {
using RealType = typename VectorType::RealType; using RealType = typename VectorType::RealType;
auto vector = py::class_<VectorType>(scope, name) auto vector = py::class_<VectorType>(scope, name)
.def(py::init< typename VectorType::RealType >()) .def(py::init< RealType >())
.def(py::init< VectorType >()) .def(py::init< VectorType >())
.def_static("getType", &VectorType::getType) .def_static("getType", &VectorType::getType)
.def("getSize", &VectorType::getSize) .def("getSize", &VectorType::getSize)
.def("assign", &VectorType::operator=) // operator=
.def("assign", []( VectorType& vector, const VectorType& other ) -> VectorType& {
return vector = other;
})
.def(py::self == py::self) .def(py::self == py::self)
.def(py::self != py::self) .def(py::self != py::self)
.def("setValue", &VectorType::setValue) .def("setValue", &VectorType::setValue)
...@@ -28,10 +28,11 @@ void export_StaticVector( Scope & scope, const char* name ) ...@@ -28,10 +28,11 @@ void export_StaticVector( Scope & scope, const char* name )
// .def(py::self_ns::str(py::self)) // .def(py::self_ns::str(py::self))
.def(py::self += py::self) .def(py::self += py::self)
.def(py::self -= py::self) .def(py::self -= py::self)
.def(py::self *= typename VectorType::RealType()) .def(py::self *= RealType())
.def(py::self /= RealType())
.def(py::self + py::self) .def(py::self + py::self)
.def(py::self - py::self) .def(py::self - py::self)
.def(py::self * typename VectorType::RealType()) .def(py::self * RealType())
.def(py::self * py::self) .def(py::self * py::self)
.def(py::self < py::self) .def(py::self < py::self)
.def(py::self > py::self) .def(py::self > py::self)
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment