Skip to main content
Best answer by Werner_E

Here is an attempt from what I understood so far.

Vectorization as suggested by Terry sure is the clue, but its not so straightforward as you may think because we don't want to vectorize the elements of DB or n but just the elements of the results of the function n.s1() and A.sDB().

Here is one possible way to do it:

Werner_E_0-1587827996036.png

 

Additional remark: Its not necessary to vectorize the call A.sDB(DB) because the function uses DB^2 and squaring a vector is not defined in mathematics. So Prime automatically applies vectorization.
But in my opinion its good habit to apply the vectorization explicitly  yourself in cases like this - just to be on the safe side in case you later change the function A.sDB.

 

 

 

3 replies

21-Topaz II
April 25, 2020

Hi,

 

Try "vectorisation".

 

On the ribbon at Math | Operators   - lower right hand corner.

 

Cheers 

Terry

25-Diamond I
April 25, 2020

Please attach your worksheet.

And state clearly, what exactly you expect as desired result. For this it might be helpful if you change the input matrices DB and n in a way so not all entries are the same value.

Werner_E25-Diamond IAnswer
25-Diamond I
April 25, 2020

Here is an attempt from what I understood so far.

Vectorization as suggested by Terry sure is the clue, but its not so straightforward as you may think because we don't want to vectorize the elements of DB or n but just the elements of the results of the function n.s1() and A.sDB().

Here is one possible way to do it:

Werner_E_0-1587827996036.png

 

Additional remark: Its not necessary to vectorize the call A.sDB(DB) because the function uses DB^2 and squaring a vector is not defined in mathematics. So Prime automatically applies vectorization.
But in my opinion its good habit to apply the vectorization explicitly  yourself in cases like this - just to be on the safe side in case you later change the function A.sDB.

 

 

 

15-Moonstone
April 25, 2020

Now I am not near my pc. Yep that I prefer but when I enlarge matrix DB 1x4 or higher it will work ?

i will test tomorrow, I will be back

big thank Werner_E &Terry

23-Emerald V
April 25, 2020

As I'm in a cat-skinning mood, here's another approach that uses functions to achieve the desired outcome.

 

Element-by-element multiplication is conventionally referred to as Hadamard (or Schur) multiplication.   The attached worksheet implements it as the function hadamard and applies it to your problem.   The worksheet also includes the map, zeros, ones and seq functions.

 

Here are the hadamard and map functions,

 

2020 04 25 A.png

 

And here are the zeros, ones and seq functions.

zeros, ones, and seq functionszeros, ones, and seq functions

 

Stuart

25-Diamond I
April 26, 2020

Always nice to see your thought son problems and your consequent use a (useful) custom functions.

 

There is no need for "i" anyway. Neither as range, nor as argument in function "A.s".

 

23-Emerald V
April 29, 2020

Vielen Dank, Werner. I'm pretty sure any one of a number of the "core" Mathcadders (yourself included) would have come up with a similar solution if you too came late to the party! 😎

 

Working with Prime Express somewhat forces a purer functional mindset. If I could find nice (ie, quick and short), non-programming ways to return an array after setting an element and to convert an n-parameter function into an n-1 parameter function, I'd be happy. 

 

Well, I would be if the recursion depth wasn't so shallow, although that in itself is just one more challenge to work around.   The lack of expression wrap-around is also a limiting factor as far as readability goes.

 

Sowieso zurück zur Geschichte, yes, I wondered about the 'i' and guessed it might have been intended for some future use when the OP got the function working.

 

Stuart