discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Using Vectors instead of Arrays


From: 'Eric Blossom'
Subject: Re: [Discuss-gnuradio] Using Vectors instead of Arrays
Date: Sat, 22 Apr 2006 11:34:28 -0700
User-agent: Mutt/1.5.9i

On Sat, Apr 22, 2006 at 12:27:30PM -0400, Garrett Mcgrath wrote:
> Ack, string at the end there is supposed to be array.  Basically what I need
> to do is a series of modifications of some or all of the values in the
> array, and the size is constantly changing, so rather then have to malloc
> memory and figure out how malloc works all over again (I don't use it very
> often, I keep to the OOP for things like container objects.)

Sure, we use std::vectors all over the place in the implementation,
just not in the one place you asked about ;)

Also, no reason to use malloc in C++, just use new / delete, or new
combined with smart pointers to avoid figuring out when to call delete.

> For example here's what most of my current test code looks like (I'm making
> a small shell program to test the functions currently).:
> 
> //input stuff up here
> temp_int=array_doubler(temp_int);
> temp_int=array_sub_one(temp_int);
> temp_int=array_matrix_expansion(temp_int);  //the return of this is 2 times
> as large as the original one.
> temp_dub=array_matrix_division(temp_int, 2); // the 2 is just the divisor to
> divide all objects in the matrix by.
> 
> //output stuff down here
> 
> Now I know you can pass pointers in and out and work with arrays in that
> fashion, I just honestly hate doing it.  To many places for it to break.  So
> the 'temp_int' is populated by the input array at the start of general work,
> and I'm planning at the end of general work to just assign each position
> from the matrix to the corresponding position in the output array.

I guess I fail to understand the problem.  You can trivially construct
vectors from arrays and likewise can fish the raw data pointer and
length out of a vector.

Taking it to a higher level of abstraction, why wouldn't you be using
a linear algebra or other scientific library for your matrix manipulations?
E.g., gsl or vsipl++.

Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]