BASKER_INLINE
  int Basker<Int,Entry,Exe_Space>::solve_interface
  (
   Entry *_x, //Solution (len = gn)
   Entry *_y
   )
  {
  
    //===== Move to view===========
    ENTRY_1DARRAY  x;
    ENTRY_1DARRAY  y;

    MALLOC_ENTRY_1DARRAY(x, gn);
    MALLOC_ENTRY_1DARRAY(y, gm);
    
    for(Int i =0; i < gn; i++)
      {
	x(i) = (Entry) 0;
        y(i) = (Entry) _y[i];
      }
    
    //printf("RHS: \n");
    //printVec(y, gn);
    //printf("\n");


    //===== Permute
    //printf("Permute RHS\n");
    //==== Need to make this into one global perm
    if(match_flag == BASKER_TRUE)
      {
	//printf("match order\n");
	//printVec("match.txt", order_match_array, gn);
	permute_inv(y,order_match_array, gn);
      }
    if(btf_flag == BASKER_TRUE)
      {
	//printf("btf order\n");
	//printVec("btf.txt", order_btf_array, gn);
	permute_inv(y,order_btf_array, gn);
        //printVec("btf_amd.txt", order_c_csym_array, gn);
        permute_inv(y,order_blk_amd_array, gn);

      }
    if(nd_flag == BASKER_TRUE)
      {
	//printf("ND order \n");
	//printVec("nd.txt", part_tree.permtab, gn);
	permute_inv(y,part_tree.permtab, gn);
      }
    if(amd_flag == BASKER_TRUE)
      {
	//printf("AMD order \n");
	//printVec("amd.txt",order_csym_array, gn);
	permute_inv(y,order_csym_array, gn);
      }


    //printVec("perm.txt" , gperm, gn);
    permute_inv(y,gperm, gn);


    solve_interface(x,y);

    //Inverse perm
    //Note: don't need to inverse a row only perm
    if(btf_flag == BASKER_TRUE)
      {
	//printf("btf order\n");
	//printVec(order_btf_array, gn);
	permute(x,order_btf_array, gn);
      }
    if(nd_flag == BASKER_TRUE)
      {
	//printf("ND order \n");
	//printVec(part_tree.permtab, gn);
	permute(x,part_tree.permtab, gn);
      }
    if(amd_flag == BASKER_TRUE)
      {
	//printf("AMD order \n");
	//printVec(order_csym_array, gn);
	//FILE *fpamd;
	//fpamd = fopen("amd.csv", "w");
	//for(Int i = 0; i < gn; i++)
	// {
	//   fprintf(fpamd, "%d \n", 
	//	    order_csym_array(i));
	//  }
	//fclose(fpamd);
	    
	permute(x,order_csym_array, gn);
      }
   


    #ifdef BASKER_DEBUG_SOLVE_RHS
    printf("\n\n");
    printf("X: \n");
    for(Int i = 0; i < gn; i++)
      {
	printf("%f, " , x(i));
      }
    printf("\n\n");
    printf("RHS: \n");
    for(Int i =0; i < gm; i++)
      {
	printf("%f, ", y(i)); 
      }
    printf("\n\n");
    #endif

    for(Int i = 0; i < gn; i++)
      {
        _x[i] = x(i);
      } 

    #ifndef BASKER_KOKKOS
    FREE_ENTRY_1DARRAY(x);
    FREE_ENTRY_1DARRAY(y);
    #endif

    return 0;
  }
