%% File : sfun_polyval.tlc generated from sfun_polyval.ttlc revsion 1.4
%% $Date: 2002/04/10 18:18:28 $
%%
%% Rob Aberg, 11-Aug-1999
%% Copyright 1990-2002 The MathWorks, Inc.
%%
%% Abstract: Polynomial evaluation block target file

%implements sfun_polyval "C"
 
%% Function: Outputs ==========================================================
%% Abstract:
%%    Use Horner's Method to evaluate a polynomial in one variable.
%%
%function Outputs(block, system) Output
  /* Polynomial Evaluation (polyval) Block: %<Name> */
  %assign rollVars = ["U", "Y"]
  %roll idx = RollRegions, lcv = RollThreshold, block, "Roller", rollVars
    %assign u = LibBlockInputSignal( 0, "", lcv, "%<tRealPart>%<idx>")
    %assign y = LibBlockOutputSignal(0, "", lcv, "%<tRealPart>%<idx>")
    %assign c0 =  LibBlockParameter(coefs, "0", "", "")
    %assign bufferOverWrite = (LibBlockInputSignalBufferDstPort(0) == 0)
    %<y> = %<c0>;

    %assign rc = LibBlockParameterSize(coefs)
    %if (rc[0]*rc[1]) > 1
      %assign crollVars = ["P"]
      %roll cidx = [1:%<rc[0]*rc[1]-1>], clcv = RollThreshold, block, ...
	"Roller", crollVars
	%assign c = LibBlockParameter(coefs, "", clcv, "%<tRealPart>%<cidx>")
	%<y> = %<y>*%<u> + %<c>;
      %endroll
    %endif
  %endroll
  
%endfunction
