Home My Page Projects Code Snippets Project Openings diderot
 Summary Activity Tracker Tasks SCM

# SCM Repository

[diderot] View of /branches/pure-cfg/src/include/Diderot/inline-matrix.h
 [diderot] / branches / pure-cfg / src / include / Diderot / inline-matrix.h

# View of /branches/pure-cfg/src/include/Diderot/inline-matrix.h

Revision 727 - (download) (as text) (annotate)
Fri Apr 1 23:59:45 2011 UTC (10 years, 5 months ago) by jhr
File size: 1609 byte(s)
```  Split matrix operations into their own file and added matrix (Frobenius) norm
```
```/*! \file inline-matrix.h
*
* \author John Reppy
*/

/*
* COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu)
* All rights reserved.
*/

#ifndef _DIDEROT_INLINE_MATRIX_H_
#define _DIDEROT_INLINE_MATRIX_H_

#ifndef _DIDEROT_TYPES_H_
#include "types.h"
#endif
#ifndef _DIDEROT_INLINE_VEC2_H_
#  include "inline-vec2.h"
#endif
#ifndef _DIDEROT_INLINE_VEC3_H_
#  include "inline-vec3.h"
#endif
#ifndef _DIDEROT_INLINE_VEC4_H_
#  include "inline-vec4.h"
#endif

/********** 2x2 matrix functions **********/

STATIC_INLINE float trace2x2f (Diderot_Mat2x2_t m)
{
return m[0].r[0] + m[1].r[1];
}

// The Frobenius norm of a matrix is the sum of the squares of the elements
STATIC_INLINE float norm2x2f (Diderot_Mat2x2_t m)
{
return dot2f(m[0].v,m[0].v) + dot2f(m[1].v,m[1].v);
}

/********** 3x3 matrix functions **********/

STATIC_INLINE float trace3x3f (Diderot_Mat3x3_t m)
{
return m[0].r[0] + m[1].r[1] + m[2].r[2];
}

// The Frobenius norm of a matrix is the sum of the squares of the elements
STATIC_INLINE float norm3x3f (Diderot_Mat3x3_t m)
{
return dot3f(m[0].v,m[0].v) + dot3f(m[1].v,m[1].v) + dot3f(m[2].v,m[2].v);
}

/********** 4x4 matrix functions **********/

STATIC_INLINE float trace4x4f (Diderot_Mat4x4_t m)
{
return m[0].r[0] + m[1].r[1] + m[2].r[2] + m[3].r[3];
}

// The Frobenius norm of a matrix is the sum of the squares of the elements
STATIC_INLINE float norm4x4f (Diderot_Mat4x4_t m)
{
return dot4f(m[0].v,m[0].v) + dot4f(m[1].v,m[1].v) + dot4f(m[2].v,m[2].v) + dot4f(m[3].v,m[3].v);
}

#endif /* !_DIDEROT_INLINE_MATRIX_H_ */
```

 root@smlnj-gforge.cs.uchicago.edu ViewVC Help Powered by ViewVC 1.0.0