Tensor multiplication

I'm looking for a solution to do Tensor multiplication, similar to Matrix multiplication, which works really great!
Thank you for any hint

I peeked at

and am reminded of some procedures I wrote for matrix multiplication, at

Feel free to build on them.

1 Like

Thank you, meanwhile I solved to programm a Tensor product and it works fine even with complex values.
But now I have an additional question:
how is it possible to make a list (1-dimensional) with complex numbers?
I found a way, but it is very laborious: initialize a global variable with the complex number and then add it to the list.
But there should be a more direct way ...
Thank you

AI2 supports complex numbers natively.

Are you trying to do csv list conversion with complex numbers?
That would be out of scope for the CSV spec.

Show us what is not working for you.


This code works, give or take floating point fuzz.

1 Like

Thank you for your quick reply!
The only way i found to put complex numbers in a list element is shown in the image.
I am using https://ai2-test.appinventor.mit.edu/
I cannot find your "set ListView1.Elements to". Is there another version of AI2 ?
Thanks again and best regards

Why, you should use ai2-test for testing ai2-test only, it is not for app development and production.

nb201 has just been released so all the features in ai2-test are in the main ai2 server.

Read the introduction to lists.

Also study value procedures.

You will need to code one to convert a pair to a complex number.

I can't do that on my phone.

Finally, learn JSON for text representation of nested lists.

BTW, you should be able to enter complex Numbers in the blue math constant block

I tested this, and to my surprise, you can't.

I wonder if this happened duting our recent Blockly update.

I am searching my old code for examples of such blocks, not that it would help now.

I am also searching for formulas that can be used to extract real and imaginary parts of an imaginary value. They are not to be found in the math blocks pallette.

In the meantime, here's a complex number maker function:


(draggable)

image

It gets worse. Many of the formulas for reverse engineering the real and complex parts of an imaginary number I have found rely on sin() and cos(), which don't support complex numbers in AI2.

I hope I don't have to resort to text manipulation.

Still looking ...

I have taken a rest from that part of the problem.

Addressing your problem of how to feed complex numbers into a list, here is
image

You need to pull in a ListView from the UI Pallette in the Designer first.

Thanks a lot for your engagement and help !!!!