utilities.c File Reference

See documentation of header.h - this file contains source code only, with function prototypes in header.h. More...

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_eigen.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_sort.h>
#include <gsl/gsl_sort_vector.h>
#include <gsl/gsl_math.h>
#include "header.h"

Go to the source code of this file.

Functions

double abs_val (gsl_vector *vec)
 Returns absolute value (length) of vector vec.
void base_4_rep_inc (int counter[], int n)
 Input array has base-4 rep of n-1, it's incremented to n.
double concurrence (gsl_matrix_complex *matrix)
 Returns concurrence of the input density matrix.
void display_matrix (gsl_matrix_complex *data)
 Prints complex matrix to screen.
void display_matrix_real (gsl_matrix *data)
 Prints real matrix to screen.
void display_vector_real (gsl_vector *data)
 Prints real-valued vector to screen.
double entropy_linear (gsl_matrix_complex *matrix)
 Returns entropy of the input complex-valued density matrix.
double fidelity (gsl_matrix_complex *m1, gsl_matrix_complex *m2)
 Returns fidelity between two density matrices m1 and m2.
int Fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream)
 Wrapper function for fwrite to handle return codes.
void gsl_vector_add_element (gsl_vector *vector, double element)
 Adds element as last element in vector, after re-allocating size of vector.
void kron (gsl_matrix_complex *a, gsl_matrix_complex *b, gsl_matrix_complex *c)
 Performs tensor product on matrices A and B storing the output into pre-allocated matrix C.
void make_T (const gsl_vector *t, gsl_matrix_complex *T)
 Seeds in values from vector t into Cholesky lower-diagonal matrix T, like described in the paper.
void matrix_complex_random_init (gsl_matrix_complex *random)
 Fills a pre-allocated matrix with random values sampled from U(-1,1).
void mu_tensor (gsl_matrix_complex *mu_cell[], gsl_matrix_complex *mu_array[], int mu_counter[], int counter[])
 Shortcut algorithm for tensoring on additional mu matrices to save computation time.
void outer_product (gsl_vector_complex *a, gsl_matrix_complex *c)
 Performs outer product |a><a| into pre-allocated output matrix.
void PSI_matrix (gsl_matrix_complex *psi, double theta)
 Adjusts the density matrix psi to fall on the Werner state line by using the paramter theta, which is delta in the paper.
void random_density_matrix (gsl_matrix_complex *density_random)
 Creates a random density matrix out of a pre-allocated complex matrix.
int read_vector_real (char *fname, gsl_vector *data)
 Reads in real valued vector into data from ASCII file fname.
void rho_MEMS (gsl_matrix_complex *rho_mems, double gamma)
 Density matrix rho_mems fall on MEMS line by varying parameter gamma, as described in the paper.
void sig_tensor (gsl_matrix_complex *sigma_cell[], gsl_matrix_complex *sig_array[], int mu_counter[], int counter[])
 Shortcut algorithm for tensoring on additional sigma matrices to save computation time, see mu_tensor function description.
void sqrtm (gsl_matrix_complex *matrix)
 Computes square root of complex matrix, stores output in originally pre-allocated matrix.
gsl_complex trace (gsl_matrix_complex *m)
 Computes trace of a complex matrix and returns a complex number.
void W_state (gsl_matrix_complex *density)
 Creates a W state density matrix.
int write_data (char *name, gsl_matrix_complex *data)
 Writes complex matrix data into ASCII file specified by name, standard return codes for write.
int write_matrix_real (char *name, gsl_matrix *data)
 Writes real matrix data into ASCII file name.
int write_vector_real (char *name, gsl_vector *data)
 Writes real vector into ASCII file specified by name char string.


Detailed Description

See documentation of header.h - this file contains source code only, with function prototypes in header.h.

Numerical State Tomography Using GSL -> www.gnu.org/software/gsl Copyright (C) 2007 Max S Kaznady

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;

AUTHOR Max S Kaznady, [EMAIL PROTECTED] max.kaznady@gmail.com Summer, 2007

Definition in file utilities.c.


Function Documentation

void mu_tensor ( gsl_matrix_complex *  mu_cell[],
gsl_matrix_complex *  mu_array[],
int  mu_counter[],
int  counter[] 
)

Shortcut algorithm for tensoring on additional mu matrices to save computation time.

Mu_cell contains pointers to gsl mu matrices that make up the final mu matrix which corresponds to base-4 representation in mu_counter. The function corrects mu_cell to represent "counter" base-4 representation by location the index of the mu matrix in mu_cell starting from which new matrices need to be tensored on from mu_array.

Basically this is an update function which computes the final mu_matrix corresponding to the correct base-4 representation in counter without recomputing everything from scratch.

Definition at line 185 of file utilities.c.

References kron(), and NQ.

Referenced by measure_state(), my_df(), my_f(), and my_fdf().

00185                                                                                                           {
00186     //gsl_matrix_complex *mu_nu = gsl_matrix_complex_alloc(pow(2, NQ), pow(2, NQ));
00187     int i, j;
00188     for (i=0; i<NQ; i++) {
00189         if (counter[i]!=mu_counter[i]) { //locate place from which to update
00190             if (i==0) { //base case
00191                 //mu_cell[i] = mu_array[0];
00192                 //mu_cell[0] = gsl_matrix_complex_alloc(2, 2);
00193                 gsl_matrix_complex_memcpy(mu_cell[0], mu_array[counter[i]]);
00194                 i++;
00195             }
00196             for (j=i; j<NQ; j++) { //update the rest of elements
00197                 //gsl_matrix_complex_free(mu_cell[i]);
00198                 //printf("mu_tensor, j=%d and i=%d, counter[j]=%d \n", j, i, counter[j]);
00199                 //mu_cell[j] = gsl_matrix_complex_alloc((mu_cell[j-1]->size1)*2, (mu_cell[j-1]->size2)*2);
00200                 kron(mu_cell[j-1], mu_array[counter[j]], mu_cell[j]);
00201             }
00202             break; // done updating
00203         }
00204     }
00205 }


Generated on Thu Sep 11 10:27:18 2008 for Numerical State Tomography by  doxygen 1.5.6