This file is indexed.

/usr/include/rheolef/tensor.h is in librheolef-dev 5.93-2.

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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# ifndef _RHEOLEF_TENSOR_H
# define _RHEOLEF_TENSOR_H
///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef 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.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
/// 
/// =========================================================================

/*Class:tensor
NAME: @code{tensor} - a N*N tensor, N=1,2,3
@cindex tensor
@clindex tensor
@clindex point
@clindex field
SYNOPSYS:
@noindent
The @code{tensor} class defines a 3*3 tensor, as the value of
a tensorial valued field. Basic algebra with scalars, vectors
of R^3 (i.e. the @code{point} class) and @code{tensor} objects
are supported.
AUTHOR: Pierre.Saramito@imag.fr
DATE:   9 october 2003
End:
*/

#include "rheolef/point.h"
namespace rheolef {

//<tensor:
class tensor {
    public:

	typedef size_t size_type;
	typedef Float  element_type;

// allocators:

	tensor (const Float& init_val = 0);
	tensor (Float x[3][3]);
	tensor (const tensor& a);

// affectation:

	tensor& operator = (const tensor& a);
	tensor& operator = (const Float& val);

// modifiers:

	void fill (const Float& init_val);
	void reset ();
	void set_row    (const point& r, size_t i, size_t d = 3);
	void set_column (const point& c, size_t j, size_t d = 3);

// accessors:

	Float& operator()(size_type i, size_type j);
	Float  operator()(size_type i, size_type j) const;
	point  row(size_type i) const;
	point  col(size_type i) const;
	size_t nrow() const; // = 3, for template matrix compatibility
	size_t ncol() const;

// inputs/outputs:

	friend std::istream& operator >> (std::istream& in, tensor& a);
	friend std::ostream& operator << (std::ostream& out, const tensor& a);
	std::ostream& put (std::ostream& s, size_type d = 3) const;

// algebra:

	friend bool  operator == (const tensor&, const tensor&);
	friend tensor operator - (const tensor&);
	friend tensor operator + (const tensor&, const tensor&);
	friend tensor operator - (const tensor&, const tensor&);
	friend tensor operator * (Float, const tensor&);
	friend tensor operator * (const tensor& a, Float k);
	friend tensor operator / (const tensor& a, Float k);
	friend point  operator * (const tensor& a, const point& x);
	friend point  operator * (const point& yt, const tensor& a);
	       point  trans_mult (const point& x) const;
	friend tensor trans      (const tensor& a, size_type d = 3);
	friend tensor operator * (const tensor& a, const tensor& b);
	friend tensor inv        (const tensor& a, size_type d = 3);
	friend tensor diag (const point& d);

// metric and geometric transformations:

	friend Float dotdot (const tensor&, const tensor&);
	friend Float norm2 (const tensor& a) { return dotdot(a,a); }
	friend Float dist2 (const tensor& a, const tensor& b) { return norm2(a-b); }
	friend Float norm  (const tensor& a) { return ::sqrt(norm2(a)); }
	friend Float dist  (const tensor& a, const tensor& b) { return norm(a-b); }
	Float determinant (size_type d = 3) const;
	friend Float determinant (const tensor& A, size_t d = 3);
	friend bool invert_3x3 (const tensor& A, tensor& result);

// spectral:
	// eigenvalues & eigenvectors:
	// a = q*d*q^T
	// a may be symmetric
	// where q=(q1,q2,q3) are eigenvectors in rows (othonormal matrix)
	// and   d=(d1,d2,d3) are eigenvalues, sorted in decreasing order d1 >= d2 >= d3
	// return d
	point eig (tensor& q, size_t dim = 3) const;
	point eig (size_t dim = 3) const;

	// singular value decomposition:
	// a = u*s*v^T
	// a can be unsymmetric
	// where u=(u1,u2,u3) are left pseudo-eigenvectors in rows (othonormal matrix)
	//       v=(v1,v2,v3) are right pseudo-eigenvectors in rows (othonormal matrix)
	// and   s=(s1,s2,s3) are eigenvalues, sorted in decreasing order s1 >= s2 >= s3
	// return s
	point svd (tensor& u, tensor& v, size_t dim = 3) const;

// data:
	Float _x[3][3];
// internal:
	std::istream& get (std::istream&);
};
// t = a otimes b
tensor otimes (const point& a, const point& b, size_t na = 3);
// t += a otimes b
void cumul_otimes (tensor& t, const point& a, const point& b, size_t na = 3);
void cumul_otimes (tensor& t, const point& a, const point& b, size_t na, size_t nb);
//>tensor:

// -----------------------------------------------------------------------
// inlined
// -----------------------------------------------------------------------

inline
void
tensor::fill (const Float& init_val)
{ 
    for (size_type i = 0; i < 3; i++) for (size_type j = 0; j < 3; j++)
      _x[i][j] = init_val;
}
inline
void
tensor::reset ()
{
    fill (0);
}
inline
tensor::tensor (const Float& init_val)
{ 
    fill (init_val);
}
inline
tensor::tensor (Float x[3][3])
{
    for (size_type i = 0; i < 3; i++) for (size_type j = 0; j < 3; j++)
      _x[i][j] = x[i][j];
}
inline
tensor::tensor (const tensor& a)
{
    for (size_type i = 0; i < 3; i++) for (size_type j = 0; j < 3; j++)
      _x[i][j] = a._x[i][j];
}
inline
tensor&
tensor::operator = (const tensor& a)
{
    for (size_type i = 0; i < 3; i++) for (size_type j = 0; j < 3; j++)
      _x[i][j] = a._x[i][j];
    return *this;
}
inline
tensor&
tensor::operator = (const Float& val)
{
    for (size_type i = 0; i < 3; i++) for (size_type j = 0; j < 3; j++)
      _x[i][j] = val;
    return *this;
}
inline
size_t
tensor::nrow() const
{
  return 3;
}
inline
size_t
tensor::ncol() const
{
  return 3;
}
inline
Float&
tensor::operator()(size_type i, size_type j)  
{
    return _x[i%3][j%3];
}
inline
Float
tensor::operator()(size_type i, size_type j) const
{
    return _x[i%3][j%3];
}
inline
std::istream& operator >> (std::istream& in, tensor& a)
{
    return a.get (in);
}
inline
std::ostream& operator << (std::ostream& out, const tensor& a)
{
    return a.put (out); 
}
inline
tensor
operator * (const tensor& a, Float k)
{
    return k*a;
}
inline
tensor
operator / (const tensor& a, Float k)
{
    return (1/k)*a;
}
inline
point
tensor::trans_mult (const point& x) const
{
    return x*(*this);
}
inline
void
cumul_otimes (tensor& t, const point& a, const point& b, size_t n)
{
    cumul_otimes (t, a, b, n, n);
}
inline
tensor
otimes (const point& a, const point& b, size_t n)
{
    tensor t;
    cumul_otimes (t, a, b, n, n);
    return t;
}
inline
Float
determinant (const tensor& A, size_t d)
{ 
    return A.determinant (d);
}
inline
tensor
diag (const point& d)
{
  tensor a;
  a(0,0) = d[0];
  a(1,1) = d[1];
  a(2,2) = d[2];
  return a;
}
inline
void
tensor::set_column (const point& c, size_t j, size_t d)
{
  for (size_t i = 0; i < d; i++)
    operator()(i,j) = c[i];
}
inline
void
tensor::set_row (const point& r, size_t i, size_t d)
{
  for (size_t j = 0; j < d; j++)
    operator()(i,j) = r[j];
}
}// namespace rheolef
# endif /* _RHEOLEF_TENSOR_H */