C++ initializer list order in a constructor matters?

This is a computer related article, and about THE hardest language, C++. So, I think the audience is again limited.

gcc's -Wall option sometimes gives a warning as the order of initializer list in the constructor is wrong. For example,

% g++ -Wall initializer_list.cc
initializer_list.cc: In constructor 'InitializerListTest::InitializerListTest()':
initializer_list.cc:30: warning: 'InitializerListTest::d_j' will be initialized after
initializer_list.cc:29: warning: 'int InitializerListTest::d_i'
initializer_list.cc:7: warning: when initialized here.

This warning said that the order of initializer list in the constructor and the member variables declaration order are different. The following code is such an example.


class InitializerListTest {
/// constructor
InitializerListTest() :
d_j(123), // j = 123;
d_i(d_j - 1) // i = j - 1;
// empty
/// print out
void print()
std::cout << "i = " << d_i << ", j = " << d_j << std::endl;

/// i, j
int d_i;
int d_j;

int main()
InitializerListTest ilt;
return 0;

This warning pointed out that the member initialization order does not related with the order of initializer list in C++. In the C++ book 3rd edition by Stroustrup, Section 10.4.6 Class Objects as Members describes this as "The constructors are called in the order in which they are declared in the class rather than the order in which they appear in the initializer list. To avoid confusion, it is best to specify the initializers in declaration order." This is the meaning of the warning. In the above sample code, the initializer list is

d_i(d_j - 1).

This looks like the following code,

d_j = 123;
d_i = (d_j - 1);.

But, actually, it is

d_i = (d_j - 1);
d_j = 123;.

Therefore, the value of d_i is undefined. In my environment, the execution result is

i = 32766, j = 123.

Since this is a source of the confusion, I agree the C++ book and gcc warnings. But, the real problem comes from the initialization depends on other member initialization. In such case, I avoid to initialize the member in the initialization list, rather do in the constructor body. It would be more accurate that if the warning detects the dependency between the initializer list.

The answer of the title of this article, "C++ initializer list order in a constructor matters?", would be Yes. By the way, Lisp has let and let* for the block local variable initialization. We can initialize the let function's element in Lisp, and let* is the sequential version, which defines the order of initialization. C++'s initializer list is an implicit version of the let*.

I think it is a bit unnatural in C++ since C++ has only implicit let*, which is based on sequential model. C++'s design is usually tend to execution time optimization. But this definition lead us to make it hard to understand and to be potentially slower. (Or is it a nature of C++?)


Visual C++ ... MD and MT compile option

This article is only for limited audiences. If you use Visual Studio C++ (2008) and have a question about What is the MD and MT, then you might be interested in this.

When I made a Console Application on the Visual C++ 2008 using STL. I start to get the following error.

error LNK2001: unresolved external symbol __imp___CrtDbgReportW

It is related with a Windows runtime library. One thing is Unicode related, so I switched off.

It seems this is related C/C++ Code generation, Multi-threaded Debug Dll (MT option) (/Mdd) or Multi-threaded debug (/MTd). (Note: only one character difference /MDd and /MTd.) In some reason while I develop an application, I got a warning about there is a library conflict, and suggested to ignore one of the runtime libraries. I followed the link's output and ignore the 'MSVCRT' library. But this is the problem. I removed it from the ignore library list.

I set up all the Code Generation to Multi-threaded Debug DLL (/MDd) for debug, and not ignore any runtime library. Then now it works. This was a confusion.

Then, I asked my colleague, T. What is this MD and MT stuffs. He said:

- MT: Multi-threaded static library. This is good for distribution a whole application package, since everything is statically linked and there is no dependency to the environment.

- MD: Multi-threaded Dynamic link library. If you distribute some library instead of a whole application, dynamically linked runtime is better since, some part of the program uses one version of runtime, and the other uses different version,this causes a trouble. For example, 'new'ed some memory at one version of runtime, and 'delete'd by other version of runtime could be a trouble.

So, it depends on the situation and I see now it is better to have both. But these are too similar and I am easy to confuse them.


Is spamming really profittable?

Spam mails are everywhere and everyday. There is a question, "Is spamming really profitable?" One "academic" paper try to answer this question. They set up the bot net, set up fake web pages, send spam mails (350million spam emails in their experience), observe how many can go through, how many comes to the web page, and how many actually buy the medicine. This is the paper: Kanich et al. Spamalytics: an empirical analysis of spam marketing conversion. CASM, 2009, Vol.52, No.9, pp.99-107

I do not know how, but they claims it they cleared U.S. legal doctrine and ethics.

The authors said, "We would be the first to admit that these results represents a single data point and are not necessarily representative of spam as a whole." and they even said there is some danger to interpret the result's means. But, for 28 days experience, 350 million spam mails are sent, 82 million delivered (but, of course they do not know how many are shown up in user's inbox, most of them might be just filtered to the spam folder.), more than 10,000 web page visitors, and 28 purchased the medicine. The transaction was 2800 dollars. 100 dollars/day transaction. Their method only uses 1.5 % of the botnet ability, so, 7000 to 9500 dollars/day transaction are extrapolated. Of course there is a machine and human cost and also the business cost (if the spammer does the business) are not included, but, it could be profitable. This is an interesting paper.


What is the rank of matrix

I will talk about the part of Introduction to Linear Algebra by Gilbert Strang, again.

There is an important indicator of matrix called "rank". According to the http://mathworld.wolfram.com/, the rank of a matrix is the dimension of the image of the matrix, corresponding to the number of linearly independent rows or columns of the matrix. This is a common definition in a textbook.

In the Strang book, the rank is explained from a bit different way. He explained rank and elimination together. The definition of rank is the number of pivots after the elimination. After all, they are the same, but I found interesting that how to approach to the concept of rank through the elimination.

Gaussian elimination is employed to diagonalize of a matrix. Because if we could diagonalize a matrix, we can easily solve the linear equations. Let's think about a bit of elimination. We could use the following matrix as an example matrix.

A =
|1 2 2 2|
|2 4 6 8|
|3 6 8 10|

Let's do elimination.

Subtract row 1st x 2 from row 2nd.

|1 2 2 2|
|0 0 2 4|
|3 6 8 10|

Subtract row 1st x 3 from row 3rd.

|1 2 2 2|
|0 0 2 4|
|0 0 2 4|

Subtract row 2nd from row 3rd.

|1 2 2 2|
|0 0 2 4|
|0 0 0 0|

Only two rows remain. The number of remaining rows are the rank, therefore, rank of this matrix is 2.

Let's think about a bit more what was done. Let's consider the matrix is a simultaneous equations. Then, the matrix

|1 2 2 2|
|2 4 6 8|
|3 6 8 10|


1 x1 + 2 x2 + 2 x3 + 2 x4 = b1 ... (1.1)
2 x1 + 4 x2 + 6 x3 + 8 x4 = b2 ... (1.2)
3 x1 + 6 x2 + 8 x3 + 10 x4 = b3 ... (1.3)

where, x1, x2, and x3 are unknowns and b1, b2, and b3 are the right hand side.

Elimination does a subtract or an add one equation from the others with multiplied by a constant. After these operations, there remains only "minimal number of equations in the matrix." You could ask me "what is the maximal or minimal number of equations in the matrix." It is also called "independent equations," but, the minimal number of equations means that how many equations are there in the matrix. You would say, that was three. But it is not always true, since you can make equations from the others.

The following (2.x) are created by elimination of (1.x).

1 x1 + 2 x2 + 2 x3 + 2 x4 = b'1 ... (2.1)
2 x3 + 4 x4 = b'2 ... (2.2)

The minimal number of equation means, if we have these (2.1) and (2.2), then we could make (1.1), (1.2), and (1.3). Therefore, (2.x) are the minimal set. In other words, the minimal set of equation to make (1.1), (1.2), and (1.3), are (2.1) and (2.2). For example, (2.1) * 2 + (2.2) makes (1.2). We could make more equations from (2.1). When we doubled (2.1)

1 x1 + 2 x2 + 2 x3 + 2 x4 = b1,


2 x1 + 4 x2 + 4 x3 + 4 x4 = 2 b1.

We could multiply this three times or four times. But there doesn't create any new equations. Let's think about the simplest one.

The solution of

2 x = 6

is x = 3. If we doubled the equation, we could get

4 x = 12,

but the solution is still x = 3. These are all the same equation to find the x. we could use 2x = 6 to make 4 x = 12. There is no new information in these equations. Actually all can be made from x = 3.

We could make infinite number of equations based on a few number of equations by multiplying constants and adding them. In this case, the important thing is what is the minimal set of the equations. That's the "identity" equations of the matrix (not the identity matrix). A complex matrix could be actually a simple, but it just might look like a huge matrix. To understand a matrix, we should find the identity equations of the matrix. Elimination is the tool to find it out.

