text:
//  Copyright (c) 2005-2009 Hartmut Kaiser
//
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef SAGA_ADAPTORS_DEFAULT_REPLICA_DATABASE_HPP
#define SAGA_ADAPTORS_DEFAULT_REPLICA_DATABASE_HPP

#include <boost/assert.hpp>
#include <saga/saga/url.hpp>

#include "default_replica_adaptor.hpp"
#include "replica_database_connection.hpp"

///////////////////////////////////////////////////////////////////////////////
namespace replica
{
    ///////////////////////////////////////////////////////////////////////////
    // forward declaration only
    class database_scope;

    ///////////////////////////////////////////////////////////////////////////
    class database
    {
    public:
        database(database_connection::db_type type, std::string const & connect_string)
          : type_(type), connect_string_(connect_string)
        {}
        ~database()
        {}

        void verify_status() { connection_->verify_status(); }
        void close(bool verify = true)
            { if (verify) verify_status(); }

        // detect, whether advert already exists
        bool exists(std::string const& lfn)
            { return connection_->exists(lfn); }
        bool exists_entry(std::string const& lfn, bool throw_on_error = true)
            { return connection_->exists_entry(lfn, throw_on_error); }
        bool exists_directory(std::string const& lfn, bool throw_on_error = true)
            { return connection_->exists_directory(lfn, throw_on_error); }

        int find(std::string const& url, bool& found_dir)
            { return connection_->find(url, found_dir); }

        // create a new advert
        bool create_entry(std::string const& lfn, bool create_parents)
            { return connection_->create_entry(lfn, create_parents); }
        bool create_directory(std::string const& lfn, bool create_parents)
            { return connection_->create_directory(lfn, create_parents); }

        // manage nodes
        bool remove(std::string const& lfn)
            { return connection_->remove(lfn); }
        bool remove_directory(std::string const& lfn)
            { return connection_->remove_directory(lfn); }
        bool list(std::string const& lfn, std::string const& pattern,
                std::vector<std::string>& entries)
            { return connection_->list(lfn, pattern, entries); }

        // manage attributes
        bool attribute_exists(std::string const& lfn, std::string const& key,
                bool& val)
            { return connection_->attribute_exists(lfn, key, val); }
        bool get_attribute(std::string const& lfn, std::string const& key,
                std::string& val, bool& is_vector)
            { return connection_->get_attribute(lfn, key, val, is_vector); }
        bool set_attribute(std::string const& lfn, std::string const& key,
                std::string const& val, bool is_vector)
            { return connection_->set_attribute(lfn, key, val, is_vector); }
        bool remove_attribute(std::string const& lfn, std::string const& key)
            { return connection_->remove_attribute(lfn, key); }
        bool list_attributes(std::string const& lfn,
                std::vector<std::string>& keys)
            { return connection_->list_attributes(lfn, keys); }
        bool find_attributes(std::string const& lfn, std::string const& kpat,
                std::string const& vpat, std::vector<std::string>* keys,
                bool count_only = false)
            { return connection_->find_attributes(lfn, kpat, vpat, keys, count_only); }
        bool find_attributes(std::string const& lfn, std::vector<std::string> const& kpat,
                std::vector<std::string> const& vpat, std::vector<std::string>* keys,
                bool count_only = false)
            { return connection_->find_attributes(lfn, kpat, vpat, keys, count_only); }

        // manage entries
        bool get_entries(std::string const& lfn, std::vector<std::string>& locations)
            { return connection_->get_entries(lfn, locations); }
        bool add_entry(std::string const& lfn, std::string const& location)
            { return connection_->add_entry(lfn, location); }
        bool remove_entry(std::string const& lfn, std::string const& location)
            { return connection_->remove_entry(lfn, location); }
        bool update_entry(std::string const& lfn, std::string const& oldlocation,
            std::string const& newlocation)
            { return connection_->update_entry(lfn, oldlocation, newlocation); }

        database_connection::db_type get_dbtype() const { return type_; }
        std::string const& get_connectstring() const { return connect_string_; }

    protected:
        friend class database_scope;

        void set_connection(TR1::shared_ptr<database_connection> connection)
        {
            BOOST_ASSERT(!connection_);
            connection_ = connection;
        }
        TR1::shared_ptr<database_connection> get_connection() const
        {
            return connection_;
        }
        void reset_connection()
        {
            connection_.reset();
        }

    private:
        database_connection::db_type type_;
        std::string connect_string_;
        TR1::shared_ptr<database_connection> connection_;
    };

    ///////////////////////////////////////////////////////////////////////////
    class database_scope
    {
    public:
        template <typename Cpi>
        database_scope(Cpi *cpi_instance, database& db)
          : adaptor_ (TR1::static_pointer_cast<replica::adaptor>(
                cpi_instance->get_adaptor())),
            db_(db)
        {
            db.set_connection(adaptor_->aquire_db_connection(
                db.get_dbtype(), db.get_connectstring()));
        }
        ~database_scope()
        {
            adaptor_->release_db_connection(db_.get_connection());
            db_.reset_connection();
        }

    private:
        TR1::shared_ptr<replica::adaptor> adaptor_;
        database& db_;
    };

///////////////////////////////////////////////////////////////////////////////
}   // replica

#endif // !SAGA_ADAPTORS_DEFAULT_REPLICA_DATABASE_HPP

max_stars_repo_name: saga-project/saga-cpp

max_issues_repo_name: saga-project/saga-cpp

max_forks_repo_name: saga-project/saga-cpp


text:
//==================================================================================================
/*!
  @file

  @copyright 2016 NumScale SAS
  @copyright 2016 J.T.Lapreste

  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#ifndef BOOST_SIMD_ARCH_COMMON_SIMD_FUNCTION_MASK2LOGICAL_HPP_INCLUDED
#define BOOST_SIMD_ARCH_COMMON_SIMD_FUNCTION_MASK2LOGICAL_HPP_INCLUDED
#include <boost/simd/detail/overload.hpp>

#include <boost/simd/meta/hierarchy/simd.hpp>
#include <boost/simd/function/simd/bitwise_cast.hpp>
#include <boost/simd/meta/as_logical.hpp>
#include <boost/simd/meta/is_logical_mask.hpp>
#include <boost/simd/detail/assert_utils.hpp>

namespace boost { namespace simd { namespace ext
{
   namespace bd = boost::dispatch;
   namespace bs = boost::simd;
  BOOST_DISPATCH_OVERLOAD(mask2logical_
                         , (typename A0,typename X)
                         , bd::cpu_
                         , bs::pack_<bd::arithmetic_<A0>,X>
                         )

  {
    using result =  bs::as_logical_t<A0> ;
    BOOST_FORCEINLINE result operator()( const A0& a0
                                       ) const BOOST_NOEXCEPT
    {
//       std::cout << a0 << std::endl;
//       std::cout << typeindex::type_id < A0>() << std::endl;
      BOOST_ASSERT_MSG(assert_is_mask(a0), "Argument to mask2logical is not a valid logical mask");
      return bitwise_cast<result>(a0);
    }
  };

} } }

#endif

ext: hpp


text:
/*
 * This file is open source software, licensed to you under the terms
 * of the Apache License, Version 2.0 (the "License").  See the NOTICE file
 * distributed with this work for additional information regarding copyright
 * ownership.  You may not use this file except in compliance with the License.
 *
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
/*
 * Copyright (C) 2018 ScyllaDB
 */

#pragma once

#ifdef SEASTAR_USE_STD_OPTIONAL_VARIANT_STRINGVIEW
#include <optional>
#include <string_view>
#include <variant>
#else
#include <experimental/optional>
#include <experimental/string_view>
#include <boost/variant.hpp>
#endif

#if __cplusplus >= 201703L && __has_include(<filesystem>)
#include <filesystem>
#else
#include <experimental/filesystem>
#endif

namespace seastar {

/// \cond internal

namespace compat {

#ifdef SEASTAR_USE_STD_OPTIONAL_VARIANT_STRINGVIEW

template <typename T>
using optional = std::optional<T>;

using nullopt_t = std::nullopt_t;

inline constexpr auto nullopt = std::nullopt;

template <typename T>
inline constexpr optional<std::decay_t<T>> make_optional(T&& value) {
    return std::make_optional(std::forward<T>(value));
}

template <typename CharT, typename Traits = std::char_traits<CharT>>
using basic_string_view = std::basic_string_view<CharT, Traits>;

template <typename CharT, typename Traits = std::char_traits<CharT>>
std::string string_view_to_string(const basic_string_view<CharT, Traits>& v) {
    return std::string(v);
}

template <typename... Types>
using variant = std::variant<Types...>;

template <std::size_t I, typename... Types>
constexpr std::variant_alternative_t<I, variant<Types...>>& get(variant<Types...>& v) {
    return std::get<I>(v);
}

template <std::size_t I, typename... Types>
constexpr const std::variant_alternative_t<I, variant<Types...>>& get(const variant<Types...>& v) {
    return std::get<I>(v);
}

template <std::size_t I, typename... Types>
constexpr std::variant_alternative_t<I, variant<Types...>>&& get(variant<Types...>&& v) {
    return std::get<I>(v);
}

template <std::size_t I, typename... Types>
constexpr const std::variant_alternative_t<I, variant<Types...>>&& get(const variant<Types...>&& v) {
    return std::get<I>(v);
}

template <typename U, typename... Types>
constexpr U& get(variant<Types...>& v) {
    return std::get<U>(v);
}

template <typename U, typename... Types>
constexpr const U& get(const variant<Types...>& v) {
    return std::get<U>(v);
}

template <typename U, typename... Types>
constexpr U&& get(variant<Types...>&& v) {
    return std::get<U>(v);
}

template <typename U, typename... Types>
constexpr const U&& get(const variant<Types...>&& v) {
    return std::get<U>(v);
}

template <typename U, typename... Types>
constexpr U* get_if(variant<Types...>* v) {
    return std::get_if<U>(v);
}

template <typename U, typename... Types>
constexpr const U* get_if(const variant<Types...>* v) {
    return std::get_if<U>(v);
}

#else

template <typename T>
using optional = std::experimental::optional<T>;

using nullopt_t = std::experimental::nullopt_t;

constexpr auto nullopt = std::experimental::nullopt;

template <typename T>
inline constexpr optional<std::decay_t<T>> make_optional(T&& value) {
    return std::experimental::make_optional(std::forward<T>(value));
}

template <typename CharT, typename Traits = std::char_traits<CharT>>
using basic_string_view = std::experimental::basic_string_view<CharT, Traits>;

template <typename CharT, typename Traits = std::char_traits<CharT>>
std::string string_view_to_string(const basic_string_view<CharT, Traits>& v) {
    return v.to_string();
}

template <typename... Types>
using variant = boost::variant<Types...>;

template<typename U, typename... Types>
U& get(variant<Types...>& v) {
    return boost::get<U, Types...>(v);
}

template<typename U, typename... Types>
U&& get(variant<Types...>&& v) {
    return boost::get<U, Types...>(v);
}

template<typename U, typename... Types>
const U& get(const variant<Types...>& v) {
    return boost::get<U, Types...>(v);
}

template<typename U, typename... Types>
const U&& get(const variant<Types...>&& v) {
    return boost::get<U, Types...>(v);
}

template<typename U, typename... Types>
U* get_if(variant<Types...>* v) {
    return boost::get<U, Types...>(v);
}

template<typename U, typename... Types>
const U* get_if(const variant<Types...>* v) {
    return boost::get<U, Types...>(v);
}

#endif

#if defined(__cpp_lib_filesystem)
namespace filesystem = std::filesystem;
#elif defined(__cpp_lib_experimental_filesystem)
namespace filesystem = std::experimental::filesystem;
#else
#error No filesystem header detected.
#endif

using string_view = basic_string_view<char>;

} // namespace compat

/// \endcond

} // namespace seastar

ext: hh

max_stars_repo_name: elazarl/seastar

max_issues_repo_name: elazarl/seastar

max_forks_repo_name: elazarl/seastar


