Skip to content
Snippets Groups Projects
Select Git revision
  • 08e29acee092df86aa25c148494e7cbaa2869af5
  • master default protected
  • dof-renumbering
  • test-dof-hash
  • gdemesy-master-patch-30528
  • eval-space-time
  • oscillating_multiharm
  • MH_movement
  • axisqu
  • write_vtu_and_ensight_formats
  • movingband
  • CP_1972_add_vtu_file_writing
  • mortar
  • fast_freq_sweep_Resolution
  • applyresolvent_again
  • marteaua-master-patch-54323
  • patch-1
  • binde-master-patch-08072
  • binde-master-patch-52461
  • BCGSL
  • resolvent
  • getdp_3_5_0
  • getdp_3_4_0
  • getdp_3_3_0
  • getdp_3_2_0
  • getdp_3_1_0
  • getdp_3_0_4
  • getdp_3_0_3
  • getdp_3_0_2
  • getdp_3_0_1
  • getdp_3_0_0
  • onelab_mobile_2.1.0
  • getdp_2_11_3 protected
  • getdp_2_11_2 protected
  • getdp_2_11_1 protected
  • getdp_2_11_0 protected
  • getdp_2_10_0 protected
  • getdp_2_9_2 protected
  • getdp_2_9_1 protected
  • getdp_2_9_0 protected
  • getdp_2_8_0 protected
41 results

debug.h

Blame
  • Polynomial.cpp 13.63 KiB
    #include <cmath>
    #include <sstream>
    #include <stack>
    
    #include "Polynomial.h"
    
    using namespace std;
    
    const char Polynomial::coefName[3] = {'x', 'y', 'z'};
    
    Polynomial::Polynomial(double coef,
                           int powerX,
                           int powerY,
                           int powerZ){
      nMon = 1;
      mon  = new monomial_t[1];
    
      mon[0].coef     = coef;
      mon[0].power[0] = powerX;
      mon[0].power[1] = powerY;
      mon[0].power[2] = powerZ;
    }
    
    Polynomial::Polynomial(const Polynomial& other){
      nMon = other.nMon;
      mon  = copyMonomial(other.mon, nMon);
    }
    
    Polynomial::Polynomial(void){
      nMon = 0;
      mon  = NULL;
    }
    
    Polynomial::~Polynomial(void){
      if(mon)
        delete[] mon;
    }
    
    void Polynomial::derivative(int dim){
      // Take derivative //
      for(int i = 0; i < nMon; i++){
        mon[i].coef *= mon[i].power[dim];
        mon[i].power[dim] -= 1;
      }
    
      // Remove zero monomials //
      int N = 0;
      stack<monomial_t*> s;
    
      for(int i = 0; i < nMon; i++){
        if(mon[i].coef != 0.0){
          s.push(&mon[i]);
          N++;
        }
      }
    
      // If no monomial any more ---> return zero polynomial
      if(!N){
        delete[] mon;
    
        mon  = zeroPolynomial();
        nMon = 1;
        return;
      }
    
      // If no zero found ---> return;
      if(N == nMon)
        return;
    
      // Else, remove them //