Code
NODElib
The Neural Optimization Development Engine library
Quick Links
From the Main Page
NODElib (which stands for Neural Optimization Development Engine library) is a programming library for rapidly developing powerful neural network simulations. Very few assumptions have been made regarding the system in which the code is to be used; thus, NODElib is suitable as a back-end engine for most applications.
But wait, there's more.
NODElib is general enough that you can probably find many other uses for it. The code is extremely modular, compact, and robust. It is written in an object oriented manner. All of the library code, example and test program source, documentation, and supporting text is only on the order of about 20,000 lines, which means that NODElib is extremely compact. This is important from the point of view of comprehending the code, and for the memory requirements of the library.
Status Update
I haven't done a serious update to NODElib in a long time. Nonetheless, a fair number of people are still using it, which makes me happy to no end. I hope to resume maintaining NODElib in the very near future (mid 2005), with the hope that I can give it the attention that it deserves. However, if you would like to take a crack at maintaining it, get me a shout.
CBofN Code
Source Code from The Computational Beauty of Nature
Quick Links
From the Main Page
The source code is currently available many flavors:
- cbn-noarch-src.tgz - only the source code. You will need either (1) GNU make and gcc, or (2) Microsoft Visual C++, in order to build the source. Moreover, perl and sed are required to build the manual and HTML pages. Get this only if you are hacker that wants to get down and dirty with everything (216 KB).
- cbn-noarch-src+docs.tgz - same as above but has the manual and HTML pages prebuilt. Get this only if you are hacker but you don't want to build the docs (259 KB).
- cbn-noarch-src+docs.zip - same as above but as a zip archive. Get this only if you are Windows hacker (462 KB).
- cbn-linux-bin.tgz - contains everything prebuilt for an i386 linux box with glibc and glibm (498 KB).
- cbn-sunos-bin.tgz - this contains everything prebuilt for Sun machines running SunOS. (1,177 KB).
- cbn-win-bin.zip - this contains everything prebuilt for Windows 95/98/NT (1,807 KB).
- cbn-mac-bin.sit.hqx - this contains only the Mac executables. You may also want to get cbn-noarch-src+docs.zip for documentation and source, as well as cbn-mac-proj.sit.hqx for an example project file under CodeWarrior. (1,557 KB).
Status Update
It's been a long time since I updated this as well. I intend to make sure that it cleanly compiles on all major platforms in the very near future. (Look specifically for Windows, OS X, and Linux to be all supported.)
IOCCC
A couple of years ago I submitted an entry to the International Obfuscated C Coding Competition. I didn't even rate. Nonetheless, this is one of my all time favorite little hacks.
Quick Links
From the IOCCC submission
This program prints out the first 2^N prime numbers, where N is
equal to the number of supplied command-line arguments, argc.
Regarding the format, excepting the #define lines, the source has
no spaces and has the property that any white space characters can
be inserted anywhere without breaking the code. I took the
liberty of making the 15 source lines have length equal to the
first 15 primes. Clever planning on my part? Nope, just a happy
coincidence.
Why is this obfuscated? Go ahead, do a 'gcc -E prog.c | indent'.
The code does not use a single if/then, while loop, or for loop.
This baby is pure recursion, and nothing else. The code does use
a handful of + and - operations, but each use always has at least
one constant 1 as an argument (thus, no real higher math). Also
note that the only constants in the code are 0, 1, and 2.
Moreover, there are no local or global variables, only function
parameters.
Status Update
I unobfuscated and documented to the code for fun, and made it the basis for one of my Brain Candy columns. What follows is from the documentation:
This program demonstrates the most ridiculous method for computing
primes. It uses only unsigned recursive functions, increment (++),
decrement (--), if, return, and 0. Also, a single printf() is used
for output, but that's it.
The interesting thing is that this subset of C is Turing complete.
So whatever can be done on a general purpose computer can also be
done in this primitive C. In fact, it wouldn't be too difficult to
show that this subset of C is trivially identical to the general
recursive functions; but that's left as an exercise for the reader
;-).
9 Responses to “Code”
2008 Feb 12
11:05 am
Ernesto Costa wrote:
Hi,
I’m using parts of your book CBoN in a course at the University of Coimbra for MSc students in Computer Science.
I wonder if there is a Mac OS X (intel) version of the code.
Sincerely.
Ernesto Costa
2008 Apr 13
10:42 am
DN wrote:
I recently purchased CBoN (and am waiting for Amazon to ship it to me). In anticipation, I downloaded cbn-noarch-src+docs.tgz, gunziped and untarred it to my home directory. I am unable to get the code to build. Here is what I have tried:
1. cd cbn/code/bin and editing the Makefile so that XINCLUDE equals /usr/X11/include and XLIBS equals /usr/X11R6/lib/X11 as suggested in the FAQ.
2. cd .. and running ./make which produces the following output:
../src/stutter.c: In function ‘garbage_collect’:
../src/stutter.c:189: error: invalid lvalue in assignment
../src/stutter.c: In function ‘new_cell’:
../src/stutter.c:208: warning: type defaults to ‘int’ in declaration of ‘init’
../src/stutter.c:216: error: invalid lvalue in assignment
../src/stutter.c:217: error: invalid lvalue in assignment
../src/stutter.c:224: error: invalid lvalue in assignment
../src/stutter.c:225: error: invalid lvalue in assignment
../src/stutter.c: In function ‘new_atom’:
../src/stutter.c:249: error: invalid lvalue in assignment
../src/stutter.c:250: error: invalid lvalue in assignment
../src/stutter.c:251: error: invalid lvalue in assignment
../src/stutter.c:255: error: invalid lvalue in assignment
../src/stutter.c:256: error: invalid lvalue in assignment
../src/stutter.c: In function ‘cons’:
../src/stutter.c:343: error: invalid lvalue in assignment
../src/stutter.c:345: error: invalid lvalue in assignment
../src/stutter.c:347: error: invalid lvalue in assignment
../src/stutter.c: In function ‘set’:
../src/stutter.c:405: error: invalid lvalue in assignment
../src/stutter.c:414: error: invalid lvalue in assignment
../src/stutter.c:415: error: invalid lvalue in assignment
../src/stutter.c:419: error: invalid lvalue in assignment
../src/stutter.c:420: error: invalid lvalue in assignment
../src/stutter.c: In function ‘lambda’:
../src/stutter.c:458: error: invalid lvalue in assignment
../src/stutter.c:459: error: invalid lvalue in assignment
../src/stutter.c: In function ‘eval_lambda’:
../src/stutter.c:569: error: invalid lvalue in assignment
../src/stutter.c:570: error: invalid lvalue in assignment
../src/stutter.c: In function ‘initialize’:
../src/stutter.c:702: error: invalid lvalue in assignment
../src/stutter.c:705: error: invalid lvalue in assignment
../src/stutter.c:708: error: invalid lvalue in assignment
../src/stutter.c:711: error: invalid lvalue in assignment
../src/stutter.c:714: error: invalid lvalue in assignment
../src/stutter.c:718: error: invalid lvalue in assignment
../src/stutter.c:721: error: invalid lvalue in assignment
../src/stutter.c:724: error: invalid lvalue in assignment
make[1]: *** [stutter.o] Error 1
make: *** [progs] Error 2
I’m running ubuntu ppc gutsy. Any suggestions would be appreciated.
2008 Apr 14
4:23 pm
DN wrote:
Update and partial solution: I commented out the reference to stutter in Makefile.inc and ran make again. Everything else appears to have compiled fine. So I’ve set aside stutter until I have time to try to figure out why it is complaining about an invalid lvalue assignment.
2009 May 4
10:50 am
regow wrote:
DN, I have those problems too.
openSuSE 10.3
Any suggestions would be appreciated.
2007 Sep 24
1:22 pm
Ryan Moniz wrote:
Hi Dr. Flake,
My supervisor gave me your “The Computational Beauty of Nature” book, it’s really interesting and well written. Thank you for writing it! Also I’ve tried to download and install the accompanying programs but I’m having a hard time getting them to work on a Mac OS X machine (intel). I would really appreciate your help so I can continue to explore and learn.
Thanks,
Sincerely,
Ryan D. Moniz