Deconvolution/1D: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: added the REXX computer programming language.)
m (→‎{{header|REXX}}: simplified the REXX program, used (more) unique variables.)
Line 1,105: Line 1,105:
exit /*stick a fork in it, we're all done. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
deco@: parse arg $1,$2,$R /*obtain the arguments. */
deco@: parse arg $1,$2,$r; b=@.$2.# + 1; a=@.$1.# + 1 /*get sizes of array 1&2*/
f#=@.$2.? + 1; g#=@.$1.? + 1 /*get size of array 1&2.*/
@.$r.#=a - b /*size of return array. */
@.$R.?=g# - f# /*size of return array. */
do n=0 to a-b /*define return array. */
do n=0 to g#-f# /*define return array. */
@.$r.n=@.$1.n /*define RETURN element.*/
@.$R.n=@.$1.n /*define RETURN element.*/
if n<b then L=0 /*define the variable L.*/
if n<f# then L=0 /*define the variable L.*/
else L=n - b + 1 /* " " " " */
else L=n - f# + 1 /* " " " " */
if n>0 then do j=L to n-1; _=n-j /*define elements > 0. */
if n>0 then do i=L to n-1; _=n-i /*define elements > 0. */
@.$r.n=@.$r.n - @.$r.j * @.$2._ /*compute " " " */
@.$R.n=@.$R.n - @.$R.i * @.$2._ /*compute " " " */
end /*j*/ /* [↑] subtract product.*/
end /*i*/ /* [↑] subtract product.*/
@.$r.n=@.$r.n / @.$2.0 /*divide array element. */
@.$R.n=@.$R.n / @.$2.0 /*divide array element. */
end /*n*/; return
end /*n*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
make@: parse arg $,z; @.$.?=words(z) - 1 /*obtain args; set size.*/
make@: parse arg $,z; @.$.#=words(z) - 1 /*obtain args; set size.*/
do j=0 to @.$.?; @.$.j=word(z,j+1) /*define array element. */
do k=0 to @.$.#; @.$.k=word(z,k+1) /*define array element. */
end /*j*/; return /*array starts at unity.*/
end /*k*/; return /*array starts at unity.*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
show@: parse arg $,z,_; do j=0 to @.$.? /*obtain the arguments. */
show@: parse arg $,z,_; do s=0 to @.$.#; _=strip(_ @.$.s) /*obtain the arguments. */
_=strip(_ @.$.j) /*create array list. */
end /*s*/ /* [↑] build the list. */
end /*j*/ /* [↑] build the list. */
say 'array' $": "_; return /*show the list; return*/
say 'array' $": "_; return /*show the list; return*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
test@: parse arg $1,$2; do j=0 to max(@.$1.?, @.$2.?) /*obtain the arguments. */
test@: parse arg $1,$2; do t=0 to max(@.$1.#, @.$2.#) /*obtain the arguments. */
if @.$1.j=@.$2.j then iterate /*create array list. */
if @.$1.t=@.$2.t then iterate /*create array list. */
say "***error*** arrays" $1 ' and ' $2 "aren't equal."
say "***error*** arrays" $1 ' and ' $2 "aren't equal."
end /*j*/; return /* [↑] build the list.*/</lang>
end /*t*/; return /* [↑] build the list. */</lang>
{{out|output|text=&nbsp; when using the default internal inputs:}}
{{out|output|text=&nbsp; when using the default internal inputs:}}
<pre>
<pre>