Tuesday, July 28, 2009

I know you can write a recursive functions that calls itself, but....?

can you write one function that calls another function, which in turn calls the first function? if so what is this called? is this another kind of recursion?





I'm trying to add member functions to the apmatrix class in C++.


right now i'm almost done with an adjoint function, which will return the adjoint of the specified element within the matrix. it looks something like this:





::adjoint (const int %26amp; row, const int %26amp; column)


{static apmatrix%26lt;itemType%26gt; tempmat;


tempmat = *this;


int value = 0;


tempmat = tempmat.submatrix(row, column);


//function submatrix returns the submatrix formed by deleting


// the row and column specified.


value = myMatrix[row][column] * tempmat.determinant();


return value;


}





similarily, .determinant() will call on .adjoint() to find the determinant, except in 2x2 matricies which are defined, to serve as the basis for the recursive loop? will this type of implementation work?

I know you can write a recursive functions that calls itself, but....?
I didn't look at your C++ code, but what you were describing is called indirect recursion.

salary survey

No comments:

Post a Comment