text:
/*=========================================================================

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
/*=========================================================================
  The Software is copyright (c) Commonwealth Scientific and Industrial Research Organisation (CSIRO)
  ABN 41 687 119 230.
  All rights reserved.

  Licensed under the CSIRO BSD 3-Clause License
  You may not use this file except in compliance with the License.
  You may obtain a copy of the License in the file LICENSE.md or at

  https://stash.csiro.au/projects/SMILI/repos/smili/browse/license.txt

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
=========================================================================*/
#include "vtkDiffusionTensorGlyphFilter.h"

#include <boost/math/special_functions/spherical_harmonic.hpp>

#include "vtkObjectFactory.h"
#include "vtkCell.h"
#include "vtkCellData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkUnsignedCharArray.h"
#include "vtkAppendPolyData.h"

vtkStandardNewMacro(vtkDiffusionTensorGlyphFilter);

vtkDiffusionTensorGlyphFilter::vtkDiffusionTensorGlyphFilter() : vtkProgrammableGlyphFilter()
{
  m_Resolution = 16;
}

vtkDiffusionTensorGlyphFilter::~vtkDiffusionTensorGlyphFilter()
{

}

double vtkDiffusionTensorGlyphFilter::computeAmplitude(std::vector<double> SH, double x, double y, double z, int lmax)
{
    double az = atan2(y, x);
    double el = acos(z);
    double val = 0.0;
    for (int l = 0; l <= lmax; l+=2)
    {
        // val += SH[vtkDiffusionTensorGlyphFilter::index(l,0)] * boost::math::legendre_p<double>(l, 0, z);
        val += SH[vtkDiffusionTensorGlyphFilter::index(l,0)] * boost::math::spherical_harmonic_r<double>(l, 0, el,az);
    }

    for (int m = 1; m <= lmax; m++)
    {
//        float caz = cos(m*az);
//        float saz = sin(m*az);
        for (int l = 2*((m+1)/2); l <= lmax; l+=2)
        {
        // float buf = boost::math::legendre_p<double>(l, 0, z);
        // val += SH[index(l,m)]*buf*caz;
        // val += SH[index(l,-m)]*buf*saz;
            val += SH[vtkDiffusionTensorGlyphFilter::index(l,m)]*boost::math::spherical_harmonic_r(l,m,el,az);
            val += SH[vtkDiffusionTensorGlyphFilter::index(l,-m)]*boost::math::spherical_harmonic_i(l,m,el,az);
        }
    }

    return val;
}

//Overide the vtkProgrammableGlyphFilter due to colouring not being unsigned char etc.
/*int vtkDiffusionTensorGlyphFilter::RequestData(
  vtkInformation *vtkNotUsed(request),
  vtkInformationVector **inputVector,
  vtkInformationVector *outputVector)
{
  // get the info objects
  vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
  vtkInformation *sourceInfo = inputVector[1]->GetInformationObject(0);
  vtkInformation *outInfo = outputVector->GetInformationObject(0);

  // get the input and output
  vtkDataSet *input = vtkDataSet::SafeDownCast(
    inInfo->Get(vtkDataObject::DATA_OBJECT()));
  vtkPolyData *source = vtkPolyData::SafeDownCast(
    sourceInfo->Get(vtkDataObject::DATA_OBJECT()));
  vtkPolyData *output = vtkPolyData::SafeDownCast(
    outInfo->Get(vtkDataObject::DATA_OBJECT()));

  vtkPointData *inputPD = input->GetPointData();
  vtkCellData *inputCD = input->GetCellData();
  vtkPointData *outputPD = output->GetPointData();
  vtkCellData *outputCD = output->GetCellData();
  vtkPoints *newPts, *sourcePts;
  vtkUnsignedCharArray *ptScalars=NULL, *cellScalars=NULL; //CHANGED
  vtkDataArray *inPtScalars = NULL, *inCellScalars = NULL;
  vtkIdType numPts = input->GetNumberOfPoints();
  vtkPointData *sourcePD;
  vtkCellData *sourceCD;
  vtkIdType numSourcePts, numSourceCells, ptOffset=0, cellId, ptId, id, idx;
  int i, npts;
  vtkIdList *pts;
  vtkIdList *cellPts;
  vtkCell *cell;

  // Initialize
  vtkDebugMacro(<<"Generating programmable glyphs!");
  std::cout << "Generating Diffusion programmable glyphs!" << std::endl;

  if ( numPts < 1 )
    {
    vtkErrorMacro(<<"No input points to glyph");
    }

  pts=vtkIdList::New();
  pts->Allocate(VTK_CELL_SIZE);
  sourcePD = source->GetPointData();
  sourceCD = source->GetCellData();
  numSourcePts = source->GetNumberOfPoints();
  numSourceCells = source->GetNumberOfCells();

  outputPD->CopyScalarsOff(); //'cause we control the coloring process
  outputCD->CopyScalarsOff();

  output->Allocate(numSourceCells*numPts,numSourceCells*numPts);
  outputPD->CopyAllocate(sourcePD, numSourcePts*numPts, numSourcePts*numPts); //causes float array allocation
  outputCD->CopyAllocate(sourceCD, numSourceCells*numPts, numSourceCells*numPts);
  newPts = vtkPoints::New();
  newPts->Allocate(numSourcePts*numPts);

  // figure out how to color the data and setup
  if ( this->ColorMode == VTK_COLOR_BY_INPUT )
    {
    if ( (inPtScalars = inputPD->GetScalars()) )
      {
      ptScalars = vtkUnsignedCharArray::New();
      ptScalars->SetNumberOfComponents(3); //CHANGED
      ptScalars->SetName("Colours");
      ptScalars->SetNumberOfTuples(numSourcePts*numPts);
      }
    if ( (inCellScalars = inputCD->GetScalars()) )
      {
      cellScalars = vtkUnsignedCharArray::New();
      cellScalars->SetNumberOfComponents(3); //CHANGED
      cellScalars->SetNumberOfTuples(numSourcePts*numPts);
      }
    }

  else
    {
    if ( sourcePD->GetScalars() )
      {
      ptScalars = vtkUnsignedCharArray::New();
      ptScalars->SetNumberOfComponents(3); //CHANGED
      ptScalars->SetName("Colours");
      ptScalars->SetNumberOfTuples(numSourcePts*numPts);
      }
    if ( sourceCD->GetScalars() )
      {
      cellScalars = vtkUnsignedCharArray::New();
      cellScalars->SetNumberOfComponents(3); //CHANGED
      cellScalars->SetNumberOfTuples(numSourcePts*numPts);
      }
    }

  // Loop over all points, invoking glyph method and Update(),
  // then append output of source to output of this filter.
  //
//  this->Updating = 1; // to prevent infinite recursion
  this->PointData = input->GetPointData();
  for (this->PointId=0; this->PointId < numPts; this->PointId++)
    {
    if ( ! (this->PointId % 10000) )
      {
      this->UpdateProgress ((double)this->PointId/numPts);
      if (this->GetAbortExecute())
        {
        break;
        }
      }

    input->GetPoint(this->PointId, this->Point);

    if ( this->GlyphMethod )
      {
      (*this->GlyphMethod)(this->GlyphMethodArg);

      // The GlyphMethod may have set the source connection to NULL
      if (this->GetNumberOfInputConnections(1) == 0)
        {
        source = NULL;
        }
      else
        {
        // Update the source connection in case the GlyphMethod changed
        // its parameters.
        this->GetInputAlgorithm(1, 0)->Update();
        // The GlyphMethod may also have changed the source.
        sourceInfo = inputVector[1]->GetInformationObject(0);
        source = vtkPolyData::SafeDownCast(
          sourceInfo->Get(vtkDataObject::DATA_OBJECT()));
        }
      }
    if (source)
      {
      sourcePts = source->GetPoints();
      numSourcePts = source->GetNumberOfPoints();
      numSourceCells = source->GetNumberOfCells();
      sourcePD = source->GetPointData();
      sourceCD = source->GetCellData();

      if ( this->ColorMode == VTK_COLOR_BY_SOURCE )
        {
        inPtScalars = sourcePD->GetScalars();
        inCellScalars = sourceCD->GetScalars();
        }

      // Copy all data from source to output.
      for (ptId=0; ptId < numSourcePts; ptId++)
        {
        id = newPts->InsertNextPoint(sourcePts->GetPoint(ptId));
        outputPD->CopyData(sourcePD, ptId, id);
        }

      for (cellId=0; cellId < numSourceCells; cellId++)
        {
        cell = source->GetCell(cellId);
        cellPts = cell->GetPointIds();
        npts = cellPts->GetNumberOfIds();
        for (pts->Reset(), i=0; i < npts; i++)
          {
          pts->InsertId(i,cellPts->GetId(i) + ptOffset);
          }
        id = output->InsertNextCell(cell->GetCellType(),pts);
        outputCD->CopyData(sourceCD, cellId, id);
        }

      // If we're coloring the output with scalars, do that now
      if ( ptScalars )
        {
        for (ptId=0; ptId < numSourcePts; ptId++)
          {
          idx = (this->ColorMode == VTK_COLOR_BY_INPUT ? this->PointId : ptId);
          unsigned char colourOfPoint[3] = {0, 0, 0};
          colourOfPoint[0] = static_cast<unsigned char>( inPtScalars->GetComponent(idx, 0) );
          colourOfPoint[1] = static_cast<unsigned char>( inPtScalars->GetComponent(idx, 1) );
          colourOfPoint[2] = static_cast<unsigned char>( inPtScalars->GetComponent(idx, 2) );
          ptScalars->InsertNextTupleValue(colourOfPoint); //CHANGED
          }
        }
      else if ( cellScalars )
        {
        for (cellId=0; cellId < numSourceCells; cellId++)
          {
          idx = (this->ColorMode == VTK_COLOR_BY_INPUT ? this->PointId : cellId);
          unsigned char colourOfCell[3] = {0, 0, 0};
          colourOfCell[0] = static_cast<unsigned char>( inCellScalars->GetComponent(idx, 0) );
          colourOfCell[1] = static_cast<unsigned char>( inCellScalars->GetComponent(idx, 1) );
          colourOfCell[2] = static_cast<unsigned char>( inCellScalars->GetComponent(idx, 2) );
          cellScalars->InsertNextTupleValue(colourOfCell); //CHANGED
          }
        }

      ptOffset += numSourcePts;

      }//if a source is available
    } //for all input points

//  this->Updating = 0;

  pts->Delete();

  output->SetPoints(newPts);
  newPts->Delete();

  if ( ptScalars )
    {
    idx = outputPD->AddArray(ptScalars);
    outputPD->SetActiveAttribute(idx, vtkDataSetAttributes::SCALARS);
    ptScalars->Delete();
    }

  if ( cellScalars )
    {
    idx = outputCD->AddArray(cellScalars);
    outputCD->SetActiveAttribute(idx, vtkDataSetAttributes::SCALARS);
    cellScalars->Delete();
    }

  output->Squeeze();

  return 1;
}*/
int vtkDiffusionTensorGlyphFilter::RequestData(
  vtkInformation *vtkNotUsed(request),
  vtkInformationVector **inputVector,
  vtkInformationVector *outputVector)
{
  // get the info objects
  vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
  vtkInformation *sourceInfo = inputVector[1]->GetInformationObject(0);
  vtkInformation *outInfo = outputVector->GetInformationObject(0);

  // get the input and output
  vtkDataSet *input = vtkDataSet::SafeDownCast(
    inInfo->Get(vtkDataObject::DATA_OBJECT()));
  vtkPolyData *source = vtkPolyData::SafeDownCast(
    sourceInfo->Get(vtkDataObject::DATA_OBJECT()));
  vtkPolyData *output = vtkPolyData::SafeDownCast(
    outInfo->Get(vtkDataObject::DATA_OBJECT()));

  vtkPointData *inputPD = input->GetPointData();
  vtkCellData *inputCD = input->GetCellData();
  vtkIdType numPts = input->GetNumberOfPoints();
  vtkPointData *sourcePD;
  vtkCellData *sourceCD;
  vtkIdType numSourcePts, numSourceCells, ptOffset=0, cellId, ptId, id, idx;

  vtkSmartPointer<vtkAppendPolyData> appendedOutput = vtkSmartPointer<vtkAppendPolyData>::New();
  #if VTK_MAJOR_VERSION <= 5
    appendedOutput->AddInput(output);
  #else
    appendedOutput->AddInputData(output);
  #endif

  // Initialize
  vtkDebugMacro(<<"Generating programmable glyphs!");

  if ( numPts < 1 )
    {
    vtkErrorMacro(<<"No input points to glyph");
    }

  sourcePD = source->GetPointData();
  sourceCD = source->GetCellData();
  numSourcePts = source->GetNumberOfPoints();
  numSourceCells = source->GetNumberOfCells();

  // Loop over all points, invoking glyph method and Update(),
  // then append output of source to output of this filter.
  //
//  this->Updating = 1; // to prevent infinite recursion
  this->PointData = input->GetPointData();
  for (this->PointId=0; this->PointId < numPts; this->PointId++)
    {
    if ( ! (this->PointId % 10000) )
      {
      this->UpdateProgress (static_cast<long double>(this->PointId)/numPts);
      if (this->GetAbortExecute())
        {
        break;
        }
      }

    input->GetPoint(this->PointId, this->Point);

    if ( this->GlyphMethod )
      {
      (*this->GlyphMethod)(this->GlyphMethodArg);

    #if VTK_MAJOR_VERSION > 5
      // The GlyphMethod may have set the source connection to NULL
      if (this->GetNumberOfInputConnections(1) == 0)
        {
        source = NULL;
        }
      else
        {
        // Update the source connection in case the GlyphMethod changed
        // its parameters.
        this->GetInputAlgorithm(1, 0)->Update();
        // The GlyphMethod may also have changed the source.
        sourceInfo = inputVector[1]->GetInformationObject(0);
        source = vtkPolyData::SafeDownCast(
          sourceInfo->Get(vtkDataObject::DATA_OBJECT()));
        }
    #endif
      }
    if (source)
      {
      numSourcePts = source->GetNumberOfPoints();
      numSourceCells = source->GetNumberOfCells();
      sourcePD = source->GetPointData();
      sourceCD = source->GetCellData();

      #if VTK_MAJOR_VERSION <= 5
        appendedOutput->AddInput(source);
      #else
        appendedOutput->AddInputData(source);
      #endif

      ptOffset += numSourcePts;
      }//if a source is available
    } //for all input points

//  this->Updating = 0;
  appendedOutput->Update();
  this->UpdateProgress(100);
  output->DeepCopy(appendedOutput->GetOutput());
  output->Squeeze();

  return 1;
}

