answersLogoWhite

0


Best Answer

An important part of IDL is the ability to work with data that is organized as vectors and arrays. We will first describe vectors and arrays and then show some tools for constructing them. Finally, we will demonstrate some of their uses. In addition to arrays of numbers, which we will describe here, there are also arrays of strings, structures and objects. You can look up information about them in IDL help if you are eager to find out about them now.

Arrays are especially important in signal image processing. We will find that images are just arrays of values with one value for each pixel. Vectors are important in the representation of one-dimensional functions such as functions of time or one spatial dimension.

Vectors

A vector is a list of data items, and can be constructed with an assignment statement like

A=[1.2, 3.1, 4.6, 5.7]

Note that square brackets are used to contain the list. Try typing a list like that shown above and then using HELP,A to get information about the vector.

Vectors can contain any of the number types that are accepted by IDL. When the assignment is made all of the numbers are converted to one type. The type that is used is determined by the data type hierarchy. Try typing

A=[1, 3B, 4L, 5.7] & HELP,A

IDL responds that A is an array of type FLOAT of length 4. If you were to type

A=[1, 3B, 4L, 5] & HELP,A

you would find that A is now of type LONG. The rule is to convert all of the numbers to the highest number type.

Arrays

We can think of a vector as a list that has one dimension. It is a row of data. An array is a list that is arranged in multiple dimensions. A two-dimensional array is a vector of vectors that are all of the same length.

C=[[1,2,3,4],[5,6,7,8],[7,6,5,4]] & PRINT,C

1 2 3 4

5 6 7 8

7 6 5 4

We see that A has three rows and four columns and that each row is one of the vectors in the list. An array can contain any of the IDL data types. When it is created all of the numbers are converted to the highest number type. We will describe a number of IDL functions for the construction of arrays. By using these functions one can construct arrays of up to eight dimensions.

Indexing

Column and Row Index

It is important to be able to refer to particular elements of an array. An element in column 1 and row 2 can be referred to by C[1,2]. In the above array we would find that C[1,2]=6. In IDL the column index comes before the row index.

Rows and columns are indexed beginning with the number 0. The column indexes of C are 0, 1, 2, 3 and the row indexes are 0, 1, 2. Zero-referenced indexing is a convention that may seem strange at first, but it has programming advantages.

One can refer to an entire row by using an asterisk in the column position. C[*,r] refers to the vector in row r. Try the command PRINT,C[*,2].

One can refer to an entire column by using an asterisk in the row position. C[col,*] refers to the vector in column col. Try the command PRINT,C[3,*].

A part of a row or column can be indexed by providing a list of the elements that are wanted. Try the following

row =[0,1,2] & col = [3,2,1] & PRINT,C[col,row]

Can you explain what is printed?

A contiguous segment of column or row elements can be referred to with the notation a:b. For example, C[0:2,2] refers to the elements in positions 0,1,2 in row 2. Try the command PRINT,C[0:2,2]

Array Index

Every element in an array has an array index. The array index is found by counting each element from the beginning of the array to the end row by row. An array that has four columns and three rows would have the indexes as shown below.

0 1 2 3

4 5 6 7

8 9 10 11

Any element in the array can be referred to by its array index. A list of elements in positions 0, 6 and 8 can be printed by

k=[0,6,8] & C[k]

One can find the value of array index from the row and column indexes. The number of columns, n, has to be known. Then k is simply

k = col + row*n

If k is given then the column and row indexes can be found by integer operations:

row = k/n

col = k - row*n

For an array with n=4 columns, C[6]=C[2,1]. You should try converting in both directions.

Array Creation Tools

IDL provides a number of functions that can be used to create arrays and initialize their values. The list can be found in the section "Array Creation Routines" in IDL Online Help. A subset of these routines are listed below.

BINDGEN Return a byte array with each element set to its subscript.

BYTARRCreate a byte vector or array.

FINDGEN Return a floating-point array with each element set to its subscript.

FLTARRReturn a floating-point vector or array.

INDGEN Return an integer array with each element set to its subscript.

INTARRReturn an integer vector or array.

LINDGEN Return a longword integer array with each element set to its subscript.

LONARRReturn a longword integer vector or array.

IDENTITY Return an identity array.

MAKE_ARRAYGeneral purpose array creation.

REPLICATEForm array of given dimensions filled with a value.

