Change Log
==========

Version 0.7.0 *(2020-08-31)*
----------------------------

 * New: Add support for contextual serializers which are registered with the supplied format.
   No new API or action is required for this to work–it's all implementation detail. Since it's
   a potentially incompatible behavior change, the version was bumped.

Version 0.6.0 *(2020-08-19)*
----------------------------

 * Kotlin updated to 1.4.0
 * Serialization updated to 1.0.0-rc

   Note that the APIs used by this converter are marked as experimental. As such, the experimental
   annotation has been propagated to the public API such that you will need to opt-in to using it
   or receive a warning.

Version 0.5.0 *(2020-03-06)*
----------------------------

 * Kotlin updated to 1.3.70
 * Serialization updated to 0.20.0
 * Retrofit updated to 2.6.4

Version 0.4.0 *(2019-04-12)*
----------------------------

 * Serialization updated to 0.11.0

Version 0.3.0 *(2019-02-25)*
----------------------------

 * New: `asConverterFactory()` extension API on `StringFormat` and `BinaryFormat`. This deprecates
   the old `serializationConverterFactory` top-level function.
 * Kotlin updated to 1.3.20
 * Serialization updated to 0.10.0

Version 0.2.0 *(2018-10-29)*
----------------------------

 * New: `stringBased` and `bytesBased` have been removed in favor of a single
   `serializationConverterFactory` function with overloads for `StringFormat` and `BinaryFormat`
   instances (like `JSON` and `ProtoBuf`). For those configuring Retrofit from Java the API is now
   `KotlinSerializationConverterFactory.create`.
 * Kotlin updated to 1.3.0
 * Serialization updated to 0.9.0

Version 0.1.0 *(2018-09-22)*
----------------------------

Update to Kotlin 1.3.0-rc-57 and serialization 0.8.0-rc13.

Version 0.0.1 *(2018-01-15)*
----------------------------

Initial release.


# Perks for Go (golang.org)

Perks contains the Go package quantile that computes approximate quantiles over
an unbounded data stream within low memory and CPU bounds.

For more information and examples, see:
http://godoc.org/github.com/bmizerany/perks

A very special thank you and shout out to Graham Cormode (Rutgers University),
Flip Korn (AT&T Labs–Research), S. Muthukrishnan (Rutgers University), and
Divesh Srivastava (AT&T Labs–Research) for their research and publication of
[Effective Computation of Biased Quantiles over Data Streams](http://www.cs.rutgers.edu/~muthu/bquant.pdf)

Thank you, also:
* Armon Dadgar (@armon)
* Andrew Gerrand (@nf)
* Brad Fitzpatrick (@bradfitz)
* Keith Rarick (@kr)

FAQ:

Q: Why not move the quantile package into the project root?
A: I want to add more packages to perks later.

Copyright (C) 2013 Blake Mizerany

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


# Contributing to Go

Go is an open source project.

It is the work of hundreds of contributors. We appreciate your help!

## Filing issues

When [filing an issue](https://github.com/golang/oauth2/issues), make sure to answer these five questions:

1.  What version of Go are you using (`go version`)?
2.  What operating system and processor architecture are you using?
3.  What did you do?
4.  What did you expect to see?
5.  What did you see instead?

General questions should go to the [golang-nuts mailing list](https://groups.google.com/group/golang-nuts) instead of the issue tracker.
The gophers there will answer or ask you to file an issue if you've tripped over a bug.

## Contributing code

Please read the [Contribution Guidelines](https://golang.org/doc/contribute.html)
before sending patches.

Unless otherwise noted, the Go source files are distributed under
the BSD-style license found in the LICENSE file.


/*=============================================================================
    Copyright (c) 2014-2015 Kohei Takahashi

    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 FUSION_VECTOR_FORWARD_11052014_1626
#define FUSION_VECTOR_FORWARD_11052014_1626

#include <boost/config.hpp>
#include <boost/fusion/support/config.hpp>
#include <boost/fusion/container/vector/detail/config.hpp>

///////////////////////////////////////////////////////////////////////////////
// With no variadics, we will use the C++03 version
///////////////////////////////////////////////////////////////////////////////
#if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
# include <boost/fusion/container/vector/detail/cpp03/vector_fwd.hpp>
#else

///////////////////////////////////////////////////////////////////////////////
// C++11 interface
///////////////////////////////////////////////////////////////////////////////
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>

namespace boost { namespace fusion
{
    template <typename ...T>
    struct vector;

#define FUSION_VECTOR_N_ALIASES(z, N, d)                                    \
    template <typename ...T>                                                \
    using BOOST_PP_CAT(vector, N) = vector<T...>;

    BOOST_PP_REPEAT(51, FUSION_VECTOR_N_ALIASES, ~)

#undef FUSION_VECTOR_N_ALIASES
}}

#endif
#endif


// Copyright 2015 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <wx/arrstr.h>
#include <wx/panel.h>
#include "Common/CommonTypes.h"
#include "DiscIO/Volume.h"

class wxCheckBox;
class wxChoice;

class WiiConfigPane final : public wxPanel
{
public:
	WiiConfigPane(wxWindow* parent, wxWindowID id);

private:
	void InitializeGUI();
	void LoadGUIValues();
	void RefreshGUI();

	void OnScreenSaverCheckBoxChanged(wxCommandEvent&);
	void OnPAL60CheckBoxChanged(wxCommandEvent&);
	void OnSDCardCheckBoxChanged(wxCommandEvent&);
	void OnConnectKeyboardCheckBoxChanged(wxCommandEvent&);
	void OnSystemLanguageChoiceChanged(wxCommandEvent&);
	void OnAspectRatioChoiceChanged(wxCommandEvent&);

	static u8 GetSADRCountryCode(DiscIO::IVolume::ELanguage language);

	wxArrayString m_system_language_strings;
	wxArrayString m_aspect_ratio_strings;

	wxCheckBox* m_screensaver_checkbox;
	wxCheckBox* m_pal60_mode_checkbox;
	wxCheckBox* m_sd_card_checkbox;
	wxCheckBox* m_connect_keyboard_checkbox;
	wxChoice* m_system_language_choice;
	wxChoice* m_aspect_ratio_choice;
};


<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Console\Descriptor;

use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputDefinition;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Exception\InvalidArgumentException;

/**
 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
 *
 * @internal
 */
abstract class Descriptor implements DescriptorInterface
{
    /**
     * @var OutputInterface
     */
    private $output;

    /**
     * {@inheritdoc}
     */
    public function describe(OutputInterface $output, $object, array $options = array())
    {
        $this->output = $output;

        switch (true) {
            case $object instanceof InputArgument:
                $this->describeInputArgument($object, $options);
                break;
            case $object instanceof InputOption:
                $this->describeInputOption($object, $options);
                break;
            case $object instanceof InputDefinition:
                $this->describeInputDefinition($object, $options);
                break;
            case $object instanceof Command:
                $this->describeCommand($object, $options);
                break;
            case $object instanceof Application:
                $this->describeApplication($object, $options);
                break;
            default:
                throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object)));
        }
    }

    /**
     * Writes content to output.
     *
     * @param string $content
     * @param bool   $decorated
     */
    protected function write($content, $decorated = false)
    {
        $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
    }

    /**
     * Describes an InputArgument instance.
     *
     * @param InputArgument $argument
     * @param array         $options
     *
     * @return string|mixed
     */
    abstract protected function describeInputArgument(InputArgument $argument, array $options = array());

    /**
     * Describes an InputOption instance.
     *
     * @param InputOption $option
     * @param array       $options
     *
     * @return string|mixed
     */
    abstract protected function describeInputOption(InputOption $option, array $options = array());

    /**
     * Describes an InputDefinition instance.
     *
     * @param InputDefinition $definition
     * @param array           $options
     *
     * @return string|mixed
     */
    abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());

    /**
     * Describes a Command instance.
     *
     * @param Command $command
     * @param array   $options
     *
     * @return string|mixed
     */
    abstract protected function describeCommand(Command $command, array $options = array());

    /**
     * Describes an Application instance.
     *
     * @param Application $application
     * @param array       $options
     *
     * @return string|mixed
     */
    abstract protected function describeApplication(Application $application, array $options = array());
}


open Core_kernel
open Bap.Std
open Bap_llvm.Std
open X86_asm.Reg
open X86_tools_types

type semantics = Mem_to_reg | Reg_to_mem

module type S = sig
  type t [@@deriving bin_io, sexp, compare, enumerate]
  val asm_of_t  : t -> X86_asm.reg
  val semantics : semantics
end

module type Version = sig
  module Mov_oa_ia32  : S
  module Mov_oa_amd64 : S
  module Mov_ao_ia32  : S
  module Mov_ao_amd64 : S
  val allow_nil : bool
end

module type Semantics = sig
  val lift : X86_asm.reg -> semantics -> bool -> lifter
end

module Insn_semantics(Tools : X86_tools.S) = struct
  open Tools

  let apply mem seg disp reg sem =
    let mem = MM.of_mem ?seg ~disp mem in
    match sem with
    | Mem_to_reg ->
      Ok [MM.load mem ~size:(RR.width reg) |> RR.set reg ]
    | Reg_to_mem ->
      Ok [RR.get reg |> MM.store mem ~size:(RR.width reg)]

  let lift asm sem allow_nil =
    let reg = RR.of_asm_exn asm in
    if allow_nil then
      X86_operands.ir ~f:(fun mem off seg -> apply mem (Some seg) off reg sem)
    else
      X86_operands.i ~f:(fun mem off -> apply mem None off reg sem)
end

module Ver_34 = struct

  let allow_nil = false

  module Mov_oa_ia32 = struct
    type t = MOV8o8a | MOV16o16a | MOV32o32a
    [@@deriving bin_io, sexp, compare, enumerate]

    let asm_of_t t = match t with
      | MOV8o8a    -> `AL
      | MOV16o16a  -> `AX
      | MOV32o32a  -> `EAX

    let semantics = Mem_to_reg
  end

  module Mov_oa_amd64 = struct
    type t = MOV64o8a | MOV64o16a | MOV64o32a | MOV64o64a
    [@@deriving bin_io, sexp, compare, enumerate]

    let asm_of_t t = match t with
      | MOV64o8a  -> `AL
      | MOV64o16a -> `AX
      | MOV64o32a -> `EAX
      | MOV64o64a -> `RAX

    let semantics = Mem_to_reg
  end

  module Mov_ao_ia32 = struct
    type t = MOV8ao8 | MOV16ao16 | MOV32ao32
    [@@deriving bin_io, sexp, compare, enumerate]

    let asm_of_t t = match t with
      | MOV8ao8   -> `AL
      | MOV16ao16 -> `AX
      | MOV32ao32 -> `EAX

    let semantics = Reg_to_mem
  end

  module Mov_ao_amd64 = struct
    type t = MOV64ao8 | MOV64ao16 | MOV64ao32 | MOV64ao64
    [@@deriving bin_io, sexp, compare, enumerate]

    let asm_of_t t = match t with
      | MOV64ao8  -> `AL
      | MOV64ao16 -> `AX
      | MOV64ao32 -> `EAX
      | MOV64ao64 -> `RAX

    let semantics = Reg_to_mem
  end
