dimitris kalamaras

math, social network analysis, web dev, free software…

Tag: coding

Create complex visual elements with Processing language

I was having a kind of …insomnia attack last Friday night, so I decided to search the openSUSE repositories for interesting applications. I was using openSUSE (11.1) at the moment, with lots of additional repos [1] from the excellent Build Service, so there were a lot of things there to explore. One thing led to another, and soon I ended up downloading Processing. What is this? The package description looked interesting:

Processing is an open source programming language and
environment for people who want to program images, animation,
and interactions. It is used by students, artists, designers,
researchers, and hobbyists for learning, prototyping, and production.
It is created to teach fundamentals of computer programming
within a visual context and to serve as a software sketchbook
and professional production tool. Processing is an alternative
to proprietary software tools in the same domain

I thought “ok, this is promising, let’s have a closer look at it”, and waited a couple minutes for all 85MB of packages to be downloaded and installed from the Education repository (no Ubuntu packages yet, but you can just download a tarball with linux binaries). Then I started the application with the command:

Read More

LIFO (2001)

The goal of this project was to create a class (named lifo) of Last-In-First-Out Lists (Stacks) of integers with variable length. The class actually defines a new Data Type, named lifo. Each variable of this type will be a LIFO List. Of course, the class must have defined some operations (member-functions) for handling the lists, ie PUSH an integer to a stack, POP an integer from the stack, PRINT a list, COPY one list to another, COMPARE two lists, CONCATENATE two lists, SEARCH a list for an element etc.
The program is quite simple. It creates an “array” a of 100 elements of type lifo. Thus, it creates 100 LIFO lists and displayes a simple menu as user interface with the above actions.

It was written in Borland C++ v.5 but I think you can compile and run it in any compiler due of its simplicity. It only requires the iostream.h for cout and cin.

Read More

Horner Value Finder

This Pascal program finds the value of a Nth order polynomial:
a_{n}x^{n}+a_{n-1}x^{n-1}+cdots+a_{1}x+a_{0}
implementing Horner method without using any complex arithmetic in Fortran 77.

Obviously, it can find complex values, for complex x’s, but without complex arithmetic.
The program also uses ANSI codes to clear screen.

Read More

Root-o-matic

This little Fortran program, originally written in DOS, uses the arithmetic sequence x_n+1={1/2} x_{n} + A / x_{n} to find the root of A.

All you have to do is to enter A and a guess value x_0

Caution: This program is very old; it uses Escape codes to clear the screen. In DOS, it needs the ANSI.COM driver. I haven’t test it on Linux 😉

Read More

Prime numbers’ generator

This is a Prime Numbers’ Generator from Integers up to 2,000,000,000, written in Turbo Pascal.
This program generates the prime numbers up to a given arithmetic limit, using 4 (four) different known methods. They are all based in modulo algebra. The methods are:

  1. This uses the mathematical definition of a prime number to generate them. A prime is only divided by 1 and himself. Disadvantage: The method is very slow.
  2. In this method, each number N is modulo divided only with the half of the numbers below it (N/2). Thus, the search is becoming faster than the first method.
  3. In the third method, a number, let N, is modulo divided only with the numbers up to sqrt{N}. As a result of that, the generation process is 10 times faster than the previous methods.
  4. The fourth method is the best of all. It is based on the 3rd method, only it bypass the sqrt{x} praxis, by modulo dividing each number N with the first, the second and the third prime number and then, if there is a residue, it modulo divides N with j, where j is an integer from j*j cdots N with step 2. The above trick has the eye-blink effect: the method generates primes (within a reasonable range) before you blink your eyes….:-)

Read More

Qt (Μέρος Ι): Convertor

Το Q Toolkit (Qt) είναι μία εργαλειοθήκη για δημιουργία εφαρμογών με γραφικό περιβάλλον (GUI), αντίστοιχη της GTK του Gnome. Ξεκίνησε να αναπτύσσεται το 1991 από τους Haavard Nord and Eirik Chambe-Eng και έγινε η βάση πάνω στην οποία στηρίχτηκε ολόκληρο το γραφικό περιβάλλον KDE. Ουσιαστικά, οι εκδόσεις του KDE ακολουθούν πάντα τις αναβαθμίσεις της Qt. H Qt αναπτύσσεται πλέον από τη Νορβηγική Trolltech, και υπάρχουν ανοικτού κώδικα εκδόσεις της για Unix, Mac OS, Windows και embedded συστήματα.

Λίγη ιστορία

Μέχρι την έκδοση 1.45, η άδεια χρήσης της Qt (FreeQt) δεν ήταν συμβατή με τις άδειες χρήσης ανοικτού κώδικα του OSI (www.opensource.org) αλλά και τον ορισμό του ελεύθερου λογισμικού (www.fsf.org), πράγμα που έκανε πολλούς developers να ανησυχούν για την εξέλιξη του KDE. Η άδεια άλλαξε με την Qt2 που είχε άδεια Q Public License, την οποία όμως το FSF θεώρησε και πάλι ασύμβατη με την GPL. Το αποτέλεσμα ήταν η ανάπτυξη ανταγωνιστικών προσπαθειών, όπως της εργαλειοθήκης Harmony και του Gnome. Το Harmony ήταν μια άδοξη προσπάθεια αναδημιουργίας της Qt με άδεια GPL ενώ, πιο φιλόδοξα, το Gnome έθεσε ως στόχο την αντικατάσταση του KDE στα desktops μας (από εκεί πηγάζει η αντιπαράθεση KDE εναντίον Gnome, που όμως έχει πλέον ατονήσει).

Read More

Integral in C (1997)

This program uses the basis of the Archimedes (287-212 BC) method, known as exhaustion, to approximate the integral of a given real function in a given space [a,b]. First it segments the given space into N subspaces. It calculates: a) the sum of the areas of orthogonal parallelograms of height equal to the minimum of the function in each segment and b) the sum of the areas of orthog. parallelograms of height equal to the max value of f(x) in each segment. Theoretically, when N right infty, the progressions are both converging to the same limit which is the integral of the function.

The program is simple. It requires the segmentation number N and the integration limits a,b. You can easily change the function to your desired one in the function at the end of the code. As you may see, after the calculations, it tries to graph the function. Well don’t expect much, although it has very good output in some functions like the f(x)=xsinx.

The program was written in Borland C++ 5.0. You will need the compiler bcc in order to compile and run it, but it’s very easy to make some alterations for other compilers or other OS’s.

Read More

Powered by WordPress & Theme by Anders Norén