Skip to content

Commit

Permalink
Merge pull request #13 from OSU-LRAM/Ross
Browse files Browse the repository at this point in the history
Ross
  • Loading branch information
rlhatton authored Nov 22, 2016
2 parents 7f35137 + a8f69b6 commit 9fe1c5c
Show file tree
Hide file tree
Showing 326 changed files with 5,246 additions and 789 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions ProgramFiles/Utilities/celltensorconvert.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function B = celltensorconvert(A)
% Takes an NxMx... cell array of YxZx... arrays, and returns an YxZx... cell array of
% NxMx.. arrays


% Create a cell containing a matrix whose dimensions are taken from A
new_cell = {zeros(size(A))};

% Replicate this cell to make a cell array whose dimensions are taken from
% the contents of (the first value of) A
B = repmat(new_cell,size(A{1}));

for i = 1:numel(A)

for j = 1:numel(B)

B{j}(i) = A{i}(j);

end

end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function B = fatbackbone_from_curvature_bases(kappa_basis_input,r,L,width)

[h, J] = backbone_from_curvature_bases(kappa_basis_input,r,L);
[h] = backbone_from_curvature_bases(kappa_basis_input,r,L);


B = fatbackbone(h,L*[-.5 .5],width);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function B = fatbackbone_from_general_curvature(curvdef,cparams,L,width)

[h, J] = backbone_from_general_curvature(curvdef,cparams,L);
[h] = backbone_from_general_curvature(curvdef,cparams,L);


B = fatbackbone(h,L*[-.5 .5],width);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
function make_curvdef(curv_fun_string,paramlist,name,attempt_analytic)
function make_curvdef(curv_fun_string,paramlist,name,attempt_analytic,sysplotterpath,syspath)
% curv_fun_string can be either a string expression or a symbolic
% expression

% Load the paths where files should be found
load sysplotter_config
if ~exist('sysplotterpath','var') || ~exist('syspath','var')

load sysplotter_config

end

% Initialize a cell structure to hold the list of functions to operate on
flist = {};

% Symbolically calculate all of the requested functions unless told
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
function triangle_wave_matched = triangle_wave_generator

% Generate a scale factor so that the maximum angle reached by the sin and
% pinched sin basis functions is the same
n = logspace(-1,1.5,100);

x = linspace(0,pi/2);

base_area = trapz(x,cos(x));

for idx = 1:numel(n)

scale_factor(idx) = base_area/trapz(x,cos(x).^n(idx)); %#ok<AGROW>

end

P = polyfit(n,scale_factor,3);



% Now generate the pinched sin function

n=10;

syms a1 a2 omega s

% Wave with sin and cosine amplitudes
raw_wave = (a1*cos(omega*2*pi*s)+a2*sin(omega*2*pi*s));

% Amplitude of the wave
amp_wave = (a1^2+a2^2)^(.5);

% Normalize the wave
norm_wave = raw_wave/amp_wave;

% Pinch the wave
pinched_wave = (abs(norm_wave)^n) * sign(norm_wave);

% Restore the scale of the wave
pinched_wave_restored = pinched_wave*amp_wave;

% Scale to match max angle with original wave
triangle_wave_matched = pinched_wave_restored * (P*[n^3;n^2;n;1]);




end
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function output = AA_SHCHFILENAME(input_mode)
function output = AA_SHCHFILENAME(input_mode,pathnames)

% Default argument
if ~exist('input_mode','var')
Expand All @@ -19,7 +19,7 @@ function output = AA_SHCHFILENAME(input_mode)

case 'dependency'

output.dependency = {fullfile(pwd,[paramfile '.mat'])};
output.dependency = {fullfile(pathnames.shchpath,[paramfile '.mat'])};

