text:
#include <cstdlib>
#include <iostream>

#include "exception.h"
#include "averageplane.h"
#include "triangulator.h"
#include "meshcleanup.h"
#include "meshdecimation.h"

REMESHER_NAMESPACE_BEGIN

void
MeshDecimation::start_decimation (void)
{
  /* A few consistency checks... */
  if (this->mesh.get() == 0)
    throw Exception("Mesh not set!");

  if (this->dlist == 0 || this->dlist->empty())
    throw Exception("Delete list not initialized!");

  if (this->dlist->size() != this->mesh->get_vertices().size())
    throw Exception("Invalid delete list given");

  /* Calculate vertex information. */
  this->vinfo = VertexInfoList::create(this->mesh);
  this->vertex_amount = this->vinfo->size();

  /* Try to delete each marked vertex. */
  std::size_t deleted = 0;
  std::vector<std::size_t> retry_list;
  for (std::size_t i = 0; i < this->dlist->size(); ++i)
  {
    if (!this->dlist->at(i))
      continue;

    this->dlist->at(i) = this->delete_vertex(i);
    if (this->dlist->at(i) == false)
      retry_list.push_back(i);
    else
      deleted += 1;
  }

  std::cout << "Deleted " << deleted << " vertices. retrying..." << std::endl;

  /* Retry to delete. */
  deleted = 0;
  for (std::size_t i = 0; i < retry_list.size(); ++i)
  {
    std::size_t index = retry_list[i];
    this->dlist->at(index) = this->delete_vertex(index);
    if (this->dlist->at(index) == true)
      deleted += 1;
  }
  std::cout << "Done, deleted " << deleted << " more vertices." << std::endl;

  /* Try to match the specified vertex budget. */
  if (this->vertex_budget != 0)
  {
    while (this->vertex_amount > this->vertex_budget)
    {
      std::size_t rand = std::rand() % this->dlist->size();

      /* Skip already deleted vertices. */
      if (this->dlist->at(rand))
        continue;

      /* Skip feature vertices. */
      if (this->features.get() != 0 && !this->features->empty())
      {
        VertexInfo::VertexList vl;
        this->vinfo->get_adjacent_vertices(rand, vl);
        std::size_t fedges = this->features->count_edges_for_vertex(rand, vl);
        if (fedges > 0)
          continue;
      }

      /* Try to delete vertex. */
      this->dlist->at(rand) = this->delete_vertex(rand);
    }
  }

  /* Clean the mesh from deleted faces and vertices. */
  MeshCleanup cleaner(this->mesh);
  cleaner.set_vertex_info(this->vinfo);
  cleaner.set_vertex_reloc_list(this->reloc);
  cleaner.cleanup_deleted(*this->dlist);

  this->vinfo.reset();

  /* Make a copy of the mesh to free unused space. */
  this->mesh = this->mesh->create_copy();

  /* Update features. */
  this->features->set_mesh(this->mesh);
  this->features->set_vertex_info(VertexInfoList::create(this->mesh));
  this->features->fix_index_relocation(*this->reloc);
}

/* ---------------------------------------------------------------- */

bool
MeshDecimation::delete_vertex (std::size_t index)
{
  /* Check if the vertex should really be deleted. */
  VertexInfo const& vi = this->vinfo[index];
  switch (vi.vclass)
  {
    case VERTEX_CLASS_COMPLEX:
      std::cout << "Warning: Cannot delete complex vertex!" << std::endl;
      return false;

    case VERTEX_CLASS_UNREFERENCED:
      this->vertex_amount -= 1;
      return true;

    case VERTEX_CLASS_SIMPLE:
      if (vi.adj_faces.size() < 3)
      {
        std::cout << "Warning: Skipping vertex with <3 faces" << std::endl;
        return false;
      }
      break;

    case VERTEX_CLASS_BORDER:
      if (vi.adj_faces.size() < 2)
        return false;
      break;

    default:
      return false;
  }

  /* Get some information about the vertex. */
  VertexInfo::VertexList vlist;
  this->vinfo->get_adjacent_vertices(index, vlist);

  #if 0
  /* Check for complex vertex loops. */
  if (this->vinfo->is_complex_vertex_loop(vlist))
  {
    std::cout << "Warning: Skipping vertex with complex loop" << std::endl;
    return false;
  }
  #endif

  /* Define a (yet invalid) split line. The resulting hole is forced to
   * be triangulated with the given split line, that is to keep features. */
  SplitLine sline(MAX_SIZE_T, MAX_SIZE_T);

  /* Check if the vertex is on a feature crease. Define a splitline then. */
  bool is_global_feature = false;
  if (this->features.get() != 0 && !this->features->empty())
  {
    FeatureVertexEdges ve = this->features->get_edges_for_vertex(index, vlist);
    if (ve.size() == 2)
    {
      is_global_feature = true;
      for (std::size_t i = 0; i < vlist.size(); ++i)
      {
        if (ve[0] == vlist[i])
          sline.first = i;
        else if (ve[1] == vlist[i])
          sline.second = i;
      }

      if (sline.first == MAX_SIZE_T || sline.second == MAX_SIZE_T)
      {
        sline = SplitLine(MAX_SIZE_T, MAX_SIZE_T);
        std::cout << "Warning: Splitline was not found!" << std::endl;
        return false;
      }
    }
    else if (ve.size() == 1 || ve.size() > 2)
    {
      return false;
    }
  }

  /* Calculate average plane. */
  Plane3f av_plane;
  {
    MeshVertexList const& verts = this->mesh->get_vertices();
    AveragePlane av;
    for (std::size_t i = 0; i < vlist.size(); ++i)
      av.add_point(verts[vlist[i]]);
    av.add_point(verts[index]);
    av_plane = av.get_average();
  }

  /* Triangulate the vertex loop. */
  MeshFaceList flist;
  Triangulator tri(this->mesh);
  tri.set_vertex_info(this->vinfo);
  bool good = tri.triangulate(vlist, flist, av_plane.n, sline);
  if (!good)
  {
    std::cout << "Warning: Triangulation failed!" << std::endl;
    return false;
  }

  /* Fix features data structure. */
  if (is_global_feature)
  {
    this->features->rm_feature_edge(index, vlist[sline.first]);
    this->features->rm_feature_edge(index, vlist[sline.second]);
    this->features->add_feature_edge(vlist[sline.first], vlist[sline.second]);
    this->features[index].clear();
  }

  /* Replace faces in the mesh with the new triangulation. */
  VertexInfo::FaceList const& aflist = vi.adj_faces;
  this->replace_faces(aflist, flist);
  this->vertex_amount -= 1;

  return true;
}

/* ---------------------------------------------------------------- */

void
MeshDecimation::replace_faces (VertexInfo::FaceList aflist,
    MeshFaceList const& flist)
{
  if (aflist.size() < flist.size() / 3)
    throw Exception("Cannot insert faces while replacing");

  MeshFaceList& faces = this->mesh->get_faces();

  /* Remove all references in the vertex info to the old faces. */
  for (std::size_t i = 0; i < aflist.size(); ++i)
  {
    std::size_t fidx = aflist[i];
    for (std::size_t j = 0; j < 3; ++j)
      this->vinfo->remove_adjacent_face(faces[fidx * 3 + j], fidx);
  }

  /* Insert references in the vertex info to the new faces. */
  for (std::size_t i = 0; i < flist.size(); ++i)
  {
    std::size_t offset = i % 3;
    std::size_t fidx = aflist[i / 3];
    faces[fidx * 3 + offset] = flist[i];
    this->vinfo[flist[i]].adj_faces.push_back(fidx);
  }

  /* Invalidate residual faces by setting vertex indices to 0. */
  for (std::size_t i = flist.size() / 3; i < aflist.size(); ++i)
    for (std::size_t j = 0; j < 3; ++j)
      faces[aflist[i] * 3 + j] = 0;

  /* Update the data structure by reordering the faces. */
  for (std::size_t i = 0; i < flist.size(); ++i)
    this->vinfo->order_and_classify(flist[i]);
}

REMESHER_NAMESPACE_END


text:
require 'telegram_rb'
trap("SIGINT") { exit! }

$flag = false
$peer = nil
$msg = ""

module Telegram
  def self.receive_message(message)
    if $flag == false
      $flag = !$flag
      $peer = message.from_id
      $msg = message.text.force_encoding("UTF-8")
    else
      $flag = !$flag
      $peer = nil
      $msg = ""
    end
  end
end

Telegram.init

while true
  Telegram.poll_messages
  if $flag == true
    puts $msg.encoding.name
    Telegram.send_message($peer, $msg.reverse)
  end
  sleep 5
end

redpajama_set_name: RedPajamaGithub


text:
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd" version="3.3" ID="P0b002ee1873d1385">
<name type="corporate">
 <namePart>United States Government Printing Office</namePart>
 <role>
  <roleTerm type="text" authority="marcrelator">printer</roleTerm>
  <roleTerm type="code" authority="marcrelator">prt</roleTerm>
</role>
 <role>
  <roleTerm type="text" authority="marcrelator">distributor</roleTerm>
  <roleTerm type="code" authority="marcrelator">dst</roleTerm>
</role>
</name>
<name type="corporate">
 <namePart>United States</namePart>
 <namePart>United States District Court District of Kansas</namePart>
 <role>
  <roleTerm type="text" authority="marcrelator">author</roleTerm>
  <roleTerm type="code" authority="marcrelator">aut</roleTerm>
