/usr/include/shogun/lib/SGNDArray.h is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2012 Fernando José Iglesias García
* Written (W) 2010,2012 Soeren Sonnenburg
* Copyright (C) 2010 Berlin Institute of Technology
* Copyright (C) 2012 Soeren Sonnenburg
*/
#ifndef __SGNDARRAY_H__
#define __SGNDARRAY_H__
#include <shogun/lib/config.h>
#include <shogun/lib/DataType.h>
#include <shogun/lib/SGReferencedData.h>
namespace shogun
{
/** @brief shogun n-dimensional array */
template<class T> class SGNDArray : public SGReferencedData
{
public:
/** default constructor */
SGNDArray();
/** constructor for setting params */
SGNDArray(T* a, index_t* d, index_t nd, bool ref_counting=true);
/** constructor to create new ndarray in memory */
SGNDArray(index_t* d, index_t nd, bool ref_counting=true);
/** copy constructor */
SGNDArray(const SGNDArray &orig);
/** empty destructor */
virtual ~SGNDArray();
/** get a matrix formed by the two first dimensions
*
* @param matIdx matrix index
* @return pointer to the matrix
*/
T* get_matrix(index_t matIdx) const
{
ASSERT(array && dims && num_dims > 2 && dims[2] > matIdx)
return &array[int64_t(matIdx)*int64_t(dims[0])*dims[1]];
}
/** transposes a matrix formed by the two first dimensions
*
* @param matIdx matrix index
*/
void transpose_matrix(index_t matIdx) const;
/** operator overload for ndarray read only access
*
* @param index to access
*/
inline const T& operator[](index_t index) const
{
return array[index];
}
/** operator overload for ndarray r/w access
*
* @param index to access
*/
inline T& operator[](index_t index)
{
return array[index];
}
protected:
/** copy data */
virtual void copy_data(const SGReferencedData &orig);
/** init data */
virtual void init_data();
/** free data */
virtual void free_data();
public:
/** array */
T* array;
/** dimension sizes */
index_t* dims;
/** number of dimensions */
index_t num_dims;
};
}
#endif // __SGNDARRAY_H__
|