necpp icon indicating copy to clipboard operation
necpp copied to clipboard

Why do you check for symmetry in factrs()? Isn't that redundant?

Open ewheelerinc opened this issue 4 years ago • 0 comments

Notice below that you could omit the check if (nrow==np) because num_symmetric_modes = nrow/np = 1 .

Thus, the loop iterates only once and mode=0, so mode_offset = mode*np = 0*np = 0 when there is only one iteration and that a == a.segment()

Maybe its a touch faster if a.segment actually copies the array, but if it generates a reference then it is sthe same.

Is this redundant, or am I missing something?

-Eric

void factrs(nec_output_file& s_output,  int64_t np, int64_t nrow, complex_array& a, int_array& ip )
{
  DEBUG_TRACE("factrs(" << np << "," << nrow << ")");
  if (nrow == np) { // no symmetry
    lu_decompose(s_output,  np, a, ip, nrow );
    return;
  }
  
  int num_symmetric_modes = static_cast<int>(nrow / np);
  DEBUG_TRACE("\tnum_symmetric_modes = " << num_symmetric_modes);
  
  for (int mode = 0; mode < num_symmetric_modes; mode++ ) {
    int64_t mode_offset = mode * np;
    
    complex_array a_temp = a.segment(mode_offset, a.size()-mode_offset);
    int_array ip_temp = ip.segment(mode_offset, ip.size()-mode_offset);
    
    lu_decompose(s_output,  np, a_temp, ip_temp, nrow );
  }
}

ewheelerinc avatar Aug 31 '21 03:08 ewheelerinc