void vtkDiffusionTensorGlyphFilter::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os,indent);

  os << indent << "Color Mode: " << this->GetColorModeAsString() << endl;
  os << indent << "Point Id: " << this->PointId << "\n";
  os << indent << "Point: " << this->Point[0]
                    << ", " << this->Point[1]
                    << ", " << this->Point[2] << "\n";
  if (this->PointData)
    {
    os << indent << "PointData: " << this->PointData << "\n";
    }
  else
    {
    os << indent << "PointData: (not defined)\n";
    }

  if ( this->GlyphMethod )
    {
    os << indent << "Glyph Method defined\n";
    }
  else
    {
    os << indent << "No Glyph Method\n";
    }
}

ext: cxx

max_stars_repo_name: aneube/smili-spine

max_issues_repo_name: aneube/smili-spine

max_forks_repo_name: aneube/smili-spine


text:
/* Copyright (c) 2017, Waterloo Autonomous Vehicles Laboratory (WAVELab),
 * Waterloo Intelligent Systems Engineering Lab (WISELab),
 * University of Waterloo.
 *
 * Refer to the accompanying LICENSE file for license information.
 *
 * ############################################################################
 ******************************************************************************
 |                                                                            |
 |                         /\/\__/\_/\      /\_/\__/\/\                       |
 |                         \          \____/          /                       |
 |                          '----________________----'                        |
 |                              /                \                            |
 |                            O/_____/_______/____\O                          |
 |                            /____________________\                          |
 |                           /    (#UNIVERSITY#)    \                         |
 |                           |[**](#OFWATERLOO#)[**]|                         |
 |                           \______________________/                         |
 |                            |_""__|_,----,_|__""_|                          |
 |                            ! !                ! !                          |
 |                            '-'                '-'                          |
 |       __    _   _  _____  ___  __  _  ___  _    _  ___  ___   ____  ____   |
 |      /  \  | | | ||_   _|/ _ \|  \| |/ _ \| \  / |/ _ \/ _ \ /     |       |
 |     / /\ \ | |_| |  | |  ||_||| |\  |||_|||  \/  |||_||||_|| \===\ |====   |
 |    /_/  \_\|_____|  |_|  \___/|_| \_|\___/|_|\/|_|\___/\___/ ____/ |____   |
 |                                                                            |
 ******************************************************************************
 * ############################################################################
 *
 * File: world_frame_conversions.cpp
 * Desc: Implementation file for world frame conversion functions
 * Auth: Michael Smart <michael.smart@uwaterloo.ca>
 *
 * ############################################################################
*/

#include <Eigen/Core>
#include "wave/geography/world_frame_conversions.hpp"

namespace wave {

void ecefPointFromLLH(const double llh[3], double ecef[3]) {
    double latitude = llh[0], longitude = llh[1], height = llh[2];

    GeographicLib::Geocentric earth = GeographicLib::Geocentric::WGS84();

    double X, Y, Z;
    earth.Forward(latitude, longitude, height, X, Y, Z);

    ecef[0] = X;
    ecef[1] = Y;
    ecef[2] = Z;
}

void llhPointFromECEF(const double ecef[3], double llh[3]) {
    double X = ecef[0], Y = ecef[1], Z = ecef[2];

    GeographicLib::Geocentric earth = GeographicLib::Geocentric::WGS84();

    double latitude, longitude, height;
    earth.Reverse(X, Y, Z, latitude, longitude, height);

    llh[0] = latitude;
    llh[1] = longitude;
    llh[2] = height;
}

void ecefFromENUTransformMatrix(const double datum[3],
                                double T_ecef_enu[4][4],
                                bool datum_is_llh) {
    // Both Forward() and Reverse() return the same rotation matrix from ENU
    // to ECEF
    std::vector<double> R_ecef_enu(9, 0.0);
    GeographicLib::Geocentric earth = GeographicLib::Geocentric::WGS84();
    double datum_X, datum_Y, datum_Z;

    if (datum_is_llh) {
        double latitude = datum[0], longitude = datum[1], height = datum[2];

        earth.Forward(
          latitude, longitude, height, datum_X, datum_Y, datum_Z, R_ecef_enu);
    } else {
        // Datum is already given in ECEF
        datum_X = datum[0];
        datum_Y = datum[1];
        datum_Z = datum[2];

        double latitude, longitude, height;
        earth.Reverse(
          datum_X, datum_Y, datum_Z, latitude, longitude, height, R_ecef_enu);
    }

    T_ecef_enu[0][0] = R_ecef_enu[0];
    T_ecef_enu[0][1] = R_ecef_enu[1];
    T_ecef_enu[0][2] = R_ecef_enu[2];
    T_ecef_enu[0][3] = datum_X;
    T_ecef_enu[1][0] = R_ecef_enu[3];
    T_ecef_enu[1][1] = R_ecef_enu[4];
    T_ecef_enu[1][2] = R_ecef_enu[5];
    T_ecef_enu[1][3] = datum_Y;
    T_ecef_enu[2][0] = R_ecef_enu[6];
    T_ecef_enu[2][1] = R_ecef_enu[7];
    T_ecef_enu[2][2] = R_ecef_enu[8];
    T_ecef_enu[2][3] = datum_Z;
    T_ecef_enu[3][0] = 0.0;
    T_ecef_enu[3][1] = 0.0;
    T_ecef_enu[3][2] = 0.0;
    T_ecef_enu[3][3] = 1.0;
}

void enuFromECEFTransformMatrix(const double datum[3],
                                double T_enu_ecef[4][4],
                                bool datum_is_llh) {
    // Get T_ecef_enu and then invert it
    double T_ecef_enu[4][4];
    ecefFromENUTransformMatrix(datum, T_ecef_enu, datum_is_llh);

    // Affine inverse: [R | t]^(-1) = [ R^T | - R^T * t]
    // TODO(msmart/benskikos) - Move these functions to somewhere where we have
    // matrix classes and ownership since it is ours. Manual transposition is
    // undesirable. The below should be 2 lines:
    // R_new = R.transpose(); t_new = - R.transpose()*t;
    T_enu_ecef[0][0] = T_ecef_enu[0][0];
    T_enu_ecef[0][1] = T_ecef_enu[1][0];
    T_enu_ecef[0][2] = T_ecef_enu[2][0];
    T_enu_ecef[1][0] = T_ecef_enu[0][1];
    T_enu_ecef[1][1] = T_ecef_enu[1][1];
    T_enu_ecef[1][2] = T_ecef_enu[2][1];
    T_enu_ecef[2][0] = T_ecef_enu[0][2];
    T_enu_ecef[2][1] = T_ecef_enu[1][2];
    T_enu_ecef[2][2] = T_ecef_enu[2][2];

    // Affine inverse translation component: -R_inverse * b
    //    with b as the 4th column of T_ecef_enu
    T_enu_ecef[0][3] = -T_enu_ecef[0][0] * T_ecef_enu[0][3]    //
                       - T_enu_ecef[0][1] * T_ecef_enu[1][3]   //
                       - T_enu_ecef[0][2] * T_ecef_enu[2][3];  //

    T_enu_ecef[1][3] = -T_enu_ecef[1][0] * T_ecef_enu[0][3]    //
                       - T_enu_ecef[1][1] * T_ecef_enu[1][3]   //
                       - T_enu_ecef[1][2] * T_ecef_enu[2][3];  //

    T_enu_ecef[2][3] = -T_enu_ecef[2][0] * T_ecef_enu[0][3]    //
                       - T_enu_ecef[2][1] * T_ecef_enu[1][3]   //
                       - T_enu_ecef[2][2] * T_ecef_enu[2][3];  //

    // Last row is the same
    T_enu_ecef[3][0] = 0.0;
    T_enu_ecef[3][1] = 0.0;
    T_enu_ecef[3][2] = 0.0;
    T_enu_ecef[3][3] = 1.0;
}

void enuPointFromLLH(const double point_llh[3],
                     const double enu_datum[3],
                     double point_enu[3],
                     bool datum_is_llh) {
    double enu_datum_llh[3];
    if (datum_is_llh) {
        enu_datum_llh[0] = enu_datum[0];
        enu_datum_llh[1] = enu_datum[1];
        enu_datum_llh[2] = enu_datum[2];
    } else {
        // Datum is ECEF
        llhPointFromECEF(enu_datum, enu_datum_llh);
    }

    GeographicLib::Geocentric earth = GeographicLib::Geocentric::WGS84();
    GeographicLib::LocalCartesian localENU(
      enu_datum_llh[0], enu_datum_llh[1], enu_datum_llh[2], earth);

    localENU.Forward(point_llh[0],
                     point_llh[1],
                     point_llh[2],
                     point_enu[0],
                     point_enu[1],
                     point_enu[2]);
}

void llhPointFromENU(const double point_enu[3],
                     const double enu_datum[3],
                     double point_llh[3],
                     bool datum_is_llh) {
    double enu_datum_llh[3];
    if (datum_is_llh) {
        enu_datum_llh[0] = enu_datum[0];
        enu_datum_llh[1] = enu_datum[1];
        enu_datum_llh[2] = enu_datum[2];
    } else {
        // Datum is ECEF
        llhPointFromECEF(enu_datum, enu_datum_llh);
    }

    GeographicLib::Geocentric earth = GeographicLib::Geocentric::WGS84();
    GeographicLib::LocalCartesian localENU(
      enu_datum_llh[0], enu_datum_llh[1], enu_datum_llh[2], earth);

    localENU.Reverse(point_enu[0],
                     point_enu[1],
                     point_enu[2],
                     point_llh[0],
                     point_llh[1],
                     point_llh[2]);
}

}  // namespace wave

ext: cpp

