## Upgrading from Kubuntu Gutsy (7.10) to Hardy (8.04)

I just upgrades my workstation and my laptop from Kubuntu gutsy to Hardy.

When I upgraded my workstation, I chose to keep the setting for my xorg.conf. The result was quite bad. The reason was that Hardy’s installation disabled restricted drivers by default. And I use ATI restricted driver for my X setting. So it crashes when it tries to load the X server after the installation finish.

To overcome this problem, I need to login using terminal, and type
`\$ sudo dpkg-reconfigure -phigh xserver-xorg`

this restore the xorg.conf using the default value instead of using ATI drivers. After I reboot, I can login to my Desktop.

For my laptop, I got error when I tried to install using the alternate CD. The reason was that I previously install ubuntu-desktop package. Somehow it requires me to uninstall them before I upgrade to Kubuntu Hardy. It works fine after I remove ubuntu-desktop package.

However, for both my workstation and laptop, after updating all the package, I encouter some packages are being kept from upgrade. I search to the internet, and found that I somehow need to use aptitute. So I type
``` \$sudo aptitude update \$sudo aptitude dist-upgrade ```

The strange thing was that, I couldn’t use apt-get. I am not sure why. Anyway, that solves my problem. 🙂

## Regarding Inverse Fermi Dirac Integral

Regarding my previous post on obtaining inverse fermi dirac integral. I found a paper by Antia which uses rational function to solve the inverse integral.

Antia, H. M. Rational Function Approximations for Fermi-Dirac Integrals. Astrophysical Journal Supplement v.84, p.101, (1993)

Do a Google Scholar Search to get the file.

The paper provide the Fortran codes.

## Adding custom function to Octave

After writing a new function such as this one, we need to make sure that Octave can find the file.

To do this create a new directory where you usually install your packages. If you are not sure, you can type
`octave:1> path`
inside octave.

`path(path(),"/home/blabla/octave/myfun")`
where /home/blabal/octave is the place where you usually install your octave packages.

## Creating fermi dirac integral order -3/2 Octave function from Fortran source code

I need to use a Fermi Dirac Integral function of order -3/2 which is not available in Octave. Octave only has order -1/2, 1/2, and 3/2 from its GSL package. The source code is available in Fortran from

A. Trellakis, A. J. Galick, U. Ravaioli, Rational Chebyshev approximation for the Fermi-Dirac integral F_{−3/2}(x). Solid-State Electronics, Volume 41, Issue 5, May 1997, Pages 771-773.

To create an Octave loadable function. Follow the instruction in this Octave Wiki. Basically, we need to create a C++ function, say fm3half.cc
``` #include #include #include "f77-fcn.h" extern "C" { int F77_FUNC (fm3hf77, FM3HF77) (double& vret, const double& x); } DEFUN_DLD (fm3half, args, , "- Loadable Function: [FM3HALF] = fm3half ()\n\ \n\ Returns the fermi dirac integral of order -3/2.") { octave_value_list retval; const double x=args(0).double_value(); //=args(0).double_value(); double vret; F77_XFCN (fm3hf77, FM3HF77, (vret,x)); if (f77_exception_encountered) { error ("unrecoverable error in fm3half"); return retval; } retval(0) = octave_value (vret); return retval; }```
which load a Fortran function called fm3hf77.f. You can take a look at the fortran function from this sourcecodesfm3half PDF file.

Note that the Fortran function is written as a subroutine and the arguments are passed by reference. The C++ function takes the first argument x and convert it from octave_value to double type. Then it passes to the Fortran function. The Fortran function saves the result in the first parameter vret, which is then converted to octave_value type.

## Inverse Fermi Dirac Integral using Octave/Matlab

I need to obtain the inverse of the fermi dirac integral of order -1/2 in my code. This is what I do. I create a file inv_fermi_dirac_mhalf.m

```function y=inv_fermi_dirac_mhalf(fval,init_guess) global fvalfermi; %get length of vector Nel=length(fval);```

``` %initialize y=zeros(Nel,1); ```

```%loop over all data for nloop=1:Nel fvalfermi=fval(nloop); y(nloop)=fzero('myfunfermi',init_guess(nloop)); end end```

The loop enable the function to take vector data. It uses optimization function fzero to obtain the inverse of the fermi dirac integral. You will need to install Optim and Miscellaneous package into your octave before using fzero function. This function calls another function which will find its zero. So in this case myfunfermi.m is

```function y=myfunfermi(x) global fvalfermi;```

``` ```

`y=fermi_dirac_mhalf(x)-fvalfermi;`

Note that I need to use a global function to pass into myfunfermi.m. This is because the function that fzero can call must be in the form

$f(x)=0$

And the function fermi_dirac_mhalf.m is from GSL package of Octave.

## Enable Octave mode in Emacs

Emacs Octave Support is already packaged in Emacs 22 and 23.

To begin using Octave mode for all `.m’ files you visit, add the following lines to a file loaded by Emacs at startup time, typically your `~/.emacs’ file:

```(autoload 'octave-mode "octave-mod" nil t) (setq auto-mode-alist (cons '("\\.m\$" . octave-mode) auto-mode-alist)) ```

Finally, to turn on the abbrevs, auto-fill and font-lock features automatically, also add the following lines to one of the Emacs startup files:

```(add-hook 'octave-mode-hook (lambda () (abbrev-mode 1) (auto-fill-mode 1) (if (eq window-system 'x) (font-lock-mode 1)))) ```

## Disable or Enable Touchpad in Kubuntu 7.10

Install “ksynaptics” using Adept or apt-get.

``` Option "SHMConfig" "on" ```
``` Section "InputDevice" Identifier "Synaptics Touchpad" Driver "synaptics" Option "SendCoreEvents" "true" Option "Device" "/dev/psaux" Option "Protocol" "auto-dev" Option "HorizEdgeScroll" "0" Option "SHMConfig" "on" EndSection ```