This file is indexed.

/usr/include/simgear/math/SGMatrix.hxx is in libsimgear-dev 3.0.0-1.

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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
// Copyright (C) 2006  Mathias Froehlich - Mathias.Froehlich@web.de
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//

#ifndef SGMatrix_H
#define SGMatrix_H

/// Expression templates for poor programmers ... :)
template<typename T>
struct TransNegRef;

/// 3D Matrix Class
template<typename T>
class SGMatrix {
public:
  enum { nCols = 4, nRows = 4, nEnts = 16 };
  typedef T value_type;

  /// Default constructor. Does not initialize at all.
  /// If you need them zero initialized, use SGMatrix::zeros()
  SGMatrix(void)
  {
    /// Initialize with nans in the debug build, that will guarantee to have
    /// a fast uninitialized default constructor in the release but shows up
    /// uninitialized values in the debug build very fast ...
#ifndef NDEBUG
    for (unsigned i = 0; i < nEnts; ++i)
      _data.flat[i] = SGLimits<T>::quiet_NaN();
#endif
  }
  /// Constructor. Initialize by the content of a plain array,
  /// make sure it has at least 16 elements
  explicit SGMatrix(const T* data)
  { for (unsigned i = 0; i < nEnts; ++i) _data.flat[i] = data[i]; }

  /// Constructor, build up a SGMatrix from given elements
  SGMatrix(T m00, T m01, T m02, T m03,
           T m10, T m11, T m12, T m13,
           T m20, T m21, T m22, T m23,
           T m30, T m31, T m32, T m33)
  {
    _data.flat[0] = m00; _data.flat[1] = m10;
    _data.flat[2] = m20; _data.flat[3] = m30;
    _data.flat[4] = m01; _data.flat[5] = m11;
    _data.flat[6] = m21; _data.flat[7] = m31;
    _data.flat[8] = m02; _data.flat[9] = m12;
    _data.flat[10] = m22; _data.flat[11] = m32;
    _data.flat[12] = m03; _data.flat[13] = m13;
    _data.flat[14] = m23; _data.flat[15] = m33;
  }

  /// Constructor, build up a SGMatrix from a translation
  template<typename S>
  SGMatrix(const SGVec3<S>& trans)
  { set(trans); }

  /// Constructor, build up a SGMatrix from a rotation and a translation
  template<typename S>
  SGMatrix(const SGQuat<S>& quat)
  { set(quat); }

  /// Copy constructor for a transposed negated matrix
  SGMatrix(const TransNegRef<T>& tm)
  { set(tm); }

  /// Set from a tranlation
  template<typename S>
  void set(const SGVec3<S>& trans)
  {
    _data.flat[0] = 1; _data.flat[4] = 0;
    _data.flat[8] = 0; _data.flat[12] = T(trans(0));
    _data.flat[1] = 0; _data.flat[5] = 1;
    _data.flat[9] = 0; _data.flat[13] = T(trans(1));
    _data.flat[2] = 0; _data.flat[6] = 0;
    _data.flat[10] = 1; _data.flat[14] = T(trans(2));
    _data.flat[3] = 0; _data.flat[7] = 0;
    _data.flat[11] = 0; _data.flat[15] = 1;
  }

  /// Set from a scale/rotation and tranlation
  template<typename S>
  void set(const SGQuat<S>& quat)
  {
    T w = quat.w(); T x = quat.x(); T y = quat.y(); T z = quat.z();
    T xx = x*x; T yy = y*y; T zz = z*z;
    T wx = w*x; T wy = w*y; T wz = w*z;
    T xy = x*y; T xz = x*z; T yz = y*z;
    _data.flat[0] = 1-2*(yy+zz); _data.flat[1] = 2*(xy-wz);
    _data.flat[2] = 2*(xz+wy); _data.flat[3] = 0;
    _data.flat[4] = 2*(xy+wz); _data.flat[5] = 1-2*(xx+zz);
    _data.flat[6] = 2*(yz-wx); _data.flat[7] = 0;
    _data.flat[8] = 2*(xz-wy); _data.flat[9] = 2*(yz+wx);
    _data.flat[10] = 1-2*(xx+yy); _data.flat[11] = 0;
    _data.flat[12] = 0; _data.flat[13] = 0;
    _data.flat[14] = 0; _data.flat[15] = 1;
  }

