Re: [eigen] problem with colwise/cross product

[ Thread Index | Date Index | More Archives ]

Another option is to map eigen matrices to numpy arrays.

I have done a SWIG typemaps.i for that purpose, it's quite primitive, and for sure buggy, but at least it helps for my purpose right now.

I attach the typemaps.i and the typedefs.h files, that I use.  There might be some unnecessary stuff in there.

By the way, any point outs about how to make these bindings better are very welcome.

Hope it can be useful in some way.


On Mon, Jan 5, 2009 at 3:27 PM, Benoit Jacob <jacob.benoit.1@xxxxxxxxx> wrote:
2009/1/5 Benoit Jacob <jacob.benoit.1@xxxxxxxxx>:
> It's no biggy to implement, so I do it and I update you.

Svn up, should work now.




Attachment: typemaps.i
Description: Binary data

** Copyright (C) 2008 Ricard Marxer <email@xxxxxxxxxxxxxxxxxxxx>
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or   
** (at your option) any later version.                                 
** This program is distributed in the hope that it will be useful,     
** but WITHOUT ANY WARRANTY; without even the implied warranty of      
** GNU General Public License for more details.                        
** You should have received a copy of the GNU General Public License   
** along with this program; if not, write to the Free Software         
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

#ifndef TYPEDEFS_H
#define TYPEDEFS_H

#define EIGEN_MATRIXBASE_PLUGIN "MatrixBaseAddons.h"

#include "debug.h"

#include <Eigen/Core>
#include <Eigen/Array>
#include <cmath>

// Types for scalar values
typedef int Integer;
typedef float Real;
typedef std::complex< Real > Complex;

// Types for vector values
typedef Eigen::Matrix< Integer, 1, Eigen::Dynamic > RowXI;
typedef Eigen::Matrix< Real, 1, Eigen::Dynamic > RowXR;
typedef Eigen::Matrix< Complex, 1, Eigen::Dynamic > RowXC;

typedef Eigen::Matrix< Integer, Eigen::Dynamic, 1 > ColXI;
typedef Eigen::Matrix< Real, Eigen::Dynamic, 1 > ColXR;
typedef Eigen::Matrix< Complex, Eigen::Dynamic, 1 > ColXC;

// Types for matrix values
typedef Eigen::Matrix< Integer, Eigen::Dynamic, Eigen::Dynamic > MatrixXI;
typedef Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic > MatrixXR;
typedef Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic > MatrixXC;

// Types for mapping Scipy matrices (these are RowMajor)
typedef Eigen::Matrix< Integer, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor, Eigen::Dynamic, Eigen::Dynamic > MatrixXIscipy;
typedef Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor, Eigen::Dynamic, Eigen::Dynamic > MatrixXRscipy;
typedef Eigen::Matrix< Complex, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor, Eigen::Dynamic, Eigen::Dynamic > MatrixXCscipy;

#endif // TYPEDEFS_H

Mail converted by MHonArc 2.6.19+