/usr/include/ITK-4.9/vnl/vnl_block.h is in libinsighttoolkit4-dev 4.9.0-4ubuntu1.
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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | // This is core/vnl/vnl_block.h
#ifndef vnl_block_h_
#define vnl_block_h_
#ifdef VCL_NEEDS_PRAGMA_INTERFACE
#pragma interface
#endif
//:
// \file
// \author fsm
//
// \verbatim
// Modifications
// 2009-03-30 Peter Vanroose - Added arg_min() & arg_max() and reimplemented min_value() & max_value()
// \endverbatim
//
#include <vcl_compiler.h>
void vnl_block_raise_exception(char const *FILE, int LINE, char const *why);
//: return sum of elements
template <class T> inline
T vnl_block_sum(T const x[], unsigned n)
{
if (n == 0)
return T(0);
else {
T ans = x[0];
for (unsigned i=1; i<n; ++i)
ans += x[i];
return ans;
}
}
//: return product of elements
template <class T> inline
T vnl_block_product(T const x[], unsigned n)
{
if (n == 0)
return T(1);
else {
T ans = x[0];
for (unsigned i=1; i<n; ++i)
ans *= x[i];
return ans;
}
}
//: return smallest value.
template <class T> inline
T vnl_block_min_value(T const *x, unsigned n)
{
if (n == 0)
vnl_block_raise_exception(__FILE__, __LINE__, "n is 0");
T ans = *x;
while (--n > 0)
if (ans > *++x)
ans = *x;
return ans;
}
//: return largest value.
template <class T> inline
T vnl_block_max_value(T const *x, unsigned n)
{
if (n == 0)
vnl_block_raise_exception(__FILE__, __LINE__, "n is 0");
T ans = *x;
while (--n > 0)
if (ans < *++x)
ans = *x;
return ans;
}
//: return index of smallest value.
template <class T> inline
unsigned vnl_block_arg_min(T const x[], unsigned n)
{
if (n == 0)
vnl_block_raise_exception(__FILE__, __LINE__, "n is 0");
T tmp = *x;
unsigned idx = 0;
for (unsigned i=1; i<n; ++i)
if (tmp > *++x)
tmp = *x, idx = i;
return idx;
}
//: return index of largest value.
template <class T> inline
unsigned vnl_block_arg_max(T const x[], unsigned n)
{
if (n == 0)
vnl_block_raise_exception(__FILE__, __LINE__, "n is 0");
T tmp = *x;
unsigned idx = 0;
for (unsigned i=1; i<n; ++i)
if (tmp < *++x)
tmp = *x, idx = i;
return idx;
}
//: y[i] = x[i]
template <class T> inline
void vnl_block_copy(T const x[], T y[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
y[i] = x[i];
}
//: reverses sequence
template <class T> inline
void vnl_block_reverse(T x[], unsigned n)
{
T tmp;
for (unsigned i=0; 2*i<n; ++i) {
tmp = x[i];
x[i] = x[n-1-i];
x[n-1-i] = tmp;
}
}
//: x[i] *= a
template <class T> inline
void vnl_block_scale(T a, T x[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
x[i] *= a;
}
//: y[i] = a * x[i]
template <class T> inline
void vnl_block_scale(T a, T const x[], T y[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
y[i] = a * x[i];
}
//: y[i] += x[i]
template <class T> inline
void vnl_block_add(T const x[], T y[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
y[i] += x[i];
}
//: z[i] = x[i] + y[i]
template <class T> inline
void vnl_block_add(T const x[], T const y[], T z[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
z[i] = x[i] + y[i];
}
//: z[i] = x[i] - y[i]
template <class T> inline
void vnl_block_sub(T const x[], T const y[], T z[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
z[i] = x[i] - y[i];
}
//: y[i] *= x[i]
template <class T> inline
void vnl_block_mul(T const x[], T y[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
y[i] *= x[i];
}
//: z[i] = x[i] * y[i]
template <class T> inline
void vnl_block_mul(T const x[], T const y[], T z[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
z[i] = x[i] * y[i];
}
//: z[i] = x[i] / y[i]
template <class T> inline
void vnl_block_div(T const x[], T const y[], T z[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
z[i] = x[i] / y[i];
}
//: y[i] = -x[i]
template <class T> inline
void vnl_block_negate(T const x[], T y[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
y[i] = - x[i];
}
//: y[i] = 1/x[i]
template <class T> inline
void vnl_block_invert(T const x[], T y[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
y[i] = T(1) / x[i];
}
//: y[i] += a * x[i]
template <class T> inline
void vnl_block_axpy(T a, T const x[], T y[], unsigned n)
{
for (unsigned i=0; i<n; ++i)
y[i] += a * x[i];
}
//: x[i] = v
template <class T> inline
void vnl_block_fill(T x[], unsigned n, T value)
{
for (unsigned i=0; i<n; ++i)
x[i] = value;
}
#endif // vnl_block_h_
|