This is a static copy of a profile report

Home

ff_saveborr_grid (Calls: 1, Time: 0.007 s)
Generated 16-Jul-2020 17:08:31 using performance time.
function in file /Users/sidhantkhanna/Documents/GitHub/BKS modified/ProfFanCode/generate/ff_saveborr_grid.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
hhsave_VFI_3OCfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
51
[fl_a_min, fl_a_max, it_a_poin...
10.001 s9.3%
124
for i=2:(it_a_points)
10.001 s7.8%
126
end
990.000 s7.1%
177
end
10.000 s6.7%
95
[grid_log10space_x1, grid_log1...
10.000 s6.5%
All other lines  0.004 s62.5%
Totals  0.007 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function138
Non-code lines (comments, blank lines)64
Code lines (lines that can run)74
Code lines that did run39
Code lines that did not run35
Coverage (did run/can run)52.70 %
Function listing
time 
Calls 
 line
  41 
function varargout = ff_saveborr_grid(varargin)
  42 

< 0.001 
      1 
  43
if (~isempty(varargin)) 
  44 
    
< 0.001 
      1 
  45
    st_grid_type = 'grid_linspace'; 
< 0.001 
      1 
  46
    bl_verbose = false; 
  47 
    
< 0.001 
      1 
  48
    if (length(varargin) == 3) 
  49 
        [fl_a_min, fl_a_max, it_a_points] = varargin{:};
< 0.001 
      1 
  50
    elseif (length(varargin) == 4) 
< 0.001 
      1 
  51
        [fl_a_min, fl_a_max, it_a_points, st_grid_type] = varargin{:}; 
  52 
    elseif (length(varargin) == 5)
  53 
        [fl_a_min, fl_a_max, it_a_points, ...
  54 
            st_grid_type, mp_grid_control_ext] = varargin{:};
  55 
    else
  56 
        error('Must specify three parameters.');
< 0.001 
      1 
  57
    end 
  58 

  59 
else
  60 

  61 
    fl_a_min = 0;
  62 
    fl_a_max = 50;
  63 
    it_a_points = 25;
  64 
    bl_verbose = true;
  65 
    
  66 
%     st_grid_type = 'grid_linspace';
  67 
    st_grid_type = 'grid_log10space';
  68 
%     st_grid_type = 'grid_powerspace';
  69 
%     st_grid_type = 'grid_evenlog';
  70 
    
< 0.001 
      1 
  71
end 
  72 

  73 
%% Set and Update Support Map
< 0.001 
      1 
  74
mp_grid_control = containers.Map('KeyType','char', 'ValueType','any'); 
  75 

  76 
% Options for st_grid_type == grid_linspace
  77 

  78 
% Options for st_grid_type == grid_log10space
< 0.001 
      1 
  79
mp_grid_control('grid_log10space_x1') = 0.3; 
< 0.001 
      1 
  80
mp_grid_control('grid_log10space_x2') = 3; 
  81 

  82 
% Options for st_grid_type == grid_powerspace
< 0.001 
      1 
  83
mp_grid_control('grid_powerspace_power') = 3; 
  84 

  85 
% Options for st_grid_type == grid_evenlog
< 0.001 
      1 
  86
mp_grid_control('grid_evenlog_threshold') = 1; 
  87 

  88 
% override default support_map values
< 0.001 
      1 
  89
if (length(varargin)==5) 
  90 
    mp_grid_control = [mp_grid_control; mp_grid_control_ext];
< 0.001 
      1 
  91
end 
  92 

  93 
%% Parse mp_grid_control
< 0.001 
      1 
  94
params_group = values(mp_grid_control, {'grid_log10space_x1', 'grid_log10space_x2'}); 
< 0.001 
      1 
  95
[grid_log10space_x1, grid_log10space_x2] = params_group{:}; 
< 0.001 
      1 
  96
params_group = values(mp_grid_control, {'grid_powerspace_power'}); 
< 0.001 
      1 
  97
[grid_powerspace_power] = params_group{:}; 
< 0.001 
      1 
  98
params_group = values(mp_grid_control, {'grid_evenlog_threshold'}); 
< 0.001 
      1 
  99
[grid_evenlog_threshold] = params_group{:}; 
 100 

 101 
%% Grid Generations
< 0.001 
      1 
 102
if (strcmp(st_grid_type, 'grid_linspace')) 
 103 
    %% st_grid_type == grid_linspace
 104 
    
 105 
    ar_fl_saveborr = linspace(fl_a_min, fl_a_max, (it_a_points))';
 106 
    
< 0.001 
      1 
 107
elseif (strcmp(st_grid_type, 'grid_log10space')) 
 108 
    %% st_grid_type == grid_log10space
 109 
    
 110 
    % generate logspace
 111 
    ar_fl_logspace = logspace(grid_log10space_x1, grid_log10space_x2, it_a_points)';
 112 
    
 113 
    % use logspace as ratio
 114 
    ar_fl_saveborr_ratio = (ar_fl_logspace -min(ar_fl_logspace))./(max(ar_fl_logspace) - min(ar_fl_logspace));
 115 
    
 116 
    % use ratio with min and max
 117 
    ar_fl_saveborr = ar_fl_saveborr_ratio.*(fl_a_max-fl_a_min) + fl_a_min;
 118 
    
< 0.001 
      1 
 119
elseif (strcmp(st_grid_type, 'grid_powerspace')) 
 120 
    %% st_grid_type == grid_powerspace
 121 
    
< 0.001 
      1 
 122
    ar_fl_saveborr=zeros(it_a_points, 1); 
 123 

< 0.001 
      1 
 124
    for i=2:(it_a_points) 
< 0.001 
     99 
 125
        ar_fl_saveborr(i)=fl_a_max*((i-1)/(it_a_points-1))^grid_powerspace_power; 
< 0.001 
     99 
 126
    end 
 127 
                
 128 
elseif (strcmp(st_grid_type, 'grid_evenlog'))
 129 
    %% st_grid_type == grid_evenlog
 130 

 131 
    it_a_vec_n_log_cur = it_a_points;
 132 
    it_a_vec_n_actual = it_a_points + 99999999;
 133 

 134 
    while (it_a_vec_n_actual >= it_a_points+1)
 135 
        
 136 
        % After Threshold log space
 137 
        avec_log = logspace(...
 138 
            log10(grid_evenlog_threshold),...
 139 
            log10(fl_a_max), ...
 140 
            it_a_vec_n_log_cur);
 141 
        log_space_min_gap = avec_log(2) - avec_log(1);
 142 
        
 143 
        % Before Threshold equi-distance
 144 
        avec_lin = fl_a_min:log_space_min_gap:grid_evenlog_threshold;
 145 
        
 146 
        % combine
 147 
        ar_fl_saveborr = unique([avec_lin';avec_log']);
 148 
        
 149 
        % length check
 150 
        it_a_vec_n_actual = length(ar_fl_saveborr);
 151 
        it_a_vec_n_log_cur = it_a_vec_n_log_cur - 1;
 152 
    end
 153 
    
< 0.001 
      1 
 154
end 
 155 

 156 
%% print details
< 0.001 
      1 
 157
if (bl_verbose) 
 158 

 159 
    % gather all info
 160 
    mp_container_map = containers.Map('KeyType','char', 'ValueType','any');
 161 
    mp_container_map('ar_fl_saveborr') = ar_fl_saveborr;
 162 
    mp_container_map = [mp_container_map; mp_grid_control];
 163 
    
 164 
    % print
 165 
    ff_container_map_display(mp_container_map, 50, 50);
 166 

< 0.001 
      1 
 167
end 
 168 

 169 

 170 
%% Return
< 0.001 
      1 
 171
varargout = cell(nargout,0); 
< 0.001 
      1 
 172
for it_k = 1:nargout 
< 0.001 
      1 
 173
    if (it_k==1) 
< 0.001 
      1 
 174
        ob_out_cur = ar_fl_saveborr; 
< 0.001 
      1 
 175
    end 
< 0.001 
      1 
 176
    varargout{it_k} = ob_out_cur; 
< 0.001 
      1 
 177
end 
< 0.001 
      1 
 178
end 

Other subfunctions in this file are not included in this listing.