Click here to Skip to main content
15,867,453 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Vector of Class with Array Pin
CPallini19-Apr-19 10:32
mveCPallini19-Apr-19 10:32 
GeneralRe: Vector of Class with Array Pin
T Bones Jones19-Apr-19 11:04
T Bones Jones19-Apr-19 11:04 
GeneralRe: Vector of Class with Array Pin
Richard MacCutchan19-Apr-19 21:53
mveRichard MacCutchan19-Apr-19 21:53 
GeneralRe: Vector of Class with Array Pin
CPallini20-Apr-19 4:17
mveCPallini20-Apr-19 4:17 
GeneralRe: Vector of Class with Array Pin
T Bones Jones20-Apr-19 6:31
T Bones Jones20-Apr-19 6:31 
GeneralRe: Vector of Class with Array Pin
CPallini20-Apr-19 7:18
mveCPallini20-Apr-19 7:18 
GeneralRe: Vector of Class with Array Pin
Richard MacCutchan20-Apr-19 22:12
mveRichard MacCutchan20-Apr-19 22:12 
GeneralRe: Vector of Class with Array Pin
T Bones Jones22-Apr-19 4:52
T Bones Jones22-Apr-19 4:52 
It is reasonable that I am being asked about my Matrix class and its functions. However, since I have been using it for over 10 years, I am fairly confident that its bugs have been worked out. The matrix multiplication and inversion functions produce the results that should be expected. So, I really do not think the problem is there, and asking you to examine that voluminous code would probably not be useful.

If it helps, I tried the program written this way (differences on the last 7 lines):

for (unsigned i=0; i<frames; i++)
    {
     Matrix F(4,4); // functional alignment matrix
     double angle;
     F=BA.inverse() * Jtertiary.at(i) * MA; // tertiary axis functional alignment
     //Remove Tertiary Translation
     trans(x)=F(x,3);   trans(y)=F(y,3); trans(z)=F(z,3);
     trans(tertiaryaxis)=0;

     if (tertiaryaxis==X)
      {
       angle=ExtractX(F.inner(), RotationSequence);
       F=(Xrot(angle).transpose() * F.inner()).homogeneous();
       F(x,3)=0; F(y,3)=trans(y); F(z,3)=trans(z);
       F3.at(i)(1)=trans(x);   F3.at(i)(2)=trans(y); F3.at(i)(3)=trans(z);
     }
     else if (tertiaryaxis==Y)
      {
       angle=ExtractY(F.inner(), RotationSequence);
       F=(Yrot(angle).transpose() * F.inner()).homogeneous();
       F(x,3)=trans(x); F(y,3)=0; F(z,3)=trans(z);
       F3.at(i)(1)=trans(x);   F3.at(i)(2)=trans(y); F3.at(i)(3)=trans(z);
     }
     else if (tertiaryaxis==Z)
      {
       angle=ExtractY(F.inner(), RotationSequence);
       F=(Zrot(angle).transpose() * F.inner()).homogeneous();
       F(x,3)=trans(x); F(y,3)=trans(y); F(z,3)=0;
       F3.at(i)(1)=trans(x);   F3.at(i)(2)=trans(y); F3.at(i)(3)=trans(z);
     }
     else
        throw("ERROR: Tertiary Axis designation invalid for Three Axis Functional Alignment.\n");
     F3.at(i)(0)=degrees(angle);  //sets rotation about axis value into the final answer vector

     //E.push_back(BA * F * MA.inverse()); // revised J matrix without tertiary rotation
     Matrix er;
     er=BA * F * MA.inverse();
     cout << i << endl; // how many times through the loop
     er.dump();  // prints the matrix to the screen so that I can verify that it is a proper matrix     
     E.push_back(er); // when the program fails, this is where it happens 

     if (angle<minangle) minangle=angle;
     if (angle>maxangle) maxangle=angle;
    }


Again, the program can run several times without apparent error. When the error does occur it will even go several times through the for loop before it crashes. In the format I am giving here, it will print out the iteration of the loop and the matrix that was provided to the E vector (which should be pretty close to a 4x4 identity matrix).

The program just stops. No error messages are given. I've tried throw-catch around it, but I don't know what to catch here other than ..., and that doesn't work.

In my experience, odd behavior like this is due to a memory leak. But, the only place I can think of where memory is leaking would be if the Matrix destructor is not being called when the E (or other similar vectors like F3) goes out of scope.

Am I correct in this suspicion? If so, how do I invoke an array destructor before the vector of arrays goes out of scope?

I know that many of you want me to re-write the Matrix class with vectors instead of dynamic arrays. That may be the only correct ultimate solution to my problem. But right now, this is also an academic question about the proper use of a vector of arrays.

And, of course, if the vector of arrays issue is not my problem, then I am really lost and in greater need of any help that can be offered.

Thanks for the efforts so far, and for any efforts that appear in the future to help me solve this thing.
GeneralRe: Vector of Class with Array Pin
Richard MacCutchan22-Apr-19 5:52
mveRichard MacCutchan22-Apr-19 5:52 
GeneralRe: Vector of Class with Array Pin
Gerry Schmitz22-Apr-19 8:54
mveGerry Schmitz22-Apr-19 8:54 
QuestionConcept of namespace Pin
Aakashdata16-Apr-19 21:14
Aakashdata16-Apr-19 21:14 
AnswerRe: Concept of namespace Pin
Richard MacCutchan16-Apr-19 22:19
mveRichard MacCutchan16-Apr-19 22:19 
AnswerRe: Concept of namespace Pin
CPallini17-Apr-19 2:06
mveCPallini17-Apr-19 2:06 
AnswerRe: Concept of namespace Pin
harshalipatel17-Apr-19 2:19
harshalipatel17-Apr-19 2:19 
GeneralRe: Concept of namespace Pin
leon de boer20-Apr-19 0:11
leon de boer20-Apr-19 0:11 
GeneralRe: Concept of namespace Pin
Richard MacCutchan20-Apr-19 1:32
mveRichard MacCutchan20-Apr-19 1:32 
GeneralRe: Concept of namespace Pin
jschell21-Apr-19 7:33
jschell21-Apr-19 7:33 
QuestionPopularity Of C among developer Pin
Aakashdata14-Apr-19 21:31
Aakashdata14-Apr-19 21:31 
QuestionRe: Popularity Of C among developer Pin
Richard MacCutchan14-Apr-19 21:32
mveRichard MacCutchan14-Apr-19 21:32 
AnswerRe: Popularity Of C among developer Pin
Victor Nijegorodov14-Apr-19 21:40
Victor Nijegorodov14-Apr-19 21:40 
GeneralRe: Popularity Of C among developer Pin
Richard MacCutchan14-Apr-19 23:40
mveRichard MacCutchan14-Apr-19 23:40 
GeneralRe: Popularity Of C among developer Pin
CPallini15-Apr-19 1:33
mveCPallini15-Apr-19 1:33 
GeneralRe: Popularity Of C among developer Pin
Richard MacCutchan15-Apr-19 3:01
mveRichard MacCutchan15-Apr-19 3:01 
GeneralRe: Popularity Of C among developer Pin
Daniel Pfeffer15-Apr-19 4:19
professionalDaniel Pfeffer15-Apr-19 4:19 
GeneralRe: Popularity Of C among developer Pin
Victor Nijegorodov15-Apr-19 5:38
Victor Nijegorodov15-Apr-19 5:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.