difference engine.

Difference Engine
Weierstrass:
A machine to compute mathematical tables

–	 Any continuous function can be approximated by a
polynomial
–	 Any Polynomial can be computed from difference tables

[latex]
\int{(n)} = n^{2}+n+41 \\
d1(n) = \int{(n)} – \int{(n-1)} = 2n \\
d2(n) = d1{(n)} – d1{(n-1)} = 2 \\
[/latex]
Make a Table with the equations.
You can use Addition and Find the next value of function for a new “n”.

source : http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-823-computer-system-architecture-fall-2005/lecture-notes/

cairo graphics 0.3



/* Jeffrin Jose Licensed GPL v3 Copyright
August 2010 GPL --> http://www.gnu.org/copyleft/gpl.html */

#include

int
main ()
{
int i;
cairo_surface_t *surface =
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 800, 600);
cairo_t *cr =
cairo_create (surface);

cairo_set_font_size (cr, 32.0);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_line_width(cr,1.0);
for (i=0;i<100;i++)
{
/* cairo_move_to(cr,30+i,60);
cairo_line_to(cr,30+i,60+i);*/
cairo_rectangle(cr,50+i,100,10+i,10+i);
/* cairo_line_to(cr,40,200); */

cairo_stroke(cr);
/* cairo_surface_flush(); */
/* usleep(100000);*/
}

/* cairo_rectangle(cr,30,20,67,70);*/
/* cairo_stroke(cr);*/

cairo_destroy (cr);
cairo_surface_write_to_png (surface, "imagecairo1.png");
cairo_surface_destroy (surface);
return 0;
}


Output

https://beautifulworknew.wordpress.com/wp-content/uploads/2021/03/826a6-imagecairo1.png

cairo graphics 0.2 (triangle)



/* Jeffrin Jose Licensed GPL v3 Copyright
August 2010 GPL --> http://www.gnu.org/copyleft/gpl.html */

#include
#include

int i=0;

static gboolean
draw(GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
cairo_t *cr;

cr = gdk_cairo_create(widget->window);

cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_line_width (cr, 0.5);

for (i=0;i<200;i++)
{
cairo_move_to(cr,30+i,60);
cairo_line_to(cr,30+i,60+i);
/* cairo_line_to(cr,40,200); */

cairo_stroke(cr);
/* cairo_surface_flush(); */
/* usleep(100000);*/
}

cairo_destroy(cr);

return FALSE;
}

int
main (int argc, char *argv[])
{

GtkWidget *window;

gtk_init(&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

gtk_widget_add_events (window, GDK_BUTTON_PRESS_MASK);

g_signal_connect(window, "expose-event",
G_CALLBACK(draw), NULL);
g_signal_connect(window, "destroy",
G_CALLBACK(gtk_main_quit), NULL);

gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(window), "lines");
gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
gtk_widget_set_app_paintable(window, TRUE);

gtk_widget_show_all(window);

gtk_main();

return 0;
}

cairo graphics 0.1 (line)



#include
#include

int i=0;

static gboolean
draw(GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
cairo_t *cr;

cr = gdk_cairo_create(widget->window);

cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_line_width (cr, 0.5);

/*for (i=0;i<200;i++)
{ */
cairo_move_to(cr,30,60);
/* cairo_line_to(cr,30+i,60+i);*/
cairo_line_to(cr,40,200);

cairo_stroke(cr);
/* cairo_surface_flush(); */
/* usleep(100000);*/
/*} */
cairo_destroy(cr);

return FALSE;
}

int

main (int argc, char *argv[])
{

GtkWidget *window;

gtk_init(&argc, &argv);

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

gtk_widget_add_events (window, GDK_BUTTON_PRESS_MASK);

g_signal_connect(window, "expose-event",
G_CALLBACK(draw), NULL);
g_signal_connect(window, "destroy",
G_CALLBACK(gtk_main_quit), NULL);

gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(window), "lines");
gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
gtk_widget_set_app_paintable(window, TRUE);

gtk_widget_show_all(window);

gtk_main();

return 0;
}

auxiliary and vector.

Words

auxiliary = assistant,help,helper,supporter.
vector    = a one dimensional array.

source: http://www.thefreedictionary.com

Application

Vector graphics is the use of geometrical primitives such as points,
lines, curves, and shapes or polygon(s), which are all based on mat
hematical equations, to represent images in computer graphics.Vector
graphics formats are complementary to raster graphics, which is the
representation of images as an array of pixels, as it is typically used for
the representation of photographic images.[1] There are instances when
working with vector tools and formats is the best practice, and instances
when working with raster tools and formats is the best practice. There are
times when both formats come together. An understanding of the adv
antages and limitations of each technology and the relationship between
them is most likely to result in efficient and effective use of tools.

source : http://en.wikipedia.org/wiki/Vector_graphics

operating system auxiliary vector

GDB show’s Auxiliary Vector

(gdb) info auxv
33   AT_SYSINFO_EHDR      System-supplied DSO's ELF header 0x7fff68bdf000
16   AT_HWCAP             Machine-dependent CPU capability hints 0x78bfbff
6    AT_PAGESZ            System page size               4096
17   AT_CLKTCK            Frequency of times()           100
3    AT_PHDR              Program headers for program    0x400040
4    AT_PHENT             Size of program header entry   56
5    AT_PHNUM             Number of program headers      8
7    AT_BASE              Base address of interpreter    0x7f936f757000
8    AT_FLAGS             Flags                          0x0
9    AT_ENTRY             Entry point of program         0x401850
11   AT_UID               Real user ID                   1000
12   AT_EUID              Effective user ID              1000
13   AT_GID               Real group ID                  1000
14   AT_EGID              Effective group ID             1000
23   AT_SECURE            Boolean, was exec setuid-like? 0
25   AT_RANDOM            Address of 16 random bytes     0x7fff68a94c69
31   AT_EXECFN            File name of executable        0x7fff68a95fef "/bin/cat"
15   AT_PLATFORM          String identifying platform    0x7fff68a94c79 "x86_64"
0    AT_NULL              End of vector                  0x0
(gdb)

