Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Matrix resize for CNiScalarMatrix not preserving data!

If I do a resize on a matrix and increase the row size by one, the data is not properly preserved. The values remain in the matrix but their positions in the matrix are not correct. I was expecting to be able to append a vector to a matrix by increasing the number of rows using:
MyMatrix.Resize(MyMatrix.GetRows()+1, MyMatrix.GetCols());
Then use AssignRow to copy in the vector:
MyMatrix.AssignRow(MyMatrix.GetRows()-1, MyVector);

It does, however, work properly for an increase in columns. This works:
MyMatrix.Resize(MyMatrix.GetRows(), MyMatrix.GetCols()+1);
MyMatrix.AssignColumn(MyMatrix.GetCols()-1, MyVector);

Is this a bug or a feature?

Thanks,
Lyle
0 Kudos
Message 1 of 7
(3,953 Views)
Hello

I made a small program to test this out and it seems to work fine. The project is using MS 6.0 and VS 6.0.
I hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 7
(3,953 Views)
Hi,

I tried running your code and it works for square matricies, but it seems to have trouble with other sizes. Try running a 2x3 rather than a 2x2.

Here's what I get:
[
[ 0 1 2 ]
[ 3 4 5 ]
][
[ 0 1 2 ]
[ 2 3 4 ]
[ 23.51 389.1 277 ]
][
[ 0 1 2 23.51 ]
[ 2 3 4 389.1 ]
]

Thanks,
Lyle
0 Kudos
Message 3 of 7
(3,953 Views)
Hello,

I think I see the problem, please send an email in at ni.com/ask (choose Email NI from the drop down box), with the subject "Resize cnimatrix", so that we can document this and see if we can find a way around this

Thanks

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 4 of 7
(3,953 Views)
Lyle:

This is a known issue with Measurement Studio. This problem has already been fixed and is waiting to be released with the next version of Measurement Studio.

A peculiarity of the MSVC compiler requires that all template classes have their implementations available at compile time. Hence, the implementation for the CNiMatrixT<> class ships along with the other headers for Measurement Studio. The definition for the CNiMatrixT<>::Resize() function can be found in the file NiMatrix.inl in your MeasurementStudio/VC/Include directory. So, in the meantime, this problem can be easily corrected. I'm attaching the correct version of the definition, which you can cut-and-paste into your NiMatrix.h file, over the existing definition of Resize(). This should
fix the problem. Please let me know if it doesn't, or if there's anything else I can do.

Thanks,

Chris W.
Measurement Studio
National Instruments
0 Kudos
Message 5 of 7
(3,953 Views)
...And here is the attachment I forgot. Sorry!

-- Chris
0 Kudos
Message 6 of 7
(3,953 Views)

hi,Chris W.

i use VC6.0 and Measurement Studio 8.0

when i used the CNiMatrixT::Resize(),i found the same problem and i have tried your method

the attechment is the definition of Resize(),so i think i should cut and paste into NiMatrix.inl not NiMatrix.h.

However, there are more errors when i build my project.

so can you tell me the details of your method for the problem.

 

i'm a novice at C++ and Measurement Studio,so please try a more detailed

Thanks

Vivi Gao

 

 

0 Kudos
Message 7 of 7
(3,303 Views)