max_stars_repo_name: wavelab/wavelib

max_issues_repo_name: wavelab/wavelib

max_forks_repo_name: wavelab/wavelib


text:
/*
 * @name BookFiler Module - HTTP
 * @author Branden Lee
 * @version 1.00
 * @license MIT
 * @brief HTTP module for BookFiler™ applications.
 */

#ifndef BOOKFILER_MODULE_HTTP_HTTP_SERVER_H
#define BOOKFILER_MODULE_HTTP_HTTP_SERVER_H

// config
#include "config.hpp"

// C++17
//#include <filesystem>
#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <map>
#include <utility>
#include <vector>

/* rapidjson v1.1 (2016-8-25)
 * Developed by Tencent
 * License: MITs
 */
#include <rapidjson/document.h>
#include <rapidjson/filewritestream.h>
#include <rapidjson/ostreamwrapper.h>
#include <rapidjson/reader.h> // rapidjson::ParseResult
#include <rapidjson/stringbuffer.h>
#include <rapidjson/writer.h>

/* boost 1.72.0
 * License: Boost Software License (similar to BSD and MIT)
 */
#include <boost/config.hpp>

// Local Project
#include "certificateManager.hpp"
#include "ServerListener.hpp"

namespace beast = boost::beast;   // from <boost/beast.hpp>
namespace http = beast::http;     // from <boost/beast/http.hpp>
namespace net = boost::asio;      // from <boost/asio.hpp>
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>

/*
 * bookfiler - HTTP
 */
namespace bookfiler {
namespace HTTP {

class ServerImpl : public Server {
private:
  std::shared_ptr<rapidjson::Value> settingsDoc;
  std::shared_ptr<ServerState> serverState;
  std::shared_ptr<boost::asio::io_context> ioContext;
  std::shared_ptr<boost::asio::ssl::context> sslContext;
  std::shared_ptr<Listener> listener;
  std::vector<std::thread> threadList;
  std::shared_ptr<RouteImpl> routePtr;

public:
  ServerImpl();
  ~ServerImpl();
  int setSettingsDoc(std::shared_ptr<rapidjson::Value>);
  int run();
  void runIoContext();
  int extractSettings();
  int useCertificate(std::shared_ptr<bookfiler::certificate::Certificate>);
  int route(std::map<std::string, routeVariantTypeExternal> map_);
};

} // namespace HTTP
} // namespace bookfiler

#endif
// end BOOKFILER_MODULE_MYSQL_HTTP_H

max_stars_repo_name: bradosia/BookFiler-Module-HTTP-Curl

max_issues_repo_name: bradosia/BookFiler-Module-HTTP-Curl

max_forks_repo_name: bradosia/BookFiler-Module-HTTP-Curl


text:
/*
 * common.h
 *
 *  Created on: Oct 15, 2012
 *      Author: Kamal Sharma
 */

#ifndef COMMON_H_
#define COMMON_H_

#include <iostream>
#include <ostream>
#include <fstream>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>

using namespace std;

#define foreach BOOST_FOREACH

extern std::ostream *tracePtr;
#define trace (*tracePtr)
#define traceerror (std::cerr)

namespace FieldTypes {
enum TYPE {
	INT, FLOAT, DOUBLE, UNKNOWN
};
}

namespace CompilerTypes {
enum TYPE {
	UNKNOWN, GCC, ICC, XLC, PGI
};
}

namespace AccessTypes {
enum TYPE {
	READ, WRITE, READWRITE
};
}

#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif

#endif /* COMMON_H_ */

max_stars_repo_name: maurizioabba/rose

max_issues_repo_name: sujankh/rose-matlab

max_forks_repo_name: sujankh/rose-matlab


text:
// Copyright (c) 2015 - 2016 Anyar, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "ascent/io/ChaiEngine.h"

#include <chaiscript/chaiscript_stdlib.hpp>

#include "ascent/core/LinkBase.h"
#include "ascent/Link.h"
#include "ascent/core/ModuleCore.h"

#include <Eigen/Dense>

using namespace asc;
using namespace chaiscript;

template <typename E>
void assign(E& lhs, const E& rhs) { lhs = rhs; }

template <typename E>
E cross(const E& lhs, const E& rhs) { return lhs.cross(rhs); }

template <typename E>
double dot(const E& lhs, const E& rhs) { return lhs.dot(rhs); }

template <typename LHS, typename E>
E timesL(const LHS& lhs, const E& rhs) { return lhs*rhs; }

template <typename E, typename RHS>
E timesR(const E& lhs, const RHS& rhs) { return lhs*rhs; }

std::shared_ptr<asc::Module> linkBaseModule(asc::LinkBase& link_base)
{
   return asc::ModuleCore::getModule(link_base.linkedModule().second).shared_from_this();
}

ChaiEngine::ChaiEngine() : ChaiScript(Std_Lib::library())
{
   add(base_class<asc::LinkBase, asc::Link<asc::Module>>());
   add(fun(static_cast<std::shared_ptr<asc::Module>(asc::Link<asc::Module>::*)>(&asc::Link<asc::Module>::module)), "module");
   add(fun(&linkBaseModule), "module");

   add(fun(static_cast<const size_t(asc::Module::*)>(&asc::Module::module_id)), "module_id");

   add(fun([](const size_t id) -> asc::Module& { return asc::ModuleCore::getModule(id); }), "getModule");

   add(fun(static_cast<bool(asc::Link<asc::Module>::*)(const std::string&)>(&asc::Link<asc::Module>::name)), "name");

   add(fun(&asc::hidden::assignModule), "=");
   add(fun(&asc::hidden::assignLinkBase), "=");

   // Register Eigen matrix/vector types
   add(constructor<Eigen::Vector2d(const double x0, const double x1)>(), "Vector2d");
   add(constructor<Eigen::Vector2d(const Eigen::Vector2d&)>(), "Vector2d");
   add(fun(&assign<Eigen::Vector2d>), "=");
   add(fun(&timesL<double, Eigen::Vector2d>), "*");
   add(fun(&timesR<Eigen::Vector2d, double>), "*");
   add(fun(&dot<Eigen::Vector2d>), "dot");

   add(constructor<Eigen::Vector3d(const double x0, const double x1, const double x2)>(), "Vector3d");
   add(constructor<Eigen::Vector3d(const Eigen::Vector3d&)>(), "Vector3d");
   add(fun(&assign<Eigen::Vector3d>), "=");
   add(fun(&timesL<double, Eigen::Vector3d>), "*");
   add(fun(&timesR<Eigen::Vector3d, double>), "*");
   add(fun(&dot<Eigen::Vector3d>), "dot");
   add(fun(&cross<Eigen::Vector3d>), "cross");

   add(constructor<Eigen::Vector4d(const double x0, const double x1, const double x2, const double x3)>(), "Vector4d");
   add(constructor<Eigen::Vector4d(const Eigen::Vector4d&)>(), "Vector4d");
   add(fun(&assign<Eigen::Vector4d>), "=");
   add(fun(&timesL<double, Eigen::Vector4d>), "*");
   add(fun(&timesR<Eigen::Vector4d, double>), "*");
   add(fun(&dot<Eigen::Vector4d>), "dot");

   add(fun(&assign<Eigen::VectorXd>), "=");
   add(fun(&timesL<double, Eigen::VectorXd>), "*");
   add(fun(&timesR<Eigen::VectorXd, double>), "*");
   add(fun(&dot<Eigen::VectorXd>), "dot");

   add(fun(&assign<Eigen::MatrixXd>), "=");
   add(fun(&timesL<double, Eigen::MatrixXd>), "*");
   add(fun(&timesL<Eigen::VectorXd, Eigen::MatrixXd>), "*");
   add(fun(&timesR<Eigen::MatrixXd, double>), "*");
   add(fun(&timesR<Eigen::MatrixXd, Eigen::VectorXd>), "*");
}

bool ChaiEngine::registered(const std::string& module, const std::string& var)
{
   if (!chai_rg.count(module))
      return false;

   std::vector<std::string>& names = chai_rg[module];

   for (auto& name : names)
   {
      if (name == var)
         return true;
   }

   return false;
}

max_stars_repo_name: AnyarInc/ascent-beta

max_issues_repo_name: AnyarInc/ascent-beta

max_forks_repo_name: AnyarInc/ascent-beta


text:
// Copyright (c) 2019 Graphcore Ltd. All rights reserved.
#define BOOST_TEST_MODULE PipelineTrainingTest0

#include <boost/test/unit_test.hpp>
#include <filereader.hpp>
#include <popart/builder.hpp>
#include <popart/dataflow.hpp>
#include <popart/devicemanager.hpp>
#include <popart/inputshapeinfo.hpp>
#include <popart/ndarraywrapper.hpp>
#include <popart/op/identity.hpp>
#include <popart/op/l1.hpp>
#include <popart/session.hpp>
#include <popart/sgd.hpp>
#include <popart/tensorinfo.hpp>
#include <popart/tensornames.hpp>
#include <popart/testdevice.hpp>

#include <algorithm>
#include <map>
#include <random>
#include <tuple>
#include <vector>