</role>
 <description>Government Organization</description>
</name>
<typeOfResource>text</typeOfResource>
<genre authority="marcgt">government publication</genre>
<language>
 <languageTerm authority="iso639-2b" type="code">eng</languageTerm>
</language>
<extension>
 <collectionCode>USCOURTS</collectionCode>
 <category>Judicial Publications</category>
 <branch>judicial</branch>
 <dateIngested>2014-02-21</dateIngested>
</extension>
<originInfo>
 <publisher>Administrative Office of the United States Courts</publisher>
 <dateIssued encoding="w3cdtf">2006-01-17</dateIssued>
 <issuance>monographic</issuance>
</originInfo>
<physicalDescription>
 <note type="source content type">deposited</note>
 <digitalOrigin>born digital</digitalOrigin>
</physicalDescription>
<classification authority="sudocs">JU 4.15</classification>
<identifier type="uri">http://www.gpo.gov/fdsys/pkg/USCOURTS-ksd-5_04-cr-40028</identifier>
<identifier type="local">P0b002ee1873d1385</identifier>
<recordInfo>
 <recordContentSource authority="marcorg">DGPO</recordContentSource>
 <recordCreationDate encoding="w3cdtf">2014-02-21</recordCreationDate>
 <recordChangeDate encoding="w3cdtf">2014-02-21</recordChangeDate>
 <recordIdentifier source="DGPO">USCOURTS-ksd-5_04-cr-40028</recordIdentifier>
 <recordOrigin>machine generated</recordOrigin>
 <languageOfCataloging>
  <languageTerm authority="iso639-2b" type="code">eng</languageTerm>
</languageOfCataloging>
</recordInfo>
<accessCondition type="GPO scope determination">fdlp</accessCondition>
<extension>
 <docClass>USCOURTS</docClass>
 <accessId>USCOURTS-ksd-5_04-cr-40028</accessId>
 <courtType>District</courtType>
 <courtCode>ksd</courtCode>
 <courtCircuit>10th</courtCircuit>
 <courtState>Kansas</courtState>
 <courtSortOrder>2190</courtSortOrder>
 <caseNumber>5:04-cr-40028</caseNumber>
 <caseOffice>Topeka</caseOffice>
 <caseType>criminal</caseType>
 <party firstName="Julius" fullName="Julius Shaner Hayes" lastName="Hayes" middleName="Shaner" role="Defendant"></party>
 <party firstName="Julius" fullName="Julius Shanier Hayes" lastName="Hayes" middleName="Shanier" role="Defendant"></party>
 <party fullName="USA" lastName="USA" role="Plaintiff"></party>
</extension>
<titleInfo>
 <title>USA v. Hayes</title>
 <partNumber>5:04-cr-40028</partNumber>
</titleInfo>
<location>
 <url access="object in context" displayLabel="Content Detail">http://www.gpo.gov/fdsys/pkg/USCOURTS-ksd-5_04-cr-40028/content-detail.html</url>
</location>
<classification authority="sudocs">JU 4.15</classification>
<identifier type="preferred citation">5:04-cr-40028;04-40028</identifier>
<name type="corporate">
 <namePart>United States District Court District of Kansas</namePart>
 <namePart>10th Circuit</namePart>
 <namePart>Topeka</namePart>
 <affiliation>U.S. Courts</affiliation>
 <role>
  <roleTerm authority="marcrelator" type="text">author</roleTerm>
  <roleTerm authority="marcrelator" type="code">aut</roleTerm>
</role>
</name>
<name type="personal">
 <displayForm>Julius Shaner Hayes</displayForm>
 <namePart type="family">Hayes</namePart>
 <namePart type="given">Julius</namePart>
 <namePart type="termsOfAddress"></namePart>
 <description>Defendant</description>
</name>
<name type="personal">
 <displayForm>Julius Shanier Hayes</displayForm>
 <namePart type="family">Hayes</namePart>
 <namePart type="given">Julius</namePart>
 <namePart type="termsOfAddress"></namePart>
 <description>Defendant</description>
</name>
<name type="personal">
 <displayForm>USA</displayForm>
 <namePart type="family">USA</namePart>
 <namePart type="given"></namePart>
 <namePart type="termsOfAddress"></namePart>
 <description>Plaintiff</description>
</name>
<extension>
 <docClass>USCOURTS</docClass>
 <accessId>USCOURTS-ksd-5_04-cr-40028</accessId>
 <courtType>District</courtType>
 <courtCode>ksd</courtCode>
 <courtCircuit>10th</courtCircuit>
 <courtState>Kansas</courtState>
 <courtSortOrder>2190</courtSortOrder>
 <caseNumber>5:04-cr-40028</caseNumber>
 <caseOffice>Topeka</caseOffice>
 <caseType>criminal</caseType>
 <party firstName="Julius" fullName="Julius Shaner Hayes" lastName="Hayes" middleName="Shaner" role="Defendant"></party>
 <party firstName="Julius" fullName="Julius Shanier Hayes" lastName="Hayes" middleName="Shanier" role="Defendant"></party>
 <party fullName="USA" lastName="USA" role="Plaintiff"></party>
 <state>Kansas</state>
</extension>
<relatedItem type="constituent" ID="id-USCOURTS-ksd-5_04-cr-40028-0" xlink:href="http://www.gpo.gov/fdsys/granule/USCOURTS-ksd-5_04-cr-40028/USCOURTS-ksd-5_04-cr-40028-0/mods.xml">
 <titleInfo>
  <title>USA v. Hayes</title>
  <subTitle>MEMORANDUM AND ORDER denying 25 Motion to Vacate (2255) as to Julius Shanier Hayes (1). Signed by Judge Richard D. Rogers on 1/17/06. (meh)</subTitle>
  <partNumber>0</partNumber>
</titleInfo>
 <originInfo>
  <dateIssued>2006-01-17</dateIssued>
</originInfo>
 <relatedItem type="otherFormat" xlink:href="http://www.gpo.gov/fdsys/pkg/USCOURTS-ksd-5_04-cr-40028/pdf/USCOURTS-ksd-5_04-cr-40028-0.pdf">
  <identifier type="FDsys Unique ID">D09002ee1875bec4c</identifier>
</relatedItem>
 <identifier type="uri">http://www.gpo.gov/fdsys/granule/USCOURTS-ksd-5_04-cr-40028/USCOURTS-ksd-5_04-cr-40028-0</identifier>
 <identifier type="former granule identifier">ksd-5_04-cr-40028_0.pdf</identifier>
 <location>
  <url access="object in context" displayLabel="Content Detail">http://www.gpo.gov/fdsys/granule/USCOURTS-ksd-5_04-cr-40028/USCOURTS-ksd-5_04-cr-40028-0/content-detail.html</url>
  <url access="raw object" displayLabel="PDF rendition">http://www.gpo.gov/fdsys/pkg/USCOURTS-ksd-5_04-cr-40028/pdf/USCOURTS-ksd-5_04-cr-40028-0.pdf</url>
</location>
 <extension>
  <searchTitle>USCOURTS 5:04-cr-40028; USA v. Hayes; </searchTitle>
  <courtName>United States District Court District of Kansas</courtName>
  <state>Kansas</state>
  <accessId>USCOURTS-ksd-5_04-cr-40028-0</accessId>
  <sequenceNumber>0</sequenceNumber>
  <dateIssued>2006-01-17</dateIssued>
  <docketText>MEMORANDUM AND ORDER denying 25 Motion to Vacate (2255) as to Julius Shanier Hayes (1). Signed by Judge Richard D. Rogers on 1/17/06. (meh)</docketText>
</extension>
</relatedItem>
</mods>


text:
public interface IFoo<S>
{ }

public class ArrayList<T>
{
        public virtual int InsertAll (IFoo<T> foo)
        {
                return 0;
        }

        public virtual int InsertAll<U> (IFoo<U> foo)
                where U : T
        {
                return 1;
        }

        public virtual int AddAll (IFoo<T> foo)
        {
                return InsertAll (foo);
        }
}

class X
{
	public static void Main ()
	{ }
}


text:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>NcRecomb: NumCosmo Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" />
<link rel="home" href="index.html" title="NumCosmo Reference Manual" />
<link rel="up" href="ch06.html" title="Cosmological Calculators" />
<link rel="prev" href="NcScalefactor.html" title="NcScalefactor" />
<link rel="next" href="NcRecombSeager.html" title="NcRecombSeager" />
<meta name="generator" content="GTK-Doc V1.33.1 (XML mode)" />
<link rel="stylesheet" href="style.css" type="text/css" />
<link rel="stylesheet" href="container.css" type="text/css" />

Top  |
                  Description  |
                  Object Hierarchy  |
                  Properties

NcRecomb

NcRecomb — Abstract class for cosmic recombination.

Functions

<colgroup>
<col width="150px" class="functions_proto_type" />
<col class="functions_proto_name" />
</colgroup>

NcRecomb *

nc_recomb_new_from_name ()

NcRecomb *

nc_recomb_ref ()

void

nc_recomb_free ()

void

nc_recomb_clear ()

void

nc_recomb_prepare ()

void

nc_recomb_prepare_if_needed ()

void

nc_recomb_set_zi ()

void

nc_recomb_require_zi ()

gdouble