  /// set from a transposed negated matrix
  void set(const TransNegRef<T>& tm)
  {
    const SGMatrix& m = tm.m;
    _data.flat[0] = m(0,0);
    _data.flat[1] = m(0,1);
    _data.flat[2] = m(0,2);
    _data.flat[3] = m(3,0);

    _data.flat[4] = m(1,0);
    _data.flat[5] = m(1,1);
    _data.flat[6] = m(1,2);
    _data.flat[7] = m(3,1);

    _data.flat[8] = m(2,0);
    _data.flat[9] = m(2,1);
    _data.flat[10] = m(2,2);
    _data.flat[11] = m(3,2);

    // Well, this one is ugly here, as that xform method on the current
    // object needs the above data to be already set ...
    SGVec3<T> t = xformVec(SGVec3<T>(m(0,3), m(1,3), m(2,3)));
    _data.flat[12] = -t(0);
    _data.flat[13] = -t(1);
    _data.flat[14] = -t(2);
    _data.flat[15] = m(3,3);
  }

  /// Access by index, the index is unchecked
  const T& operator()(unsigned i, unsigned j) const
  { return _data.flat[i + 4*j]; }
  /// Access by index, the index is unchecked
  T& operator()(unsigned i, unsigned j)
  { return _data.flat[i + 4*j]; }

  /// Access raw data by index, the index is unchecked
  const T& operator[](unsigned i) const
  { return _data.flat[i]; }
  /// Access by index, the index is unchecked
  T& operator[](unsigned i)
  { return _data.flat[i]; }

  /// Get the data pointer
  const T* data(void) const
  { return _data.flat; }
  /// Get the data pointer
  T* data(void)
  { return _data.flat; }

  /// Readonly interface function to ssg's sgMat4/sgdMat4
  const T (&sg(void) const)[4][4]
  { return _data.carray; }
  /// Interface function to ssg's sgMat4/sgdMat4
  T (&sg(void))[4][4]
  { return _data.carray; }

  /// Inplace addition
  SGMatrix& operator+=(const SGMatrix& m)
  { for (unsigned i = 0; i < nEnts; ++i) _data.flat[i] += m._data.flat[i]; return *this; }
  /// Inplace subtraction
  SGMatrix& operator-=(const SGMatrix& m)
  { for (unsigned i = 0; i < nEnts; ++i) _data.flat[i] -= m._data.flat[i]; return *this; }
  /// Inplace scalar multiplication
  template<typename S>
  SGMatrix& operator*=(S s)
  { for (unsigned i = 0; i < nEnts; ++i) _data.flat[i] *= s; return *this; }
  /// Inplace scalar multiplication by 1/s
  template<typename S>
  SGMatrix& operator/=(S s)
  { return operator*=(1/T(s)); }
  /// Inplace matrix multiplication, post multiply
  SGMatrix& operator*=(const SGMatrix<T>& m2);

  template<typename S>
  SGMatrix& preMultTranslate(const SGVec3<S>& t)
  {
    for (unsigned i = 0; i < 3; ++i) {
      T tmp = T(t(i));
      if (tmp == 0)
        continue;
      (*this)(i,0) += tmp*(*this)(3,0);
      (*this)(i,1) += tmp*(*this)(3,1);
      (*this)(i,2) += tmp*(*this)(3,2);
      (*this)(i,3) += tmp*(*this)(3,3);
    }
    return *this;
  }
  template<typename S>
  SGMatrix& postMultTranslate(const SGVec3<S>& t)
  {
    SGVec4<T> col3((*this)(0,3), (*this)(1,3), (*this)(2,3), (*this)(3,3));
    for (unsigned i = 0; i < SGMatrix<T>::nCols-1; ++i) {
      SGVec4<T> tmp((*this)(0,i), (*this)(1,i), (*this)(2,i), (*this)(3,i));
      col3 += T(t(i))*tmp;
    }
    (*this)(0,3) = col3(0); (*this)(1,3) = col3(1);
    (*this)(2,3) = col3(2); (*this)(3,3) = col3(3);
    return *this;
  }