Process Involved

/bin/cat .
concatenate files and print on the standard output.

Explanation

     Display the auxiliary vector of the inferior, which can be either a
     live process or a core dump file.  GDB prints each tag value
     numerically, and also shows names and text descriptions for
     recognized tags.  Some values in the vector are numbers, some bit
     masks, and some pointers to strings or other data.  GDB displays
     each value in the most appropriate form for a recognized tag, and
     in hexadecimal for an unrecognized tag.

source :  http://www.slac.stanford.edu/comp/unix/package/
             rtems/doc/html/gdb/gdb.info.Auxiliary_Vector.html

A Screen Shot from /usr/include/elf.h in Debian

/* Legal values for a_type (entry type).  */

#define AT_NULL         0               /* End of vector */
#define AT_IGNORE       1               /* Entry should be ignored */
#define AT_EXECFD       2               /* File descriptor of program */
#define AT_PHDR         3               /* Program headers for program */
#define AT_PHENT        4               /* Size of program header entry */
#define AT_PHNUM        5               /* Number of program headers */
#define AT_PAGESZ       6               /* System page size */
#define AT_BASE         7               /* Base address of interpreter */
#define AT_FLAGS        8               /* Flags */
#define AT_ENTRY        9               /* Entry point of program */
#define AT_NOTELF       10              /* Program is not ELF */
#define AT_UID          11              /* Real uid */
#define AT_EUID         12              /* Effective uid */
#define AT_GID          13              /* Real gid */
#define AT_EGID         14              /* Effective gid */
#define AT_CLKTCK       17              /* Frequency of times() */

rectangle with cairo



/* Jeffrin Jose Licensed GPL v3 Copyright August 2010
GPL --> http://www.gnu.org/copyleft/gpl.html */

#include

int
main ()
{
cairo_surface_t *surface =
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 800, 600);
cairo_t *cr =
cairo_create (surface);

cairo_set_font_size (cr, 32.0);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_line_width(cr,1.0);
cairo_rectangle(cr,30,20,67,70);
cairo_stroke(cr);

cairo_destroy (cr);
cairo_surface_write_to_png (surface, "hello.png");
cairo_surface_destroy (surface);
return 0;
}

line with cairo



/* Jeffrin Jose Licensed GPL v3 Copyright August 2010
GPL --> http://www.gnu.org/copyleft/gpl.html */

#include

int
main ()
{
cairo_surface_t *surface =
cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 800, 600);
cairo_t *cr = cairo_create (surface);

cairo_set_font_size (cr, 32.0);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_line_width(cr,1.0);
cairo_move_to (cr, 10.0, 50.0);
cairo_line_to(cr,20,300);
cairo_stroke(cr);

cairo_destroy (cr);
cairo_surface_write_to_png (surface, "hello.png");
cairo_surface_destroy (surface);
return 0;
}

Print With Delay 0.6 ( with option)



/* Jeffrin Jose Licensed GPL v3 Copyright August 2010
GPL --> http://www.gnu.org/copyleft/gpl.html */

#include
#include
#include
#include

int main(int argc,char *argv[])
{
int count;
int i=0,getptr;
pid_t pid;
size_t length;
char array[20]="Happy Friendship Day";
/* printf("n Happy Friendship Day n"); */
pid=fork();
if (pid == 0)
{
setsid();
setenv("PS1","$",1);
/* getptr=getenv("PS1");
printf("%s",getptr); */
printf("\n");
for(i=0;i<20;i++)
{
printf("%c",array[i]);
/* for(seconds=0;seconds<100000000;seconds++);*/
/* system("sleep 1s");*/
fflush(stdout);
usleep(100000);
}
printf(" ");

for(count=1;count <argc;count++)

{

printf("%s",argv[count]);
fflush(stdout);
usleep(100000);
}
printf("\n");
length=strlen(argv[1]);
length= 21 + length;
/* printf("%d",length);*/
for(i=0;i<length;i++)
{
printf("%c",'-');
/* for(seconds=0;seconds<100000000;seconds++);*/
/* system("sleep 1s");*/
fflush(stdout);
usleep(100000);
}
printf("\n");
}
/* printf("%d",pid); */
return 0;
}

negate instruction NEG

GDB shows “neg” instruction

  or     $0xffffffffffffffff,%eax
  jmp    0x7f94f7fce0d0 
  mov    0x296e5f(%rip),%rax        # 0x7f94f8264f98
  neg    %edx
  mov    %edx,%fs:(%rax)
  or     $0xffffffffffffffff,%eax
  jmp    0x7f94f7fce10f 
End of assembler dump.
(gdb)

0x00007f94f7fce139 : neg %edx

Process Involved

software : gnome-panel.
The launcher and docking facility for GNOME

Explanation

The neg (negate) instruction takes the two's complement of a byte or
word. It takes a single (destination) operation and negates it. The
syntax for this instruction is
		neg	dest

It computes the following:
		dest := 0 - dest

source: http://www.arl.wustl.edu/~lockwood/class/cs306/books/
           artofasm/Chapter_6/CH06-2.html