nc_recomb_get_zi ()

gdouble

nc_recomb_Xe ()

gdouble

nc_recomb_XHII ()

gdouble

nc_recomb_XHeII ()

gdouble

nc_recomb_HI_ion_saha ()

gdouble

nc_recomb_HeI_ion_saha ()

gdouble

nc_recomb_HeII_ion_saha ()

gdouble

nc_recomb_HeII_ion_saha_x ()

gdouble

nc_recomb_HeII_ion_saha_x_by_HeIII_He ()

gdouble

nc_recomb_He_fully_ionized_Xe ()

gdouble

nc_recomb_equilibrium_Xe ()

gdouble

nc_recomb_equilibrium_XHI ()

gdouble

nc_recomb_equilibrium_XHII ()

gdouble

nc_recomb_equilibrium_XHeI ()

gdouble

nc_recomb_equilibrium_XHeII ()

gdouble

nc_recomb_equilibrium_XHeIII ()

gdouble

nc_recomb_dtau_dx ()

gdouble

nc_recomb_dtau_dlambda ()

gdouble

nc_recomb_d2tau_dlambda2 ()

gdouble

nc_recomb_d3tau_dlambda3 ()

gdouble

nc_recomb_tau ()

gdouble

nc_recomb_tau_drag ()

gdouble

nc_recomb_tau_lambda0_lambda1 ()

gdouble

nc_recomb_log_v_tau ()

gdouble

nc_recomb_v_tau ()

gdouble

nc_recomb_dv_tau_dlambda ()

gdouble

nc_recomb_d2v_tau_dlambda2 ()

void

nc_recomb_v_tau_lambda_features ()

gdouble

nc_recomb_get_v_tau_max_lambda ()

gdouble

nc_recomb_get_tau_lambda ()

gdouble

nc_recomb_get_tau_drag_lambda ()

gdouble

nc_recomb_get_tau_cutoff_lambda ()

gdouble

nc_recomb_get_v_tau_max_z ()

gdouble

nc_recomb_get_tau_z ()

gdouble

nc_recomb_get_tau_drag_z ()

gdouble

nc_recomb_get_tau_cutoff_z ()

gdouble

nc_recomb_dtau_dlambda_Xe ()

gdouble

nc_recomb_He_fully_ionized_dtau_dlambda ()

Properties

<colgroup>
<col width="150px" class="properties_type" />
<col width="300px" class="properties_name" />
<col width="200px" class="properties_flags" />
</colgroup>

double
init-frac
Read / Write / Construct

double
prec
Read / Write / Construct

double
zi
Read / Write / Construct

Types and Values

<colgroup>
<col width="150px" class="other_proto_type" />
<col class="other_proto_name" />
</colgroup>

#define
NC_RECOMB_STARTING_X

Object Hierarchy

    GObject
    ╰── NcRecomb
        ├── NcRecombCBE
        ╰── NcRecombSeager

Includes

#include <numcosmo/nc_recomb.h>

Description

$
 \newcommand{\He}{\text{He}}
 \newcommand{\HeI}{\text{HeI}}
 \newcommand{\HeII}{\text{HeII}}
 \newcommand{\HeIII}{\text{HeIII}}
 \newcommand{\Hy}{\text{H}}
 \newcommand{\HyI}{\text{HI}}
 \newcommand{\HyII}{\text{HII}}
 \newcommand{\e}{{\text{e}^-}}
$

The NcRecomb abstract object describe a general recombination process.
To describe the functions we have the following definitions,
more details in Weinberg (2008).

We refer to the total number of hydrogen nucleus (ionized or not) as
$n_{\Hy}$, the neutral hydrogen atoms as $n_{\HyI}$ and ionized hydrogen as
$n_{\HyII}$ and, therefore, $n_{\HyI} + n_{\HyII} = n_{\Hy}$. Similarly,
the number of helium nuclei is $n_{\He}$ and the neutral,
single and double ionized are $n_{\HeI}$, $n_{\HeII}$ and $n_{\HeIII}$,
respectively.

We also define the helium primordial abundance as the ratio of the helium
mass to the total baryonic mass, i.e.,
\begin{align}\label{def:Yp}
Y_p = \frac{n_{\He} m_{\He}}{(n_{\He} m_{\He} + n_{\Hy} m_{\Hy})},
\end{align}
where $m_{\Hy}$ and $m_{\He}$ are the hydrogen and helium masses.

The element abundances are defined as the ratio of the element by the total
number of free protons $n_p \equiv n_\Hy$:
\begin{align}
X_{f} = \frac{n_{f}}{n_p},
\end{align}
where $f$ is any one of the elements described above and $\e$ represent
the number of free electrons.

These fractions have the following properties:
\begin{align}\label{eq:Hy:add}
X_\HyI + X_{\HyII} &= 1, \\ \label{eq:He:add}
X_{\HeI} + X_{\HeII} + X_{\HeIII} &= X_{\He}, \\
X_{\He} &\equiv \frac{m_p}{m_{\He}}\frac{Y_p}{1-Y_p}.
\end{align}
We also define the number of free electrons as $n_\e$. Assuming a neutral
universe we have
\begin{equation}\label{eq:def:Xe}
X_\e = X_{\HyII} + X_{\HeII} + 2X_{\HeIII}.
\end{equation}

Equilibrium fractions

Equilibrium ratio $X_{\HyII}X_\e / X_\Hy$ through Saha equation, i.e.,
\begin{equation}\label{eq:saha:HyI}
\frac{X_{\HyII}X_\e}{X_\HyI} = \frac{e^{-\HyI_{1s}/(k_BT)}}{n_{\Hy}\lambda_{\e}^3},
\end{equation}
where $\HyI_{1s}$ is the hydrogen $1s$ binding energy ncm_c_HI_ion_E_1s_2S0_5(),
$\lambda_{\e}$ is the electron thermal wavelength, i.e.,
\begin{equation}
\lambda_{\e} = \sqrt{\frac{2\pi\hbar^2}{m_\e{}k_BT}},
\end{equation}
$k_K$ is the Boltzmann constant ncm_c_kb(), $m_\e$ the electron mass and
$\hbar$ is the Planck constant ncm_c_hbar().

This calculation is done using the Saha equation as in
Weinberg (2008).

The equilibrium single/non-ionized helium ratio $X_{\HeII}X_\e/X_{\HeI}$
through Saha equation, i.e.,
\begin{equation}\label{eq:saha:HeI}
\frac{X_{\HeII}X_\e}{X_{\HeI}} = \frac{e^{-\HeI_{1s}/(k_BT)}}{4n_{\Hy}\lambda_{\e}^3},
\end{equation}
where $\HeI_{1s}$ is the helium I $1s$ binding energy ncm_c_HeI_ion_E_1s_1S0().
This calculation is done using the Saha equation as in
Seager (2000).

The equilibrium double/single-ionized helium ratio $X_{\HeIII}X_\e/X_{\HeII}$
through Saha equation, i.e.,
\begin{equation}\label{eq:saha:HeII}
\frac{X_{\HeIII}X_\e}{X_{\HeII}} = \frac{e^{-\HeII_{1s}/(k_BT)}}{4n_{\Hy}\lambda_{\e}^3},
\end{equation}
where $\HeII_{1s}$ is the helium II $1s$ binding energy ncm_c_HeII_ion_E_1s_2S0_5().
This calculation is done using the Saha equation as in
Seager (2000).

The default value of the helium primordial abundance
is given by nc_hicosmo_Yp_4He().
The primordial Helium fraction is define by nc_hicosmo_XHe().

Optical depth and visibility function

The derivative of the optical depth $\tau$ with respect to the redshift
time $\lambda \equiv -\ln(x) = -\ln(1 + z)$ is
\begin{equation}\label{eq:def:dtaudlambda}
\frac{d\tau}{d\lambda} = -\frac{c\sigma_Tn_BX_\e}{H},
\end{equation}
where $c$ is the speed of light [ncm_c_c()], $\sigma_T$ is the Thomson
cross section [ncm_c_thomson_cs()], $n_B$ is the number density of baryons
and $H$ the Hubble function. We define the optical depth $\tau$ integrating
from the present time, i.e.,
\begin{equation}\label{eq:def:tau}
\tau = \int_0^\lambda\frac{d\tau}{d\lambda}.
\end{equation}
Using the equations above we define the visibility function $v_\tau$ as
\begin{equation}\label{eq:def:vtau}
v_\tau = \frac{d\tau}{d\lambda}e^{-\tau}.
\end{equation}

Functions

nc_recomb_new_from_name ()

NcRecomb *
nc_recomb_new_from_name (const gchar *recomb_name);

This function instantiates a new object of type NcRecomb given recomb_name
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb_name

a string representing a NcRecomb object

Returns

 a new NcRecomb

nc_recomb_ref ()

NcRecomb *
nc_recomb_ref (NcRecomb *recomb);

Increases the reference count of recomb
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

Returns

recomb
.

[<acronym title="The caller owns the data, and is responsible for free it.">transfer full</acronym>]

nc_recomb_free ()

void
nc_recomb_free (NcRecomb *recomb);

Decreases the reference count of recomb

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

nc_recomb_clear ()

void
nc_recomb_clear (NcRecomb **recomb);

Decreases the reference count of *recomb
 if
*recomb
 is not NULL, then sets *recomb
 to NULL.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

