Re: newbie question on functions

• To: mathgroup at smc.vnet.net
• Subject: [mg51776] Re: [mg51750] newbie question on functions
• From: DrBob <drbob at bigfoot.com>
• Date: Mon, 1 Nov 2004 02:53:47 -0500 (EST)
• References: <200410310617.BAA16316@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```I don't think making ratio and intensity Listable helps, in this case.

If the different combinations of cy3 and cy5 are not too numerous to fit computed values in memory, this saves them when they're first used:

ratio[cy3_,cy5_]:=ratio[cy3,cy5]=N@Log[cy3/cy5];
intensity[cy3_,cy5_]:=intensity[cy3,cy5]=N@Log[2,cy3*cy5];

I'm guessing at some of that, since the first two Tables in your post make no sense. (no iterators)

The last Table might be this:

Table[ratio[fmicroarray[[i, 18]], fmicroarray[[j, 19]]],
{i, Length@fmicroarray}, {j, Length@fmicroarray}]

or:

Outer[ratio,fmicroarray[All,18],fmicroarray[All,19]]

But maybe you meant:

Table[ratio[fmicroarray[[i, 18]], fmicroarray[[i, 19]]],
{i, Length@fmicroarray}]

which is the same as:

Inner[ratio,fmicroarray[All,18],fmicroarray[All,19],List]

That solution stores values in the ratio and intensity functions, after which it is easy to compute the table whenever you want it. If you'd rather, you can eliminate the storing of values in ratio and intensity, but store the table. Which is more efficient depends on how the values will be used.

Bobby

On Sun, 31 Oct 2004 01:17:36 -0500 (EST), Todd Allen <genesplicer28 at yahoo.com> wrote:

> Hi all,
>     I have what is probably a nieve question, but it is giving me some difficulty.  I am trying to generate a function in which I pass two columns of information from a matrix to this function to perform some calculations.  I can successfully pass the data and get the resulting calculation......but the problem is the function returns the results but does not save the results in memory to perform subsequent calculations with.  How can I get the function to keep the result?  Is there a way to assign the function output to a new variable before mathematica discards the results.  Does this behavior have anything to do with the Head of the function  being symbolic, rather than say a list??
>Below is the relevant code:
>SetAttributes[ratio,Listable];
> SetAttributes[intensity,Listable];
>
> ratio[cy3_,cy5_]:=Table[Log[2,(cy3/cy5)]]//N;
> intensity[cy3_,cy5_]:=Table[Log[2,(cy3*cy5)]]//N;
> ratio[Table[fmicroarray[[i,18]],{i,1,Length[fmicroarray]}],
>   Table[fmicroarray[[i,19]],{i,1,Length[fmicroarray]}]]
>I appreciate any insight you might have.  Thanks.
>Todd
>
>
>
>

--
DrBob at bigfoot.com
www.eclecticdreams.net

```

• Prev by Date: Re: Zero divided by a number...
• Next by Date: Re: Re: New version, new bugs
• Previous by thread: Re: newbie question on functions
• Next by thread: Re: newbie question on functions