Mantid
Loading...
Searching...
No Matches
Framework
PythonInterface
core
inc
MantidPythonInterface
core
Converters
MatrixToNDArray.h
Go to the documentation of this file.
1
// Mantid Repository : https://github.com/mantidproject/mantid
2
//
3
// Copyright © 2012 ISIS Rutherford Appleton Laboratory UKRI,
4
// NScD Oak Ridge National Laboratory, European Spallation Source,
5
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
#pragma once
8
9
#include "
MantidKernel/Matrix.h
"
10
#include "
MantidPythonInterface/core/Converters/WrapWithNDArray.h
"
11
#include <boost/python/detail/prefix.hpp>
12
13
namespace
Mantid
{
14
namespace
PythonInterface {
15
namespace
Converters
{
16
//-----------------------------------------------------------------------
17
// Converter implementation
18
//-----------------------------------------------------------------------
26
template
<
typename
ElementType,
typename
ConversionPolicy>
27
struct
DLLExport
MatrixToNDArray
{
//clang-format off
33
inline
PyObject *
operator()
(
const
Kernel::Matrix<ElementType>
&cmatrix)
const
{
34
const
std::pair<size_t, size_t> matrixDims = cmatrix.
size
();
35
Py_intptr_t dims[2] = {
static_cast<
Py_intptr_t
>
(matrixDims.first),
static_cast<
Py_intptr_t
>
(matrixDims.second)};
36
using
policy =
typename
ConversionPolicy::template apply<ElementType>;
37
return
policy::createFromArray(&(cmatrix[0][0]), 2, dims);
38
}
// namespace Converters
39
};
// namespace PythonInterface
40
//clang-format on
41
}
// namespace Mantid
42
}
// namespace PythonInterface
43
}
// namespace Mantid
Matrix.h
DLLExport
#define DLLExport
Definitions of the DLLImport compiler directives for MSVC.
Definition
System.h:37
WrapWithNDArray.h
Mantid::Kernel::Matrix
Numerical Matrix class.
Definition
Matrix.h:42
Mantid::Kernel::Matrix::size
std::pair< size_t, size_t > size() const
Access matrix sizes.
Definition
Matrix.h:141
Mantid::PythonInterface::Converters
Definition
CArrayToNDArray.h:13
Mantid
Helper class which provides the Collimation Length for SANS instruments.
Definition
AbsorptionCorrection.h:18
Mantid::PythonInterface::Converters::MatrixToNDArray
Converter that takes a Mantid Matrix and converts it into a numpy array.
Definition
MatrixToNDArray.h:27
Mantid::PythonInterface::Converters::MatrixToNDArray::operator()
PyObject * operator()(const Kernel::Matrix< ElementType > &cmatrix) const
Operator to convert a matrix to a numpy array.
Definition
MatrixToNDArray.h:33
Generated by
1.9.8