nc_recomb_prepare ()

void
nc_recomb_prepare (NcRecomb *recomb,
                   NcHICosmo *cosmo);

Prepares the object using the model cosmo
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

nc_recomb_prepare_if_needed ()

void
nc_recomb_prepare_if_needed (NcRecomb *recomb,
                             NcHICosmo *cosmo);

Prepares the object using the model cosmo
 if it was changed
since last preparation.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

nc_recomb_set_zi ()

void
nc_recomb_set_zi (NcRecomb *recomb,
                  const gdouble zi);

Sets the initial redshift of the integration $[0, z_i]$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

zi

initial redshift to prepare the recombination functions $z_i$

nc_recomb_require_zi ()

void
nc_recomb_require_zi (NcRecomb *recomb,
                      const gdouble zi);

Requires the initial redshift of at least $z_i$ = zi
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

zi

initial redshift to prepare the recombination functions $z_i$

nc_recomb_get_zi ()

gdouble
nc_recomb_get_zi (NcRecomb *recomb);

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

Returns

 the current initial redshift $z_i$.

nc_recomb_Xe ()

gdouble
nc_recomb_Xe (NcRecomb *recomb,
              NcHICosmo *cosmo,
              const gdouble lambda);

Calculates the value of $X_\e$ at lambda
.

[<acronym title="This is the invoker for a virtual method.">virtual</acronym> Xe]

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $X_\e$

nc_recomb_XHII ()

gdouble
nc_recomb_XHII (NcRecomb *recomb,
                NcHICosmo *cosmo,
                const gdouble lambda);

Calculates the value of $X_\HyII$ at lambda
.

[<acronym title="This is the invoker for a virtual method.">virtual</acronym> XHII]

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $X_\HyII$

nc_recomb_XHeII ()

gdouble
nc_recomb_XHeII (NcRecomb *recomb,
                 NcHICosmo *cosmo,
                 const gdouble lambda);

Calculates the value of $X_\HeII$ at lambda
.

[<acronym title="This is the invoker for a virtual method.">virtual</acronym> XHeII]

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $X_\HeII$

nc_recomb_HI_ion_saha ()

gdouble
nc_recomb_HI_ion_saha (NcHICosmo *cosmo,
                       const gdouble x);

Calculates the equilibrium ionized/non-ionized hydrogen abundance ratio
$X_{\HyII}X_\e / X_{\HyI}$. See Eq. \eqref{eq:saha:HyI}.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 the abundance ratio $X_{\HyII}X_\e / X_{\HyI}$

nc_recomb_HeI_ion_saha ()

gdouble
nc_recomb_HeI_ion_saha (NcHICosmo *cosmo,
                        const gdouble x);

Calculates the equilibrium single/non-ionized helium ratio
$X_{\HeII}X_\e/X_{\HeI}$. See Eq. \eqref{eq:saha:HeI}.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 the ratio $X_{\HeII}X_\e/X_{\HeI}$

nc_recomb_HeII_ion_saha ()

gdouble
nc_recomb_HeII_ion_saha (NcHICosmo *cosmo,
                         const gdouble x);

Calculates the equilibrium double/single ionized helium ratio
($X_{\HeIII}X_\e/X_{\HeII}$). See Eq. \eqref{eq:saha:HeII}.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 the ratio $X_{\HeIII}X_\e/X_{\HeII}$

nc_recomb_HeII_ion_saha_x ()

gdouble
nc_recomb_HeII_ion_saha_x (NcHICosmo *cosmo,
                           const gdouble f);

Calculates the redshift where the ratio $$X_{\HeIII}X_\e/X_{\HeII} = f.$$

This calculation is done by finding the value of $x$ where
$$\frac{e^{-\HeII_{1s}/(k_BT)}}{4n_{\Hy}\lambda_{\e}^3} = f.$$

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

cosmo

a NcHICosmo

f

$X_{\HeIII}X_\e/X_{\HeII}$

Returns

 the value of $x$ where the ratio f
occur

nc_recomb_HeII_ion_saha_x_by_HeIII_He ()

gdouble
nc_recomb_HeII_ion_saha_x_by_HeIII_He (NcHICosmo *cosmo,
                                       const gdouble f);

Calculates the redshift where the ratio $$X_{\HeIII}/X_{\He} = f.$$

This calculation is done assuming that hydrogen and helium are
fully ionized, i.e., $\HyI = 0 = \HeI$. In this case
$$\frac{X_{\HeIII}X_\e}{X_{\HeII}} =
\frac{f}{1-f}\left[1 + X_\He(1+f)\right].$$

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

cosmo

a NcHICosmo

f

value of $X_{\HeIII}/X_{\He}$

Returns

 the value of $x$ where the ratio f
occur

nc_recomb_He_fully_ionized_Xe ()

gdouble
nc_recomb_He_fully_ionized_Xe (NcHICosmo *cosmo,
                               const gdouble x);

Assuming that all helium is single or double ionized and all hydrogen is
ionized, we have $$X_\e = 1 + X_\HeII + 2X_\HeIII,\quad X_\He = X_\HeII +
X_\HeIII,$$ thus, $$X_\HeIII = X_\e-X_\He-1,\quad X_\HeII = 1 + 2X_\He -
X_\e.$$ Using nc_recomb_HeII_ion_saha() and nc_hicosmo_XHe() we obtain
$X_\e$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 $X_\e$

nc_recomb_equilibrium_Xe ()

gdouble
nc_recomb_equilibrium_Xe (NcRecomb *recomb,
                          NcHICosmo *cosmo,
                          const gdouble x);

Calculates the ionization fraction $X_\e$ assuming equilibrium at all times.
It solves the system containing all Saha's equations Eqs \eqref{eq:saha:HyI},
\eqref{eq:saha:HeI} and \eqref{eq:saha:HeII} and the constraints Eq
\eqref{eq:Hy:add}, \eqref{eq:He:add} and \eqref{eq:def:Xe}.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 $X_\e$

nc_recomb_equilibrium_XHI ()

gdouble
nc_recomb_equilibrium_XHI (NcRecomb *recomb,
                           NcHICosmo *cosmo,
                           const gdouble x);

Calculates the hydrogen-I fraction $X_\HyI$ assuming equilibrium at all times.
It solves the system containing all Saha's equations Eqs \eqref{eq:saha:HyI},
\eqref{eq:saha:HeI} and \eqref{eq:saha:HeII} and the constraints Eq
\eqref{eq:Hy:add}, \eqref{eq:He:add} and \eqref{eq:def:Xe}.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 $X_\HyI$

nc_recomb_equilibrium_XHII ()

gdouble
nc_recomb_equilibrium_XHII (NcRecomb *recomb,
                            NcHICosmo *cosmo,
                            const gdouble x);

Calculates the hydrogen-II fraction $X_\HyII$ assuming equilibrium at all times.
It solves the system containing all Saha's equations Eqs \eqref{eq:saha:HyI},
\eqref{eq:saha:HeI} and \eqref{eq:saha:HeII} and the constraints Eq
\eqref{eq:Hy:add}, \eqref{eq:He:add} and \eqref{eq:def:Xe}.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 $X_\HyII$

nc_recomb_equilibrium_XHeI ()

gdouble
nc_recomb_equilibrium_XHeI (NcRecomb *recomb,
                            NcHICosmo *cosmo,
                            const gdouble x);

Calculates the helium-I fraction $X_\HeI$ assuming equilibrium at all times.
It solves the system containing all Saha's equations Eqs \eqref{eq:saha:HyI},
\eqref{eq:saha:HeI} and \eqref{eq:saha:HeII} and the constraints Eq
\eqref{eq:Hy:add}, \eqref{eq:He:add} and \eqref{eq:def:Xe}.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 $X_\HyII$

nc_recomb_equilibrium_XHeII ()

gdouble
nc_recomb_equilibrium_XHeII (NcRecomb *recomb,
                             NcHICosmo *cosmo,
                             const gdouble x);

Calculates the helium-II fraction $X_\HeII$ assuming equilibrium at all times.
It solves the system containing all Saha's equations Eqs \eqref{eq:saha:HyI},
\eqref{eq:saha:HeI} and \eqref{eq:saha:HeII} and the constraints Eq
\eqref{eq:Hy:add}, \eqref{eq:He:add} and \eqref{eq:def:Xe}.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 $X_\HyII$

nc_recomb_equilibrium_XHeIII ()

gdouble
nc_recomb_equilibrium_XHeIII (NcRecomb *recomb,
                              NcHICosmo *cosmo,
                              const gdouble x);

Calculates the helium-III fraction $X_\HeIII$ assuming equilibrium at all times.
It solves the system containing all Saha's equations Eqs \eqref{eq:saha:HyI},
\eqref{eq:saha:HeI} and \eqref{eq:saha:HeII} and the constraints Eq
\eqref{eq:Hy:add}, \eqref{eq:He:add} and \eqref{eq:def:Xe}.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

x

redshift factor, $x = 1+z$

Returns

 $X_\HyII$

nc_recomb_dtau_dx ()

gdouble
nc_recomb_dtau_dx (NcRecomb *recomb,
                   NcHICosmo *cosmo,
                   const gdouble lambda);

Computes the derivative of the optical depth with respect to $x = 1 + z$,
$\frac{\mathrm{d}\tau}{\mathrm{d}x}$, at lambda
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $\left.\frac{\mathrm{d}\tau}{\mathrm{d}x}\right|_{\lambda}$