Now I could answer the question of the title, what is the rank of matrix. Matrix rank is the number of identity equation of the matrix. How many equations actually the matrix has, that is the rank. We can not simplify a matrix less than its rank. That's the reason, matrix rank is important.

「行列の正体見たり rank 数」斉

(This is a Senryu in Japanese, similar form of Haiku. But Haiku needs the words about the season by definition, and this does not have that. A translations could be "I see what you are, matrix, this is your rank." Hitoshi)

By the way, the rank of Laplacian matrix in differential geometry is n-1 when the size of matrix is n by n. The Laplacian matrix can be considered a local differentiation. There is one fix point is missing to determine the whole points. (The right hand side is differencial coordinate.) As an analogy, one order differential equation needs to one integral constant to determine the integration. Does this related with the rank of matrix? But wait a moment, Laplacian is the second order derivative, isn't it? OK, I still do not understand what the Laplacian matrix is. I will continue to study and find out what it is. At least, I should continue the Strang's book.


C++ is hard... link considering dynamic library plugin.

This article might be interesting to someone who writes a plugin software with C/C++ using shared library (dynamic link library) mechanism. But, if you are not, I think this is totally rubbish.

When I develop a plugin, I could compile it and link it, but when I run it, I happen to see an error message, ``no such symbol''. I see the symbol in the executable via nm/dumpbin, but, it is not recognized from the plugin code at runtime.

Why this happens? Because the linker optimizes exposing symbols.

Some of the software needs symbols that are only used by its plugin. When you need to build such software, you need to ask to the linker to keep those symbols. Otherwise linker trashes un-referenced symbols. This is usually useful, otherwise my disk and memory will be filled up by copies of unused symbols.

To ask to the linker that ``please keep unused symbols since I might need them later,'' you need to specify --export-dynamic option (liker option) to the linker. If you use gcc as the linker driver, the option is -Wl,--export-dynamic.

In this way, the executable can have the symbols that are only referred by dlopen-ed code.

This method keeps all the symbols that are exported from the executable, but you can also specify the symbols you want to keep, one by one. This is effective to avoid reverse engineering a bit, since I can control which symbol I want to expose. But, this is a pain for developers and I sometimes envy the freesoftware writers that they do not need to care and manage these cumbersome problem. Sometimes I spent days only for this.

The motivation of writing this article comes from my job task. We also do this. Sometimes our customer complains our library, ``Hey, you don't give us the promised function! Where it is?'' Not only that, I made a bug in a make file, my colleague can not use our software. Sorry, Matthias.


Using LaTeX CJK package to use three languages at once

(The English translation is below the German text.)

Normalerweise verwende ich platex um Japanisch zu schreiben. Damit kann ich einen japanischen und einen englischen Text zusammen in einem LaTeX Dokument verfassen. Aber als ich einen deutschen Text unter Verwendung des Babel Pakets hinzugef"ugt habe, wurde die folgende Warnung angezeigt:

Package babel Warning: No hyphenation patterns were loaded for the language `ngerman'.

Ich habe im Internet danach gesucht, ob jemand diese drei Sprachen gleichzeitig verwendet hat, aber ich konnte nichts dazu finden. (In der Vergangenheit gab es ein "ahnliches Problem auf das sich die Warnung bezogen hat. Aber dieses wurde schon gel"ost.)

Es scheint, als ob einige Dateien mit initex erneut kompiliert werden m"ussen. Das platex Paket von Ubuntu machte dies jedoch nicht. Ich vertraue immer auf die Worttrennung von LaTeX. Aber gestern hat meine Tandempartnerin bemerkt, dass der Bindestrich bei ,,in meiner Heimatstadt'' als ``in mein-er Heimatstadt'' gesetzt wird. Das ist falsch. Ich habe herausgefunden, dass das CJK Paket von LaTeX dies korrekt behandeln kann. Diese LaTeX Datei ist ein Beispiel daf"ur, Japanisch, Deutsch und Englisch in einem LaTeX Dokument zu kombinieren.

[1] http://blogs.fsfe.org/ciaran/?p=150+k

Thanks to Leo to proofreading in the German text.

English version

I usually use platex for writing Japanese. I can have a Japanese and English mixed document by platex, but when I added a German text to such document with the babel package, the following error message is shown up.

Package babel Warning: No hyphenation patterns were loaded for the language `ngerman'.

I could not find a solution on the web that someone uses Japanese, English, and German at once in a LaTeX document. (In the past, there was a problem related with this error, but it has been solved.)

It seems I need to recompile some files with initex. Ubuntu's package seems not to do this. I always rely on the LaTeX about the hyphenation. But, yesterday my tandem partner noticed that ``in meiner Heimatstadt'' is hyphenated as ``in mein-er Heimatstadt.'' This is not correct. I found LaTeX's CJK package can handle this situation. This is a sample file of writing Japanese, German, and English.

LaTeX source

%defparentheses 【 】
%defswap |
%defdelete /
%defcomment ;
%deforder older-first
%defversion 0.9.5-current

\usepackage{CJK} % CJK latex
%\usepackage{hyperref} % Unfortunately, this does not work in CJK


\title{日本語ドイツ語英語混在の \LaTeX 文書}


\section{CJK パッケージを利用して三ヶ国語を同時利用する}

