This file is indexed.

/usr/include/odindata/utils.h is in libodin-dev 1.8.4-1ubuntu2.

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
219
220
/***************************************************************************
                          mri_utils.h  -  description
                             -------------------
    begin                : Wed Feb 9 2005
    copyright            : (C) 2005 by Thies H. Jochimsen
    email                : 
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef UTILS_H
#define UTILS_H

#include <odindata/data.h>

/**
  * @addtogroup odindata
  * @{
  */


//////////////////////////////////////////////////////////////////


/**
  * returns integer next to zero of float arrays
  */
template <int N_rank>	
Array<float,N_rank> truncate_float(Array<float,N_rank> a){
  Array<float,N_rank> result(a.shape());
  result=where(a <= 0, ceil(a),floor(a));
  return result;
}

/**
  * wraps phase of a float array (in rad !!!)
  */
template <int N_rank>
void wrapPhase(Array<float,N_rank>  ph){
  ph=ph-(truncate_float(Array<float,N_rank>(ph/(2.*PII))))*2.*PII;
  ph=ph-(truncate_float(Array<float,N_rank>(ph/PII)))*2.*PII;
}

/**
  * unwraps phase of a float array in last dimension
  */
template <int N_rank>	
void unwrapPhase1d(Data<float,N_rank> ph){

	unsigned long   i,j,dim;
    float add1;
	dim=ph.extent(ph.dimensions()-1);
  Array<float,1> phu(dim);
	wrapPhase(ph);
	
  for(i=0;i<(unsigned)ph.size()/dim;i++){
    phu(0)=ph(ph.create_index(i*dim));
    add1=0;
    for(j=1;j<dim;j++){
      	if ((ph(ph.create_index(i*dim+j))-ph(ph.create_index(i*dim+j-1))) > PII) add1=add1-2.*PII;
      	if ((ph(ph.create_index(i*dim+j))-ph(ph.create_index(i*dim+j-1))) < -PII) add1=add1+2.*PII;
      	phu(j)=ph(ph.create_index(i*dim+j))+add1;
  	}
  	add1=phu(dim/2);
  	add1=(int)(add1/2./PII)*2.*PII+(int)((add1-(int)(add1/2./PII)*2.*PII)/PII)*2.*PII;
    for(j=0;j<dim;j++)
    	ph(ph.create_index(i*dim+j))=phu(j)-add1;

    	
  }
}


//////////////////////////////////////////////////////////


/**
  * matrix-vector product
  */
template<typename T>
Array<T,1> matrix_product(const Array<T,2>& matrix, const Array<T,1>& vector) {
  Log<OdinData> odinlog("","matrix_product");
  int nrows=matrix.extent()(0);
  int ncols=matrix.extent()(1);

  Array<T,1> result(nrows);
  result=0;

  int vector_extent=vector.extent(0);
  if(vector.extent(0)!=ncols) {
    ODINLOG(odinlog,errorLog) << "size mismatch (vector_extent=" << vector_extent << ") != (ncols=" << ncols << ")" << STD_endl;
    return result;
  }


  for(int icol=0; icol<ncols; icol++) {
    for(int irow=0; irow<nrows; irow++) {
      result(irow)+=matrix(irow,icol)*vector(icol);
    }
  }

  return result;
}

//////////////////////////////////////////////////////////

/**
  * matrix-matrix product
  */
template<typename T>
Array<T,2> matrix_product(const Array<T,2>& matrix1, const Array<T,2>& matrix2) {
  Log<OdinData> odinlog("","matrix_product");
  int nrows=matrix1.extent()(0);
  int ncols=matrix2.extent()(1);
  ODINLOG(odinlog,normalDebug) << "nrows/ncols=" << nrows << "/" << ncols << STD_endl;

  Array<T,2> result(nrows,ncols);
  result=0;

  if(matrix1.extent(1)!=matrix2.extent(0)) {
    ODINLOG(odinlog,errorLog) << "size mismatch (matrix1=" << matrix1.shape() << ", matrix2=" << matrix2.shape() << ")" << STD_endl;
    return result;
  }

  int nprod=matrix1.extent(1);
  ODINLOG(odinlog,normalDebug) << "nprod=" << nprod << STD_endl;
  for(int irow=0; irow<nrows; irow++) {
    for(int icol=0; icol<ncols; icol++) {

      T scalprod(0);
      for(int iprod=0; iprod<nprod; iprod++) {
        scalprod+= matrix1(irow,iprod)*matrix2(iprod,icol);
      }
      result(irow,icol)=scalprod;
    }
  }

  return result;
}

//////////////////////////////////////////////////////////


/**
  * cross (vector) product (always in 3 dimensions)
  */
template<typename T>
Array<T,1> vector_product(const Array<T,1>& u, const Array<T,1>& v) {
  Log<OdinData> odinlog("","vector_product");
  Array<T,1> result(3);
  if(u.extent(0)!=3 || v.extent(0)!=3) {
    ODINLOG(odinlog,errorLog) << "input size != 3" << STD_endl;
    return result;
  }
  result(0)=u(1)*v(2)-u(2)*v(1);
  result(1)=u(2)*v(0)-u(0)*v(2);
  result(2)=u(0)*v(1)-u(1)*v(0);
  return result;
}


//////////////////////////////////////////////////////////

/**
  * Equal-comparison operator for TinyVectors
  */
template<typename T, int N_rank>
bool operator == (const TinyVector<T,N_rank>& t1, const TinyVector<T,N_rank>& t2) {
  return sum(abs(t1-t2))==0;
}

//////////////////////////////////////////////////////////

/**
  * Unequal-comparison operator for TinyVectors
  */
template<typename T, int N_rank>
bool operator != (const TinyVector<T,N_rank>& t1, const TinyVector<T,N_rank>& t2) {
  return !(t1==t2);
}

//////////////////////////////////////////////////////////

/**
  * Compares array shapes, returns true if equal
  */
template<typename T, int N_rank>
bool same_shape(const Array<T,N_rank>& a1, const Array<T,N_rank>& a2) {
  return a1.shape()==a2.shape();
}



////////////////////////////////////////////////////////

/**
  * Limits value 'val' to range (min,max)
  */
template <typename T>
bool check_range(T& val, T min, T max) {
  bool in_range=true;
  if(val<min) {val=min; in_range=false;}
  if(val>max) {val=max; in_range=false;}
  return in_range;
}




/** @}
  */


#endif