Select Git revision
Numeric.cpp
Numeric.cpp 44.83 KiB
// Gmsh - Copyright (C) 1997-2018 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
#include <algorithm>
#include "GmshConfig.h"
#include "GmshMessage.h"
#include "Numeric.h"
double myatan2(double a, double b)
{
if(a == 0.0 && b == 0)
return 0.0;
return atan2(a, b);
}
double myasin(double a)
{
if(a <= -1.)
return -M_PI / 2.;
else if(a >= 1.)
return M_PI / 2.;
else
return asin(a);
}
double myacos(double a)
{
if(a <= -1.)
return M_PI;
else if(a >= 1.)
return 0.;
else
return acos(a);
}
double norm2(double a[3][3])
{
double norm2sq =
gmsh_SQU(a[0][0])+
gmsh_SQU(a[0][1])+
gmsh_SQU(a[0][2])+
gmsh_SQU(a[1][0])+
gmsh_SQU(a[1][1])+
gmsh_SQU(a[1][2])+
gmsh_SQU(a[2][0])+
gmsh_SQU(a[2][1])+
gmsh_SQU(a[2][2]);
return sqrt(norm2sq);
}
void matvec(double mat[3][3], double vec[3], double res[3])
{
res[0] = mat[0][0] * vec[0] + mat[0][1] * vec[1] + mat[0][2] * vec[2];
res[1] = mat[1][0] * vec[0] + mat[1][1] * vec[1] + mat[1][2] * vec[2];
res[2] = mat[2][0] * vec[0] + mat[2][1] * vec[1] + mat[2][2] * vec[2];
}
void matmat(double mat1[3][3], double mat2[3][3], double res[3][3])
{
res[0][0] = mat1[0][0]*mat2[0][0] + mat1[0][1]*mat2[1][0] + mat1[0][2]*mat2[2][0];
res[0][1] = mat1[0][0]*mat2[0][1] + mat1[0][1]*mat2[1][1] + mat1[0][2]*mat2[2][1];
res[0][2] = mat1[0][0]*mat2[0][2] + mat1[0][1]*mat2[1][2] + mat1[0][2]*mat2[2][2];
res[1][0] = mat1[1][0]*mat2[0][0] + mat1[1][1]*mat2[1][0] + mat1[1][2]*mat2[2][0];
res[1][1] = mat1[1][0]*mat2[0][1] + mat1[1][1]*mat2[1][1] + mat1[1][2]*mat2[2][1];
res[1][2] = mat1[1][0]*mat2[0][2] + mat1[1][1]*mat2[1][2] + mat1[1][2]*mat2[2][2];
res[2][0] = mat1[2][0]*mat2[0][0] + mat1[2][1]*mat2[1][0] + mat1[2][2]*mat2[2][0];
res[2][1] = mat1[2][0]*mat2[0][1] + mat1[2][1]*mat2[1][1] + mat1[2][2]*mat2[2][1];
res[2][2] = mat1[2][0]*mat2[0][2] + mat1[2][1]*mat2[1][2] + mat1[2][2]*mat2[2][2];