私が利用している日本語の\LaTeX\ は \texttt{platex} である.
\texttt{platex} で日本語と英語を混在させるのは問題がないが,ドイツ語を利
Package babel Warning: No hyphenation
patterns were loaded for the language
というエラーがでる.Web 上を探したがこの日本語英語ドイツ語の三言語を同時
に利用する方法というのはどうもみつからなかった.(過去に Ubuntu にはこの

これを解決するには \texttt{initex} によっていくつかのファイルを
recompile しないといけないようである.Ubuntu の \texttt{platex} の
package はおそらく babel を考慮していない.私は hyphenation は全て \TeX
まかせなのだが,この場合,in meiner Heimatstadt が in \mbox{mein-er}
Heimatstadt と hyphenation されてしまうことがあり,私の tandem partner に
ことが \TeX を使っていて便利な点なのに,間違いをされるのは困る.そこで,
いくつか試してみた結果,\LaTeX\ の CJK package ならできるようであ
る.このファイルは CJK package を使って,日本語,ドイツ語,英語を同時に利

\selectlanguage{american} % Use american
\section{Using CJK package to use three languages at once}

I usually use \texttt{platex} for writing Japanese. I can have a
Japanese and English mixed document by \texttt{platex}, but when I added
a German text to such document with the babel package, the following
error message is shown up.
Package babel Warning: No hyphenation
patterns were loaded for the language
I could not find a solution on the web that someone uses Japanese,
English, and German at once in a \LaTeX\ document. (In the past,
there was a problem related with this error, but it has been solved.)

It seems I need to recompile some files with initex. Ubuntu's package
seems not to do this. I always rely on the \LaTeX\ about the hyphenation.
But, yesterday my tandem partner noticed that ``in meiner Heimatstadt''
is hyphenated as ``in \mbox{mein-er} Heimatstadt.'' This is not correct. I
found \LaTeX's CJK package can handle this situation. This is a sample
file of writing Japanese, German, and English.

\selectlanguage{ngerman} % Use new-german
\section{Die Verwendung des CJK Pakets um drei Sprachen gleichzeitig zu

Normalerweise verwende ich \texttt{platex} um Japanisch zu
schreiben. Damit kann ich einen japanischen und einen englischen Text
zusammen in einem \LaTeX\ Dokument verfassen. Aber als ich einen
deutschen Text unter Verwendung des Babel Pakets hinzugef"ugt habe,
wurde die folgende Warnung angezeigt:
Package babel Warning: No hyphenation
patterns were loaded for the language
Ich habe im Internet danach gesucht, ob jemand diese drei Sprachen
gleichzeitig verwendet hat, aber ich konnte nichts dazu finden. (In der
Vergangenheit gab es ein "ahnliches Problem auf das sich die Warnung
bezogen hat. Aber dieses wurde schon gel"ost.)

Es scheint, als ob einige Dateien mit \texttt{initex} erneut kompiliert
werden m"ussen. Das \texttt{platex} Paket von Ubuntu machte dies jedoch
nicht. Ich vertraue immer auf die Worttrennung von \LaTeX. Aber
gestern hat meine Tandempartnerin bemerkt, dass der Bindestrich bei ,,in
meiner Heimatstadt'' als ``in \mbox{mein-er} Heimatstadt'' gesetzt wird. Das
ist falsch. Ich habe herausgefunden, dass das CJK Paket von \LaTeX\
dies korrekt behandeln kann. Diese \LaTeX\ Datei ist ein Beispiel
daf"ur, Japanisch, Deutsch und Englisch in einem \LaTeX\ Dokument zu

\verb+[1] http://blogs.fsfe.org/ciaran/?p=150+k

Thanks to L. to proofreading in the German text.



Logically speaking....

It is election time in Germany. I can find quite a lot of notice boards. I was surprised that one political party's motto is

"More tax to everyone"

This party got a lot of votes at Saarland recently. Actually, they did not directory say it, but they have two slogans:

1. Reichtum besteueren (Tax the rich: Front side)

2. Reichtum fuer alle (Rich for everyone: Back side)

"More tax to rich people" and "Everyone should be rich", therefore, "More tax to everyone." Am I missing something?

My friend L. told me this.

Front side

Back side


cool matrix (5)

Finally I would like to talk about cool matrices.

Let's think about a three dimensional vector [x1 x2 x3]' =


(Here ' means transpose.) The vector of difference of each term is [(x1 - 0) (x2 - x1) (x3 - x1)]'. Let's think about a matrix A that makes this difference in the right hand side. I will tell you why we think such a matrix. A is

[ 1 0 0
-1 1 0
0 -1 1].

Let's check it out.

[ 1 0 0 [x1 [ x1 - 0
-1 1 0 x2 = x2 - x1
0 -1 1] x3] x3 - x2 ]

For instance, use [x1 x2 x3]' = [1 4 9]',

[ 1 0 0 [1 [ 1
-1 1 0 4 = 3
0 -1 1] 9] 5 ].

The right hand side is the difference of each term. By the way, this matrix has its inverse matrix B,

[1 0 0
1 1 0
1 1 1].

Let's compute A B,

[ 1 0 0 [1 0 0 [ 1 0 0 [1 0 0
-1 1 0 1 1 0 = (-1+1) 1 0 = 0 1 0
0 -1 1] 1 1 1] (-1+1) (-1+1) 1] 0 0 1].

Therefore, A^{-1} = B. Please be patience a bit more. Let's look into what is B.

[ 1 0 0 [x1 [x1
Bx = 1 1 0 x2 = x1 + x2
1 1 1] x3] x1 + x2 + x3]

You see B is adding terms. A does difference and B does sum. I was surprised here. The idea ``difference'' belongs more to calculus, compare to linear algebra. In calculus, difference is d/dx. The inverse operation of difference is integral (\int). These matrices are:

A ... d/dx
B ... \int

and we know A^{-1} = B.

A^{-1} = {d/dx}^{-1} = B = \int
===> {d/dx}^{-1} = \int

Matrix behaves an operator, now we think matrix A is a differential operator and B is an integral operator, then these are inverse operation each other. I hope you can see why I surprised. We can see an analogy of the fundamental theorem of calculus in a matrix operation. So I think these matrix A and B are cool matrices. I might be only one to think so, I can imagine many people don't agree with me... Well.

This matrix story is in the book: Gilbert Strang, ``Introduction to LINEAR ALGEBRA''. This is my personal hot book. He describes what is the inverse of matrix with calculus analogy. That is fantastic and I like his book.

For the people who is lazy as me, here is a octave code.

--- BEGIN diff_and_int.m ---
a = [1 0 0; -1 1 0 ; 0 -1 1]
--- END diff_and_int.m ---

When you run this code with typing 'octave diff_and_int.m', you will see
the matrix B.

cool matrix (4)

There are so many applications of this linear operation. For example, one day's total sales of a supermarket can be computed in the same way:

price of item 1 * number of sold of item 1 + price of item 2 * number of sold of item 2 + ...

Again, price of item 1 * price of item 2 has no meaning here and therefore, we should not do that.

Matrix is useful when we want to perform this kind of operation. Of course we can use matrix (so many) different ways, even so this is still useful.

Until here, I hope this is understandable for a junior high school student. But, I realize I could not reach the entitled theme, a cool matrix, in this pace. Then, I will skip several topics, like, what is the relationship between a linear operation and a matrix. I am going to talk about a cool matrix in the next article. The audience would be a bit limited. I assume you know what is matrix or vector and how to write down this language, also can speak a bit. So I assume the audience is a
high school student or more.


Cool matrix (3)

Today's abstract

Let's talk about impossible multiplication. An impossible multiplication is just it doesn't make any sense.

``How much is 6 Euro pasta for 5 people?''

is 6 * 5 = 30 Euro. But,

``How much is 6 Euro pasta for 7 Euro salad?''

doesn't make any sense. If someone does 6 * 7 = 42. What does it mean? But it seems some people teach these stuffs to children. They make the students to hate mathematics. That's pity.

Main part

Here multiplication is only with a number. If we have some variables x and y, we can do 3 * x + 5 * y, but not x * y. You might wonder what kind of mathematics we can not do x * y, that is such a simple operation. But I would like to emphasize, we have not so much freedom to compute numbers in real world with meaning. We all learned that we sometimes can not multiply numbers, again in real world.

Let's think about in a restaurant as an example. For instance, x or y are a menu A and B's price, respectively. As more vivid example, this restaurant has only two menus, a pasta and a salad. We are five people and went to this restaurant. The pasta costed 6 Euro and the salad costed 7 Euro. The three ordered pasta and two ordered salad. Then total amount is:

3(persons) * 6 (price of pasta) + 2 (persons) * 7 (price of salad)

This is basic of linear operation since there are additions and multiplications. You can see that the multiplications of the price of pasta and price of salad, 6 * 7 = 42 has no meaning here. What is price times price? Namely,

``How much is 6 Euro pasta for 5 people?''

I could understand this question, but,

``How much is 6 Euro pasta for 7 Euro salad?''

has no meaning. At least I can not explain what it is. There are two things I could not explain in this question. The first one is this multiplication itself, and the second is the question ``how much?'' Multiplication can change the unit, this question is that. But the question stays the same unit.

For instance, we have ten strings, each is five meter long, then total length are 5m * 10 = 50m. But if we have a land 5m * 10m = 50 square meters. The question here is:

``How long (meters) is the length of land that has five meter width and 10 meter height?''

If the anser is 50 meters length land, I got a trouble. Let me high light the unit of the first question.

``How much (Euro) is 6 Euro pasta for 7 Euro salad?''

I do not get the meaning of the question. If someone sells me 50m (length) land, I have a problem. It could be 50m long and 1mm width, and the price is the same as the 50m^2. I recommended to know the basic mathematics not to be cheated like this.

We do not do such multiplication since this is nonsense. We can always multiply the numbers themselves, i.e., 6 * 7 = 42. But, there is a case we can not do that if we think about the meaning. I once read a book explaining -1 * -1 = 1 as debt times debt becomes money. This is a good example that the calculation is right, but the explanation is wrong. It is simply we can not debt * debt (what does it mean?). If you were explained like this, I understand you hate mathematics. It is better to not to give a chance to cheaters. However, some cheaters learn mathematics to cheat people, oh well. By the way, I like a movie, Paper moon (http://www.imdb.com/title/tt0070510). In this movie, there is a cheat like here, exchanging nonsense to calculating the numbers.

Cool matrix (2)

I am not sure it is a good idea that using music as an analogy of mathematics. But let me try it. Most of the music is combination of notes. These notes are not alone. We call a sound if it is alone. If we make sounds together in particular sequence, they become a music. Even I could make a C sound by a piano. But, music is different. Make a C sound by typing a key is an analogy to that we could add two numbers. We can't start the music or mathematics if we don't have this basis. These are fundamental, but, if we made a harmony or thought about vectors, they reach to another level. One sound and a music are different. One scaler operation and a matrix-vector operation are different as well. I think a deep insight of linear algebra comes from like that. Some of the music people might complain this analogy, but, some music are quite mathematical for me, like Bach's musical offering (inverse operation, recursive, infinite), I just think about the analogy.

Well, I would like to say please don't hate linear algebra or matrix because it sounds awkward. I found some kind of entrance of this harmony, so I am writing this article.

I think it is better to stop here and making a new section.


Cool matrix (1)

First I would like to introduce a bit of linear algebra. Then, I want to talk about a cool matrix.

Here, a matrix is a mathematical object, not the movie's matrix. It becomes a long story about the matrix, but in short, this is about linear operator.

But this is just a word substitute from ``matrix'' to ``linear operator,'' it seems I just fuzzify you. It is like saying Cat is Neko (in Japanese). Just substitute the words does not make sense for the people who don't know about cats.

If I could add a bit more words, linear operator treats addition and multiplication only. It's bit strange when I said ``linear algebra,'' that sounds something great, especially in Japanese. I don't know why. Some people misunderstood that is lofty, this sometimes annoys me, oh well. On the other hand, linear operations are combination of addition and multiplication. These are the same, but, if I said ``I study addition and multiplication'' instead of saying ```linear algebra,'' sometimes people said, ``Do you seriously study addition and multiplication at your age?''

Addition and multiplication has deep insight. I think when the mathematics thought about not only a single number (scaler), but also a vector and add vectors, this deepness was added. For instance, it is 5km from my home to my company, 10 km from my home to a film theater, and 11 km from my company to the theater. If these buildings are on a line, we can add and subtract 5, 10, 11 to find the relationship of the distance, but that is rare. In such case, we need not only the distance, but also the direction. We should compute the these distance including their direction. Mathematics could represent them by vectors. These are some kind of ``extended(*)'' numbers, but we are happy if we could do addition and multiplication on them (Since we could calculate the distance from my company to the film theater), we can not make light of these addition and multiplication. But, the bottom line is that linear algebra is addition and multiplication.

It becomes longer than I expected, so this is for today.

* There is a problem to call a vector as an extended number since it is not clear how to compare the vectors and how to divide the vectors. We can compare or divide usual numbers like 3 or 7, so if number should have these property, vector is not a number. Here we confront the problem that what is the number? But this is not today's topic, so I stop this theme here. If you want to know about some kind of numbers, I have a series of blog about Peano number. Also there are many other number systems.


Vote from abroad II

The role of the rest of four people is following: 1. the one checks my vote registration is genuine. There is the number and name are recorded. 2. the one distributes the voting papers and envelopes. Then I go to a booth to write the vote and seal the envelopes. 3. the one records I voted. 4. the one seals the envelope A and took my vote.

I asked how many people come to vote. The answer is almost 100 people. There is not so many Japanese lives in Berlin, but around 3000. The vote is not only from Berlin, I think the voting ratio is quite low. By the way, the embassy's people were so kind. There is no such reception in Germany even in a shop.

The merit of voting from abroad is I need not to hear the election campaign. There is no disturbance campaign in Germany. Most of Japanese election campaign using the microphon car and just say the candidates name all the day. Everytime I was disturbed by such annoying campaign car, I swore I will never vote this disturbance person. If one did not think about others disturbance, how can I vote that one. Also, I doubt the efficiency of this just shouting the name. (Maybe you do not understand this. In Japan, political party shout its name using advertizing cars. Like the cars run around with microphone, shout CDU! CDU! or SPD! SPD! something like that. When you visit to Japan in the election time, you can take a video and put them onto the YouTube.) If someone care the policy, then they read newspaper, watch the TV, or discuss with friends to decide the vote. If one does not care, does not matter shout the name or not. In Japan, there are a lot of motto, but I also doubt the effect. (Do not steal! or something like that. My imagination does not enough how this works.) But I am afraid that I voted to one who is doing the campaign? Germany is better at this point.

On the other hand, there is some campaign using notices in Germany. For example, one big political party puts ``Wir haben die Kraft.'' I think this in Japanse, then ``Oretachi niha chikara ga aru. (We have the power.)'' This words usually followed by ``dakara omaetachi oretachi ni sakarattemo muda nanndayo.'' (Deshalb, Wiederstand ist zwecklos. (Therefore, the registance is futile.)) So, I wonder, Merkel becomes a dictator? I hope not. Maybe here ``wir'' is not CDU, but Germany. But, still I am afraid as an foreigner. Everyday, I saw them, I wonder what does it mean. This words, we have the power, could encourage the weak people, however, when this words come from the people who have the power, usually connects with too much pride. I don't recall an example that went good end.

Vote from abroad I

There is an election in Japan at August 30th, 45th Syuugiin sousenkyo (the House of representative). I don't live in Japan, but recently I can vote from the outside of Japan. Recently means it is possible after 2000. This was only for proportional representation, but after 2007, I can vote for small electoral district at my last Japanese address. There was a judgment of this, the result is a Japanese can not vote for small electoral district is against the constitution low. I got benefit of this judgment and I thank to the people who worked on this. However, the last time I mistook the election date. I need to vote in advance since my vote will send to Japan by mail. So it goes...

I decided not to make the same mistake, I visited Japanese embassy 21st. If I made a mistake, I had still other days.

There was a sign of ``Here is election'' in front of Japanese embassy (in Japanese!). Great! But, the gatekeepers don't speak Japanese. I said, ``Ich komme hier fuer die Wahl.'' (I come here to vote.) But I am not sure this is correct, so I repeat, ``die Wahl, die Wahl (vote, vote).'' Then, the gatekeeper said, ``Haben Sie wahrscheinlich... (Do you have maybe, ..)'' I asked ``wahrscheinlich was? (maybe what?)'' However, I thought I need to show documents, so I show my passport and vote registration document. Then, he opened the gate. I realize a few seconds later, maybe he said, ``Haben Sie den Wahlschein? (Do you have the vote document)'' I never thought about this vote registration paper's name in German. Many of my friend don't believe I can not hear the L and R difference. I suddenly want to say to friends, ``See, I told you, I can't.'', but nobody was there. Oh, well.

There were five Japanese people in the voting room. The first lady explain me the overview of how to vote. There are two voting paper, here is for the proportional representation, here is for small electoral district. This is the envelope (A) to send the vote to Japan. Please write your vote registration number and sign on it... Wait a moment, then this shows I vote to whom. She continue to explain. There are four more envelopes. You need to use two envelopes (B:large, C:small) for each vote. When I wrote the vote, I put the paper into envelope C. Nothing is written on the envelope C. Then I seal the C, put it into B. I need to write my registration ID on B and sign it. Then, I put these two envelope Bs into envelope A. A is send to Japan. A and Bs are opened under observation, envelope Cs are mixed with other votes. This way, the secret of the vote is protected. Of course there could be broken, but, I trust them. (Anyway, I could tell whom I voted to to my friends.)

... will be continue.


printf and va_args

Last time, I wrote about a problem with printf and size_t. However, I think it is better to say that this is caused by va_args. Because, a program needs to know what type of arguments are there when we use va_args. I think the promotion of arguments is invented to alleviate this problem.

I met an bug as follows recently. This bug only lives in 64bit environment.

Let's assume the following function using va_args.

void vafunction(const char* p_name, ...)
va_list ap;
va_start(ap, p_name);
while(p_name != 0){
// do something
p_name = va_arg(ap, const char*);

If I call this function as

vafunction("This sometimes doesn't work in 64bit.", 0); // (1)

then, this sometimes crashes. This does not always crash. When I traced this bug by a debugger, sometimes p_name never 0, then segmentation fault happens.

But, if I call this as

vafunction("This should always work in 64bit.", NULL); // (2)

always works. The difference here is that the last argument is 0 or NULL only.

Because, the vafunction assumes the arguments are (const char*), however, (1)'s last 0 is 32bit (int)0.

The reason of (2) has no problem is that NULL is defined as 64bit (void *)0. Therefore, this crash only happens in 32bit. In the case of (1), I observed sometimes extra 0 is inserted on the stack, but I think that is just coincident.


printf with size_t (in C)

When you print out a size_t data with printf, 32bit and 64bit has an issue. This is described at, for instance,


The horror of this problem is that it is just a one character typo and the output becomes not only incorrect, but also it could crash the program. Especially under above pages condition, usual compiler can not detects the problem.

The conclusion is 'use stream,' then the problem itself does not happens unless you have a huge text data (but even so...).

But there is an another question for this. Why float and double have %g and %f only? One of my colleague (D.S.) asked this question.

The problem is caused by the size of size_t alters according to the environment, but the printf only see the format string and operates the stack memory (via va_args), therefore, if you have a mistake in the format string, the memory operation can't be right. Then, why float and double, their size of is 32bit and 64bit, respectively, have no problem?

Because, va_args has a concept of promotion in C language. If a function has va_args, char becomes int, float becomes double. This is called promotion. float is always becomes double before a function is called in va_args. This is explained in K&R books (at the explanation of va_arg). If you are interested in further, OpenBSD's man pages http://www.openbsd.org/cgi-bin/man.cgi?query=va_arg, or, see gcc's manual, Calling Variadic Functions (http://www.chemie.fu-berlin.de/chemnet/use/info/libc/libc_28.html)

But the conclusion is the same, it is better to use stream. I think it is better to do if I could make the problem itself impossible.

The reason I wrote this is that: a DCC software called 3ds*** crashes under some condition because of this one character typo. I follows this conclusion, so this is not my code, but one of my job is debug this software. OK, this is my job, so maybe it is fine, I get some money for this. But, there are customers who paid to this software, if they know someone just lazy and do not care the robustness, that crashes their data, scene, and their time, ... I am afraid they got angry. I should not say this as a software developer: I want to make our software robust and stable instead of adding unstable new features. But our manages always say without unstable new features, customers never buy our software.


Japan2009 19.6-20.6


One of my friend introduced a Karaoke-bar at night. This bar seems rare since it provides real German Beer and dishes. The atmosphere is also nice.

PartIII Karaoke Lounge Mariko
164-0011 Yuni-buru nakano sakaue, Chuuou 1-32-7
Nakano-ku, Tokyo

I came from Germany, so, I usually do not visit to German restaurant while I am in Japan. This is exception because of my friends. I never know this kind of bar in Germany. The most different part is the customer enjoys conversation with the bartender (usually woman). I almost never visit this kind of bar in Japan, because it is difficult to know what kind of bar it is. Some of them are kind of prostitute and super expensive. But most of them you can enjoy the conversation and reasonable price. However, I never visit these bars unless someone with me knows it. This is a nice bar.


I started 6 in the morning. I used Narita express from Shinjyuku to Narita. I came back to Berlin Tegel via Frankfurt. It is pity there is no direct connection from Narita to Berlin. Tegel had a short, but strong rain, then we once abort to landing.

I read two books in the airplane: Shakespeare, the world as stage by Bill Bryson and Player Piano by Kurt Vonnegut, Jr. This is my second book from Bill Bryson, I enjoyed a lot. I will read more. As a Vonnegut book, it is a bit too normal. But still I like it.

This concludes my holiday in Japan. Most of the part was great, but it was a sad holiday.


Japan2006 17.6-19.6


I moved to Tokyo. I met K again. But, first I almost visited O's lab. With K, we tried 8 Euro coffee. I think it tasted good, but I am not sure. But the atmosphere was great. I, K, and Y went to a Korean restaurant. Great.


I visited Shiosai park in the morning to see RX-78 type 2 (Gandum). Finally, there is. I took mechanical engineering in the University because of Atom and Gandum. Later, I changed my course to information science, but several of my friends continued to research on robotics. Some foreign people asked me, why there are so many Japanese robotics researchers? Or why Japanese researchers developed walking robot? Because this is a common dream of my generation.

By the way, I can not help to stop reminding Minofski (?) particle with Minkowski sum.

I visited Toukyo mentuu dan. Great. They research only Men (= Pasta) itself. Of course they also have great sauce, but the fundamental is so solid. Then, it is absolutely not necessary to make anything up.


Tezuka Osamu's Black Jack, "Shrinking"

I like several novel authors. My first favorite author is probably Teduka, Osamu. I still love him. The list grows by adding Hoshi, Shinichi, Agatha Christie, Hermann Hesse, and so forth. My first favorite article of Tezuka was Atom as most of the (boy's) Tezuka fans did. But my favorite is Black Jack. I try to summarize one story, it is still quite vivid in my memory. I first read this story when I was 13 - 15 years old. I re-read it at least several times since Black Jack is composed of many short episodes. The title should be "ちぢむ (SHRINKING)" or it might be "縮む(Shrinking)". (It is not so convenient to translate this to English, since English does not have a system to say the exact same word in several ways. So I just simulate it with capital letters.)

Black Jack is a genius surgeon, but he does not have the license. In short, his medical activity is illegal. His skill is top level in the world, but, the fee is also out-of-law expensive.

In the story "Shrinking," his master Dr. Togakushi invited Black Jack (B.J.) to a village in Africa. B.J. saw a lot of dead animals because of famine and drought. He saw also bodies in the hospital.

Dr. Togakushi showed a stuffed specimen to B.J.

Togakushi: B.J. How do you see this stuffed specimen?

B.J.: It's a wild cat, I think.

T: How is this?

B: A human dried head? I heard some people do this, but it is impressive. A head can be such small.

T: These are neither dried head nor wild cat. These are real person's head. And this is a stuffed matured Lion.

B.: What?

T: I first thought this is a some kind of abnormality of growth. But this is a new disease around this region .

Dr. Togakushi asked B.J to help to find this new disease's cure. But B.J. said, "I am a surgeon, not a researcher. If you pay me 30 million yen*, I could help you." B.J. knew Dr. Togakushi can not pay such money, means he rejected Togakushi's request. But, Dr. Togakushi said to leaving B.J.,

T: B.J. This disease infects through the air. I have already infected. The incubation period is around a month. If you have already infected, it's too late. I call you because I believe you can find a cure."

(Is Togakushi too desperate? It is a bit too much I think now.)

Dr. Togakushi and B.J. can not find any problem of the body. The cells of the body just shrink and there is no other problem. X-ray, microscopic investigation, ..., they can not find any. But it is sure there is infection. When the body becomes 1/3 of the original, that individual dies. Dr. Togakushi also shrinks a few centimeters in this week. B.J. investigate all the bides he found. But, nothing is found. The assistant of the hospital ran away.

B.J. did a operation that puts growth hormone in Dr. Togakushi's thyroid gland as a counter remedy. But, the result was negative. Dr. Togakushi becomes almost half tall, he sometimes becomes unconscious. When he gained conscious, he told B.J.,

T: B.J., do you realize this disease happens always very heavy famine place? This might be related with the reason of disease.

B.J.: I could not find any... Everything is normal. But just the body shrinks. Why this happens at heavy famine place... The air, the water, all are normal.

T: This might be a warning from the god.

B.J.: What? Dr. Togakushi, this is a disease!

T: If you don't like to say the warning from the god, I could say this is nature. When there is no food, small animals like mice bear only small children. Then most of them don't grow or die until the nature can provide enough food. This is a mechanism of the nature to keep the balance with avoiding catastrophe. I just thought this is a warning, when the famine is hard, the body should be small to survive. Then, Dr. Togakushi lost the conscious.

B.J.: I can not accept this is a mechanism of the nature. There must be something. Give me a hint! A hint! If someone gave me a hint, Iwill give you 30 million yen, no I will give you 100 million yen!

B.J. goes to investigate other villages. He saw all the people died, all the body are small at a village.

B.J.: A human village is annihilated. But why, some animal herds survive, even some of them are dead. This is air infection. Why animal herds survive?

Then, he encountered a strange scene.

B.J.: Zebras eat a miniaturized dead body... Zebra does not eat meat... Maybe, ... they know here is antibody in the dead body from instinct? Yes! Serotherapy!

B.J. made Serotherapy from the dead body of Zebra. He reported to Dr. Togakushi. But Togakushi is almost dead.

B.J.: I made it, Dr. Togakushi.

T: B.J., I have no chance. When I dead, make serotherapy from my body and cure the people.

B.J.: Dr. Togakushi, this could cure you also. Give me a chance! I don't want to lose here.

But Dr. Togakushi was dead. B.J. took his small body and stood under the beautiful African night.

B.J.: Hey god, or whatever... You are crucial.

B.J. walked with looking at the starts.

B.J.: Doctors cure the disease.Then human population exploded.

B.J. whispered.

B.J.: That causes famine and destruction of the environment.

B.J.: Then, why we doctors exist?!

The End.

My work related with a bit of science. I sometimes remind this story. This time I explained what I am doing at work to my family. My sister said, "What can I believe if CG can make this images?"Our technology can fake realistic images. You can make fake war movie, and fake the people. A few years ago, I was afraid a country made a fake mass destruction weapon scene, and convince the world to make a war.

This story was published 70s. Tezuka published this kind of story every week, and this is only one of the episodes out of (maybe) 200 for a children magazine. Because these are published for children, most of Tezuka's stories seems to be not translated to foreign countries. I am a bit disappointed of that. But Japanese classics are also not translated, even Natume Souseki or Akutagawa Ryunosuke.

If you never heard Tezuka Osamu or Black Jack, I recommended it. If you are not interested in it because of this summary, that is my fault. I hope you forget this article and try Tezuka's story.

* This story is written 1970th, 30 milion yen is enough to buy amiddle class house in Japan at that time.

Japan 2006 13.6-16.6


It's a bit surprised, but NHK (a Japanese broadcasting) has several interesting TV programs. Nikaku's Seikatu shouhyakka, Turubee no Kazoku ni kanpai, tameshite gatten, The death of Yugoslavia(1996 documentary), Suiensa, Degista, Bakushou gakumon, Alf, Fullhouse, etc..

I read Saisyuuheiki kanojyo (The ultimate weapon, my girlfriend or the last love song on the planet) by Shin Takahashi volume 1 to 7. What a sad story this is. Great.

I read Satorate by Makoto Sato volume 1 to 3. The idea itself is classic like Fukuyama Keiko. A person broadcasts their mind, opposite of mind reader (= Satori in Japanese). However, this story makes this serious story. It's fun.6/14 I walk around in the city. I went though the green load of Fuji.This is the starting point. (picture)

You can find some Japanese rice field. (picture)

This road is originally a train track of Minobu line, that was single track. When the Minobu line becomes double track, the original line becomes a road. Here is originally a station. (picture)

The road ended at the Fuji's shopping street. This street was changed a lot compared with 10 years ago. (picture)


I read Sekai no owari to ha-do boirudo wanda-rando. (The end of the world and hard boiled wonderland) by Haruki Murakami.It is great as always. But I felt that the end of the story is a bit sudden.

I read Life strategies by Phillip McGraw. The world is and how Irecognize is the totally different matter. I understand the idea. But this is not so easy. However, this is also a nice book. This holiday,I read three management related book. All three different books from differenty countries and different authors suggest we are on theloser's track. (If I can add Machiavelli, then four.) Hum.


Japan 2006 9.6-12.6


My fixed phone right will be expire next year. I do not have any plan to use it next year, so I decided to sell that. But, I found there is no shop that buy a fixed phone right. There seems no demand. If youknow me and want it, please let me know.

I read "Hitotu ue no puresen" (The next level presentation) Editor:Jun Maki. It seems each famous creators says different, but, I think the bottom line is that "a presentation is communication."

I've got a message from a friend, that says "Problem." I could not read it. This word "Problem" makes me sick. I could not move and eat, so I read some books with drinking water in my bed.


Sick. Stay at home.


I read "the secret of the Jewish Mind" by Eran Katz. Maybe most important thing of learning is dialog or discussion. But, it is a bit questionable if this makes all the success. It seems others are well known. However, believing makes motivation. If I only doubt, I am sure that I can achieve nothing.


I read Timequake by Kurt Vonnegut. This is interesting and totally free from the style. This is Kilgore Trout full throttle. Each sectioncan be a novel. The author just said the substance, so I can just think, well, I see. Then Vonnegut say, "you are stupid if you think, I see" in the next paragraph. It always is double shock. Even I expect it coming, I am shocked. Indeed, nation, money, or doctrine, one think it too serious, it is easy to over the line. This is the source of the problem. However, I can not think like Vonnegut. I can not say,"That's all? Thanks!" when I died.

200906Japan 7.6-8.6

I read "Ginga Hitchhaiku Gaido" (Hitchhiker's guide to the galaxy) Douglas Adams. I have read it in English, but I might miss something, so I read this again in Japanese. But, it was so fun in English, it is not so fun in Japanese. But translation seems OK. The book is very difficult to translate, I presume.

I read "The Rules" Ellen Fein and Sherrie Schneider.I see some of the rules. But in my case I give up such a woman. Maybe many of men will not give up and also I should not? But I think it is better to give up and move on.


Today I visited to Shizuoka and close Sumitomo bank account. This bank has no branch in my city, so it is a bit inconvenient. But around 2000, according my research, I believed this bank was the most convenient bank from outside of Japan.

By the way, I found a nice shop called Yumekoubou in the city. This shop's clerk has a nice accessory and I asked where can I get. Then she introduced me a shop called Ernie Pyle Company & Garden (picture). This shop is amazing.

There is a small park in the city. There is an intermittent convolution (picture). There are some more interesting objects in the city.
I read "Deadeye dick" Kurt Vonnegut. This is fun, but I do not understand why it is so fun. It is easy to read... I like these black wit and warm talk but sometimes includes a small rejections. Maybe this is totally stupid idea, but I feel sometimes Murakami Haruki. They are totally different, but I feel something common at the bottom, a little bit. I love both authors.


200906Japan 5.6-6.6

I visited a Soba restaurant. Great.

I move to my family'splace.
I read "Tensai Yanagisawa kyoujyu no seikatu 17" (A life of genius Prof. Yanagisawa Vol.17) Kazumi Yamashita. It's been long time not to read this series. I missed these books.
I read "Sugoi kaigi" (Great meetings) Zentaro Oohashi. I was once recommended this book from a company president in Aizu. This book is about meeting. I found it quite useful and maybe I could apply at my work. A nice book.

200906Japan 3.6(night)-4.6

3.6 Night
Night, I met my friend G. He is now famous and gets inviatation letters from internatonal film festivals. I always complained ``I don't understand what is this article.'' But, he always try to explain how it is nice. Recently, I started to understand some of them. Just feel something. This is stereo shadow. This is fun. (picture)

By the way, when I was a student, I bought a theater ticket. I felt that was unique, but, I did not understand it. Then I asked them after the play. Then the director answered, ``What? How impolite you are. How can't you understand my play?'' After few years, I lost the trail of her theatrical company. If you make a sincere question, and the answer was ``How impolite you are.'' Then you made a right question, I believe. The responders need to deceive the question since they cannot answer the question or answering question negates them.
I believe both research and software development are based oncommunication. Maybe artistics activity is also based on communication. I want to tell something, I want to show something, but always ``to someone.''
We watched Blade Runner togather again.
Morning, I visited old friends and they are now parents. We learn Aikido together. Their child has a lot of imagination and so many vocabulary. Yes, the mother's field was literature. I think the most important ability is natural language (mother tongue). Especially if the person goes to science or mathematics area. Because the first task of science is to understand what is the problem, that is given by the natural language. Then if one has an answer, s/he need to explain it to people.
Night, I met a sister of my colleague. I never met such a person who can read/write almost perfect Japanese, but a German person. She told me about her life a bit and it seems there was a lot of luck she had. But I see it is based on calculated strategy. I have met several people, who want to visit to Japan and want to live there. But, she can read and write Japanese. This does not belong to luck. Some says like her, "I'm interested in business. Maybe I join a foreign company in Japan."But she is writing doctor thesis about the role of foreign companies in Japan, and contacted managers of such companies. That's not luck again. This is strategy. She is not only intelligent, but also an attractive woman.

200906Japan 2.6-3.6

From the morning, I met N (we met yesterday) and T's family. T was my colleague and friend, but he was gone last year. We visit his grave. Good people dies first, Stupids remains.

From Tokyo to Chiba, there is a tunnel-bridge. Half of the way is tunnel and the other is bridge. Why half the way is tunnel and the other half is bridge? A rumor told me that tunnel companies and bridge companies are connected to politician, but, they can not compromise each oher. Then, let's make half is bridge and half is tunnel. This could be lie, but, I can believe it. Connecting bridge and tunnel in the sea requires quite high technology. But here is Japan, politics and concession is more important. Developing a new technology is cheaper than that. The pictures ares from Umihotal, an artificial island connecting the tunnel and the bridge.

(Up:Bridge side, Down Tunnel side)


This is the cutter for boring.
This technology used Seikan-tunnel, and later exported to France and England. They used to bore the tunnelbetween them.This is a scene from my friend's grave.
Night, I met friend from MPI and others. All are good, nice.
First, I asked to join K's class. It was fun. I also asked to joinmy friend's O's seminar. But I feel a bit strange. I could not feel joy from students. But, I do not need to be afraid that since O is a first class researcher. Last time I visited to a lab. That was M's lab, I know him from MPI. Students were active and they want to tell me their research. Even they do not know me, they think talking about their research creates some new idea. They do for themself, but it is simultaneously for my hospitality. That was great.

200906Japan 30.5 - 1.6

Visit to Japan
Departure from Berlin. This is my staring point of this journey,Hohenzollerndamm(picture).

This is Frankfurt (am Main) airport. Earlier, this airport is not non-smoking, but now they are separated(picture).

This is my airplane.(picture)

Arrived at Narita. I stayed at Ueno. It has been long time to visit a Game center (an amusement place). But many of them are now network game, strategy game, or horse simulation. These are not my favorite. But I found PSIKYO's 1945 and I play it an hour.
When I open the suitcase, surprise! A can bier has holes.

This day, I washed all my cloths. This is not a hotel, but called weekly mansions. In Japanese, mansion is just a normal room. It's a marketing jargon. This is a bit cheaper than a usual hotel, but no room services. Therefore, I need to cook, wash, and clean the room by myself. If you stay a week, I could recommend this.

This is supermarket near by my ``mansion.'' Recent price tags seems all wireless. (picture)

Night, I met my old colleague and friend Mr. N, his wife, andProf. T. Okonomiyaki!


A mystery of transpose of matrix multiplication -- Why (AB)^T = B^T A^T?

At one Wednesday night party (meeting), there was a conversation:

``... I met the woman at that party. She was looking for her job...''
``What does she look like? Pretty? Positive? Tall?''
``I love a positive woman.''

A few minutes later at the same party,

``... I found this matrix in that paper. It was constructed by...''
``What does the matrix look like? Symmetric? Positive definite? How large?''
``Positive definite.''
``I love a positive definite matrix.''

As you see, some of my friends like a positive definite quadratic form matrix. It is also interesting to think about the relationship of this matrix with transpose. But first I would like to talk about transpose only.

One of my friend wrote an article ``A mystery of transpose of matrix multiplication -- Why (AB)^T = B^T A^T?'' By the way, it is not comfortable to write a mathematical blog since it is hard to write equations. I have a permission to copy it here, but I will just link the article. The following is the abstract of the article.

A transpose of matrix multiplication is

Eq (1)

Sometimes we just say this is a rule. But, I would like to think about this more. First, I would like to think about vector since vector is a special case of matrix and it is simpler than matrix. From a transpose of dot product of vector,


is shown as a natural rule. This is well explained in the Farin and Hansford book [1]. I added some additional details with the book's explanation. I recommend this book.

Matrix multiplication includes dot product if you can see that a matrix is also a representation of transform. This matrix's aspect is emphasized and well explained in the Sugihara's book [2]. I recommend this book, an unfortunate for non Japanese readers, the book is written in Japanese.

If you sum these two ideas, I hope you will see the meaning of Equation 1 better.


[1] Gerald Farin and Dianne Hansford, Practical Linear Algebra; A Geometry Toolbox, A K Peters, Ltd., 2005, ISBN: 1-56881-234-5

[2] Koukichi Sugihara, Mathematical Theory of Graphics (Gurafikusu no Suuri), Kyouritu-shuppan, 1995, ISBN: 4-320-02663-2 C3341


Reflection Line in 3 minutes

Reflection lines are lines observed on a surface from tube lights. Car designers employed this to see the surface quality. Usually, parallel fluorescent tubes are placed above the car model.

But this is quite common in Germany.

This is Berlin Hauptbahnhof (main station). The large part of building is transparent (glass). Steel frames are aligned regularly on the ceiling. These are not fluorescent tubes, but reflection line only requires regularly arranged lines. If there is something specular surface, we could see reflection lines.

Please look into the widows of this train. We could easily see that each window has a different quality. Most of the windows did not connects smoothly between windows.

Link to the explanation slides


[1] Mario Botsch, Mark Pauly, Leif Kobbelt, Pierre Alliez, Bruno Levy,
Stephan Bischo, Christian Roeossl, ``Geometric Modeling based on
Polygonal Meshes,'' EG2008 Tutorial, 2008

[2] Takashi Kanai, Yusuke Yasui, ``High-quality Display of Subdivision
Surfaces on GPU,'' IPSJ 47(2), pp.647-655, 2006 [in Japanese]


e: The meaning of the base of natural logarithm's definition

Base of natural logarithm appears almost everywhere in mathematics. Many of the sciences also use this number. When I came Germany, I found it on the 10 DM note. 10DM note has a portrait of Gauss. I saw why Germany's science level is high when I found a graph of normal distribution on a 10 DM note. When children got allowance from their parents, they would ask ``what is this curve? who is this?'' Then the parents would answer ``This is Karl Friedrich Gauss. A great mathematician. This curve is called normal distribution. It represents....'' I'm not sure how accurate my imagination is. I think Euro is a good idea, but I missed Gauss on a note.

Famous transcendental numbers are e and π. It is well known how the π is defined (circumference/diameter), why e's definition is
was not on my high school text book.

I found a slide of this explanation and put the link here with the author's permission. Thanks a lot.


Conclusion of lambda

Japanese version

Recently I saw this advertisement, ``For the finance specialists: Let's start from the simple thing.'' I assume the simple thing means, 1+1=2. I try to explain in this blog that how to teach 1 + 1 to a machine. I took more than eight months and yet not quite complete. (By the way, this is a tobacco advertisement.)

For human beings, this seems simple. But once you want to teach what 1+1 means to a machine, you must know more about it. For example, we discussed what is the numbers, and we represent it as Church numbers since a machine does not know what the meaning of '1' or '2''s sign. Someone may think this is paranoia since this is so natural.

I believe ``natural'' does not mean simple. It is just familiar to us. It is not simple at all for me. Some of you might feel it is natural to spend time with your family or your lover. But it is just you are familiar with that, it is not simple thing. It is important for me to see back into the natural things.

I would like to conclude this Hitchhiker's guide to λ calculus at the moment.

One day, I searched lambda calculus in Wikipedia. It said, ``it can be verified that PLUS 2 3 and 5 are equivalent lambda expressions.'' on the PLUS function. However, I did not understand how it works. I needed a large help of my friends. I do not want to forget about this. This is the motivation of writing this blog.

We talked about what is λ calculus, why people care about that, and several concrete examples. I hope this blog could help the people like me.

But this is not everything about the λ calculus. λ calculus is deep, I am hardly just open the door of this area. I still do not understand combinators. If I could understand it, I would like to continue this blog. I learned that writing is learning or teaching is learning. Also I learned that I could write an article only if I really like it.

I try to keep this article more understandable in informal way. I did neither mention about formal λexpression construction method, nor conversion procedure (α-conversion, β-conversion, and η-conversion). If you wan to know further, Wikipedia would be a good starting point.


Thanks to Uchida to give me the cue to write this blog. Thanks to my friends Hoedicke and Rehders to help to understand the examples. Thanks to Maeda who gave me an implementation of Y combinator. This blog is dedicated to my friend Tateoka. I wanted to show him this blog, but unfortunately it is not possible anymore.


Japanese version

These series of the examples might be not so fun if you don't try to apply them by yourself. If you do not follow them step by step, these are just a bunch of equations. Therefore, I recommend to try it.

We will define the subtraction using PRED function.

SUB := λ m n. n PRED m

SUB 3 2 = (λ m n. n PRED m) (λ f x. f (f (f x))) (λ f x. f (f x))

= (λ n. n PRED (λ f x. f (f (f x)))) (λ f x. f (f x))

= (λ f x. f (f x)) PRED (λ f x. f (f (f x)))

= (λ x. PRED (PRED x)) (λ f x. f (f (f x)))

You see that the PRED is duplicated as the second argument (= 2). This is the trick. If the second argument (subtrahend) is ten, then PRED is repeated ten times.

= PRED (PRED (λ f x. f (f (f x))))

This is PRED (PRED 3).

= PRED 2

= 1

Therefore, 3 - 2 = 1. We can do subtraction.


Japanese version

We have addition and multiplication. Next I would like to subtraction. But, we do not have minus numbers of Church numbers. Because we construct the numbers by number of f-s. For simplicity, we do not think about minus numbers here. If you want to know more, you can look up Wikipedia.

We prepare PRED before we go to subtraction. The PRED (predecessor) function generates one Church number before the input number. Here we will not think about before the number 0.

The definition of PRED is

PRED := λ n f x. n (λ g h. h (g f)) (λ u. x) (λ u. u).

Let's compute PRED 2.

PRED 2 := (λ n f x. n (λ g h. h (g f)) (λ u. x) (λ u. u)) (λ f x. f (f x))

= (λ f x. (λ f x. f (f x)) (λ g h. h (g f)) (λ u. x) (λ u. u))

= (λ f x. (λ x. (λ g h. h (g f)) ((λ g h. h (g f)) x)) (λ u. x) (λ u. u))

= (λ f x. (λ x. (λ g h. h (g f)) (λ h. h (x f))) (λ u. x) (λ u. u))

= (λ f x. (λ g h. h (g f)) (λ h. h ( (λ u. x) f)) (λ u. u))

= (λ f x. (λ h. h ((λ h. h ( (λ u. x) f)) f)) (λ u. u))

Notice, one 'f' is vanished here. Number of 'f's represent Church number, therefore, remove one 'f' is minus 1.

= (λ f x. (λ h. h ((λ h. h x) f)) (λ u. u))

= (λ f x. (λ h. h ((f x))) (λ u. u))

= (λ f x. ((λ u. u) ((f x))) )

= (λ f x. (f x))

= (λ f x. f x)

= 1

It is curious to compute PRED 0. What is the predecessor of 0?

PRED 0 := (λ n f x. n (λ g h. h (g f)) (λ u. x) (λ u. u)) (λ f x. x)
= (λ f x. (λ f x. x) (λ g h. h (g f)) (λ u. x) (λ u. u))

= (λ f x. (λ x. x) (λ u. x) (λ u. u))

= (λ f x. (λ u. x) (λ u. u))

= (λ f x. x)

It returns 0. This is a nice property of this PRED definition. PRED returns 0 if the input is 0, otherwise it returns one predecessor number.

I am fascinated that Church number itself is part of program. The number is a program here. Of course Church number is a function. Therefore, it is natural in a sense.

If we apply λ n . n (λ g h. h (g f)) to 0,

(λ n . n (λ g h. h (g f))) (λ f x . x)
= (λ f x . x) (λ g h. h (g f))
= (λ x . x)

This is part of PRED function. The output is 0. In PRED function has more terms, so I would like to stop here. The basic mechanism here is that when this part of the function apples to 0, then the first team is ignored. Since Church number 0 (λ x . x) does not have binding to 'f'.



Japanese version

Multiplication is defined as the following.

MULT := λ m n f . m (n f)


2 := λ f x. f (f x)
3 := λ f x. f (f (f x)),

MULT 2 3 := (λ m n f . m (n f)) (λ f x. f (f x)) (λ f x. f (f (f x)))

= (λ n f . (λ f x. f (f x)) (n f)) (λ f x. f (f (f x)))

You can see that (n f) is copied as many as f-s.

= (λ n f . (λ x. (n f) ((n f) x))) (λ f x. f (f (f x)))

(n f) is copied the first argument (=2) times. The second argument (=3)
is replaced with n of (n f).

= (λ f . (λ x. ((λ f x. f (f (f x))) f) (((λ f x. f (f (f x))) f) x)))

= (λ f . (λ x. (λ x. f (f (f x))) (((λ x. f (f (f x)))) x)))

= (λ f . (λ x. f (f (f (((λ x. f (f (f x)))) x) x))))

= (λ f . (λ x. f (f (f (f (f (f x))) x))))

= (λ f . f (f (f (f (f (f x))))))

= 6

There is another multiplication definition.

MULT := λ m n. m (PLUS n) 0

I thought this 0 is just number 0 instead of Church number 0, when I saw
this in Wilipedia. This is not easy for beginners.

MULT 2 3 := (λ m n. m (PLUS n) (λ f x. x)) (λ f x. f (f x)) (λ f x. f (f (f x)))

= (λ n. (λ f x. f (f x)) (PLUS n) (λ f x. x)) (λ f x. f (f (f x)))

You can find the similar pattern as the first definition, (PLUS n) is
copied k-times (k = the first argument number).

= (λ n. (λ x. (PLUS n) ((PLUS n) x)) (λ f x. x)) (λ f x. f (f (f x)))

= (λ n. (PLUS n) ((PLUS n) (λ f x. x))) (λ f x. f (f (f x)))

= (PLUS (λ f x. f (f (f x)))) ((PLUS (λ f x. f (f (f x)))) (λ f x. x))

The underline part, PLUS 3 0 is 3 (= 3 + 0). Therefore,

= (PLUS (λ f x. f (f (f x)))) (λ f x. f (f (f x))).

This is 3 + 3, then,

= 6.


Japanese version

Addition is defined by the following.

PLUS := λ m n f x. m f (n f x)

Let's calculate 1 + 2.

1 and 2 are

1 := λ f x. f x
2 := λ f x. f (f x),


m n f x. m f (n f x)) (λ f x. f x)(λ f x. f (f x))

= (λ n f x. (λ f x. f x) f (n f x)) (λ f x. f (f x))

= (λ n f x. (λ x. f x) (n f x)) (λ f x. f (f x))

= (λ n f x. f (n f x)) (λ f x. f (f x))

= (λ f x. f ((λ f x. f (f x)) f x))

= (λ f x. f ((λ x. f (f x)) x))

= (λ f x. f (f (f x)))

= λ f x. f (f (f x))

= 3

Therefore 1 + 2 = PLUS 1 2 = 3. It seems a magic. But the principle is the same as the Pop1. Church number represents numbers by the number of 'f's. Therefore, addition is basically concatinate the numbers.

If 1 = f and 2 = ff, 1 + 2 = f + ff = fff. In the sama way, for example 3 + 4 = fff + ffff = fffffff = 7.


Japanese version

Now we are ready to calculate SUCC 1.

= (λ n f x. f (n f x))(λ f x. f x)

= (λ f x. f ((λ f x. f x) f x))

= (λ f x. f ((λ x. f x) x))

= (λ f x. f (f x))

= λ f x. f (f x)

= 2

SUCC 1 is 2.

The red color characters are processed at each line.

In case if ((λ f x. f x) f x)) is not clear, we could change the
variable name more unique to distinguish.

((λ f x. f x) f x)) is the same to ((λ g h. g h) f x)).

((λ g h. g h) f x)) ... f is replaced with g.

((λ h. f h) x)) ... h is replaced with x.

(f x)

I hope this is not ambiguous anymore.


succ -- Apply numbers (Cont.)

Japanese version

I could not update the blog for a while, since I was in Muenchen for a week.

(λf x. x) f x


f x. x) f x
... remove f since f is not bound.

x. x) x
... Input x, output x.


(λx. x) x




(λ f x. f ((λf x. x) f x))


(λ f x. f (x)).

Although parentheses '()' represent priority of the expression, there is not so much meaning in this case. Then lazy mathematicians will write it as

(λ f x. f x)

Almost, but not yet. We can remove the outmost parentheses also.

λ f x. f x

Now, this is Church number 1. Therefore, SUCC 0 is 1.

Finally, it was a long way, but we compute the SUCC 0 in the lambda expression way. Let's move on to SUCC 1.


succ -- Apply numbers

Japanese version

Let's compute the SUCC function one by one. First time, I was confused and I tried to use `0' or `1' as a number. But here, a number is a Church number, then 0 is (λf x. x). You can see I am a totally amateur. Please keep the left-associative in mind,

SUCC 0 := (λn f x. f (n f x)) (λf x. x)
= (λ f x. f ((λf x. x) f x)).

Because of left-associative `n' is (λf x. x). Here the underlined part,

((λf x. x) f x))

Can you see that any `f' will vanish? For example, One argument function

(λf. 3)


f(x) := 3.

Therefore, this function is always 3 for any `x.' Such variable `x' is called free variable (or the variable does not bound). It is like Marvin in the Heart of Gold. Anything does not matter for Marvin. Zaphod always forgets him. But this free variable is necessary as Marvin in Hitchhiker's guide to the Galaxy. The vending machine gensym3141 does not bound any variables until you put your credit card. Without credit card, all the variables are free variable for gensym3141. λ function has such a function.

In (λf x. x) f x, first, f is applied to f, however, this is a free variable. Then this f is vanished. (This λ expression has only `x' after the `.'.) If you are confused two fs in this λ expression, we can rewrite it to (λg x. x) f x. This is the same. When the function apples to f, g does not bound, then f will vanish.

Then, this will be

(λf x. x) f x
(λx. x) x.

The last line, λ expression applys to x, then it becomes x. Again, there are three xs here. To make this clear, we could change the variable name to y.

(λy. y) x

This is totally same as (λx. x) x. If we write this in conventional way,

f(x) := x
f(y) := y.

These two are substantially the same.

Marvin is ``マービン'' in Japanese. It is "Marvin" in English. But Marvin itself does never change according to which language do you use. Please note that the variable name can be changed does not mean (λx.x) can be (λx.y). The corresponding what to what must be kept. This is the line and if you over that, anyone can treat Vogon correctly.


λ version succ -- definition

Japanese version

A definition, like function application is left-associative, is alike a rule of a sport. One of the rules of basketball is a player with the ball must dribble a ball when the player moves. Why is it? Because it is a rule of the game. If someone dribbles a ball in baseball, it does not make any sense (in case baseball makes sense). If a soccer player uses hands except the goal-keeper, it is a foul. Why is it so even they all use a ball? That is out of question. It is the rules of the game. Mathematics also has the similar aspect. ``Why is it left-associative?'' ``Because it is a definition. (means that's the rule.)''

Unfortunate starts when someone teaches this mathematical rule is the unique and unalterable truth. If one believe 1+1=2 is the unique and unalterable truth, then s/he could not understand mathematics at some point. For example, there is a mathematics 1+1=1. This mathematics is used in nowadays computer. Nowadays computer widely uses binary system, and binary system has only `0' and `1.' Then 1+1=2 could not be possible if 2 does not exist in one digits computation. Another unfortunate could be someone think now 1+1=2 is a mistake. Like there are rules for baseball and football, each game has each rule/truth. 1+1=2 is useful, many cases it is considered truth, but, it is done after it has been defined. Namely, if the rules of a game are defined, that rules become the unique and unalterable truth/rule/definition.

Both in sports and mathematics, we are always interested in a similar aspects. ``Does the rule/definition make an interesting game?'' I think we do not so much care about the rule or the definition itself. I am much interested in the game, not the rules. If we define an operation of addition, does it lead something interesting? If we think about a system which only uses addition and multiplication, what will it be? By the way, the system of linear algebra consists of addition and one constant multiplication.

When I think about other people, I usually found more interesting about ``What this person did?'' than ``Who is this person? (weight, hight, outlook, name, ...)'' I also find that ``what is the function of the definition?'' is more intriguing than the definition itself. I happen to have a question ``Why we need this definition?'' for many times. Then I hate mathematics at the moment. But, I think I should not have this question.

``But Marvin, no mathematics teacher taught me such things. Do you know why?''

``Because it is obvious.''

If someone understand well, then they did not realized it. Even they did not cast a question. However, I always feel no question is not a good sign.

Let's see the SUCC function again.

SUCC := λn f x. f (n f x)

This is a short form of

SUCC := ((λn. λf). λx). f (n f x).

The left side of ``.'' indicates function, we could remove two redundant λs out of three λs. More precisely, this is related with ``curring.'' ``Curring'' coined after Haskell Curry, but it seems Curry is not the inventor (Moses Schoenfinkel and Gottlob Frege). It is the technique of transforming a multiple arguments function to a combination of single argument functions. If you fix all arguments except the first one, you get a function of the non-first arguments in this technique. This means we only need to think about single argument function. Why do we think about curring? Because single argument function is simpler than multiple argument function. If the effects are the same, (lazy) mathematician likes the simpler one.