end

module Ver_common = struct

  let allow_nil = true

  module Mov_oa_ia32 = struct
    type t =
      | MOV8o16a
      | MOV8o32a
      | MOV16o32a
      | MOV32o32a
      | MOV16o16a
      | MOV32o16a
    [@@deriving bin_io, sexp, compare, enumerate]

    let asm_of_t op = match op with
      | MOV8o16a  | MOV8o32a  -> `AL
      | MOV16o16a | MOV16o32a -> `AX
      | MOV32o16a | MOV32o32a -> `EAX

    let semantics = Reg_to_mem
  end

  module Mov_oa_amd64 = struct
    type t = MOV8o64a | MOV16o64a | MOV32o64a | MOV64o32a | MOV64o64a
    [@@deriving bin_io, sexp, compare, enumerate]

    let asm_of_t op = match op with
      | MOV8o64a  -> `AL
      | MOV16o64a -> `AX
      | MOV32o64a -> `EAX
      | MOV64o32a | MOV64o64a -> `RAX

    let semantics = Reg_to_mem
  end

  module Mov_ao_ia32 = struct
    type t =
      | MOV8ao16
      | MOV8ao32
      | MOV16ao32
      | MOV32ao32
      | MOV16ao16
      | MOV32ao16
    [@@deriving bin_io, sexp, compare, enumerate]

    let asm_of_t op = match op with
      | MOV8ao16  | MOV8ao32  -> `AL
      | MOV16ao16 | MOV16ao32 -> `AX
      | MOV32ao16 | MOV32ao32 -> `EAX

    let semantics = Mem_to_reg
  end

  module Mov_ao_amd64 = struct
    type t = MOV8ao64 | MOV16ao64 | MOV32ao64 | MOV64ao32 | MOV64ao64
    [@@deriving bin_io, sexp, compare, enumerate]

    let asm_of_t op = match op with
      | MOV8ao64  -> `AL
      | MOV16ao64 -> `AX
      | MOV32ao64 -> `EAX
      | MOV64ao32 | MOV64ao64 -> `RAX

    let semantics = Mem_to_reg
  end
end

module Make(V : Version) = struct
  module IA32 = X86_backend.IA32
  module AMD64 = X86_backend.AMD64
  module Sema32 = Insn_semantics(X86_tools.IA32)
  module Sema64 = Insn_semantics(X86_tools.AMD64)
  open V

  let add insn back sema =
    let module L = (val insn : S) in
    let module B = (val back : X86_backend.S) in
    let module S = (val sema : Semantics) in
    List.iter L.all (fun op ->
        let f = S.lift (L.asm_of_t op) L.semantics V.allow_nil in
        let s = L.sexp_of_t op |> Sexp.to_string in
        B.register s f)

  let register () =
    add (module Mov_oa_ia32)  (module IA32)  (module Sema32);
    add (module Mov_ao_ia32)  (module IA32)  (module Sema32);
    add (module Mov_oa_amd64) (module AMD64) (module Sema64);
    add (module Mov_ao_amd64) (module AMD64) (module Sema64)
end

module T_34 = Make(Ver_34)
module T = Make(Ver_common)

module Self = Self ()

let normalize ver =
  match String.index ver '.' with
  | None -> ver
  | Some i -> match String.sub ver 0 (i + 2) with
    | x -> x
    | exception _ -> ver

let () =
  Bap_main.Extension.declare @@ fun _ctxt ->
  let ver = normalize llvm_version in
  if String.equal ver "3.4"
  then T_34.register ()
  else T.register ();
  Ok ()


# This file is auto-generated by n2y

maintainers:
  - github: SilverRainZ
    email: Shengyu Zhang <la@archlinuxcn.org>

build_prefix: extra-x86_64

pre_build: aur_pre_build

post_build: aur_post_build

update_on:
  - source: aur
    aur: stockfish


<annotation>
<folder>widerface</folder>
<filename>58--Hockey_58_Hockey_icehockey_puck_58_536.jpg</filename>
<source>
<database>wider face Database</database>
<annotation>PASCAL VOC2007</annotation>
<image>flickr</image>
<flickrid>-1</flickrid>
</source>
<owner>
<flickrid>yanyu</flickrid>
<name>yanyu</name>
</owner>
<size>
<width>1024</width>
<height>654</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>face</name>
<pose>Unspecified</pose>
<truncated>1</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>648</xmin>
<ymin>118</ymin>
<xmax>724</xmax>
<ymax>220</ymax>
</bndbox>
<lm>
<x1>653.58</x1>
<y1>156.371</y1>
<x2>688.692</x2>
<y2>162.754</y2>
<x3>663.156</x3>
<y3>184.46</y3>
<x4>667.625</x4>
<y4>196.589</y4>
<x5>685.5</x5>
<y5>197.228</y5>
<visible>0</visible>
<blur>0.62</blur>
</lm>
<has_lm>1</has_lm>
</object>
<object>
<name>face</name>
<pose>Unspecified</pose>
<truncated>1</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>538</xmin>
<ymin>72</ymin>
<xmax>612</xmax>
<ymax>186</ymax>
</bndbox>
<lm>
<x1>550.781</x1>
<y1>116.281</y1>
<x2>577.375</x2>
<y2>117.719</y2>
<x3>555.812</x3>
<y3>142.875</y3>
<x4>557.969</x4>
<y4>158.688</y4>
<x5>579.531</x5>
<y5>156.531</y5>
<visible>0</visible>
<blur>0.67</blur>
</lm>
<has_lm>1</has_lm>
</object>
<object>
<name>face</name>
<pose>Unspecified</pose>
<truncated>1</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>406</xmin>
<ymin>126</ymin>
<xmax>492</xmax>
<ymax>234</ymax>
</bndbox>
<lm>
<x1>428.692</x1>
<y1>170.621</y1>
<x2>462.844</x2>
<y2>167.888</y2>
<x3>447.134</x3>
<y3>195.21</y3>
<x4>432.79</x4>
<y4>200.674</y4>
<x5>464.893</x5>
<y5>197.259</y5>
<visible>0</visible>
<blur>0.7</blur>
</lm>
<has_lm>1</has_lm>
</object>
</annotation>


<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES">
    <device id="retina4_7" orientation="landscape">
        <adaptation id="fullscreen"/>
    </device>
    <dependencies>
        <deployment identifier="iOS"/>
        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    </dependencies>
    <objects>
        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="LiveDemoViewController">
            <connections>
                <outlet property="alphaSlider" destination="SsB-GY-PgB" id="cMB-Fg-ttK"/>
                <outlet property="imageView" destination="S3Q-R7-DIe" id="Yyj-xO-KgA"/>
                <outlet property="panelView" destination="G8w-r5-HXe" id="aiW-2X-7fg"/>
                <outlet property="view" destination="YUW-eb-20i" id="mi2-Zn-1oA"/>
            </connections>
        </placeholder>
        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
        <view clipsSubviews="YES" contentMode="scaleToFill" id="YUW-eb-20i">
            <rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
            <subviews>
                <imageView userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" image="5" translatesAutoresizingMaskIntoConstraints="NO" id="S3Q-R7-DIe">
                    <rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
                    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                </imageView>
                <view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="G8w-r5-HXe">
                    <rect key="frame" x="0.0" y="330" width="667" height="45"/>
                    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
                    <subviews>
                        <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PbJ-kc-WZ4">
                            <rect key="frame" x="17" y="7" width="46" height="30"/>
                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                            <state key="normal" title="Play"/>
                            <connections>
                                <action selector="onPlayBtnClick:" destination="-1" eventType="touchUpInside" id="Nko-FK-gWj"/>
                            </connections>
                        </button>
                        <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sJ8-rs-xRb">
                            <rect key="frame" x="84" y="7" width="56" height="30"/>
                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
                            <state key="normal" title="Pause"/>
                            <connections>
                                <action selector="onPauseBtnClick:" destination="-1" eventType="touchUpInside" id="zHL-9G-BeF"/>
                            </connections>
                        </button>
                        <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="v33-iC-OCl">
                            <rect key="frame" x="600" y="7" width="46" height="30"/>
                            <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
                            <state key="normal" title="Send"/>
                            <connections>
                                <action selector="onSendClick:" destination="-1" eventType="touchUpInside" id="DcX-Wc-asF"/>
                            </connections>
                        </button>
                        <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gRw-iv-X8L">
                            <rect key="frame" x="533" y="7" width="46" height="30"/>
                            <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
                            <state key="normal" title="Set"/>
                            <connections>
                                <action selector="onSetBtnClick:" destination="-1" eventType="touchUpInside" id="vxE-g3-WJz"/>
                            </connections>
                        </button>
                        <slider opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="1" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="SsB-GY-PgB">
                            <rect key="frame" x="262" y="8" width="194" height="31"/>
                            <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
                            <color key="thumbTintColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
                            <connections>
                                <action selector="onAlphaChange:" destination="-1" eventType="valueChanged" id="QLf-To-Nfu"/>
                            </connections>
                        </slider>
                        <slider opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="A2o-HR-FbK">
                            <rect key="frame" x="262" y="44" width="194" height="31"/>
                            <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
                            <color key="thumbTintColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
                            <connections>
                                <action selector="onCountChange:" destination="-1" eventType="valueChanged" id="AiB-aW-gqb"/>
                            </connections>
                        </slider>
                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Alpha " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6PX-7M-etI">
                            <rect key="frame" x="192" y="13" width="70" height="21"/>
                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
                            <color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                            <nil key="highlightedColor"/>
                        </label>
                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Count" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pDi-Tr-Np1">
                            <rect key="frame" x="189" y="49" width="73" height="21"/>
                            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                            <fontDescription key="fontDescription" type="system" pointSize="17"/>
                            <color key="textColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                            <nil key="highlightedColor"/>
                        </label>
                    </subviews>
                    <color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.20000000000000001" colorSpace="calibratedRGB"/>
                </view>
                <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pEn-d0-NJv">
                    <rect key="frame" x="8" y="7" width="38" height="30"/>
                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                    <fontDescription key="fontDescription" type="system" pointSize="25"/>
                    <state key="normal" title="<"/>
                    <connections>
                        <action selector="onBackClick:" destination="-1" eventType="touchUpInside" id="670-G5-wv8"/>
                    </connections>
                </button>
            </subviews>
            <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
            <point key="canvasLocation" x="130.5" y="-69.5"/>
        </view>
    </objects>
    <resources>
        <image name="5" width="1920" height="1080"/>
    </resources>
    <simulatedMetricsContainer key="defaultSimulatedMetrics">
        <simulatedStatusBarMetrics key="statusBar"/>
        <simulatedOrientationMetrics key="orientation" orientation="landscapeRight"/>
        <simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
    </simulatedMetricsContainer>