The functions BYTARR, FLTARR, INTARR, LONARR create arrays with of the type indicated by the first letter of the name and with their initial values set to zero. You can then enter data into them by assignment statements. For example, create an integer array of size 3x4 and set the elements of the first row to the value 3.

A=INDGEN(3,4)

A[*,0]=3

PRINT,A

The functions BINDGEN, INDGEN, FINDGEN, LINDGEN create arrays of the type indicated by the first letter of the name and with the initial values set to the array index. For example, create an array of type byte of size 3x4 and set its initial value to the index.

B=BINDGEN(3,4)

PRINT,B

0 1 2

3 4 5

6 7 8

9 10 11

The functions that generate index arrays are very useful in creating a vector of independent variables to be used in calculating and plotting a function. Suppose that you needed to plot the function (1+t2)Cos(5t) over the interval [0,3] in steps of size 0.01. You will then need a vector of 301 values t=[0, .01, .02, ..., 2.99, 3]. You certainly would not want to type all this in. The statements that will do the calculation and plot a graph are given below.

t=FINDGEN(301)/100 ;Generates the desired vector

f=(1+t^2)*cos(5*t) ;Calculates the function

plot,t,f ;Draws the graph

The IDENTITY function returns a square array of type float with the elements on the main diagonal set to 1 and all others set to zero. This function is very useful in many linear algebra computations.

I=IDENTITY(4)

PRINT,I

The REPLICATE function makes an array of the specified size in which a give value placed in all of the positions. To make a 5x2 array in which all of the elements contain the value 3.1 one can use

C=REPLICATE(3.1,5,2)

PRINT,C

The function MAKE_ARRAY is the most general array creation tool. It has many options which are best described by the online help documentation and the reference manual.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is vector and array processing?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which is better vector or array list?

It depends... If you want a speedy processing go for array list If you want thread safety go for a vector


What do string and vector and array all inherit from that has the size method so you can take it as an argument?

string, vector and array do not have a common base class. Overload your function to accept either a string, a vector or an array.


Main difference between Array List and Vector in Java?

List is not sync'd as a vector is.


What are the issues of Vector processing?

yes


Difference between vector and array list?

Vectors are thread safe but array lists are not. Hence array lists are faster than Vectors.


Is it the most efficient approach to access elements with the vector data structure?

Yes. A vector is a variable-length array but constant-time random-access is guaranteed regardless of an array's length.


Difference between pipeline and vector processing?

Pipeline processing involves a string of data processed in a chain reaction. This means the output of the first data point processing is the input of the next processing point. Vector processing involves a CPU and only one-dimensional arrays of data. This is similar to how a basic computer functions.


What is array processors?

array processor is a cpu or an extension to its arithmetic unit which is capable of performing simultaneous computation on the element of array or table of data in some number of dimension. or array processor is an extension to its arithmetic unit that implements instruction set containing instruction that operates on one dimensional array of data called vector. Debayan Basu: Array processor is a processor capable of processing array elements.It performs a single instruction in multiple execution units in the same clock cycle.In case of array processor parallelism is achieved by the multiplicity of processing elements each of which constitutes a distinct ALU in its own right.Array processors are of two types : 1)SIMD array processor & 2)Attached or Dedicated array processor hope i helped a bit :)


What is an array processor?

The array processor, is also commonly known as the Vector Processor.Array processing is signal processing of the outputs of an array of sensors to:Enhance the signal-to-interference-plus-noise ratio (SINR) compared to that of a single sensor using conventional or adaptive beamforming.Determine the number of emitting sources, the locations of these sources, their waveforms, and other signal parameters.Track multiple moving sources.See the related link for further information.


Why is an array called a derived data type?

An array is not a derived data type at all. In order to be derived there has to be a base class and an array has no base class. Here is the basic declaration of the std::array template class from the <array> header file: template<class _Ty, size_t _Size> class array { // fixed size array of values // ... }; A vector, on the other hand, is derived (from the <vector> header file): template<class _Ty, class _Alloc = allocator<_Ty>> class vector : public _Vector_alloc<!is_empty<_Alloc>::value, _Vec_base_types<_Ty, _Alloc>> { // varying size array of values // ... };


What are numbers lined up horizontally called?

A horizontal array or a row vector.


What is the Difference between array and vector processors?

Vector processor and Array processor are just the same thing, its a CPU design where instruction are set includes operations that can perform mathematical operations on multiple data elements simultaneously.