// We set weights as anchors, and verify that the returned values are sensible,
// agree with calls to readWeights()
//
BOOST_AUTO_TEST_CASE(WeightAnchorTest0) {

  using namespace popart;

  auto builder     = Builder::create();
  auto aiOnnx      = builder->aiOnnxOpset9();
  auto aiGraphcore = builder->aiGraphcoreOpset1();

  // accumulationFactor = replicationFactor = 1 in this example, so
  // batchSize = microBatchSize

  // samples in batch  (samples per weight update)
  int64_t batchSize = 4;

  // batches in a step (processed with each call to run(...))
  int64_t batchesPerStep = 100;

  // the number of weight update steps is batchesPerStep = 100
  // the number of samples in a step is batchesPerStep * batchSize = 400

  std::vector<int64_t> sampleShape{1, 1};

  // in this test, weights are of the same shape as data samples
  std::vector<int64_t> weightShape = sampleShape;

  // shape of a batch
  std::vector<int64_t> batchShape{batchSize, 1, 1};
  std::vector<int64_t> stepDataShape{batchesPerStep, batchSize, 1, 1};

  // When  weights are anchors (of ReturnType ALL), the the number of weights
  // that are returned will be batchesPerStep * accumulationFactor (probably,
  // see T10052)
  std::vector<int64_t> stepWeightShape{batchesPerStep, 1, 1};

  TensorInfo sampleInfo{"FLOAT", sampleShape};
  TensorInfo weightInfo = sampleInfo;
  TensorInfo batchInfo{"FLOAT", batchShape};
  TensorInfo stepDataInfo{"FLOAT", stepDataShape};
  TensorInfo stepWeightInfo{"FLOAT", stepWeightShape};

  int64_t sampleElms{1};
  int64_t batchElms      = sampleElms * batchSize;
  int64_t stepWeightElms = sampleElms * batchesPerStep;
  int64_t stepDataElms   = batchElms * batchesPerStep;

  auto input1 = builder->addInputTensor(batchInfo, "tupni");

  //
  // The model : A series of additions of a Weight, and scaling by 0.5
  //
  std::vector<float> w0Vals(sampleElms, 1.0f);
  ConstVoidData w0Data = {w0Vals.data(), sampleInfo};
  auto w0              = builder->addInitializedInputTensor(w0Data);
  auto act0            = aiOnnx.add({w0, input1}, "act0");
  act0                 = aiGraphcore.scale({act0}, 0.5);

  std::vector<float> w1Vals(sampleElms, 1.0f);
  ConstVoidData w1Data = {w1Vals.data(), sampleInfo};
  auto w1              = builder->addInitializedInputTensor(w1Data);
  auto act1            = aiOnnx.add({w1, act0}, "act1");
  act1                 = aiGraphcore.scale({act1}, 0.5);

  std::vector<float> w2Vals(sampleElms, 1.0f);
  ConstVoidData w2Data = {w2Vals.data(), sampleInfo};
  auto w2              = builder->addInitializedInputTensor(w2Data);
  auto act2            = aiOnnx.add({w2, act1}, "act2");
  act2                 = aiGraphcore.scale({act2}, 0.5);

  std::vector<float> w3Vals(sampleElms, 1.0f);
  ConstVoidData w3Data = {w3Vals.data(), sampleInfo};
  auto w3              = builder->addInitializedInputTensor(w3Data);
  auto act3            = aiOnnx.add({w3, act2}, "act3");
  act3                 = aiGraphcore.scale({act3}, 0.5);

  std::vector<float> w4Vals(sampleElms, 1.0f);
  ConstVoidData w4Data = {w4Vals.data(), sampleInfo};
  auto w4              = builder->addInitializedInputTensor(w4Data);
  auto act4            = aiOnnx.add({w4, act3}, "act4");
  act4                 = aiGraphcore.scale({act4}, 0.5);

  std::vector<float> w5Vals(sampleElms, 1.0f);
  ConstVoidData w5Data = {w5Vals.data(), sampleInfo};
  auto w5              = builder->addInitializedInputTensor(w5Data);
  auto act5            = aiOnnx.add({w5, act4}, "act5");
  act5                 = aiGraphcore.scale({act5}, 0.5);

  auto l1 = builder->aiGraphcoreOpset1().l1loss({act5}, 0.1);

  auto proto = builder->getModelProto();

  // Setting anchors as act5 and a bunch of weights
  //
  auto dataFlow = DataFlow(batchesPerStep,
                           {{act5, AnchorReturnType("All")},
                            {w1, AnchorReturnType("All")},
                            {w2, AnchorReturnType("All")},
                            {w3, AnchorReturnType("All")},
                            {w4, AnchorReturnType("All")},
                            {w5, AnchorReturnType("All")}});

  // shard over 3 IPUs
  //
  SessionOptions userOptions;
  userOptions.virtualGraphMode = VirtualGraphMode::Auto;

  auto optimizer = ConstSGD(0.01);

  auto device = createTestDevice(TEST_TARGET, 3);

  auto session = popart::TrainingSession::createFromOnnxModel(
      proto,
      dataFlow,
      l1,
      optimizer,
      device,
      InputShapeInfo(),
      userOptions,
      popart::Patterns(PatternsLevel::Default));

  session->prepareDevice();

  // All 400 samples are [[1.0f]]
  std::vector<float> v_input_0(stepDataElms, 1.0f);
  popart::NDArrayWrapper<float> input1_wrapper(v_input_0.data(), stepDataInfo);
  std::map<popart::TensorId, popart::IArray &> inputs = {
      {input1, input1_wrapper}};

  // Preparing the anchors.
  std::vector<float> v_act5_out(stepDataElms);
  popart::NDArrayWrapper<float> act5_wrapper(v_act5_out.data(), stepDataShape);

  // Note the size of the buffer we'll write to for weight anchors is
  // independent of batch-size. It is number of micro-batches (= number of
  // batches) * weight size (see T10052)
  std::vector<float> v_w1_out(stepWeightElms, -77.0f);
  popart::NDArrayWrapper<float> w1_wrapper(v_w1_out.data(), stepWeightShape);

  std::vector<float> v_w2_out(stepWeightElms, -77.0f);
  popart::NDArrayWrapper<float> w2_wrapper(v_w2_out.data(), stepWeightShape);

  std::vector<float> v_w3_out(stepWeightElms, -77.0f);
  popart::NDArrayWrapper<float> w3_wrapper(v_w3_out.data(), stepWeightShape);

  std::vector<float> v_w4_out(stepWeightElms, -77.0f);
  popart::NDArrayWrapper<float> w4_wrapper(v_w4_out.data(), stepWeightShape);

  std::vector<float> v_w5_out(stepWeightElms, -77.0f);
  popart::NDArrayWrapper<float> w5_wrapper(v_w5_out.data(), stepWeightShape);

  std::map<popart::TensorId, popart::IArray &> anchors = {{act5, act5_wrapper},
                                                          {w1, w1_wrapper},
                                                          {w2, w2_wrapper},
                                                          {w3, w3_wrapper},
                                                          {w4, w4_wrapper},
                                                          {w5, w5_wrapper}};

  WeightsIO weightsRead;
  std::vector<float> w0_readback(weightInfo.nelms(), -99.0f);
  std::vector<float> w1_readback(weightInfo.nelms(), -99.0f);
  std::vector<float> w2_readback(weightInfo.nelms(), -99.0f);
  std::vector<float> w3_readback(weightInfo.nelms(), -99.0f);
  std::vector<float> w4_readback(weightInfo.nelms(), -99.0f);
  std::vector<float> w5_readback(weightInfo.nelms(), -99.0f);
  weightsRead.insert(w0, {w0_readback.data(), weightInfo});
  weightsRead.insert(w1, {w1_readback.data(), weightInfo});
  weightsRead.insert(w2, {w2_readback.data(), weightInfo});
  weightsRead.insert(w3, {w3_readback.data(), weightInfo});
  weightsRead.insert(w4, {w4_readback.data(), weightInfo});
  weightsRead.insert(w5, {w5_readback.data(), weightInfo});

  // write initial weights to host
  session->weightsFromHost();

  // read final weights back
  session->weightsToHost();
  session->readWeights(weightsRead);

  // write followed by immediate read : read back initializer values
  std::cout << "Testing that immediately read back initializer vals are correct"
            << std::endl;
  BOOST_CHECK(w0_readback.back() == w0Vals.back());
  BOOST_CHECK(w1_readback.back() == w1Vals.back());
  BOOST_CHECK(w2_readback.back() == w2Vals.back());
  BOOST_CHECK(w3_readback.back() == w3Vals.back());
  BOOST_CHECK(w4_readback.back() == w4Vals.back());
  BOOST_CHECK(w5_readback.back() == w5Vals.back());

  for (int i = 0; i < 3; ++i) {
    std::cout << "Iteration (call to run(...)) # " << i << std::endl;

    // we will use the same data (inputs) for every step
    popart::StepIO stepio(inputs, anchors);

    // process the 400 samples (100 batches), streaming back anchors each batch
    session->run(stepio);

    // read final weights back
    session->weightsToHost();
    session->readWeights(weightsRead);

    std::cout << "Testing that final (weight) anchors are the same as values "
                 "from readWeights()"
              << std::endl;

    BOOST_CHECK(w1_readback.back() == v_w1_out.back());
    BOOST_CHECK(w2_readback.back() == v_w2_out.back());
    BOOST_CHECK(w3_readback.back() == v_w3_out.back());
    BOOST_CHECK(w4_readback.back() == v_w4_out.back());
    BOOST_CHECK(w5_readback.back() == v_w5_out.back());

    std::cout << "all the w1 anchor returns" << std::endl;
    for (auto x : v_w1_out) {
      std::cout << x << "  ";
    }
    std::cout << std::endl;
  }
}


text:
/**

\file
\author Datta Ramadasan
//==============================================================================
//         Copyright 2015 INSTITUT PASCAL UMR 6602 CNRS/Univ. Clermont II
//
//          Distributed under the Boost Software License, Version 1.0.
//                 See accompanying file LICENSE.txt or copy at
//                     http://www.boost.org/LICENSE_1_0.txt
//==============================================================================

*/

#ifndef __OPTIMISATION2_CONTAINER_EIGEN_HPP__
#define __OPTIMISATION2_CONTAINER_EIGEN_HPP__

#include "tag.hpp"
#include <Eigen/Dense>
// #include <Eigen/SparseCholesky>
#include <libv/lma/lm/trait/accessor.hpp>
#include <libv/lma/lm/trait/adl.hpp>
#include <libv/lma/ttt/traits/naming.hpp>
#include <libv/lma/ttt/traits/wrap.hpp>
#include <libv/lma/string/string_utiliy.hpp>
#include <boost/fusion/include/pair.hpp>
#include "residual.hpp"
#include <libv/lma/lm/container/container.hpp>

namespace std
{
  template<int I, int J, int N, int M, class Float> inline const Float& get(const Eigen::Matrix<Float,N,M>& mat)
  {
    static_assert( I < N , "std::get<I>(eigen)");
    static_assert( J < M , "std::get<I>(eigen)");
    return mat(I,J);
  }

  template<int I, int J, int N, class Float> inline const Float& get(const Eigen::Matrix<Float,I,1>& mat)
  {
    static_assert( I < N , "std::get<I,J>(toon)");
    static_assert( J == 0 , "std::get<I,J>(toon)");
    return mat[I];
  }

  template<int I, int N, class Float> inline const Float& get(const Eigen::Matrix<Float,N,1>& mat)
  {
    static_assert( I < N , "std::get<I,J>(toon)");
    return mat[I];
  }

  template<int I, int J, int N, int M, class Float> inline Float& get(Eigen::Matrix<Float,N,M>& mat)
  {
    static_assert( I < N , "std::get<I>(eigen)");
    static_assert( J < M , "std::get<J>(eigen)");
    return mat(I,J);
  }

  template<int I, int J, int N, class Float> inline Float& get(Eigen::Matrix<Float,I,1>& mat)
  {
    static_assert( I < N , "std::get<I,J>(toon)");
    static_assert( J == 0 , "std::get<I,J>(toon)");
    return mat[I];
  }
}

namespace lma
{
  template<std::size_t I, std::size_t J, class flt> struct ContainerOption<boost::fusion::pair<Eig,flt>,I,J>
  {
    typedef flt Float;
    typedef Eigen::Matrix<Float,I,J> Matrix;
    static EIGEN_STRONG_INLINE const typename Eigen::DenseBase<Matrix>::ConstantReturnType Zero() { return Matrix::Zero(); }
    typedef Eigen::Matrix<Float,Eigen::Dynamic,Eigen::Dynamic> MatrixDD;
    typedef Eigen::Matrix<Float,Eigen::Dynamic,1> MatrixD1;
  };

  template<class Float, int Rows_, int Cols_> struct Rows<Eigen::Matrix<Float,Rows_,Cols_>>
  {
    enum { value = Rows_ };
  };

  template<class Float, int Rows_, int Cols_> struct Cols<Eigen::Matrix<Float,Rows_,Cols_>>
  {
    enum { value = Cols_ };
  };

////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
  template<class T, size_t I, int K> struct ChooseBackUp<Eigen::Matrix<T,K,1>,I>
  {
    typedef Eigen::Matrix<T,K,1> Obj;
    typedef BackUp<T> Result;

    static Result create_back_up(Obj& obj)
    {
      return Result(obj(I));
    }
  };

  template<class T, int I, int J> struct Size< Eigen::Matrix<T,I,J> > { static const std::size_t value = I; };

  template<class Float, int N, int M> inline Float& at(Eigen::Matrix<Float,N,M>& m, int i, int j)
    { static_assert(N==M,"at(Eigen::Matrix<F,N,M>): N!=M");assert(i<N && j<N);return m(i,j); }

  template<class Float, int N, int M> inline const Float& at(const Eigen::Matrix<Float,N,M>& m, int i, int j)
    { static_assert(N==M,"at(Eigen::Matrix<F,N,M>): N!=M");assert(i<N && j<N);return m(i,j); }

  template<class Float, size_t N> Eigen::Map<const Eigen::Matrix<Float,int(N),1>> make_view(const std::array<Float,N>& residual, ttt::wrap<boost::fusion::pair<Eig,Float>>)
  {
    return Eigen::Map<const Eigen::Matrix<Float,N,1>>(residual.data());
  }

  template<class Float, int N> void damp_diag(Eigen::Matrix<Float,N,N>& m, const Float& lambda)
  {
    for(int i = 0 ; i < N ; ++i)
      m(i,i) += lambda;
  }

  template<class Float, int N> const Eigen::Matrix<Float,N,1>& make_view(const Eigen::Matrix<Float,N,1>& residual, ttt::wrap<boost::fusion::pair<Eig,Float>>)
  {
    return residual;
  }

  template<class Float, std::size_t X, std::size_t Y> struct Blocker<boost::fusion::pair<Eig,Float>,X,Y>
  {
    template<class Derived> static Eigen::Block<Derived,X,Y> view(Eigen::MatrixBase<Derived>& m, std::size_t j, std::size_t k)
    {
      return Eigen::Block<Derived,X,Y>(m.derived(), j, k);
    }
  };

