Mantid
Loading...
Searching...
No Matches
NDArrayTypeIndex.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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//-----------------------------------------------------------------------------
8// Includes
9//-----------------------------------------------------------------------------
11#include "MantidTypes/Core/DateAndTime.h"
12
13#include <boost/python/detail/prefix.hpp> // Safe include of Python.h
14#define PY_ARRAY_UNIQUE_SYMBOL CORE_ARRAY_API
15#define NO_IMPORT_ARRAY
16#include <numpy/arrayobject.h>
17
20#define DEFINE_TYPE_MAPPING(CType, NDTypeNum, NDTypeCode) \
21 template <> int NDArrayTypeIndex<CType>::typenum = NDTypeNum; \
22 template <> char NDArrayTypeIndex<CType>::typecode = NDTypeCode; \
23 template struct NDArrayTypeIndex<CType>;
24
25DEFINE_TYPE_MAPPING(int, NPY_INT, NPY_INTLTR)
26DEFINE_TYPE_MAPPING(long, NPY_LONG, NPY_LONGLTR)
27DEFINE_TYPE_MAPPING(long long, NPY_LONGLONG, NPY_LONGLONGLTR)
28DEFINE_TYPE_MAPPING(Mantid::Types::Core::DateAndTime, NPY_INT64, NPY_DATETIMELTR)
29DEFINE_TYPE_MAPPING(unsigned int, NPY_UINT, NPY_UINTLTR)
30DEFINE_TYPE_MAPPING(unsigned long, NPY_ULONG, NPY_ULONGLTR)
31DEFINE_TYPE_MAPPING(unsigned long long, NPY_ULONGLONG, NPY_ULONGLONGLTR)
32DEFINE_TYPE_MAPPING(bool, NPY_BOOL, NPY_BOOLLTR)
33DEFINE_TYPE_MAPPING(double, NPY_DOUBLE, NPY_DOUBLELTR)
34DEFINE_TYPE_MAPPING(float, NPY_FLOAT, NPY_CFLOATLTR)
35} // namespace Mantid::PythonInterface::Converters
#define DEFINE_TYPE_MAPPING(CType, NDTypeNum, NDTypeCode)
Macro to define mappings between the CType and Numpy enum.