Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6916

Re: A matrix element specified by a vector?

From "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: A matrix element specified by a vector?
Date 2011-12-03 10:12 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jbcsm0$c0r$1@smc.vnet.net> (permalink)
References <jbag3k$1v9$1@smc.vnet.net>

Show all headers | View raw


On Fri, 02 Dec 2011 12:25:24 -0000, Ralph Dratman  
<ralph.dratman@gmail.com> wrote:

> I am wondering if there is a more compact way to express the following  
> idea:
>
> myMatrix[[   myVector[[1]],  myVector[[2]]   ]]  =  myScalar
>
> This keeps coming up. Did I miss the quick and easy way to do it? Of
> course it looks even uglier in 3 dimensions.
>
> Thank you.
>
> Ralph Dratman
>

If the vector has only two elements (or only three in the 3-d case), you  
could use

myMatrix[[ Sequence@@myVector ]]  =  myScalar

to accomplish the same thing. I think this is about as compact as you are  
going to get since this operation cannot really be simplified much  
further. However, it doesn't look particularly verbose to me even in the  
form you give above. Are you finding that you need to do this for many  
values of myVector and myScalar at the same time? Certainly that operation  
could be made more compact by using e.g. MapThread.

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

A matrix element specified by a vector? Ralph Dratman <ralph.dratman@gmail.com> - 2011-12-02 12:25 +0000
  Re: A matrix element specified by a vector? A Retey <awnl@gmx-topmail.de> - 2011-12-03 09:14 +0000
  Re: A matrix element specified by a vector? "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-12-03 10:12 +0000

csiph-web