  template<class T, int I, int J>
  bool is_invalid(const Eigen::Matrix<T,I,J>& mat)
  {
    for(int k = 0 ; k < mat.size() ; ++k)
      if (is_invalid(mat(k)))
        return true;
    return false;
  }

  template<class T, int I, int J>
  bool is_symmetric(const Eigen::Matrix<T,I,J>& mat)
  {
    for(int i = 0 ; i < I ; ++i)
      for(int j = 0 ; j < J ; ++j)
        if (mat(i,j) != mat(j,i))
          return false;
    return true;
  }

  template<class Float, int I>
  const Float* get_ptr(const Eigen::Matrix<Float,I,1>& m)
  {
    return m.data();
  }

  template<class Derived>
  EIGEN_STRONG_INLINE typename Eigen::NumTraits<typename Eigen::internal::traits<Derived>::Scalar>::Real
  squared_norm(const Eigen::MatrixBase<Derived>& m)
  {
    return m.squaredNorm();
  }

  template<class Derived>
  inline typename Eigen::NumTraits<typename Eigen::internal::traits<Derived>::Scalar>::Real
  norm(const Eigen::MatrixBase<Derived>& m)
  {
    return m.norm();
  }

  template<class Float, size_t N>
  Eigen::Map<const Eigen::Matrix<Float,N,1>> array_to_eigen(const std::array<Float,N>& array)
  {
    return Eigen::Map<const Eigen::Matrix<Float,N,1>>(array.data());
  }

  template<class Float, size_t N>
  Float squared_norm(const std::array<Float,N>& res)
  { return squared_norm(array_to_eigen(res));}

  template<class Float, size_t N>
  Float norm(const std::array<Float,N>& res)
  { return norm(array_to_eigen(res));}

  template<class Derived, class T, size_t N>
  void cwise_product(std::array<T,N>& a, const Eigen::MatrixBase<Derived>& b, const std::array<T,N>& c)
  {
    auto x = (b.cwiseProduct(array_to_eigen(c))).eval();
    for(size_t i = 0 ; i < N ; ++i)
      a[i] = x[i];
  }

  template<class T, int N>
  void cwise_product(Eigen::Matrix<T,N,1>& a, const Eigen::Matrix<T,N,1>& b, const Eigen::Matrix<T,N,1>& c)
  {
    a = b.cwiseProduct(c);
  }

  template<class T>
  void cwise_product(double& a, const Eigen::Matrix<T,1,1>& b, const double& c)
  {
    a = b[0] * c;
  }

////////////////////////////////////////////////////////

  template<class T, int I> void apply_increment(Eigen::Matrix<T, I, 1>& obj, const T *delta, const Adl&)
  {
	  for (int i = 0; i < I; i++)
		  obj[i] += delta[i];
  }

  template<class T> void apply_increment(Eigen::Matrix<T, 1, 1>& obj, const T& delta, const Adl&)
  {
	  obj[0] += delta;
  }

  template<class T, int K, int I> void apply_small_increment(Eigen::Matrix<T, K, 1>& obj, T h, v::numeric_tag<I>, const Adl&)
  {
	  static_assert(I < K, " apply_small_increment : I < K ");
	  obj[I] += h;
  }

////////////////////////////////////////////////////////

  template<class Float, int I> Eigen::Matrix<Float,I,I> inverse(const Eigen::Matrix<Float,I,I>& mat)
  {
    return mat.inverse();
  }

  template<class Float, int I, int J> void inverse_in_place(Eigen::Matrix<Float,I,J>& mat)
  {
    static_assert(I==J,"inverse_in_place(Matrix<F,I,J>: I!=J");
    mat = mat.inverse().eval();
  }

  template<class Float, int I, int J>
  const Eigen::Transpose<const Eigen::Matrix<Float,I,J>> transpose(const Eigen::Matrix<Float,I,J>& mat)
  {
    return mat.transpose();
  }

  template<class Derived, class OtherDerived>
  typename Eigen::internal::scalar_product_traits<typename Eigen::internal::traits<Derived>::Scalar,typename Eigen::internal::traits<OtherDerived>::Scalar>::ReturnType
  dot(const Eigen::MatrixBase<Derived>& a, const Eigen::MatrixBase<OtherDerived>& b)
  {
    return a.dot(b);
  }

  template<class Float, int I, int J> void set_zero(Eigen::Matrix<Float,I,J>& mat)
  {
    mat.setZero();
  }

  template<class Float>
  void ldlt_solve(Eigen::Matrix<Float,Eigen::Dynamic,1>& x, const Eigen::Matrix<Float,Eigen::Dynamic,Eigen::Dynamic>& a, const Eigen::Matrix<Float,Eigen::Dynamic,1>&  b)
  {
    assert(a.cols()!=0 && a.rows()!=0 && b.size()!=0);
    x = a.template selfadjointView<Eigen::Upper>().ldlt().solve(b);
  }
}

namespace ttt
{
  template<> struct Name<lma::Eig> { static std::string name() { return "Eigen"; } };
  template<class T, int I, int J> struct Name<Eigen::Matrix<T,I,J>> { static std::string name() { return "Eigen<" + ttt::name<T>() + "," + lma::to_string(I) + "," + lma::to_string(J) + ">";}};
}

#endif

max_stars_repo_name: bezout/LMA

max_issues_repo_name: ayumizll/LMA

max_forks_repo_name: bezout/LMA


text:
/* Copyright (c) Members of the EGEE Collaboration. 2004.
See http://www.eu-egee.org/partners/ for details on the copyright
holders.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <cstdio>
#include <ctime>

#include <string>
#include <iostream>
#include <fstream>

#include <boost/lexical_cast.hpp>
#include "glite/wms/common/logger/logstream.h"
#include "glite/wms/common/logger/manipulators.h"
#include "common/EventLogger.h"

#include "EventJobReleased.h"
#include "MonitorData.h"

USING_COMMON_NAMESPACE;
RenameLogStreamNS(elog);

JOBCONTROL_NAMESPACE_BEGIN {

namespace logmonitor {
namespace processer {

EventJobReleased::EventJobReleased(ULogEvent *event, MonitorData *data)
  : EventInterface(event, data), event_(dynamic_cast<JobReleasedEvent*>(event))
{ }

void EventJobReleased::process_event()
{
  logger::StatePusher pusher(elog::cedglog, "EventJobReleased::process_event()");

  elog::cedglog << logger::setlevel(logger::info) << "Got a job release event for cluster: " << ei_condor << '\n';

  return;
}

}} // namespace processer, logmonitor
} JOBCONTROL_NAMESPACE_END

max_stars_repo_name: italiangrid/wms

max_issues_repo_name: italiangrid/wms

max_forks_repo_name: italiangrid/wms


text:
// (c) Copyright Juergen Hunold 2012
// Use, modification and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#define BOOST_TEST_MODULE QtPositioning

#include <QGeoAddress>
#include <QGeoLocation>

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE (defines)
{
    BOOST_CHECK_EQUAL(BOOST_IS_DEFINED(QT_CORE_LIB), true);
    BOOST_CHECK_EQUAL(BOOST_IS_DEFINED(QT_POSITIONING_LIB), true);
    BOOST_CHECK_EQUAL(BOOST_IS_DEFINED(QT_NETWORK_LIB), true);
    BOOST_CHECK_EQUAL(BOOST_IS_DEFINED(QT_LOCATION_LIB), true);
}

BOOST_TEST_DONT_PRINT_LOG_VALUE(QGeoAddress)

BOOST_AUTO_TEST_CASE( geo_location )
{
    QGeoLocation geolocation;

    QGeoAddress address;

    BOOST_CHECK_EQUAL(geolocation.address(), address);
}

max_stars_repo_name: MaxSac/build

max_issues_repo_name: MaxSac/build

max_forks_repo_name: MaxSac/build


text:
/****************************************************************************
 *
 * rtsp_image_transport
 * Copyright © 2021 Fraunhofer FKIE
 * Author: Timo Röhling
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ****************************************************************************/
#include "frame_extractor.h"

#include "frame_data.h"
#include "stream_client.h"

#include <boost/format.hpp>
#include <ros/console.h>

namespace rtsp_image_transport
{

namespace
{

const unsigned char MPEG_START_CODE[] = {0x00, 0x00, 0x00, 0x01};

}

FrameExtractor*
FrameExtractor::createNew(const std::weak_ptr<StreamClient>& stream_client,
                          UsageEnvironment& env, MediaSubsession* subsession)
{
    return new FrameExtractor(stream_client, env, subsession);
}

FrameExtractor::FrameExtractor(const std::weak_ptr<StreamClient>& stream_client,
                               UsageEnvironment& env,
                               MediaSubsession* subsession)
    : MediaSink(env), stream_client_(stream_client), subsession_(subsession),
      codec_(fromRTSPCodecName(subsession_->codecName())), buffer_length_(0)
{
    if (codec_ == VideoCodec::Unknown)
        throw StreamingError((boost::format("unsupported video codec %1%")
                              % subsession->codecName())
                                 .str());
    if (codec_ == VideoCodec::H264 || codec_ == VideoCodec::H265)
    {
        /* Pass out-of-band PPS and SPS NAL units */
        char const* sprops = subsession->fmtp_spropparametersets();
        if (sprops)
        {
            std::shared_ptr<StreamClient> sc = stream_client_.lock();
            if (sc)
            {
                unsigned num_nals;
                SPropRecord* nals = parseSPropParameterSets(sprops, num_nals);
                for (unsigned i = 0; i < num_nals; ++i)
                {
                    if (buffer_length_ + nals[i].sPropLength + 4
                        > buffer_.size())
                        throw StreamingError("frame buffer overflow");
                    std::copy_n(MPEG_START_CODE, sizeof(MPEG_START_CODE),
                                buffer_.data() + buffer_length_);
                    std::copy_n(nals[i].sPropBytes, nals[i].sPropLength,
                                buffer_.data() + buffer_length_
                                    + sizeof(MPEG_START_CODE));
                    buffer_length_ +=
                        nals[i].sPropLength + sizeof(MPEG_START_CODE);
                }
                delete[] nals;
            }
        }
    }
}

VideoCodec FrameExtractor::codec() const
{
    return codec_;
}

Boolean FrameExtractor::continuePlaying()
{
    if (codec_ == VideoCodec::H264 || codec_ == VideoCodec::H265)
    {
        if (buffer_.size() - sizeof(MPEG_START_CODE) >= buffer_length_)
        {
            std::copy_n(MPEG_START_CODE, sizeof(MPEG_START_CODE),
                        buffer_.data() + buffer_length_);
            buffer_length_ += sizeof(MPEG_START_CODE);
        }
    }
    fSource->getNextFrame(buffer_.data() + buffer_length_,
                          buffer_.size() - buffer_length_, newFrameCallback,
                          this, onSourceClosure, this);
    return True;
}

void FrameExtractor::deliverFrame(unsigned frameSize,
                                  unsigned numTruncatedBytes,
                                  struct timeval presentationTime,
                                  unsigned durationInMicroseconds)
{
    std::shared_ptr<StreamClient> sc = stream_client_.lock();
    if (sc)
    {
        if (numTruncatedBytes)
        {
            ROS_WARN_STREAM("FrameExtractor buffer is " << numTruncatedBytes
                                                        << " bytes too small");
        }
        buffer_length_ += frameSize;
        ros::Time ts(presentationTime.tv_sec,
                     1000ull * presentationTime.tv_usec);
        if (buffer_length_ > 48)
        {
            sc->receiveStreamData(codec_, subsession_,
                                  std::make_shared<FrameData>(
                                      buffer_.data(), buffer_length_, ts));
            buffer_length_ = 0;
        }
        continuePlaying();
    }
}

void FrameExtractor::newFrameCallback(void* obj, unsigned frameSize,
                                      unsigned numTruncatedBytes,
                                      struct timeval presentationTime,
                                      unsigned durationInMicroseconds)
{
    FrameExtractor* self = static_cast<FrameExtractor*>(obj);
    self->deliverFrame(frameSize, numTruncatedBytes, presentationTime,
                       durationInMicroseconds);
}

}  // namespace rtsp_image_transport


