dimSize - make- matrixOp

 

 

Hello -

I'm trying to get a handle on why dimsize(waveName, 1) returns 0 for waves where only rows are specified in during the make command. Ex. Make/o/n = 1 waveName

I had always assumed that the first column was "there" by default when only rows were specified during the make command.

This is a issue in some code I'm developing because I'm relying on the value dimsize returns from one wave to determine the number of columns in a second wave.

One additional point is that waves that show as having one column entering a matrixop, return showing 0 columns (according to dimsize).

Thanks.

 

 

You have run into an unfortunate inconsistency in Igor. A wave with non-zero columns is considered to be a multidimensional wave. A wave with N rows and 1 column is a one-column matrix, while a wave with N rows and 0 columns is 1D wave. Of course, they should be functionally equivalent, and many of our built-in functions and operations have been written to accept either one where a 1D wave is required. But not all have been, and in general, dialogs for operations that require a 1D wave will reject a wave with 1 column.

I think the MatrixOP behavior you cite is an instance in which MatrixOP is trying to be helpful- it is converting the 1-column "matrix" into a true 1D wave for you. That conversion may save some problems associated with the 1-column matrix not being accepted as a 1D wave in some places in Igor.

The explanation for this unfortunate behavior lies in history and the internal structure used to define multi-D waves. Back in the mists of time Igor had only 1D waves, and there is a member of the wave structure that gives the number of points. When Multi-D waves were added, we added a four-element array to the wave structure that gives the number of elements in each dimension. That means that for a 1D wave there are two members of the structure that give the number of points. It also means that the array having the elements {N, 1, 0, 0} is often treated differently from the array having elements {N, 0, 0, 0}. It would have been nice if this programming construct didn't leak out into areas that our users have to deal with!

On the other hand, one consequence of this programming construct and Igor's history, is that a multi-D wave can generally be passed to an operation taking a 1D wave, and that operation will simply treat it as a 1D wave. That is actually useful surprisingly often.

Hope this helps you to at least understand what is going on.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
johnweeks wrote:

Hope this helps you to at least understand what is going on.


It helps a lot! Thank you.

johnweeks wrote:

It would have been nice if this programming construct didn't leak out into areas that our users have to deal with!


Maybe I don't need to deal with it? I went down this road because I am attempting to place the values from a row with variable number of columns into a different wave using "q".

Ex. TPStorageWave[TestPulseCycleCount][][0] = BaselineSSAvg[0][q][0]

I found that the waves needed the same number of columns or I had an index out of range error. My solution was to make the waves have the same number of columns.

For now, I've inelegantly handled the the 0 column return from dimsize with an if statement Ex. if(dimsize(wavename, 1) == 0). Is there a command that returns the dimension status of a wave i.e. "true" 1D or Multi-D?

- Tim
Quote:
For now, I've inelegantly handled the the 0 column return from dimsize with an if statement Ex. if(dimsize(wavename, 1) == 0). Is there a command that returns the dimension status of a wave i.e. "true" 1D or Multi-D?

If DimSize(wavename, 1) returns 0, then it is a "true" 1D wave. If it returns 1 and DimSize(wavename,2) returns 0, then it is a 1-column matrix.

But maybe your problem is a misunderstanding of how to transfer your points.
Quote:
Ex. TPStorageWave[TestPulseCycleCount][][0] = BaselineSSAvg[0][q][0]

if BaselineSSAvg is a 1D wave, then you need the q in the first set of brackets. And then BaselineSSAvg must have the same number of rows as TPStorageWave has columns.
Quote:
Maybe I don't need to deal with it? I went down this road because I am attempting to place the values from a row with variable number of columns into a different wave using "q".

OK. I re-read that statement and now I'm not so sure I understand what you want. I suggest reading this:
DisplayHelpTopic "Multidimensional Wave Assignment"
to get a better understanding of what all the p's and q's are. Then try again here, spelling out what you want as if you were talking to your mother :)

At the least, tell me the dimensions of the two waves involved there, and what part of the right side you want transferred to the left side, and where in the left side you want it.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com