nc_recomb_dtau_dlambda ()

gdouble
nc_recomb_dtau_dlambda (NcRecomb *recomb,
                        NcHICosmo *cosmo,
                        const gdouble lambda);

Computes the derivative of the optical depth with respect to $\lambda$,
$\frac{\mathrm{d}\tau}{\mathrm{d}\lambda}$, at lambda
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $\left.\frac{\mathrm{d}\tau}{\mathrm{d}\lambda}\right|_{\lambda}$

nc_recomb_d2tau_dlambda2 ()

gdouble
nc_recomb_d2tau_dlambda2 (NcRecomb *recomb,
                          NcHICosmo *cosmo,
                          const gdouble lambda);

Computes the second derivative of the optical depth with respect to $\lambda$,
$\frac{\mathrm{d}^2\tau}{\mathrm{d}\lambda^2}$, at lambda
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $\left.\frac{\mathrm{d}^2\tau}{\mathrm{d}\lambda^2}\right|_{\lambda}$

nc_recomb_d3tau_dlambda3 ()

gdouble
nc_recomb_d3tau_dlambda3 (NcRecomb *recomb,
                          NcHICosmo *cosmo,
                          const gdouble lambda);

Computes the third derivative of the optical depth with respect to $\lambda$,
$\frac{\mathrm{d}^3\tau}{\mathrm{d}\lambda^3}$, at lambda
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $\left.\frac{\mathrm{d}^3\tau}{\mathrm{d}\lambda^3}\right|_{\lambda}$

nc_recomb_tau ()

gdouble
nc_recomb_tau (NcRecomb *recomb,
               NcHICosmo *cosmo,
               const gdouble lambda);

Computes the optical depth [Eq. \eqref{eq:def:tau}] at lambda
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $\tau$

nc_recomb_tau_drag ()

gdouble
nc_recomb_tau_drag (NcRecomb *recomb,
                    NcHICosmo *cosmo,
                    const gdouble lambda);

Computes the drag depth,
$$\tau_d \equiv \int_0^\lambda \mathrm{d}\lambda R^{-1} \frac{n_e \sigma_T}{1+z},$$
where $R = \frac{3\bar{\rho}_b}{4\bar{\rho}_\gamma}$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $\tau_\mathrm{drag}$

nc_recomb_tau_lambda0_lambda1 ()

gdouble
nc_recomb_tau_lambda0_lambda1 (NcRecomb *recomb,
                               NcHICosmo *cosmo,
                               const gdouble lambda0,
                               const gdouble lambda1);

Computes the optical depth between lambda1
 and lambda0
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda0

$\lambda_0$

lambda1

$\lambda_1$

Returns

 $\tau(\lambda_1) - \tau(\lambda_0)$

nc_recomb_log_v_tau ()

gdouble
nc_recomb_log_v_tau (NcRecomb *recomb,
                     NcHICosmo *cosmo,
                     const gdouble lambda);

Computes the logarithm base e of the visibility function [Eq. \eqref{eq:def:vtau}] at lambda
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $\log(v_\tau)$

nc_recomb_v_tau ()

gdouble
nc_recomb_v_tau (NcRecomb *recomb,
                 NcHICosmo *cosmo,
                 const gdouble lambda);

Computes the visibility function [Eq. \eqref{eq:def:vtau}] at lambda
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $v_\tau$

nc_recomb_dv_tau_dlambda ()

gdouble
nc_recomb_dv_tau_dlambda (NcRecomb *recomb,
                          NcHICosmo *cosmo,
                          const gdouble lambda);

Computes the derivative of the visibility function [Eq. \eqref{eq:def:vtau}] at lambda
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $\left. \frac{\mathrm{d}v_\tau}{\mathrm{d}\lambda}\right|_\lambda$

nc_recomb_d2v_tau_dlambda2 ()

gdouble
nc_recomb_d2v_tau_dlambda2 (NcRecomb *recomb,
                            NcHICosmo *cosmo,
                            const gdouble lambda);

Computes the second derivative of the visibility function [Eq. \eqref{eq:def:vtau}] at lambda
.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $\left. \frac{\mathrm{d}^2v_\tau}{\mathrm{d}\lambda^2}\right|_\lambda$

nc_recomb_v_tau_lambda_features ()

void
nc_recomb_v_tau_lambda_features (NcRecomb *recomb,
                                 NcHICosmo *cosmo,
                                 gdouble logref,
                                 gdouble *lambda_max,
                                 gdouble *lambda_l,
                                 gdouble *lambda_u);

Calculates the maximum of the visibility function [Eq \eqref{eq:def:vtau}], i.e,
the value of $\lambda_\text{max}$ where
$dv_\tau(\lambda_\text{max})/d\lambda = 0$, and the values where the
visibility drops to $v_\tau(\lambda_\text{max})e^{-\text{logref}}$ to the left
$\lambda_l$ and to the right $\lambda_u$ of $\lambda_\text{max}$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

logref

the logarithm of the reference scale

lambda_max

$\lambda_\text{max}$.

[<acronym title="Parameter for returning results. Default is transfer full.">out</acronym>]

lambda_l

$\lambda_l$.

[<acronym title="Parameter for returning results. Default is transfer full.">out</acronym>]

lambda_u

$\lambda_u$.

[<acronym title="Parameter for returning results. Default is transfer full.">out</acronym>]

nc_recomb_get_v_tau_max_lambda ()

gdouble
nc_recomb_get_v_tau_max_lambda (NcRecomb *recomb,
                                NcHICosmo *cosmo);

Calculates the maximum of the visibility function [Eq. \eqref{eq:def:vtau}],
the value of $\lambda_\text{max}$ where
$dv_\tau(\lambda_\text{max})/d\lambda = 0$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

Returns

 $\lambda_\text{max}$

nc_recomb_get_tau_lambda ()

gdouble
nc_recomb_get_tau_lambda (NcRecomb *recomb,
                          NcHICosmo *cosmo);

Calculates the value of $\lambda$ where the optical depth
[Eq \eqref{eq:def:tau}] is equal to one, i.e., $\tau(\lambda^\star) = 1$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

Returns

 $\lambda^\star$

nc_recomb_get_tau_drag_lambda ()

gdouble
nc_recomb_get_tau_drag_lambda (NcRecomb *recomb,
                               NcHICosmo *cosmo);

Calculates the value of $\lambda$ where the optical depth times $R$
[Eq. \eqref{eq:def:tau}] is equal to one, i.e., $\tau_\mathrm{drag}(\lambda^\star) = 1$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

Returns

 $\lambda^\star$

nc_recomb_get_tau_cutoff_lambda ()

gdouble
nc_recomb_get_tau_cutoff_lambda (NcRecomb *recomb,
                                 NcHICosmo *cosmo);

Calculates the value of $\lambda$ where the optical depth
[Eq \eqref{eq:def:tau}] attains a value such that
$e^{-\tau(\lambda_\text{cutoff})} = \epsilon_\text{double}$, i.e.,
equal to the smallest value of a double which add to one.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

Returns

 $\lambda_\text{cutoff}$

nc_recomb_get_v_tau_max_z ()

gdouble
nc_recomb_get_v_tau_max_z (NcRecomb *recomb,
                           NcHICosmo *cosmo);

Calculates the maximum of the visibility function [Eq. \eqref{eq:def:vtau}],
the value of $z(\lambda_\text{max})$ where
$dv_\tau(\lambda_\text{max})/d\lambda = 0$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

Returns

 $z(\lambda_\text{max})$

nc_recomb_get_tau_z ()

gdouble
nc_recomb_get_tau_z (NcRecomb *recomb,
                     NcHICosmo *cosmo);

Calculates the value of $z(\lambda)$ where the optical depth
[Eq \eqref{eq:def:tau}] is equal to one, i.e., $\tau(\lambda^\star) = 1$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

Returns

 $z(\lambda^\star)$

nc_recomb_get_tau_drag_z ()

gdouble
nc_recomb_get_tau_drag_z (NcRecomb *recomb,
                          NcHICosmo *cosmo);

Calculates the value of $z(\lambda)$ where the optical depth times $R$ (drag depth)
[Eq. \eqref{eq:def:tau}] is equal to one, i.e., $\tau_\mathrm{drag}(\lambda^\star) = 1$.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

Returns

 $z(\lambda^\star)$

nc_recomb_get_tau_cutoff_z ()

gdouble
nc_recomb_get_tau_cutoff_z (NcRecomb *recomb,
                            NcHICosmo *cosmo);

Calculates the value of $z(\lambda)$ where the optical depth
[Eq \eqref{eq:def:tau}] attains a value such that
$e^{-\tau(\lambda_\text{cutoff})} = \epsilon_\text{double}$, i.e.,
equal to the smallest value of a double which add to one.

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

recomb

a NcRecomb

cosmo

a NcHICosmo

Returns

 $z(\lambda_\text{cutoff})$

nc_recomb_dtau_dlambda_Xe ()

gdouble
nc_recomb_dtau_dlambda_Xe (NcHICosmo *cosmo,
                           const gdouble lambda);

The derivative of the optical depth [Eq. \eqref{eq:def:dtaudlambda}] over
the ionization fraction $X_\e$ [Eq. \eqref{eq:def:Xe}].

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $X_\e^{-1}d\tau/d\lambda$