text: #include <boost/fusion/functional/generation/make_fused_procedure.hpp>

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
//==================================================================================================
/*!
  @file

  @copyright 2016 NumScale SAS

  Distributed under the Boost Software License, Version 1.0.
  (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
//==================================================================================================
#ifndef BOOST_SIMD_FUNCTION_EPS_HPP_INCLUDED
#define BOOST_SIMD_FUNCTION_EPS_HPP_INCLUDED

#if defined(DOXYGEN_ONLY)
namespace boost { namespace simd
{
  /*!
    @ingroup group-ieee
    Computes the distance between its argument and the next representable value of its argument type.

    @par Semantic:

    For every parameter of type @c T

    @code
    T r = eps(x);
    @endcode

    is similar to:

    @code
    T  r = pow(2,exponent(x))*Eps<T>();
    @endcode

    if @c T is a floating-point type and to :

    @code
    T r = 1;
    @endcode

    if @c T is an integral type.

    @param  x Base value for epsilon computation.
    @return The distance between @c x and its next representable value.

    @see ulp, ulpdist, Eps
**/
  Value eps(Value const & x);

} }
#endif

#include <boost/simd/function/scalar/eps.hpp>
#include <boost/simd/function/simd/eps.hpp>

#endif

max_stars_repo_name: nickporubsky/boost-simd-clone


text:
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/json
//

#ifndef BOOST_JSON_IMPL_ARRAY_IPP
#define BOOST_JSON_IMPL_ARRAY_IPP

#include <boost/json/array.hpp>
#include <boost/json/pilfer.hpp>
#include <boost/json/detail/except.hpp>
#include <cstdlib>
#include <limits>
#include <new>
#include <utility>

BOOST_JSON_NS_BEGIN

//----------------------------------------------------------

constexpr array::table::table() = default;

// empty arrays point here
BOOST_JSON_REQUIRE_CONST_INIT
array::table array::empty_;

auto
array::
table::
allocate(
    std::size_t capacity,
    storage_ptr const& sp) ->
        table*
{
    BOOST_ASSERT(capacity > 0);
    if(capacity > array::max_size())
        detail::throw_length_error(
            "array too large",
            BOOST_JSON_SOURCE_POS);
    auto p = reinterpret_cast<
        table*>(sp->allocate(
            sizeof(table) +
                capacity * sizeof(value),
            alignof(value)));
    p->capacity = static_cast<
        std::uint32_t>(capacity);
    return p;
}

void
array::
table::
deallocate(
    table* p,
    storage_ptr const& sp)
{
    if(p->capacity == 0)
        return;
    sp->deallocate(p,
        sizeof(table) +
            p->capacity * sizeof(value),
        alignof(value));
}

//----------------------------------------------------------

array::
revert_insert::
revert_insert(
    const_iterator pos,
    std::size_t n,
    array& arr)
    : arr_(&arr)
    , i_(pos - arr_->data())
    , n_(n)
{
    BOOST_ASSERT(
        pos >= arr_->begin() &&
        pos <= arr_->end());
    if( n_ <= arr_->capacity() -
        arr_->size())
    {
        // fast path
        p = arr_->data() + i_;
        if(n_ == 0)
            return;
        relocate(
            p + n_,
            p,
            arr_->size() - i_);
        arr_->t_->size = static_cast<
            std::uint32_t>(
                arr_->t_->size + n_);
        return;
    }
    if(n_ > max_size() - arr_->size())
        detail::throw_length_error(
            "array too large",
            BOOST_JSON_SOURCE_POS);
    auto t = table::allocate(
        arr_->growth(arr_->size() + n_),
            arr_->sp_);
    t->size = static_cast<std::uint32_t>(
        arr_->size() + n_);
    p = &(*t)[0] + i_;
    relocate(
        &(*t)[0],
        arr_->data(),
        i_);
    relocate(
        &(*t)[i_ + n_],
        arr_->data() + i_,
        arr_->size() - i_);
    t = detail::exchange(arr_->t_, t);
    table::deallocate(t, arr_->sp_);
}

array::
revert_insert::
~revert_insert()
{
    if(! arr_)
        return;
    BOOST_ASSERT(n_ != 0);
    auto const pos =
        arr_->data() + i_;
    arr_->destroy(pos, p);
    arr_->t_->size = static_cast<
        std::uint32_t>(
            arr_->t_->size - n_);
    relocate(
        pos,
        pos + n_,
        arr_->size() - i_);
}

//----------------------------------------------------------

void
array::
destroy(
    value* first, value* last) noexcept
{
    if(sp_.is_not_shared_and_deallocate_is_trivial())
        return;
    while(last-- != first)
        last->~value();
}

void
array::
destroy() noexcept
{
    if(sp_.is_not_shared_and_deallocate_is_trivial())
        return;
    auto last = end();
    auto const first = begin();
    while(last-- != first)
        last->~value();
    table::deallocate(t_, sp_);
}

//----------------------------------------------------------
//
// Special Members
//
//----------------------------------------------------------

array::
array(detail::unchecked_array&& ua)
    : sp_(ua.storage())
{
    BOOST_STATIC_ASSERT(
        alignof(table) == alignof(value));
    if(ua.size() == 0)
    {
        t_ = &empty_;
        return;
    }
    t_= table::allocate(
        ua.size(), sp_);
    t_->size = static_cast<
        std::uint32_t>(ua.size());
    ua.relocate(data());
}

array::
~array()
{
    destroy();
}

array::
array(
    std::size_t count,
    value const& v,
    storage_ptr sp)
    : sp_(std::move(sp))
{
    if(count == 0)
    {
        t_ = &empty_;
        return;
    }
    t_= table::allocate(
        count, sp_);
    t_->size = 0;
    revert_construct r(*this);
    while(count--)
    {
        ::new(end()) value(v, sp_);
        ++t_->size;
    }
    r.commit();
}

array::
array(
    std::size_t count,
    storage_ptr sp)
    : sp_(std::move(sp))
{
    if(count == 0)
    {
        t_ = &empty_;
        return;
    }
    t_ = table::allocate(
        count, sp_);
    t_->size = static_cast<
        std::uint32_t>(count);
    auto p = data();
    do
    {
        ::new(p++) value(sp_);
    }
    while(--count);
}

array::
array(array const& other)
    : array(other, other.sp_)
{
}

array::
array(
    array const& other,
    storage_ptr sp)
    : sp_(std::move(sp))
{
    if(other.empty())
    {
        t_ = &empty_;
        return;
    }
    t_ = table::allocate(
        other.size(), sp_);
    t_->size = 0;
    revert_construct r(*this);
    auto src = other.data();
    auto dest = data();
    auto const n = other.size();
    do
    {
        ::new(dest++) value(
            *src++, sp_);
        ++t_->size;
    }
    while(t_->size < n);
    r.commit();
}

array::
array(
    array&& other,
    storage_ptr sp)
    : sp_(std::move(sp))
{
    if(*sp_ == *other.sp_)
    {
        // same resource
        t_ = detail::exchange(
            other.t_, &empty_);
        return;
    }
    else if(other.empty())
    {
        t_ = &empty_;
        return;
    }
    // copy
    t_ = table::allocate(
        other.size(), sp_);
    t_->size = 0;
    revert_construct r(*this);
    auto src = other.data();
    auto dest = data();
    auto const n = other.size();
    do
    {
        ::new(dest++) value(
            *src++, sp_);
        ++t_->size;
    }
    while(t_->size < n);
    r.commit();
}

array::
array(
    std::initializer_list<
        value_ref> init,
    storage_ptr sp)
    : sp_(std::move(sp))
{
    if(init.size() == 0)
    {
        t_ = &empty_;
        return;
    }
    t_ = table::allocate(
        init.size(), sp_);
    t_->size = 0;
    revert_construct r(*this);
    value_ref::write_array(
        data(), init, sp_);
    t_->size = static_cast<
        std::uint32_t>(init.size());
    r.commit();
}

//----------------------------------------------------------

array&
array::
operator=(array const& other)
{
    array(other,
        storage()).swap(*this);
    return *this;
}

array&
array::
operator=(array&& other)
{
    array(std::move(other),
        storage()).swap(*this);
    return *this;
}

array&
array::
operator=(
    std::initializer_list<value_ref> init)
{
    array(init,
        storage()).swap(*this);
    return *this;
}

//----------------------------------------------------------
//
// Capacity
//
//----------------------------------------------------------

void
array::
shrink_to_fit() noexcept
{
    if(capacity() <= size())
        return;
    if(size() == 0)
    {
        table::deallocate(t_, sp_);
        t_ = &empty_;
        return;
    }

#ifndef BOOST_NO_EXCEPTIONS
    try
    {
#endif
        auto t = table::allocate(
            size(), sp_);
        relocate(
            &(*t)[0],
            data(),
            size());
        t->size = static_cast<
            std::uint32_t>(size());
        t = detail::exchange(
            t_, t);
        table::deallocate(t, sp_);
#ifndef BOOST_NO_EXCEPTIONS
    }
    catch(...)
    {
        // eat the exception
        return;
    }
#endif
}

//----------------------------------------------------------
//
// Modifiers
//
//----------------------------------------------------------

void
array::
clear() noexcept
{
    if(size() == 0)
        return;
    destroy(
        begin(), end());
    t_->size = 0;
}

auto
array::
insert(
    const_iterator pos,
    value const& v) ->
        iterator
{
    return emplace(pos, v);
}

auto
array::
insert(
    const_iterator pos,
    value&& v) ->
        iterator
{
    return emplace(pos, std::move(v));
}

auto
array::
insert(
    const_iterator pos,
    std::size_t count,
    value const& v) ->
        iterator
{
    revert_insert r(
        pos, count, *this);
    while(count--)
    {
        ::new(r.p) value(v, sp_);
        ++r.p;
    }
    return r.commit();
}

auto
array::
insert(
    const_iterator pos,
    std::initializer_list<
        value_ref> init) ->
    iterator
{
    revert_insert r(
        pos, init.size(), *this);
    value_ref::write_array(
        r.p, init, sp_);
    return r.commit();
}

auto
array::
erase(
    const_iterator pos) noexcept ->
    iterator
{
    BOOST_ASSERT(
        pos >= begin() &&
        pos <= end());
    auto const p = &(*t_)[0] +
        (pos - &(*t_)[0]);
    destroy(p, p + 1);
    relocate(p, p + 1, 1);
    --t_->size;
    return p;
}

auto
array::
erase(
    const_iterator first,
    const_iterator last) noexcept ->
        iterator
{
    std::size_t const n =
        last - first;
    auto const p = &(*t_)[0] +
        (first - &(*t_)[0]);
    destroy(p, p + n);
    relocate(p, p + n,
        t_->size - (last -
            &(*t_)[0]));
    t_->size = static_cast<
        std::uint32_t>(t_->size - n);
    return p;
}

void
array::
push_back(value const& v)
{
    emplace_back(v);
}

void
array::
push_back(value&& v)
{
    emplace_back(std::move(v));
}

void
array::
pop_back() noexcept
{
    auto const p = &back();
    destroy(p, p + 1);
    --t_->size;
}

void
array::
resize(std::size_t count)
{
    if(count <= t_->size)
    {
        // shrink
        destroy(
            &(*t_)[0] + count,
            &(*t_)[0] + t_->size);
        t_->size = static_cast<
            std::uint32_t>(count);
        return;
    }

    reserve(count);
    auto p = &(*t_)[t_->size];
    auto const end = &(*t_)[count];
    while(p != end)
        ::new(p++) value(sp_);
    t_->size = static_cast<
        std::uint32_t>(count);
}

void
array::
resize(
    std::size_t count,
    value const& v)
{
    if(count <= size())
    {
        // shrink
        destroy(
            data() + count,
            data() + size());
        t_->size = static_cast<
            std::uint32_t>(count);
        return;
    }
    count -= size();
    revert_insert r(
        end(), count, *this);
    while(count--)
    {
        ::new(r.p) value(v, sp_);
        ++r.p;
    }
    r.commit();
}