</document>


<swlist_state xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#hpux" id="oval:org.mitre.oval:ste:24314" version="1">
  <version datatype="fileset_revision" operation="less than">1.6.0.18.00</version>
</swlist_state>


#include "test/jemalloc_test.h"

#define MAXALIGN (((size_t)1) << 22)
#define NITER 3

TEST_BEGIN(test_basic) {
	void *ptr = mallocx(64, 0);
	sdallocx(ptr, 64, 0);
}
TEST_END

TEST_BEGIN(test_alignment_and_size) {
	size_t nsz, sz, alignment, total;
	unsigned i;
	void *ps[NITER];

	for (i = 0; i < NITER; i++) {
		ps[i] = NULL;
	}

	for (alignment = 8;
	    alignment <= MAXALIGN;
	    alignment <<= 1) {
		total = 0;
		for (sz = 1;
		    sz < 3 * alignment && sz < (1U << 31);
		    sz += (alignment >> (LG_SIZEOF_PTR-1)) - 1) {
			for (i = 0; i < NITER; i++) {
				nsz = nallocx(sz, MALLOCX_ALIGN(alignment) |
				    MALLOCX_ZERO);
				ps[i] = mallocx(sz, MALLOCX_ALIGN(alignment) |
				    MALLOCX_ZERO);
				total += nsz;
				if (total >= (MAXALIGN << 1)) {
					break;
				}
			}
			for (i = 0; i < NITER; i++) {
				if (ps[i] != NULL) {
					sdallocx(ps[i], sz,
					    MALLOCX_ALIGN(alignment));
					ps[i] = NULL;
				}
			}
		}
	}
}
TEST_END

int
main(void) {
	return test_no_reentrancy(
	    test_basic,
	    test_alignment_and_size);
}


from collections import OrderedDict

class FrozenDict(OrderedDict):
    """
    Immutable ordered dictionary subclass

    Once constructed, dictionary can not be mutated without
    internal python hacks. Useful for enforcing invariants,
    but not useful for securing anything!

    Uses an OrderedDict as base, to preserve ordering when
    making outputs.
    """

    def __init__(self, *args, **kwargs):
        self.frozen = False
        super(FrozenDict, self).__init__(*args, **kwargs)
        self.frozen = True

    def __readonly__(self, func, *args, **kwargs):
        if self.frozen:
            raise ValueError("Can not modify FrozenDict")
        else:
            return func(*args, **kwargs)

    def __setitem__(self, *args, **kwargs):
        return self.__readonly__(super(FrozenDict, self).__setitem__, *args, **kwargs)

    def __delitem__(self, *args, **kwargs):
        return self.__readonly__(super(FrozenDict, self).__delitem__, *args, **kwargs)

    def pop(self, *args, **kwargs):
        return self.__readonly__(super(FrozenDict, self).pop, *args, **kwargs)

    def popitem(self, *args, **kwargs):
        return self.__readonly__(super(FrozenDict, self).popitem, *args, **kwargs)

    def clear(self, *args, **kwargs):
        return self.__readonly__(super(FrozenDict, self).clear, *args, **kwargs)

    def update(self, *args, **kwargs):
        return self.__readonly__(super(FrozenDict, self).update, *args, **kwargs)

    def setdefault(self, *args, **kwargs):
        return self.__readonly__(super(FrozenDict, self).setdefault, *args, **kwargs)


/*******************************************************************************
 * Copyright (c) 2015-2018 Skymind, Inc.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Apache License, Version 2.0 which is available at
 * https://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.
 *
 * SPDX-License-Identifier: Apache-2.0
 ******************************************************************************/

package org.nd4j.linalg.indexing;

import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.nd4j.common.base.Preconditions;
import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.api.shape.Shape;
import org.nd4j.common.util.ArrayUtil;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * NDArray indexing
 *
 * @author Adam Gibson
 */
@Slf4j
public abstract class NDArrayIndex implements INDArrayIndex {

    private long[] indices;
    private static NewAxis NEW_AXIS = new NewAxis();

    /**
     * Returns a point index
     * @param point the point index
     * @return the point index based
     * on the specified point
     */
    public static INDArrayIndex point(long point) {
        return new PointIndex(point);
    }

    /**
     * Add indexes for the given shape
     * @param shape the shape ot convert to indexes
     * @return the indexes for the given shape
     */
    public static INDArrayIndex[] indexesFor(long... shape) {
        INDArrayIndex[] ret = new INDArrayIndex[shape.length];
        for (int i = 0; i < shape.length; i++) {
            ret[i] = NDArrayIndex.point(shape[i]);
        }

        return ret;
    }

    /**
     * Compute the offset given an array of offsets.
     * The offset is computed(for both fortran an d c ordering) as:
     * sum from i to n - 1 o[i] * s[i]
     * where i is the index o is the offset and s is the stride
     * Notice the -1 at the end.
     * @param arr the array to compute the offset for
     * @param offsets the offsets for each dimension
     * @return the offset that should be used for indexing
     */
    public static long offset(INDArray arr, long... offsets) {
        return offset(arr.stride(), offsets);
    }

    /**
     * Compute the offset given an array of offsets.
     * The offset is computed(for both fortran an d c ordering) as:
     * sum from i to n - 1 o[i] * s[i]
     * where i is the index o is the offset and s is the stride
     * Notice the -1 at the end.
     * @param arr the array to compute the offset for
     * @param indices the offsets for each dimension
     * @return the offset that should be used for indexing
     */
    public static long offset(INDArray arr, INDArrayIndex... indices) {
        return offset(arr.stride(), Indices.offsets(arr.shape(), indices));
    }

    /**
     * Compute the offset given an array of offsets.
     * The offset is computed(for both fortran an d c ordering) as:
     * sum from i to n - 1 o[i] * s[i]
     * where i is the index o is the offset and s is the stride
     * Notice the -1 at the end.
     * @param strides the strides to compute the offset for
     * @param offsets the offsets for each dimension
     * @return the offset that should be used for indexing
     */
    public static long offset(long[] strides, long[] offsets) {
        int ret = 0;

        if (ArrayUtil.prod(offsets) == 1) {
            for (int i = 0; i < offsets.length; i++) {
                ret += offsets[i] * strides[i];
            }
        } else {
            for (int i = 0; i < offsets.length; i++) {
                ret += offsets[i] * strides[i];
            }

        }

        return ret;
    }

    public static long offset(int[] strides, long[] offsets) {
        int ret = 0;

        if (ArrayUtil.prodLong(offsets) == 1) {
            for (int i = 0; i < offsets.length; i++) {
                ret += offsets[i] * strides[i];
            }
        } else {
            for (int i = 0; i < offsets.length; i++) {
                ret += offsets[i] * strides[i];
            }

        }

        return ret;
    }

    /**
     * Repeat a copy of copy n times
     * @param copy the ndarray index to copy
     * @param n the number of times to copy
     * @return an array of length n containing copies of
     * the given ndarray index
     */
    public static INDArrayIndex[] nTimes(INDArrayIndex copy, int n) {
        INDArrayIndex[] ret = new INDArrayIndex[n];
        for (int i = 0; i < n; i++) {
            ret[i] = copy;
        }

        return ret;
    }

    /**
     * NDArrayIndexing based on the given
     * indexes
     * @param indices
     */
    public NDArrayIndex(long... indices) {
        this.indices = indices;
    }

    /**
     * Represents collecting all elements
     *
     * @return an ndarray index
     * meaning collect
     * all elements
     */
    public static INDArrayIndex all() {
        return new NDArrayIndexAll();
    }

    /**
     * Returns an instance of {@link SpecifiedIndex}.
     * Note that SpecifiedIndex works differently than the other indexing options, in that it always returns a copy
     * of the (subset of) the underlying array, for get operations. This means that INDArray.get(..., indices(x,y,z), ...)
     * will be a copy of the relevant subset of the array.
     * @param indices Indices to get
     */
    public static INDArrayIndex indices(long... indices){
        return new SpecifiedIndex(indices);
    }

    /**
     * Represents adding a new dimension
     * @return the indexing for
     * adding a new dimension
     */
    public static INDArrayIndex newAxis() {
        return NEW_AXIS;
    }

    /**
     * Given an all index and
     * the intended indexes, return an
     * index array containing a combination of all elements
     * for slicing and overriding particular indexes where necessary
     * @param arr the array to resolve indexes for
     * @param intendedIndexes the indexes specified by the user
     * @return the resolved indexes (containing all where nothing is specified, and the intended index
     * for a particular dimension otherwise)
     */
    public static INDArrayIndex[] resolve(INDArray arr, INDArrayIndex... intendedIndexes) {
        return resolve(NDArrayIndex.allFor(arr), intendedIndexes);
    }

    /**
     * Number of point indexes
     * @param indexes the indexes
     *                to count for points
     * @return the number of point indexes
     * in the array
     */
    public static int numPoints(INDArrayIndex... indexes) {
        int ret = 0;
        for (int i = 0; i < indexes.length; i++)
            if (indexes[i] instanceof PointIndex)
                ret++;
        return ret;
    }

