Append value to ArrayFire Array?

288 views
Skip to first unread message

Aaron J. Pung

unread,
Sep 27, 2016, 9:18:47 AM9/27/16
to ArrayFire Users
In the script I am writing, I need to append a value to an array, but I cannot find out how to do this -- surprising, given the power of ArrayFire, and it's capabilities regarding arrays.

Ex: Let's say I have the following C++ code..

    typedef struct
    {
        array TH;
    } structype;

    structype THING;

    THING.TH = 3;

At this point, THING.TH is an array with values: [3]

How can I append another value (7) to THING.TH, such that it reads something like:   THING.TH = [3, 7]   ?

Pradeep Garigipati

unread,
Sep 27, 2016, 9:52:09 AM9/27/16
to Aaron J. Pung, ArrayFire Users
Hey Aaron,

If the data to be joined/appended are already in the form of ArrayFire arrays (these can be arrays with just single data element), then you can use the function join to append data elements along different dimensions.

If you are trying to add scalar values to an already existing Array, then i am afraid that's not possible. The size of an ArrayFire array is not dynamic and once allocated it can't be reallocated to a different size by appending new data elements. The cost of transfer of singular scalar value to GPU memory is far greater compared to the number of elements actually transferred, which is one in this case.

Regards,
Pradeep.

--
You received this message because you are subscribed to the Google Groups "ArrayFire Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to arrayfire-use...@googlegroups.com.
To post to this group, send email to arrayfi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/arrayfire-users/2c9ce7cb-3a98-4c8e-aebd-d2b9b2c34410%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages