Posts Tagged ‘Emacs’

Ok guys! time to continue 🙂

In the last post I stop just before explaining how to allocate a tensor.

Allocate method

In the allocation method there is a line where the itertools.product command is used. It was the first time I saw such a command, so I opened reinteract (it’s like ipython) to test it.

import itertools
rank = (0,2)
n = rank[0] + rank[1]
indc = list(itertools.product(range(4),repeat=n))

gives the output,
[(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3), (3, 0), (3, 1), (3, 2), (3, 3)]

Now I know!!! It gives you a list of the Cartesian product, i.e., a list of all possible values of the indices of a tensor of rank n 🙂 Very clever Sergei!

Next there is a loop, which ends with an assignment. In the loop, every possible combination of indices is stored in a list called mastr and finally a dictionary is created by zipping this mastr list with a zeros list.

This loop assignment complication looks like a work around for differentiate upper and lower components. However, for my mental health… I’ll avoid (at least by now) the shape of the tensor, and the whole loop-assignment can be changed by,

self.components = dict(zip(indc,[0 for i in xrange(len(indc))]))

right after the Cartesian product definition.

_dictkeycopy Attribute

This attribute takes a dictionary (code name hay), extract the keys of the dictionary, and create a new dictionary with those keys but assigning zero values to every key.

:-S Got confused?

it’s like having a copy of the possible indices values of the tensor, zipped with zeros.

getNonZero attribute

This is another important attribute!!! We all know that not all components of tensor in GR are different than zero, so this attribute “print” only those that are non-vanishing 😉

I think it’s more or less clear what it does. It sweeps the values on the dictionary, and if the value is non-zero, it stores both key and value in a new dictionary 🙂

__str__ attribute

It prints the result of getNonZero. 😛

Now what?!

On the next post I’ll start by defining a metric tensor. However, it could be useful to define instead a set of vielbein and a signature… :-/ Perhaps later!

Get GR-module.py (version 2)

Got to work right now!

Enjoy life!



Read Full Post »

Some times, depending of the resolution of the monitor, the window of Emacs is bigger than it should. For controlling the size, I added a Lisp line to my .emacs file

(setq default-frame-alist '((width . 80) (height . 33) (menu-bar-lines . 1)))

which set the display to 80 columns and 33 rows.


Read Full Post »

After upgrade to Ubuntu 10.10, my emacs got a bug. Whenever I wanted to enable the flyspell-mode, minibuffer answer was “Enabling Flyspell mode gave an error”, no more information were given even with the debugger turned on.

Some googling, web surfing, et cetera… and still nothing.

Finally, right now (after almost 3 week, and quasi-given up), it occurs to me that and update of Emacs could solve the problem… How?

THAT’S IT!!!!! I looked for an Emacs PPA source,

$ sudo add-apt-repository ppa:ubuntu-elisp/ppa
$ sudo apt-get update
$ sudo apt-get dist-upgrade

And problem solved.

Read Full Post »

A brief comment…

From time to time, when writing in LaTeX, one repeats a mathematical expression over and over. A shortcut for this is to define a newcommand using,


In the above example, the capital R denoting real numbers is re-defined through the command \R. However, every time one’d like to call the command inside the text the dollar signs should be written, i.e., $\R$.

A way for avoiding the dollar signs is to use the ensuremath command,


which allows to write just \R in both, math and text mode.


Read Full Post »

I’ve just re-installed Ubuntu in my Dell XPS 1330n. It looks very nice… but as I wrote in a previous post, I’d like it to be a bit different (out of the box) ’cause it tends to look much like Leopard.

  • The internet connection works, but it is slow… could be the repositories.
  • Firefox’s default search engine has gone back to Google. I have nothing against Yahoo!, but I’m a Google’s fan… So, good for me.
  • I’ve noticed that Empathy includes Facebook chat and MySpace one. As usual, the F4 key allows you to configure your accounts. The chat windows is cuter.
  • In System-> Administration -> Software Source, I changed to mIain server in Ubuntu SoftwareTab, checked the Canonical Archive box in Other Software Tab, and checked the proposed and backport boxes in the Updates Tab. Finally close for reload the changes.
  • After changing the Sotfware sources… It finally began to dist-update. 103 files for a total of 117.1 Mb. Not to bad.
  • I’ve just found something called Gwibber or Broadcast (when you press the mail icon in the upper panel)… It allows you to post in Social networks such as facebook, Flirk, … and many others.
  • Transmission continues been the default torrent client (I really love it!).
  • Still don’t use the Simple Scan program, but I liked really much Xsane… I know, I should give him a try!
  • The detection of external media is as good as before.
  • One of my favourite text editors, Emacs has evolved to Emacs23, I tried like one month ago and I didn’t like it much. Let’s see if this version is better.
  • A Kernel problem which slow down the copy process for large files seems to be gone!

I haven’t finished the Configuration, so I’ll be posting during the day!


Read Full Post »

A few minuted ago I could install and use the sagetex package for Sage(math). I’d like to thank ElMonkey for helping me via the IRC channel #sage-devel.


It is assumed that you have installed

  • A LaTeX compiler,
  • A LaTeX editor,
  • and Sage(math)

all of them configured and working properly.

Downloading the Package.

Get the last version of the package in http://www.sagemath.org/packages/optional/.

Installing the Package.

Useful Advise.

My Sage script is located in a sub/sub/sub/subfolder/Sage-4.3.1 (from my HOME folder), so when I want to running it, I should type

$ sub/sub/sub/subfolder/Sage-4.3.1/./sage

It isn’t nice to repeat this one and again, every day.

Thus, I created an alias.

Open the .bashrc file in your editor (gedit for example)

$ gedit .bashrc

add (at the end of the file) the line

alias sage='/path/to/your/sage/folder/./sage'

which in my example would be,

alias sage='/home/doxdrum/sub/sub/sub/subfolder/Sage-4.3.1/./sage'

Save and close the editor. Now in the terminal,

$ source .bashrc

and from now on I just type

$ sage

for running the program.

The real installation.

Now, type in the terminal

$ sage -i sagetex-2.2.1.spkg

and that’s it.


After the installation, a new folder is placed into the Sage folder. Look into local/share/texmf. All files (and folders) inside it must be copied to the LaTeX tree.

In a Linux distribution the LaTeX tree should be placed in /usr/share/texmf/tex/latex

$ sudo cp -r /path/to/Sage-4.3.1/local/share/texmf \
$ sudo mktexlsr /usr/share/texmf/tex/latex

This should work. However, if it doesn’t… the desperate method is to copy the sagetex.sty from /path/to/Sage-4.3.1/local/share/texmf to the folder of the TEX file.

The TeX File.

It is time to create a file.tex, just as any other TEX file. Add the line


to the preable.

Compiling the TeX file.

When you run

$ pdflatex file.tex

the compilator exits with errors… but you get a file.sage, sage-compile it and run pdflatex again,

$ sage file.sage
$ pdflatex file.tex

There it is!!!

A resume compilation line could be

$ pdflatex file.tex && sage file.sage && pdflatex file.tex

Enjoy it!

Read Full Post »

Yes, I just realize that Emacs 23 is available in Ubuntu repositories, so if you want to install it just do as follows,

$ sudo apt-get autoremove emacs
$ sudo apt-get install emacs23

The first will remove the previous version and the 2nd line will install the fresh one.

Read Full Post »

« Newer Posts - Older Posts »