示例#2
0
  BASKER_INLINE
  int Basker<Int,Entry,Exe_Space>::solve_interface
  (
   Entry *_x, //Solution (len = gn)
   Entry *_y
   )
  {

    //Need to modify to use global perm 
    INT_1DARRAY temp_array;
    MALLOC_INT_1DARRAY(temp_array, gn);
  
    //===== Move to view===========
    ENTRY_1DARRAY  x;
    ENTRY_1DARRAY  y;

    MALLOC_ENTRY_1DARRAY(x, gn);
    MALLOC_ENTRY_1DARRAY(y, gm);
    
    for(Int i =0; i < gn; i++)
      {
	x(i) = (Entry) 0;
        y(i) = (Entry) _y[i];
      }
    
    //printf("RHS: \n");
    //printVec(y, gn);
    //printf("\n");


    //===== Permute
    //printf("Permute RHS\n");
    //==== Need to make this into one global perm
    if(match_flag == BASKER_TRUE)
      {
	//printf("match order\n");
	//printVec("match.txt", order_match_array, gn);
	permute_inv(y,order_match_array, gn);
      }
    if(btf_flag == BASKER_TRUE)
      {
	//printf("btf order\n");
	//printVec("btf.txt", order_btf_array, gn);
	permute_inv(y,order_btf_array, gn);
        //printVec("btf_amd.txt", order_c_csym_array, gn);
        permute_inv(y,order_blk_amd_array, gn);

      }
    if(nd_flag == BASKER_TRUE)
      {
	//printf("ND order \n");
	//printVec("nd.txt", part_tree.permtab, gn);
	for(Int i = 0; i < BTF_A.ncol; ++i)
	  {
	    temp_array(i) = part_tree.permtab(i);
	  }
	for(Int i = BTF_A.ncol; i < gn; ++i)
	  {
	    temp_array(i) = i;
	  }
	//permute_inv(y,part_tree.permtab, gn);
	permute_inv(y, temp_array,gn);
      }
    if(amd_flag == BASKER_TRUE)
      {
	//printf("AMD order \n");
	//printVec("amd.txt",order_csym_array, gn);
	for(Int i = 0; i < BTF_A.ncol; ++i)
	  {
	    temp_array(i) = order_csym_array(i);
	  }
	for(Int i = BTF_A.ncol; i < gn; ++i)
	  {
	    temp_array(i) = i;
	  }
	//permute_inv(y,order_csym_array, gn);
	permute_inv(y,temp_array, gn);
      }


    //printVec("perm.txt" , gperm, gn);
    permute_inv(y,gperm, gn);


    solve_interface(x,y);

    //Inverse perm
    //Note: don't need to inverse a row only perm
    if(btf_flag == BASKER_TRUE)
      {
	//printf("btf order\n");
	//printVec(order_btf_array, gn);
	permute(x,order_btf_array, gn);
      }
    if(nd_flag == BASKER_TRUE)
      {
	//printf("ND order \n");
	//printVec(part_tree.permtab, gn);
	for(Int i = 0; i < BTF_A.ncol; ++i)
	  {
	    temp_array(i) = part_tree.permtab(i);
	  }
	for(Int i = BTF_A.ncol; i < gn; i++)
	  {
	    temp_array(i) = i;
	  }
	//permute(x,part_tree.permtab, gn);
	permute(x,temp_array, gn);
      }
    if(amd_flag == BASKER_TRUE)
      {
	//printf("AMD order \n");
	//printVec(order_csym_array, gn);
	for(Int i = 0; i < BTF_A.ncol; ++i)
	  {
	    temp_array(i) = order_csym_array(i);
	  }
	for(Int i = BTF_A.ncol; i < gn; ++i)
	  {
	    temp_array(i) = order_csym_array(i);
	  }
	//permute(x,order_csym_array, gn);
	permute(x,temp_array,gn);
      }
   


    #ifdef BASKER_DEBUG_SOLVE_RHS
    printf("\n\n");
    printf("X: \n");
    for(Int i = 0; i < gn; i++)
      {
	printf("%f, " , x(i));
      }
    printf("\n\n");
    printf("RHS: \n");
    for(Int i =0; i < gm; i++)
      {
	printf("%f, ", y(i)); 
      }
    printf("\n\n");
    #endif

    for(Int i = 0; i < gn; i++)
      {
        _x[i] = x(i);
      } 

   
    FREE_ENTRY_1DARRAY(x);
    FREE_ENTRY_1DARRAY(y);
    FREE_INT_1DARRAY(temp_array);
   

    return 0;
  }