    /**
     * Given an all index and
     * the intended indexes, return an
     * index array containing a combination of all elements
     * for slicing and overriding particular indexes where necessary
     * @param shapeInfo the index containing all elements
     * @param intendedIndexes the indexes specified by the user
     * @return the resolved indexes (containing all where nothing is specified, and the intended index
     * for a particular dimension otherwise)
     */
    public static INDArrayIndex[] resolveLong(long[] shapeInfo, INDArrayIndex... intendedIndexes) {
        int numSpecified = 0;
        for (int i = 0; i < intendedIndexes.length; i++) {
            if (intendedIndexes[i] instanceof SpecifiedIndex)
                numSpecified++;
        }

        if (numSpecified > 0) {
            val shape = Shape.shapeOf(shapeInfo);
            INDArrayIndex[] ret = new INDArrayIndex[intendedIndexes.length];
            for (int i = 0; i < intendedIndexes.length; i++) {
                if (intendedIndexes[i] instanceof SpecifiedIndex)
                    ret[i] = intendedIndexes[i];
                else {
                    if (intendedIndexes[i] instanceof NDArrayIndexAll) {
                        SpecifiedIndex specifiedIndex = new SpecifiedIndex(ArrayUtil.range(0L, shape[i]));
                        ret[i] = specifiedIndex;
                    } else if (intendedIndexes[i] instanceof IntervalIndex) {
                        IntervalIndex intervalIndex = (IntervalIndex) intendedIndexes[i];
                        ret[i] = new SpecifiedIndex(ArrayUtil.range(intervalIndex.begin, intervalIndex.end(),
                                        intervalIndex.stride()));
                    } else if(intendedIndexes[i] instanceof PointIndex){
                        ret[i] = intendedIndexes[i];
                    }
                }
            }

            return ret;
        }

        /**
         * If it's a vector and index asking
         * for a scalar just return the array
         */
        int rank = Shape.rank(shapeInfo);
        val shape = Shape.shapeOf(shapeInfo);
        if (intendedIndexes.length >= rank || Shape.isVector(shapeInfo) && intendedIndexes.length == 1) {
            if(Shape.rank(shapeInfo) == 1){
                //1D edge case, with 1 index
                return intendedIndexes;
            }

            if (Shape.isRowVectorShape(shapeInfo) && intendedIndexes.length == 1) {
                INDArrayIndex[] ret = new INDArrayIndex[2];
                ret[0] = NDArrayIndex.point(0);
                long size;
                if (1 == shape[0] && rank == 2)
                    size = shape[1];
                else
                    size = shape[0];
                ret[1] = validate(size, intendedIndexes[0]);
                return ret;
            }
            List<INDArrayIndex> retList = new ArrayList<>(intendedIndexes.length);
            for (int i = 0; i < intendedIndexes.length; i++) {
                if (i < rank)
                    retList.add(validate(shape[i], intendedIndexes[i]));
                else
                    retList.add(intendedIndexes[i]);
            }
            return retList.toArray(new INDArrayIndex[retList.size()]);
        }

        List<INDArrayIndex> retList = new ArrayList<>(intendedIndexes.length + 1);
        int numNewAxes = 0;

        if (Shape.isMatrix(shape) && intendedIndexes.length == 1) {
            retList.add(validate(shape[0], intendedIndexes[0]));
            retList.add(NDArrayIndex.all());
        } else {
            for (int i = 0; i < intendedIndexes.length; i++) {
                retList.add(validate(shape[i], intendedIndexes[i]));
                if (intendedIndexes[i] instanceof NewAxis)
                    numNewAxes++;
            }
        }

        int length = rank + numNewAxes;
        //fill the rest with all
        while (retList.size() < length)
            retList.add(NDArrayIndex.all());

        return retList.toArray(new INDArrayIndex[retList.size()]);
    }

    /**
     * Given an all index and
     * the intended indexes, return an
     * index array containing a combination of all elements
     * for slicing and overriding particular indexes where necessary
     * @param shape the index containing all elements
     * @param intendedIndexes the indexes specified by the user
     * @return the resolved indexes (containing all where nothing is specified, and the intended index
     * for a particular dimension otherwise)
     */
    public static INDArrayIndex[] resolve(int[] shape, INDArrayIndex... intendedIndexes) {
        return resolve(ArrayUtil.toLongArray(shape), intendedIndexes);
    }

    public static INDArrayIndex[] resolve(long[] shape, INDArrayIndex... intendedIndexes) {
        /**
         * If it's a vector and index asking for a scalar just return the array
         */
        if (intendedIndexes.length >= shape.length || Shape.isVector(shape) && intendedIndexes.length == 1) {
            if (Shape.isRowVectorShape(shape) && intendedIndexes.length == 1) {
                INDArrayIndex[] ret = new INDArrayIndex[2];
                ret[0] = NDArrayIndex.point(0);
                long size;
                if (1 == shape[0] && shape.length == 2)
                    size = shape[1];
                else
                    size = shape[0];
                ret[1] = validate(size, intendedIndexes[0]);
                return ret;
            }
            List<INDArrayIndex> retList = new ArrayList<>(intendedIndexes.length);
            for (int i = 0; i < intendedIndexes.length; i++) {
                if (i < shape.length)
                    retList.add(validate(shape[i], intendedIndexes[i]));
                else
                    retList.add(intendedIndexes[i]);
            }
            return retList.toArray(new INDArrayIndex[retList.size()]);
        }

        List<INDArrayIndex> retList = new ArrayList<>(intendedIndexes.length + 1);
        int numNewAxes = 0;

        if (Shape.isMatrix(shape) && intendedIndexes.length == 1) {
            retList.add(validate(shape[0], intendedIndexes[0]));
            retList.add(NDArrayIndex.all());
        } else {
            for (int i = 0; i < intendedIndexes.length; i++) {
                retList.add(validate(shape[i], intendedIndexes[i]));
                if (intendedIndexes[i] instanceof NewAxis)
                    numNewAxes++;
            }
        }

        int length = shape.length + numNewAxes;
        //fill the rest with all
        while (retList.size() < length)
            retList.add(NDArrayIndex.all());

        return retList.toArray(new INDArrayIndex[retList.size()]);
    }

    protected static INDArrayIndex validate(long size, INDArrayIndex index) {
        if ((index instanceof IntervalIndex || index instanceof PointIndex) && size <= index.offset())
            throw new IllegalArgumentException("NDArrayIndex is out of range. Beginning index: " + index.offset()
                            + " must be less than its size: " + size);
        if (index instanceof IntervalIndex && index.end() > size)
            throw new IllegalArgumentException("NDArrayIndex is out of range. End index: " + index.end()
                    + " must be less than its size: " + size);
        if (index instanceof IntervalIndex && size < index.end()) {
            long begin = ((IntervalIndex) index).begin;
            index = NDArrayIndex.interval(begin, index.stride(), size);
        }
        return index;
    }

    /**
     * Given an all index and
     * the intended indexes, return an
     * index array containing a combination of all elements
     * for slicing and overriding particular indexes where necessary
     * @param allIndex the index containing all elements
     * @param intendedIndexes the indexes specified by the user
     * @return the resolved indexes (containing all where nothing is specified, and the intended index
     * for a particular dimension otherwise)
     */
    public static INDArrayIndex[] resolve(INDArrayIndex[] allIndex, INDArrayIndex... intendedIndexes) {

        int numNewAxes = numNewAxis(intendedIndexes);
        INDArrayIndex[] all = new INDArrayIndex[allIndex.length + numNewAxes];
        Arrays.fill(all, NDArrayIndex.all());
        for (int i = 0; i < allIndex.length; i++) {
            //collapse single length indexes in to point indexes
            if (i >= intendedIndexes.length)
                break;

            if (intendedIndexes[i] instanceof NDArrayIndex) {
                NDArrayIndex idx = (NDArrayIndex) intendedIndexes[i];
                if (idx.indices.length == 1)
                    intendedIndexes[i] = new PointIndex(idx.indices[0]);
            }
            all[i] = intendedIndexes[i];
        }

        return all;
    }

    /**
     * Given an array of indexes
     * return the number of new axis elements
     * in teh array
     * @param axes the indexes to get the number
     *             of new axes for
     * @return the number of new axis elements in the given array
     */
    public static int numNewAxis(INDArrayIndex... axes) {
        int ret = 0;
        for (INDArrayIndex index : axes)
            if (index instanceof NewAxis)
                ret++;
        return ret;
    }

    /**
     * Generate an all index
     * equal to the rank of the given array
     * @param arr the array to generate the all index for
     * @return an ndarray index array containing of length
     * arr.rank() containing all elements
     */
    public static INDArrayIndex[] allFor(INDArray arr) {
        INDArrayIndex[] ret = new INDArrayIndex[arr.rank()];
        for (int i = 0; i < ret.length; i++)
            ret[i] = NDArrayIndex.all();

        return ret;
    }

    /**
     * Creates an index covering the given shape
     * (for each dimension 0,shape[i])
     * @param shape the shape to cover
     * @return the ndarray indexes to cover
     */
    public static INDArrayIndex[] createCoveringShape(int[] shape) {
        INDArrayIndex[] ret = new INDArrayIndex[shape.length];
        for (int i = 0; i < ret.length; i++) {
            ret[i] = NDArrayIndex.interval(0, shape[i]);
        }
        return ret;
    }

    public static INDArrayIndex[] createCoveringShape(long[] shape) {
        INDArrayIndex[] ret = new INDArrayIndex[shape.length];
        for (int i = 0; i < ret.length; i++) {
            ret[i] = NDArrayIndex.interval(0, shape[i]);
        }
        return ret;
    }

    /**
     * Create a range based on the given indexes.
     * This is similar to create covering shape in that it approximates
     * the length of each dimension (ignoring elements) and
     * reproduces an index of the same dimension and length.
     *
     * @param indexes the indexes to create the range for
     * @return the index ranges.
     */
    public static INDArrayIndex[] rangeOfLength(INDArrayIndex[] indexes) {
        INDArrayIndex[] indexesRet = new INDArrayIndex[indexes.length];
        for (int i = 0; i < indexes.length; i++)
            indexesRet[i] = NDArrayIndex.interval(0, indexes[i].length());
        return indexesRet;
    }

    /**
     * Generates an interval from begin (inclusive) to end (exclusive)
     *
     * @param begin the begin
     * @param stride  the stride at which to increment
     * @param end   the end index
     * @param max the max length for this domain
     * @return the interval
     */
    public static INDArrayIndex interval(long begin, long stride, long end,long max) {
        if(begin < 0) {
            begin += max;
        }

        if(end < 0) {
            end += max;
        }

        if (Math.abs(begin - end) < 1)
            end++;
        if (stride > 1 && Math.abs(begin - end) == 1) {
            end *= stride;
        }
        return interval(begin, stride, end, false);
    }

    /**
     * Generates an interval from begin (inclusive) to end (exclusive)
     *
     * @param begin the begin
     * @param stride  the stride at which to increment
     * @param end   the end index
     * @return the interval
     */
    public static INDArrayIndex interval(long begin, long stride, long end) {
        if (Math.abs(begin - end) < 1)
            end++;
        if (stride > 1 && Math.abs(begin - end) == 1) {
            end *= stride;
        }
        return interval(begin, stride, end, false);
    }

    /**
     * Generates an interval from begin (inclusive) to end (exclusive)
     *
     * @param begin     the begin
     * @param stride the stride at which to increment
     * @param end       the end index
     * @param inclusive whether the end should be inclusive or not
     * @return the interval
     */
    public static INDArrayIndex interval(int begin, int stride, int end, boolean inclusive) {
        Preconditions.checkArgument(begin <= end, "Beginning index (%s) in range must be less than or equal to end (%s)", begin, end);
        INDArrayIndex index = new IntervalIndex(inclusive, stride);
        index.init(begin, end);
        return index;
    }

    public static INDArrayIndex interval(long begin, long stride, long end,long max, boolean inclusive) {
        Preconditions.checkArgument(begin <= end, "Beginning index (%s) in range must be less than or equal to end (%s)", begin, end);
        INDArrayIndex index = new IntervalIndex(inclusive, stride);
        index.init(begin, end);
        return index;
    }

