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
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 729 - (download) (as text) (annotate)
Sat Apr 2 00:05:10 2011 UTC (9 years, 10 months ago) by jhr
File size: 1665 byte(s)
  Fixed typo
/*! \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 sqrt of the sum of the squares of the elements
STATIC_INLINE float norm2x2f (Diderot_Mat2x2_t m)
{
    return sqrtf(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 sqrt of the sum of the squares of the elements
STATIC_INLINE float norm3x3f (Diderot_Mat3x3_t m)
{
    return sqrtf(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 sqrt of the sum of the squares of the elements
STATIC_INLINE float norm4x4f (Diderot_Mat4x4_t m)
{
    return sqrt(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