Pages

Notes on Linear Algebra

I have been taking Linear Algebra LAFF course from edX and Applications of Linear Algebra (Part 1) also from edX.

This page is for discussing what I learn, links to videos, books, web pages, articles related to linear algebra.

Useful resources for learning linear algebra:
Essence of Linear Algebra (Video playlist from 3Blue1Brown YouTube Channel)
What is the point of linear algebra? (from Reddit)
Coding the Matrix Resources (contains python scripts)
Auto-grading for Coding the Matrix (contains python scripts)
Mathematics for Machine Learning: Linear Algebra (from Coursera)
LAFF - Linear Algebra: Foundations to Frontiers (course from Edx)

Before reading anything related to linear algebra or taking courses, I would recommend you to watch all the videos from 3Blue1Brown channel on the essence of linear algebra. Again, after taking the Coursera and edX courses, if you watch the YouTube videos, you can understand linear algebra completely. 

Now I try to explain what is a simple use (or motivation for LA) of linear algebra.

Suppose, you are going to a shop on some day and by 5 apples and 10 mangoes and you pay 20 dollars and return to home. But you don't know how much each apple and mango costs. On another day (assuming the price is same) and buy 30 apples and 2 mangoes. Now you pay 15 dollars. Now also you don't know the value.  Now, using the number apples and mangoes you bought each time, and knowing how much those costed, you can calculated the cost of each apple and each mango.

You may ask "How"?

The answer is "Using Linear Algebra".

What you have to do is that you consider apple as x (or any alphabet you want) and mango as y you can construct an equation as follow.

"\begin{pmatrix} x & y \\ z & v \end{pmatrix}"

In math mode:
(5 10) (x)
                  =  (20, 15)
(30 2) (y) 

If you solve this linear equation, you will get the price of apple and mango.



How to understand an existing complete (open source) code

Here are some of the good discussions on this topic. See at the end of the tips for more links.
  • If the code is written in a language you are not familiar with, then take a crash course on that particular language. If you are good at any programming language, you can easily learn most of the programming languages easily.
  • Use mind map to learn about the different modules used in main program, where each module is defined, different call functions in each modules, where they are called, where they are defined, what each modules, functions do, what are the external (used defined) functions, what are the user defined data types in this code etc.
  • You should also have a general idea about what the code does actually. What are the inputs, what are the outputs, what the code does, what are the algorithms used, etc.
  • If you think that some portion in the open source may be shortened (for more readability or more efficiency), you may try it and ask for pull request. This will improve the code as well as you have contributed to the code. In some cases, if you are not sure what to do, but you are sure that something can be done, use Code Review (for improvement of the working code). 
  • For a give module, understand what it does. Then, understand what are the inputs for that module. Then, test that module by giving different inputs.
  • Now, do that for functions. What are the functions used in a given module, what are the uses of those functions, what are arguments, what is calculated, what is returned, how it is calculated etc.
SE Software Engineering site has a good collection of questions and fantastic answers. Here are some of the links for answering the question:
Best practices for understanding/resurrecting old technical code?
What is the most effective way to add functionality to unfamiliar, structurally unsound code?
How do you dive into large code bases?
I've inherited 200K lines of spaghetti code — what now?


Working with BLAS library


To install the BLAS and LAPACK library, you can try:

sudo apt-get install libblas-dev liblapack-dev

This will install both BLAS and LAPACK.

Also you should understand that LAPACK uses BLAS libraries in the backend.

Here is the main page of BLAS.

The BLAS (Basic Linear Algebra Subprograms) are routines that provide standard building blocks for performing basic vector and matrix operations. 

  • Level 1 BLAS perform scalar, vector and vector-vector operations
  • Level 2 BLAS perform matrix-vector operations
  • Level 3 BLAS perform matrix-matrix operations. 

Because the BLAS are efficient, portable, and widely available, they are commonly used in the development of high quality linear algebra software, LAPACK for example.





Now, 
How to know whether BLAS library is installed or not?
OR
How to find the location of BLAS library in linux?

type (on the terminal):

locate libblas.so 