    public static INDArrayIndex interval(long begin, long stride, long end, boolean inclusive) {
        Preconditions.checkArgument(begin <= end, "Beginning index (%s) in range must be less than or equal to end (%s)", begin, end);
        INDArrayIndex index = new IntervalIndex(inclusive, stride);
        index.init(begin, end);
        return index;
    }

    /**
     * Generates an interval from begin (inclusive) to end (exclusive)
     *
     * @param begin the begin
     * @param end   the end index
     * @return the interval
     */
    public static INDArrayIndex interval(int begin, int end) {
        return interval(begin, 1, end, false);
    }

    public static INDArrayIndex interval(long begin, long end) {
        return interval(begin, 1, end, false);
    }

    /**
     * Generates an interval from begin (inclusive) to end (exclusive)
     *
     * @param begin     the begin
     * @param end       the end index
     * @param inclusive whether the end should be inclusive or not
     * @return the interval
     */
    public static INDArrayIndex interval(long begin, long end, boolean inclusive) {
        return interval(begin, 1, end, inclusive);
    }

    @Override
    public long end() {
        if (indices != null && indices.length > 0)
            return indices[indices.length - 1];
        return 0;
    }

    @Override
    public long offset() {
        if (indices.length < 1)
            return 0;
        return indices[0];
    }

    /**
     * Returns the length of the indices
     *
     * @return the length of the range
     */
    @Override
    public long length() {
        return indices.length;
    }

    @Override
    public long stride() {
        return 1;
    }

    @Override
    public void reverse() {
        ArrayUtil.reverse(indices);
    }

    @Override
    public String toString() {
        return "NDArrayIndex{" + "indices=" + Arrays.toString(indices) + '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o)
            return true;
        if (!(o instanceof INDArrayIndex))
            return false;

        NDArrayIndex that = (NDArrayIndex) o;

        if (!Arrays.equals(indices, that.indices))
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        return Arrays.hashCode(indices);
    }

    @Override
    public void init(INDArray arr, long begin, int dimension) {

    }

    @Override
    public void init(INDArray arr, int dimension) {

    }

    @Override
    public void init(long begin, long end, long max) {

    }

    @Override
    public void init(long begin, long end) {

    }

}


/* ----------------------------------------------------------------------
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
*
* $Date:        19. March 2015
* $Revision: 	V.1.4.5
*
* Project: 	    CMSIS DSP Library
* Title:	    arm_biquad_cascade_df2T_f32.c
*
* Description:  Processing function for the floating-point transposed
*               direct form II Biquad cascade filter.
*
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*   - Redistributions of source code must retain the above copyright
*     notice, this list of conditions and the following disclaimer.
*   - Redistributions in binary form must reproduce the above copyright
*     notice, this list of conditions and the following disclaimer in
*     the documentation and/or other materials provided with the
*     distribution.
*   - Neither the name of ARM LIMITED nor the names of its contributors
*     may be used to endorse or promote products derived from this
*     software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
* -------------------------------------------------------------------- */

#include "arm_math.h"

/**
* @ingroup groupFilters
*/

/**
* @defgroup BiquadCascadeDF2T Biquad Cascade IIR Filters Using a Direct Form II Transposed Structure
*
* This set of functions implements arbitrary order recursive (IIR) filters using a transposed direct form II structure.
* The filters are implemented as a cascade of second order Biquad sections.
* These functions provide a slight memory savings as compared to the direct form I Biquad filter functions.
* Only floating-point data is supported.
*
* This function operate on blocks of input and output data and each call to the function
* processes blockSize samples through the filter.
* pSrc points to the array of input data and
* pDst points to the array of output data.
* Both arrays contain blockSize values.
*
* \par Algorithm
* Each Biquad stage implements a second order filter using the difference equation:
*

*    y[n] = b0 * x[n] + d1
*    d1 = b1 * x[n] + a1 * y[n] + d2
*    d2 = b2 * x[n] + a2 * y[n]
*

* where d1 and d2 represent the two state values.
*
* \par
* A Biquad filter using a transposed Direct Form II structure is shown below.
* \image html BiquadDF2Transposed.gif "Single transposed Direct Form II Biquad"
* Coefficients b0, b1, and b2  multiply the input signal x[n] and are referred to as the feedforward coefficients.
* Coefficients a1 and a2 multiply the output signal y[n] and are referred to as the feedback coefficients.
* Pay careful attention to the sign of the feedback coefficients.
* Some design tools flip the sign of the feedback coefficients:
*

*    y[n] = b0 * x[n] + d1;
*    d1 = b1 * x[n] - a1 * y[n] + d2;
*    d2 = b2 * x[n] - a2 * y[n];
*

* In this case the feedback coefficients a1 and a2 must be negated when used with the CMSIS DSP Library.
*
* \par
* Higher order filters are realized as a cascade of second order sections.
* numStages refers to the number of second order stages used.
* For example, an 8th order filter would be realized with numStages=4 second order stages.
* A 9th order filter would be realized with numStages=5 second order stages with the
* coefficients for one of the stages configured as a first order filter (b2=0 and a2=0).
*
* \par
* pState points to the state variable array.
* Each Biquad stage has 2 state variables d1 and d2.
* The state variables are arranged in the pState array as:
*

*     {d11, d12, d21, d22, ...}
*

* where d1x refers to the state variables for the first Biquad and
* d2x refers to the state variables for the second Biquad.
* The state array has a total length of 2*numStages values.
* The state variables are updated after each block of data is processed; the coefficients are untouched.
*
* \par
* The CMSIS library contains Biquad filters in both Direct Form I and transposed Direct Form II.
* The advantage of the Direct Form I structure is that it is numerically more robust for fixed-point data types.
* That is why the Direct Form I structure supports Q15 and Q31 data types.
* The transposed Direct Form II structure, on the other hand, requires a wide dynamic range for the state variables d1 and d2.
* Because of this, the CMSIS library only has a floating-point version of the Direct Form II Biquad.
* The advantage of the Direct Form II Biquad is that it requires half the number of state variables, 2 rather than 4, per Biquad stage.
*
* \par Instance Structure
* The coefficients and state variables for a filter are stored together in an instance data structure.
* A separate instance structure must be defined for each filter.
* Coefficient arrays may be shared among several instances while state variable arrays cannot be shared.
*
* \par Init Functions
* There is also an associated initialization function.
* The initialization function performs following operations:
* - Sets the values of the internal structure fields.
* - Zeros out the values in the state buffer.
* To do this manually without calling the init function, assign the follow subfields of the instance structure:
* numStages, pCoeffs, pState. Also set all of the values in pState to zero.
*
* \par
* Use of the initialization function is optional.
* However, if the initialization function is used, then the instance structure cannot be placed into a const data section.
* To place an instance structure into a const data section, the instance structure must be manually initialized.
* Set the values in the state buffer to zeros before static initialization.
* For example, to statically initialize the instance structure use
*

*     arm_biquad_cascade_df2T_instance_f32 S1 = {numStages, pState, pCoeffs};
*

* where numStages is the number of Biquad stages in the filter; pState is the address of the state buffer.
* pCoeffs is the address of the coefficient buffer;
*
*/

/**
* @addtogroup BiquadCascadeDF2T
* @{
*/

/**
* @brief Processing function for the floating-point transposed direct form II Biquad cascade filter.
* @param[in]  *S        points to an instance of the filter data structure.
* @param[in]  *pSrc     points to the block of input data.
* @param[out] *pDst     points to the block of output data
* @param[in]  blockSize number of samples to process.
* @return none.
*/

