Linear Algebra and the C Language/a0d9


Code study: GJ_PP_FreeV_mR();

  • You must use the algoritm of free variables .
  • GJ_PP_FreeV_mR(); displays a zero row, introduces the free variable, solves the system, and returns a free vector.
/* ------------------------------------ */
/* ------------------------------------ */
double **GJ_PP_FreeV_mR(
double **Ab,
double **b_free
)
{
double **new_Ab;
int    rsize_Ab = rsize_R(Ab);
int r;

       new_Ab = i_Abr_Ac_bc_mR(csize_A_R(Ab),
                               csize_A_R(Ab),
                               C2); 
                                    
      c_nr_mR(Ab,rsize_Ab,new_Ab);                    // Copy Ab into new_Ab
      zero4_under_all_pivot_mR(new_Ab);               // Displays a null row
      put_freeV_TP_mR(new_Ab,rsize_Ab);               // Introduces the free variable
      

      r=Ab[C_SIZE_A][C0]-C1;
      while( r>R1 )                                   // Solves the system
        zero_above_pivot_gj1Ab_mR(new_Ab,r--);
        
      sort_c_mR(new_Ab);
      sort_r_mR(new_Ab);

      c_Ab_b_mR(new_Ab,b_free);
            
      f_mR(new_Ab);
      
      return(b_free);                                   // Returns a free vector
}
/* ------------------------------------ */
/* ------------------------------------ */