Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Help

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28228] Re: [mg28196] Help
  • From: Tomas Garza <tgarza01 at prodigy.net.mx>
  • Date: Thu, 5 Apr 2001 03:00:44 -0400 (EDT)
  • References: <200104040813.EAA23835@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I only hope your s vector has no zero elements. If m and s have all
nonnegative elements,

In[1]:=
c[m_, s_] := (n = (m - s)/s; negs = Position[n, x_ /; x < 0];
    ReplacePart[n, m, negs, negs])

can handle the job decently. For example, with m 100x150 and s 100x1,

In[2]:=
m = Table[Random[Integer, {0, 9}], {100}, {150}];
s = Table[Random[Integer, {1, 9}], {100}];

In[3]:=
c[m, s]; // Timing
Out[3]=
{12.31 Second, Null}

If you allow for both negative and positive elements, then some
modifications must be made to the above. You should have given us some more
information about the nature of your matrix and vector.

Tomas Garza
Mexico City


----- Original Message -----
From: <Yannis.Paraskevopoulos at ubsw.com>
To: mathgroup at smc.vnet.net
Subject: [mg28228] [mg28196] Help


> Hi all,
>
> I would appreciate your help on the following problem:
>
>
> assume that we have a matrix m with dimensions (RxC) and a vector s
> with dimensions (Rx1). Now what I want is to create another matrix Q
>
> If m[[i,j]]>s[[i]], then Q=(m[[i,j]]-s[[i]])/s[[i]], for {i,1,R},{j,1,C}
>
>
> I'm sure there must be an elegant and fast way to do that.
>
>
> Best Regards
>
> yannis
>
>
>
>
> Visit our website at http://www.ubswarburg.com
>
> This message contains confidential information and is intended only
> for the individual named.  If you are not the named addressee you
> should not disseminate, distribute or copy this e-mail.  Please
> notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system.
>
> E-mail transmission cannot be guaranteed to be secure or error-free
> as information could be intercepted, corrupted, lost, destroyed,
> arrive late or incomplete, or contain viruses.  The sender therefore
> does not accept liability for any errors or omissions in the contents
> of this message which arise as a result of e-mail transmission.  If
> verification is required please request a hard-copy version.  This
> message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities or
> related financial instruments.
>
>




  • References:
    • Help
      • From: Yannis.Paraskevopoulos@ubsw.com
  • Prev by Date: RE: Polar Grids in Mathematica
  • Next by Date: Re: complex coefficients and rules...
  • Previous by thread: Help
  • Next by thread: Re: Help