qubx_model_storage.h.html mathcode2html   
 Source file:   qubx_model_storage.h
 Converted:   Wed Jan 6 2016 at 15:24:07
 This documentation file will not reflect any later changes in the source file.

$$\phantom{******** If you see this on the webpage then the browser could not locate *********}$$
$$\phantom{******** jsMath/easy/load.js or the variable root is set wrong in this file *********}$$
$$\newcommand{\vector}[1]{\left[\begin{array}{c} #1 \end{array}\right]}$$ $$\newenvironment{matrix}{\left[\begin{array}{cccccccccc}} {\end{array}\right]}$$ $$\newcommand{\A}{{\cal A}}$$ $$\newcommand{\W}{{\cal W}}$$

/* Copyright 2008-2011 Research Foundation State University of New York   */

/* This file is part of QUB Express.                                      */

/* QUB Express 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 3 of the License, or      */
/* (at your option) any later version.                                    */

/* QUB Express 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,     */
/* named LICENSE.txt, in the QUB Express program directory.  If not, see  */
/* <http://www.gnu.org/licenses/>.                                        */

#ifndef QUBX_MODEL_STORAGE_H
#define QUBX_MODEL_STORAGE_H

#include "qubx_model.h"
#include "ublas_plus.h"
#include "callbk_reportstream.h"

class QUBFAST_API_CLASS qubx_model_storage {
 public:
  int &Nstate, &Nclass, &IeqFv;
  pointy_col_vector<int> clazz;
  pointy_col_vector<double> P0, amp, var, d_amp, d_var;
  pointy_matrix<double> K0, K1, d_K0, d_K1;
  pointy_matrix<int> L, V;
  callbk_reportfun report_cb;
  void* report_data;
  callbk_reportstream output;

  double &amp0, &var0, &Vrev, &Vleak, &Gleak;
  
  pointy_matrix<double> K2, d_K2;
  pointy_matrix<int> P;
  
  qubx_model_storage(int& Nstate_, int& Nclass_, int *class_of_state, callbk_reportfun report_cb_, void *report_data_,
		     int &IeqFv_, double &amp0_, double &var0_, double &Vrev_, double &Vleak_, double &Gleak_ );
};

class QUBFAST_API_CLASS qubx_multi_model_storage {
 public:
  int &nmutistate, &nmutipath, &nmuticlass, &npath;
  pointy_col_vector<int> class_order, cmutistate;
  pointy_matrix<int> path, mutistate, mutipath;

  qubx_multi_model_storage(int Nstate, int& npath_, int& nmutistate_, int& nmutipath_, int& nmuticlass_);
  
  void setup(int nmutistate, int nmutipath, qubx_multi_model *mm);
};

class QUBFAST_API_CLASS qubx_constrained_storage
{
public:
  int &Npar, &NparR, &NfPar, &Ncns, &NcnsR;
  pointy_matrix<double> Ain, AinR, Acns, Ainv, Ascal, Asci;
  pointy_col_vector<double> Bin, BinR, Bcns, Bscal;
  pointy_col_vector<double> pars, parsR, fPars_unscaled, fPars;
  pointy_col_vector<int> kR_indices, constraint_indices;

  qubx_constrained_storage(int& Npar_, int& NparR_, int& NfPar_, int& Ncns_, int& NcnsR_);

  int setup();
  void free_to_pars();
  void pars_to_free();
  void calc_std(double *InvHessian, double *dPar);
};

   
    
class QUBFAST_API_CLASS qubx_stim_amps_storage
{
public:
  qubx_model *model;
  int Nstim, Nsig, Npar;
  pointy_col_vector<double> stimclasses, sc_frac;
  qubx_constrained *cns;
  qubx_constrained_storage *cnst;
  pointy_matrix<double> sc_amp, sc_var, sc_std;

  qubx_stim_amps_storage(qubx_model *m, int Nstim_, int Nsig_, double *stimclasses_, double *sc_frac_);
  virtual ~qubx_stim_amps_storage();
  
  void setup_scs();
  void pars_to_model();
  void model_to_pars();
};



class QUBFAST_API_CLASS qubx_stim_rates_storage
{
public:
  qubx_model *model;
  eigen_func custom_eigen;
  int Nstim, Nsig;
  pointy_col_vector<double> stimclasses, sc_frac;
  double sampling;
  qubx_constrained *cns;
  qubx_constrained_storage *cnst;
  std::vector< pointy_matrix<double> > QQ, AA, QQ_evec, QQ_einv;
  std::vector< pointy_col_vector<double> > QQ_eig, QQ_imag;
  std::vector<double**> QQ_p, AA_p, QQ_evec_p, QQ_einv_p;
  std::vector<double*> QQ_eig_p, QQ_imag_p;
  pointy_matrix<double> A;
  pointy_matrix<double> tmp_diag, tmp_m;
  
  qubx_stim_rates_storage(qubx_model *m, int Nstim_, int Nsig_, double *stimclasses_, double *sc_frac_,
			  double sampling_, eigen_func custom_eigen_);
  virtual ~qubx_stim_rates_storage();
  
  void setup_QQ();
  void setup_AA();
  void setup_A(int sc, double dt);
  void setup_A(int sc, double dt, matrix<double>& tmp_diag, matrix<double>& tmp_m, matrix<double>& A_result);
  void fixRate(int a, int b);
  void fixExp(int a, int b);
  void scaleRate(int a, int b, int c, int d);
  void scaleExp(int a, int b, int c, int d);
  void balanceLoop(int Nloop, int *loopstates);
  void balanceLoops();
  int setup_constraints();
  void pars_to_model();
  void model_to_pars();
};



#endif