nc_recomb_He_fully_ionized_dtau_dlambda ()

gdouble
nc_recomb_He_fully_ionized_dtau_dlambda
                               (NcHICosmo *cosmo,
                                const gdouble lambda);

The derivative of the optical depth [Eq. \eqref{eq:def:dtaudlambda}], considering
fully ionized helium and hydrogen [nc_recomb_He_fully_ionized_Xe()].

Parameters

<colgroup>
<col width="150px" class="parameters_name" />
<col class="parameters_description" />
<col width="200px" class="parameters_annotations" />
</colgroup>

cosmo

a NcHICosmo

lambda

$\lambda = - \ln(1+z)$

Returns

 $d\tau/d\lambda$

Types and Values

NC_RECOMB_STARTING_X

#define NC_RECOMB_STARTING_X (1.0e12)

Property Details

The "init-frac" property

  "init-frac"                double

Initial fraction to start numerical integration.

Owner: NcRecomb

Flags: Read / Write / Construct

Allowed values: [0,1]

Default value: 1e-11

The "prec" property

  "prec"                     double

The precision used in the calculations.

Owner: NcRecomb

Flags: Read / Write / Construct

Allowed values: [0,1]

Default value: 1e-07

The "zi" property

  "zi"                       double

Initial redshift to prepare the recombination functions.

Owner: NcRecomb

Flags: Read / Write / Construct

Allowed values: >= 0

Default value: 1e+12

Generated by GTK-Doc V1.33.1


text:
<!doctype html>

<meta charset="utf-8">
<title>Automated Testing with PHPUnit is a puzzle, Continuous Integration is the missing Piece [Slides] – YoungInnovations Blog</title>
<meta name="description" content="Well I’m going to present today at the 14th PHP developers meetup. I will be talking about Automated Unit Testing and Continuous Integration. I am going to be explaining about why testing, in general is important, the features of unit tests and why CI is cool.

Automated tests with phpunit is a puzzle, CI is the missing piece

">
<meta name="keywords" content="phpunit, unit tests, automated testing, continuous integration, shippable">

<meta name="twitter:title" content="Automated Testing with PHPUnit is a puzzle, Continuous Integration is the missing Piece [Slides]">
<meta name="twitter:description" content="Well I’m going to present today at the 14th PHP developers meetup. I will be talking about Automated Unit Testing and Continuous Integration. I am going to be explaining about why testing, in general is important, the features of unit tests and why CI is cool.

Automated tests with phpunit is a puzzle, CI is the missing piece

">
<meta name="twitter:site" content="@yipl">

<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://blog.yipl.com.np/images/default-thumb.png">

<meta property="og:locale" content="en_US">
<meta property="og:type" content="article">
<meta property="og:title" content="Automated Testing with PHPUnit is a puzzle, Continuous Integration is the missing Piece [Slides]">
<meta property="og:description" content="Well I’m going to present today at the 14th PHP developers meetup. I will be talking about Automated Unit Testing and Continuous Integration. I am going to be explaining about why testing, in general is important, the features of unit tests and why CI is cool.

Automated tests with phpunit is a puzzle, CI is the missing piece

">
<meta property="og:url" content="http://blog.yipl.com.np/automated-testing-and-continuous-integration/">
<meta property="og:site_name" content="YoungInnovations Blog">

<meta property="og:image" content="http://blog.yipl.com.np/images/default-thumb.png">

<meta name="google-site-verification" content="ohAwulapf87s0SWlslqhJUAb2phTTGjazQ0AvLD3xv0">

<link rel="canonical" href="http://blog.yipl.com.np/automated-testing-and-continuous-integration/">
<link href="http://blog.yipl.com.np/feed.xml" type="application/atom+xml" rel="alternate" title="YoungInnovations Blog Feed">
<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700' rel='stylesheet' type='text/css'>

<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="http://blog.yipl.com.np/assets/css/main.css">

<meta http-equiv="cleartype" content="on">

<link href='//fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700%7CPT+Serif:400,700,400italic' rel='stylesheet' type='text/css'>

<link rel="shortcut icon" href="http://blog.yipl.com.np/favicon.ico">

<link rel="shortcut icon" href="http://blog.yipl.com.np/favicon.png">

<link rel="apple-touch-icon-precomposed" href="http://blog.yipl.com.np/images/apple-touch-icon-precomposed.png">

<link rel="apple-touch-icon-precomposed" sizes="72x72" href="http://blog.yipl.com.np/images/apple-touch-icon-72x72-precomposed.png">

<link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://blog.yipl.com.np/images/apple-touch-icon-114x114-precomposed.png">

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="http://blog.yipl.com.np/images/apple-touch-icon-144x144-precomposed.png">

		YoungInnovations Blog

About

Posts

Sachit Bir Singh Dongol

Jr. Software Engineer

   Github

Automated Testing with PHPUnit is a puzzle, Continuous Integration is the missing Piece [Slides]

Well I'm going to present today at the 14th PHP developers meetup. I will be talking about Automated Unit Testing and Continuous Integration. I am going to be explaining about why testing, in general is important, the features of unit tests and why CI is cool.

Automated tests with phpunit is a puzzle, CI is the missing piece

Automated unit test simply put is code testing another piece of code. Unit testing focuses on testing a small independent working part of the code which is generally a method/function. Unit tests need to be fast, offline, not dependent on database and test only one thing. Mocking other dependencies is a great way to unit test the class to be tested. To a beginner understanding this is as difficult as solving a puzzle.

With Continuous Integration, at every push, all the tests are run that covers the code changes and approves what works, what doesn't and all the bugs you have in your system from a unit perspective with a fast feedback loop. If your change broke something existing you know it in minutes then you can fix your code and add more tests for the parts you did.

Moreover continuous integration is a mentality to keep software quality high with having the build green for main branch in a VCS at all times. CI goes like a hand in a glove with the issue flow and simplified gitflow that we follow. I will talk about how we integrated our automated tests with Shippable and the benefits of CI.

You can check out the slides for my talk at my github page or down below.

  Automated Unit Testing and Continuous Integration  from bsscht

Interested in what you see? Then you can check out the offical documentation for PHPUnit and to learn more about Shippable, they have got a pretty decent documentation.

Write testable code and readable tests.

Tags: phpunit , unit tests , automated testing , continuous integration , shippable

Share on

       Twitter

       Facebook

       Google+

Automated Testing with PHPUnit is a puzzle, Continuous Integration is the missing Piece [Slides] was published on <time datetime="2015-09-05T00:00:00+04:00">September 05, 2015</time> and last modified on <time datetime="2015-09-05">September 05, 2015</time>.

You might also enjoy (View all posts)

7 Golden Rules of Simple and Clean code and some more considerations [Slides]

Dribbble Meetup 2015

Deploy a Laravel 5 application with Capistrano 3

© 2015 YoungInnovations Blog. Powered by Jekyll using the Minimal Mistakes theme.


text:
/*
	All rights reserved. Use of this source code is governed by the
	3-clause BSD License in LICENSE.txt.
*/

#include <iostream>
#include <list>
#include <algorithm>
#include "palette.h"
#include "selectable.h"

Palette::Palette(PaletteType pt) : kind(pt) { }

bool Palette::hasSelections() const { return selections.size() > 0; }
void Palette::select(Selectable * w) {
	if (kind == PT_SINGLE_SELECT)
		clearSelections(w);
	selections.insert(w);
}
void Palette::deselect(Selectable *w) { selections.erase(w); }

void Palette::clearSelections(Selectable * except) {
	if (!selections.empty()) {
		std::list<Selectable*> to_deselect;
		std::copy(selections.begin(), selections.end(), std::back_inserter(to_deselect) );
		for (auto iter = to_deselect.begin(); iter != to_deselect.end(); ++iter) {
			Selectable *sel = *iter;
			if (sel != except && sel->isSelected())
				sel->deselect();
		}
	}
}

const std::set<Selectable *> &Palette::getSelected() const {
	return selections;
}

#if 0
Palette::Palette(const Palette &orig){
    text = orig.text;
}

Palette &Palette::operator=(const Palette &other) {
    text = other.text;
    return *this;
}

std::ostream &Palette::operator<<(std::ostream &out) const  {
    out << text;
    return out;
}

std::ostream &operator<<(std::ostream &out, const Palette &m) {
    return m.operator<<(out);
}

bool Palette::operator==(const Palette &other) {
    return text == other.text;
}
#endif


text:
print('text 1')
print('text 2')


text:
<?php

namespace SkyaTura\EloquentREST\Traits;

use Illuminate\Http\Request;

trait DefaultActionsTrait
{
    use ResponseTrait, FilterTrait;
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $obj = $this->model();
        $filtered = $this->filter($obj, $request);
        return $this->response($filtered->get());
    }

    /**
     * Display the specified resource.
     *
     * @param  Request $request
     * @return \Illuminate\Http\Response
     */
    public function show(Request $request)
    {
        $obj = $this->model();
        $filtered = $this->filter($obj, $request);
        return $this->response($filtered->get()->first());
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $model = $this->defaultModel($request->all());
        $model->save();
        return $this->response($model);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request)
    {
        $class = $this->defaultModel;
        /**
         * @var $model \Illuminate\Database\Eloquent\Model
         */
        $model = $class::find($this->ref);
        $fillable = $model->getFillable();
        $newValues = $request->intersect($fillable);
        $model->fill($newValues);
        $model->save();
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int $id
     * @return \Illuminate\Http\Response
     */
    public function delete(Request $request)
    {
        $class = $this->defaultModel;
        /**
         * @var $model \Illuminate\Database\Eloquent\Model
         */
        $model = $class::find($this->ref);
        $model->delete();
    }

    /**
     * Handle calls to missing methods on the controller.
     *
     * @param  string  $method
     * @param  array   $parameters
     * @return mixed
     *
     * @throws \BadMethodCallException
     */
    public function __call($method, $parameters = []){
        return $this->responseError("Unknown method");
    }
}


