Skip to content
Snippets Groups Projects
Select Git revision
  • 9bf2f762a0ce4e0d21cbf0d2f30cda9bcbbc083c
  • master default protected
  • overlaps_tags_and_distributed_export
  • overlaps_tags_and_distributed_export_rebased
  • relaying
  • alphashapes
  • patches-4.14
  • steplayer
  • bl
  • pluginMeshQuality
  • fixBugsAmaury
  • hierarchical-basis
  • new_export_boris
  • oras_vs_osm
  • reassign_partitions
  • distributed_fwi
  • rename-classes
  • fix/fortran-api-example-t4
  • robust_partitions
  • reducing_files
  • fix_overlaps
  • gmsh_4_14_0
  • gmsh_4_13_1
  • gmsh_4_13_0
  • gmsh_4_12_2
  • gmsh_4_12_1
  • gmsh_4_12_0
  • gmsh_4_11_1
  • gmsh_4_11_0
  • gmsh_4_10_5
  • gmsh_4_10_4
  • gmsh_4_10_3
  • gmsh_4_10_2
  • gmsh_4_10_1
  • gmsh_4_10_0
  • gmsh_4_9_5
  • gmsh_4_9_4
  • gmsh_4_9_3
  • gmsh_4_9_2
  • gmsh_4_9_1
  • gmsh_4_9_0
41 results

Numeric.cpp

Blame
  • 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];