This will return the locaiton as follow if BLAS is installed.

/home/username/libblas.so
/home/username/../../../lib/libblas.so
/usr/lib64/libblas.so.3

(for many computational codes (PySCF, etc), BLAS libraries are essential).




List of Scripts (HPC and Research)


To get the output geometry of a *.out file (Q-Chem)

Using rev, column commands

grep "  B  " lda_bnr_2_n_ring_03_geo_restricted_singlet.out | tail -n6 | awk 'BEGIN {OFS=" ";} {print $1, $3, $5}' | rev | column -t | rev

Using AWK 

grep "  B  " lda_bnr_2_n_ring_03_geo_restricted_singlet.out | tail -n6 | awk 'BEGIN {OFS="
 ";} {print $1, $3, $5}'

To extract the geometry from a *.out file ($f) and paste in a ea/ip file (and insert $molecule at the beginning)

#!/usr/bin/env bash
for f in *.out; do
    for g in ea*.in; do
        n=$(((ls $f) | cut -d_ -f6))
        t=$((2 * $n ))
        grep "  B  " $f | tail -${t} | awk 'BEGIN {OFS=" ";} {print $1, $4, $5, $6}' | rev | column -t | rev > xyz.xyz
        sed -i '1i -1 2' xyz.xyz
        sed -i '1i $molecule' xyz.xyz
        echo '$end' >> xyz.xyz
        cat xyz.xyz ./input_ea.in > $g
     done
done
ClusterHOme$ ./script_ea_input.sh
./script_ea_input.sh: line 4: (ls lda_bnr_2_n_ring_05_geo_restricted_singlet.out) | cut -d_ -f6: syntax error: invalid arithmetic operator (error token is ".out) | cut -d_ -f6")

========================================
Using two for loops:

for i in *.out; do 
    for j in *.in; do 
       what/you/want/to/do 
    done
done


GMail tips and tricks

To list unread messages in the mai

is: category:primary is:unread

To list all the unread messages

is: unread



Activate Undo Send option
For replying to similar messages (or routine messages) use canned message option.
Use Google calendar inside the GMail
Also use mail forwarding option to receive mail from other accounts.

How to write a paper quickly?

Top 10 rules
Note that writing a paper to journal is a painstaking effort and takes a lot of time for researchers in their early career (some times even for experts too). Sometimes, it may be possible for an expert to write a complete paper from conception to submission format. These are considered to be an exception. Personally, I take at least six months to come with the first draft of the manuscript. Here is one of the ways to write papers quickly for a journal of conference. 
  1. Start with the hypothesis and start writing. Don't procrastinate. Write from the starting of the work, when you are doing experiment, write the methodology.
  2. Review the notes and renew the literature search, and refine your conception and hypothesis
  3. Determine who your audience is - most likely reviewers, so get their concerns firstly addressed
  4. Create the outline and get the big picture done, i.e., complete the first draft while resisting the temptation to correct and edit as you go; the logical sequence of data/tables/figures may be the outline; while writing the first draft, take notes indicating what references might be needed and would be about, but don't stop to collect the references
  5. Begin with the easier part of the task - experimental section rather then the introduction; then follows the results and discussion section
  6. Then comes the really hard part - critical editing where you make sure that the English is coherent and the science is correct
  7. Write the conclusion in a numbered format
  8. Then comes the abstract and the acknowledgements
  9. Now comes the introduction, the two most important things to address in which are the purpose and relevant background
  10. Then collect the references.
  11. Use Latex for writing your paper. No matter how complicated your paper is, LaTeX will give you a best final draft.
Reference

Writing Good Papers (Prof. Michal Lipson)

Top advice form Prof. Michal Lipson, 

  1. Don't write paper for those 10 people who is specialized in your area (who will read no matter what). Our goal should be to reach much broader community (broader audience) 
  2. In one minute of grasping you paper, the reader should know what you did
  3. Paper should be crisp clear and easy to read (should not be hard to read). Writing your research without clarity may have no effect even though your work has potential to form a new field in research
  4. Tell your story in one minute.
Golden Rules

