R ( cons p (f p r )) ) ) ) ( reverse r ) ) Identity Matrix - Lee Mac Args: n - matrix dimension ( defun imat ( n / i j l m ) ( repeat ( setq i n ) ( repeat ( setq j n ) ( setq l ( cons ( if ( = i j ) 1.0 0.0 ) l ) R nil ) ( setq p ( mapcar ' ( lambda ( x ) ( / ( float x ) ( caar m ))) ( cdar m )) ( setq c ( mapcar ' ( lambda ( x ) ( abs ( car x ))) m )) ( repeat ( vl-position ( apply ' max c ) c ) ( setq m ( append ( cdr m ) ( list ( car m )))) ) ( if ( equal 0.0 ( caar m ) 1e-14 ) ( setq m nil
Args: m - nxn matrix ( defun invm ( m / c f p r ) ( defun f ( p m ) ( mapcar ' ( lambda ( x ) ( mapcar ' ( lambda ( a b ) ( - a ( * ( car x ) b ))) ( cdr x ) p )) m ) ) ( setq m ( mapcar ' append m (imat ( length m )))) ( while m ( mapcar ' ( lambda ( x / k ) ( setq k 0 ) ( vl-remove-if ' ( lambda ( y ) ( = j ( setq k ( 1+ k )))) x ) ) ( cdr m ) ) ) ) ) ( car m ) ) ) ) ) ) Matrix Inverse - gile & Lee Mac Uses Gauss-Jordan Elimination to return the inverse of a non-singular nxn matrix. ( mapcar ( function ( lambda ( a / d ) ( setq d ( / ( car a ) ( float ( caar m )))) ( mapcar ( function ( lambda ( b c ) ( - b ( * c d ))) ) ( cdr a ) ( cdar m ) ) ) ) ( cdr m ) ) ) ) ) ) ) Matrix Determinant (Laplace Formula) - Lee Mac Args: m - nxn matrix ( defun detm ( m / i j ) ( setq i -1 j 0 ) ( cond ( ( null ( cdr m )) ( caar m )) ( ( null ( cddr m )) ( - ( * ( caar m ) ( cadadr m )) ( * ( cadar m ) ( caadr m )))) ( ( apply ' + ( mapcar ' ( lambda ( c ) ( setq j ( 1+ j )) ( * c ( setq i ( - i )) (detm
#MAC DRAW FUNCTIONS CODE#
So you'll probably have to rewrite quite a bit of code to have it work for different systems (that's why people generally use wrappers for that, so they don't have to rewrite all the stuff inside their main functions).Select all Matrix Determinant (Upper Triangular Form) - ElpanovEvgeniy Args: m - nxn matrix ( defun detm ( m / d ) ( cond ( ( null m ) 1 ) ( ( and ( zerop ( caar m )) ( setq d ( car ( vl-member-if-not ( function ( lambda ( a ) ( zerop ( car a )))) ( cdr m )))) ) (detm ( cons ( mapcar ' + ( car m ) d ) ( cdr m ))) ) ( ( zerop ( caar m )) 0 ) ( ( * ( caar m ) (detm These commands are most probably not the same for the two systems.
If you're not using a library you need to use native commands to create a window to draw in (or you need to get the handle of the desktop if you want to draw onto there directly).
#MAC DRAW FUNCTIONS WINDOWS#
Since you probably don't have a Mac and a Windows at home to test both of the conditional branches.Īnd there's probably much more to it. That's quite a bit of organizational work actually. You just make a condition so the right libraries will be included during compilation. The Windows.h and MacGraphics library and standard libraries for Windows/Mac systems (I guessed the Mac name, I have no clue of Mac-specific programming). A Mac version won't work on a Windows PC.Īnd no, you don't have to write your own library. When a user installs the program he just needs to make sure to get the right version of it. That's why you can choose between downloading a Mac or Windows version of many programs in the internet. If you let someone compile your project on a Mac he'll get a exe (or whatever file they use lolz) that'll be made specifically for Mac. So if you compile on a Windows machine your program will import Windows.h and use Window's functions. When you compile and build your exe with your IDE (say Visual Studio or GCC) you get a exe file which is built to be able to run on your type of system only.