Initializations for very large arrays.


 
Thread Tools Search this Thread
Top Forums Programming Initializations for very large arrays.
# 1  
Old 02-21-2003
Question Initializations for very large arrays.

Hello,

I am facing problems initializing very large arrays of linked list types. The problem is it takes too much of time. The array iterations are around few millions.

The array elements are of type "double".

I have arrays of linked lists. Each element of the array need to be
initialized to "-1.0" not even zero.

I tried to use memset(), but is it is not working.

Please advice/suggest.

Thanks,
-Jay.


Last edited by Jayathirtha; 02-21-2003 at 11:08 AM..
# 2  
Old 02-21-2003
You tell us that you have an array of linked lists. But the type of the array is double. And you want to initialize it to -1.

(double) -1.0 is a very odd linked list. Could you post your data structure? I can't visualize what it is that you're trying to do.
# 3  
Old 02-21-2003
Initialization of very large array

Here is the structure :

struct pvcrates_ {
double speed,
fr_oneway[MAXREGION + ATMREGION],
fr_twoway[MAXREGION + ATMREGION],
atma_oneway[MAXREGION + ATMREGION],
atma_twoway[MAXREGION + ATMREGION],
atmc_oneway[MAXREGION + ATMREGION],
atmc_twoway[MAXREGION + ATMREGION],
fr_onewayinst[MAXREGION + ATMREGION],
fr_twowayinst[MAXREGION + ATMREGION],
atma_onewayinst[MAXREGION + ATMREGION],
atma_twowayinst[MAXREGION + ATMREGION],
atmc_onewayinst[MAXREGION + ATMREGION],
atmc_twowayinst[MAXREGION + ATMREGION],
e_fr_twoway[MAXREGION + ATMREGION],
e_fr_twowayinst[MAXREGION + ATMREGION],
siw_twoway[MAXREGION + ATMREGION],
siw_twowayinst[MAXREGION + ATMREGION],
siw_oneway[MAXREGION + ATMREGION],
siw_onewayinst[MAXREGION + ATMREGION];
struct pvcrates_ *next;
};

pvcrates is a linked list. This structure has arrays that store values of type "double".

Thanks,
- Jay.
# 4  
Old 02-21-2003
I guess that I would allocate one pvcrates_ structure and call it init_pvcrates_. Then I would fill it up the way I want a pvcrates_ to look after it is initialized. Then after I allocate each new pvcrates_ structure, I would memcpy init_pvcrates_ into it. I don't believe that there is any faster way to initialize your structure.

If you aren't using the highest level of optimization that your complier has available, give that a try. It can make a big difference if the compiler is well written.
# 5  
Old 02-22-2003
Thanks Perderabo,

It works.

Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash arrays: rebin/interpolate smaller array to large array

hello, i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N. for case 1, I want to stretch N to fit M arrayHuge H = (... (2 Replies)
Discussion started by: f77hack
2 Replies

2. UNIX for Dummies Questions & Answers

Arrays

Am using bash For eg: Suppose i have a array arr=(1 2 3 4 5 6 7 8 9 10 11 12) suppose i give input 5 to a script and script should able to print values greater than or equal to 5 like below: Input: 5 output: 5,6,7,8,9,10,11,12 (7 Replies)
Discussion started by: manid
7 Replies

3. Shell Programming and Scripting

Using arrays?

I have never used arrays before but I have a script like this: var1=$(for i in $(cat /tmp/jobs.021013);do $LIST -job $i -all | perl -ne 'print /.*(\bInfo.bptm\(pid=\d{3,5}).*/' | tr -d "(Info=regpid" | tr -d ')'; $LIST -job $i -all | cut -f7 -d','| sed -e "s/^\(*\)\(*\)\(*\)\(.*\)/\1... (2 Replies)
Discussion started by: newbie2010
2 Replies

4. Programming

Arrays in C++

I've noticed something interesting in C++ programming. I've always done tricky stuff with pointers and references to have functions deal with arrays. Doing exercises again out of a C++ book has shown me an easier way, I didn't even know was there. It's weird to me. When dealing with arrays, it... (4 Replies)
Discussion started by: John Tate
4 Replies

5. Shell Programming and Scripting

How can I use the arrays ?

Hi all, I have a file test1.txt with the below contents abc def ghj xyz I tried printing these values using arrays. Script tried : =========== set -A array1 `cat test1.txt` count=${#array1 } i=0 while do echo "element of array $array1" done (1 Reply)
Discussion started by: dnam9917
1 Replies

6. Programming

question about int arrays and file pointer arrays

if i declare both but don't input any variables what values will the int array and file pointer array have on default, and if i want to reset any of the elements of both arrays to default, should i just set it to 0 or NULL or what? (1 Reply)
Discussion started by: omega666
1 Replies

7. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

8. UNIX for Dummies Questions & Answers

arrays how to?

Hello, I am some what of a newbie to awk scripting and I seem to be struggling with this problem. I know I need to use arrays but I can't figure out how to use them. I have an input file that looks like this; Name,Team,First Test, Second Test, Third Test Crystal,Red,5,17,22... (1 Reply)
Discussion started by: vlopez
1 Replies

9. Web Development

PHP arrays in arrays

PHP question... I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names. So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person with values "Fred", "Bert", "Tom" etc So what I want to do is display the... (3 Replies)
Discussion started by: JerryHone
3 Replies

10. Shell Programming and Scripting

Arrays

Dear all, How can i unset arrays. I mean all the subscripts including the array after using them. Could you direct me to some links of array memory handling in the korn shell. Thanks (2 Replies)
Discussion started by: earlysame55
2 Replies
Login or Register to Ask a Question