text:
<?php

declare(strict_types=1);

namespace AspectMock\Intercept;

class MethodInvocation
{
    public $closure;

    protected $method;

    protected $arguments;

    protected $isStatic;

    protected $declaredClass;

    protected $class;

    /**
     * @param mixed $declaredClass
     */
    public function setDeclaredClass($declaredClass): void
    {
        $this->declaredClass = $declaredClass;
    }

    /**
     * @return mixed
     */
    public function getDeclaredClass()
    {
        return $this->declaredClass;
    }

    /**
     * @param mixed $isStatic
     */
    public function isStatic($isStatic = null)
    {
        if ($isStatic === null) return $this->isStatic;

        $this->isStatic = $isStatic;
    }

    /**
     * @param mixed $class
     */
    public function setThis($class): void
    {
        $this->class = $class;
    }

    /**
     * @return mixed
     */
    public function getThis()
    {
        return $this->class;
    }

    /**
     * @param mixed $closure
     */
    public function setClosure($closure): void
    {
        $this->closure = $closure;
    }

    /**
     * @return mixed
     */
    public function getClosure()
    {
        return $this->closure;
    }

    /**
     * @param mixed $method
     */
    public function setMethod($method): void
    {
        $this->method = $method;
    }

    /**
     * @return mixed
     */
    public function getMethod()
    {
        return $this->method;
    }

    /**
     * @param mixed $params
     */
    public function setArguments($params): void
    {
        $this->arguments = $params;
    }

    /**
     * @return mixed
     */
    public function getArguments()
    {
        return $this->arguments;
    }

}


text:
class ChangeConversationArchivedToBoolean < ActiveRecord::Migration
  def up
    add_column :conversations, :archived, :boolean, default: false
    Conversation.where(
      status: 'archived'
    ).update_all(
      archived: true
    )
    remove_column :conversations, :status
  end

  def down
    add_column :conversations, :status, :string
    Conversation.where(
      archived: true
    ).update_all(
      status: 'archived'
    )
    remove_column :conversations, :archived
  end

end


text:
package org.spongepowered.common.data.nbt.validation;

import org.spongepowered.api.CatalogType;
import org.spongepowered.api.util.annotation.CatalogedBy;

@CatalogedBy(Validations.class)
public interface ValidationType extends CatalogType {

}


text:
<?php

namespace Tests\Centreon\Domain\PlatformTopology;

use Centreon\Domain\Platform\Interfaces\PlatformRepositoryInterface;
use PHPUnit\Framework\TestCase;
use Centreon\Domain\Broker\BrokerConfiguration;
use Centreon\Domain\Contact\Contact;
use Centreon\Domain\Engine\EngineException;
use PHPUnit\Framework\MockObject\MockObject;
use Centreon\Domain\Engine\EngineConfiguration;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Centreon\Domain\Exception\EntityNotFoundException;
use Centreon\Domain\MonitoringServer\MonitoringServer;
use Centreon\Domain\PlatformTopology\Model\PlatformRegistered;
use Centreon\Domain\PlatformTopology\Model\PlatformPending;
use Centreon\Domain\Proxy\Interfaces\ProxyServiceInterface;
use Centreon\Domain\Broker\Interfaces\BrokerRepositoryInterface;
use Centreon\Domain\PlatformTopology\PlatformTopologyService;
use Centreon\Domain\MonitoringServer\Exception\MonitoringServerException;
use Centreon\Domain\PlatformTopology\Exception\PlatformTopologyException;
use Centreon\Domain\PlatformInformation\Exception\PlatformInformationException;
use Centreon\Domain\Engine\Interfaces\EngineConfigurationServiceInterface;
use Centreon\Domain\MonitoringServer\Interfaces\MonitoringServerServiceInterface;
use Centreon\Domain\PlatformTopology\Interfaces\PlatformTopologyRepositoryInterface;
use Centreon\Domain\PlatformInformation\Interfaces\PlatformInformationServiceInterface;
use Centreon\Domain\PlatformTopology\Interfaces\PlatformTopologyRegisterRepositoryInterface;
use Centreon\Domain\PlatformTopology\Interfaces\PlatformTopologyRepositoryExceptionInterface;
use Centreon\Domain\RemoteServer\Interfaces\RemoteServerRepositoryInterface;

class PlatformTopologyServiceTest extends TestCase
{
    /**
     * @var Contact|null $adminContact
     */
    protected $adminContact;

    /**
     * @var PlatformPending|null $platform
     */
    protected $platform;

    /**
     * @var PlatformRegistered|null $registeredParent
     */
    protected $registeredParent;

    /**
     * @var PlatformRepositoryInterface&MockObject $platformTopologyRepository
     */
    protected $platformTopologyRepository;

    /**
     * @var HttpClientInterface|null $httpClient
     */
    protected $httpClient;

    /**
     * @var PlatformInformationServiceInterface&MockObject $platformInformationService
     */
    private $platformInformationService;

    /**
     * @var ProxyServiceInterface&MockObject $proxyService
     */
    private $proxyService;

    /**
     * @var EngineConfiguration|null $engineConfiguration
     */
    protected $engineConfiguration;

    /**
     * @var BrokerConfiguration $brokerConfiguration
     */
    protected $brokerConfiguration;

    /**
     * @var EngineConfigurationServiceInterface&MockObject $engineConfigurationService
     */
    protected $engineConfigurationService;

    /**
     * @var MonitoringServerServiceInterface&MockObject $monitoringServerService
     */
    protected $monitoringServerService;

    /**
     * @var MonitoringServer;
     */
    protected $monitoringServer;

    /**
     * @var BrokerRepositoryInterface&MockObject $brokerRepository
     */
    protected $brokerRepository;

    /**
     * @var PlatformTopologyRegisterRepositoryInterface&MockObject $platformTopologyRegisterRepository
     */
    private $platformTopologyRegisterRepository;

    /**
     * Undocumented variable
     *
     * @var RemoteServerRepositoryInterface&MockObject $remoteServerRepository
     */
    private $remoteServerRepository;

    /**
     * initiate query data
     */
    protected function setUp(): void
    {
        $this->adminContact = (new Contact())
            ->setId(1)
            ->setName('admin')
            ->setAdmin(true);

        $this->platform = (new PlatformPending())
            ->setId(2)
            ->setName('poller1')
            ->setAddress('1.1.1.2')
            ->setType('poller')
            ->setParentAddress('1.1.1.1')
            ->setHostname('localhost.localdomain');

        $this->registeredParent = (new PlatformRegistered())
            ->setName('Central')
            ->setAddress('1.1.1.1')
            ->setType('central')
            ->setId(1)
            ->setHostname('central.localdomain');

        $this->engineConfiguration = (new EngineConfiguration())
            ->setId(1)
            ->setIllegalObjectNameCharacters('$!?')
            ->setMonitoringServerId(1)
            ->setName('Central');

        $this->monitoringServer = (new MonitoringServer())
            ->setId(1)
            ->setName('Central');

        $this->brokerConfiguration = (new BrokerConfiguration())
            ->setConfigurationKey('one_peer_retention_mode')
            ->setConfigurationValue('no');

        $this->platformTopologyRepository = $this->createMock(PlatformTopologyRepositoryInterface::class);
        $this->platformInformationService = $this->createMock(PlatformInformationServiceInterface::class);
        $this->proxyService = $this->createMock(ProxyServiceInterface::class);
        $this->httpClient = $this->createMock(HttpClientInterface::class);
        $this->engineConfigurationService = $this->createMock(EngineConfigurationServiceInterface::class);
        $this->monitoringServerService = $this->createMock(MonitoringServerServiceInterface::class);
        $this->brokerRepository = $this->createMock(BrokerRepositoryInterface::class);
        $this->platformTopologyRegisterRepository = $this->createMock(
            PlatformTopologyRegisterRepositoryInterface::class
        );
        $this->remoteServerRepository = $this->createMock(RemoteServerRepositoryInterface::class);
    }

    /**
     * test addPendingPlatformToTopology with already existing platform
     * @throws MonitoringServerException
     * @throws EngineException
     * @throws PlatformTopologyException
     * @throws EntityNotFoundException
     * @throws PlatformTopologyRepositoryExceptionInterface
     * @throws PlatformInformationException
     */
    public function testaddPendingPlatformToTopologyAlreadyExists(): void
    {
        $this->platformTopologyRepository
            ->expects($this->once())
            ->method('findPlatformByAddress')
            ->willReturn($this->platform);

        $this->platformTopologyRepository
            ->expects($this->once())
            ->method('findPlatformByName')
            ->willReturn($this->platform);

        $this->monitoringServerService
            ->expects($this->once())
            ->method('findLocalServer')
            ->willReturn($this->monitoringServer);

        $this->engineConfigurationService
            ->expects($this->once())
            ->method('findEngineConfigurationByName')
            ->willReturn($this->engineConfiguration);

        $platformTopologyService = new PlatformTopologyService(
            $this->platformTopologyRepository,
            $this->platformInformationService,
            $this->proxyService,
            $this->engineConfigurationService,
            $this->monitoringServerService,
            $this->brokerRepository,
            $this->platformTopologyRegisterRepository,
            $this->remoteServerRepository
        );

        $this->expectException(PlatformTopologyException::class);
        $this->expectExceptionMessage("A platform using the name : 'poller1' or address : '1.1.1.2' already exists");
        $platformTopologyService->addPendingPlatformToTopology($this->platform);
    }

