// -*- C++ -*-
// automatically generated by autodoc

// ========== HEADER FILE src/aux2/applyfunc2d.h: ==========

inline void apply_func(Type **f, ulong nr, ulong nc, Type (*func)(Type));
// apply function func to each element of f[]

// ========== HEADER FILE src/aux2/arith2d.h: ==========

inline Type sum(const Type *const*f, ulong nr, ulong nc);
// return \sum_{k,j} {f[k][j]}

inline Type sum_of_squares(const Type *const*f, ulong nr, ulong nc);
// return \sum_{k,j} {f[k][j]*f[k][j]}

inline void negate(Type **f, ulong nr, ulong nc);
// negate every value of f[][]

inline void add_val(Type **f, ulong nr, ulong nc, Type s);
// f[][] += g

inline void subtract_val(Type **f, ulong nr, ulong nc, Type s);
// f[][] -= g

inline void multiply_val(Type **f, ulong nr, ulong nc, Type s);
// f[][] *= s

inline void add(Type **f, ulong nr, ulong nc, const Type *const*g);
// f[][] += g[][] element-wise

inline void subtract(Type **f, ulong nr, ulong nc, const Type *const*g);
// f[][] -= g[][] element-wise

inline void multiply(Type **f, ulong nr, ulong nc, const Type *const*g);
// f[][] *= g[][] element-wise

inline void divide(Type **f, ulong nr, ulong nc, const Type *const*g);
// f[][] /= g[][]  (no check for overflow !)

// ========== HEADER FILE src/aux2/array2d.h: ==========

// ----- SRCFILE=src/aux2/array2d.cc: -----
void row_assert(ulong r, ulong nr);

class array2d;

array2d<Type>::array2d(ulong nr, ulong nc, Type *f/*=0*/);
    : nc_(nc), nr_(nr), n_(nc*nr),
      maxrc_( ::max2(nr_, nc_) ),
      minrc_( ::min2(nr_, nc_) )

array2d<Type>::array2d(ulong nr, ulong nc, Type **rowp);
    : nc_(nc), nr_(nr), n_(nc*nr),
      maxrc_( ::max2(nr_, nc_) ),
      minrc_( ::min2(nr_, nc_) )

array2d<Type>::~array2d();

void copy(const array2d<Type1> &src, array2d<Type2> &dst);

void copy(const array2d<Type1> &src, array2d<Type2> &dst,;
          ulong coff, ulong roff)

void transpose(const array2d<Type> &src, array2d<Type> &dst);

void array2d<Type>::transpose();

// ========== HEADER FILE src/aux2/copy2d.h: ==========

void null(Type **f, ulong nr, ulong nc);
// set values to zero

void fill(Type **f, ulong nr, ulong nc, Type v);
// set values to v

void copy(const Type1 *const*src, Type2 **dst, ulong nr, ulong nc);

void offset_copy(const Type1 *const*src, ulong nrs, ulong ncs,;
                 Type2 **dst, ulong nrd, ulong ncd,
                 ulong coff=0,
                 ulong roff=0)
//
// copy (as much data as possible)
// src[r+roff][c+coff] --> dst[r][c]
//

// ========== HEADER FILE src/aux2/minmax2d.h: ==========

Type min(const Type **f, ulong nr, ulong nc);
// find min and max

Type max(const Type **f, ulong nr, ulong nc);
// find min and max

void min_max(const Type **f, ulong nr, ulong nc, Type *mi, Type *ma);
// find min and max

// ========== HEADER FILE src/aux2/reverse2d.h: ==========

void reverse_horiz(Type **f, ulong nr, ulong nc);
// reverse order of rows

void reverse_vert(Type **f, ulong nr, ulong nc);
// reverse order of rows

// ========== HEADER FILE src/aux2/rotate2d.h: ==========

void rotate_up(Type **f, ulong nr, ulong nc, ulong s);
// rotate towards row #0

void rotate_down(Type **f, ulong nr, ulong nc, ulong s);
// rotate away from row #0

void rotate_vert(Type **f, ulong nr, ulong nc, long s);

void rotate_left(Type **f, ulong nr, ulong nc, ulong s);
// rotate towards col #0

void rotate_right(Type **f, ulong nr, ulong nc, ulong s);
// rotate away from col #0

void rotate_horiz(Type **f, ulong nr, ulong nc, long s);

void rotate_vh(Type **f, ulong nr, ulong nc, long vert, long horiz);

void zero2center(Type **f, ulong nr, ulong nc);
// useful for 2dim FFTs:
// brings zero freq to midpoint

// ========== HEADER FILE src/aux2/scale2d.h: ==========

void linear_scale(Type **f, ulong nr, ulong nc,;
                  Type nmi, Type nma)   // new min, max
// linear scale so that
//   new_min==nmi,  ne_max==nma

void linear_scale(Type **f, ulong nr, ulong nc,;
                  Type mi, Type ma,     // old min, max
                  Type nmi, Type nma)   // new min, max
// linear scale so that
//   new_min==nmi,  ne_max==nma
// supply (or pretend) old min and max

void log_scale(Type **f, ulong nr, ulong nc,;
               double xi, double xa, Type nma)

// ========== HEADER FILE src/aux2/shift2d.h: ==========

void shift_left(Type **f, ulong nr, ulong nc, ulong s);
// shift towards col #0

void shift_right(Type **f, ulong nr, ulong nc, ulong s);
// shift away from col #0

void shift_horiz(Type **f, ulong nr, ulong nc, long s);
// shift each row:
// if s>0  shift right
// else    shift left

void shift_up(Type **f, ulong nr, ulong nc, ulong s);
// shift towards row #0
// (analogue to 'shift left columns')

void shift_down(Type **f, ulong nr, ulong nc, ulong s);
// shift away from row #0
// (analogue to 'shift right columns')

void shift_vert(Type **f, ulong nr, ulong nc, long s);
// if s>0  shift up
// else    shift down


void shift_vh(Type **f, ulong nr, ulong nc, long vert, long horiz);
// shift both horiz/vert

// ========== HEADER FILE src/aux2/transpose.h: ==========

void transpose_square(Type **f, ulong nrc);
// In-place transposition of an nr x nc array (nr = nc = nrc)
// that lies at nr rows of length nc

void transpose_square(Type *f, ulong nrc);
// In-place transposition of an nr x nc array (nr = nc = nrc)
// that lies in contiguous memory

void transpose(const Type * restrict f, Type * restrict g, ulong nr, ulong nc);
// Transpose nr x nc matrix f[]  into an nc x nr matrix g[].

void transpose(Type *f, ulong nr, ulong nc, bitarray *ba=0);
// In-place transposition of an  nr X nc  array
// that lies in contiguous memory.
//.
// Use bitarray for tagging moved elements.

// ========== HEADER FILE src/aux2/transpose2.h: ==========

void transpose2(Type *f, ulong nr, ulong nc, bitarray *ba=0);
// In-place transposition of an  nr X nc  array
//   that lies in contiguous memory.
// Special case where both nr and nc are power of 2.
//.
// Use bitarray for tagging moved elements.