  SGMatrix& preMultRotate(const SGQuat<T>& r)
  {
    for (unsigned i = 0; i < SGMatrix<T>::nCols; ++i) {
      SGVec3<T> col((*this)(0,i), (*this)(1,i), (*this)(2,i));
      col = r.transform(col);
      (*this)(0,i) = col(0); (*this)(1,i) = col(1); (*this)(2,i) = col(2);
    }
    return *this;
  }
  SGMatrix& postMultRotate(const SGQuat<T>& r)
  {
    for (unsigned i = 0; i < SGMatrix<T>::nCols; ++i) {
      SGVec3<T> col((*this)(i,0), (*this)(i,1), (*this)(i,2));
      col = r.backTransform(col);
      (*this)(i,0) = col(0); (*this)(i,1) = col(1); (*this)(i,2) = col(2);
    }
    return *this;
  }

  SGVec3<T> xformPt(const SGVec3<T>& pt) const
  {
    SGVec3<T> tpt;
    tpt(0) = (*this)(0,3);
    tpt(1) = (*this)(1,3);
    tpt(2) = (*this)(2,3);
    for (unsigned i = 0; i < SGMatrix<T>::nCols-1; ++i) {
      T tmp = pt(i);
      tpt(0) += tmp*(*this)(0,i);
      tpt(1) += tmp*(*this)(1,i);
      tpt(2) += tmp*(*this)(2,i);
    }
    return tpt;
  }
  SGVec3<T> xformVec(const SGVec3<T>& v) const
  {
    SGVec3<T> tv;
    T tmp = v(0);
    tv(0) = tmp*(*this)(0,0);
    tv(1) = tmp*(*this)(1,0);
    tv(2) = tmp*(*this)(2,0);
    for (unsigned i = 1; i < SGMatrix<T>::nCols-1; ++i) {
      T tmp = v(i);
      tv(0) += tmp*(*this)(0,i);
      tv(1) += tmp*(*this)(1,i);
      tv(2) += tmp*(*this)(2,i);
    }
    return tv;
  }

  /// Return an all zero matrix
  static SGMatrix zeros(void)
  { return SGMatrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); }

  /// Return a unit matrix
  static SGMatrix unit(void)
  { return SGMatrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); }

private:
  /// Required to make that alias safe.
  union Data {
    T flat[16];
    T carray[4][4];
  };

  /// The actual data, the matrix is stored in column major order,
  /// that matches the storage format of OpenGL
  Data _data;
};

/// Class to distinguish between a matrix and the matrix with a transposed
/// rotational part and a negated translational part
template<typename T>
struct TransNegRef {
  TransNegRef(const SGMatrix<T>& _m) : m(_m) {}
  const SGMatrix<T>& m;
};

/// Unary +, do nothing ...
template<typename T>
inline
const SGMatrix<T>&
operator+(const SGMatrix<T>& m)
{ return m; }

/// Unary -, do nearly nothing
template<typename T>
inline
SGMatrix<T>
operator-(const SGMatrix<T>& m)
{
  SGMatrix<T> ret;
  for (unsigned i = 0; i < SGMatrix<T>::nEnts; ++i)
    ret[i] = -m[i];
  return ret;
}

/// Binary +
template<typename T>
inline
SGMatrix<T>
operator+(const SGMatrix<T>& m1, const SGMatrix<T>& m2)
{
  SGMatrix<T> ret;
  for (unsigned i = 0; i < SGMatrix<T>::nEnts; ++i)
    ret[i] = m1[i] + m2[i];
  return ret;
}

/// Binary -
template<typename T>
inline
SGMatrix<T>
operator-(const SGMatrix<T>& m1, const SGMatrix<T>& m2)
{
  SGMatrix<T> ret;
  for (unsigned i = 0; i < SGMatrix<T>::nEnts; ++i)
    ret[i] = m1[i] - m2[i];
  return ret;
}

/// Scalar multiplication
template<typename S, typename T>
inline
SGMatrix<T>
operator*(S s, const SGMatrix<T>& m)
{
  SGMatrix<T> ret;
  for (unsigned i = 0; i < SGMatrix<T>::nEnts; ++i)
    ret[i] = s*m[i];
  return ret;
}

/// Scalar multiplication
template<typename S, typename T>
inline
SGMatrix<T>
operator*(const SGMatrix<T>& m, S s)
{
  SGMatrix<T> ret;
  for (unsigned i = 0; i < SGMatrix<T>::nEnts; ++i)
    ret[i] = s*m[i];
  return ret;
}