case 'initialize'

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
100 changes: 100 additions & 0 deletions ProgramFiles/Utilities/mat2tiles.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
function outCell=mat2tiles(inArray,varargin)
%MAT2TILES - breaks up an array into a cell array of adjacent sub-arrays of
% equal sizes
%
% C=mat2tiles(X,D1,D2,D3,...,Dn)
% C=mat2tiles(X,[D1,D2,D3,...,Dn])
%
%will produce a cell array C containing adjacent chunks of the array X,
%with each chunk of dimensions D1xD2xD3x...xDn. If a dimensions Di does
%not divide evenly into size(X,i), then the chunks at the upper boundary of
%X along dimension i will be truncated.
%
%It is permissible for the Di to be given value Inf. When this is done, it is
%equivalent to setting Di=size(X,i).
%
%If n < ndims(X), then the unspecified dimensions Dj, n<j<=ndims(X) will be
%set to size(X,i).
%
%If n > ndims(X), the the extra dimensions Dj, j>ndims(X) will be ignored.
%
%EXAMPLE 1: Split a 28x28 matrix into 4x7 sub-matrices
%
% >> A=rand(28); C=mat2tiles(A,[4,7])
%
% C =
%
% [4x7 double] [4x7 double] [4x7 double] [4x7 double]
% [4x7 double] [4x7 double] [4x7 double] [4x7 double]
% [4x7 double] [4x7 double] [4x7 double] [4x7 double]
% [4x7 double] [4x7 double] [4x7 double] [4x7 double]
% [4x7 double] [4x7 double] [4x7 double] [4x7 double]
% [4x7 double] [4x7 double] [4x7 double] [4x7 double]
% [4x7 double] [4x7 double] [4x7 double] [4x7 double]
%
%EXAMPLE 2: Split a 20x20x6 array into 20x6x3 sub-arrays. This example
%illustrates how 'Inf' can be used to indicate that one of the sub-array
%dimensions is to be the same as in the original array, in this case size(A,1)=20.
%
%
% >> A=rand(20,20,6);
%
% >> C=mat2tiles(A,[Inf,6,3]) %equivalent to mat2tiles(A,[20,6,3])
%
% C(:,:,1) =
%
% [20x6x3 double] [20x6x3 double] [20x6x3 double] [20x2x3 double]
%
%
% C(:,:,2) =
%
% [20x6x3 double] [20x6x3 double] [20x6x3 double] [20x2x3 double]
%
%The example also shows a situation where the original array does not
%divide evenly into sub-arrays of the specified size. Note therefore that
%some boundary sub-chunks are 20x2x3.

tileSizes=[varargin{:}];

N=length(tileSizes);

Nmax=ndims(inArray);

if N<Nmax

tileSizes=[tileSizes,inf(1,Nmax-N)];


elseif N>Nmax

tileSizes=tileSizes(1:Nmax);

end
N=Nmax;

C=cell(1,N);

for ii=1:N %loop over the dimensions

dim=size(inArray,ii);
T=min(dim, tileSizes(ii));

if T~=floor(T) || T<=0
error 'Tile dimension must be a strictly positive integer or Inf'
end

nn=( dim / T );
nnf=floor(nn);

resid=[];
if nnf~=nn
nn=nnf;
resid=dim-T*nn;
end

C{ii}=[ones(1,nn)*T,resid];


end

outCell=mat2cell(inArray,C{:});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions ProgramFiles/sys_calcpath_fcns/fourier_eval.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function f = fourier_eval(x,AN,BN,T)
% Evaluate a fourier function with coefficients AN and BN at points x for a
% period T

