Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions @bndfun/bndfun.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
pref = chebfunpref(pref);
end

data = parseDataInputs(data, pref);
data = bndfun.parseDataInputs(data, pref);

% Check the domain input.
if ( ~all(size(data.domain) == [1, 2]) || (diff(data.domain) <= 0) )
Expand Down Expand Up @@ -120,12 +120,19 @@
f = make(varargin);

end

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% METHODS IMPLEMENTED IN THIS FILE:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% PRIVATE STATIC METHODS:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
methods ( Access = private, Static = true )


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Class-related functions: private utilities for this m-file.
%% Note: temporarily (?) made private static methods for Octave
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function data = parseDataInputs(data, pref)
%PARSEDATAINPUTS Parse inputs from the DATA structure and assign defaults.
Expand All @@ -139,4 +146,7 @@
data.hscale = norm(data.domain, inf);
end

end

end % methods
end
72 changes: 60 additions & 12 deletions @chebfun/chebfun.m
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,23 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% CLASS PROPERTIES:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
properties (Access = public)
properties (Access = private)
% DOMAIN of definition of a CHEBFUN object. If K = length(F.DOMAIN) is
% greater than 1 then the CHEBFUN is referred to as a "piecewise".
% CHEBFUN. The first and last values of this vector define the left and
% right endpoints of the domain, respectively. The other values give the
% locations of the interior breakpoints that define the domains of the
% individual FUN objects comprising the CHEBFUN. The entries in this
% vector should be strictly increasing.
domain % (1x(K+1) double)

mydomain % (1x(K+1) double)


% POINTVALUES Values of the function at the break points.
%pointValues = []; % (1 x (K+1) double)


end
properties (Access = public)
% FUNS is a cell array containing the FUN objects that comprise a
% piecewise CHEBFUN. The kth entry in this cell is the FUN defining
% the representation used by the CHEBFUN object on the open interval
Expand All @@ -163,7 +170,7 @@
% (Mxinf) arrays. This difference is only behavioral; the other
% properties described above are _NOT_ stored differently if this flag
% is set.)
isTransposed = 0; % (logical)
isTransposed = 0; % (logical) ---!!!class field---
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -200,7 +207,7 @@
end

% Parse inputs:
[op, dom, data, pref, flags] = parseInputs(varargin{:});
[op, dom, data, pref, flags] = chebfun.parseInputs(varargin{:});

if ( flags.done )
% An update was performed. Exit gracefully:
Expand All @@ -216,14 +223,14 @@
% Construct from function_handle, numeric, or string input:

% Call the main constructor:
[f.funs, f.domain] = chebfun.constructor(op, dom, data, pref);
[f.funs, f.mydomain] = chebfun.constructor(op, dom, data, pref);

if ( flags.doubleLength )
% Using the length of f.funs{1} is okay because the
% 'doubleLength' flag is mutually exclusive with 'splitting
% on'.
pref.techPrefs.fixedLength = 2*length(f.funs{1}) - 1;
[f.funs, f.domain] = chebfun.constructor(op, dom, data, pref);
[f.funs, f.mydomain] = chebfun.constructor(op, dom, data, pref);
end

% Update values at breakpoints (first row of f.pointValues):
Expand All @@ -242,6 +249,41 @@
end

end


%{
# in case pointValues ​​is a private class field
function set_private_point_values(f, array)
f.pointValues = array;
end


function f = set_private_point_values(f, varargin)

disp("set private property here!")
%approach 1!

prop = varargin{1};
val = varargin{2};
while (numel (varargin) > 1)
prop = varargin{1};
val = varargin{2};
varargin(1:2) = [];

f.pointValues = val(:); % force row vector
endwhile
disp("set result")
f.pointValues
disp("set result end")

endfunction

function res = get_private_point_values(f)
disp("get here!")
res = f.pointValues;
end

%}

end

Expand Down Expand Up @@ -442,14 +484,14 @@
% Parse inputs to PLOT. Extract 'lineWidth', etc.
[lineStyle, pointStyle, jumpStyle, deltaStyle, out] = ...
parsePlotStyle(varargin)
end

end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Class-related functions: private utilities for this m-file.
%% Note: temporarily (?) made private static methods for Octave
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function op = str2op(op)
% Convert string inputs to either numeric format or function_handles.
sop = str2num(op); %#ok<ST2NM> % STR2DOUBLE doesn't support str2double('pi')
Expand Down Expand Up @@ -779,10 +821,10 @@
function op = parseOp(op)
% Convert string input to function_handle:
if ( ischar(op) )
op = str2op(op);
op = chebfun.str2op(op);
end
if ( doVectorCheck && isa(op, 'function_handle') )
op = vectorCheck(op, dom, vectorize);
op = chebfun.vectorCheck(op, dom, vectorize);
end
if ( isa(op, 'chebfun') )
if ( op.isTransposed )
Expand Down Expand Up @@ -944,7 +986,6 @@

end

end

function g = vec(op, y)
%VEC Vectorize a function or string expression.
Expand Down Expand Up @@ -984,3 +1025,10 @@
end

end

end



end % methods
end
45 changes: 31 additions & 14 deletions @chebfun/compose.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@

if ( numel(f) == 1 )
% Array-valued CHEBFUN case:
%disp(op)
f = columnCompose(f, op, g, pref, opIsBinary);
else
% QUASIMATRIX case:
Expand All @@ -239,30 +240,41 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function f = columnCompose(f, op, g, pref, opIsBinary)
function f = columnCompose(obj, op, g, pref, opIsBinary)



%% Initialise:

% Initialise pointValues.
f = chebfun();
%disp("in columnCompose from compose.m!!!!!")