void
array::
swap(array& other)
{
    BOOST_ASSERT(this != &other);
    if(*sp_ == *other.sp_)
    {
        t_ = detail::exchange(
            other.t_, t_);
        return;
    }
    array temp1(
        std::move(*this),
        other.storage());
    array temp2(
        std::move(other),
        this->storage());
    this->~array();
    ::new(this) array(
        pilfer(temp2));
    other.~array();
    ::new(&other) array(
        pilfer(temp1));
}

//----------------------------------------------------------
//
// Private
//
//----------------------------------------------------------

std::size_t
array::
growth(
    std::size_t new_size) const
{
    if(new_size > max_size())
        detail::throw_length_error(
            "array too large",
            BOOST_JSON_SOURCE_POS);
    std::size_t const old = capacity();
    if(old > max_size() - old / 2)
        return new_size;
    std::size_t const g =
        old + old / 2; // 1.5x
    if(g < new_size)
        return new_size;
    return g;
}

// precondition: new_capacity > capacity()
void
array::
reserve_impl(
    std::size_t new_capacity)
{
    BOOST_ASSERT(
        new_capacity > t_->capacity);
    auto t = table::allocate(
        growth(new_capacity), sp_);
    relocate(
        &(*t)[0],
        &(*t_)[0],
        t_->size);
    t->size = t_->size;
    t = detail::exchange(t_, t);
    table::deallocate(t, sp_);
}

// precondition: pv is not aliased
value&
array::
push_back(
    pilfered<value> pv)
{
    auto const n = t_->size;
    if(n < t_->capacity)
    {
        // fast path
        auto& v = *::new(
            &(*t_)[n]) value(pv);
        ++t_->size;
        return v;
    }
    auto const t =
        detail::exchange(t_,
            table::allocate(
                growth(n + 1),
                    sp_));
    auto& v = *::new(
        &(*t_)[n]) value(pv);
    relocate(
        &(*t_)[0],
        &(*t)[0],
        n);
    t_->size = n + 1;
    table::deallocate(t, sp_);
    return v;
}

// precondition: pv is not aliased
auto
array::
insert(
    const_iterator pos,
    pilfered<value> pv) ->
        iterator
{
    BOOST_ASSERT(
        pos >= begin() &&
        pos <= end());
    std::size_t const n =
        t_->size;
    std::size_t const i =
        pos - &(*t_)[0];
    if(n < t_->capacity)
    {
        // fast path
        auto const p =
            &(*t_)[i];
        relocate(
            p + 1,
            p,
            n - i);
        ::new(p) value(pv);
        ++t_->size;
        return p;
    }
    auto t =
        table::allocate(
            growth(n + 1), sp_);
    auto const p = &(*t)[i];
    ::new(p) value(pv);
    relocate(
        &(*t)[0],
        &(*t_)[0],
        i);
    relocate(
        p + 1,
        &(*t_)[i],
        n - i);
    t->size = static_cast<
        std::uint32_t>(size() + 1);
    t = detail::exchange(t_, t);
    table::deallocate(t, sp_);
    return p;
}

//----------------------------------------------------------

bool
array::
equal(
    array const& other) const noexcept
{
    if(size() != other.size())
        return false;
    for(std::size_t i = 0; i < size(); ++i)
        if((*this)[i] != other[i])
            return false;
    return true;
}

BOOST_JSON_NS_END

#endif

ext: ipp


text:
/*
The library Boost.Ref is typically used in conjunction with Boost.Bind and
thus is presented next. It provides two functions -
boost::ref() and boost::cref() - defined in boost/ref.hpp.

Boost.Ref is of importance whenever functions containing at least one
reference parameter should be used with boost::bind().
Since boost::bind() copies its parameters, references need to be handled
separately.
*/
#include <boost/bind.hpp>
#include <iostream>
#include <vector>
#include <algorithm>

void add(int i, int j, std::ostream &os)
{
  os << i + j << std::endl;
}

int main()
{
  std::vector<int> v;
  v.push_back(1);
  v.push_back(3);
  v.push_back(2);

  std::for_each(v.begin(), v.end(), boost::bind(add, 10, _1, boost::ref(std::cout)));
}

/*
The above example uses the known add() function from the previous paragraph.
This time however, the function expects a reference to a stream object in
order to print the information. Since parameters to boost::bind() are
passed by value, std::cout cannot be used directly since otherwise the
function would attempt to create a copy of it.

Using the template function boost::ref(), streams such as std::cout can be
passed by reference which allows to compile the example successfully.

In order to pass constant objects by reference, the template function
boost::cref() can be used instead.
*/


text:
/**
 ** Copyright (c) 2014 Illumina, Inc.
 **
 ** This file is part of Illumina's Enhanced Artificial Genome Engine (EAGLE),
 ** covered by the "BSD 2-Clause License" (see accompanying LICENSE file)
 **
 ** \description Top level component to induce variants in a reference.
 **
 ** \author Lilian Janin
 **/

#ifndef EAGLE_MAIN_VCF_COMPARATOR_HH
#define EAGLE_MAIN_VCF_COMPARATOR_HH

#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/noncopyable.hpp>
#include <boost/filesystem.hpp>
#include <boost/format.hpp>

#include "genome/VariantList.hh"
#include "main/VcfComparatorOptions.hh"

namespace bfs = boost::filesystem;

namespace eagle
{
namespace main
{

class VcfComparator
{
public:
    VcfComparator( const VcfComparatorOptions& options );
    void run();

private:
    const VcfComparatorOptions &options_;
    eagle::genome::VariantList simulatedVariantList_;
    eagle::genome::VariantList calledVariantList_;
};

} // namespace main
} // namespace eagle

#endif // EAGLE_MAIN_VCF_COMPARATOR_HH

max_stars_repo_name: sequencing/EAGLE

max_issues_repo_name: sequencing/EAGLE

max_forks_repo_name: sequencing/EAGLE


text:
// Copyright <disenone>

#include <iostream>

#define BOOST_TEST_MODULE test_squares
#define BOOST_TEST_DYN_LINK
#include <boost/test/included/unit_test.hpp>

#include <common/nuid.hpp>

using namespace aoi;

BOOST_AUTO_TEST_CASE(test_nuid) {
  Nuid nuid1 = aoi::GenNuid();
  Nuid nuid2 = aoi::GenNuid();
  Nuid nuid3 = aoi::GenNuid();
  BOOST_TEST(nuid2 == nuid1 + 1);
  BOOST_TEST(nuid3 == nuid2 + 1);
}

max_stars_repo_name: disenone/AoiTesting

max_issues_repo_name: disenone/AoiTesting

max_forks_repo_name: disenone/AoiTesting


text:
#define BOOST_TEST_MODULE pcraster dal space step mapper
#include <boost/test/unit_test.hpp>
#include "dal_MathUtils.h"
#include "dal_SpaceStepMapper.h"

BOOST_AUTO_TEST_CASE(test)
{
  using namespace dal;

  {
    SpaceStepMapper mapper;
    BOOST_CHECK(!mapper.isValid());
  }

  {
    SpaceStepMapper mapper(0, 5.0, 0.5);

    BOOST_CHECK(comparable(mapper.destination(1.0), 5.5));
    BOOST_CHECK(comparable(mapper.destination(0.0), 5.0));
    BOOST_CHECK(comparable(mapper.destination(-1.0), 4.5));

    BOOST_CHECK(comparable(mapper.destination(0.5), 5.25));
    BOOST_CHECK(comparable(mapper.destination(-0.5), 4.75));

    BOOST_CHECK(comparable(mapper.source(5.5), 1.0));
    BOOST_CHECK(comparable(mapper.source(5.0), 0.0));
    BOOST_CHECK(comparable(mapper.source(4.5), -1.0));
    BOOST_CHECK(comparable(mapper.source(5.25), 0.5));
    BOOST_CHECK(comparable(mapper.source(4.75), -0.5));
  }

  {
    SpaceStepMapper mapper(0, 74.85, -0.30);

    BOOST_CHECK(comparable(mapper.destination(0), 74.85));
    BOOST_CHECK(comparable(mapper.destination(1), 74.55));
    BOOST_CHECK(comparable(mapper.destination(-0.5), 75.0));
    BOOST_CHECK(comparable(mapper.source(0.15), 249.0));

    BOOST_CHECK(comparable(mapper.source(74.85), 0.0));
    BOOST_CHECK(comparable(mapper.source(74.55), 1.0));
    BOOST_CHECK(comparable(mapper.source(75.0), -0.5));
  }

  {
    SpaceStepMapper mapper(1, 74.85, -0.30);

    BOOST_CHECK(comparable(mapper.destination(1), 74.85));
    BOOST_CHECK(comparable(mapper.destination(2), 74.55));
    BOOST_CHECK(comparable(mapper.destination(0.5), 75.0));

    BOOST_CHECK(comparable(mapper.source(74.85), 1.0));
    BOOST_CHECK(comparable(mapper.source(74.55), 2.0));
    BOOST_CHECK(comparable(mapper.source(75.0), 0.5));
  }
}

ext: cc

max_stars_repo_name: quanpands/wflow

max_issues_repo_name: quanpands/wflow

max_forks_repo_name: quanpands/wflow


text:
// Copyright (c) 2020-2022 Dr. Colin Hirsch and Daniel Frey
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)

#ifndef TAO_PEGTL_INTERNAL_FILESYSTEM_HPP
#define TAO_PEGTL_INTERNAL_FILESYSTEM_HPP

#if defined( TAO_PEGTL_BOOST_FILESYSTEM )

#define BOOST_FILESYSTEM_NO_DEPRECATED

#include <boost/filesystem.hpp>

namespace tao::pegtl::internal
{
   namespace filesystem = ::boost::filesystem;

   using error_code = ::boost::system::error_code;

   inline const auto& system_category() noexcept
   {
      return ::boost::system::system_category();
   }

}  // namespace tao::pegtl::internal

#elif defined( TAO_PEGTL_STD_EXPERIMENTAL_FILESYSTEM )

#include <experimental/filesystem>

namespace tao::pegtl::internal
{
   namespace filesystem = ::std::experimental::filesystem;

   using error_code = ::std::error_code;

   inline const auto& system_category() noexcept
   {
      return ::std::system_category();
   }

}  // namespace tao::pegtl::internal

#else

#include <filesystem>

namespace tao::pegtl::internal
{
   namespace filesystem = ::std::filesystem;

   using error_code = ::std::error_code;

   inline const auto& system_category() noexcept
   {
      return ::std::system_category();
   }

}  // namespace tao::pegtl::internal

#endif

#endif

max_stars_repo_name: faizol/PEGTL

max_issues_repo_name: faizol/PEGTL

max_forks_repo_name: faizol/PEGTL


text:
#ifndef CAFFE_PARALLEL_MPI_SYNC_CPU_HPP_
#define CAFFE_PARALLEL_MPI_SYNC_CPU_HPP_

#include <boost/date_time/posix_time/posix_time.hpp>

#include <vector>

#include "caffe/common.hpp"
#include "caffe/mpi.hpp"
#include "caffe/parallel/cpu_params.hpp"
#include "caffe/solver.hpp"

namespace caffe {

// Synchronous data parallelism using Allreduce between remote CPUs.
template<typename Dtype>
class MPISyncCPU : public CPUParams<Dtype>, public Solver<Dtype>::Callback {
 public:
  explicit MPISyncCPU(shared_ptr<Solver<Dtype> > root_solver);
  virtual ~MPISyncCPU();

  inline const shared_ptr<Solver<Dtype> >& solver() const {
    return solver_;
  }

  void Run();
  void Step(int iters);

 protected:
  void on_start();
  void on_gradients_ready();

#ifdef USE_MPI
  MPI_Comm comm_;
#endif
  int comm_size_;
  shared_ptr<Solver<Dtype> > solver_;

  using Params<Dtype>::size_;
  using Params<Dtype>::data_;
  using Params<Dtype>::diff_;
};

}  // namespace caffe

#endif

max_stars_repo_name: matex-org/caffe-intel

max_issues_repo_name: matex-org/caffe-intel

max_forks_repo_name: matex-org/caffe-intel