FLASH_Obj.c File Reference

(r)


Functions

FLA_Datatype FLASH_Obj_datatype (FLA_Obj H)
dim_t FLASH_Obj_depth (FLA_Obj H)
dim_t FLASH_Obj_blocksizes (FLA_Obj H, dim_t *b_m, dim_t *b_n)
dim_t FLASH_Obj_scalar_length (FLA_Obj H)
dim_t FLASH_Obj_scalar_width (FLA_Obj H)
FLA_Error FLASH_Obj_create (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *blocksizes, FLA_Obj *H)
FLA_Error FLASH_Obj_create_ext (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
FLA_Error FLASH_Obj_create_without_buffer (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *blocksizes, FLA_Obj *H)
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)
FLA_Error FLASH_Obj_create_helper (FLA_Bool without_buffer, FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
FLA_Error FLASH_Obj_create_hierarchy (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *elem_sizes_m, dim_t *elem_sizes_n, FLA_Obj flat_matrix, FLA_Obj *H, unsigned long id, dim_t depth_overall, dim_t *depth_sizes_m, dim_t *depth_sizes_n, dim_t *m_offsets, dim_t *n_offsets)
FLA_Error FLASH_Obj_create_conf_to (FLA_Trans trans, FLA_Obj H_cur, FLA_Obj *H_new)
FLA_Error FLASH_Obj_create_hier_conf_to_flat (FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *blocksizes, FLA_Obj *H)
FLA_Error FLASH_Obj_create_hier_conf_to_flat_ext (FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
FLA_Error FLASH_Obj_create_flat_conf_to_hier (FLA_Trans trans, FLA_Obj H, FLA_Obj *F)
FLA_Error FLASH_Obj_create_hier_copy_of_flat (FLA_Obj F, dim_t depth, dim_t *blocksizes, FLA_Obj *H)
FLA_Error FLASH_Obj_create_hier_copy_of_flat_ext (FLA_Obj F, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
FLA_Error FLASH_Obj_create_flat_copy_of_hier (FLA_Obj H, FLA_Obj *F)
void FLASH_Obj_free (FLA_Obj *H)
void FLASH_Obj_free_without_buffer (FLA_Obj *H)
void FLASH_Obj_free_hierarchy (FLA_Obj *H)
void * FLASH_Obj_extract_buffer (FLA_Obj H)
FLA_Error FLASH_Obj_flatten (FLA_Obj H, FLA_Obj F)
FLA_Error FLASH_Obj_hierarchify (FLA_Obj F, FLA_Obj H)
FLA_Error FLASH_Obj_show (char *header, FLA_Obj H, char *elem_format, char *footer)
FLA_Error FLASH_Obj_attach_buffer (void *buffer, dim_t ldim, FLA_Obj *H)
FLA_Error FLASH_Obj_attach_buffer_hierarchy (FLA_Obj F, FLA_Obj *H)
void FLASH_print_struct (FLA_Obj H)
void FLASH_print_struct_helper (FLA_Obj H, int indent)

Function Documentation

FLA_Error FLASH_Obj_attach_buffer ( void *  buffer,
dim_t  ldim,
FLA_Obj H 
)

References FLA_Check_error_level(), FLA_Obj_attach_buffer(), FLA_Obj_create_without_buffer(), FLA_Obj_free_without_buffer(), FLASH_Obj_attach_buffer_check(), FLASH_Obj_attach_buffer_hierarchy(), FLASH_Obj_datatype(), FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

00812 {
00813     FLA_Obj      flat_matrix;
00814     dim_t        m_H, n_H;
00815     FLA_Datatype datatype;
00816 
00817     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00818         FLASH_Obj_attach_buffer_check( buffer, ldim, H );
00819 
00820     // Extract the overall scalar dimensions of the hierarchical matrix and
00821     // its base numerical datatype. (These fields will be set even if it has
00822     // a NULL buffer, which presumably it does given that this function was
00823     // just invoked.)
00824     m_H      = FLASH_Obj_scalar_length( *H );
00825     n_H      = FLASH_Obj_scalar_width( *H );
00826     datatype = FLASH_Obj_datatype( *H );
00827 
00828     // Create a temporary conventional object and attach the given buffer.
00829     // Segments of this buffer will be partitioned out to the various
00830     // leaf-level matrices of the hierarchical matrix H.
00831     FLA_Obj_create_without_buffer( datatype, m_H, n_H, &flat_matrix );
00832     FLA_Obj_attach_buffer( buffer, ldim, &flat_matrix );
00833 
00834     // Recurse through the hierarchical matrix, assigning segments of
00835     // flat_matrix to the various leaf-level matrices, similar to what
00836     // we would do if we were creating the object outright.
00837     FLASH_Obj_attach_buffer_hierarchy( flat_matrix, H );
00838 
00839     // Free the object (but don't free the buffer!).
00840     FLA_Obj_free_without_buffer( &flat_matrix );
00841 
00842     return FLA_SUCCESS;
00843 }

FLA_Error FLASH_Obj_attach_buffer_hierarchy ( FLA_Obj  F,
FLA_Obj H 
)

References FLA_Check_error_level(), FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Obj_attach_buffer(), FLA_Obj_buffer(), FLA_Obj_elemtype(), FLA_Obj_ldim(), FLA_Obj_length(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Repart_1x2_to_1x3(), FLA_Repart_2x1_to_3x1(), FLASH_Obj_attach_buffer_hierarchy(), FLASH_Obj_attach_buffer_hierarchy_check(), FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

Referenced by FLASH_Obj_attach_buffer(), and FLASH_Obj_attach_buffer_hierarchy().

00847 {
00848     FLA_Obj FL,    FR,       F0,  F1,  F2;
00849 
00850     FLA_Obj HL,    HR,       H0,  H1,  H2;
00851 
00852     FLA_Obj F1T,              F01,
00853             F1B,              F11,
00854                               F21;
00855 
00856     FLA_Obj H1T,              H01,
00857             H1B,              H11,
00858                               H21;
00859 
00860     FLA_Obj* H11p;
00861 
00862     dim_t b_m, b_n;
00863 
00864     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00865         FLASH_Obj_attach_buffer_hierarchy_check( F, H );
00866 
00867     if ( FLA_Obj_elemtype( *H ) == FLA_SCALAR )
00868     {
00869         // If we've recursed down to a leaf node, then we can simply attach the
00870         // matrix buffer to the current leaf-level submatrix.
00871         FLA_Obj_attach_buffer( FLA_Obj_buffer( F ), FLA_Obj_ldim( F ), H );
00872     }
00873     else
00874     {
00875         FLA_Part_1x2( *H,    &HL,  &HR,      0, FLA_LEFT );
00876 
00877         FLA_Part_1x2(  F,    &FL,  &FR,      0, FLA_LEFT );
00878 
00879         while ( FLA_Obj_width( HL ) < FLA_Obj_width( *H ) )
00880         {
00881 
00882             FLA_Repart_1x2_to_1x3( HL,  /**/ HR,        &H0, /**/ &H1, &H2,
00883                                    1, FLA_RIGHT );
00884 
00885             b_n = FLASH_Obj_scalar_width( H1 );
00886 
00887             FLA_Repart_1x2_to_1x3( FL,  /**/ FR,        &F0, /**/ &F1, &F2,
00888                                    b_n, FLA_RIGHT );
00889 
00890             /*------------------------------------------------------------*/
00891 
00892             FLA_Part_2x1( H1,    &H1T,
00893                                  &H1B,            0, FLA_TOP );
00894 
00895             FLA_Part_2x1( F1,    &F1T,
00896                                  &F1B,            0, FLA_TOP );
00897 
00898             while ( FLA_Obj_length( H1T ) < FLA_Obj_length( H1 ) )
00899             {
00900 
00901                 FLA_Repart_2x1_to_3x1( H1T,               &H01,
00902                                     /* ** */            /* ** */
00903                                                           &H11,
00904                                        H1B,               &H21,        1, FLA_BOTTOM );
00905 
00906                 b_m = FLASH_Obj_scalar_length( H11 );
00907 
00908                 FLA_Repart_2x1_to_3x1( F1T,               &F01,
00909                                     /* ** */            /* ** */
00910                                                           &F11,
00911                                        F1B,               &F21,      b_m, FLA_BOTTOM );
00912 
00913                 /*------------------------------------------------------------*/
00914 
00915                 H11p = ( FLA_Obj* ) FLA_Obj_buffer( H11 );
00916 
00917                 FLASH_Obj_attach_buffer_hierarchy( F11, H11p );
00918 
00919                 /*------------------------------------------------------------*/
00920 
00921                 FLA_Cont_with_3x1_to_2x1( &H1T,               H01,
00922                                                               H11,
00923                                         /* ** */           /* ** */
00924                                           &H1B,               H21,     FLA_TOP );
00925 
00926                 FLA_Cont_with_3x1_to_2x1( &F1T,               F01,
00927                                                               F11,
00928                                         /* ** */           /* ** */
00929                                           &F1B,               F21,     FLA_TOP );
00930             }
00931 
00932             /*------------------------------------------------------------*/
00933 
00934             FLA_Cont_with_1x3_to_1x2( &HL,  /**/ &HR,        H0, H1, /**/ H2,
00935                                       FLA_LEFT );
00936 
00937             FLA_Cont_with_1x3_to_1x2( &FL,  /**/ &FR,        F0, F1, /**/ F2,
00938                                       FLA_LEFT );
00939 
00940         }
00941     }
00942 
00943     return FLA_SUCCESS;
00944 }

dim_t FLASH_Obj_blocksizes ( FLA_Obj  H,
dim_t b_m,
dim_t b_n 
)

References FLA_Check_error_level(), FLA_Obj_buffer(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Obj_width(), and FLASH_Obj_blocksizes_check().

Referenced by FLASH_Obj_create_conf_to().

00072 {
00073     FLA_Elemtype elemtype;
00074     FLA_Obj*     buffer_H;
00075     dim_t        depth = 0;
00076 
00077     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00078         FLASH_Obj_blocksizes_check( H, b_m, b_n );
00079 
00080     // Recurse through the hierarchy to the first leaf node. We initialize
00081     // the recursion here:
00082     elemtype = FLA_Obj_elemtype( H );
00083     buffer_H = ( FLA_Obj* ) FLA_Obj_buffer( H );
00084 
00085     while ( elemtype == FLA_MATRIX )
00086     {
00087         b_m[depth] = FLA_Obj_length( buffer_H[0] );
00088         b_n[depth] = FLA_Obj_width( buffer_H[0] );
00089         ++depth;
00090 
00091         // Get the element type of the top-leftmost underlying object. Also,
00092         // get a pointer to the first element of the top-leftmost object and
00093         // assume that it is of type FLA_Obj* in case elemtype is once again
00094         // FLA_MATRIX.
00095         elemtype = FLA_Obj_elemtype( buffer_H[0] );
00096         buffer_H = ( FLA_Obj * ) FLA_Obj_buffer( buffer_H[0] );
00097     }
00098 
00099     // At this point, the first depth elements of blocksizes have been filled
00100     // with the blocksizes of H's various hierarchical levels. Return the
00101     // matrix depth as a confirmation of how many blocksizes were found.
00102     return depth;
00103 }

FLA_Error FLASH_Obj_create ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t blocksizes,
FLA_Obj H 
)

References FLASH_Obj_create_helper().

Referenced by FLA_QR_UT_inc_create_U_panel(), and FLASH_Obj_create_hier_conf_to_flat().

00178 {
00179     FLASH_Obj_create_helper( FALSE, datatype, m, n, depth, blocksizes, blocksizes, H );
00180 
00181     return FLA_SUCCESS;
00182 }

FLA_Error FLASH_Obj_create_conf_to ( FLA_Trans  trans,
FLA_Obj  H_cur,
FLA_Obj H_new 
)

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLASH_Obj_blocksizes(), FLASH_Obj_create_conf_to_check(), FLASH_Obj_create_ext(), FLASH_Obj_datatype(), FLASH_Obj_depth(), FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

Referenced by FLA_QR_UT_inc_create_U().

00439 {
00440     FLA_Datatype datatype;
00441     dim_t        m_H_cur, n_H_cur;
00442     dim_t        m_H_new, n_H_new;
00443     dim_t        d_H;
00444     dim_t*       b_m;
00445     dim_t*       b_n;
00446 
00447     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00448         FLASH_Obj_create_conf_to_check( trans, H_cur, H_new );
00449 
00450     // Acquire the numerical datatype, length, width, and depth of the
00451     // hierarchical matrix object.
00452     datatype = FLASH_Obj_datatype( H_cur );
00453     m_H_cur  = FLASH_Obj_scalar_length( H_cur );
00454     n_H_cur  = FLASH_Obj_scalar_width( H_cur );
00455     d_H      = FLASH_Obj_depth( H_cur );
00456 
00457     // Allocate a pair of temporary arrays for the blocksizes, whose length is
00458     // equal to the object's hierarchical depth.
00459     b_m = ( dim_t * ) FLA_malloc( d_H * sizeof( dim_t ) );
00460     b_n = ( dim_t * ) FLA_malloc( d_H * sizeof( dim_t ) );
00461 
00462     // Accumulate the blocksizes into a buffer.
00463     FLASH_Obj_blocksizes( H_cur, b_m, b_n );
00464 
00465     // Factor in the transposition, if requested.
00466     if ( trans == FLA_NO_TRANSPOSE )
00467     {
00468         m_H_new = m_H_cur;
00469         n_H_new = n_H_cur;
00470     }
00471     else
00472     {
00473         m_H_new = n_H_cur;
00474         n_H_new = m_H_cur;
00475     }
00476 
00477     // Create the new hierarchical matrix object.
00478     FLASH_Obj_create_ext( datatype, m_H_new, n_H_new, d_H, b_m, b_n, H_new ); 
00479 
00480     // Free the temporary blocksize arrays.
00481     FLA_free( b_m );
00482     FLA_free( b_n );
00483 
00484     return FLA_SUCCESS;
00485 }

FLA_Error FLASH_Obj_create_ext ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)

FLA_Error FLASH_Obj_create_flat_conf_to_hier ( FLA_Trans  trans,
FLA_Obj  H,
FLA_Obj F 
)

References FLA_Check_error_level(), FLA_Obj_create(), FLASH_Obj_create_flat_conf_to_hier_check(), FLASH_Obj_datatype(), FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

Referenced by FLASH_Obj_create_flat_copy_of_hier().

00557 {
00558     FLA_Datatype datatype;
00559     dim_t        m_H, n_H;
00560     dim_t        m_F, n_F;
00561 
00562     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00563         FLASH_Obj_create_flat_conf_to_hier_check( trans, H, F );
00564 
00565     // Acquire the numerical datatype, length, and width of the
00566     // hierarchical matrix object.
00567     datatype = FLASH_Obj_datatype( H );
00568     m_H      = FLASH_Obj_scalar_length( H );
00569     n_H      = FLASH_Obj_scalar_width( H );
00570 
00571     // Factor in the transposition, if requested.
00572     if ( trans == FLA_NO_TRANSPOSE )
00573     {
00574         m_F = m_H;
00575         n_F = n_H;
00576     }
00577     else
00578     {
00579         m_F = n_H;
00580         n_F = m_H;
00581     }
00582 
00583     // Create the flat matrix object.
00584     FLA_Obj_create( datatype, m_F, n_F, F );
00585 
00586     return FLA_SUCCESS;
00587 }

FLA_Error FLASH_Obj_create_flat_copy_of_hier ( FLA_Obj  H,
FLA_Obj F 
)

References FLA_Check_error_level(), FLASH_Copy_global_to_subobject(), FLASH_Obj_create_flat_conf_to_hier(), and FLASH_Obj_create_flat_copy_of_hier_check().

Referenced by FLASH_Max_elemwise_diff(), FLASH_Norm1(), FLASH_Obj_set_to_scalar(), FLASH_Obj_shift_diagonal(), FLASH_Obj_show(), FLASH_Random_matrix(), FLASH_Random_spd_matrix(), and FLASH_Triangularize().

00623 {
00624     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00625         FLASH_Obj_create_flat_copy_of_hier_check( H, F );
00626 
00627     // Create a flat object conformal to the hierarchical object.
00628     FLASH_Obj_create_flat_conf_to_hier( FLA_NO_TRANSPOSE, H, F );
00629 
00630     // Flatten the hierarchical object's contents into the new flat object.
00631     FLASH_Copy_global_to_subobject( 0, 0, H, *F );
00632 
00633     return FLA_SUCCESS;
00634 }

FLA_Error FLASH_Obj_create_helper ( FLA_Bool  without_buffer,
FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLA_Obj_create(), FLA_Obj_create_without_buffer(), FLA_Obj_free_without_buffer(), FLASH_Obj_create_helper_check(), and FLASH_Obj_create_hierarchy().

Referenced by FLASH_Obj_create(), FLASH_Obj_create_ext(), FLASH_Obj_create_without_buffer(), and FLASH_Obj_create_without_buffer_ext().

00210 {
00211     dim_t     i;
00212     FLA_Obj   flat_matrix;
00213 
00214     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00215         FLASH_Obj_create_helper_check( without_buffer, datatype, m, n, depth, b_m, b_n, H );
00216 
00217     if ( depth == 0 )
00218     {
00219         // Base case: create a single contiguous matrix block.
00220         if ( without_buffer == FALSE )
00221             FLA_Obj_create( datatype, m, n, H );
00222         else
00223             FLA_Obj_create_without_buffer( datatype, m, n, H );
00224     }
00225     else
00226     {
00227         // We need temporary arrays the same length as the blocksizes arrays.
00228         dim_t* elem_sizes_m  = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
00229         dim_t* elem_sizes_n  = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
00230         dim_t* depth_sizes_m = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
00231         dim_t* depth_sizes_n = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
00232         dim_t* m_offsets     = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
00233         dim_t* n_offsets     = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
00234         
00235         // Fill two sets of arrays: elem_sizes_m/elem_sizes_n and depth_sizes_m/
00236         // depth_sizes_n.
00237         //  - elem_sizes_m[i] will contain the number of numerical elements that span
00238         //    the row dimension of a block at the ith level of the hierarchy. This is
00239         //    just the product of all row blocksizes "internal" to and including the
00240         //    current blocking level. (The elem_sizes_n array tracks similar values
00241         //    in the column dimension.)
00242         //  - depth_sizes_m[i] is similar to elem_sizes_m[i]. The only difference is
00243         //    that instead of tracking the number of numerical elements in the row
00244         //    dimension, it tracks the number of "storage" blocks that span the m
00245         //    dimension of a block at the ith level, where the m dimension of a
00246         //    storage block is the block size given in b_m[depth-1], ie:
00247         //    the inner-most row dimension block size. (The depth_sizes_n array
00248         //    tracks similar values in the column dimension.)
00249         elem_sizes_m[depth-1]  = b_m[depth-1];
00250         elem_sizes_n[depth-1]  = b_n[depth-1];
00251         depth_sizes_m[depth-1] = 1;
00252         depth_sizes_n[depth-1] = 1;
00253         for ( i = depth - 1; i > 0; --i )
00254         {
00255             elem_sizes_m[i-1]  = elem_sizes_m[i]  * b_m[i-1];
00256             elem_sizes_n[i-1]  = elem_sizes_n[i]  * b_n[i-1];
00257             depth_sizes_m[i-1] = depth_sizes_m[i] * b_m[i-1];
00258             depth_sizes_n[i-1] = depth_sizes_n[i] * b_n[i-1];
00259         }
00260     
00261         // Initialize the m_offsets and n_offsets arrays to zero.
00262         for ( i = 0; i < depth; i++ )
00263         {
00264             m_offsets[i] = 0;
00265             n_offsets[i] = 0;
00266         }
00267 
00268         // Create a "flat" matrix object. All leaf-level child objects will refer
00269         // to various offsets within this object's buffer.
00270         // Notice that the normal invocation requests a 1 x m*n flat matrix,
00271         // whereas the without_buffer line requests an m x n matrix. This is
00272         // simply how Tze originally implemented the corresponding cases.
00273         // There may be a subtle difference between these two methods--one
00274         // which I can't see at the time of this writing.
00275         if ( without_buffer == FALSE )
00276             FLA_Obj_create( datatype, 1, m*n, &flat_matrix );
00277         else
00278             FLA_Obj_create_without_buffer( datatype, m, n, &flat_matrix );
00279         
00280         // Recursively create the matrix hierarchy.
00281         FLASH_Obj_create_hierarchy( datatype, m, n, depth, elem_sizes_m, elem_sizes_n, flat_matrix, H, 0, depth, depth_sizes_m, depth_sizes_n, m_offsets, n_offsets );
00282         
00283         // Free the flat_matrix object, but not its buffer. If we created a
00284         // normal object with a buffer, we don't want to free the buffer because
00285         // it is being used by the hierarchical objected we just created. If we
00286         // created a bufferless object, we don't want to free the buffer because
00287         // there was no buffer allocated in the first place.
00288         FLA_Obj_free_without_buffer( &flat_matrix );
00289         
00290         // Free the local arrays.
00291         FLA_free( elem_sizes_m );
00292         FLA_free( elem_sizes_n );
00293         FLA_free( depth_sizes_m );
00294         FLA_free( depth_sizes_n );
00295         FLA_free( m_offsets );
00296         FLA_free( n_offsets );
00297     }
00298 
00299     return FLA_SUCCESS;
00300 }

FLA_Error FLASH_Obj_create_hier_conf_to_flat ( FLA_Trans  trans,
FLA_Obj  F,
dim_t  depth,
dim_t blocksizes,
FLA_Obj H 
)

References FLA_Check_error_level(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_width(), FLASH_Obj_create(), and FLASH_Obj_create_hier_conf_to_flat_check().

Referenced by FLASH_Obj_create_hier_copy_of_flat().

00489 {
00490     FLA_Datatype datatype;
00491     dim_t        m_H, n_H;
00492     dim_t        m_F, n_F;
00493 
00494     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00495         FLASH_Obj_create_hier_conf_to_flat_check( trans, F, depth, blocksizes, H );
00496 
00497     // Acquire the numerical datatype, length, and width of the flat matrix
00498     // object.
00499     datatype = FLA_Obj_datatype( F );
00500     m_F      = FLA_Obj_length( F );
00501     n_F      = FLA_Obj_width( F );
00502 
00503     // Factor in the transposition, if requested.
00504     if ( trans == FLA_NO_TRANSPOSE )
00505     {
00506         m_H = m_F;
00507         n_H = n_F;
00508     }
00509     else
00510     {
00511         m_H = n_F;
00512         n_H = m_F;
00513     }
00514 
00515     // Create the hierarchical matrix object.
00516     FLASH_Obj_create( datatype, m_H, n_H, depth, blocksizes, H );
00517 
00518     return FLA_SUCCESS;
00519 }

FLA_Error FLASH_Obj_create_hier_conf_to_flat_ext ( FLA_Trans  trans,
FLA_Obj  F,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)

References FLA_Check_error_level(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_width(), FLASH_Obj_create_ext(), and FLASH_Obj_create_hier_conf_to_flat_ext_check().

Referenced by FLASH_Obj_create_hier_copy_of_flat_ext().

00523 {
00524     FLA_Datatype datatype;
00525     dim_t        m_H, n_H;
00526     dim_t        m_F, n_F;
00527 
00528     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00529         FLASH_Obj_create_hier_conf_to_flat_ext_check( trans, F, depth, b_m, b_n, H );
00530 
00531     // Acquire the numerical datatype, length, and width of the flat matrix
00532     // object.
00533     datatype = FLA_Obj_datatype( F );
00534     m_F      = FLA_Obj_length( F );
00535     n_F      = FLA_Obj_width( F );
00536 
00537     // Factor in the transposition, if requested.
00538     if ( trans == FLA_NO_TRANSPOSE )
00539     {
00540         m_H = m_F;
00541         n_H = n_F;
00542     }
00543     else
00544     {
00545         m_H = n_F;
00546         n_H = m_F;
00547     }
00548 
00549     // Create the hierarchical matrix object.
00550     FLASH_Obj_create_ext( datatype, m_H, n_H, depth, b_m, b_n, H );
00551 
00552     return FLA_SUCCESS;
00553 }

FLA_Error FLASH_Obj_create_hier_copy_of_flat ( FLA_Obj  F,
dim_t  depth,
dim_t blocksizes,
FLA_Obj H 
)

References FLA_Check_error_level(), FLASH_Copy_subobject_to_global(), FLASH_Obj_create_hier_conf_to_flat(), and FLASH_Obj_create_hier_copy_of_flat_check().

Referenced by FLASH_LU_incpiv_create_hier_matrices(), and FLASH_QR_UT_inc_create_hier_matrices().

00591 {
00592     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00593         FLASH_Obj_create_hier_copy_of_flat_check( F, depth, blocksizes, H );
00594 
00595     // Create a hierarchical object conformal to the flat object.
00596     FLASH_Obj_create_hier_conf_to_flat( FLA_NO_TRANSPOSE, F, depth, blocksizes, H );
00597 
00598     // Initialize the contents of the hierarchical matrix object with the
00599     // contents of the flat matrix object.
00600     FLASH_Copy_subobject_to_global( F, 0, 0, *H );
00601     
00602     return FLA_SUCCESS;
00603 }

FLA_Error FLASH_Obj_create_hier_copy_of_flat_ext ( FLA_Obj  F,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)

References FLA_Check_error_level(), FLASH_Copy_subobject_to_global(), FLASH_Obj_create_hier_conf_to_flat_ext(), and FLASH_Obj_create_hier_copy_of_flat_ext_check().

00607 {
00608     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00609         FLASH_Obj_create_hier_copy_of_flat_ext_check( F, depth, b_m, b_n, H );
00610 
00611     // Create a hierarchical object conformal to the flat object.
00612     FLASH_Obj_create_hier_conf_to_flat_ext( FLA_NO_TRANSPOSE, F, depth, b_m, b_n, H );
00613 
00614     // Initialize the contents of the hierarchical matrix object with the
00615     // contents of the flat matrix object.
00616     FLASH_Copy_subobject_to_global( F, 0, 0, *H );
00617     
00618     return FLA_SUCCESS;
00619 }

FLA_Error FLASH_Obj_create_hierarchy ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t elem_sizes_m,
dim_t elem_sizes_n,
FLA_Obj  flat_matrix,
FLA_Obj H,
unsigned long  id,
dim_t  depth_overall,
dim_t depth_sizes_m,
dim_t depth_sizes_n,
dim_t m_offsets,
dim_t n_offsets 
)

References FLA_Obj_view::base, FLA_Check_error_level(), FLA_Cont_with_1x3_to_1x2(), FLA_Obj_attach_buffer(), FLA_Obj_buffer(), FLA_Obj_create_ext(), FLA_Obj_create_without_buffer(), FLA_Obj_datatype_size(), FLA_Obj_free_without_buffer(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Repart_1x2_to_1x3(), FLASH_Obj_create_hierarchy(), FLASH_Obj_create_hierarchy_check(), FLASH_Queue_set_block_size(), FLA_Obj_struct::id, FLA_Obj_struct::m_index, and FLA_Obj_struct::n_index.

Referenced by FLASH_Obj_create_helper(), and FLASH_Obj_create_hierarchy().

00304 {
00305     dim_t    i, j, b;
00306     dim_t    next_m, next_n;
00307     dim_t    num_m, num_n;
00308     dim_t    m_inner, n_inner;
00309     dim_t    elem_size_m_cur;
00310     dim_t    elem_size_n_cur;
00311     FLA_Obj  FL, FR, F0, F1, F2;
00312     FLA_Obj* buffer_H;
00313 
00314     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00315         FLASH_Obj_create_hierarchy_check( datatype, m, n, depth, elem_sizes_m, elem_sizes_n, flat_matrix, H, id, depth_overall, depth_sizes_m, depth_sizes_n, m_offsets, n_offsets );
00316 
00317     if ( depth == 0 )
00318     {
00319         // If we're asked to create a zero-depth matrix, we interpret that as
00320         // a request to create leaf-level objects using the remaining portion
00321         // of the segment of the flat_matrix buffer that was passed in.
00322         FLA_Obj_create_without_buffer( datatype, m, n, H );
00323         FLA_Obj_attach_buffer( FLA_Obj_buffer( flat_matrix ), m, H );
00324 #ifdef FLA_ENABLE_SUPERMATRIX
00325         FLASH_Queue_set_block_size( m * n * FLA_Obj_datatype_size( datatype ) );
00326 #endif
00327         H->base->id = id;
00328 
00329         // Fill in the m_index and n_index variables, which identify the
00330         // location of the current leaf node, in units of storage blocks,
00331         // within the overall matrix.
00332         for ( i = 0; i < depth_overall; i++ )
00333         {
00334             H->base->m_index += m_offsets[i] * depth_sizes_m[i];
00335             H->base->n_index += n_offsets[i] * depth_sizes_n[i];
00336         }
00337     }
00338     else
00339     {
00340         // The "current" level's elem_size value. That is, the number of numerical
00341         // scalar elements along one side of a full block on the current level,
00342         // for the row and column dimensions.
00343         elem_size_m_cur = elem_sizes_m[0];
00344         elem_size_n_cur = elem_sizes_n[0];
00345 
00346         // Compute the number of rows and columns in the current hierarchical
00347         // level of blocking.
00348         num_m = m / elem_size_m_cur + ( (m % elem_size_m_cur) ? 1 : 0 );
00349         num_n = n / elem_size_n_cur + ( (n % elem_size_n_cur) ? 1 : 0 );
00350 
00351         // The total number of scalar elements contained within/below this level
00352         // of the hierarchy. (The edge cases are handled by the computation of
00353         // next_m and next_n below, since they are passed in as the new m and n
00354         // for the next recursive call.)
00355         m_inner = m;
00356         n_inner = n;
00357         
00358         // Create a matrix whose elements are FLA_Objs for the current level of
00359         // blocking.
00360         FLA_Obj_create_ext( datatype, FLA_MATRIX, num_m, num_n, m_inner, n_inner, H );
00361 
00362         if ( depth == depth_overall )
00363             id = H->base->id;
00364         else
00365             H->base->id = id;
00366 
00367         // Grab the buffer from the new hierarchical object. This is an array of
00368         // FLA_Objs.
00369         buffer_H = ( FLA_Obj* ) FLA_Obj_buffer( *H );
00370         
00371         // Prepare to partition through the flat matrix so we can further allocate
00372         // segments of it to the various hierarchical sub-matrices. (The second
00373         // case occurs when the current function is called with a flat_matrix
00374         // argument that was created without a buffer.)
00375         if ( FLA_Obj_buffer( flat_matrix ) != NULL )
00376             FLA_Part_1x2( flat_matrix, &FL, &FR, 0, FLA_LEFT );
00377         else
00378             FLA_Obj_create_without_buffer( datatype, 0, 0, &F1 );
00379         
00380         for ( j = 0; j < num_n; ++j )
00381         {
00382             // Determine the number of elements along the column dimension
00383             // that will be contained within the submatrix referenced by
00384             // the (i,j)th FLA_MATRIX element in the current matrix.
00385             if ( j != num_n-1 || (n % elem_size_n_cur) == 0 )
00386                 next_n = elem_size_n_cur;
00387             else
00388                 next_n = n % elem_size_n_cur;
00389             
00390             n_offsets[depth_overall-depth] = j;
00391                         
00392             for ( i = 0; i < num_m; ++i )
00393             {           
00394                 // Determine the number of elements along the row dimension
00395                 // that will be contained within the submatrix referenced by
00396                 // the (i,j)th FLA_MATRIX element in the current matrix.
00397                 if ( i != num_m-1 || (m % elem_size_m_cur) == 0 )
00398                     next_m = elem_size_m_cur;
00399                 else
00400                     next_m = m % elem_size_m_cur;
00401 
00402                 m_offsets[depth_overall-depth] = i;
00403                 
00404                 // Partition the next m*n elements from the flat matrix so we can
00405                 // "attach" them to the hierarchical matrices contained within the
00406                 // (i,j)th FLA_MATRIX object.
00407                 if ( FLA_Obj_buffer( flat_matrix ) != NULL )
00408                 {
00409                     b = min( FLA_Obj_width( FR ), next_m * next_n );
00410                     FLA_Repart_1x2_to_1x3( FL,  /**/ FR,        &F0, /**/ &F1, &F2,
00411                                            b, FLA_RIGHT );
00412                 }
00413                 
00414                 // Recursively call ourselves, with the appropriate parameters for
00415                 // the next deeper level in the matrix hierarchy.
00416                 FLASH_Obj_create_hierarchy( datatype, next_m, next_n, depth-1, &elem_sizes_m[1], &elem_sizes_n[1], F1, &buffer_H[j*num_m + i], id, depth_overall, depth_sizes_m, depth_sizes_n, m_offsets, n_offsets );
00417 
00418                 // Continue with the repartitioning.
00419                 if ( FLA_Obj_buffer( flat_matrix ) != NULL )
00420                 {
00421                     FLA_Cont_with_1x3_to_1x2( &FL,  /**/ &FR,        F0, F1, /**/ F2,
00422                                               FLA_LEFT );
00423                 }
00424             }
00425         }
00426 
00427         // Free the temporary flat matrix subpartition object, but only if it was
00428         // created to begin with. Since it would have been created without a
00429         // buffer, we must free it in a similar manner.
00430         if ( FLA_Obj_buffer( flat_matrix ) == NULL )
00431             FLA_Obj_free_without_buffer( &F1 );
00432     }
00433     
00434     return FLA_SUCCESS;
00435 }

FLA_Error FLASH_Obj_create_without_buffer ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t blocksizes,
FLA_Obj H 
)

References FLASH_Obj_create_helper().

00194 {
00195     FLASH_Obj_create_helper( TRUE, datatype, m, n, depth, blocksizes, blocksizes, H );
00196 
00197     return FLA_SUCCESS;
00198 }

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 
)

References FLASH_Obj_create_helper().

00202 {
00203     FLASH_Obj_create_helper( TRUE, datatype, m, n, depth, b_m, b_n, H );
00204 
00205     return FLA_SUCCESS;
00206 }

FLA_Datatype FLASH_Obj_datatype ( FLA_Obj  H  ) 

dim_t FLASH_Obj_depth ( FLA_Obj  H  ) 

References FLA_Obj_buffer(), and FLA_Obj_elemtype().

Referenced by FLASH_Apply_Q_UT_inc_create_workspace(), FLASH_FS_incpiv(), FLASH_LU_incpiv(), and FLASH_Obj_create_conf_to().

00043 {
00044     FLA_Elemtype elemtype;
00045     FLA_Obj*     buffer_H;
00046     dim_t        depth = 0;
00047 
00048     // Recurse through the hierarchy to the first leaf node. We initialize
00049     // the recursion here:
00050     elemtype = FLA_Obj_elemtype( H );
00051     buffer_H  = ( FLA_Obj* ) FLA_Obj_buffer( H );
00052 
00053     while ( elemtype == FLA_MATRIX )
00054     {
00055         ++depth;
00056 
00057         // Get the element type of the top-leftmost underlying object. Also,
00058         // get a pointer to the first element of the top-leftmost object and
00059         // assume that it is of type FLA_Obj* in case elemtype is once again
00060         // FLA_MATRIX.
00061         elemtype = FLA_Obj_elemtype( buffer_H[0] );
00062         buffer_H = ( FLA_Obj * ) FLA_Obj_buffer( buffer_H[0] );
00063     }
00064 
00065     // At this point, the value of depth represents the depth of the matrix
00066     // hierarchy.
00067     return depth;
00068 }

void* FLASH_Obj_extract_buffer ( FLA_Obj  H  ) 

References FLA_Obj_buffer(), and FLA_Obj_elemtype().

Referenced by FLASH_Obj_free().

00745 {
00746     FLA_Elemtype elemtype;
00747     FLA_Obj*     buffer_H;
00748 
00749     // Recurse through the hierarchy to the first leaf node to gain access
00750     // to the address of the actual numerical data buffer (ie: the "flat"
00751     // matrix object used in FLASH_Obj_create()). We initialize the search
00752     // here:
00753     elemtype = FLA_Obj_elemtype( H );
00754     buffer_H  = ( FLA_Obj* ) FLA_Obj_buffer( H );
00755 
00756     while ( elemtype == FLA_MATRIX )
00757     {
00758         elemtype = FLA_Obj_elemtype( buffer_H[0] );
00759         buffer_H  = ( FLA_Obj * ) FLA_Obj_buffer( buffer_H[0] );
00760     }
00761 
00762     // At this point, the value in buffer_H is a pointer to the array that
00763     // holds the numerical data.
00764     return ( void* ) buffer_H;
00765 }

FLA_Error FLASH_Obj_flatten ( FLA_Obj  H,
FLA_Obj  F 
)

References FLASH_Copy_global_to_subobject().

00769 {
00770     FLASH_Copy_global_to_subobject( 0, 0, H, F );
00771 
00772     return FLA_SUCCESS;
00773 }

void FLASH_Obj_free ( FLA_Obj H  ) 

References FLA_Check_error_level(), FLA_free(), FLA_Obj_elemtype(), FLA_Obj_free(), FLASH_Obj_extract_buffer(), FLASH_Obj_free_check(), and FLASH_Obj_free_hierarchy().

Referenced by FLA_QR_UT_inc_free_U_panel(), and FLASH_Random_spd_matrix().

00638 {
00639     FLA_Obj* buffer_H;
00640 
00641     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00642         FLASH_Obj_free_check( H );
00643 
00644     // Free the object accordin got whether it contains a hierarchy.
00645     if ( FLA_Obj_elemtype( *H ) == FLA_MATRIX )
00646     {
00647         // Extract a pointer to the data buffer that was parititioned across all
00648         // leaf-level submatrices.
00649         buffer_H = ( FLA_Obj * ) FLASH_Obj_extract_buffer( *H );
00650     
00651         // Free the data buffer. This works because FLASH_Obj_extract_buffer()
00652         // returns the starting address of the first element's buffer, which is
00653         // also the starting address of the entire buffer.
00654         FLA_free( buffer_H );
00655     
00656         // All that remains now is to free the interior of the matrix hierarchy.
00657         // This includes non-leaf buffers and their corresponding base objects
00658         // as well as leaf-level base objects.
00659         FLASH_Obj_free_hierarchy( H );
00660 
00661         // Finally, free the top-level FLASH object itself.
00662         FLA_Obj_free( H );
00663     }
00664     else
00665     {
00666         // If the matrix has no hierarchy, treat it like a flat object.
00667         FLA_Obj_free( H );
00668     }
00669 }

void FLASH_Obj_free_hierarchy ( FLA_Obj H  ) 

References FLA_Check_error_level(), FLA_Obj_buffer(), FLA_Obj_elemtype(), FLA_Obj_free_without_buffer(), FLA_Obj_length(), FLA_Obj_width(), FLASH_Obj_free_hierarchy(), and FLASH_Obj_free_hierarchy_check().

Referenced by FLASH_Obj_free(), FLASH_Obj_free_hierarchy(), and FLASH_Obj_free_without_buffer().

00701 {
00702     dim_t    i,j, m_H, n_H;
00703     FLA_Obj* buffer_H;
00704     FLA_Obj* obj_ij_ptr;
00705 
00706     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00707         FLASH_Obj_free_hierarchy_check( H );
00708 
00709     m_H = FLA_Obj_length( *H );
00710     n_H = FLA_Obj_width( *H );
00711 
00712     // If the element type of H is FLA_SCALAR, then it has no children to free,
00713     // so we can return. (The base object of H will be freed by the caller,
00714     // whether that is a recursive instance of the current function,
00715     // FLASH_Obj_free_hierarchy(), or FLASH_Obj_free() or
00716     // FLASH_Obj_free_without_buffer()).
00717     if ( FLA_Obj_elemtype( *H ) == FLA_SCALAR ) return;
00718 
00719     // Since we didn't return, we know that H is of type FLA_MATRIX. Here, we
00720     // acquire the array of objects contained inside of H.
00721     buffer_H = ( FLA_Obj* ) FLA_Obj_buffer( *H );
00722 
00723     // For each submatrix in H...
00724     for ( j = 0; j < n_H; ++j )
00725     {
00726         for ( i = 0; i < m_H; ++i )
00727         {
00728             obj_ij_ptr = &buffer_H[ j*m_H + i ];
00729 
00730             // Recurse. The object at element (i,j) may also be of element type
00731             // FLA_MATRIX. If so, we will need to free its children.
00732             FLASH_Obj_free_hierarchy( obj_ij_ptr );
00733 
00734             // Free the base object at element (i,j). In order to avoid freeing
00735             // the object's data buffer, which would have already been freed en
00736             // masse by now if the calling function is FLASH_Obj_free(), we
00737             // will call FLA_Obj_free_without_buffer().
00738             FLA_Obj_free_without_buffer( obj_ij_ptr );
00739         }
00740     }
00741 }

void FLASH_Obj_free_without_buffer ( FLA_Obj H  ) 

References FLA_Check_error_level(), FLA_Obj_elemtype(), FLA_Obj_free(), FLA_Obj_free_without_buffer(), FLASH_Obj_free_hierarchy(), and FLASH_Obj_free_without_buffer_check().

00673 {
00674     if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
00675         FLASH_Obj_free_without_buffer_check( H );
00676 
00677     // Free the object according to whether it contains a hierarchy.
00678     if ( FLA_Obj_elemtype( *H ) == FLA_MATRIX )
00679     {
00680         // Skip freeing the numerical data buffer, since the object was
00681         // presumably created with FLASH_Obj_create_without_buffer().
00682 
00683         // Free the interior of the matrix hierarchy. This includes non-leaf
00684         // buffers and their corresponding base objects as well as leaf-level
00685         // base objects.
00686         FLASH_Obj_free_hierarchy( H );
00687 
00688         // Finally, free the top-level FLASH object itself.
00689         FLA_Obj_free( H );
00690     }
00691     else
00692     {
00693         // If the matrix has no hierarchy, treat it like a flat object with
00694         // no internal data buffer.
00695         FLA_Obj_free_without_buffer( H );
00696     }
00697 }

FLA_Error FLASH_Obj_hierarchify ( FLA_Obj  F,
FLA_Obj  H 
)

dim_t FLASH_Obj_scalar_length ( FLA_Obj  H  ) 

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

Referenced by FLA_Check_submatrix_dims_and_offset(), FLA_QR_UT_inc_create_U_panel(), FLASH_Apply_Q_UT(), FLASH_Apply_Q_UT_inc(), FLASH_Apply_Q_UT_inc_create_workspace(), FLASH_Apply_Q_UT_UD(), FLASH_Axpy_hierarchy_r(), FLASH_Copy_hierarchy_r(), FLASH_Obj_attach_buffer(), FLASH_Obj_attach_buffer_hierarchy(), FLASH_Obj_create_conf_to(), FLASH_Obj_create_flat_conf_to_hier(), FLASH_QR_UT_inc_noopt(), FLASH_QR_UT_inc_opt1(), and FLASH_QR_UT_UD().

00107 {
00108     FLA_Obj  HT,              H0,
00109              HB,              H1,
00110                               H2;
00111     FLA_Obj* H1p;
00112 
00113     dim_t b = 0;
00114 
00115     if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
00116         return FLA_Obj_length( H );
00117 
00118     FLA_Part_2x1( H,    &HT,
00119                         &HB,            0, FLA_TOP );
00120 
00121     while ( FLA_Obj_length( HT ) < FLA_Obj_length( H ) )
00122     {
00123         FLA_Repart_2x1_to_3x1( HT,                &H0,
00124                             /* ** */            /* ** */
00125                                                   &H1,
00126                                HB,                &H2,        1, FLA_BOTTOM );
00127 
00128         /*------------------------------------------------------------*/
00129 
00130         H1p = FLASH_OBJ_PTR_AT( H1 );
00131         b += H1p->base->m_inner;
00132 
00133         /*------------------------------------------------------------*/
00134 
00135         FLA_Cont_with_3x1_to_2x1( &HT,                H0,
00136                                                       H1,
00137                                 /* ** */           /* ** */
00138                                   &HB,                H2,     FLA_TOP );
00139   }
00140 
00141   return b;
00142 }

dim_t FLASH_Obj_scalar_width ( FLA_Obj  H  ) 

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

Referenced by FLA_Check_submatrix_dims_and_offset(), FLASH_Apply_Q_UT_inc_create_workspace(), FLASH_Axpy_hierarchy_r(), FLASH_Copy_hierarchy_r(), FLASH_FS_incpiv(), FLASH_LU_incpiv(), FLASH_Obj_attach_buffer(), FLASH_Obj_attach_buffer_hierarchy(), FLASH_Obj_create_conf_to(), and FLASH_Obj_create_flat_conf_to_hier().

00146 {
00147     FLA_Obj  HL,    HR,       H0,  H1,  H2;
00148     FLA_Obj* H1p;
00149 
00150     dim_t b = 0;
00151 
00152     if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
00153         return FLA_Obj_width( H );
00154 
00155     FLA_Part_1x2( H,    &HL,  &HR,      0, FLA_LEFT );
00156 
00157     while ( FLA_Obj_width( HL ) < FLA_Obj_width( H ) )
00158     {
00159         FLA_Repart_1x2_to_1x3( HL,  /**/ HR,        &H0, /**/ &H1, &H2,
00160                                1, FLA_RIGHT );
00161 
00162         /*------------------------------------------------------------*/
00163 
00164         H1p = FLASH_OBJ_PTR_AT( H1 );
00165         b += H1p->base->n_inner;
00166 
00167         /*------------------------------------------------------------*/
00168 
00169         FLA_Cont_with_1x3_to_1x2( &HL,  /**/ &HR,        H0, H1, /**/ H2,
00170                                   FLA_LEFT );
00171     }
00172 
00173     return b;
00174 }

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

References FLA_Obj_elemtype(), FLA_Obj_free(), FLA_Obj_show(), and FLASH_Obj_create_flat_copy_of_hier().

00785 {
00786     FLA_Obj F;
00787     
00788     // Show the object according to whether it contains a hierarchy.
00789     if ( FLA_Obj_elemtype( H ) == FLA_MATRIX )
00790     {
00791         // Create a temporary flat object conformal to and copied from the
00792         // hierarchical object.
00793         FLASH_Obj_create_flat_copy_of_hier( H, &F );
00794     
00795         // We can now display the temporary matrix in a straightforward manner.
00796         FLA_Obj_show( header, F, elem_format, footer );
00797     
00798         // Free the temporary flat matrix.
00799         FLA_Obj_free( &F );
00800     }
00801     else
00802     {
00803         // Display the flat matrix.
00804         FLA_Obj_show( header, H, elem_format, footer );
00805     }
00806 
00807     return FLA_SUCCESS;
00808 }

void FLASH_print_struct ( FLA_Obj  H  ) 

References FLA_Obj_buffer(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Obj_width(), and FLASH_print_struct_helper().

00948 {
00949     dim_t    i, j, m_H, n_H;
00950     FLA_Obj* buffer_temp;
00951 
00952     m_H = FLA_Obj_length( H );
00953     n_H = FLA_Obj_width( H );
00954 
00955     if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
00956         FLASH_print_struct_helper( H, 0 );
00957     else
00958     {
00959         for ( j = 0; j < n_H; ++j )
00960         {
00961             for ( i = 0; i < m_H; ++i )
00962             {
00963                 buffer_temp = ( FLA_Obj* ) FLA_Obj_buffer( H );
00964 
00965                 FLASH_print_struct_helper( buffer_temp[ j*m_H + i ], 0 );
00966             }
00967         }
00968     }
00969 }

void FLASH_print_struct_helper ( FLA_Obj  H,
int  indent 
)

References FLA_Obj_buffer(), FLA_Obj_datatype(), FLA_Obj_elemtype(), FLA_Obj_ldim(), FLA_Obj_length(), FLA_Obj_width(), and FLASH_print_struct_helper().

Referenced by FLASH_print_struct(), and FLASH_print_struct_helper().

00973 {
00974     dim_t    i, j, k, m_H, n_H;
00975     FLA_Obj* buffer_temp;
00976 
00977     for ( i = 0; i < indent; ++i )
00978         fprintf( stdout, "  " );
00979 
00980     if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
00981     {
00982         fprintf( stdout, "LEAF (%3d | ldim %3d | %3d x %3d | addr %p)\n",
00983                          FLA_Obj_datatype( H ), FLA_Obj_ldim( H ),
00984                          FLA_Obj_length( H ), FLA_Obj_width( H ),
00985                          FLA_Obj_buffer( H ) );
00986         fflush( stdout );
00987     }
00988     else
00989     {
00990         m_H = FLA_Obj_length( H );
00991         n_H = FLA_Obj_width( H );
00992         
00993         fprintf( stdout, "MATRIX (%dx%d):%d - %p\n",
00994                          m_H, n_H,
00995                          FLA_Obj_datatype( H ),
00996                          FLA_Obj_buffer( H ) );
00997         fflush( stdout );
00998         
00999         for ( j = 0; j < n_H; ++j )
01000         {
01001             for ( i = 0; i < m_H; ++i )
01002             {
01003                 for ( k = 0; k < indent; ++k )
01004                     fprintf( stdout, "  " );
01005                 
01006                 buffer_temp = ( FLA_Obj* ) FLA_Obj_buffer( H );
01007 
01008                 FLASH_print_struct_helper( buffer_temp[ j*m_H + i ],
01009                                            indent + 1);
01010             }
01011         }
01012     }
01013 }


Generated on Mon Jul 6 05:45:51 2009 for libflame by  doxygen 1.5.9