/// Vector multiplication
template<typename T>
inline
SGVec4<T>
operator*(const SGMatrix<T>& m, const SGVec4<T>& v)
{
  SGVec4<T> mv;
  T tmp = v(0);
  mv(0) = tmp*m(0,0);
  mv(1) = tmp*m(1,0);
  mv(2) = tmp*m(2,0);
  mv(3) = tmp*m(3,0);
  for (unsigned i = 1; i < SGMatrix<T>::nCols; ++i) {
    T tmp = v(i);
    mv(0) += tmp*m(0,i);
    mv(1) += tmp*m(1,i);
    mv(2) += tmp*m(2,i);
    mv(3) += tmp*m(3,i);
  }
  return mv;
}

/// Vector multiplication
template<typename T>
inline
SGVec4<T>
operator*(const TransNegRef<T>& tm, const SGVec4<T>& v)
{
  const SGMatrix<T>& m = tm.m;
  SGVec4<T> mv;
  SGVec3<T> v2;
  T tmp = v(3);
  mv(0) = v2(0) = -tmp*m(0,3);
  mv(1) = v2(1) = -tmp*m(1,3);
  mv(2) = v2(2) = -tmp*m(2,3);
  mv(3) = tmp*m(3,3);
  for (unsigned i = 0; i < SGMatrix<T>::nCols - 1; ++i) {
    T tmp = v(i) + v2(i);
    mv(0) += tmp*m(i,0);
    mv(1) += tmp*m(i,1);
    mv(2) += tmp*m(i,2);
    mv(3) += tmp*m(3,i);
  }
  return mv;
}

/// Matrix multiplication
template<typename T>
inline
SGMatrix<T>
operator*(const SGMatrix<T>& m1, const SGMatrix<T>& m2)
{
  SGMatrix<T> m;
  for (unsigned j = 0; j < SGMatrix<T>::nCols; ++j) {
    T tmp = m2(0,j);
    m(0,j) = tmp*m1(0,0);
    m(1,j) = tmp*m1(1,0);
    m(2,j) = tmp*m1(2,0);
    m(3,j) = tmp*m1(3,0);
    for (unsigned i = 1; i < SGMatrix<T>::nCols; ++i) {
      T tmp = m2(i,j);
      m(0,j) += tmp*m1(0,i);
      m(1,j) += tmp*m1(1,i);
      m(2,j) += tmp*m1(2,i);
      m(3,j) += tmp*m1(3,i);
    }
  }
  return m;
}

/// Inplace matrix multiplication, post multiply
template<typename T>
inline
SGMatrix<T>&
SGMatrix<T>::operator*=(const SGMatrix<T>& m2)
{ (*this) = operator*(*this, m2); return *this; }

/// Return a reference to the matrix typed to make sure we use the transposed
/// negated matrix
template<typename T>
inline
TransNegRef<T>
transNeg(const SGMatrix<T>& m)
{ return TransNegRef<T>(m); }

/// Compute the inverse if the matrix src. Store the result in dst.
/// Return if the matrix is nonsingular. If it is singular dst contains
/// undefined values
template<typename T>
inline
bool
invert(SGMatrix<T>& dst, const SGMatrix<T>& src)
{
  // Do a LU decomposition with row pivoting and solve into dst
  SGMatrix<T> tmp = src;
  dst = SGMatrix<T>::unit();

  for (unsigned i = 0; i < 4; ++i) {
    T val = tmp(i,i);
    unsigned ind = i;

    // Find the row with the maximum value in the i-th colum
    for (unsigned j = i + 1; j < 4; ++j) {
      if (fabs(tmp(j, i)) > fabs(val)) {
        ind = j;
        val = tmp(j, i);
      }
    }

    // Do row pivoting
    if (ind != i) {
      for (unsigned j = 0; j < 4; ++j) {
        T t;
        t = dst(i,j); dst(i,j) = dst(ind,j); dst(ind,j) = t;
        t = tmp(i,j); tmp(i,j) = tmp(ind,j); tmp(ind,j) = t;
      }
    }

    // Check for singularity
    if (fabs(val) <= SGLimits<T>::min())
      return false;

    T ival = 1/val;
    for (unsigned j = 0; j < 4; ++j) {
      tmp(i,j) *= ival;
      dst(i,j) *= ival;
    }

    for (unsigned j = 0; j < 4; ++j) {
      if (j == i)
        continue;

      val = tmp(j,i);
      for (unsigned k = 0; k < 4; ++k) {
        tmp(j,k) -= tmp(i,k) * val;
        dst(j,k) -= dst(i,k) * val;
      }
    }
  }
  return true;
}