LOW_OPTIMIZATION_ENTER
void arm_biquad_cascade_df2T_f32(
const arm_biquad_cascade_df2T_instance_f32 * S,
float32_t * pSrc,
float32_t * pDst,
uint32_t blockSize)
{

   float32_t *pIn = pSrc;                         /*  source pointer            */
   float32_t *pOut = pDst;                        /*  destination pointer       */
   float32_t *pState = S->pState;                 /*  State pointer             */
   float32_t *pCoeffs = S->pCoeffs;               /*  coefficient pointer       */
   float32_t acc1;                                /*  accumulator               */
   float32_t b0, b1, b2, a1, a2;                  /*  Filter coefficients       */
   float32_t Xn1;                                 /*  temporary input           */
   float32_t d1, d2;                              /*  state variables           */
   uint32_t sample, stage = S->numStages;         /*  loop counters             */

#if defined(ARM_MATH_CM7)

   float32_t Xn2, Xn3, Xn4, Xn5, Xn6, Xn7, Xn8;   /*  Input State variables     */
   float32_t Xn9, Xn10, Xn11, Xn12, Xn13, Xn14, Xn15, Xn16;
   float32_t acc2, acc3, acc4, acc5, acc6, acc7;  /*  Simulates the accumulator */
   float32_t acc8, acc9, acc10, acc11, acc12, acc13, acc14, acc15, acc16;

   do
   {
      /* Reading the coefficients */
      b0 = pCoeffs[0];
      b1 = pCoeffs[1];
      b2 = pCoeffs[2];
      a1 = pCoeffs[3];
      /* Apply loop unrolling and compute 16 output values simultaneously. */
      sample = blockSize >> 4u;
      a2 = pCoeffs[4];

      /*Reading the state values */
      d1 = pState[0];
      d2 = pState[1];

      pCoeffs += 5u;

      /* First part of the processing with loop unrolling.  Compute 16 outputs at a time.
       ** a second loop below computes the remaining 1 to 15 samples. */
      while(sample > 0u) {

         /* y[n] = b0 * x[n] + d1 */
         /* d1 = b1 * x[n] + a1 * y[n] + d2 */
         /* d2 = b2 * x[n] + a2 * y[n] */

         /* Read the first 2 inputs. 2 cycles */
         Xn1  = pIn[0 ];
         Xn2  = pIn[1 ];

         /* Sample 1. 5 cycles */
         Xn3  = pIn[2 ];
         acc1 = b0 * Xn1 + d1;

         Xn4  = pIn[3 ];
         d1 = b1 * Xn1 + d2;

         Xn5  = pIn[4 ];
         d2 = b2 * Xn1;

         Xn6  = pIn[5 ];
         d1 += a1 * acc1;

         Xn7  = pIn[6 ];
         d2 += a2 * acc1;

         /* Sample 2. 5 cycles */
         Xn8  = pIn[7 ];
         acc2 = b0 * Xn2 + d1;

         Xn9  = pIn[8 ];
         d1 = b1 * Xn2 + d2;

         Xn10 = pIn[9 ];
         d2 = b2 * Xn2;

         Xn11 = pIn[10];
         d1 += a1 * acc2;

         Xn12 = pIn[11];
         d2 += a2 * acc2;

         /* Sample 3. 5 cycles */
         Xn13 = pIn[12];
         acc3 = b0 * Xn3 + d1;

         Xn14 = pIn[13];
         d1 = b1 * Xn3 + d2;

         Xn15 = pIn[14];
         d2 = b2 * Xn3;

         Xn16 = pIn[15];
         d1 += a1 * acc3;

         pIn += 16;
         d2 += a2 * acc3;

         /* Sample 4. 5 cycles */
         acc4 = b0 * Xn4 + d1;
         d1 = b1 * Xn4 + d2;
         d2 = b2 * Xn4;
         d1 += a1 * acc4;
         d2 += a2 * acc4;

         /* Sample 5. 5 cycles */
         acc5 = b0 * Xn5 + d1;
         d1 = b1 * Xn5 + d2;
         d2 = b2 * Xn5;
         d1 += a1 * acc5;
         d2 += a2 * acc5;

         /* Sample 6. 5 cycles */
         acc6 = b0 * Xn6 + d1;
         d1 = b1 * Xn6 + d2;
         d2 = b2 * Xn6;
         d1 += a1 * acc6;
         d2 += a2 * acc6;

         /* Sample 7. 5 cycles */
         acc7 = b0 * Xn7 + d1;
         d1 = b1 * Xn7 + d2;
         d2 = b2 * Xn7;
         d1 += a1 * acc7;
         d2 += a2 * acc7;

         /* Sample 8. 5 cycles */
         acc8 = b0 * Xn8 + d1;
         d1 = b1 * Xn8 + d2;
         d2 = b2 * Xn8;
         d1 += a1 * acc8;
         d2 += a2 * acc8;

         /* Sample 9. 5 cycles */
         acc9 = b0 * Xn9 + d1;
         d1 = b1 * Xn9 + d2;
         d2 = b2 * Xn9;
         d1 += a1 * acc9;
         d2 += a2 * acc9;

         /* Sample 10. 5 cycles */
         acc10 = b0 * Xn10 + d1;
         d1 = b1 * Xn10 + d2;
         d2 = b2 * Xn10;
         d1 += a1 * acc10;
         d2 += a2 * acc10;

         /* Sample 11. 5 cycles */
         acc11 = b0 * Xn11 + d1;
         d1 = b1 * Xn11 + d2;
         d2 = b2 * Xn11;
         d1 += a1 * acc11;
         d2 += a2 * acc11;

         /* Sample 12. 5 cycles */
         acc12 = b0 * Xn12 + d1;
         d1 = b1 * Xn12 + d2;
         d2 = b2 * Xn12;
         d1 += a1 * acc12;
         d2 += a2 * acc12;

         /* Sample 13. 5 cycles */
         acc13 = b0 * Xn13 + d1;
         d1 = b1 * Xn13 + d2;
         d2 = b2 * Xn13;

         pOut[0 ] = acc1 ;
         d1 += a1 * acc13;

         pOut[1 ] = acc2 ;
         d2 += a2 * acc13;

         /* Sample 14. 5 cycles */
         pOut[2 ] = acc3 ;
         acc14 = b0 * Xn14 + d1;

         pOut[3 ] = acc4 ;
         d1 = b1 * Xn14 + d2;

         pOut[4 ] = acc5 ;
         d2 = b2 * Xn14;

         pOut[5 ] = acc6 ;
         d1 += a1 * acc14;

         pOut[6 ] = acc7 ;
         d2 += a2 * acc14;

         /* Sample 15. 5 cycles */
         pOut[7 ] = acc8 ;
         pOut[8 ] = acc9 ;
         acc15 = b0 * Xn15 + d1;

         pOut[9 ] = acc10;
         d1 = b1 * Xn15 + d2;

         pOut[10] = acc11;
         d2 = b2 * Xn15;

         pOut[11] = acc12;
         d1 += a1 * acc15;

         pOut[12] = acc13;
         d2 += a2 * acc15;

         /* Sample 16. 5 cycles */
         pOut[13] = acc14;
         acc16 = b0 * Xn16 + d1;

         pOut[14] = acc15;
         d1 = b1 * Xn16 + d2;

         pOut[15] = acc16;
         d2 = b2 * Xn16;

         sample--;
         d1 += a1 * acc16;

         pOut += 16;
         d2 += a2 * acc16;
      }

      sample = blockSize & 0xFu;
      while(sample > 0u) {
         Xn1 = *pIn;
         acc1 = b0 * Xn1 + d1;

         pIn++;
         d1 = b1 * Xn1 + d2;

         *pOut = acc1;
         d2 = b2 * Xn1;

         pOut++;
         d1 += a1 * acc1;

         sample--;
         d2 += a2 * acc1;
      }

      /* Store the updated state variables back into the state array */
      pState[0] = d1;
      /* The current stage input is given as the output to the next stage */
      pIn = pDst;

      pState[1] = d2;
      /* decrement the loop counter */
      stage--;

      pState += 2u;

      /*Reset the output working pointer */
      pOut = pDst;

   } while(stage > 0u);

#elif defined(ARM_MATH_CM0_FAMILY)

   /* Run the below code for Cortex-M0 */

   do
   {
      /* Reading the coefficients */
      b0 = *pCoeffs++;
      b1 = *pCoeffs++;
      b2 = *pCoeffs++;
      a1 = *pCoeffs++;
      a2 = *pCoeffs++;

      /*Reading the state values */
      d1 = pState[0];
      d2 = pState[1];

      sample = blockSize;

      while(sample > 0u)
      {
         /* Read the input */
         Xn1 = *pIn++;

         /* y[n] = b0 * x[n] + d1 */
         acc1 = (b0 * Xn1) + d1;

         /* Store the result in the accumulator in the destination buffer. */
         *pOut++ = acc1;

         /* Every time after the output is computed state should be updated. */
         /* d1 = b1 * x[n] + a1 * y[n] + d2 */
         d1 = ((b1 * Xn1) + (a1 * acc1)) + d2;

         /* d2 = b2 * x[n] + a2 * y[n] */
         d2 = (b2 * Xn1) + (a2 * acc1);

         /* decrement the loop counter */
         sample--;
      }

      /* Store the updated state variables back into the state array */
      *pState++ = d1;
      *pState++ = d2;

      /* The current stage input is given as the output to the next stage */
      pIn = pDst;

      /*Reset the output working pointer */
      pOut = pDst;

      /* decrement the loop counter */
      stage--;

   } while(stage > 0u);

#else

   float32_t Xn2, Xn3, Xn4;                  	  /*  Input State variables     */
   float32_t acc2, acc3, acc4;              		  /*  accumulator               */

   float32_t p0, p1, p2, p3, p4, A1;

   /* Run the below code for Cortex-M4 and Cortex-M3 */
   do
   {
      /* Reading the coefficients */
      b0 = *pCoeffs++;
      b1 = *pCoeffs++;
      b2 = *pCoeffs++;
      a1 = *pCoeffs++;
      a2 = *pCoeffs++;

      /*Reading the state values */
      d1 = pState[0];
      d2 = pState[1];

      /* Apply loop unrolling and compute 4 output values simultaneously. */
      sample = blockSize >> 2u;

      /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.
   ** a second loop below computes the remaining 1 to 3 samples. */
      while(sample > 0u) {

         /* y[n] = b0 * x[n] + d1 */
         /* d1 = b1 * x[n] + a1 * y[n] + d2 */
         /* d2 = b2 * x[n] + a2 * y[n] */

         /* Read the four inputs */
         Xn1 = pIn[0];
         Xn2 = pIn[1];
         Xn3 = pIn[2];
         Xn4 = pIn[3];
         pIn += 4;

         p0 = b0 * Xn1;
         p1 = b1 * Xn1;
         acc1 = p0 + d1;
         p0 = b0 * Xn2;
         p3 = a1 * acc1;
         p2 = b2 * Xn1;
         A1 = p1 + p3;
         p4 = a2 * acc1;
         d1 = A1 + d2;
         d2 = p2 + p4;

         p1 = b1 * Xn2;
         acc2 = p0 + d1;
         p0 = b0 * Xn3;
         p3 = a1 * acc2;
         p2 = b2 * Xn2;
         A1 = p1 + p3;
         p4 = a2 * acc2;
         d1 = A1 + d2;
         d2 = p2 + p4;

         p1 = b1 * Xn3;
         acc3 = p0 + d1;
         p0 = b0 * Xn4;
         p3 = a1 * acc3;
         p2 = b2 * Xn3;
         A1 = p1 + p3;
         p4 = a2 * acc3;
         d1 = A1 + d2;
         d2 = p2 + p4;

         acc4 = p0 + d1;
         p1 = b1 * Xn4;
         p3 = a1 * acc4;
         p2 = b2 * Xn4;
         A1 = p1 + p3;
         p4 = a2 * acc4;
         d1 = A1 + d2;
         d2 = p2 + p4;

         pOut[0] = acc1;
         pOut[1] = acc2;
         pOut[2] = acc3;
         pOut[3] = acc4;
		 pOut += 4;

         sample--;
      }

      sample = blockSize & 0x3u;
      while(sample > 0u) {
         Xn1 = *pIn++;

         p0 = b0 * Xn1;
         p1 = b1 * Xn1;
         acc1 = p0 + d1;
         p3 = a1 * acc1;
         p2 = b2 * Xn1;
         A1 = p1 + p3;
         p4 = a2 * acc1;
         d1 = A1 + d2;
         d2 = p2 + p4;

         *pOut++ = acc1;

         sample--;
      }

      /* Store the updated state variables back into the state array */
      *pState++ = d1;
      *pState++ = d2;

      /* The current stage input is given as the output to the next stage */
      pIn = pDst;

      /*Reset the output working pointer */
      pOut = pDst;

      /* decrement the loop counter */
      stage--;

   } while(stage > 0u);

#endif

}
LOW_OPTIMIZATION_EXIT

/**
   * @} end of BiquadCascadeDF2T group
   */


// automatically generated by the FlatBuffers compiler, do not modify

package com.nvidia.spark.rapids.format;

import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;

@SuppressWarnings("unused")
/**
 * Descriptor for a buffer within another uncompressed buffer.
 */
public final class SubBufferMeta extends Struct {
  public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
  public SubBufferMeta __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }

  /**
   * byte-offset from the start of the buffer where this buffer begins
   */
  public long offset() { return bb.getLong(bb_pos + 0); }
  public void mutateOffset(long offset) { bb.putLong(bb_pos + 0, offset); }
  /**
   * size in bytes of the buffer
   */
  public long length() { return bb.getLong(bb_pos + 8); }
  public void mutateLength(long length) { bb.putLong(bb_pos + 8, length); }

  public static int createSubBufferMeta(FlatBufferBuilder builder, long offset, long length) {
    builder.prep(8, 16);
    builder.putLong(length);
    builder.putLong(offset);
    return builder.offset();
  }
}