if ( opIsBinary )
% Call OVERLAP() if we are composing two CHEBFUN inputs with a binary op:
[f, g] = overlap(f, g);
pointValues = feval(op, f.pointValues, g.pointValues);
[f, g] = overlap(obj, g);
pointValues = feval(op, obj.pointValues, g.pointValues);
newPointValues = pointValues(1,:);
else
pointValues = feval(op, f.pointValues);
pointValues = feval(op, obj.pointValues);
newPointValues = pointValues(1,:);
end

% Number of piecewise intervals in f:
numInts = numel(f.domain) - 1;
%disp(obj.mydomain)
numInts = numel(obj.mydomain) - 1;
%disp(numInts)

% Initialise storage for the output FUN cell:
newFuns = {};

% Initialise new domain vector:
newDom = f.domain(1);
% Initialise new domain vector

temp_dom = obj.mydomain;
newDom = temp_dom(1);
%newDom = get(f, "domain")(1); %%%% working
%newDom = f.mydomain(1); %%%%!!!!!! error: can't perform indexing operation on array of chebfun objects


if ( pref.splitting) % Is splitting on?
% Set the maximum length (i.e., number of sample points for CHEBTECH):
Expand All @@ -280,19 +292,22 @@
% This line assumes that the compose method for f is the one that gets called
% ultimately instead of the one for g (which is true currently but could
% change).
pref.tech = get(f.funs{1}, 'tech');
temp_funs = obj.funs;
pref.tech = get(temp_funs{1}, 'tech');

% Suppress growing vector Mlint warnings (which are inevitable here):
%#ok<*AGROW>

%% Loop through each interval:
for k = 1:numInts

%disp(k)

% Attempt to generate FUN objects using FUN/COMPOSE().
if ( isempty(g) )
newFun = compose(f.funs{k}, op, [], [], pref);
newFun = compose(temp_funs{k}, op, [], [], pref);
else
newFun = compose(f.funs{k}, op, g.funs{k}, [], pref);
newFun = compose(temp_funs{k}, op, g.funs{k}, [], pref);
end
isHappy = get(newFun, 'ishappy');

Expand All @@ -314,7 +329,7 @@
% Store new FUN in cell array:
newFuns = [newFuns, {newFun}];
% Store new ends:
newDom = [newDom, f.domain(k+1)];
newDom = [newDom, temp_dom(k+1)];
% Store new pointValues: (Note, will only be a matrix - not a tensor)
if ( isempty(g) )
newPointValues = [newPointValues ; pointValues(k+1,:)];
Expand All @@ -325,7 +340,7 @@
elseif ( pref.splitting )

% If not happy and splitting is on, get a CHEBFUN for that subinterval:
domk = f.domain(k:k+1);
domk = temp_dom(k:k+1);
if ( opIsBinary )
newChebfun = chebfun(@(x) feval(op, feval(f, x), feval(g, x)), ...
domk, pref);
Expand Down Expand Up @@ -359,9 +374,11 @@
%% Prepare output:

% Put the FUN cell, domain, and pointValues back into a CHEBFUN:
f.funs = newFuns;
f.domain = newDom;

f.pointValues = newPointValues;
%f = set_private_point_values(f, "pointValues", newPointValues);
f.funs = newFuns;
f.mydomain = newDom;

end

Expand Down
4 changes: 4 additions & 0 deletions @chebfun/constructor.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
end
end

%disp("in constructor funs")
%iscell(funs)
%disp(funs)

end

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%% SPLITTING ON %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
21 changes: 16 additions & 5 deletions @chebfun/disp.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ function disp(f)
% See http://www.chebfun.org/ for Chebfun information.

% If the 'format loose' setting is enabled, we print additional linebreaks:
loose = strcmp(get(0, 'FormatSpacing'), 'loose');
if (exist('OCTAVE_VERSION', 'builtin') )
if (compare_versions(OCTAVE_VERSION(), '4.3.0', '>='))
[fmt, spacing] = format();
loose = strcmp(spacing, 'loose');
else
loose = eval('! __compactformat__ ()');
end
else
loose = strcmp(get(0, 'FormatSpacing'), 'loose');
end

s = '';

Expand Down Expand Up @@ -70,9 +79,10 @@ function disp(f)
s = [s, sprintf('\n interval length endpoint values %s\n', extraItem)];
len = zeros(numFuns, 1);
for j = 1:numFuns
len(j) = length(f.funs{j});
ffuns = f.funs;
len(j) = length(ffuns{j});

if ( ~isreal(f.funs{j}) )
if ( ~isreal(ffuns{j}) )
% For complex-valued funs, we don't display the values.

% Print information to screen:
Expand All @@ -82,16 +92,17 @@ function disp(f)
else

% Grab values at endpoints:
endvals = [get(f.funs{j}, 'lval'), get(f.funs{j}, 'rval')];
endvals = [get(ffuns{j}, 'lval'), get(ffuns{j}, 'rval')];

% Tweak the endpoint values: (This prevents -0 and +0)
if ( ~any(isnan(endvals)) )
endvals(~logical(abs(endvals))) = 0;
end

% Print information to screen:
temp = f.domain; % TODO: improve chaining in subsref?
s = [s, sprintf('[%8.2g,%8.2g] %6i %8.2g %8.2g %s\n', ...
f.domain(j), f.domain(j+1), len(j), endvals, extraData{j})];
temp(j), temp(j+1), len(j), endvals, extraData{j})];

end
end
Expand Down
3 changes: 2 additions & 1 deletion @chebfun/dispData.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

% Loop over each FUN:
for j = 1:numFuns
infoJ = dispData(f.funs{j});
temp = f.funs;
infoJ = dispData(temp{j});
if ( ~isempty(infoJ) )
numInfo = numel(infoJ);
for k = 1:numInfo
Expand Down
Loading