vl_rodr.c
Go to the documentation of this file.
00001 /* file:        rodr.mex.c
00002 ** author:      Andrea Vedaldi
00003 ** description: Rodrigues formula
00004 **/
00005 
00006 /*
00007 Copyright (C) 2007-12 Andrea Vedaldi and Brian Fulkerson.
00008 All rights reserved.
00009 
00010 This file is part of the VLFeat library and is made available under
00011 the terms of the BSD license (see the COPYING file).
00012 */
00013 
00014 #include <mexutils.h>
00015 
00016 #include <vl/generic.h>
00017 #include <vl/rodrigues.h>
00018 
00019 enum {
00020   IN_OM = 0
00021 } ;
00022 
00023 enum {
00024   OUT_R=0,
00025   OUT_DR
00026 } ;
00027 
00028 /* -------------------------------------------------------------------
00029 **                                                              Driver
00030 ** ---------------------------------------------------------------- */
00031 
00032 void
00033 mexFunction(int nout, mxArray *out[],
00034             int nin, const mxArray *in[])
00035 {
00036   int k,K ;
00037   double const * om_pt ;
00038   double* R_pt ;
00039   double* dR_pt ;
00040 
00041   if(nin != 1) {
00042     mexErrMsgTxt("Exactly one argument required.") ;
00043   }
00044 
00045   if(!vlmxIsMatrix(in[IN_OM],-1,-1)) {
00046     mexErrMsgTxt("OM must be a DOUBLE array") ;
00047   }
00048 
00049   K = mxGetNumberOfElements(in[IN_OM]) ;
00050   if(K % 3 || K < 3) {
00051     mexErrMsgTxt("The number of elements of OM must be a multiple of 3") ;
00052   }
00053   K /= 3 ;
00054   om_pt = mxGetPr(in[IN_OM]) ;
00055 
00056   /* space for output (R) */
00057   if( K == 1 ) {
00058     out[OUT_R] = mxCreateDoubleMatrix(3,3,mxREAL) ;
00059   } else {
00060     mwSize dims [3] ;
00061     dims[0] = 3 ; dims[1] = 3 ; dims[2] = K ;
00062     out[OUT_R] = mxCreateNumericArray(3,dims,mxDOUBLE_CLASS,mxREAL) ;
00063   }
00064   R_pt = mxGetPr(out[OUT_R]) ;
00065 
00066   /* space for optional output (dR) */
00067   dR_pt = NULL ;
00068   if( nout > 1 ) {
00069     if( K == 1 ) {
00070       out[OUT_DR] = mxCreateDoubleMatrix(9,3,mxREAL) ;
00071     } else {
00072       mwSize dims [3] ;
00073       dims[0] = 9 ; dims[1] = 3 ; dims[2] = K ;
00074       out[OUT_DR] = mxCreateNumericArray(3,dims,mxDOUBLE_CLASS,mxREAL) ;
00075     }
00076     dR_pt = mxGetPr(out[OUT_DR]) ;
00077   }
00078 
00079   /* -----------------------------------------------------------------
00080   **                                                           Process
00081   ** -------------------------------------------------------------- */
00082   for(k = 0 ; k < K ; ++k) {
00083     vl_rodrigues(R_pt, dR_pt, om_pt) ;
00084     om_pt += 3 ;
00085     R_pt  += 3*3 ;
00086     dR_pt += 9*3 ;
00087   }
00088 }


libvlfeat
Author(s): Andrea Vedaldi
autogenerated on Thu Jun 6 2019 20:25:51