Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe19.iad.POSTED!f8a62740!not-for-mail
From: Geico Caveman <spammers-go-here@spam.invalid>
Newsgroups: comp.soft-sys.matlab
Message-ID: <2009110421001016807-spammersgohere@spaminvalid>
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> <hctanf$dbk$1@fred.mathworks.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Subject: Re: mxGetNumberOfDimensions missing ?
User-Agent: Unison/1.8.1
Lines: 88
X-Complaints-To: abuse@teranews.com
NNTP-Posting-Date: Thu, 05 Nov 2009 04:00:10 UTC
Organization: TeraNews.com
Date: Wed, 4 Nov 2009 21:00:10 -0700
Xref: news.mathworks.com comp.soft-sys.matlab:582609


On 2009-11-04 18:45:19 -0700, "James Tursa" 
<aclassyguy_with_a_k_not_a_c@hotmail.com> said:

> 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.

Can I email it to you ?

> 
>> 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 ...

No problem.

> 
> 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.

Sounds interesting. Maybe you could post this to Matlab's code exchange 
once it is ready.

> 
> 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?

Yes. Basically  have three indices. I would want to be able to access 
the 3D array pointed to for manipulation in Matlab and Fortran.

I am still a little uncomfortable with all those *4 and *8 as I got 
used to the "Use the selected_int_kind() school for maximum code 
portability" school. But if it works, it works.