1. Cut! This seems to be the most important rule. Reduce any unnecessary word or phrases (cut many, anything subjective). Cut efficiently. Say aloud and write it. When we say something, we say clearly and simply. Just write as you explain to some one else. After writing, hunt down every word that will distract the reader from the main point you make. Very, really, basically, quite, generally - these words don't add much. Write without these sentences. Avoid starting with "there are". Following are the unnecessary phrases: for the most part, for the purpose of, in the case of, in the final analysis, in the event that, it has been estimated that, it may be argued that (come straight), as far as we know, as we know. Remove clunky phrases (with the word in bracket):  A majority of (most), A number of (many), Are of the same opinion (agree), At the present moment (now), By means of (by), Less frequently occurring (rare). Wordy vs Pointed: in spite of the fact that (although), in the event that (if), period of four days (four days), refer back (refer), shorter/longer in length (shorter/longer), had been previously found (hand been found). Ask these questions again and again: Is this word/phrase necessary?, What happens if I take it out? If it is not critical (not changing anything), remove it.

2. Use active voice. When use passive voice, the sentence becomes hard to read, and not actually gives who did the experiment. Use we found major differences.... We did this, We did that, etc.

3. Use parallel construction: If you want to be a good researcher, you must study hard, listen well, and think critically about the literature.

4. Start paragraph with main point: Start the paragraphs with your main point then expand (Professor's favorite). This is important to write a crisp clear paper. Every paragraph should start with the main idea of the whole paragraph. Rest of the sentences are should be just details explaining the first sentence. If you take first sentences of all the paragraphs and put them together, it should form the abstract.

If you want to write a sentence and if you don't know how to order it, always bring the important points front.

Know the difference between the introduction and discussion. 
In introduction, start with what is available, then explain what is missing, then your work (i.e., the introduction moves from general to specific)
In the discussion, at the end, say what amazing thing you did is going to revolutionize the word  (The discussion moves from specific to general). You know the simplification, why and what you did some body else would care, and why the deficiencies you have might or might not be fundamental (which is pretty important). Put your work in the big picture. Your performance is not the best. But, put the minor drawback of the work. 

In results, you show the number. In discussion, you show the big picture. The discussion should be the big picture. Not the little details.

Most important things not to put in the discussion
Do not simply repeat what is in the Results
Do not try to explain every minor flaw
Do not try to explain away every unexpected result
Do not exaggerate or make extravagant claims 
Don't hedge
(Editors and reviewers may read only this part, if they are busy. They don't care about the number. They care about the big picture.)

Need to attract very wide audience. But don't over claim and don't exaggerate. 
















Links to learn Machine Learning with TensorFlow


TensorFlow official tutorial
A Neural network playground using TensorFlow


Machine Learning Tools Installations

Installations

pip install tensorflow --user
pip install Keras --user


To check the full path where TensorFlow is installed

python -c 'import os; import inspect; import tensorflow; print(os.path.dirname(inspect.getfile(tensorflow)))'

/home/full/path/tensorflow

Density Functional Theory (DFT) Researchers

Density functional theory (Kohn-Sham formalism), developed for finding electronic properties of materials, based on Hohenberg-Kohn theorems, cleverly overcomes the pain of manybody effects of electrons. Here I provide the groups which develop electronic structure theory (mainly post Kohn-Sham DFT theory), develop codes for the calculation of properties using DFT.

Following is the (partial) list which may be updated regularly. These are the links for the detailed page containing the group/professor/research's research interest, link to their page, etc. The group's name is given by the groups PI's first name (mostly).

  1. Becke (Axel D. Becke, Dalhousie University (Department of Chemistry)
  2. Burke (Kieron Burke, UC Irvine)
  3. Hardy Gross (E K U Gross, MPI Halle)
  4. Perdew's Grop (John Perdew)

You may be interested in these posts

Error in image file conversion: convert-im6.q16: not authorized `test.eps' @ error/constitute.c/WriteImage/1037.

This error is because of the vulnerability. This allows remote execution of code using image formats. So, some Linux distributions by defaul...