#!/usr/bin/python

from jinja2 import Environment, FileSystemLoader
import traceback, cgi, time, sys, os, shutil
from docs import gen_docs

glfx_file = '../glfx.js'
source_dir = '../src/'
template_dir = './templates/'
output_dir = './glfx.js/'

html = '
Error rendering %s

An error was encountered while rendering the file %s.  Here is the stack trace:

%s
'

def do(files):
    if not os.path.exists(output_dir):
        os.makedirs(output_dir)
    shutil.copy(glfx_file, os.path.join(output_dir, os.path.basename(glfx_file)))
    docs = gen_docs()
    for file in files:
        file = file.replace(template_dir, '')
        if file == 'base.html' or not file.endswith('.html'):
            continue
        new_file = output_dir + file
        if file != 'index.html':
            directory = output_dir + file[0:-5]
            if not os.path.exists(directory):
                os.makedirs(directory)
            new_file = directory + '/index.html'
        f = open(new_file, 'w')
        try:
            f.write(env.get_template(file).render(debug=debug, docs=docs))
            print 'success -', file
        except:
            print traceback.format_exc()
            f.write(html % (cgi.escape(file), cgi.escape(os.getcwd() + '/' + file), cgi.escape(traceback.format_exc())))
            print 'error -', file
        f.close()

def stat(files):
    return [os.stat(file).st_mtime for file in files]

def findfiles(path, ext):
    return [os.path.join(base, f) for base, folders, files in \
        os.walk(path) for f in files if f.endswith(ext)]

def files():
    return findfiles(source_dir, '.js') + findfiles(template_dir, '.html') + [glfx_file]

debug = 'debug' in sys.argv
env = Environment(loader=FileSystemLoader(template_dir))

do(files())
if debug:
    a = stat(files())
    while True:
        time.sleep(1)
        b = stat(files())
        if a != b:
            a = b
            do(files())


/*
 * Copyright (C) 2019 Peng fei Pan <panpfpanpf@outlook.me>
 *
 * 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.
 */

package me.panpf.sketch;

import android.app.Application;
import android.content.ComponentCallbacks2;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.widget.ImageView;

import androidx.annotation.DrawableRes;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import me.panpf.sketch.request.CancelCause;
import me.panpf.sketch.request.DisplayHelper;
import me.panpf.sketch.request.DisplayRequest;
import me.panpf.sketch.request.DownloadHelper;
import me.panpf.sketch.request.DownloadListener;
import me.panpf.sketch.request.LoadHelper;
import me.panpf.sketch.request.LoadListener;
import me.panpf.sketch.uri.AssetUriModel;
import me.panpf.sketch.uri.DrawableUriModel;
import me.panpf.sketch.util.SketchUtils;

/**
 * {@link Sketch} 是一个功能强大且全面的图片加载器，可以从网络或者本地加载图片，支持 gif、手势缩放以及分块显示超大图
 *

 *
{@link #display(String, SketchView)}：显示图片到 {@link SketchImageView} 上

 *
{@link #load(String, LoadListener)}：加载图片到内存中

 *
{@link #download(String, DownloadListener)}：下载图片到磁盘上

 *

 */
public class Sketch {
    public static final String META_DATA_KEY_INITIALIZER = "SKETCH_INITIALIZER";

    @Nullable
    private static volatile Sketch instance;
    @NonNull
    private Configuration configuration;

    private Sketch(@NonNull Context context) {
        this.configuration = new Configuration(context);
    }

    /**
     * Get a unique instance
     */
    @NonNull
    public static Sketch with(@NonNull Context context) {
        Sketch oldInstance = instance;
        if (oldInstance != null) return oldInstance;

        synchronized (Sketch.class) {
            oldInstance = instance;
            if (oldInstance != null) return oldInstance;

            Sketch newInstance = new Sketch(context);
            SLog.i(null, "Version %s %s(%d) -> %s",
                    BuildConfig.BUILD_TYPE, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, newInstance.configuration.toString());

            Initializer initializer = SketchUtils.findInitializer(context);
            if (initializer != null) {
                initializer.onInitialize(context.getApplicationContext(), newInstance.configuration);
            }
            instance = newInstance;
            return newInstance;
        }
    }

    /**
     * 取消请求
     *
     * @param sketchView 会通过 {@link SketchView} 的 {@link Drawable} 找到正在执行的请求，然后取消它
     * @return true：当前 {@link SketchView} 有正在执行的任务并且取消成功；false：当前 {@link SketchView} 没有正在执行的任务
     */
    public static boolean cancel(@NonNull SketchView sketchView) {
        final DisplayRequest displayRequest = SketchUtils.findDisplayRequest(sketchView);
        if (displayRequest != null && !displayRequest.isFinished()) {
            displayRequest.cancel(CancelCause.BE_CANCELLED);
            return true;
        } else {
            return false;
        }
    }

    /**
     * 获取配置对象
     *
     * @return {@link Configuration}
     */
    @NonNull
    public Configuration getConfiguration() {
        return configuration;
    }

    /**
     * 根据指定的 uri 下载图片
     *
     * @param uri      图片 uri，只支持 http:// 和 https://
     * @param listener 监听下载过程
     * @return {@link DownloadHelper} 你可以继续通过 {@link DownloadHelper} 设置参数，最后调用其 {@link DownloadHelper#commit()} 方法提交
     */
    @NonNull
    public DownloadHelper download(@NonNull String uri, @Nullable DownloadListener listener) {
        return configuration.getHelperFactory().getDownloadHelper(this, uri, listener);
    }

    /**
     * 根据指定的 uri 加载图片到内存中
     *
     * @param uri      图片 uri，支持全部的 uri 类型，请参考 https://github.com/panpf/sketch/blob/master/docs/wiki/uri.md
     * @param listener 监听下载过程
     * @return {@link LoadHelper} 你可以继续通过 {@link LoadHelper} 设置参数，最后调用其 {@link LoadHelper#commit()} 方法提交
     */
    @NonNull
    public LoadHelper load(@NonNull String uri, @Nullable LoadListener listener) {
        return configuration.getHelperFactory().getLoadHelper(this, uri, listener);
    }

    /**
     * 加载 assets 资源图片
     *
     * @param assetFileName assets 文件夹下的图片文件的名称
     * @param listener      监听加载过程
     * @return {@link LoadHelper} 你可以继续通过 {@link LoadHelper} 设置参数，最后调用其 {@link LoadHelper#commit()} 方法提交
     */
    @NonNull
    public LoadHelper loadFromAsset(@NonNull String assetFileName, @Nullable LoadListener listener) {
        String uri = AssetUriModel.makeUri(assetFileName);
        return configuration.getHelperFactory().getLoadHelper(this, uri, listener);
    }

    /**
     * 加载 drawable 资源图片
     *
     * @param drawableResId drawable 资源 id
     * @param listener      监听加载过程
     * @return {@link LoadHelper} 你可以继续通过 {@link LoadHelper} 设置参数，最后调用其 {@link LoadHelper#commit()} 方法提交
     */
    @NonNull
    public LoadHelper loadFromResource(@DrawableRes int drawableResId, @Nullable LoadListener listener) {
        String uri = DrawableUriModel.makeUri(drawableResId);
        return configuration.getHelperFactory().getLoadHelper(this, uri, listener);
    }

    /**
     * 加载来自 {@link ContentProvider} 的图片
     *
     * @param uri      来自 {@link ContentProvider} 的图片 uri，例如：content://、file://，使用 {@link ContentResolver#openInputStream(Uri)} api 读取图片
     * @param listener 监听加载过程
     * @return {@link LoadHelper} 你可以继续通过 {@link LoadHelper} 设置参数，最后调用其 {@link LoadHelper#commit()} 方法提交
     */
    @NonNull
    public LoadHelper loadFromContent(@NonNull String uri, @Nullable LoadListener listener) {
        return configuration.getHelperFactory().getLoadHelper(this, uri, listener);
    }

    /**
     * 根据指定的 uri 显示图片
     *
     * @param uri        图片 uri，支持全部的 uri 类型，请参考 https://github.com/panpf/sketch/blob/master/docs/wiki/uri.md
     * @param sketchView {@link Sketch} 对 {@link ImageView} 的规范接口，默认实现是 {@link SketchImageView}
     * @return {@link DisplayHelper} 你可以继续通过 {@link DisplayHelper} 设置参数，最后调用其 {@link DisplayHelper#commit()} 方法提交
     */
    @NonNull
    public DisplayHelper display(@Nullable String uri, @NonNull SketchView sketchView) {
        return configuration.getHelperFactory().getDisplayHelper(this, uri, sketchView);
    }

    /**
     * 显示 assets 资源图片
     *
     * @param assetFileName assets 文件夹下的图片文件的名称
     * @param sketchView    {@link Sketch} 对 {@link ImageView} 的规范接口，默认实现是 {@link SketchImageView}
     * @return {@link DisplayHelper} 你可以继续通过 {@link DisplayHelper} 设置参数，最后调用其 {@link DisplayHelper#commit()} 方法提交
     */
    @NonNull
    public DisplayHelper displayFromAsset(@NonNull String assetFileName, @NonNull SketchView sketchView) {
        String uri = AssetUriModel.makeUri(assetFileName);
        return configuration.getHelperFactory().getDisplayHelper(this, uri, sketchView);
    }

    /**
     * 显示 drawable 资源图片
     *
     * @param drawableResId drawable 资源 id
     * @param sketchView    {@link Sketch} 对 {@link ImageView} 的规范接口，默认实现是 {@link SketchImageView}
     * @return {@link DisplayHelper} 你可以继续通过 {@link DisplayHelper} 设置参数，最后调用其 {@link DisplayHelper#commit()} 方法提交
     */
    @NonNull
    public DisplayHelper displayFromResource(@DrawableRes int drawableResId, @NonNull SketchView sketchView) {
        String uri = DrawableUriModel.makeUri(drawableResId);
        return configuration.getHelperFactory().getDisplayHelper(this, uri, sketchView);
    }

    /**
     * 显示来自 {@link ContentProvider} 的图片
     *
     * @param uri        来自 {@link ContentProvider} 的图片 uri，例如：content://、file://，使用 {@link ContentResolver#openInputStream(Uri)} api 读取图片
     * @param sketchView {@link Sketch} 对 {@link ImageView} 的规范接口，默认实现是 {@link SketchImageView}
     * @return {@link DisplayHelper} 你可以继续通过 {@link DisplayHelper} 设置参数，最后调用其 {@link DisplayHelper#commit()} 方法提交
     */
    @NonNull
    public DisplayHelper displayFromContent(@NonNull String uri, @NonNull SketchView sketchView) {
        return configuration.getHelperFactory().getDisplayHelper(this, uri, sketchView);
    }

