Rank: 56 based on 3976 downloads (last 30 days) and 19 files submitted
photo

James Tursa

E-mail
Lat/Long
47.68167, -122.2075

Personal Profile:

Interested in external applications, mex & engine applications with Fortran, C, C++, etc.

Professional Interests:

 

Watch this Author's files

 

Files Posted by James View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
23 Oct 2009 Screenshot num2vpi - Converts input exactly into vpi Converts double inputs larger than 2^53-1, or char inputs with exponents, exactly into vpi. Author: James Tursa vpi, precision, variable, integer 103 0
25 Sep 2009 Screenshot Fortran mex routine mxGetClassName A drop-in replacement for the TMW Fortran API function mxGetClassName routine that does not work. Author: James Tursa fortran, mxgetclassname, mex, class name 221 0
05 Aug 2009 Screenshot num2strexact (exact version of num2str) num2strexact does exact conversion of number to string based on IEEE floating point bit pattern Author: James Tursa num2strexact, str2num, sprintf, num2str, precision, printf 227 0
05 Aug 2009 Screenshot swapbytes C-mex function swapbytes(X1,X2,...) reverses byte ordering of each element, little-endian values to/from big-endian Author: James Tursa swapbytes, external interface, reverse byte ordering, littleendian, endian, bigendian 202 0
  • 5.0
5.0 | 1 rating
05 Aug 2009 Screenshot typecast C-mex function typecast.c is a mex function intended to mimic the MATLAB intrinsic of the same name Author: James Tursa typecast, external interface, cast, mex, external code interfa... 204 0
Comments and Ratings by James View all
Updated File Comments Rating
01 Sep 2009 Sin Cos 01 Find the zero and one degree values. Author: M P

Wow, I think I am finally getting this stuff. I have to admit it took be awhile to get the meaning of your other posts, but this one for some reason just stood out. These lines from your description were the key:

POSitive half unity: 51
POSitive unity: 102

After that it was simply putting this together with both of these lines:

X = sin(360°)
180 = sin(360°)

to get that this was a POSitive Program Of Sines (POS), or POS POS! Yeah, I finally got it! So I think you should re-title this submission as:

POS POS: Sin Cos 01

28 Aug 2009 The Four Zero System Circle: the 50.5 business. Author: M P

I had a hard time understanding what kind of Program this is. There is so much going on. I waded through all of your descriptions without grasping the meaning. Is it a Program Of Zeros, a Program Of Degrees, etc. etc.? What finally cleared things up was the last two lines of your description:

The SUM of the four circle equilibrium points is always 742°.

The circle equilibrium solution more one is always 7 times the zero of the four equilibrium points less the SUM of the four circle equilibrium points.

Aha! SUM! So I finally understood ... this is a Program Of Sums (POS). It would help others to understand your code if you updated the title to reflect this. So maybe change the title to:

POS: The Four Zero System

28 Aug 2009 mexSparseLogical0Diag Change all the elements on the main diagonal of a logical sparse matrix to 0. Author: Guy

A few suggestions for improvement:

1) Don't use bool to point to the MATLAB logical data. MATLAB supplies a data type for this, mxLogical. Using bool only sets you up for an unexpected failure on machines where sizeof(bool) is not 1.

2) Don't use nz to allocate the memory for the new array. There might be a lot of wasted space involved in the input array and there is not point in propagating that waste. Instead, just go get the actual number of current non-zero elements and use that, since you know your result will not be larger than this. e.g.,

    mwSize n, n2;
    jc = mxGetJc(prhs[0]);
    n = mxGetN(prhs[0]);
    nz = jc[n];
        :
    v = mxCreateSparseLogicalMatrix (m, n, nz);

3) There is no code to realloc the memory if a large percentage was reset to zero. e.g., an input matrix that is nearly the same as an identity matrix. Although not an error, you might think about including this.

4) I know you supplied an m-file with the help (very good), but it might be good to copy the calling info into the cpp source file so that a user can have this all in one file when editing the source. Again, not an error but it helps others to read your code.

5) Your nlhs test isn't the best, as it doesn't cover some possible erroneous inputs (e.g., what if user tries to fill two output variables?):

if (nlhs > 0)
plhs[0] = v;

 A better method is as follows:

// at the beginning of your code:
    if( nlhs > 1 ) {
        mexErrMsgTxt("Too many outputs, expecting at most one.");
}

// at the end of your code
    plhs[0] = v;

i.e., at the end of your code don't do any test, just set plhs[0]. That way it will work if the user doesn't try to set the result to any variable ... in that case the result simply goes into ans. This always works, even if nlhs == 0.

6) You might consider making this a self-building mex routine. For an example of this, see one of my submissions, e.g.,

http://www.mathworks.com/matlabcentral/fileexchange/22239

