Rank: 54791 based on 0 downloads (last 30 days) and 0 files submitted
photo

Dominik Brands

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by Dominik View all
Updated File Comments Rating
27 Oct 2010 BlockMean Mean of rectangular submatrices, fast C-Mex (no running mean) Author: Jan Simon

Hi,
I want to use your BlockMean-Function with Matlab on Linux. But I got two errors on compiling.
First one using
mex -O CFLAGS="\$CFLAGS -std=C99" BlockMean.c
as written in the header of BlockMean.c results in
>> cc1: error: unrecognized command line option "-std=C99"
>> mex: compile of ' "BlockMean.c"' failed.
Okay, this error I correct by myself using the option "c99" instead of "C99" since Linux is case sensitive.
But then I get a new error
>> BlockMean.c: In function ‘mexFunction’:
>> BlockMean.c:181: warning: implicit declaration of function ‘_control87’
>> BlockMean.c:181: error: ‘MCW_PC’ undeclared (first use in this function)
>> BlockMean.c:181: error: (Each undeclared identifier is reported only once
>> BlockMean.c:181: error: for each function it appears in.)
>> BlockMean.c:182: error: ‘PC_64’ undeclared (first use in this function)
using the command
mex -O CFLAGS="\$CFLAGS -std=c99" BlockMean.c
For this I found a hint at
http://www.fortran-2000.com/ArnaudRecipes/CompilerTricks.html .
The varaibels MCW_PC and PC_64 are only available at windows. On the mentioned homepage there was show a trick for correct this under thetopic "Floating point precision mode". I do following changes to your code in BlockMean.c
The code-lines after "// Set the floating point precision:" I replace by the code given at the homepage. Additionally I remove the calls to "control87" under comment "// Set precision to 64 bit.." and "// Reset floating point precision"
and use instead the new functions "x86_SetPrecision" and "x86_RestorePrecision".
After compiling again no errors occur and the test with TestBlockMean was succesfully due to the messages from "TestBlockMean"

I hope this modifications was correct for you.
Regards
Dominik

07 Jan 2010 cutpolygon Cut alias slice alias split a 2D surface polygon by a line, and remove the specified part. Author: Jasper Menger

Sorry, I made a mistake during the copy/paste of the code
The second part must be:
                elseif xx3 > xx1
% modified/add lines
% compute intersection point
                    X3(i) = xx1; xp = xx1;
                    yp = interp1([xx3, xx4], [yy3, yy4], xx1, 'linear', 'extrap');
                    Y3(i) = yp;
% Original code
% X3(i) = xx1; xp = xx1; yp = yy3;
                elseif xx4 > xx1
% modified/add lines
% compute intersection point
                    X4(i) = xx1; xp = xx1;
                    yp = interp1([xx3, xx4], [yy3, yy4], xx1, 'linear', 'extrap');
                    Y4(i) = yp;
% Original code
% X4(i) = xx1; xp = xx1; yp = yy4;

I think, a similar code must be add to the part for horizontal cut-lines.

06 Jan 2010 cutpolygon Cut alias slice alias split a 2D surface polygon by a line, and remove the specified part. Author: Jasper Menger

Hi,
cutpolygon is a very helpful tool,
but I found one thing I do not understand.
If I cut a polygon by a vertical line, the intersection points
will not be computed correct. The value for the y-coordinate
will be taken from the first point which will be cut-out.

I modify your code at the following lines:
                elseif xx3 < xx1
% modified/add lines
% compute intersection point
                    X3(i) = xx1; xp = xx1;
                    yp = interp1([xx3, xx4], [yy3, yy4], xx1, 'linear', 'extrap');
                    Y3(i) = yp;
%r Original code
% X3(i) = xx1; xp = xx1; yp = yy3;
                elseif xx4 < xx1
% modified/add lines
% compute intersection point
                    X4(i) = xx1; xp = xx1;
                    yp = interp1([xx3, xx4], [yy3, yy4], xx1, 'linear', 'extrap');
                    Y4(i) = yp;
% Original code
% X4(i) = xx1; xp = xx1; yp = yy4;

and:
                elseif xx3 > xx1
% modified/add lines
% compute intersection point
                    xp = interp1([yy3, yy4], [xx3, xx4], yy1, 'linear', 'extrap');
                    X3(i) = xp; yp = yy3;
% Original code
% X3(i) = xx1; xp = xx1; yp = yy3;
                elseif xx4 > xx1
% modified/add lines
% compute intersection point
                    xp = interp1([yy3, yy4], [xx3, xx4], yy1, 'linear', 'extrap');
                    X4(i) = xp; yp = yy4;
% Original code
% X4(i) = xx1; xp = xx1; yp = yy4;

I hope that this would be a helpful comment for you.

Contact us at files@mathworks.com