Set an array with undeterminate size

I should know this by now, but go figure. If I want to set up an array of Strings, yet I do not know how many Strings I am going to stick in it, how would I do so? For example, if I want to create an array myArray, and I do not know whether I am going to put 15 elements in it or 500, how would I set the length to be indeterminate, or something like that, so I do not get an ArrayIndexOutOfBoundsException?
Thanks,
Dan

Ah, that's a good idea. Thank you.
Actually, while we're talking about arrays, is there some sort of way to specify where an iterator is in an array during a for loop?
In other words, if I have an array of strings, and want my code to do something if the element in the array is greater than 2, how would I go about doing that? In case that didn't make sense, let me provide an example.
         int[] anArray = {1, 2, 3};
         for (int i : anArray) {
              if (i > 0) {
                   System.out.println("This number is greater than 1");
              else {
                   System.out.println("This number is the number 1");
         }I'm basically trying to say the same thing, except using an array of strings. In the above example, if i is greater than 0, i.e. it is on the first or second value of the array (2 and 3, respectively) it will print out that the number is greater than 1. Otherwise, it will say the number is 1.
So my question now is: how could I do something similar using an array of strings? If the iterator is on the second string element in the array or greater, how could I signify that?
Please let me know if that doesn't make sense. And thank you for your help.
Dan

Similar Messages

  • Error unsupported memory access on variable 'Decoder.number_of_values' which is (or contain) an array with unknown size at compile time

    Dear All,
    I am a new user of Vivado HLS. I want to pass an array of struct to a function and use elements of struct multiple times in a function (read and write). I find this error "error unsupported memory access on variable 'Decoder.number_of_values' which is (or contain) an array with unknown size at compile time " . Kindly can anyone tell that is it an issue of directive? if yes then which directive to use for struct and its element. Struct and function are as follows.
    typedef struct {
    uint32_t number_of_values ;
    uint32_t  address[16];
    uint8_t Processed_bit :1 ;
    uint32_t links[6];
    } Decoder_Fields;
    void Raptor_LT_decode(int To_Send,Decoder_Fields *Decoder){
        int counter=0;
        int i=0,j=0,k=0,x,aaa;
        Raptor_LT_decode_label0:while(counter<To_Send){
            if((Decoder[counter].number_of_values ==1) &&(Decoder[counter].Processed_bit==0) ){
                Decoder[counter].Processed_bit=1;
                Raptor_LT_decode_label1:for (i=0; i<To_Send;i++){
                   Raptor_LT_decode_label2:for (k=0;k<Decoder[i].number_of_values;k++){
                         if (( Decoder[counter].links[0]==Decoder[i].links[k]) && (counter != i)&&       (Decoder[i].number_of_values!= 1)) {
                            Raptor_LT_decode_label3:for (j=0;j<BLOCK_SIZE_BYTES/4;j++){
                                     Decoder[i].address[i]= Decoder[i].address[j] ^ Decoder[counter].address[j];
                            for (x=k;x<Decoder[i].number_of_values-1;x++) Decoder[i].links[x]=Decoder[i].links[x+1];
                                      Decoder[i].number_of_values--;
                counter=0;
            else
                counter++;
     

    Hi ,
    This question is asked on the forum from time to time and should be described in the UG902
    In your top level, Decoder is a pointer; this is not supported as-is as you need to know its size when you do something like Decoder[i].XXXX : the tool need to know how many bits to size the addess bus.
    you need to change Decoder_Fields *Decoder to Decoder_Fields Decoder[YOURSIZE]
    with YOURSIZE that makes sense; in this case the tool will know that it need N=log2(YOURSIZE) to fully address the Decoder array variable.
    next when you solve that and that all is good... the question that you will need to transfer the data of the structs from host memory to your VHLS IP; you need to think about this.
    I hope this helps.

  • Multi-dimensional array with dynamic size - how to?

    Hi
    I have a CONSTANT number of buckets. Each of them has to take a VARIOUS number of data series. The data series have one VARIOUS length per bucket. I'd like to index the buckets like an array to loop over them.
    So basically I need something like a multidimensional array with constant first dimension (bucket index), but dynamic second (data series index within bucket) and third (data point index within data series) dimension. What's the best way to do so?
    I should also remark that data series can get really big.
    Thanks in advance and best regards,
    Michael

    Hi Michael,
    the usual way is to use an array of cluster.
    Put your "2nd" and "3rd" data into a cluster and then make an 1D array of that cluster...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Set Height automatically with screen size

    Hi to everyone
    Can i set the height af a component from backing bean, using the height of the screen?
    I want that a panelgrouplayout fit the screen dimensions but for the height i have to take the screen height.
    Can i do thi in a different way?
    How can i take the screen height in a backing bean?
    Thanks

    Hi,
    You can place the component you want to stretch inside a panelStretchlayout,This will stretch it automatically.
    The width of the components can be set to stretch to screen width by using AFStretchWidth style class,but for stretching the height,the best practice is to keep it in a component that stretches its child.
    Ref - http://jdevadf.oracle.com/adf-richclient-demo/faces/feature/index.jspx?_afrLoop=46537651471503876#%2Ffeature%2FlayoutBasics.jspx%40
    Regards,
    guna

  • How to auto insert a number array with size of 20 into a named excel file with the positon is from A1 TO A20?i use lv6.1

    can you give me a example vi for it ?thanks a lot!
    how to auto insert a number array with size of 20 into a named excel file  with the positon is from A1 TO A20?i use lv6.1

    You don't need us to give you an example, as the example already comes with LV. Go to Help>>Find Examples and search for "excel". You will find an example called "write table to XL". You should note that the example doesn't do that exactly, because it writes a 2D array from 2 to N.
    You can modify the example by using only one for loop (instead of nested loops) with a 1D array or by going into the Set Cell Value and modifying it to accept a second cell value for the Cell2 terminal and wiring in a 1D array instead of the single string. If you do modify it, be sure to save it under a different name, so you don't overwrite the original.
    To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
    Try to take over the world!

  • Set Fixed Array Size

    Hello. I am trying to develop a VI for an FPGA target and I'm trying to make it so whoever is using the VI can specify the size of an input array when they instantiate it (such as by having an input to the VI that says "max array size" or something). So far it seems like the only way to do something like this is to go into the VI itself and manually set the array size for each input array for the VI (i.e. open the VI, right click on each input array, select "Set Dimension SIze", choose "fixed", set number of elements). I'd like to have one point where I can set the size of all the arrays at once (since in my case they are all the same size), and let the person using the VI set it to the proper size for whatever application they are using it for (to be clear, let's say I have two uses for this VI, and in one case I have an input array of size 100 and in anohter use of size 1000, I'd like to be able to set these somehow instead of doing it through the dialog). Thanks.
    Solved!
    Go to Solution.

    Unfortunately, per-call configuration of array size is not something that is supported today. This is a great idea, I would suggest that you post it on the FPGA Idea Exchange so we can get a feel for how many other people need this same feature.

  • How do I cerate an array with a set of numbers lets say 1 through 12 random order but no repeating.

    How do I cerate  an
    array with a set of numbers lets say 1 through 12 random order but no
    repeating.
    I know this should be easy but my brain wont work
    right now
    Solved!
    Go to Solution.

    OK, here's the handmade version.
    It is useful to know that arrays of clusters are sorted by the cluster order of the elements. Simply bundle random numbers with numbers 1-12 in a loop, create an array at the output tunnel, sort the array by the random number, and extract the number array. It will be shuffled.
    Message Edited by altenbach on 06-04-2007 09:20 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    shuffleArray.png ‏5 KB

  • How do i send an array of clusters with variable size over TCP/IP?

    Hi,
            I'm trying to send an array of clusters with varible size over TCP/IP,. But I'm facing the following problems:
    1) I need to accept the size of array data from the user and increase the size dynamically.
    I'm doing this using the property node but how do I convey the new size to my TCP read?
    2) I need to wire an input to my 'bytes to read' of the TCP read.
    But the number of bytes to read changes dynamically
    How do I ensure  the correct number of bytes are read and reflected on the client side?
    3) Is there anyway I can use global varibles over a network such that their values are updated just as if they would on one computer?
     Will be a great help if someone posts a solution!
    Thank you...

    twilightfan wrote:
    Altenbach,
     ... xml string. ...number of columns that I'm varying using property node s... I solved these problems by using a local variable as the type input ...o TCP read is creating a problem.... second TCP read gets truncated data because
    its no longer just the first four bytes that specify the length of the data, it could be more as my array of cluster can be pretty huge.
    Instead of writing long and complicated sentences that make little sense, why don't you simply show us your code? 
    What does any of this have to do with xml strings???? I don't see how using a local variable as type input changes anything. The user cannot interact with "property nodes", just with controls. Please clarify. Once the array of clusters is flattened to a string you only have one size that describes the size of the data, no matter how huge it is (as long as it is within the limits of I32). Similarly, you read the string of that same defined length and form the array of clusters from it. How big are the strings? What is your definition of "huge"?
    Here's is my earlier code, but now dealing with an array of clusters. Not much of a change. Since you have columns, you want 2D. Add as many diensions you want, but make sure that the control, diagram constant, and indicator all match.
    The snipped shows for a 1D array, while the attached VI shows the same for a 2D array. Same difference.  
    Message Edited by altenbach on 01-31-2010 01:13 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FlattenArrayOfClusters.vi ‏12 KB
    ioclusters3MOD.png ‏25 KB

  • Lots of blank space when printing array with only last element printed

    I have a slight problem I have been trying to figure it out for days but can't see where my problem is, its probably staring me in the face but just can't seem to see it.
    I am trying to print out my 2 dimensional array outdie my try block. Inside the trying block I have two for loops in for the arrays. Within the second for loop I have a while to put token from Stringtokeniser into my 2 arrays. When I print my arrays in this while bit it prints fine however when I print outside the try block it only print the last element and lots of blank space before the element.
    Below is the code, hope you guys can see the problem. Thank you in advance
       import java.io.*;
       import java.net.*;
       import java.lang.*;
       import java.util.*;
       import javax.swing.*;
       public class javaflights4
          public static final String MESSAGE_SEPERATOR  = "#";
          public static final String MESSAGE_SEPERATOR1  = "*";
          public static void main(String[] args) throws IOException
             String data = null;
             File file;
             BufferedReader reader = null;
             file = new File("datafile.txt");
             String flights[] [];
                   //String flightdata[];
             flights = new String[21][7];
             int x = 0;
                   //flightdata = new String[7];
             int y = 0;
             try
                reader = new BufferedReader(new FileReader(file));   
                //data = reader.readLine();   
                while((data = reader.readLine())!= null)   
                   data.trim();
                   StringTokenizer tokenised = new StringTokenizer(data, MESSAGE_SEPERATOR1);
                   for(x = 0; x<=flights.length; x++)
                      for(y = 0; y<=flights.length; y++)
                         while(tokenised.hasMoreTokens())
                            //System.out.println(tokenised.nextToken());
                            flights [x] [y] = tokenised.nextToken();
                            //System.out.print("*"+ flights [x] [y]+"&");
                   System.out.println();
                catch(ArrayIndexOutOfBoundsException e1)
                   System.out.println("error at " + e1);
                catch(Exception e)
                finally
                   try
                      reader.close();
                      catch(Exception e)
             int i = 0;
             int j = 0;
             System.out.print(flights [j]);
    //System.out.println();

    A number of problems.
    First, I bet you see a lot of "error at" messages, don't you? You create a 21x7 array, then go through the first array up to 21, going through the second one all the way to 21 as well.
    your second for loop should go to flights[x].length, not flights.length. That will eliminate the need for ArrayIndexOutOfBounds checking, which should have been an indication that you were doing something wrong.
    Second, when you get to flights[0][0] (the very first iteration of the inner loop) you are taking every element from the StringTokenizer and setting flights[0][0] to each, thereby overwriting the previous one. There will be nothing in the StringTokenizer left for any of the other (21x7)-1=146 array elements. At the end of all the loops, the very first element in the array (flights[0][0]) should contain the last token in the file.
    At the end, you only print the first element (i=0, j=0, println(flight[ i][j])) which explains why you see the last element from the file.
    I'm assuming you have a file with 21 lines, each of which has 7 items on the line. Here is some pseudo-code to help you out:
    count the lines
    reset the file
    create a 2d array with the first dimension set to the number of lines.
    int i = 0;
    while (read a line) {
      Tokenize the line;
      count the tokens;
      create an array whose size is the number of tokens;
      stuff the tokens into the array;
      set flights[i++] to this array;
    }

  • Failed MDADM Array With Ext.4 Partition

    Hi Guys,
    I had a powerfailure and now my MDADM array with Ext4 partition is broken.
    The array has now rebuilt but I still can't mount.
    sudo mdadm -D /dev/md0
    [hodge@hodge-fs ~]$ sudo mdadm -D /dev/md0
    /dev/md0:
    Version : 0.90
    Creation Time : Sun Apr 25 01:39:25 2010
    Raid Level : raid5
    Array Size : 8790815232 (8383.57 GiB 9001.79 GB)
    Used Dev Size : 1465135872 (1397.26 GiB 1500.30 GB)
    Raid Devices : 7
    Total Devices : 7
    Preferred Minor : 0
    Persistence : Superblock is persistent
    Update Time : Sun Aug 8 07:30:06 2010
    State : clean
    Active Devices : 7
    Working Devices : 7
    Failed Devices : 0
    Spare Devices : 0
    Layout : left-symmetric
    Chunk Size : 128K
    UUID : 44a8f730:b9bea6ea:3a28392c:12b22235 (local to host hodge-fs)
    Events : 0.1307880
    Number Major Minor RaidDevice State
    0 8 81 0 active sync /dev/sdf1
    1 8 97 1 active sync /dev/sdg1
    2 8 113 2 active sync /dev/sdh1
    3 8 65 3 active sync /dev/sde1
    4 8 49 4 active sync /dev/sdd1
    5 8 33 5 active sync /dev/sdc1
    6 8 16 6 active sync /dev/sdb
    sudo mount -a
    [hodge@hodge-fs ~]$ sudo mount -a
    mount: wrong fs type, bad option, bad superblock on /dev/md0,
    missing codepage or helper program, or other error
    In some cases useful info is found in syslog - try
    dmesg | tail or so
    sudo fsck.ext4 /dev/md0
    [hodge@hodge-fs ~]$ sudo fsck.ext4 /dev/md0
    e2fsck 1.41.12 (17-May-2010)
    fsck.ext4: Group descriptors look bad... trying backup blocks...
    /dev/md0: recovering journal
    fsck.ext4: unable to set superblock flags on /dev/md0
    sudo dumpe2fs /dev/md0 | grep -i superblock
    hodge@hodge-fs ~]$ sudo dumpe2fs /dev/md0 | grep -i superblock
    dumpe2fs 1.41.12 (17-May-2010)
    Primary superblock at 0, Group descriptors at 1-524
    Backup superblock at 32768, Group descriptors at 32769-33292
    Backup superblock at 98304, Group descriptors at 98305-98828
    Backup superblock at 163840, Group descriptors at 163841-164364
    Backup superblock at 229376, Group descriptors at 229377-229900
    Backup superblock at 294912, Group descriptors at 294913-295436
    Backup superblock at 819200, Group descriptors at 819201-819724
    Backup superblock at 884736, Group descriptors at 884737-885260
    Backup superblock at 1605632, Group descriptors at 1605633-1606156
    Backup superblock at 2654208, Group descriptors at 2654209-2654732
    Backup superblock at 4096000, Group descriptors at 4096001-4096524
    Backup superblock at 7962624, Group descriptors at 7962625-7963148
    Backup superblock at 11239424, Group descriptors at 11239425-11239948
    Backup superblock at 20480000, Group descriptors at 20480001-20480524
    Backup superblock at 23887872, Group descriptors at 23887873-23888396
    Backup superblock at 71663616, Group descriptors at 71663617-71664140
    Backup superblock at 78675968, Group descriptors at 78675969-78676492
    Backup superblock at 102400000, Group descriptors at 102400001-102400524
    Backup superblock at 214990848, Group descriptors at 214990849-214991372
    Backup superblock at 512000000, Group descriptors at 512000001-512000524
    Backup superblock at 550731776, Group descriptors at 550731777-550732300
    Backup superblock at 644972544, Group descriptors at 644972545-644973068
    Backup superblock at 1934917632, Group descriptors at 1934917633-1934918156
    sudo e2fsck -b 32768 /dev/md0
    [hodge@hodge-fs ~]$ sudo e2fsck -b 32768 /dev/md0
    e2fsck 1.41.12 (17-May-2010)
    /dev/md0: recovering journal
    e2fsck: unable to set superblock flags on /dev/md0
    sudo dmesg | tail
    [hodge@hodge-fs ~]$ sudo dmesg | tail
    EXT4-fs (md0): ext4_check_descriptors: Checksum for group 0 failed (59837!=29115)
    EXT4-fs (md0): group descriptors corrupted!
    EXT4-fs (md0): ext4_check_descriptors: Checksum for group 0 failed (59837!=29115)
    EXT4-fs (md0): group descriptors corrupted!
    Please Help!

    Give a tip here is somewhat delicate. Perhaps a tip works perfect in some cases and in one case only worsen the situation.
    Have you tried to send an email to linux-ext4 mailing list? There are lots of people involved that may help. http://vger.kernel.org/vger-lists.html#linux-ext4
    I hope that you recover all your information.

  • Can the Property Loader load arrays of variable size?

    I need to run a series of tests on the same UUT, changing only one parameter at a time (for example, a frequency response test). The hardware developers would like to be able to change the values of parameters of the test at will, without making changes to the sequence. That's easy - just change the value of the parameter in the Properties file. The hard part is changing the number of iterations of the test, by ONLY adding or deleting the number of parameters from the text file. In other words, all I know during sequence editing is the types of parameters, not the values or how many. I want the test to loop as many times as there are sets of parameters in the text file.
    I would like to do this by loading the paramet
    ers as an array. But the Property Loader wants me to specify each variable while I am editing the sequence, including each individual member of the array (e.g. "Locals.Array[0].Value"). I want to do somthing like "Locals.Array[*].Value", where "*" means "all elements".
    Am I forced to write external code to load each parameter, or does TS have a native way to do this? Even better, has anybody done this already, and will you explain how? Thanks

    Hi,
    there's a couple of options here, and I've included what I think is the simplest below (using TestStand 2.0.1).
    It's not exactly elegant though. What I've done is to put in a step that finds out the number of steps to load (based on an earlier decision - in this case a message popup step). I read a number from the limits file, and use this in the looping options of the property loader step that's loading the values into the array. I've done it with a fixed size array target here, big enough to take any incoming data. (Otherwise, knowing how many items you're going to load from the limits file, you could start with an empty array and re-size it prior to loading).
    I've cheated slightly by using the pre-expression on the property loader step to specify where th
    e data is coming from and where it's going to in the sequence on each iteration of the loop based on the Runstate.Loopindex.
    Another option is to go straight into the property loader step, and keep loading properties until the Step.Result.NumPropertiesRead = 0 (remember we're only doing this one at a time)
    Another idea would be to load in a value, and check it isn't a "flag" value (i.e. you'd never use say 999 in your array, so set the last element in your limits file to this, and drop out of the loop when this happens.
    Further still, you've got the source code for the property loader step, so you could re-write it to make a custom step that loads an array until it fails all on its own (no looping in TestStand).
    Hope this gets you going
    S.
    // it takes almost no time to rate an answer
    Attachments:
    DynamicPropertyLoader.seq ‏32 KB

  • How do I set the initial servlet pool size in WL 5.1

              In WL 4.5, I can set the initial servlet pool size using the
              weblogic.httpd.servlet.SingleThreadedModelPoolSize. I tried to set this property in WL 5.1, and get an "Found undeclared property..." message when booting WL. Is this feature still supported in WL 5.1? If so, how do I set it?
              Thankx
              

    It appears that pool size of 5 is hardcoded somewhere - no matter where you specify
              weblogic.httpd.servlet.SingleThreadedModelPoolSize, the following test servlet:
              import javax.servlet.*;
              import javax.servlet.http.*;
              public class SingleT extends HttpServlet implements SingleThreadModel {
              static int instanceCount = 0;
              public SingleT() {
              super();
              System.out.println("Instance " + (++instanceCount) + " created");
              always produces:
              Instance 1 created
              Wed Nov 01 11:15:36 PST 2000:<I> <ServletContext-General> SingleT: init
              Instance 2 created
              Wed Nov 01 11:15:36 PST 2000:<I> <ServletContext-General> SingleT: init
              Instance 3 created
              Wed Nov 01 11:15:36 PST 2000:<I> <ServletContext-General> SingleT: init
              Instance 4 created
              Wed Nov 01 11:15:36 PST 2000:<I> <ServletContext-General> SingleT: init
              Instance 5 created
              Wed Nov 01 11:15:36 PST 2000:<I> <ServletContext-General> SingleT: init
              Joe Trung <[email protected]> wrote:
              > Hi Huy,
              > There are lot of 'undeclared' stuffes if you move from 451 to 51.
              > However, if you run WLS with
              > '-Dweblogic.httpd.servlet.SingleThreadedModelPoolSize=10'
              > You will get what you want. I think BEA has moved this option to the <System props>, no more in its <config>
              > Joe
              > "Huy Pham" <[email protected]> wrote:
              >>
              >>In WL 4.5, I can set the initial servlet pool size using the
              >>weblogic.httpd.servlet.SingleThreadedModelPoolSize. I tried to set this property in WL 5.1, and get an "Found undeclared property..." message when booting WL. Is this feature still supported in WL 5.1? If so, how do I set it?
              >>
              >>Thankx
              Dimitri
              

  • Auto-indexing is slow for arrays with 1 dimensions

    Hi,
    I was looking at the performance of operations on all individual elements in 3D arrays, especially the difference between auto-indexing (left image) and manual-indexing (right image, calling "Index array" and "Replace array subset" in the innermost loop). I'm a bit puzzled by the results and post it here for discussion and hopefully somebody's benefit in the future.
    Left: auto-indexing; right: manual-indexing
    In the tests I added a different random number to all individual elements in a 3D array. I found that auto-indexing is 1.2 to 1.5 times slower than manual-indexing. I also found that the performance of auto-indexing is much more dependent on the size the dimensions: an array with 1000x200x40 elements is 20% slower than an array with 1000x40x200 elements. For manual-indexing there is hardly any difference. The detailed results can be found at the end of this post.
    I was under the impression that auto-indexing was the preferred method for this kind of operation: it achieves exactly the same result and it is much clearer in the block diagram. I also expected that auto-indexing would have been optimized in LabView, but the the tests show this is clearly not the case.
    What is auto-indexing doing?
    With two tests I looked at how auto-index works.
    First, I looked if auto-indexing reorganizes the data in an inefficient way. To do this I made a method "fake-auto-indexing" which calls "Array subset" and "Reshape array" (or "Index array" for a 1D-array) when it enters _every_ loop and calls "Replace array subset" when exiting _every_ loop (as opposed to manual-indexing, where I do this only in the inner loop). I replicated this in a test (calling it fake-auto-indexing) and found that the performance is very similar to auto-indexing, especially looking at the trend for the different array lengths.
    Fake-auto-indexing
    Second, I looked if Locality of reference (how the 3D array is stored in memory and how efficiently you can iterate over that) may be an issue. Auto-indexing loops over pages-rows-columns (i.e. pages in the outer for-loop, rows in the middle for-loop, columns in the inner for-loop). This can't be changed for auto-indexing, but I did change it for manual and fake-indexing. The performance of manual-indexing is now similar to auto-indexing, except for two cases that I can't explain. Fake-auto-indexing performs way worse in all cases.
    It seems that the performance problem with auto-indexing is due to inefficient data organization.
    Other tests
    I did the same tests for 1D and 2D arrays. For 1D arrays the three methods perform identical. For 2D arrays auto-indexing is 15% slower than manual-indexing, while fake-auto-indexing is 8% slower than manual-indexing. I find it interesting that auto-indexing is the slowest of the three methods.
    Finally, I tested the performance of operating on entire columns (instead of every single element) of a 3D array. In all cases it is a lot faster than iterating over individual elements. Auto-indexing is more than 1.8 to 3.4 times slower than manual-indexing, while fake-auto-indexing is about 1.5 to 2.7 times slower. Because of the number of iterations that has to be done, the effect of the size of the column is important: an array with 1000x200x40 elements is in all cases much slower than an array with 1000x40x200 elements.
    Discussion & conclusions
    In all the cases I tested, auto-indexing is significantly slower than manual-indexing. Because auto-indexing is the standard way of indexing arrays in LabView I expected the method to be highly optimized. Judging by the tests I did, that is not the case. I find this puzzling.
    Does anybody know any best practices when it comes to working with >1D arrays? It seems there is a lack of documentation about the performance, surprising given the significant differences I found.
    It is of course possible that I made mistakes. I tried to keep the code as straightforward as possible to minimize that risk. Still, I hope somebody can double-check the work I did.
    Results
    I ran the tests on a computer with a i5-4570 @ 3.20 GHz processor (4 cores, but only 1 is used), 8 GB RAM running Windows 7 64-bit and LabView 2013 32-bit. The tests were averaged 10 times. The results are in milliseconds.
    3D-arrays, iterate pages-rows-columns
    pages x rows x cols : auto    manual  fake
       40 x  200 x 1000 : 268.9   202.0   268.8
       40 x 1000 x  200 : 276.9   204.1   263.8
      200 x   40 x 1000 : 264.6   202.8   260.6
      200 x 1000 x   40 : 306.9   205.0   300.0
     1000 x   40 x  200 : 253.7   203.1   259.3
     1000 x  200 x   40 : 307.2   206.2   288.5
      100 x  100 x  100 :  36.2    25.7    33.9
    3D-arrays, iterate columns-rows-pages
    pages x rows x cols : manual  fake
       40 x  200 x 1000 : 277.6   457       
       40 x 1000 x  200 : 291.6   461.5
      200 x   40 x 1000 : 277.4   431.9
      200 x 1000 x   40 : 452.5   572.1
     1000 x   40 x  200 : 298.1   460.4     
     1000 x  200 x   40 : 460.5   583.8
      100 x  100 x  100 :  31.7    51.9
    2D-arrays, iterate rows-columns
    rows  x cols  : auto     manual   fake
      200 x 20000 :  123.5    106.1    113.2    
    20000 x   200 :  119.5    106.1    115.0    
    10000 x 10000 : 3080.25  2659.65  2835.1
    1D-arrays, iterate over columns
    cols   : auto  manual  fake
    500000 : 11.5  11.8    11.6
    3D-arrays, iterate pages-rows, operate on columns
    pages x rows x cols : auto    manual  fake
       40 x  200 x 1000 :  83.9   23.3     62.9
       40 x 1000 x  200 :  89.6   31.9     69.0     
      200 x   40 x 1000 :  74.3   27.6     62.2
      200 x 1000 x   40 : 135.6   76.2    107.1
     1000 x   40 x  200 :  75.3   31.2     68.6
     1000 x  200 x   40 : 133.6   71.7    108.7     
      100 x  100 x  100 :  13.0    5.4      9.9
    VI's
    I attached the VI's I used for testing. "ND_add_random_number.vi" (where N is 1, 2 or 3) is where all the action happens, taking a selector with a method and an array with the N dimensions as input. It returns the result and time in milliseconds. Using "ND_add_random_number_automated_test.vi" I run this for a few different situations (auto/manual/fake-indexing, interchanging the dimensions). The VI's starting with "3D_locality_" are used for the locality tests. The VI's starting with "3D_norows_" are used for the iterations over pages and columns only.
    Attachments:
    3D_arrays_2.zip ‏222 KB

    Robert,
    the copy-thing is not specific for auto-indexing. It is common for all tunnels. A tunnel is first of all a unique data space.
    This sounds hard, but there is an optimization in the compiler trying to reduce the number of copies the VI will create. This optimization is called "in-placeness".
    The in-placeness algorithm checks, if the wire passing data to the is connected to anything else ("branch"). If there is no other connection then the tunnel, chance is high that the tunnel won't create an additional copy.
    Speaking of loops, tunnels always copies. The in-placeness algorithm cannot opt that out.
    You can do a small test to elaborate on this: Simply wire "0" (or anything less than the array sizy of the input array) to the 'N' terminal.......
    Norbert
    PS: Auto-indexing is perfect for a "by element" operation of analysis without modification of the element in the array. If you want to modify values, use shift registers and Replace Array Subset.
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Unable to plot 1-D array with a cluster of 2 elements on an XY graph

    I'm Unable to plot a 1-D array with a cluster of 2 elements on an XY graph. The data appears at the input to the graph but nothing is plotted. I'm trying to plot a line connecting each point generated.
    Solved!
    Go to Solution.
    Attachments:
    TEST11.vi ‏13 KB

    Chuck,
    0. Do not post VIs with infinite loops! Change the True constant to a control.  One of the regular participants on these Forums has commented that using the Abort button to stop a VI is like using a tree to stop a car.  It works, but may have undesired consequences!
    1. Use a shift register on the For loop also.
    2. Inserting into an empty array leaves you with an empty array.  Initialize the array outside the loop to a size greater or equal to the maximum size you will be using.  Then use Replace Array Subest inside the loop.
    3. Just make an array of the cluster of points.  No need for the extra cluster.
    Lynn
    Attachments:
    TEST11.2.vi ‏11 KB

  • How to create an array with Generic type?

    Hi,
    I need to create a typed array T[] from an object array Object[]. This is due to legacy code integration with older collections.
    The method signature is simple:public static <T> T[] toTypedArray(Object[] objects)I tried using multiple implementations and go over them in the debugger. None of them create a typed collection as far as I can tell. The type is always Object[].
    A simple implementation is just to cast the array and return, however this is not so safe.
    What is interesting is that if I create ArrayList<String>, the debugger shows the type of the array in the list as String[].
    If I create ArrayList<T>, the class contains Object[] and not T[].
    I also triedT[] array = (T[]) Array.newInstance(T[].class.getComponentType(), objects.length);And a few other combinations. All work at runtime, create multiple compilation warnings, and none actually creates T[] array at runtime.
    Maybe I am missing something, but Array.newInstace(...) is supposed to create a typed array, and I cannot see any clean way to pass Class<T> into it.T[].class.getComponentType()Returns something based on object and not on T, and T.class is not possible.
    So is there anything really wrong here, or should I simply cast the array and live with the warnings?
    Any help appreciated!

    Ok. May be you could keep information about generic type in the your class:
    public class Util {
        public static <T> T[] toTypedArray(Class<T> cls, Object[] objects){
            int size = objects.length;
            T[] t = (T[]) java.lang.reflect.Array.newInstance(cls, size);
            System.arraycopy(objects, 0, t, 0, size);
            return t;
    public class Sample<T> {
        Class<T> cls;
        T[] array;
        public Sample(Class<T> cls) {
            this.cls = cls;
        public void setArray(Object[] objects){
            array = Util.toTypedArray(cls, objects);
        public T[] getArray(){
            return array;
        public static void main(String[] args) {
            Object[] objects = new Object[] { new LinkedList(), new ArrayList()};
            Sample<List> myClass = new  Sample<List>(List.class);
            myClass.setArray(objects);
            for(List elem: myClass.getArray()){
                System.out.println(elem.getClass().getName());
    }

Maybe you are looking for

  • Problems editing with iPhoto 6 - modified file has a mind of its own. Help!

    I have been working through info posted re difficulties storing edits. My modified file (once I eventually found it) appears to simply duplicate originals. Recent attempts show that edits are now being stored as ThumbJPGSegment data. Attempts to open

  • Editing Blind Folded to Color - Gradable Monitors

    I have been using a very subpar external monitor for CC, and grading. I purchased 2 - 28" LG LED monitor but it is definately too bright. Blacks are less black so when i CC video it show up as very dark or darker than expected on other viewing screen

  • How can i get the FLASH LITE 1.1 code for my mobile N-gage?

    Hi everybody: someone told me that send E-mail to [email protected],but the address had changed? i hope someone can told me way i get the code,thanks very much! MY PHONE MODEL: NOKIA N-GAGE MY IMEI NUMBER: 351520001877051 my e-mail:[email protected]

  • Electronic PO Transmission to the vendor systems

    I am new to PI , I have a scenario in which i have to send the PO document electronically to the supplier system in CXML format using XI interface and get the XML confirmation back from the supplier system and update the PO and once the confirmation

  • Cannot purchase records/"processing of credit card data not possible"

    Since last Tuesday I cannot buy records at iTunes store (Austria). Whenever I click the "purchase" button the systems sends back the message that "currently the processing of credit card data is not possible". That's interesting as I have been handli