Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.1K Views
|
10 Replies
|
5 Total Likes
View groups...
Share
Share this post:

User defined plus and product.

Posted 11 years ago

Hello.

I'm a new user of Mathematica. So please be patient with me :)

I try to define E = { e1, e2, e3, e4 }, a set, and two operations on E : the plus and the product. The idea is to compute product of matrices using those user defined operations.

Could someone give me the syntax and the "how to" to make it work ?

Regards

10 Replies

I finally found a recursive possibility :

f [ x_ ,y_ , z__ ] = f [ f [x,y] , z ]

hope recursive aspect will be replaced at execution time by iterative computation...

I met a last difficulty I didnt solve. I didnt see it 4 hours ago because of the sample limitation at dimension 2.

If I work on :

Inner[dwproduct, ( {
   {1, On, 0, 0},
   {On, 1, On, On},
   {0, On, 1, 0},
   {0, On, 0, 1}
  } ), ( { {V},{N},{N},{N} } ), wsum]

The given result is

{
 {wsum[V, N, 0, 0]},
 {wsum[V, N, N, N]},
 {wsum[0, N, N, 0]},
 {wsum[0, N, 0, N]}
}

So, how to define wsum a general/generic way to avoid specialize for each tuple ? (i probably will compute samples with matrices at dimension 600 and more)

Could I imagine something recursive (or not) that will transfer "evaluation capability" to binary operation ?

Let's say wsum[x1,x2,x3,...,xn]= ((((x1)+x2)+x3)+...)+xn

Nice feature. I really appreciate the opulence of symbols. It make articles more readable and attractive.

Thanks for the tip.

Just what I was searching for. It perfectly uses a and b as 'atoms'.

Thanks for your patience.

Posted 11 years ago

This might also be interesting: Operators without Built In Meanings

In[1]:= CirclePlus[a, b] = b

Out[1]= b

In[2]:= a \[CirclePlus] b

Out[2]= b

(Note that [CirclePlus] can be entered as esc c+ esc and looks like a CirclePlus symbol in an actual notebook.)

POSTED BY: David Keith

Write your own add and multiply functions. Combine them using Inner to make your matrix product function.

POSTED BY: John Doty

Excellent !!! Inner[f,list1,list2,g] is exactly what I was searching for.

The last part now is : defining f and g with elegant writing. Let's consider the informations I have are an enumeration of all tuples X+Y=Z, could I define f and g by using some kind of pattern matching or some similar mechanism ? what is the most "readable" technique for such kind of definitions ?

Regards

Frédéric DIDIER

POSTED BY: John Doty

What you are looking for probably already exists: matrix operations and vector + matrices

but you can define your own as well

POSTED BY: Kay Herbert
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard