COPYRIGHT NOTICE

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

Copyright (C) 2016 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.021

SYNOPSIS

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

DESCRIPTION

Utility functions that may be useful.

Exportable Functions

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

    Complex linear combination of states from iterator. $c is a 'complex' ndarray and $it is an iterator for the corresponding states.

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

    Hermitean product <a|b> of two 'complex' multidimensional pdls $a and $b. If $skip is present, preserve the first $skip dimensions before adding up.

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

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

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

    Euclidean product <a|b> of two 'complex' multidimensional pdls $a and $b in reciprocal space. If $skip is present, preserve the first $skip dimensions before adding up.

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

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

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

    Vector-Spinor product <a|b> of two 'complex' multidimensional pdls $a and $b in reciprocal space. For the vector-spinor field dimensions are like 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 $skip dimensions are skipped (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.

  • any_complex

    True if any of the args are a complex PDL.

  • tensor

    Given a complex PDL, an LU decomposition array-ref as returned by "lu_decomp", and the size of the tensor, returns the tensor.

  • wave_operator

    Given a Green tensor and number of dimension in the geometry, returns a wave operator.

  • make_haydock

  • make_greenp

    Given an object and a classname, construct an array-ref of objects of that class, with relevant fields copied from the object.

  • incarnate_as

    my $new_obj = incarnate_as('New::Class', $obj, [qw(f1 f2)], other => $value);

    Given an object and a classname, an array-ref of attribute-names, and then key/value pairs, returns a new object of the given class, with the given object's given attributes plus the additional ones.

  • cgtsv

    Solves a general complex tridiagonal system of equations.

    $b = cgtsv($c, $d, $e, $b);

    where $c(0..$n-2) is the subdiagonal, $d(0..$n-1) the diagonal and $e(0..$n-2) the supradiagonal of an $nX$n tridiagonal complex double precision matrix. $b(0..$n-1) is the right hand side vector. $b is replaced by the solution. Dies if gets an error.

  • lu_decomp

    Uses the appropriate LU decomposition function (real vs complex, detected) for "lu_solve". Returns list of LU, permutations. Dies if decomposition failed.

  • lu_solve

    Uses the appropriate LU solver function (real vs complex, detected). Given an array-ref with the return values of "lu_decomp", and a transposed B matrix, returns transposed x. Dies if solving failed.

  • apply_longitudinal_projection

    Given a psi_G state, a GNorm, the number of dimensions, and a real-space coefficient, transforms the psi_G field from reciprocal to real space, multiplies by the coefficient, transforms back to reciprocal space.

  • make_dyads

    Given a number of dimensions, and an array-ref of "unit pair" ndarrays, returns a matrix of dyads of unit vector pairs d^{ij}_{kl}=u^{i}_{kl}u^{j}_{kl} as 2d matrix, adjusted for symmetry.