2 * Copyright (C) 2012-2021 Euclid Science Ground Segment
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 3.0 of the License, or (at your option)
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22#include <machine/endian.h>
26#include "NdArray/NdArray.h"
28#include <ElementsKernel/Exception.h>
29#include <boost/endian/arithmetic.hpp>
36 * Implementation of writeNpy
39void writeNpy(std::ostream& out, const NdArray<T>& array) {
40 writeNpyHeader<T>(out, array.shape(), array.attributes());
41 // The header already has the endian type, so just dump the content of the array
42 for (auto v : array) {
43 out.write(reinterpret_cast<const char*>(&v), sizeof(v));
47} // end of namespace NdArray
48} // end of namespace Euclid