Changeset 15768
- Timestamp:
- Dec 7, 2007, 3:48:34 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psMatrix.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psMatrix.c
r15767 r15768 22 22 * @author Andy Becker, University of Washington (SVD). 23 23 * 24 * @version $Revision: 1.5 0$ $Name: not supported by cvs2svn $25 * @date $Date: 2007-12-08 01: 31:58$24 * @version $Revision: 1.51 $ $Name: not supported by cvs2svn $ 25 * @date $Date: 2007-12-08 01:48:34 $ 26 26 * 27 27 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 42 42 #include <gsl/gsl_eigen.h> 43 43 44 #include "psAbort.h" 44 45 #include "psMemory.h" 45 46 #include "psError.h" … … 657 658 } 658 659 659 psImage* psMatrixTranspose(psImage* out, 660 const psImage* in) 661 { 662 psU32 i = 0; 663 psU32 j = 0; 664 psS32 numRowsIn = 0; 665 psS32 numColsIn = 0; 666 psS32 numRowsOut = 0; 667 psS32 numColsOut = 0; 668 669 #define TRANSPOSE_CLEANUP { psFree(out); return NULL; } 660 psImage* psMatrixTranspose(psImage* out, const psImage* in) 661 { 670 662 // Error checks 663 #define TRANSPOSE_CLEANUP { return NULL; } 671 664 PS_ASSERT_GENERAL_IMAGE_NON_NULL(in, TRANSPOSE_CLEANUP); 672 665 PS_CHECK_DIMEN_AND_TYPE(in, PS_DIMEN_IMAGE, TRANSPOSE_CLEANUP); … … 674 667 PS_CHECK_POINTERS(in, out, TRANSPOSE_CLEANUP); 675 668 676 out = psImageRecycle(out, in->numCols, in->numRows, in->type.type); 677 678 // Initialize data 679 numRowsIn = in->numRows; 680 numColsIn = in->numCols; 681 numRowsOut = out->numRows; 682 numColsOut = out->numCols; 683 684 if(numRowsIn!=numColsOut && numRowsOut!=numColsIn) { 685 psError(PS_ERR_BAD_PARAMETER_VALUE, true, _("Number of rows do not match number of columns.")); 686 TRANSPOSE_CLEANUP; 687 } 688 689 if(out->type.type == PS_TYPE_F32) { 690 for(i=0; i<numRowsOut; i++) { 691 for(j=0; j<numColsOut; j++) { 692 out->data.F32[i][j] = in->data.F32[j][i]; 693 } 694 } 695 } else { 696 for(i=0; i<numRowsOut; i++) { 697 for(j=0; j<numColsOut; j++) { 698 out->data.F64[i][j] = in->data.F64[j][i]; 699 } 700 } 669 int numCols = in->numRows, numRows = in->numCols; // Size of transposed image 670 psElemType type = in->type.type; // Data type 671 672 out = psImageRecycle(out, numCols, numRows, type); 673 674 #define TRANSPOSE_CASE(TYPE) \ 675 case PS_TYPE_##TYPE: { \ 676 for (int i = 0; i < numRows; i++) { \ 677 for (int j = 0; j < numCols; j++) { \ 678 out->data.TYPE[i][j] = in->data.TYPE[j][i]; \ 679 } \ 680 } \ 681 break; \ 682 } 683 684 switch (type) { 685 TRANSPOSE_CASE(F32); 686 TRANSPOSE_CASE(F64); 687 default: 688 psAbort("Unsupported type: %x", type); 701 689 } 702 690
Note:
See TracChangeset
for help on using the changeset viewer.
