Home > atmlab > gformat > gf_empty.m

gf_empty

PURPOSE ^

GF_EMPTY Creates an empty and minimal gformat structure

SYNOPSIS ^

function G = gf_empty( dim )

DESCRIPTION ^

 GF_EMPTY   Creates an empty and minimal gformat structure

    The returned structure has the minimal set of fields for the selected
    dimensionality. All fields are set to be empty, except DIM that is set to
    *dim* and TYPE that is set to 'basic'.

 FORMAT   G = gf_empty( [ dim ] )
        
 OUT   G     Created gformat structure.
 OPT   dim   Dimensionality. Default is 0.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

gf_empty.m

SOURCE CODE ^

0001 % GF_EMPTY   Creates an empty and minimal gformat structure
0002 %
0003 %    The returned structure has the minimal set of fields for the selected
0004 %    dimensionality. All fields are set to be empty, except DIM that is set to
0005 %    *dim* and TYPE that is set to 'basic'.
0006 %
0007 % FORMAT   G = gf_empty( [ dim ] )
0008 %
0009 % OUT   G     Created gformat structure.
0010 % OPT   dim   Dimensionality. Default is 0.
0011 
0012 % 2010-01-06   Created by Patrick Eriksson.
0013 
0014 function G = gf_empty( dim )
0015 %
0016 if nargin < 1  ||  isempty(dim)
0017   dim = 0;
0018 end
0019 
0020 if atmlab('STRICT_ASSERT')
0021   errid=['atmlab:' mfilename, ':badInput'];
0022   
0023   %rqre_alltypes( dim, {@istensor0,@iswhole} );                    %&%
0024   %rqre_in_range( dim, 0 );                                        %&%
0025   
0026   % the following assertion is 1000x faster than the above checks
0027   assert( isnumeric(dim) && isscalar(dim) && all( dim - round(dim) == 0 ) && ...
0028         dim>=0, errid, '*dim* did not pass the test: @istensor0 && @iswhole')
0029 end
0030 
0031 G.TYPE      = 'basic';
0032 G.NAME      = [];
0033 G.SOURCE    = [];
0034 G.DIM       = dim;
0035 G.DATA      = [];
0036 G.DATA_NAME = [];
0037 G.DATA_UNIT = [];
0038 
0039 for i = 1 : dim
0040   G = gf_set_grid( G, i, [], [], [] );
0041 end
0042 
0043

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005