/// The 1-norm of the matrix, this is the largest column sum of
/// the absolute values of A.
template<typename T>
inline
T
norm1(const SGMatrix<T>& m)
{
  T nrm = 0;
  for (unsigned i = 0; i < SGMatrix<T>::nRows; ++i) {
    T sum = fabs(m(i, 0)) + fabs(m(i, 1)) + fabs(m(i, 2)) + fabs(m(i, 3));
    if (nrm < sum)
      nrm = sum;
  }
  return nrm;
}

/// The inf-norm of the matrix, this is the largest row sum of
/// the absolute values of A.
template<typename T>
inline
T
normInf(const SGMatrix<T>& m)
{
  T nrm = 0;
  for (unsigned i = 0; i < SGMatrix<T>::nCols; ++i) {
    T sum = fabs(m(0, i)) + fabs(m(1, i)) + fabs(m(2, i)) + fabs(m(3, i));
    if (nrm < sum)
      nrm = sum;
  }
  return nrm;
}

/// Return true if exactly the same
template<typename T>
inline
bool
operator==(const SGMatrix<T>& m1, const SGMatrix<T>& m2)
{
  for (unsigned i = 0; i < SGMatrix<T>::nEnts; ++i)
    if (m1[i] != m2[i])
      return false;
  return true;
}

/// Return true if not exactly the same
template<typename T>
inline
bool
operator!=(const SGMatrix<T>& m1, const SGMatrix<T>& m2)
{ return ! (m1 == m2); }

/// Return true if equal to the relative tolerance tol
template<typename T>
inline
bool
equivalent(const SGMatrix<T>& m1, const SGMatrix<T>& m2, T rtol, T atol)
{ return norm1(m1 - m2) < rtol*(norm1(m1) + norm1(m2)) + atol; }

/// Return true if equal to the relative tolerance tol
template<typename T>
inline
bool
equivalent(const SGMatrix<T>& m1, const SGMatrix<T>& m2, T rtol)
{ return norm1(m1 - m2) < rtol*(norm1(m1) + norm1(m2)); }

/// Return true if about equal to roundoff of the underlying type
template<typename T>
inline
bool
equivalent(const SGMatrix<T>& m1, const SGMatrix<T>& m2)
{
  T tol = 100*SGLimits<T>::epsilon();
  return equivalent(m1, m2, tol, tol);
}

#ifndef NDEBUG
template<typename T>
inline
bool
isNaN(const SGMatrix<T>& m)
{
  for (unsigned i = 0; i < SGMatrix<T>::nEnts; ++i) {
    if (SGMisc<T>::isNaN(m[i]))
      return true;
  }
  return false;
}
#endif

/// Output to an ostream
template<typename char_type, typename traits_type, typename T> 
inline
std::basic_ostream<char_type, traits_type>&
operator<<(std::basic_ostream<char_type, traits_type>& s, const SGMatrix<T>& m)
{
  s << "[ " << m(0,0) << ", " << m(0,1) << ", " << m(0,2) << ", " << m(0,3) << "\n";
  s << "  " << m(1,0) << ", " << m(1,1) << ", " << m(1,2) << ", " << m(1,3) << "\n";
  s << "  " << m(2,0) << ", " << m(2,1) << ", " << m(2,2) << ", " << m(2,3) << "\n";
  s << "  " << m(3,0) << ", " << m(3,1) << ", " << m(3,2) << ", " << m(3,3) << " ]";
  return s;
}

inline
SGMatrixf
toMatrixf(const SGMatrixd& m)
{
  return SGMatrixf((float)m(0,0), (float)m(0,1), (float)m(0,2), (float)m(0,3),
                   (float)m(1,0), (float)m(1,1), (float)m(1,2), (float)m(1,3),
                   (float)m(2,0), (float)m(2,1), (float)m(2,2), (float)m(2,3),
                   (float)m(3,0), (float)m(3,1), (float)m(3,2), (float)m(3,3));
}

inline
SGMatrixd
toMatrixd(const SGMatrixf& m)
{
  return SGMatrixd(m(0,0), m(0,1), m(0,2), m(0,3),
                   m(1,0), m(1,1), m(1,2), m(1,3),
                   m(2,0), m(2,1), m(2,2), m(2,3),
                   m(3,0), m(3,1), m(3,2), m(3,3));
}

#endif