The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

COPYRIGHT NOTICE

Photonic - A perl package for calculations on photonics and metamaterials.

Copyright (C) 1916 by W. Luis Mochán

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA

    mochan@fis.unam.mx

    Instituto de Ciencias Físicas, UNAM
    Apartado Postal 48-3
    62251 Cuernavaca, Morelos
    México

NAME

Photonic::Utils

VERSION

version 0.013

SYNOPSIS

    use Photonic::Utils qw(cmatmult);
    $c=cmatmult($a, $b);

DESCRIPTION

Utility functions that may be useful.

Exportable Functions

  • $r=linearCombine($c, $s)

    Complex linear combination of states. $c is an arrayref of 'complex' pdl scalars and $s is an arrayref of 'complex' states ('complex' multidimensional pdl).

  • $r=linearCombineIt($c, $it)

    Complex linear combination of states from iterator. $c is an arrayref of 'complex' pdl scalars and $it is an iterator for the corresponding states.

  • $p=HProd($a, $b, $skip)

    Hermitean product <a|b> of two 2x.... 'complex' multidimensional pdls $a and $b. If $skip is present, preserve the first 1+$skip _dimensions (the first dimension is RorI) before adding up.

  • $p=MHProd($a, $b, $m, $skip)

    Hermitean product <a|m|b> of two 2x.... 'complex' multidimensional pdls $a and $b representing vector fields using metric $m. If $skip is present, preserve the first 1+$skip dimensions (the first dimension is RorI) before adding up. (Might not be functional yet, or might be wrong)

  • $p=EProd($a, $b, $skip)

    Euclidean product <a|b> of two 2x.... 'complex' multidimensional pdls $a and $b in reciprocal space. If $skip is present, preserve the first 1+$skip dimensions (the first dimension is RorI) before adding up.

  • $p=SProd($a, $b, $skip)

    Spinor product <a|b> of two 2x.... 'complex' multidimensional pdls $a and $b in reciprocal space. If $skip is present, preserve the first 2+$skip dimensions (the first dimension is RorI and the second the spinor dimension) before adding up.

  • $p=VSProd($a, $b)

    Vector-Spinor product <a|b> of two 2x...'complex' multidimensional pdls $a and $b in reciprocal space. For the vector-spinor field dimensions are like ri:xy:pm:nx:ny.

  • $psiG = RtoG($psiR, $ndims, $skip)

    Transforms a $ndims-dimensional 'complex' scalar, vector or tensor field $psiR that is a function of position within the unit cell to a complex field $psiG that is a function of the reciprocal vectors. The first dimension must be 2, as the values are complex. The next $skip dimensions are skiped (0 for a scalar, 1 for a vector, 2 for a 2-tensor field). The Fourier transform is performed over the following $ndims dimensions.

  • $psiR = GtoR($psiG, $ndims, $skip)

    The opposite transformation to RtoG. Transform a 'complex' scalar, vector or tensorial field from reciprocal to real space.

  • $c=lentzCF($as, $bs, $max, $small)

    Compute a continued fraction a0+b1/a1+b2+... using the Lentz algorithm. $as and $bs are given in a PDL. $max is maximum number of iterations. $small is a small convergence criterium.

  • $b=tile($a, $nx, $ny,...)

    Returns $a repeated periodically $nx times along the x direction, $ny along the y direction, etc. Useful for making plots.

  • @l=vectors2Dlist($f, $s, $d)

    Returns a 2D vector field ready for gnuplotting from a vector field $f scaling the result by $s and decimating the field by $d. The vectors are centered on the decimated lattice points.

  • $c=cmatmult($a, $b)

    Returns the matrix product of the complex matrices $a times $b, with signatures a(2,j,i), b(2,k,j), c(2,k,i). The first index is 2, corresponding to the real and imaginary parts, j denotes columns of a, rows of b, i denotes rows of a and of the result c, k denotes columns of b and the result c. Recall that in pdl the first (row) index is faster. May thread over extra dimensions.

NOTE

Uses Inline::Pdlpp, so the first time it is run it compiles itself, and would take a little longer than the following. To recompile, remove the directory _Inline/ before running.

You must make sure that the relative location of the libutils.so library is correct. See $Bin below.