« first day (907 days earlier)      last day (3567 days later) » 
00:00 - 23:0023:00 - 00:00

acl
11:01 PM
@hwlau So you have a huge hermitian matrix. Is it a Hamiltonian?
 
density matrix
and hamiltonian
 
acl
and it really is dense?
I mean rho OK, but H?
 
H is not
but i need to solve density matrix for the moment
@acl what is binomc?
 
acl
OK. Anyway try and ask. The code above produces a label for a configuration of spin-1/2 systems (or hard core bosons or whatever) from a list of S_z, occupation numbers or whatver, for the case where only S_z or N is conserved
OK yes,
bmax = 30;
binomtab =
	PadRight[#, bmax] & /@ Table[
		Binomial[l, n], {l, 0, bmax},{n, -1, l}];
Binomial is not compilable I guess, otherwise I wouldn't have done this
 
How can you pass an array and matrix to compile function then?
and can you include a compiled function in another compiled function with no performance penalty?
 
acl
11:07 PM
and
ClearAll[binomc];
binomc::usage = "binomc[l,n]";
binomc = With[{binomtab = binomtab},
  Compile[{{l, _Integer}, {n, _Integer}}, (*binomtab[[l+1,n+2]]*)
    Compile`GetElement[binomtab, l + 1, n + 2], CompilationTarget -> "C"]];
@hwlau yes
so eg ` Compile[{{state, _Integer, 1}, {lsystem, _Integer}, {nparticles, _Integer}},
Module[{n = nparticles, m = 1},...]` if `state` is a list
this is all in the docs
(some of the things in the code above aren't documented though)
 
@acl Ya, that is why I find compile in Mathematica hard to use...
The binomc is not in the parameter list in the compile function, how can compiled function use it?
 
acl
@hwlau no, most of it is documented now
@hwlau because of CompilationOptions -> {"InlineExternalDefinitions" -> True}
this is also in the docs
everything I use here except Compile`GetElement is completely documented, actually
 
@acl so, where is Compile`GetElement?
 
acl
@hwlau can you rephrase?
 
sor, I just mean that I don't find the documentation of "Compile`GetElement"
 
acl
11:18 PM
@hwlau no as I said, it is the only thing that's not
it does the same as [[...]] but a bit faster.
and don't screw up with it, it can crash things
 
How can I create an initial NxN matrix with known N? Its entry are complex number with double precision.
Basically, how can I create a typed matrix?
 
acl
@hwlau known means what?
 
known size of matrix at the creation time
 
acl
@hwlau ConstantArray[0.,{3,3}]?
of course this is not compilable
this is
CompilePrint@Compile[{}, Table[0., {3}, {3}]]
so you're going to create it, then alter each element individually?
 
@acl I think so, is it the right way in compiled code?
I want the memory allocated fix for the big matrix
 
acl
11:26 PM
@hwlau but then you need to visit 30000^2 elements. can't you iterate through all states and for each produce all states with which there are matrix elements, then fill those in?
what sort of system is this?
 
It is a density matrix, the element are all non zero because it is somehow related to coherent state |alpha>. So all entries density matrix rho = |alpha><alpha| is not zero as expected.
 
acl
@hwlau OK so you are also calculating rho from scratch
I don't remember what the fastest way to construct such a matrix is. Maybe SparseMatrix[{{i_,j_}:>f[i,j]},{dim,dim}] or maybe what you say. I don't remember
 
It seems the ConstantArray does work!
 
acl
@hwlau but it doesn't compile (although it's fast anyway)
you can use that or Table, it should not really matter speed-wise
as an aside, I now see that you asked the question on physics se about universality classes. I don't post there but there are models for which RG predicts (correctly) critical exponents that depend on the parameters of the Hamiltonian.
 
@acl I almost forget that question.
What do you mean there are models? Isn't there are some model that RG gives correct prediction?
 
acl
11:39 PM
@hwlau I mean that there exist models for which both numerical simulations and the RG give an exponent which itself depends on $K$, a parameter of the model
so, you can make it be almost whatever you want
well, it's a long story
 
@acl I see. I remember that I have also seen one such model in percolation problem.
 
acl
the point is, the story most people have in mind (phase transitions can be classified in a small set of universality classes, and those correspond to RG fixed points) is true for simple Hamiltonians, basically.
yes also there I think. anyway, this isn't the place for this discussion :)
 
@acl Ya, that was what I learnt at the beginning.
@acl Now, I have another problem for the compile function. How can I create a list dynamically with unknown size starting from zero element?
B = {};
AppendTo[B, {1, 2}];
with error message
Compile::cpts: "The result after evaluating Insert[B,{1,2},-1] should be a tensor. Nontensor lists are not supported at present; evaluation will proceed with the uncompiled function."
 
acl
Compile[{}, Module[{lst},
  lst = {0};
  Do[AppendTo[lst, i], {i, 1, 10}]]]
this allows Compile to work out that it's a 1d tensor of this particular type
 
I need a two-D tensor
so the way is to give the first element so that it can determine its type?
 
acl
11:48 PM
@hwlau I suppose, I don't really remember.
 
ok, I just tried that. It is not convenient, but it works, so I can solve it.
is there a type system for the local variables in compiled function?
 
acl
@hwlau well... look at the docs :)
also, Needs["CompiledFunctionTools`"] is useful, as it provides CompilePrint which shows you what the compiled function looks like
(and whether it copies things, calls MainEvaluate which means calls out of compiled code etc)
paste this into the URL bar in the documentation centre
Compile/tutorial/Overview
there's a section on the type system (I don't remember how useful it is)
 
Thanks~
it is helpful, I may need to spend time to read it
 
acl
@hwlau it looks like it explains everything.
 
@acl Explicit type system is usually not useful except you need some gurantee. in my case, the memory. otherwise I will just let it decide itselfs.
 
acl
11:56 PM
@hwlau I think in this case the point is that if it can't decide, it simply sends the whole thing back to the main kernel and you lose the speed benefit.
if it can, it produces C code which it compiles (if you use CompilationTarget->"C")
 
Have you ever use the parallelization in compile?
 
00:00 - 23:0023:00 - 00:00

« first day (907 days earlier)      last day (3567 days later) »