    /**
     * test addPendingPlatformToTopology with not found parent
     * @throws MonitoringServerException
     * @throws EngineException
     * @throws PlatformTopologyException
     * @throws EntityNotFoundException
     * @throws PlatformInformationException
     * @throws PlatformTopologyRepositoryExceptionInterface
     */
    public function testaddPendingPlatformToTopologyNotFoundParent(): void
    {
        $this->platformTopologyRepository
            ->expects($this->any())
            ->method('findPlatformByAddress')
            ->willReturn(null);

        $this->platformTopologyRepository
            ->expects($this->once())
            ->method('findPlatformByName')
            ->willReturn(null);

        $this->platformTopologyRepository
            ->expects($this->any())
            ->method('findPlatformByAddress')
            ->willReturn(null);

        $this->monitoringServerService
            ->expects($this->once())
            ->method('findLocalServer')
            ->willReturn($this->monitoringServer);

        $this->engineConfigurationService
            ->expects($this->once())
            ->method('findEngineConfigurationByName')
            ->willReturn($this->engineConfiguration);

        $platformTopologyService = new PlatformTopologyService(
            $this->platformTopologyRepository,
            $this->platformInformationService,
            $this->proxyService,
            $this->engineConfigurationService,
            $this->monitoringServerService,
            $this->brokerRepository,
            $this->platformTopologyRegisterRepository,
            $this->remoteServerRepository
        );

        $this->expectException(EntityNotFoundException::class);
        $this->expectExceptionMessage("No parent platform was found for : 'poller1'@'1.1.1.2'");
        $platformTopologyService->addPendingPlatformToTopology($this->platform);
    }

    /**
     * test addPendingPlatformToTopology which succeed
     * @throws MonitoringServerException
     * @throws EngineException
     * @throws PlatformTopologyException
     * @throws EntityNotFoundException
     * @throws PlatformInformationException
     * @throws PlatformTopologyRepositoryExceptionInterface
     */
    /*
     * @TODO refacto the test when MBI, MAP and failover
    public function testaddPendingPlatformToTopologySuccess(): void
    {
        $this->platform->setParentId(1);

        $this->platformTopologyRepository
            ->expects($this->any())
            ->method('findPlatformByAddress')
            ->willReturn(null);

        $this->platformTopologyRepository
            ->expects($this->once())
            ->method('findPlatformByName')
            ->willReturn(null);

        $this->platformTopologyRepository
            ->expects($this->any())
            ->method('findPlatformByAddress')
            ->willReturn($this->registeredParent);

        $this->monitoringServerService
            ->expects($this->once())
            ->method('findLocalServer')
            ->willReturn($this->monitoringServer);

        $this->engineConfigurationService
            ->expects($this->once())
            ->method('findEngineConfigurationByName')
            ->willReturn($this->engineConfiguration);

        $platformTopologyService = new PlatformTopologyService(
            $this->platformTopologyRepository,
            $this->platformInformationService,
            $this->proxyService,
            $this->engineConfigurationService,
            $this->monitoringServerService,
            $this->brokerRepository,
            $this->platformTopologyRegisterRepository,
            $this->remoteServerRepository
        );

        $this->assertNull($platformTopologyService->addPendingPlatformToTopology($this->platform));
    }*/

    public function testGetPlatformTopologySuccess(): void
    {
        $this->platform
            ->setParentId(1)
            ->setServerId(2);

        $this->registeredParent
            ->setServerId(1);

        $this->brokerRepository
            ->expects($this->any())
            ->method('findByMonitoringServerAndParameterName')
            ->willReturn([$this->brokerConfiguration]);

        $this->platformTopologyRepository
            ->expects($this->once())
            ->method('getPlatformTopology')
            ->willReturn([$this->platform, $this->registeredParent]);

        $this->platformTopologyRepository
            ->expects($this->once())
            ->method('findPlatform')
            ->willReturn($this->registeredParent);

        $platformTopologyService = new PlatformTopologyService(
            $this->platformTopologyRepository,
            $this->platformInformationService,
            $this->proxyService,
            $this->engineConfigurationService,
            $this->monitoringServerService,
            $this->brokerRepository,
            $this->platformTopologyRegisterRepository,
            $this->remoteServerRepository
        );

        $this->assertIsArray($platformTopologyService->getPlatformTopology());
    }

    public function testGetPlatformTopologyWithoutParentId(): void
    {
        $this->registeredParent
            ->setServerId(1);

        $this->brokerRepository
            ->expects($this->any())
            ->method('findByMonitoringServerAndParameterName')
            ->willReturn([$this->brokerConfiguration]);

        $this->platformTopologyRepository
            ->expects($this->once(0))
            ->method('getPlatformTopology')
            ->willReturn([$this->registeredParent]);

        $platformTopologyService = new PlatformTopologyService(
            $this->platformTopologyRepository,
            $this->platformInformationService,
            $this->proxyService,
            $this->engineConfigurationService,
            $this->monitoringServerService,
            $this->brokerRepository,
            $this->platformTopologyRegisterRepository,
            $this->remoteServerRepository
        );

        /**
         * Central Case
         */
        $this->assertIsArray($platformTopologyService->getPlatformTopology());
    }

    public function testGetPlatformTopologyRelationSetting(): void
    {
        $this->registeredParent
            ->setServerId(1);

        $this->platform
            ->setId(2)
            ->setParentId(1)
            ->setServerId(2);

        $this->platformTopologyRepository
            ->expects($this->exactly(2))
            ->method('getPlatformTopology')
            ->willReturn([$this->registeredParent, $this->platform]);

        $this->platformTopologyRepository
            ->expects($this->exactly(2))
            ->method('findPlatform')
            ->willReturn($this->registeredParent);

        $brokerConfigurationPeerRetention = (new BrokerConfiguration())
            ->setConfigurationKey('one_peer_retention_mode')
            ->setConfigurationValue('yes');

        $this->brokerRepository->expects($this->exactly(4))
            ->method('findByMonitoringServerAndParameterName')
            ->willReturnOnConsecutiveCalls(
                [$this->brokerConfiguration],
                [$this->brokerConfiguration],
                [$brokerConfigurationPeerRetention],
                [$brokerConfigurationPeerRetention]
            );

        $platformTopologyService = new PlatformTopologyService(
            $this->platformTopologyRepository,
            $this->platformInformationService,
            $this->proxyService,
            $this->engineConfigurationService,
            $this->monitoringServerService,
            $this->brokerRepository,
            $this->platformTopologyRegisterRepository,
            $this->remoteServerRepository
        );

        /**
         * Normal Relation
         */
        $completeTopology = $platformTopologyService->getPlatformTopology();

        $centralRelation = $completeTopology[0]->getRelation();
        $pollerRelation = $completeTopology[1]->getRelation();

        $this->assertEquals(null, $centralRelation);
        $this->assertEquals('normal', $pollerRelation->getRelation());

        /**
         * One Peer Retention Relation
         */
        $completeTopology = $platformTopologyService->getPlatformTopology();

        $centralRelation = $completeTopology[0]->getRelation();
        $pollerRelation = $completeTopology[1]->getRelation();

        $this->assertEquals(null, $centralRelation);
        $this->assertEquals('peer_retention', $pollerRelation->getRelation());
    }

    public function testDeletePlatformTopologySuccess(): void
    {
        $this->platformTopologyRepository
            ->expects($this->once())
            ->method('findPlatform')
            ->willReturn($this->platform);

        $platformTopologyService = new PlatformTopologyService(
            $this->platformTopologyRepository,
            $this->platformInformationService,
            $this->proxyService,
            $this->engineConfigurationService,
            $this->monitoringServerService,
            $this->brokerRepository,
            $this->platformTopologyRegisterRepository,
            $this->remoteServerRepository
        );

        $this->assertEquals(null, $platformTopologyService->deletePlatformAndReallocateChildren(
            $this->platform->getId()
        ));
    }

    public function testDeletePlatformTopologyWithBadId(): void
    {
        $this->platformTopologyRepository
            ->expects($this->once())
            ->method('findPlatform')
            ->willReturn(null);

        $platformTopologyService = new PlatformTopologyService(
            $this->platformTopologyRepository,
            $this->platformInformationService,
            $this->proxyService,
            $this->engineConfigurationService,
            $this->monitoringServerService,
            $this->brokerRepository,
            $this->platformTopologyRegisterRepository,
            $this->remoteServerRepository
        );

        $this->expectException(EntityNotFoundException::class);
        $this->expectExceptionMessage('Platform not found');

        $platformTopologyService->deletePlatformAndReallocateChildren($this->platform->getId());
    }
}