Home > lattice > element_creation > atbaselem.m

atbaselem

PURPOSE ^

ATBASELEM Create an AT element structure + various checks

SYNOPSIS ^

function elem = atbaselem(famname,method,varargin)

DESCRIPTION ^

ATBASELEM  Create an AT element structure + various checks

ELEM=ATBASELEM(FAMNAME,METHOD,'FIELDNAME1',VALUE1,...) create AT element
   Create an AT element structure and check the consistence of
   PolynomA, PolynomB, MaxOrder and NumIntSteps

  NOTES
    1. length of PolynomA and PolynomB are equal (zero padding)
    2. MaxOrder is always lenght(PolynomA) - 1

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function elem = atbaselem(famname,method,varargin)
0002 %ATBASELEM  Create an AT element structure + various checks
0003 %
0004 %ELEM=ATBASELEM(FAMNAME,METHOD,'FIELDNAME1',VALUE1,...) create AT element
0005 %   Create an AT element structure and check the consistence of
0006 %   PolynomA, PolynomB, MaxOrder and NumIntSteps
0007 %
0008 %  NOTES
0009 %    1. length of PolynomA and PolynomB are equal (zero padding)
0010 %    2. MaxOrder is always lenght(PolynomA) - 1
0011 
0012 DefaultNumIntSteps = 10;
0013 
0014 [famname,rsrc] = getoption(varargin,'FamName',famname);
0015 [method,rsrc]  = getoption(rsrc,'PassMethod',method);
0016 [lg,rsrc]      = getoption(rsrc,'Length',0);
0017 elem           = struct('FamName',famname,'PassMethod',method,'Length',lg,rsrc{:});
0018 
0019 % Making PolynomA of same length with zero padding when necesssary
0020 ab = isfield(elem,{'PolynomA','PolynomB'});
0021 if any(ab)
0022     if ~ab(1), elem.PolynomA=[]; end
0023     if ~ab(2), elem.PolynomB=[]; end
0024     if ~isfield(elem,'MaxOrder')
0025         elem.MaxOrder=max([1 find(abs(elem.PolynomB)>0,1,'last') find(abs(elem.PolynomA)>0,1,'last')])-1;
0026     end
0027     la = length(elem.PolynomA);
0028     lb = length(elem.PolynomB);
0029     if la < elem.MaxOrder+1, elem.PolynomA=[elem.PolynomA zeros(1,elem.MaxOrder+1-la)]; end
0030     if lb < elem.MaxOrder+1, elem.PolynomB=[elem.PolynomB zeros(1,elem.MaxOrder+1-lb)]; end
0031     la = length(elem.PolynomA);
0032     lb = length(elem.PolynomB);
0033     if la < lb, elem.PolynomA = [elem.PolynomA zeros(1,lb-la)]; end
0034     if lb < la, elem.PolynomB = [elem.PolynomB zeros(1,la-lb)]; end
0035     if elem.Length ~= 0 && ~isfield(elem,'NumIntSteps')
0036         elem.NumIntSteps = DefaultNumIntSteps;
0037     end
0038 end
0039 
0040 end

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005