ii = (1:length(AN))-1; % The indices. (with zero-indexing)
lgh = length(x);
[ii x] = meshgrid(ii,x); % Arrays for angles.
AN = repmat(AN',lgh,1); % Create arrays for approximation.
BN = repmat(BN',lgh,1);
theta = ii.*x.*(2*pi)/T; % The angles.
f = (sum(AN.*cos(theta)+BN.*sin(theta),2))'; % the F approximation.

end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@
% Check to make sure all contents are of the right class
class_test = zeros(numel(A),1);
for i = 1:numel(A)
class_test(i) = all(cellfun(@(x) isa(x,classname),A{i}));
class_test_pieces = cellfun(@(x) isa(x,classname),A{i});
class_test(i) = all(class_test_pieces(:));
end

if all(class_test)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@
%%%%%
%Processing stages, passed off to secondary functions

%Vectorize the connection definition functions if necessary (should
%only be necessary if connection is defined as an inline function)
s = vectorize_connection(s);

%Create grids for evaluating the connection functions
s = create_grids(s);

% Ensure that there is a metric
s = ensure_connection_and_metric(s);



%Evaluate the connection and metric over the fine grid for calculations and the coarse
%grid for vector display
s = evaluate_connection(s);
s = evaluate_metric(s);
s = evaluate_metric(s);

%Reshape the evaluated connection and metric to format compatible with plotting
%over base space
s = reshape_connection(s);
s = reshape_metric(s);

%Merge components of evaluated connection and metric
s = merge_connection(s);
Expand All @@ -53,6 +50,9 @@

%Calculate the height functions from the connection
s = calc_height_functions(s);

%Build a stretch function corresponding to the metric
s = calc_stretch_functions(s);

%Save out the updated system properties
save(outfile,'s')
Expand Down
6 changes: 6 additions & 0 deletions ProgramFiles/sys_calcsystem_fcns/calc_stretch_functions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function s = calc_stretch_functions(s)
% Apply cartographic normalization to the shape space

s.convert = fast_flatten_metric(s.grid.metric_display,s.metricfield.metric_display.content.metric);

end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function s = create_grids(s)

%list of grids that will be made
grid_list = {'vector','scalar','eval','metric_eval'};
grid_list = {'vector','scalar','eval','metric_eval','metric_display'};

% Create a cell array to hold the grid primitives
gridprim = cell(length(s.grid_range)/2,1);
Expand Down
35 changes: 35 additions & 0 deletions ProgramFiles/sys_calcsystem_fcns/ensure_connection_and_metric.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function s = ensure_connection_and_metric(s)

% Currently, this program only ensures that there is a metric -- the
% connection and metric denominators are now only calculated if explicitly
% provided by the user.

% Get the number of shape variables
n_shape = nargin(s.A_num);
shape_test_list = num2cell(ones(n_shape,1));

% % If there is no connection denominator, make it all ones
% if ~isfield(s,'A_den')
%
% shape_test_list = num2cell(ones(n_shape,1));
% s.A_den = @(a,varargin) repmat(ones(size(s.A_num(shape_test_list{:}))),size(a));
%
% end


%Ensure presence of a metric and a metric denominator
if ~isfield(s,'metric')

s.metric = @(a,varargin) repmat(eye(size(shape_test_list,1)),size(a));

end

% if ~isfield(s,'metric_den')
%
% s.metric_den = @(a,varargin) repmat(ones(size(shape_test_list,1)),size(a));
%
% end



end
23 changes: 23 additions & 0 deletions ProgramFiles/sys_calcsystem_fcns/evaluate_connection.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
%Evaluate the connection over the fine grid for calculations and the coarse
%grid for vector display
function s = evaluate_connection(s)



%list of all components of the local connection and metric that may be present
component_list = {'A_num','A_den','B_ref_point',...
'B_rot_add','B_rot_mult'};


% Evaluate all components in the list at the eval density

s = evaluate_tensors_in_system_file(s,component_list,{'eval','eval'},'vecfield');

% resample the fields at a low density for vector field display
s = resample_tensors_in_system_file(s,component_list,'eval',{'display','vector'},'vecfield');





end
19 changes: 19 additions & 0 deletions ProgramFiles/sys_calcsystem_fcns/evaluate_metric.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%Evaluate the connection over the fine grid for calculations and the coarse
%grid for vector display
function s = evaluate_metric(s)


%list of all components of the local connection and metric that may be present
component_list = {'metric','metric_den'};


% Evaluate all components in the list

s = evaluate_tensors_in_system_file(s,component_list,{'metric_eval','metric_eval'},'metricfield');

% resample metric at a resolution appropriate for displaying as an
% ellipse field
s = resample_tensors_in_system_file(s,component_list,'metric_eval',{'metric_display','metric_display'},'metricfield');


end
Loading

0 comments on commit 9fe1c5c

Please sign in to comment.