Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: mxGetNumberOfDimensions missing ?
Date: Thu, 5 Nov 2009 01:45:19 +0000 (UTC)
Organization: Boeing
Lines: 52
Message-ID: <hctanf$dbk$1@fred.mathworks.com>
References: <2009102112385016807-spammersgohere@spaminvalid> <hbnv28$c5h$1@fred.mathworks.com> <2009102115045916807-spammersgohere@spaminvalid> <hbo6a4$k5l$1@fred.mathworks.com> <2009102311375416807-spammersgohere@spaminvalid> <hc56i5$3p4$1@fred.mathworks.com> <hc5jrq$b1n$1@fred.mathworks.com> <hc7ebk$8nl$1@fred.mathworks.com> <2009110417351816807-spammersgohere@spaminvalid>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257385519 13684 172.30.248.35 (5 Nov 2009 01:45:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 5 Nov 2009 01:45:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:582586


Geico Caveman <spammers-go-here@spam.invalid> wrote in message <2009110417351816807-spammersgohere@spaminvalid>...
> 
> I went over your arguments with some interest.
> 
> Makes sense. I do have a bigger problem than things not compiling. I am 
> still mystified by the fact that mxGetData compiles but 
> mxGetNumberofDimensions (or mxGetDimensions) does not.

I can't answer that without seeing your actual interface code. You gave me some links, but those were to other interfaces, not the modified one you are actually using.

> Be it so, can you post the working code example with a 3D array use, if 
> possible, as you promised ?
> 
> At this point, the interface appears to be such a mess (when is Matlab 
> going to make use of the fact that Fortran has had pointers for about 
> 10-12 years now ?), that I am almost tempted to code completely in 
> Fortran (using gnuplotfortran or dislin for graphic o/p). However, I 
> prefer matlab's plotting capabilities, so I want to stick with it long 
> term.

Sorry for the delay. As usual, I got carried away with this. I have working code, but it is not polished yet. If you can be patient just a little bit longer, I will try to finish it up in the next couple of days and post by the weekend. Basically, how would you like to be able to do this ...

use MatlabAPImx
     :
mwPointer plhs(*), prhs(*)
real*8, pointer :: Apr(:,:)
     :
Apr => fpGetPr(prhs(1))  ! fpGetPr is a function I wrote
     :

... and then from that point on use Apr as a regular Fortran matrix? e.g., you can use it in whole array computations and assignments, as a matrix in explicit interfaces, do direct array slice indexing with it, etc. etc. etc. Apr is a pointer directly into the pr area of prhs(1) with *no* data copying involved. Very efficient and easy to use.  I also have reshape code with *no* data copying involved (the Fortran intrinsic reshape does a data copy).  Also, how about this ...

real*8, pointer :: Apr(:,:)
     :
Apr => fpAllocate(4,6)  ! fpAllocate is a function I wrote
     :

... and then from that point on use Apr just like above. The difference between this and the Fortran allocate intrinsic is that behind fpAllocate is the mxMalloc function, so the memory is all part of the MATLAB memory manager and will get garbage collected if necessary.

What, specifically, do you want as a 3D example?  e.g., with my code you will be able to do this:

use MatlabAPImx
     :
mwPointer plhs(*), prhs(*)
real*8, pointer :: Apr(:,:,:)  ! <-- 3D pointer
     :
Apr => fpGetPr3(prhs(1))  ! fpGetPr3 returns a 3D result
     :

Is that what you are looking for?

James Tursa