2021年6月4日金曜日

offsetarray as a member of structure in Julia

 I do feel that accessing offsetarray, which is a member of a structure in Julia, is extremely slow.

In my case, I use a staggered grid in a FDTD code, and defined a structure as;

struct grid
    p :: OffsetArray{Float64,2}
    vx:: OffsetArray{Float64,2}
    vy:: OffsetArray{Float64,2}
end

then accessed like (output, input, resOfCalcF are all "grid".)

for j in -m+1:gridParam.ny+m
    for i in -m+1:gridParam.nx+m
         output.p[i,j] = input.p[i,j] + coef*resOfCalcF.p[i,j]
    end
end

It seems that Julia cannot determine the type of ".p" and this causes the type-instability.

To avoid this, I needed to cast type as 

op = parent(output.p)::Matrix{Float64}
ip = parent(input.p)::Matrix{Float64}
rp = parent(resOfCalcF.p)::Matrix{Float64}

and the array starts from 1 (the loop starts from 2, because the outer most layer is just a dummy)

for j in 1+1:gridParam.ny+m+m+1
    for i in 1+1:gridParam.nx+m+m+1
         op[i,j] = ip[i,j] + coef*rp[i,j] :: Float64
    end
end

I have not measured the speed-up, but probably x10 - x100 speedup is obtained.

2021年6月3日木曜日

ジム再開/Re-opening of gyms in Vienna

 5月19日から3G(陰性証明書/ワクチン接種証明書/罹患証明書の略らしい)を持っていればジムに入れるようになりました。おかげで首の調子もだいぶ戻ったし、血圧も一気に下がった。これから徐々に制限が解除されていくようだけれど、3G所持じゃないとダメな行動が広がるということでもあり、早めにワクチン接種したい。

From the 19th of May, the gyms in Vienna were allowed to re-open, but for those who have 3G certificates (certificates of negative/vaccinated/recovery). Because of the lack of exercise, my neck started complaining to me, and I got hypertension. after a couple of weeks, they are getting better. importance of exercise :)

Getting the negative certificate is not difficult whilst a bit annoying. I may wish to get vaccinated soon.

2021年5月28日金曜日

Octave 6.2.0 + MKL (intel-oneapi-mkl 2021)

The following is the configure option to include MKL in Octave.
MKL is installed via Spack, and the version is intel-oneapi-mkl@2021.2.0

CPPFLAGS=" -I${MKLROOT}/include -I${MKLROOT}/include/fftw" \
LDFLAGS=" -L${MKLROOT}/lib/intel64" \
CFLAGS="-O3 -fPIC -DM_PI=3.1415926535897932384  -I${MKLROOT}/include -I${MKLROOT}/include/fftw" \
F77="gfortran" \
../octave-6.2.0/configure --prefix=/path/to/install \
--with-blas="-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread" \
--with-lapack="-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread" \
--with-fftw3="-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm" \
--with-fftw3f="-lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm" \
--disable-java --enable-static

It seems that using intel compiler with mkl is problematic.

2021年5月17日月曜日

GeoTracker and Googe Earth Virtual Tour

 I am creating this kind of movie, and finally, I have succeeded to find the set of tools useful on Linux.


(1) GeoTracker on Android
This allows me to get the positions at each time point located with GPS.
https://play.google.com/store/apps/details?id=com.ilyabogdanovich.geotracker&hl=ja&gl=US

(2) RouteConverterLinux
This allows me to edit the points measured above without losing the timing information.
I tried with Google Maps, but it automatically deletes the timing information.

On Ubuntu 20.04, I needed to install OpenJDK 14, and the command is;
/usr/lib/jvm/java-14-openjdk-amd64/bin/java -jar RouteConverterLinux.jar 

https://www.routeconverter.de/downloads/de

(3) Google Earth
You should be able to google "Virtual Tour", and scrutinize ;)


The movie I am creating:


2021年5月8日土曜日

Poco F3

 I have not written this, but I succeeded to get Xiaomi's Poco F3 on the launch date in Europe via Amazon (8G RAM/ 256 storage ver).

So far so good, and love 48M pixel camera!


PS:
I did not know, but recent android can transfer the environment very easily. The thing I love most is that Google authenticator entries can be transferred using QR code with just one step.

Pixel Experience (Android 11) for Xiaomi A1

 I have recently bought the Poco F3, and my old Xiaomi A1 can be bricked!
So, I became to want to test some custom ROMs.

Finally, I realized the pixel experience only offers Android 11 as an official one, and installed it.

I just followed the instruction and it worked!

I may not use this intensively, but it seems the ROM is quite stable.

So far, the only defect I have found is that there is no way to use the tele-lens.



2021年5月1日土曜日

Inverse QFT

Based on the last QFT , I tried the inverse QFT.

I got the result of  [640, 654, 573, 666, 615, 601, 635, 654, 616, 603, 646, 602, 629, 605, 593, 668].
This means that the initial state of QFFT is recovered by iQFFT.

The codes of QFT and iQFT are as follows (as far as I understand).



namespace QFT_naive {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
open Microsoft.Quantum.Convert;
open Microsoft.Quantum.Arrays;
open Microsoft.Quantum.Measurement;
open Microsoft.Quantum.Math;
@EntryPoint()
operation SayHello() : Unit {
let nQubit = 4;
let maxNum = PowI(2,nQubit);
mutable counts = new Int[maxNum];
mutable theta = new Double[maxNum];
mutable revSeq = new Int[nQubit];

for iQubit in 0..(nQubit-1){
set theta w/= iQubit <- calcTheta(IntAsDouble(iQubit+1));
}

for iQubit in 0..(nQubit-1){
set revSeq w/= iQubit <- nQubit-1-iQubit;
}
for trial in 1..10000 {
use input = Qubit[nQubit] {
// 1/sqrt(8) (|000> + |001> + ,,, + |111>)
for iQubit in 0..(nQubit-1){
H(input[iQubit]);
}

// Star QFT
for iQubit in 0..(nQubit-1){
H(input[iQubit]);
for jQubit in 1..(nQubit-1-iQubit){
(Controlled R1)([input[jQubit+iQubit]],(theta[jQubit],input[iQubit]));
}

}

let numLoopSwap = Floor(IntAsDouble(nQubit)*0.5);
for iQubit in 0..(numLoopSwap-1) {
SWAP(input[iQubit],input[nQubit-1-iQubit]);
}
// Start Inverse QFFT
for iQubit in 0..(numLoopSwap-1) {
SWAP(input[iQubit],input[nQubit-1-iQubit]);
}
for iQubit in revSeq{
for jQubit in 0..(nQubit-1)-iQubit-1{
let kQubit = revSeq[(nQubit-1)-jQubit];
let controlQubit = nQubit-kQubit-1;
let rotationIndex= nQubit-(kQubit+iQubit)-1;
(Controlled R1)([input[controlQubit]],(-1.0*theta[rotationIndex],input[iQubit]));
}
H(input[iQubit]);
}
let res = MultiM(input);
let bit = ResultArrayAsInt(res);
set counts w/= bit <- counts[bit]+ 1;
ResetAll(input);
}
}
for j in 0..(maxNum-1) {
Message(IntAsString(counts[j]));
}
}
function calcTheta(l : Double) : Double {
return 2.0*PI()/(PowD(2.0,l));
}
}