Math functions on an entire DAT table

Hi All,

Is there a faster way to perform math functions on an entire table (for example multiply each cell by 2) instead of doing for loops in python and multiply each cell?

I have a chop execute, and it takes some 60ms to execute this script which seems a bit high?

Sounds like a job for the Evaluate DAT

[url]http://www.derivative.ca/wiki088/index.php?title=Evaluate_DAT[/url]

Just tested and I had to cast the value to a float to get the expected result
(seemed to parse as string by default so 22=22 and 42=44)

Another option is to convert it to a CHOP (datto CHOP), do the math, and convert it back to a DAT (if you still need it as a DAT, otherwise keeping it in a CHOP is faster).

Math is much quicker in CHOPs (native floating point numbers) then DATs (strings that are converted) in general.

1 Like

@Leskos -

The above is from the Chop Execute OP… I think it would perform the same as an evaluate Op? however I can throttle how often it runs the script based on the off to on value in the CHOP it is checking. I would imagine an evaluate CHOP would run at the same efficiency, but would constantly try to run the script.

Rob -

The DAT table is being used to control the RBG of about 450 instances of a circle. The tx ty tz is a grid of 30 x 15 (450 points), and the rgb is this table. In this particular application, would it be better to have a whole bunch of chop channels? 450 x 3 would be some 1350 individual numbers that would be between 0 … 1…

Ah OK, yeah with that many values you’d be much better off doing it all in CHOPs if possible. I’ve only ever used the evaluate DAT with relatively small tables where I need text as well as numbers. As Rob says, floating point maths is much faster in CHOPs.

In my experience CHOP math is always faster. You can also drive your instances with a CHOP instead of a DAT - which is also faster performing in general.

Rather than 450 x 3 chop channels ( 1350 ), I’d think of 3 channels with 450 samples each.

base_chop_math.tox (6.83 KB)

Thanks for the tip!

What would then be the best way to manipulate single samples within those channels?

How do you want to manipulate / control it? Is this pattern based, is this direct control of all 450 instances, is it some combination?

A bit of both… what I am working with right now is individual control of each instance/sample.

However I am thinking I will want to make a couple different configurations and be able to fade between patterns that manipulate individual samples, and others that would be more pattern based.

For direct control, you’re probably best suited to place all of the initial data in a table DAT and then convert to CHOPs. If you always have the same number of channels, you could use a cross CHOP to blend between different states. Otherwise you might use a switch CHOP

manual_and_pattern_instances.tox (3.12 KB)

The Evaluate DAT now has a Scope page, so you can affect a sub-set of cells with the expression. This is just a side-note in case you missed it last month.

Great this is wonderful!

Hi Matt,

Thanks for posting the sample!

What is the purpose of the index channel? I don’t see it used anywhere in the instance…

In this example Index isn’t used outright.

I like including an index with my instances because it makes texture instancing easier - if, in the future, you want to apply textures to your instances, this can be handy to have baked into your chop channels. I can also be useful if you’re trying to track down a particular sample.

It should still function just as well without the index channel, I just find it useful personally.

M

Here is kind of where I am at… trying to use python to now update a specific sample within a channel, but cannot get the syntax right.

I have used chops instead of python to reset and do the large table manipulation…

unless there is a chop that will let me do this?

i’m trying to pick a specific xy coordinate in my grid of hex’s and only illuminate a specific one based on that xy coordinate (converting the xy to a single index number). ultimately creating some animation of light moving around the grid of hexes…
GRID_CHOP.toe (6.2 KB)

I can’t remember if there’s a way to change the value of a sample in a CHOP directly… most of my attempts at this have been failures.

That said, you can take a table and convert it to chops, and use python to alter the table.

If you’re after more patterns than specific changes, I’d think about a ramp TOP.

New ops in orange… you can use the switch to move between the two.

M

GRID_CHOP_mr_edits.1.toe (6.87 KB)

Thank you very much for taking the time to do this :slight_smile:

totally appreciated!

-Brad.

Sure thing Brad, always glad to help.

M