libflame  revision_anchor
Functions
FLASH_View.c File Reference

(r)

Functions

FLA_Error FLASH_Part_create_2x1 (FLA_Obj A, FLA_Obj *AT, FLA_Obj *AB, dim_t n_rows, FLA_Side side)
 
FLA_Error FLASH_Part_create_1x2 (FLA_Obj A, FLA_Obj *AL, FLA_Obj *AR, dim_t n_cols, FLA_Side side)
 
FLA_Error FLASH_Part_create_2x2 (FLA_Obj A, FLA_Obj *ATL, FLA_Obj *ATR, FLA_Obj *ABL, FLA_Obj *ABR, dim_t n_rows, dim_t n_cols, FLA_Side side)
 
FLA_Error FLASH_Obj_adjust_views (FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
 
FLA_Error FLASH_Obj_adjust_views_hierarchy (FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
 
FLA_Error FLASH_Part_free_2x1 (FLA_Obj *AT, FLA_Obj *AB)
 
FLA_Error FLASH_Part_free_1x2 (FLA_Obj *AL, FLA_Obj *AR)
 
FLA_Error FLASH_Part_free_2x2 (FLA_Obj *ATL, FLA_Obj *ATR, FLA_Obj *ABL, FLA_Obj *ABR)
 
dim_t FLASH_Obj_scalar_length (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_width (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_min_dim (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_max_dim (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_vector_dim (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_row_offset (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_col_offset (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_length_tl (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_width_tl (FLA_Obj H)
 
FLA_Error FLASH_Obj_show (char *header, FLA_Obj H, char *elem_format, char *footer)
 
FLA_Error FLASH_Obj_show_hierarchy (FLA_Obj H, dim_t i, char *elem_format)
 

Function Documentation

◆ FLASH_Obj_adjust_views()

FLA_Error FLASH_Obj_adjust_views ( FLA_Bool  attach_buffer,
dim_t  offm,
dim_t  offn,
dim_t  m,
dim_t  n,
FLA_Obj  A,
FLA_Obj S 
)

References FLASH_Obj_adjust_views_hierarchy().

Referenced by FLASH_Obj_create_conf_to(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

276 {
277 
278  FLASH_Obj_adjust_views_hierarchy( attach_buffer, offm, offn, m, n, A, S );
279 
280  return FLA_SUCCESS;
281 }
FLA_Error FLASH_Obj_adjust_views_hierarchy(FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
Definition: FLASH_View.c:283

◆ FLASH_Obj_adjust_views_hierarchy()

FLA_Error FLASH_Obj_adjust_views_hierarchy ( FLA_Bool  attach_buffer,
dim_t  offm,
dim_t  offn,
dim_t  m,
dim_t  n,
FLA_Obj  A,
FLA_Obj S 
)

References FLA_Obj_view::base, FLA_Obj_struct::buffer, FLA_Obj_struct::cs, FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Obj_col_offset(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Obj_row_offset(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Part_2x2(), FLA_Repart_1x2_to_1x3(), FLA_Repart_2x1_to_3x1(), FLASH_Obj_scalar_length_tl(), FLASH_Obj_scalar_width_tl(), FLA_Obj_struct::id, FLA_Obj_view::m_inner, FLA_Obj_view::n_inner, and FLA_Obj_struct::rs.

Referenced by FLASH_Obj_adjust_views().

284 {
285  FLA_Obj ATL, ATR,
286  ABL, ABR;
287 
288  FLA_Obj STL, STR,
289  SBL, SBR;
290 
291  // Base case.
292  if ( FLA_Obj_elemtype( A ) == FLA_SCALAR )
293  {
294  // Repartition to exclude elements above and to the left of our
295  // submatrix of interest.
296  FLA_Part_2x2( A, &ATL, &ATR,
297  &ABL, &ABR, offm, offn, FLA_TL );
298  FLA_Part_2x2( *S, &STL, &STR,
299  &SBL, &SBR, offm, offn, FLA_TL );
300 
301  // Overwrite the existing views with ones that have updated offsets.
302  A = ABR;
303  *S = SBR;
304 
305  // Repartition to exclude elements below and to the right of our
306  // submatrix of interest.
307  FLA_Part_2x2( A, &ATL, &ATR,
308  &ABL, &ABR, m, n, FLA_TL );
309  FLA_Part_2x2( *S, &STL, &STR,
310  &SBL, &SBR, m, n, FLA_TL );
311 
312  // Overwrite the existing view of S with the view of A so that S
313  // Refers to the correct base object.
314  A = ATL;
315  *S = STL;
316 
317  // Adjust the _inner fields in the view to reflect the number of
318  // elements we have in each dimension.
319  S->m_inner = m;
320  S->n_inner = n;
321 
322  // Copy over buffer, stride, and object ID information if requested.
323  if ( attach_buffer )
324  {
325  // Copy over the address of the numerical data buffer and its
326  // corresponding row and column strides. This is obviously
327  // necessary since we are creating a hierarchial view into an
328  // existing hierarhical matrix, not a separate/new matrix
329  // altogether.
330  S->base->buffer = A.base->buffer;
331  S->base->rs = A.base->rs;
332  S->base->cs = A.base->cs;
333 
334  // Copy over the id field of the original matrix. This is used
335  // by SuperMatrix to distinguish between distinct hierarchical
336  // matrices. Since again, we are not creating a new matrix, we
337  // will use the original object's id value.
338  S->base->id = A.base->id;
339  }
340  }
341  else // if ( FLA_Obj_elemtype( A ) == FLA_MATRIX )
342  {
343  FLA_Obj AL, AR, A0, A1, A2;
344 
345  FLA_Obj SL, SR, S0, S1, S2;
346 
347  FLA_Obj A1T, A01,
348  A1B, A11,
349  A21;
350 
351  FLA_Obj S1T, S01,
352  S1B, S11,
353  S21;
354  dim_t b_m_full;
355  dim_t b_n_full;
356  dim_t offm_relA;
357  dim_t offn_relA;
358  dim_t offm_abs;
359  dim_t offn_abs;
360  dim_t offm_cur;
361  dim_t offn_cur;
362  dim_t offm_rem;
363  dim_t offn_rem;
364  dim_t offm_next;
365  dim_t offn_next;
366  dim_t m_next;
367  dim_t n_next;
368  dim_t m_ahead;
369  dim_t n_ahead;
370  dim_t m_behind;
371  dim_t n_behind;
372 
373  // Acquire the scalar length and width of the top-left (full) block
374  // at the current hierarchical level.
375  b_m_full = FLASH_Obj_scalar_length_tl( A );
376  b_n_full = FLASH_Obj_scalar_width_tl( A );
377 /*
378 printf( "-----------------\n" );
379 printf( "b_m/n_full: %d %d\n", b_m_full, b_n_full );
380 printf( "offm/n: %d %d\n", offm, offn );
381 printf( "r/c offsets: %d %d\n", FLA_Obj_row_offset( A ), FLA_Obj_col_offset( A ) );
382 */
383  // Compute the offsets for the top-left corner of the submatrix of
384  // interest relative to the view at the current level of the
385  // hierarchy of A.
386  offm_relA = offm / b_m_full - FLA_Obj_row_offset( A );
387  offn_relA = offn / b_n_full - FLA_Obj_col_offset( A );
388 
389  // Compute the offsets for the top-left corner of the submatrix of
390  // interest in absolute units, from the top-left edge of the
391  // overall allocated matrix. This will be used to partition into S
392  // Since its view has (presumably) not yet been changed since it
393  // was created.
394  offm_abs = offm / b_m_full;
395  offn_abs = offn / b_n_full;
396 /*
397 printf( "offm/n_relA: %d %d\n", offm_relA, offn_relA );
398 printf( "offm/n_abs: %d %d\n", offm_abs, offn_abs );
399 */
400  // Repartition to exclude blocks above and to the left of our
401  // submatrix of interest.
402  FLA_Part_2x2( A, &ATL, &ATR,
403  &ABL, &ABR, offm_relA, offn_relA, FLA_TL );
404  FLA_Part_2x2( *S, &STL, &STR,
405  &SBL, &SBR, offm_abs, offn_abs, FLA_TL );
406 /*
407 printf( "ABR.offm/n %d %d\n", FLA_Obj_row_offset( ABR ), FLA_Obj_col_offset( ABR ) );
408 printf( "ABR is %d %d\n", FLA_Obj_length( ABR ), FLA_Obj_width( ABR ) );
409 printf( "SBR.offm/n %d %d\n", FLA_Obj_row_offset( SBR ), FLA_Obj_col_offset( SBR ) );
410 printf( "SBR is %d %d\n", FLA_Obj_length( SBR ), FLA_Obj_width( SBR ) );
411 */
412  // Overwrite the existing views with ones that have updated offsets
413  // (for this level in the hierarchy).
414  A = ABR;
415  *S = SBR;
416 
417  // Compute the new offsets within SBR, which is the remaining
418  // distance after you subtract out the distance spanned by the
419  // partitioning we just did.
420  offm_rem = offm - offm_abs * b_m_full;
421  offn_rem = offn - offn_abs * b_n_full;
422 
423 //printf( "offm/n_rem: %d %d\n", offm_rem, offn_rem );
424 
425  // Compute a new set of offsets corresponding to the bottom-right
426  // edge of the desired submatrix. We'll use this to partition away
427  // the remaining (bottom and right) parts of the FLASH matrix at
428  // this level.
429  offm_cur = ( offm_rem + m ) / b_m_full;
430  offn_cur = ( offn_rem + n ) / b_n_full;
431  offm_cur += ( (offm_rem + m) % b_m_full ? 1 : 0 );
432  offn_cur += ( (offn_rem + n) % b_n_full ? 1 : 0 );
433 
434 //printf( "offm/n_cur: %d %d\n", offm_cur, offn_cur );
435 
436  // Repartition to exclude blocks below and to the right of our
437  // submatrix of interest.
438  FLA_Part_2x2( A, &ATL, &ATR,
439  &ABL, &ABR, offm_cur, offn_cur, FLA_TL );
440  FLA_Part_2x2( *S, &STL, &STR,
441  &SBL, &SBR, offm_cur, offn_cur, FLA_TL );
442 /*
443 printf( "ATL.offm/n %d %d\n", FLA_Obj_row_offset( ATL ), FLA_Obj_col_offset( ATL ) );
444 printf( "ATL is %d %d\n", FLA_Obj_length( ATL ), FLA_Obj_width( ATL ) );
445 printf( "STL.offm/n %d %d\n", FLA_Obj_row_offset( STL ), FLA_Obj_col_offset( STL ) );
446 printf( "STL is %d %d\n", FLA_Obj_length( STL ), FLA_Obj_width( STL ) );
447 */
448 
449  // Overwrite the existing views with ones that have updated offsets
450  // (for this level in the hierarchy).
451  A = ATL;
452  *S = STL;
453 
454  // Adjust the _inner fields in the view to reflect the number of
455  // elements we will eventually have in each dimension.
456  S->m_inner = m;
457  S->n_inner = n;
458 
459  // Initialize a counter that keeps track of the n offset relative to
460  // the top-left most edge of the submatrix of interest.
461  n_behind = 0;
462 
463  FLA_Part_1x2( A, &AL, &AR, 0, FLA_LEFT );
464  FLA_Part_1x2( *S, &SL, &SR, 0, FLA_LEFT );
465 
466  while ( FLA_Obj_width( AL ) < FLA_Obj_width( A ) )
467  {
468  FLA_Repart_1x2_to_1x3( AL, /**/ AR, &A0, /**/ &A1, &A2,
469  1, FLA_RIGHT );
470  FLA_Repart_1x2_to_1x3( SL, /**/ SR, &S0, /**/ &S1, &S2,
471  1, FLA_RIGHT );
472 
473  // -------------------------------------------------------------
474 
475  // Set the n offset for the next levels of recursion based
476  // on which panel of A we are in.
477  if ( FLA_Obj_width( AL ) == 0 ) offn_next = offn_rem;
478  else offn_next = 0;
479 
480  // Compute the number of columns left to be visited in the
481  // submatrix of interset.
482  n_ahead = n - n_behind;
483 
484  // Set the n dimensions for the next level of recursion
485  // depending on whether the submatrix continues beyond the
486  // current block.
487  if ( offn_next + n_ahead > b_n_full ) n_next = b_n_full - offn_next;
488  else n_next = n_ahead;
489 
490  // Initialize a counter that keeps track of the m offset relative
491  // to the top-left most edge of the submatrix of interest.
492  m_behind = 0;
493 
494  FLA_Part_2x1( A1, &A1T,
495  &A1B, 0, FLA_TOP );
496  FLA_Part_2x1( S1, &S1T,
497  &S1B, 0, FLA_TOP );
498 
499  while ( FLA_Obj_length( A1T ) < FLA_Obj_length( A1 ) )
500  {
501  FLA_Repart_2x1_to_3x1( A1T, &A01,
502  /* ** */ /* ** */
503  &A11,
504  A1B, &A21, 1, FLA_BOTTOM );
505  FLA_Repart_2x1_to_3x1( S1T, &S01,
506  /* ** */ /* ** */
507  &S11,
508  S1B, &S21, 1, FLA_BOTTOM );
509 
510  // -------------------------------------------------------------
511 
512  // Set the m offset for the next levels of recursion based
513  // on which block of A1 we are in.
514  if ( FLA_Obj_length( A1T ) == 0 ) offm_next = offm_rem;
515  else offm_next = 0;
516 
517  // Compute the number of rows left to be visited in the
518  // submatrix of interset.
519  m_ahead = m - m_behind;
520 
521  // Set the m dimensions for the next level of recursion
522  // depending on whether the submatrix continues beyond the
523  // current block.
524  if ( offm_next + m_ahead > b_m_full ) m_next = b_m_full - offm_next;
525  else m_next = m_ahead;
526 
527 //printf( "offm/n_next m/n_next: %d %d %d %d\n", offm_next, offn_next, m_next, n_next );
528  // Recursively call ourselves with new, smaller offsets
529  // and the submatrix corresponding to FLASH blocks captured by ABR.
530  FLASH_Obj_adjust_views_hierarchy( attach_buffer,
531  offm_next,
532  offn_next,
533  m_next,
534  n_next,
535  *FLASH_OBJ_PTR_AT( A11 ),
536  FLASH_OBJ_PTR_AT( S11 ) );
537 
538  // Increment m_behind to keep track of our absolute m offset.
539  m_behind += m_next;
540 
541  // -------------------------------------------------------------
542 
543  FLA_Cont_with_3x1_to_2x1( &A1T, A01,
544  A11,
545  /* ** */ /* ** */
546  &A1B, A21, FLA_TOP );
547  FLA_Cont_with_3x1_to_2x1( &S1T, S01,
548  S11,
549  /* ** */ /* ** */
550  &S1B, S21, FLA_TOP );
551  }
552 
553  // Increment n_behind to keep track of our absolute n offset.
554  n_behind += n_next;
555 
556  // -------------------------------------------------------------
557 
558  FLA_Cont_with_1x3_to_1x2( &AL, /**/ &AR, A0, A1, /**/ A2,
559  FLA_LEFT );
560  FLA_Cont_with_1x3_to_1x2( &SL, /**/ &SR, S0, S1, /**/ S2,
561  FLA_LEFT );
562  }
563  }
564 
565  return FLA_SUCCESS;
566 }
dim_t FLA_Obj_col_offset(FLA_Obj obj)
Definition: FLA_Query.c:186
FLA_Error FLA_Repart_2x1_to_3x1(FLA_Obj AT, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj AB, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:226
FLA_Error FLA_Repart_1x2_to_1x3(FLA_Obj AL, FLA_Obj AR, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:267
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Base_obj * base
Definition: FLA_type_defs.h:168
FLA_Error FLA_Cont_with_3x1_to_2x1(FLA_Obj *AT, FLA_Obj A0, FLA_Obj A1, FLA_Obj *AB, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:428
unsigned long id
Definition: FLA_type_defs.h:133
FLA_Error FLA_Part_2x2(FLA_Obj A, FLA_Obj *A11, FLA_Obj *A12, FLA_Obj *A21, FLA_Obj *A22, dim_t mb, dim_t nb, FLA_Quadrant quadrant)
Definition: FLA_View.c:17
Definition: FLA_type_defs.h:158
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
FLA_Error FLA_Cont_with_1x3_to_1x2(FLA_Obj *AL, FLA_Obj *AR, FLA_Obj A0, FLA_Obj A1, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:475
dim_t FLASH_Obj_scalar_length_tl(FLA_Obj H)
Definition: FLASH_View.c:723
void * buffer
Definition: FLA_type_defs.h:138
dim_t n_inner
Definition: FLA_type_defs.h:166
dim_t FLA_Obj_row_offset(FLA_Obj obj)
Definition: FLA_Query.c:180
dim_t m_inner
Definition: FLA_type_defs.h:165
FLA_Error FLA_Part_2x1(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:76
dim_t cs
Definition: FLA_type_defs.h:130
FLA_Error FLA_Part_1x2(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:110
dim_t FLASH_Obj_scalar_width_tl(FLA_Obj H)
Definition: FLASH_View.c:737
FLA_Error FLASH_Obj_adjust_views_hierarchy(FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
Definition: FLASH_View.c:283
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
dim_t rs
Definition: FLA_type_defs.h:129
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51

◆ FLASH_Obj_scalar_col_offset()

dim_t FLASH_Obj_scalar_col_offset ( FLA_Obj  H)

References FLA_Obj_col_offset(), FLA_Obj_elemtype(), and FLASH_Obj_scalar_width_tl().

Referenced by FLASH_Obj_create_conf_to(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

709 {
710  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
711  {
712  return FLA_Obj_col_offset( H );
713  }
714  else
715  {
716  dim_t b_n = FLASH_Obj_scalar_width_tl( H );
717 
718  return FLA_Obj_col_offset( H ) * b_n +
719  FLASH_Obj_scalar_col_offset( *FLASH_OBJ_PTR_AT( H ) );
720  }
721 }
dim_t FLA_Obj_col_offset(FLA_Obj obj)
Definition: FLA_Query.c:186
dim_t FLASH_Obj_scalar_col_offset(FLA_Obj H)
Definition: FLASH_View.c:708
unsigned long dim_t
Definition: FLA_type_defs.h:71
dim_t FLASH_Obj_scalar_width_tl(FLA_Obj H)
Definition: FLASH_View.c:737
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51

◆ FLASH_Obj_scalar_length()

dim_t FLASH_Obj_scalar_length ( FLA_Obj  H)

References FLA_Cont_with_3x1_to_2x1(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Part_2x1(), FLA_Repart_2x1_to_3x1(), and FLA_Obj_view::m_inner.

Referenced by FLA_Check_submatrix_dims_and_offset(), FLA_Obj_copy_view(), FLASH_Axpy_hierarchy(), FLASH_Copy_hierarchy(), FLASH_LU_find_zero_on_diagonal(), FLASH_Obj_create_conf_to(), FLASH_Obj_create_flat_conf_to_hier(), FLASH_Obj_scalar_max_dim(), FLASH_Obj_scalar_min_dim(), FLASH_Obj_scalar_vector_dim(), FLASH_Obj_show(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

601 {
602  FLA_Obj HT, H0,
603  HB, H1,
604  H2;
605  FLA_Obj* H1p;
606 
607  dim_t b = 0;
608 
609  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
610  return FLA_Obj_length( H );
611 
612  if ( FLA_Obj_length( H ) == 0 )
613  return 0;
614 
615  FLA_Part_2x1( H, &HT,
616  &HB, 0, FLA_TOP );
617 
618  while ( FLA_Obj_length( HT ) < FLA_Obj_length( H ) )
619  {
620  FLA_Repart_2x1_to_3x1( HT, &H0,
621  /* ** */ /* ** */
622  &H1,
623  HB, &H2, 1, FLA_BOTTOM );
624 
625  /*------------------------------------------------------------*/
626 
627  H1p = FLASH_OBJ_PTR_AT( H1 );
628  b += H1p->m_inner;
629 
630  /*------------------------------------------------------------*/
631 
632  FLA_Cont_with_3x1_to_2x1( &HT, H0,
633  H1,
634  /* ** */ /* ** */
635  &HB, H2, FLA_TOP );
636  }
637 
638  return b;
639 }
FLA_Error FLA_Repart_2x1_to_3x1(FLA_Obj AT, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj AB, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:226
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLA_Cont_with_3x1_to_2x1(FLA_Obj *AT, FLA_Obj A0, FLA_Obj A1, FLA_Obj *AB, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:428
Definition: FLA_type_defs.h:158
dim_t m_inner
Definition: FLA_type_defs.h:165
FLA_Error FLA_Part_2x1(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:76
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51

◆ FLASH_Obj_scalar_length_tl()

dim_t FLASH_Obj_scalar_length_tl ( FLA_Obj  H)

References FLA_Obj_base_buffer(), FLA_Obj_base_length(), FLA_Obj_elemtype(), and FLASH_Obj_base_scalar_length().

Referenced by FLASH_Apply_CAQ_UT_inc_create_workspace(), FLASH_Apply_Q_UT(), FLASH_Apply_Q_UT_create_workspace(), FLASH_Apply_Q_UT_inc_create_workspace(), FLASH_Apply_QUD_UT_inc_create_workspace(), FLASH_LQ_UT(), FLASH_Obj_adjust_views_hierarchy(), FLASH_Obj_create_diag_panel(), FLASH_Obj_scalar_row_offset(), FLASH_Obj_show_hierarchy(), and FLASH_QR_UT().

724 {
725  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
726  {
727  return FLA_Obj_base_length( H );
728  }
729  else
730  {
731  FLA_Obj* H00 = FLA_Obj_base_buffer( H );
732 
733  return FLASH_Obj_base_scalar_length( *H00 );
734  }
735 }
dim_t FLASH_Obj_base_scalar_length(FLA_Obj H)
Definition: FLASH_Obj.c:83
void * FLA_Obj_base_buffer(FLA_Obj obj)
Definition: FLA_Query.c:210
dim_t FLA_Obj_base_length(FLA_Obj obj)
Definition: FLA_Query.c:192
Definition: FLA_type_defs.h:158
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51

◆ FLASH_Obj_scalar_max_dim()

dim_t FLASH_Obj_scalar_max_dim ( FLA_Obj  H)

References FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

682 {
683  return max( FLASH_Obj_scalar_length( H ),
684  FLASH_Obj_scalar_width( H ) );
685 }
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641

◆ FLASH_Obj_scalar_min_dim()

dim_t FLASH_Obj_scalar_min_dim ( FLA_Obj  H)

References FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

Referenced by FLASH_LQ_UT(), FLASH_Obj_create_diag_panel(), and FLASH_QR_UT().

676 {
677  return min( FLASH_Obj_scalar_length( H ),
678  FLASH_Obj_scalar_width( H ) );
679 }
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641

◆ FLASH_Obj_scalar_row_offset()

dim_t FLASH_Obj_scalar_row_offset ( FLA_Obj  H)

References FLA_Obj_elemtype(), FLA_Obj_row_offset(), and FLASH_Obj_scalar_length_tl().

Referenced by FLASH_Obj_create_conf_to(), FLASH_Obj_show(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

694 {
695  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
696  {
697  return FLA_Obj_row_offset( H );
698  }
699  else
700  {
702 
703  return FLA_Obj_row_offset( H ) * b_m +
704  FLASH_Obj_scalar_row_offset( *FLASH_OBJ_PTR_AT( H ) );
705  }
706 }
unsigned long dim_t
Definition: FLA_type_defs.h:71
dim_t FLASH_Obj_scalar_row_offset(FLA_Obj H)
Definition: FLASH_View.c:693
dim_t FLASH_Obj_scalar_length_tl(FLA_Obj H)
Definition: FLASH_View.c:723
dim_t FLA_Obj_row_offset(FLA_Obj obj)
Definition: FLA_Query.c:180
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51

◆ FLASH_Obj_scalar_vector_dim()

dim_t FLASH_Obj_scalar_vector_dim ( FLA_Obj  H)

References FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

688 {
689  return ( FLASH_Obj_scalar_length( H ) == 1 ? FLASH_Obj_scalar_width( H )
690  : FLASH_Obj_scalar_length( H ) );
691 }
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641

◆ FLASH_Obj_scalar_width()

dim_t FLASH_Obj_scalar_width ( FLA_Obj  H)

References FLA_Cont_with_1x3_to_1x2(), FLA_Obj_elemtype(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Repart_1x2_to_1x3(), and FLA_Obj_view::n_inner.

Referenced by FLA_Check_submatrix_dims_and_offset(), FLA_Obj_copy_view(), FLASH_Apply_Q_UT_create_workspace(), FLASH_Axpy_hierarchy(), FLASH_CAQR_UT_inc_adjust_views(), FLASH_CAQR_UT_inc_solve(), FLASH_Copy_hierarchy(), FLASH_Obj_create_conf_to(), FLASH_Obj_create_flat_conf_to_hier(), FLASH_Obj_scalar_max_dim(), FLASH_Obj_scalar_min_dim(), FLASH_Obj_scalar_vector_dim(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), FLASH_Part_create_2x2(), FLASH_QR_UT_inc_create_hier_matrices(), and FLASH_QR_UT_inc_solve().

642 {
643  FLA_Obj HL, HR, H0, H1, H2;
644  FLA_Obj* H1p;
645 
646  dim_t b = 0;
647 
648  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
649  return FLA_Obj_width( H );
650 
651  if ( FLA_Obj_width( H ) == 0 )
652  return 0;
653 
654  FLA_Part_1x2( H, &HL, &HR, 0, FLA_LEFT );
655 
656  while ( FLA_Obj_width( HL ) < FLA_Obj_width( H ) )
657  {
658  FLA_Repart_1x2_to_1x3( HL, /**/ HR, &H0, /**/ &H1, &H2,
659  1, FLA_RIGHT );
660 
661  /*------------------------------------------------------------*/
662 
663  H1p = FLASH_OBJ_PTR_AT( H1 );
664  b += H1p->n_inner;
665 
666  /*------------------------------------------------------------*/
667 
668  FLA_Cont_with_1x3_to_1x2( &HL, /**/ &HR, H0, H1, /**/ H2,
669  FLA_LEFT );
670  }
671 
672  return b;
673 }
FLA_Error FLA_Repart_1x2_to_1x3(FLA_Obj AL, FLA_Obj AR, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:267
unsigned long dim_t
Definition: FLA_type_defs.h:71
Definition: FLA_type_defs.h:158
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
FLA_Error FLA_Cont_with_1x3_to_1x2(FLA_Obj *AL, FLA_Obj *AR, FLA_Obj A0, FLA_Obj A1, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:475
dim_t n_inner
Definition: FLA_type_defs.h:166
FLA_Error FLA_Part_1x2(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:110
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51

◆ FLASH_Obj_scalar_width_tl()

dim_t FLASH_Obj_scalar_width_tl ( FLA_Obj  H)

References FLA_Obj_base_buffer(), FLA_Obj_base_width(), FLA_Obj_elemtype(), and FLASH_Obj_base_scalar_width().

Referenced by FLASH_Apply_CAQ_UT_inc_create_workspace(), FLASH_Apply_Q_UT(), FLASH_Apply_Q_UT_create_workspace(), FLASH_Apply_Q_UT_inc_create_workspace(), FLASH_Apply_QUD_UT_inc_create_workspace(), FLASH_CAQR_UT_inc_adjust_views(), FLASH_FS_incpiv(), FLASH_LQ_UT(), FLASH_LU_incpiv_noopt(), FLASH_LU_incpiv_opt1(), FLASH_Obj_adjust_views_hierarchy(), FLASH_Obj_scalar_col_offset(), and FLASH_QR_UT().

738 {
739  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
740  {
741  return FLA_Obj_base_width( H );
742  }
743  else
744  {
745  FLA_Obj* H00 = FLA_Obj_base_buffer( H );
746 
747  return FLASH_Obj_base_scalar_width( *H00 );
748  }
749 }
void * FLA_Obj_base_buffer(FLA_Obj obj)
Definition: FLA_Query.c:210
Definition: FLA_type_defs.h:158
dim_t FLA_Obj_base_width(FLA_Obj obj)
Definition: FLA_Query.c:198
dim_t FLASH_Obj_base_scalar_width(FLA_Obj H)
Definition: FLASH_Obj.c:113
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51

◆ FLASH_Obj_show()

FLA_Error FLASH_Obj_show ( char *  header,
FLA_Obj  H,
char *  elem_format,
char *  footer 
)

References FLA_Obj_elemtype(), FLA_Obj_show(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_row_offset(), and FLASH_Obj_show_hierarchy().

752 {
753  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
754  {
755  // Display the flat object.
756  FLA_Obj_show( header, H, elem_format, footer );
757  }
758  else
759  {
760  dim_t m_scalar;
761  dim_t i_view;
762  dim_t i_abs;
763  dim_t offm_scalar;
764 
765  // We want to print all m rows in the FLASH view.
766  m_scalar = FLASH_Obj_scalar_length( H );
767 
768  // Get the scalar offset of the overall FLASH view relative to the
769  // top-left corner of the overall object to which the view belongs.
770  offm_scalar = FLASH_Obj_scalar_row_offset( H );
771 
772 //printf( "flash_view_show: %d\n", m_scalar );
773 //printf( "flash_view_show: %d\n", offm_scalar );
774 
775  printf( "%s\n", header );
776 
777  for ( i_view = 0; i_view < m_scalar; ++i_view )
778  {
779  // Convert the relative view index to an absolute index.
780  i_abs = offm_scalar + i_view;
781 
782  // Print the ith row of the FLASH object H.
783  FLASH_Obj_show_hierarchy( H, i_abs, elem_format );
784  printf( "\n" );
785  }
786 
787  printf( "%s\n", footer );
788  }
789 
790  return FLA_SUCCESS;
791 }
FLA_Error FLA_Obj_show(char *s1, FLA_Obj A, char *format, char *s2)
Definition: FLA_Misc.c:420
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
unsigned long dim_t
Definition: FLA_type_defs.h:71
dim_t FLASH_Obj_scalar_row_offset(FLA_Obj H)
Definition: FLASH_View.c:693
FLA_Error FLASH_Obj_show_hierarchy(FLA_Obj H, dim_t i, char *elem_format)
Definition: FLASH_View.c:793
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51

◆ FLASH_Obj_show_hierarchy()

FLA_Error FLASH_Obj_show_hierarchy ( FLA_Obj  H,
dim_t  i,
char *  elem_format 
)

References FLA_Cont_with_1x3_to_1x2(), FLA_Obj_buffer_at_view(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_elemtype(), FLA_Obj_row_offset(), FLA_Obj_row_stride(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Repart_1x2_to_1x3(), FLASH_Obj_scalar_length_tl(), i, and imag.

Referenced by FLASH_Obj_show().

794 {
795  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
796  {
797  FLA_Datatype datatype = FLA_Obj_datatype( H );
798  dim_t m = FLA_Obj_width( H );
799  dim_t rs = FLA_Obj_row_stride( H );
800  dim_t cs = FLA_Obj_col_stride( H );
801  dim_t j;
802 
803  // At this point, i is an absolute row index. We subtract out the
804  // row offset of the view so that the index is relative to the view.
805  i = i - FLA_Obj_row_offset( H );
806 
807  if ( datatype == FLA_INT )
808  {
809  int* buffer = FLA_Obj_buffer_at_view( H );
810 
811  for ( j = 0; j < m; ++j )
812  {
813  printf( elem_format, buffer[ j*cs + i*rs ] );
814  printf( " " );
815  }
816  }
817  else if ( datatype == FLA_FLOAT )
818  {
819  float* buffer = FLA_Obj_buffer_at_view( H );
820 
821  for ( j = 0; j < m; ++j )
822  {
823  printf( elem_format, buffer[ j*cs + i*rs ] );
824  printf( " " );
825  }
826  }
827  else if ( datatype == FLA_DOUBLE )
828  {
829  double* buffer = FLA_Obj_buffer_at_view( H );
830 
831  for ( j = 0; j < m; ++j )
832  {
833  printf( elem_format, buffer[ j*cs + i*rs ] );
834  printf( " " );
835  }
836  }
837  else if ( datatype == FLA_COMPLEX )
838  {
839  scomplex* buffer = FLA_Obj_buffer_at_view( H );
840 
841  for ( j = 0; j < m; ++j )
842  {
843  printf( elem_format, buffer[ j*cs + i*rs ].real,
844  buffer[ j*cs + i*rs ].imag );
845  printf( " " );
846  }
847  }
848  else if ( datatype == FLA_DOUBLE_COMPLEX )
849  {
850  dcomplex* buffer = FLA_Obj_buffer_at_view( H );
851 
852  for ( j = 0; j < m; ++j )
853  {
854  printf( elem_format, buffer[ j*cs + i*rs ].real,
855  buffer[ j*cs + i*rs ].imag );
856  printf( " " );
857  }
858  }
859  else
860  {
861  FLA_Check_error_code( FLA_NOT_YET_IMPLEMENTED );
862  }
863  }
864  else
865  {
866  FLA_Obj HT,
867  HB;
868  FLA_Obj HBL, HBR, H10, H11, H12;
869  dim_t b_m_scalar;
870  dim_t offm_local;
871  dim_t i_next;
872 
873  // Get the scalar length of the top-left block.
874  b_m_scalar = FLASH_Obj_scalar_length_tl( H );
875 
876 #if 0
877 printf( "\n------------------------\n" );
878 printf( "b_m_scalar %d\n", b_m_scalar );
879 printf( "i %d\n", i );
880 #endif
881 
882  // Compute the offset of the matrix block, relative to the current
883  // view, that contains the ith row of the matrix.
884  offm_local = ( i ) / b_m_scalar - FLA_Obj_row_offset( H );
885  i_next = ( i ) % b_m_scalar;
886 
887 #if 0
888 printf( "row offset %d\n", FLA_Obj_row_offset( H ) );
889 printf( "offm_local %d\n", offm_local );
890 printf( "i_next %d\n", i_next );
891 #endif
892 
893  FLA_Part_2x1( H, &HT,
894  &HB, offm_local, FLA_TOP );
895 
896  FLA_Part_1x2( HB, &HBL, &HBR, 0, FLA_LEFT );
897 
898  while ( FLA_Obj_width( HBL ) < FLA_Obj_width( HB ) )
899  {
900  FLA_Repart_1x2_to_1x3( HBL, /**/ HBR, &H10, /**/ &H11, &H12,
901  1, FLA_RIGHT );
902 
903  // ------------------------------------------------------
904 
905  FLASH_Obj_show_hierarchy( *FLASH_OBJ_PTR_AT( H11 ),
906  i_next, elem_format );
907 
908  // ------------------------------------------------------
909 
910  FLA_Cont_with_1x3_to_1x2( &HBL, /**/ &HBR, H10, H11, /**/ H12,
911  FLA_LEFT );
912  }
913  }
914 
915  return FLA_SUCCESS;
916 }
FLA_Error FLA_Repart_1x2_to_1x3(FLA_Obj AL, FLA_Obj AR, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:267
unsigned long dim_t
Definition: FLA_type_defs.h:71
dim_t FLA_Obj_row_stride(FLA_Obj obj)
Definition: FLA_Query.c:167
float real
Definition: FLA_f2c.h:30
FLA_Error FLASH_Obj_show_hierarchy(FLA_Obj H, dim_t i, char *elem_format)
Definition: FLASH_View.c:793
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition: FLA_Query.c:13
rho_c imag
Definition: bl1_axpyv2bdotaxpy.c:483
void * FLA_Obj_buffer_at_view(FLA_Obj obj)
Definition: FLA_Query.c:215
Definition: FLA_type_defs.h:158
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
FLA_Error FLA_Cont_with_1x3_to_1x2(FLA_Obj *AL, FLA_Obj *AR, FLA_Obj A0, FLA_Obj A1, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:475
Definition: blis_type_defs.h:132
dim_t FLASH_Obj_scalar_length_tl(FLA_Obj H)
Definition: FLASH_View.c:723
dim_t FLA_Obj_row_offset(FLA_Obj obj)
Definition: FLA_Query.c:180
FLA_Error FLA_Part_2x1(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:76
int FLA_Datatype
Definition: FLA_type_defs.h:49
FLA_Error FLA_Part_1x2(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:110
dim_t FLA_Obj_col_stride(FLA_Obj obj)
Definition: FLA_Query.c:174
int i
Definition: bl1_axmyv2.c:145
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51
Definition: blis_type_defs.h:137

◆ FLASH_Part_create_1x2()

FLA_Error FLASH_Part_create_1x2 ( FLA_Obj  A,
FLA_Obj AL,
FLA_Obj AR,
dim_t  n_cols,
FLA_Side  side 
)

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLA_Part_1x2_check(), FLASH_Obj_adjust_views(), FLASH_Obj_base_scalar_length(), FLASH_Obj_base_scalar_width(), FLASH_Obj_blocksizes(), FLASH_Obj_create_without_buffer_ext(), FLASH_Obj_datatype(), FLASH_Obj_depth(), FLASH_Obj_scalar_col_offset(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_row_offset(), and FLASH_Obj_scalar_width().

105 {
106  FLA_Datatype dt_A;
107  dim_t m_A, n_A;
108  dim_t m_A_base, n_A_base;
109  dim_t m_AL, n_AL;
110  dim_t m_AR, n_AR;
111  dim_t depth;
112  dim_t* b_m;
113  dim_t* b_n;
114  dim_t offm_A, offn_A;
115  dim_t offm_AL, offn_AL;
116  dim_t offm_AR, offn_AR;
117 
118  if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING )
119  FLA_Part_1x2_check( A, AL, AR, n_cols, side );
120 
121  // Safeguard: if n_cols > n, reduce n_cols to n.
122  if ( n_cols > FLASH_Obj_scalar_width( A ) )
123  n_cols = FLASH_Obj_scalar_width( A );
124 
125  // Acquire various properties of the hierarchical matrix object.
126  dt_A = FLASH_Obj_datatype( A );
127  m_A = FLASH_Obj_scalar_length( A );
128  n_A = FLASH_Obj_scalar_width( A );
129  offm_A = FLASH_Obj_scalar_row_offset( A );
130  offn_A = FLASH_Obj_scalar_col_offset( A );
131  m_A_base = FLASH_Obj_base_scalar_length( A );
132  n_A_base = FLASH_Obj_base_scalar_width( A );
133  depth = FLASH_Obj_depth( A );
134 
135  // Allocate a pair of temporary arrays for the blocksizes, whose lengths
136  // are equal to the object's hierarchical depth.
137  b_m = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
138  b_n = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
139 
140  // Accumulate the blocksizes into the blocksize buffers.
141  FLASH_Obj_blocksizes( A, b_m, b_n );
142 
143  // Adjust n_cols to be (n - n_cols) if the side specified is on the
144  // right so that the right values get assigned below.
145  if ( side == FLA_RIGHT ) n_cols = n_A - n_cols;
146 
147  // Set the dimensions of the partitions.
148  m_AL = m_A;
149  n_AL = n_cols;
150  m_AR = m_A;
151  n_AR = n_A - n_cols;
152 
153  // Set the offsets.
154  offm_AL = offm_A + 0;
155  offn_AL = offn_A + 0;
156  offm_AR = offm_A + 0;
157  offn_AR = offn_A + n_AL;
158 
159  // Create bufferless hierarhical objects that have the desired dimensions
160  // for the views.
161  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, AL );
162  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, AR );
163 
164  // Recursively walk the hierarchy and adjust the views so that they
165  // collectively refer to the absolute offsets given, and attach the
166  // leaf-level numerical buffers of A to the new views.
167  FLASH_Obj_adjust_views( TRUE, offm_AL, offn_AL, m_AL, n_AL, A, AL );
168  FLASH_Obj_adjust_views( TRUE, offm_AR, offn_AR, m_AR, n_AR, A, AR );
169 
170  // Free the temporary blocksize buffers.
171  FLA_free( b_m );
172  FLA_free( b_n );
173 
174  return FLA_SUCCESS;
175 }
dim_t FLASH_Obj_scalar_col_offset(FLA_Obj H)
Definition: FLASH_View.c:708
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
dim_t FLASH_Obj_blocksizes(FLA_Obj H, dim_t *b_m, dim_t *b_n)
Definition: FLASH_Obj.c:49
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Datatype FLASH_Obj_datatype(FLA_Obj H)
Definition: FLASH_Obj.c:14
dim_t FLASH_Obj_depth(FLA_Obj H)
Definition: FLASH_Obj.c:20
FLA_Error FLASH_Obj_create_without_buffer_ext(FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj.c:167
FLA_Error FLASH_Obj_adjust_views(FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
Definition: FLASH_View.c:275
dim_t FLASH_Obj_base_scalar_length(FLA_Obj H)
Definition: FLASH_Obj.c:83
dim_t FLASH_Obj_scalar_row_offset(FLA_Obj H)
Definition: FLASH_View.c:693
FLA_Error FLA_Part_1x2_check(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_Part_1x2_check.c:13
void FLA_free(void *ptr)
Definition: FLA_Memory.c:247
void * FLA_malloc(size_t size)
Definition: FLA_Memory.c:111
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
int FLA_Datatype
Definition: FLA_type_defs.h:49
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641
dim_t FLASH_Obj_base_scalar_width(FLA_Obj H)
Definition: FLASH_Obj.c:113

◆ FLASH_Part_create_2x1()

FLA_Error FLASH_Part_create_2x1 ( FLA_Obj  A,
FLA_Obj AT,
FLA_Obj AB,
dim_t  n_rows,
FLA_Side  side 
)

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLA_Part_2x1_check(), FLASH_Obj_adjust_views(), FLASH_Obj_base_scalar_length(), FLASH_Obj_base_scalar_width(), FLASH_Obj_blocksizes(), FLASH_Obj_create_without_buffer_ext(), FLASH_Obj_datatype(), FLASH_Obj_depth(), FLASH_Obj_scalar_col_offset(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_row_offset(), and FLASH_Obj_scalar_width().

Referenced by FLASH_CAQR_UT_inc_solve(), and FLASH_QR_UT_inc_solve().

16 {
17  FLA_Datatype dt_A;
18  dim_t m_A, n_A;
19  dim_t m_A_base, n_A_base;
20  dim_t m_AT, n_AT;
21  dim_t m_AB, n_AB;
22  dim_t depth;
23  dim_t* b_m;
24  dim_t* b_n;
25  dim_t offm_A, offn_A;
26  dim_t offm_AT, offn_AT;
27  dim_t offm_AB, offn_AB;
28 
29  if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING )
30  FLA_Part_2x1_check( A, AT,
31  AB, n_rows, side );
32 
33  // Safeguard: if n_rows > m, reduce n_rows to m.
34  if ( n_rows > FLASH_Obj_scalar_length( A ) )
35  n_rows = FLASH_Obj_scalar_length( A );
36 
37  // Acquire various properties of the hierarchical matrix view.
38  dt_A = FLASH_Obj_datatype( A );
39  m_A = FLASH_Obj_scalar_length( A );
40  n_A = FLASH_Obj_scalar_width( A );
41  offm_A = FLASH_Obj_scalar_row_offset( A );
42  offn_A = FLASH_Obj_scalar_col_offset( A );
43  m_A_base = FLASH_Obj_base_scalar_length( A );
44  n_A_base = FLASH_Obj_base_scalar_width( A );
45  depth = FLASH_Obj_depth( A );
46 
47  // Allocate a pair of temporary arrays for the blocksizes, whose lengths
48  // are equal to the object's hierarchical depth.
49  b_m = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
50  b_n = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
51 
52  // Accumulate the blocksizes into the blocksize buffers.
53  FLASH_Obj_blocksizes( A, b_m, b_n );
54 
55  // Adjust n_rows to be (m - n_rows) if the side specified is on the
56  // bottom so that the right values get assigned below.
57  if ( side == FLA_BOTTOM ) n_rows = m_A - n_rows;
58 
59  // Set the dimensions of the partitions.
60  m_AT = n_rows;
61  n_AT = n_A;
62  m_AB = m_A - n_rows;
63  n_AB = n_A;
64 
65  // Set the offsets.
66  offm_AT = offm_A + 0;
67  offn_AT = offn_A + 0;
68  offm_AB = offm_A + m_AT;
69  offn_AB = offn_A + 0;
70 
71  // Create bufferless hierarhical objects that have the desired dimensions
72  // for the views.
73  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, AT );
74  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, AB );
75 
76 /*
77 printf( "depth %d\n", depth );
78 printf( "b_m/n[0] %d %d\n", b_m[0], b_n[0] );
79 printf( "b_m/n_tl %d %d\n", FLASH_Obj_scalar_length_tl( A ), FLASH_Obj_scalar_width_tl( A ) );
80 printf( "m/n_A_base %d %d\n", m_A_base, n_A_base );
81 printf( "offm/n_AT: %d %d\n", offm_AT, offn_AT );
82 printf( "m/n_AT: %d %d\n", m_AT, n_AT );
83 printf( "offm/n_AB: %d %d\n", offm_AB, offn_AB );
84 printf( "m/n_AB: %d %d\n", m_AB, n_AB );
85 printf( "A is %d %d\n", FLA_Obj_length( A ), FLA_Obj_width( A ) );
86 printf( "AT is %d %d\n", FLA_Obj_length( *AT ), FLA_Obj_width( *AT ) );
87 printf( "AB is %d %d\n", FLA_Obj_length( *AB ), FLA_Obj_width( *AB ) );
88 */
89 
90  // Recursively walk the hierarchy and adjust the views so that they
91  // collectively refer to the absolute offsets given, and attach the
92  // leaf-level numerical buffers of A to the new views.
93  FLASH_Obj_adjust_views( TRUE, offm_AT, offn_AT, m_AT, n_AT, A, AT );
94  FLASH_Obj_adjust_views( TRUE, offm_AB, offn_AB, m_AB, n_AB, A, AB );
95 
96  // Free the temporary blocksize buffers.
97  FLA_free( b_m );
98  FLA_free( b_n );
99 
100  return FLA_SUCCESS;
101 }
FLA_Error FLA_Part_2x1_check(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_Part_2x1_check.c:13
dim_t FLASH_Obj_scalar_col_offset(FLA_Obj H)
Definition: FLASH_View.c:708
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
dim_t FLASH_Obj_blocksizes(FLA_Obj H, dim_t *b_m, dim_t *b_n)
Definition: FLASH_Obj.c:49
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Datatype FLASH_Obj_datatype(FLA_Obj H)
Definition: FLASH_Obj.c:14
dim_t FLASH_Obj_depth(FLA_Obj H)
Definition: FLASH_Obj.c:20
FLA_Error FLASH_Obj_create_without_buffer_ext(FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj.c:167
FLA_Error FLASH_Obj_adjust_views(FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
Definition: FLASH_View.c:275
dim_t FLASH_Obj_base_scalar_length(FLA_Obj H)
Definition: FLASH_Obj.c:83
dim_t FLASH_Obj_scalar_row_offset(FLA_Obj H)
Definition: FLASH_View.c:693
void FLA_free(void *ptr)
Definition: FLA_Memory.c:247
void * FLA_malloc(size_t size)
Definition: FLA_Memory.c:111
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
int FLA_Datatype
Definition: FLA_type_defs.h:49
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641
dim_t FLASH_Obj_base_scalar_width(FLA_Obj H)
Definition: FLASH_Obj.c:113

◆ FLASH_Part_create_2x2()

FLA_Error FLASH_Part_create_2x2 ( FLA_Obj  A,
FLA_Obj ATL,
FLA_Obj ATR,
FLA_Obj ABL,
FLA_Obj ABR,
dim_t  n_rows,
dim_t  n_cols,
FLA_Side  side 
)

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLA_Part_2x2_check(), FLASH_Obj_adjust_views(), FLASH_Obj_base_scalar_length(), FLASH_Obj_base_scalar_width(), FLASH_Obj_blocksizes(), FLASH_Obj_create_without_buffer_ext(), FLASH_Obj_datatype(), FLASH_Obj_depth(), FLASH_Obj_scalar_col_offset(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_row_offset(), and FLASH_Obj_scalar_width().

Referenced by FLASH_Axpy_flat_to_hier(), FLASH_Axpy_hier_to_flat(), FLASH_Copy_flat_to_hier(), and FLASH_Copy_hier_to_flat().

180 {
181  FLA_Datatype dt_A;
182  dim_t m_A_base, n_A_base;
183  dim_t m_A, n_A;
184  dim_t m_ATL, n_ATL;
185  dim_t m_ABL, n_ABL;
186  dim_t m_ATR, n_ATR;
187  dim_t m_ABR, n_ABR;
188  dim_t depth;
189  dim_t* b_m;
190  dim_t* b_n;
191  dim_t offm_A, offn_A;
192  dim_t offm_ATL, offn_ATL;
193  dim_t offm_ABL, offn_ABL;
194  dim_t offm_ATR, offn_ATR;
195  dim_t offm_ABR, offn_ABR;
196 
197  if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING )
198  FLA_Part_2x2_check( A, ATL, ATR,
199  ABL, ABR, n_rows, n_cols, side );
200 
201  // Safeguard: if n_rows > m, reduce n_rows to m.
202  if ( n_rows > FLASH_Obj_scalar_length( A ) )
203  n_rows = FLASH_Obj_scalar_length( A );
204 
205  // Safeguard: if n_cols > n, reduce n_cols to n.
206  if ( n_cols > FLASH_Obj_scalar_width( A ) )
207  n_cols = FLASH_Obj_scalar_width( A );
208 
209  // Acquire various properties of the hierarchical matrix object.
210  dt_A = FLASH_Obj_datatype( A );
211  m_A = FLASH_Obj_scalar_length( A );
212  n_A = FLASH_Obj_scalar_width( A );
213  offm_A = FLASH_Obj_scalar_row_offset( A );
214  offn_A = FLASH_Obj_scalar_col_offset( A );
215  m_A_base = FLASH_Obj_base_scalar_length( A );
216  n_A_base = FLASH_Obj_base_scalar_width( A );
217  depth = FLASH_Obj_depth( A );
218 
219  // Allocate a pair of temporary arrays for the blocksizes, whose lengths
220  // are equal to the object's hierarchical depth.
221  b_m = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
222  b_n = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
223 
224  // Accumulate the blocksizes into the blocksize buffers.
225  FLASH_Obj_blocksizes( A, b_m, b_n );
226 
227  // Adjust n_rows to be (m - n_rows) if the quadrant specified is on
228  // the bottom so that the right values get assigned below. Do the same
229  // for n_cols.
230  if ( side == FLA_BL || side == FLA_BR ) n_rows = m_A - n_rows;
231  if ( side == FLA_TR || side == FLA_BR ) n_cols = n_A - n_cols;
232 
233  // Set the dimensions of the partitions.
234  m_ATL = n_rows;
235  n_ATL = n_cols;
236  m_ABL = m_A - n_rows;
237  n_ABL = n_cols;
238  m_ATR = n_rows;
239  n_ATR = n_A - n_cols;
240  m_ABR = m_A - n_rows;
241  n_ABR = n_A - n_cols;
242 
243  // Set the offsets.
244  offm_ATL = offm_A + 0;
245  offn_ATL = offn_A + 0;
246  offm_ABL = offm_A + m_ATL;
247  offn_ABL = offn_A + 0;
248  offm_ATR = offm_A + 0;
249  offn_ATR = offn_A + n_ATL;
250  offm_ABR = offm_A + m_ATL;
251  offn_ABR = offn_A + n_ATL;
252 
253  // Create bufferless hierarhical objects that have the desired dimensions
254  // for the views.
255  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, ATL );
256  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, ABL );
257  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, ATR );
258  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, ABR );
259 
260  // Recursively walk the hierarchy and adjust the views so that they
261  // collectively refer to the absolute offsets given, and attach the
262  // leaf-level numerical buffers of A to the new views.
263  FLASH_Obj_adjust_views( TRUE, offm_ATL, offn_ATL, m_ATL, n_ATL, A, ATL );
264  FLASH_Obj_adjust_views( TRUE, offm_ABL, offn_ABL, m_ABL, n_ABL, A, ABL );
265  FLASH_Obj_adjust_views( TRUE, offm_ATR, offn_ATR, m_ATR, n_ATR, A, ATR );
266  FLASH_Obj_adjust_views( TRUE, offm_ABR, offn_ABR, m_ABR, n_ABR, A, ABR );
267 
268  // Free the temporary blocksize buffers.
269  FLA_free( b_m );
270  FLA_free( b_n );
271 
272  return FLA_SUCCESS;
273 }
dim_t FLASH_Obj_scalar_col_offset(FLA_Obj H)
Definition: FLASH_View.c:708
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
dim_t FLASH_Obj_blocksizes(FLA_Obj H, dim_t *b_m, dim_t *b_n)
Definition: FLASH_Obj.c:49
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Datatype FLASH_Obj_datatype(FLA_Obj H)
Definition: FLASH_Obj.c:14
dim_t FLASH_Obj_depth(FLA_Obj H)
Definition: FLASH_Obj.c:20
FLA_Error FLASH_Obj_create_without_buffer_ext(FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj.c:167
FLA_Error FLASH_Obj_adjust_views(FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
Definition: FLASH_View.c:275
dim_t FLASH_Obj_base_scalar_length(FLA_Obj H)
Definition: FLASH_Obj.c:83
dim_t FLASH_Obj_scalar_row_offset(FLA_Obj H)
Definition: FLASH_View.c:693
void FLA_free(void *ptr)
Definition: FLA_Memory.c:247
FLA_Error FLA_Part_2x2_check(FLA_Obj A, FLA_Obj *A11, FLA_Obj *A12, FLA_Obj *A21, FLA_Obj *A22, dim_t mb, dim_t nb, FLA_Quadrant quadrant)
Definition: FLA_Part_2x2_check.c:13
void * FLA_malloc(size_t size)
Definition: FLA_Memory.c:111
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
int FLA_Datatype
Definition: FLA_type_defs.h:49
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641
dim_t FLASH_Obj_base_scalar_width(FLA_Obj H)
Definition: FLASH_Obj.c:113

◆ FLASH_Part_free_1x2()

FLA_Error FLASH_Part_free_1x2 ( FLA_Obj AL,
FLA_Obj AR 
)

References FLASH_Obj_free_without_buffer().

582 {
585 
586  return FLA_SUCCESS;
587 }
void FLASH_Obj_free_without_buffer(FLA_Obj *H)
Definition: FLASH_Obj.c:674

◆ FLASH_Part_free_2x1()

FLA_Error FLASH_Part_free_2x1 ( FLA_Obj AT,
FLA_Obj AB 
)

References FLASH_Obj_free_without_buffer().

Referenced by FLASH_CAQR_UT_inc_solve(), and FLASH_QR_UT_inc_solve().

574 {
577 
578  return FLA_SUCCESS;
579 }
void FLASH_Obj_free_without_buffer(FLA_Obj *H)
Definition: FLASH_Obj.c:674

◆ FLASH_Part_free_2x2()

FLA_Error FLASH_Part_free_2x2 ( FLA_Obj ATL,
FLA_Obj ATR,
FLA_Obj ABL,
FLA_Obj ABR 
)

References FLASH_Obj_free_without_buffer().

Referenced by FLASH_Axpy_flat_to_hier(), FLASH_Axpy_hier_to_flat(), FLASH_Copy_flat_to_hier(), and FLASH_Copy_hier_to_flat().

591 {
596 
597  return FLA_SUCCESS;
598 }
void FLASH_Obj_free_without_buffer(FLA_Obj *H)
Definition: FLASH_Obj.c:674