7) With some very minor tweaking, you could also supply a C source code version so the users that only have access to the supplied lcc compiler can use this out of the box.

The code appears to work fine, and is indeed much faster than a loop. I would probably rate it a 3 at this point, but I will wait for author's response to my comments before rating and may go higher.

20 Aug 2009 MATLAB rooms KMN Color simulation of the neural instants physicity. Author: M P

Like previous submissions, I think you have another naming problem here. This is obviously a Profundity submission, but a Profundity of *what*? Fortunately, this can easily be obtained from these few lines near the top of your description:

red profundity = 0
green profundity = 0
blue profundity = 0
red time [s] = 2
green time [s] = 2
blue time [s] = 2

By looking at the units used following your profundity lines, it becomes obvious that this is a Profundity Of Seconds, or POS. So you should rename the title of your submission to:

POS: MATLAB rooms KMN

15 Aug 2009 Fortran Logical mex functions Fortran mex routines for converting logicals to/from MATLAB mxArray variables Author: James Tursa

Thanks for the 5* rating. The #define for mwSize is needed for older versions of MATLAB that do not have this. That way the same source code can be used with either newer or older versions. I am a bit surprised that the .for extension didn't work ... I had no idea there was a Fortran compiler out there that didn't know what to do with a .for file! But this is good to know. In the future I will use .f extensions (or .f90) for my Fortran submissions.

Comments and Ratings on James' Files View all
Updated File Comment by Comments Rating
15 Aug 2009 Fortran Logical mex functions Fortran mex routines for converting logicals to/from MATLAB mxArray variables Author: James Tursa Tursa, James

Thanks for the 5* rating. The #define for mwSize is needed for older versions of MATLAB that do not have this. That way the same source code can be used with either newer or older versions. I am a bit surprised that the .for extension didn't work ... I had no idea there was a Fortran compiler out there that didn't know what to do with a .for file! But this is good to know. In the future I will use .f extensions (or .f90) for my Fortran submissions.

12 Jun 2009 bsxfun bsxfun is a functional substitute for MATLAB intrinsic of the same name Author: James Tursa Tursa, James

A better bsxfun substitute can be found here by Doug Schwarz:
http://www.mathworks.com/matlabcentral/fileexchange/23005

21 Apr 2009 Fortran Logical mex functions Fortran mex routines for converting logicals to/from MATLAB mxArray variables Author: James Tursa Clark, Thomas

Incidentally, I got this to work in Linux (openSUSE10.3 with gcc 4.1.2 compiler). All I needed to do was change the extensions:
testLogicalFunctions.for becomes
testLogicalFunctions.F90
and
mxLogicalFunctions.for becomes
mxLogicalFunctions.f
Why? Something to do with recognising which files are include files and which aren't (there's no standard include in FORTRAN).

21 Apr 2009 Fortran Logical mex functions Fortran mex routines for converting logicals to/from MATLAB mxArray variables Author: James Tursa Clark, Thomas

Wow, this just got me out of a very nasty fix (I came to the end of 400 lines of Fortran, then realised I couldn't pass the logical result back!).

Thanks, James, 5*

Although, if I were nit-picking, I probably wouldn't have added the type definitions of mwSize etc - I think to prevent confusion it'd be better to throw an error if they aren't defined - and keep their definitions all in one place (typically the fintrf.h file).

13 Nov 2008 swapbytes C-mex function swapbytes(X1,X2,...) reverses byte ordering of each element, little-endian values to/from big-endian Author: James Tursa Pei

Top Tags Applied by James
external interface, mex, precision, fortran, bit
Files Tagged by James View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
23 Oct 2009 Screenshot num2vpi - Converts input exactly into vpi Converts double inputs larger than 2^53-1, or char inputs with exponents, exactly into vpi. Author: James Tursa vpi, precision, variable, integer 103 0
25 Sep 2009 Screenshot Fortran mex routine mxGetClassName A drop-in replacement for the TMW Fortran API function mxGetClassName routine that does not work. Author: James Tursa fortran, mxgetclassname, mex, class name 221 0
05 Aug 2009 Screenshot num2strexact (exact version of num2str) num2strexact does exact conversion of number to string based on IEEE floating point bit pattern Author: James Tursa num2strexact, str2num, sprintf, num2str, precision, printf 227 0
05 Aug 2009 Screenshot swapbytes C-mex function swapbytes(X1,X2,...) reverses byte ordering of each element, little-endian values to/from big-endian Author: James Tursa swapbytes, external interface, reverse byte ordering, littleendian, endian, bigendian 202 0
  • 5.0
5.0 | 1 rating
05 Aug 2009 Screenshot typecast C-mex function typecast.c is a mex function intended to mimic the MATLAB intrinsic of the same name Author: James Tursa typecast, external interface, cast, mex, external code interfa... 204 0
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com