    /**
     * 修整内存缓存，4.0 以下你需要重写 {@link Application#onTrimMemory(int)} 方法，然后调用这个方法
     *
     * @param level 修剪级别，对应 APP 的不同状态，对应 {@link ComponentCallbacks2} 里的常量
     */
    @Keep
    public void onTrimMemory(int level) {
        SLog.w(null, "Trim of memory, level= %s", SketchUtils.getTrimLevelName(level));

        configuration.getMemoryCache().trimMemory(level);
        configuration.getBitmapPool().trimMemory(level);
    }

    /**
     * 当内存低时直接清空全部内存缓存，4.0 以下你需要重写 {@link Application#onLowMemory} 方法，然后调用这个方法
     */
    @Keep
    public void onLowMemory() {
        SLog.w(null, "Memory is very low, clean memory cache and bitmap pool");

        configuration.getMemoryCache().clear();
        configuration.getBitmapPool().clear();
    }
}


module Veewee
  module Provider
    module Vmfusion
      module BoxCommand

        def build(options)
          super(options)
          add_share_from_defn
        end
      end
    end
  end
end


#ifndef BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP
#define BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP

// MS compatible compilers support #pragma once
#if defined(_MSC_VER)
# pragma once
#endif

/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// unescape.hpp

// (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
// 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)

//  See http://www.boost.org for updates, documentation, and revision history.

#include <boost/assert.hpp>

#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/pointee.hpp>

namespace boost {
namespace archive {
namespace iterators {

/////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
// class used by text archives to translate char strings to wchar_t
// strings of the currently selected locale
template<class Derived, class Base>
class unescape
    : public boost::iterator_adaptor<
        unescape<Derived, Base>,
        Base,
        typename pointee<Base>::type,
        single_pass_traversal_tag,
        typename pointee<Base>::type
    >
{
    friend class boost::iterator_core_access;
    typedef typename boost::iterator_adaptor<
        unescape<Derived, Base>,
        Base,
        typename pointee<Base>::type,
        single_pass_traversal_tag,
        typename pointee<Base>::type
    > super_t;

    typedef unescape<Derived, Base> this_t;
public:
    typedef typename this_t::value_type value_type;
    typedef typename this_t::reference reference;
private:
    value_type dereference_impl() {
        if(! m_full){
            m_current_value = static_cast<Derived *>(this)->drain();
            m_full = true;
        }
        return m_current_value;
    }

    reference dereference() const {
        return const_cast<this_t *>(this)->dereference_impl();
    }

    value_type m_current_value;
    bool m_full;

    void increment(){
        ++(this->base_reference());
        dereference_impl();
        m_full = false;
    };

public:

    unescape(Base base) :
        super_t(base),
        m_full(false)
    {}

};

} // namespace iterators
} // namespace archive
} // namespace boost

#endif // BOOST_ARCHIVE_ITERATORS_UNESCAPE_HPP


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{EF0D6FB5-5350-42B6-85C2-49C5194D53E5}</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>LogMaster4Net.Base</RootNamespace>
    <AssemblyName>LogMaster4Net.Base</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="AnyLog, Version=0.1.5.0, Culture=neutral, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\packages\AnyLog.0.1.5.0\lib\net40\AnyLog.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.Core" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="..\GlobalAssemblyInfo.cs">
      <Link>GlobalAssemblyInfo.cs</Link>
    </Compile>
    <Compile Include="ILoggingDeserializer.cs" />
    <Compile Include="ILoggingDeserializerMetadata.cs" />
    <Compile Include="LoggingDeserializerMetadataAttribute.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="XmlElementParser.cs" />
    <Compile Include="XmlLoggingDeserializer.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>


<?php

/**
 * This file is part of the PHP Telegram Bot example-bot package.
 * https://github.com/php-telegram-bot/example-bot/
 *
 * (c) PHP Telegram Bot Team
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * User "/survey" command
 *
 * Example of the Conversation functionality in form of a simple survey.
 */

namespace Longman\TelegramBot\Commands\UserCommands;

use Longman\TelegramBot\Commands\UserCommand;
use Longman\TelegramBot\Conversation;
use Longman\TelegramBot\Entities\Keyboard;
use Longman\TelegramBot\Entities\KeyboardButton;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Request;

class SurveyCommand extends UserCommand
{
    /**
     * @var string
     */
    protected $name = 'survey';

    /**
     * @var string
     */
    protected $description = 'Survery for bot users';

    /**
     * @var string
     */
    protected $usage = '/survey';

    /**
     * @var string
     */
    protected $version = '0.4.0';

    /**
     * @var bool
     */
    protected $need_mysql = true;

    /**
     * @var bool
     */
    protected $private_only = true;

    /**
     * Conversation Object
     *
     * @var Conversation
     */
    protected $conversation;

    /**
     * Main command execution
     *
     * @return ServerResponse
     * @throws TelegramException
     */
    public function execute(): ServerResponse
    {
        $message = $this->getMessage();

        $chat    = $message->getChat();
        $user    = $message->getFrom();
        $text    = trim($message->getText(true));
        $chat_id = $chat->getId();
        $user_id = $user->getId();

        // Preparing response
        $data = [
            'chat_id'      => $chat_id,
            // Remove any keyboard by default
            'reply_markup' => Keyboard::remove(['selective' => true]),
        ];

        if ($chat->isGroupChat() || $chat->isSuperGroup()) {
            // Force reply is applied by default so it can work with privacy on
            $data['reply_markup'] = Keyboard::forceReply(['selective' => true]);
        }

        // Conversation start
        $this->conversation = new Conversation($user_id, $chat_id, $this->getName());

        // Load any existing notes from this conversation
        $notes = &$this->conversation->notes;
        !is_array($notes) && $notes = [];

        // Load the current state of the conversation
        $state = $notes['state'] ?? 0;

        $result = Request::emptyResponse();

        // State machine
        // Every time a step is achieved the state is updated
        switch ($state) {
            case 0:
                if ($text === '') {
                    $notes['state'] = 0;
                    $this->conversation->update();

                    $data['text'] = 'Type your name:';

                    $result = Request::sendMessage($data);
                    break;
                }

                $notes['name'] = $text;
                $text          = '';

            // No break!
            case 1:
                if ($text === '') {
                    $notes['state'] = 1;
                    $this->conversation->update();

                    $data['text'] = 'Type your surname:';

                    $result = Request::sendMessage($data);
                    break;
                }

                $notes['surname'] = $text;
                $text             = '';

            // No break!
            case 2:
                if ($text === '' || !is_numeric($text)) {
                    $notes['state'] = 2;
                    $this->conversation->update();

                    $data['text'] = 'Type your age:';
                    if ($text !== '') {
                        $data['text'] = 'Age must be a number';
                    }

                    $result = Request::sendMessage($data);
                    break;
                }

                $notes['age'] = $text;
                $text         = '';

            // No break!
            case 3:
                if ($text === '' || !in_array($text, ['M', 'F'], true)) {
                    $notes['state'] = 3;
                    $this->conversation->update();

                    $data['reply_markup'] = (new Keyboard(['M', 'F']))
                        ->setResizeKeyboard(true)
                        ->setOneTimeKeyboard(true)
                        ->setSelective(true);

                    $data['text'] = 'Select your gender:';
                    if ($text !== '') {
                        $data['text'] = 'Choose a keyboard option to select your gender';
                    }

                    $result = Request::sendMessage($data);
                    break;
                }

                $notes['gender'] = $text;

            // No break!
            case 4:
                if ($message->getLocation() === null) {
                    $notes['state'] = 4;
                    $this->conversation->update();

                    $data['reply_markup'] = (new Keyboard(
                        (new KeyboardButton('Share Location'))->setRequestLocation(true)
                    ))
                        ->setOneTimeKeyboard(true)
                        ->setResizeKeyboard(true)
                        ->setSelective(true);

                    $data['text'] = 'Share your location:';

                    $result = Request::sendMessage($data);
                    break;
                }

                $notes['longitude'] = $message->getLocation()->getLongitude();
                $notes['latitude']  = $message->getLocation()->getLatitude();

            // No break!
            case 5:
                if ($message->getPhoto() === null) {
                    $notes['state'] = 5;
                    $this->conversation->update();

                    $data['text'] = 'Insert your picture:';

                    $result = Request::sendMessage($data);
                    break;
                }

                $photo             = $message->getPhoto()[0];
                $notes['photo_id'] = $photo->getFileId();

            // No break!
            case 6:
                if ($message->getContact() === null) {
                    $notes['state'] = 6;
                    $this->conversation->update();

                    $data['reply_markup'] = (new Keyboard(
                        (new KeyboardButton('Share Contact'))->setRequestContact(true)
                    ))
                        ->setOneTimeKeyboard(true)
                        ->setResizeKeyboard(true)
                        ->setSelective(true);

                    $data['text'] = 'Share your contact information:';

                    $result = Request::sendMessage($data);
                    break;
                }

                $notes['phone_number'] = $message->getContact()->getPhoneNumber();

            // No break!
            case 7:
                $this->conversation->update();
                $out_text = '/Survey result:' . PHP_EOL;
                unset($notes['state']);
                foreach ($notes as $k => $v) {
                    $out_text .= PHP_EOL . ucfirst($k) . ': ' . $v;
                }

                $data['photo']   = $notes['photo_id'];
                $data['caption'] = $out_text;

                $this->conversation->stop();

                $result = Request::sendPhoto($data);
                break;
        }

        return $result;
    }
}


/*
table encoder position an values id
 OFF_ON  = 0+3 = 3
 ON_OFF  = 1+5 = 6
 ON_ON   = 1+3 = 4
 OFF_OFF = 0+5 = 5
 */

 //left:3,6
// right: 4,5
const int encoder0PinA = 2;
const int encoder0PinB = 3;
const int encoder0PinC = 4; // not used
short directionEncoders;
short lastDirectionEncoders;
void setup() {// put your setup code here, to run once:
    pinMode(encoder0PinA,INPUT);
    pinMode(encoder0PinB,INPUT);
    pinMode(encoder0PinC,INPUT);

    Serial.begin(115200);
    directionEncoders = 0;
    lastDirectionEncoders = -1;
}

void loop() {
   directionEncoders = 0;
    if(digitalRead(encoder0PinA)== HIGH){
      // directionEncoders is ON for encoder A
      directionEncoders += 1;
    }
    else{
      // directionEncoders is OFF for encoder A
      directionEncoders += 0;
    }
    if(digitalRead(encoder0PinB)== HIGH){
      // directionEncoders is ON for encoder B
      directionEncoders +=3;
    }
    else{
      // directionEncoders is OFF for encoder B
      directionEncoders +=5;
    }

    // print when is different
    if(lastDirectionEncoders != directionEncoders){
      lastDirectionEncoders = directionEncoders;
      Serial.println(directionEncoders);
    }

}