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
# LeetCode ## Author Brandon Scott ## About These are my solutions to the problems on LeetCode. Some of them may be done incorrectly or inefficiently, but all of them have passed the unit tests and were accepted by LeetCode. ## License By default, all code in this project is licensed under the MIT license.
xeons/LeetCode
README.md
Markdown
mit
314
/* SPDX-License-Identifier: MIT * * 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. * * Copyright: * 2018-2020 Evan Nemerson <[email protected]> * 2020 Michael R. Crusoe <[email protected]> */ #include "sse.h" #if !defined(SIMDE_X86_AVX_H) #define SIMDE_X86_AVX_H #include "sse4.2.h" HEDLEY_DIAGNOSTIC_PUSH SIMDE_DISABLE_UNWANTED_DIAGNOSTICS SIMDE_BEGIN_DECLS_ typedef union { #if defined(SIMDE_VECTOR_SUBSCRIPT) SIMDE_ALIGN_TO_32 int8_t i8 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int16_t i16 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int32_t i32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int64_t i64 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint8_t u8 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint16_t u16 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint32_t u32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint64_t u64 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #if defined(SIMDE_HAVE_INT128_) SIMDE_ALIGN_TO_32 simde_int128 i128 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 simde_uint128 u128 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #endif SIMDE_ALIGN_TO_32 simde_float32 f32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 simde_float64 f64 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int_fast32_t i32f SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint_fast32_t u32f SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #else SIMDE_ALIGN_TO_32 int8_t i8[32]; SIMDE_ALIGN_TO_32 int16_t i16[16]; SIMDE_ALIGN_TO_32 int32_t i32[8]; SIMDE_ALIGN_TO_32 int64_t i64[4]; SIMDE_ALIGN_TO_32 uint8_t u8[32]; SIMDE_ALIGN_TO_32 uint16_t u16[16]; SIMDE_ALIGN_TO_32 uint32_t u32[8]; SIMDE_ALIGN_TO_32 uint64_t u64[4]; SIMDE_ALIGN_TO_32 int_fast32_t i32f[32 / sizeof(int_fast32_t)]; SIMDE_ALIGN_TO_32 uint_fast32_t u32f[32 / sizeof(uint_fast32_t)]; #if defined(SIMDE_HAVE_INT128_) SIMDE_ALIGN_TO_32 simde_int128 i128[2]; SIMDE_ALIGN_TO_32 simde_uint128 u128[2]; #endif SIMDE_ALIGN_TO_32 simde_float32 f32[8]; SIMDE_ALIGN_TO_32 simde_float64 f64[4]; #endif SIMDE_ALIGN_TO_32 simde__m128_private m128_private[2]; SIMDE_ALIGN_TO_32 simde__m128 m128[2]; #if defined(SIMDE_X86_AVX_NATIVE) SIMDE_ALIGN_TO_32 __m256 n; #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned char) altivec_u8[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned short) altivec_u16[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned int) altivec_u32[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed char) altivec_i8[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed short) altivec_i16[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(int) altivec_i32[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(float) altivec_f32[2]; #if defined(SIMDE_POWER_ALTIVEC_P7_NATIVE) SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned long long) altivec_u64[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(long long) altivec_i64[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(double) altivec_f64[2]; #endif #endif } simde__m256_private; typedef union { #if defined(SIMDE_VECTOR_SUBSCRIPT) SIMDE_ALIGN_TO_32 int8_t i8 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int16_t i16 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int32_t i32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int64_t i64 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint8_t u8 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint16_t u16 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint32_t u32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint64_t u64 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #if defined(SIMDE_HAVE_INT128_) SIMDE_ALIGN_TO_32 simde_int128 i128 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 simde_uint128 u128 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #endif SIMDE_ALIGN_TO_32 simde_float32 f32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 simde_float64 f64 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int_fast32_t i32f SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint_fast32_t u32f SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #else SIMDE_ALIGN_TO_32 int8_t i8[32]; SIMDE_ALIGN_TO_32 int16_t i16[16]; SIMDE_ALIGN_TO_32 int32_t i32[8]; SIMDE_ALIGN_TO_32 int64_t i64[4]; SIMDE_ALIGN_TO_32 uint8_t u8[32]; SIMDE_ALIGN_TO_32 uint16_t u16[16]; SIMDE_ALIGN_TO_32 uint32_t u32[8]; SIMDE_ALIGN_TO_32 uint64_t u64[4]; #if defined(SIMDE_HAVE_INT128_) SIMDE_ALIGN_TO_32 simde_int128 i128[2]; SIMDE_ALIGN_TO_32 simde_uint128 u128[2]; #endif SIMDE_ALIGN_TO_32 simde_float32 f32[8]; SIMDE_ALIGN_TO_32 simde_float64 f64[4]; SIMDE_ALIGN_TO_32 int_fast32_t i32f[32 / sizeof(int_fast32_t)]; SIMDE_ALIGN_TO_32 uint_fast32_t u32f[32 / sizeof(uint_fast32_t)]; #endif SIMDE_ALIGN_TO_32 simde__m128d_private m128d_private[2]; SIMDE_ALIGN_TO_32 simde__m128d m128d[2]; #if defined(SIMDE_X86_AVX_NATIVE) SIMDE_ALIGN_TO_32 __m256d n; #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned char) altivec_u8[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned short) altivec_u16[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned int) altivec_u32[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed char) altivec_i8[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed short) altivec_i16[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed int) altivec_i32[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(float) altivec_f32[2]; #if defined(SIMDE_POWER_ALTIVEC_P7_NATIVE) SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned long long) altivec_u64[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed long long) altivec_i64[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(double) altivec_f64[2]; #endif #endif } simde__m256d_private; typedef union { #if defined(SIMDE_VECTOR_SUBSCRIPT) SIMDE_ALIGN_TO_32 int8_t i8 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int16_t i16 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int32_t i32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int64_t i64 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint8_t u8 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint16_t u16 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint32_t u32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint64_t u64 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #if defined(SIMDE_HAVE_INT128_) SIMDE_ALIGN_TO_32 simde_int128 i128 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 simde_uint128 u128 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #endif SIMDE_ALIGN_TO_32 simde_float32 f32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 simde_float64 f64 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 int_fast32_t i32f SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; SIMDE_ALIGN_TO_32 uint_fast32_t u32f SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #else SIMDE_ALIGN_TO_32 int8_t i8[32]; SIMDE_ALIGN_TO_32 int16_t i16[16]; SIMDE_ALIGN_TO_32 int32_t i32[8]; SIMDE_ALIGN_TO_32 int64_t i64[4]; SIMDE_ALIGN_TO_32 uint8_t u8[32]; SIMDE_ALIGN_TO_32 uint16_t u16[16]; SIMDE_ALIGN_TO_32 uint32_t u32[8]; SIMDE_ALIGN_TO_32 uint64_t u64[4]; SIMDE_ALIGN_TO_32 int_fast32_t i32f[32 / sizeof(int_fast32_t)]; SIMDE_ALIGN_TO_32 uint_fast32_t u32f[32 / sizeof(uint_fast32_t)]; #if defined(SIMDE_HAVE_INT128_) SIMDE_ALIGN_TO_32 simde_int128 i128[2]; SIMDE_ALIGN_TO_32 simde_uint128 u128[2]; #endif SIMDE_ALIGN_TO_32 simde_float32 f32[8]; SIMDE_ALIGN_TO_32 simde_float64 f64[4]; #endif SIMDE_ALIGN_TO_32 simde__m128i_private m128i_private[2]; SIMDE_ALIGN_TO_32 simde__m128i m128i[2]; #if defined(SIMDE_X86_AVX_NATIVE) SIMDE_ALIGN_TO_32 __m256i n; #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE) SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned char) altivec_u8[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned short) altivec_u16[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned int) altivec_u32[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed char) altivec_i8[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed short) altivec_i16[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed int) altivec_i32[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(float) altivec_f32[2]; #if defined(SIMDE_POWER_ALTIVEC_P7_NATIVE) SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(unsigned long long) altivec_u64[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(signed long long) altivec_i64[2]; SIMDE_ALIGN_TO_16 SIMDE_POWER_ALTIVEC_VECTOR(double) altivec_f64[2]; #endif #endif } simde__m256i_private; #if defined(SIMDE_X86_AVX_NATIVE) typedef __m256 simde__m256; typedef __m256i simde__m256i; typedef __m256d simde__m256d; #elif defined(SIMDE_VECTOR_SUBSCRIPT) typedef simde_float32 simde__m256 SIMDE_ALIGN_TO_32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; typedef int_fast32_t simde__m256i SIMDE_ALIGN_TO_32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; typedef simde_float64 simde__m256d SIMDE_ALIGN_TO_32 SIMDE_VECTOR(32) SIMDE_MAY_ALIAS; #else typedef simde__m256_private simde__m256; typedef simde__m256i_private simde__m256i; typedef simde__m256d_private simde__m256d; #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #if !defined(HEDLEY_INTEL_VERSION) typedef simde__m256 __m256; typedef simde__m256i __m256i; typedef simde__m256d __m256d; #else #define __m256 simde__m256 #define __m256i simde__m256i #define __m256d simde__m256d #endif #endif HEDLEY_STATIC_ASSERT(32 == sizeof(simde__m256), "simde__m256 size incorrect"); HEDLEY_STATIC_ASSERT(32 == sizeof(simde__m256_private), "simde__m256_private size incorrect"); HEDLEY_STATIC_ASSERT(32 == sizeof(simde__m256i), "simde__m256i size incorrect"); HEDLEY_STATIC_ASSERT(32 == sizeof(simde__m256i_private), "simde__m256i_private size incorrect"); HEDLEY_STATIC_ASSERT(32 == sizeof(simde__m256d), "simde__m256d size incorrect"); HEDLEY_STATIC_ASSERT(32 == sizeof(simde__m256d_private), "simde__m256d_private size incorrect"); #if defined(SIMDE_CHECK_ALIGNMENT) && defined(SIMDE_ALIGN_OF) HEDLEY_STATIC_ASSERT(SIMDE_ALIGN_OF(simde__m256) == 32, "simde__m256 is not 32-byte aligned"); HEDLEY_STATIC_ASSERT(SIMDE_ALIGN_OF(simde__m256_private) == 32, "simde__m256_private is not 32-byte aligned"); HEDLEY_STATIC_ASSERT(SIMDE_ALIGN_OF(simde__m256i) == 32, "simde__m256i is not 32-byte aligned"); HEDLEY_STATIC_ASSERT(SIMDE_ALIGN_OF(simde__m256i_private) == 32, "simde__m256i_private is not 32-byte aligned"); HEDLEY_STATIC_ASSERT(SIMDE_ALIGN_OF(simde__m256d) == 32, "simde__m256d is not 32-byte aligned"); HEDLEY_STATIC_ASSERT(SIMDE_ALIGN_OF(simde__m256d_private) == 32, "simde__m256d_private is not 32-byte aligned"); #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde__m256_from_private(simde__m256_private v) { simde__m256 r; simde_memcpy(&r, &v, sizeof(r)); return r; } SIMDE_FUNCTION_ATTRIBUTES simde__m256_private simde__m256_to_private(simde__m256 v) { simde__m256_private r; simde_memcpy(&r, &v, sizeof(r)); return r; } SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde__m256i_from_private(simde__m256i_private v) { simde__m256i r; simde_memcpy(&r, &v, sizeof(r)); return r; } SIMDE_FUNCTION_ATTRIBUTES simde__m256i_private simde__m256i_to_private(simde__m256i v) { simde__m256i_private r; simde_memcpy(&r, &v, sizeof(r)); return r; } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde__m256d_from_private(simde__m256d_private v) { simde__m256d r; simde_memcpy(&r, &v, sizeof(r)); return r; } SIMDE_FUNCTION_ATTRIBUTES simde__m256d_private simde__m256d_to_private(simde__m256d v) { simde__m256d_private r; simde_memcpy(&r, &v, sizeof(r)); return r; } #define SIMDE_CMP_EQ_OQ 0 #define SIMDE_CMP_LT_OS 1 #define SIMDE_CMP_LE_OS 2 #define SIMDE_CMP_UNORD_Q 3 #define SIMDE_CMP_NEQ_UQ 4 #define SIMDE_CMP_NLT_US 5 #define SIMDE_CMP_NLE_US 6 #define SIMDE_CMP_ORD_Q 7 #define SIMDE_CMP_EQ_UQ 8 #define SIMDE_CMP_NGE_US 9 #define SIMDE_CMP_NGT_US 10 #define SIMDE_CMP_FALSE_OQ 11 #define SIMDE_CMP_NEQ_OQ 12 #define SIMDE_CMP_GE_OS 13 #define SIMDE_CMP_GT_OS 14 #define SIMDE_CMP_TRUE_UQ 15 #define SIMDE_CMP_EQ_OS 16 #define SIMDE_CMP_LT_OQ 17 #define SIMDE_CMP_LE_OQ 18 #define SIMDE_CMP_UNORD_S 19 #define SIMDE_CMP_NEQ_US 20 #define SIMDE_CMP_NLT_UQ 21 #define SIMDE_CMP_NLE_UQ 22 #define SIMDE_CMP_ORD_S 23 #define SIMDE_CMP_EQ_US 24 #define SIMDE_CMP_NGE_UQ 25 #define SIMDE_CMP_NGT_UQ 26 #define SIMDE_CMP_FALSE_OS 27 #define SIMDE_CMP_NEQ_OS 28 #define SIMDE_CMP_GE_OQ 29 #define SIMDE_CMP_GT_OQ 30 #define SIMDE_CMP_TRUE_US 31 #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) && !defined(_CMP_EQ_OQ) #define _CMP_EQ_OQ SIMDE_CMP_EQ_OQ #define _CMP_LT_OS SIMDE_CMP_LT_OS #define _CMP_LE_OS SIMDE_CMP_LE_OS #define _CMP_UNORD_Q SIMDE_CMP_UNORD_Q #define _CMP_NEQ_UQ SIMDE_CMP_NEQ_UQ #define _CMP_NLT_US SIMDE_CMP_NLT_US #define _CMP_NLE_US SIMDE_CMP_NLE_US #define _CMP_ORD_Q SIMDE_CMP_ORD_Q #define _CMP_EQ_UQ SIMDE_CMP_EQ_UQ #define _CMP_NGE_US SIMDE_CMP_NGE_US #define _CMP_NGT_US SIMDE_CMP_NGT_US #define _CMP_FALSE_OQ SIMDE_CMP_FALSE_OQ #define _CMP_NEQ_OQ SIMDE_CMP_NEQ_OQ #define _CMP_GE_OS SIMDE_CMP_GE_OS #define _CMP_GT_OS SIMDE_CMP_GT_OS #define _CMP_TRUE_UQ SIMDE_CMP_TRUE_UQ #define _CMP_EQ_OS SIMDE_CMP_EQ_OS #define _CMP_LT_OQ SIMDE_CMP_LT_OQ #define _CMP_LE_OQ SIMDE_CMP_LE_OQ #define _CMP_UNORD_S SIMDE_CMP_UNORD_S #define _CMP_NEQ_US SIMDE_CMP_NEQ_US #define _CMP_NLT_UQ SIMDE_CMP_NLT_UQ #define _CMP_NLE_UQ SIMDE_CMP_NLE_UQ #define _CMP_ORD_S SIMDE_CMP_ORD_S #define _CMP_EQ_US SIMDE_CMP_EQ_US #define _CMP_NGE_UQ SIMDE_CMP_NGE_UQ #define _CMP_NGT_UQ SIMDE_CMP_NGT_UQ #define _CMP_FALSE_OS SIMDE_CMP_FALSE_OS #define _CMP_NEQ_OS SIMDE_CMP_NEQ_OS #define _CMP_GE_OQ SIMDE_CMP_GE_OQ #define _CMP_GT_OQ SIMDE_CMP_GT_OQ #define _CMP_TRUE_US SIMDE_CMP_TRUE_US #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_castps_pd (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castps_pd(a); #else return *HEDLEY_REINTERPRET_CAST(simde__m256d*, &a); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castps_pd #define _mm256_castps_pd(a) simde_mm256_castps_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_castps_si256 (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castps_si256(a); #else return *HEDLEY_REINTERPRET_CAST(simde__m256i*, &a); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castps_si256 #define _mm256_castps_si256(a) simde_mm256_castps_si256(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_castsi256_pd (simde__m256i a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castsi256_pd(a); #else return *HEDLEY_REINTERPRET_CAST(simde__m256d*, &a); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castsi256_pd #define _mm256_castsi256_pd(a) simde_mm256_castsi256_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_castsi256_ps (simde__m256i a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castsi256_ps(a); #else return *HEDLEY_REINTERPRET_CAST(simde__m256*, &a); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castsi256_ps #define _mm256_castsi256_ps(a) simde_mm256_castsi256_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_castpd_ps (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castpd_ps(a); #else return *HEDLEY_REINTERPRET_CAST(simde__m256*, &a); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castpd_ps #define _mm256_castpd_ps(a) simde_mm256_castpd_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_castpd_si256 (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castpd_si256(a); #else return *HEDLEY_REINTERPRET_CAST(simde__m256i*, &a); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castpd_si256 #define _mm256_castpd_si256(a) simde_mm256_castpd_si256(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_setzero_si256 (void) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_setzero_si256(); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_setzero_si128(); r_.m128i[1] = simde_mm_setzero_si128(); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32f) / sizeof(r_.i32f[0])) ; i++) { r_.i32f[i] = 0; } #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setzero_si256 #define _mm256_setzero_si256() simde_mm256_setzero_si256() #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_setzero_ps (void) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_setzero_ps(); #else return simde_mm256_castsi256_ps(simde_mm256_setzero_si256()); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setzero_ps #define _mm256_setzero_ps() simde_mm256_setzero_ps() #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_setzero_pd (void) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_setzero_pd(); #else return simde_mm256_castsi256_pd(simde_mm256_setzero_si256()); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setzero_pd #define _mm256_setzero_pd() simde_mm256_setzero_pd() #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_x_mm256_not_ps(simde__m256 a) { simde__m256_private r_, a_ = simde__m256_to_private(a); #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32 = ~a_.i32; #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128) r_.m128[0] = simde_x_mm_not_ps(a_.m128[0]); r_.m128[1] = simde_x_mm_not_ps(a_.m128[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32) / sizeof(r_.i32[0])) ; i++) { r_.i32[i] = ~(a_.i32[i]); } #endif return simde__m256_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_x_mm256_select_ps(simde__m256 a, simde__m256 b, simde__m256 mask) { /* This function is for when you want to blend two elements together * according to a mask. It is similar to _mm256_blendv_ps, except that * it is undefined whether the blend is based on the highest bit in * each lane (like blendv) or just bitwise operations. This allows * us to implement the function efficiently everywhere. * * Basically, you promise that all the lanes in mask are either 0 or * ~0. */ #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_blendv_ps(a, b, mask); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b), mask_ = simde__m256_to_private(mask); #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32 = a_.i32 ^ ((a_.i32 ^ b_.i32) & mask_.i32); #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128) r_.m128[0] = simde_x_mm_select_ps(a_.m128[0], b_.m128[0], mask_.m128[0]); r_.m128[1] = simde_x_mm_select_ps(a_.m128[1], b_.m128[1], mask_.m128[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32) / sizeof(r_.i32[0])) ; i++) { r_.i32[i] = a_.i32[i] ^ ((a_.i32[i] ^ b_.i32[i]) & mask_.i32[i]); } #endif return simde__m256_from_private(r_); #endif } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_x_mm256_not_pd(simde__m256d a) { simde__m256d_private r_, a_ = simde__m256d_to_private(a); #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i64 = ~a_.i64; #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128) r_.m128d[0] = simde_x_mm_not_pd(a_.m128d[0]); r_.m128d[1] = simde_x_mm_not_pd(a_.m128d[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i64) / sizeof(r_.i64[0])) ; i++) { r_.i64[i] = ~(a_.i64[i]); } #endif return simde__m256d_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_x_mm256_select_pd(simde__m256d a, simde__m256d b, simde__m256d mask) { /* This function is for when you want to blend two elements together * according to a mask. It is similar to _mm256_blendv_pd, except that * it is undefined whether the blend is based on the highest bit in * each lane (like blendv) or just bitwise operations. This allows * us to implement the function efficiently everywhere. * * Basically, you promise that all the lanes in mask are either 0 or * ~0. */ #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_blendv_pd(a, b, mask); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b), mask_ = simde__m256d_to_private(mask); #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i64 = a_.i64 ^ ((a_.i64 ^ b_.i64) & mask_.i64); #elif SIMDE_NATURAL_VECTOR_SIZE_GE(128) r_.m128d[0] = simde_x_mm_select_pd(a_.m128d[0], b_.m128d[0], mask_.m128d[0]); r_.m128d[1] = simde_x_mm_select_pd(a_.m128d[1], b_.m128d[1], mask_.m128d[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i64) / sizeof(r_.i64[0])) ; i++) { r_.i64[i] = a_.i64[i] ^ ((a_.i64[i] ^ b_.i64[i]) & mask_.i64[i]); } #endif return simde__m256d_from_private(r_); #endif } SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_x_mm256_setone_si256 (void) { simde__m256i_private r_; #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS) __typeof__(r_.i32f) rv = { 0, }; r_.i32f = ~rv; #elif defined(SIMDE_X86_AVX2_NATIVE) __m256i t = _mm256_setzero_si256(); r_.n = _mm256_cmpeq_epi32(t, t); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32f) / sizeof(r_.i32f[0])) ; i++) { r_.i32f[i] = ~HEDLEY_STATIC_CAST(int_fast32_t, 0); } #endif return simde__m256i_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_x_mm256_setone_ps (void) { return simde_mm256_castsi256_ps(simde_x_mm256_setone_si256()); } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_x_mm256_setone_pd (void) { return simde_mm256_castsi256_pd(simde_x_mm256_setone_si256()); } SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_set_epi8 (int8_t e31, int8_t e30, int8_t e29, int8_t e28, int8_t e27, int8_t e26, int8_t e25, int8_t e24, int8_t e23, int8_t e22, int8_t e21, int8_t e20, int8_t e19, int8_t e18, int8_t e17, int8_t e16, int8_t e15, int8_t e14, int8_t e13, int8_t e12, int8_t e11, int8_t e10, int8_t e9, int8_t e8, int8_t e7, int8_t e6, int8_t e5, int8_t e4, int8_t e3, int8_t e2, int8_t e1, int8_t e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set_epi8(e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_set_epi8( e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0); r_.m128i[1] = simde_mm_set_epi8( e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16); #else r_.i8[ 0] = e0; r_.i8[ 1] = e1; r_.i8[ 2] = e2; r_.i8[ 3] = e3; r_.i8[ 4] = e4; r_.i8[ 5] = e5; r_.i8[ 6] = e6; r_.i8[ 7] = e7; r_.i8[ 8] = e8; r_.i8[ 9] = e9; r_.i8[10] = e10; r_.i8[11] = e11; r_.i8[12] = e12; r_.i8[13] = e13; r_.i8[14] = e14; r_.i8[15] = e15; r_.i8[16] = e16; r_.i8[17] = e17; r_.i8[18] = e18; r_.i8[19] = e19; r_.i8[20] = e20; r_.i8[21] = e21; r_.i8[22] = e22; r_.i8[23] = e23; r_.i8[24] = e24; r_.i8[25] = e25; r_.i8[26] = e26; r_.i8[27] = e27; r_.i8[28] = e28; r_.i8[29] = e29; r_.i8[30] = e30; r_.i8[31] = e31; #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set_epi8 #define _mm256_set_epi8(e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) \ simde_mm256_set_epi8(e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_set_epi16 (int16_t e15, int16_t e14, int16_t e13, int16_t e12, int16_t e11, int16_t e10, int16_t e9, int16_t e8, int16_t e7, int16_t e6, int16_t e5, int16_t e4, int16_t e3, int16_t e2, int16_t e1, int16_t e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set_epi16(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_set_epi16( e7, e6, e5, e4, e3, e2, e1, e0); r_.m128i[1] = simde_mm_set_epi16(e15, e14, e13, e12, e11, e10, e9, e8); #else r_.i16[ 0] = e0; r_.i16[ 1] = e1; r_.i16[ 2] = e2; r_.i16[ 3] = e3; r_.i16[ 4] = e4; r_.i16[ 5] = e5; r_.i16[ 6] = e6; r_.i16[ 7] = e7; r_.i16[ 8] = e8; r_.i16[ 9] = e9; r_.i16[10] = e10; r_.i16[11] = e11; r_.i16[12] = e12; r_.i16[13] = e13; r_.i16[14] = e14; r_.i16[15] = e15; #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set_epi16 #define _mm256_set_epi16(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) \ simde_mm256_set_epi16(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_set_epi32 (int32_t e7, int32_t e6, int32_t e5, int32_t e4, int32_t e3, int32_t e2, int32_t e1, int32_t e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set_epi32(e7, e6, e5, e4, e3, e2, e1, e0); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_set_epi32(e3, e2, e1, e0); r_.m128i[1] = simde_mm_set_epi32(e7, e6, e5, e4); #else r_.i32[ 0] = e0; r_.i32[ 1] = e1; r_.i32[ 2] = e2; r_.i32[ 3] = e3; r_.i32[ 4] = e4; r_.i32[ 5] = e5; r_.i32[ 6] = e6; r_.i32[ 7] = e7; #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set_epi32 #define _mm256_set_epi32(e7, e6, e5, e4, e3, e2, e1, e0) \ simde_mm256_set_epi32(e7, e6, e5, e4, e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_set_epi64x (int64_t e3, int64_t e2, int64_t e1, int64_t e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set_epi64x(e3, e2, e1, e0); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_set_epi64x(e1, e0); r_.m128i[1] = simde_mm_set_epi64x(e3, e2); #else r_.i64[0] = e0; r_.i64[1] = e1; r_.i64[2] = e2; r_.i64[3] = e3; #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set_epi64x #define _mm256_set_epi64x(e3, e2, e1, e0) simde_mm256_set_epi64x(e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_x_mm256_set_epu8 (uint8_t e31, uint8_t e30, uint8_t e29, uint8_t e28, uint8_t e27, uint8_t e26, uint8_t e25, uint8_t e24, uint8_t e23, uint8_t e22, uint8_t e21, uint8_t e20, uint8_t e19, uint8_t e18, uint8_t e17, uint8_t e16, uint8_t e15, uint8_t e14, uint8_t e13, uint8_t e12, uint8_t e11, uint8_t e10, uint8_t e9, uint8_t e8, uint8_t e7, uint8_t e6, uint8_t e5, uint8_t e4, uint8_t e3, uint8_t e2, uint8_t e1, uint8_t e0) { simde__m256i_private r_; r_.u8[ 0] = e0; r_.u8[ 1] = e1; r_.u8[ 2] = e2; r_.u8[ 3] = e3; r_.u8[ 4] = e4; r_.u8[ 5] = e5; r_.u8[ 6] = e6; r_.u8[ 7] = e7; r_.u8[ 8] = e8; r_.u8[ 9] = e9; r_.u8[10] = e10; r_.u8[11] = e11; r_.u8[12] = e12; r_.u8[13] = e13; r_.u8[14] = e14; r_.u8[15] = e15; r_.u8[16] = e16; r_.u8[17] = e17; r_.u8[18] = e18; r_.u8[19] = e19; r_.u8[20] = e20; r_.u8[20] = e20; r_.u8[21] = e21; r_.u8[22] = e22; r_.u8[23] = e23; r_.u8[24] = e24; r_.u8[25] = e25; r_.u8[26] = e26; r_.u8[27] = e27; r_.u8[28] = e28; r_.u8[29] = e29; r_.u8[30] = e30; r_.u8[31] = e31; return simde__m256i_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_x_mm256_set_epu16 (uint16_t e15, uint16_t e14, uint16_t e13, uint16_t e12, uint16_t e11, uint16_t e10, uint16_t e9, uint16_t e8, uint16_t e7, uint16_t e6, uint16_t e5, uint16_t e4, uint16_t e3, uint16_t e2, uint16_t e1, uint16_t e0) { simde__m256i_private r_; r_.u16[ 0] = e0; r_.u16[ 1] = e1; r_.u16[ 2] = e2; r_.u16[ 3] = e3; r_.u16[ 4] = e4; r_.u16[ 5] = e5; r_.u16[ 6] = e6; r_.u16[ 7] = e7; r_.u16[ 8] = e8; r_.u16[ 9] = e9; r_.u16[10] = e10; r_.u16[11] = e11; r_.u16[12] = e12; r_.u16[13] = e13; r_.u16[14] = e14; r_.u16[15] = e15; return simde__m256i_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_x_mm256_set_epu32 (uint32_t e7, uint32_t e6, uint32_t e5, uint32_t e4, uint32_t e3, uint32_t e2, uint32_t e1, uint32_t e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set_epi32(HEDLEY_STATIC_CAST(int32_t, e7), HEDLEY_STATIC_CAST(int32_t, e6), HEDLEY_STATIC_CAST(int32_t, e5), HEDLEY_STATIC_CAST(int32_t, e4), HEDLEY_STATIC_CAST(int32_t, e3), HEDLEY_STATIC_CAST(int32_t, e2), HEDLEY_STATIC_CAST(int32_t, e1), HEDLEY_STATIC_CAST(int32_t, e0)); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_set_epi32(HEDLEY_STATIC_CAST(int32_t, e3), HEDLEY_STATIC_CAST(int32_t, e2), HEDLEY_STATIC_CAST(int32_t, e1), HEDLEY_STATIC_CAST(int32_t, e0)); r_.m128i[1] = simde_mm_set_epi32(HEDLEY_STATIC_CAST(int32_t, e7), HEDLEY_STATIC_CAST(int32_t, e6), HEDLEY_STATIC_CAST(int32_t, e5), HEDLEY_STATIC_CAST(int32_t, e4)); #else r_.u32[ 0] = e0; r_.u32[ 1] = e1; r_.u32[ 2] = e2; r_.u32[ 3] = e3; r_.u32[ 4] = e4; r_.u32[ 5] = e5; r_.u32[ 6] = e6; r_.u32[ 7] = e7; #endif return simde__m256i_from_private(r_); #endif } SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_x_mm256_set_epu64x (uint64_t e3, uint64_t e2, uint64_t e1, uint64_t e0) { simde__m256i_private r_; r_.u64[0] = e0; r_.u64[1] = e1; r_.u64[2] = e2; r_.u64[3] = e3; return simde__m256i_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_set_ps (simde_float32 e7, simde_float32 e6, simde_float32 e5, simde_float32 e4, simde_float32 e3, simde_float32 e2, simde_float32 e1, simde_float32 e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set_ps(e7, e6, e5, e4, e3, e2, e1, e0); #else simde__m256_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_set_ps(e3, e2, e1, e0); r_.m128[1] = simde_mm_set_ps(e7, e6, e5, e4); #else r_.f32[0] = e0; r_.f32[1] = e1; r_.f32[2] = e2; r_.f32[3] = e3; r_.f32[4] = e4; r_.f32[5] = e5; r_.f32[6] = e6; r_.f32[7] = e7; #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set_ps #define _mm256_set_ps(e7, e6, e5, e4, e3, e2, e1, e0) \ simde_mm256_set_ps(e7, e6, e5, e4, e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_set_pd (simde_float64 e3, simde_float64 e2, simde_float64 e1, simde_float64 e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set_pd(e3, e2, e1, e0); #else simde__m256d_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_set_pd(e1, e0); r_.m128d[1] = simde_mm_set_pd(e3, e2); #else r_.f64[0] = e0; r_.f64[1] = e1; r_.f64[2] = e2; r_.f64[3] = e3; #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set_pd #define _mm256_set_pd(e3, e2, e1, e0) \ simde_mm256_set_pd(e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_set_m128 (simde__m128 e1, simde__m128 e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_insertf128_ps(_mm256_castps128_ps256(e0), e1, 1); #else simde__m256_private r_; simde__m128_private e1_ = simde__m128_to_private(e1), e0_ = simde__m128_to_private(e0); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128_private[0] = e0_; r_.m128_private[1] = e1_; #elif defined(SIMDE_HAVE_INT128_) r_.i128[0] = e0_.i128[0]; r_.i128[1] = e1_.i128[0]; #else r_.i64[0] = e0_.i64[0]; r_.i64[1] = e0_.i64[1]; r_.i64[2] = e1_.i64[0]; r_.i64[3] = e1_.i64[1]; #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set_m128 #define _mm256_set_m128(e1, e0) simde_mm256_set_m128(e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_set_m128d (simde__m128d e1, simde__m128d e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_insertf128_pd(_mm256_castpd128_pd256(e0), e1, 1); #else simde__m256d_private r_; simde__m128d_private e1_ = simde__m128d_to_private(e1), e0_ = simde__m128d_to_private(e0); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d_private[0] = e0_; r_.m128d_private[1] = e1_; #else r_.i64[0] = e0_.i64[0]; r_.i64[1] = e0_.i64[1]; r_.i64[2] = e1_.i64[0]; r_.i64[3] = e1_.i64[1]; #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set_m128d #define _mm256_set_m128d(e1, e0) simde_mm256_set_m128d(e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_set_m128i (simde__m128i e1, simde__m128i e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_insertf128_si256(_mm256_castsi128_si256(e0), e1, 1); #else simde__m256i_private r_; simde__m128i_private e1_ = simde__m128i_to_private(e1), e0_ = simde__m128i_to_private(e0); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i_private[0] = e0_; r_.m128i_private[1] = e1_; #else r_.i64[0] = e0_.i64[0]; r_.i64[1] = e0_.i64[1]; r_.i64[2] = e1_.i64[0]; r_.i64[3] = e1_.i64[1]; #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set_m128i #define _mm256_set_m128i(e1, e0) simde_mm256_set_m128i(e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_set1_epi8 (int8_t a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set1_epi8(a); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_set1_epi8(a); r_.m128i[1] = simde_mm_set1_epi8(a); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i8) / sizeof(r_.i8[0])) ; i++) { r_.i8[i] = a; } #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set1_epi8 #define _mm256_set1_epi8(a) simde_mm256_set1_epi8(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_set1_epi16 (int16_t a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set1_epi16(a); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_set1_epi16(a); r_.m128i[1] = simde_mm_set1_epi16(a); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i16) / sizeof(r_.i16[0])) ; i++) { r_.i16[i] = a; } #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set1_epi16 #define _mm256_set1_epi16(a) simde_mm256_set1_epi16(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_set1_epi32 (int32_t a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set1_epi32(a); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_set1_epi32(a); r_.m128i[1] = simde_mm_set1_epi32(a); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32) / sizeof(r_.i32[0])) ; i++) { r_.i32[i] = a; } #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set1_epi32 #define _mm256_set1_epi32(a) simde_mm256_set1_epi32(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_set1_epi64x (int64_t a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set1_epi64x(a); #else simde__m256i_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_mm_set1_epi64x(a); r_.m128i[1] = simde_mm_set1_epi64x(a); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i64) / sizeof(r_.i64[0])) ; i++) { r_.i64[i] = a; } #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set1_epi64x #define _mm256_set1_epi64x(a) simde_mm256_set1_epi64x(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_set1_ps (simde_float32 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set1_ps(a); #else simde__m256_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_set1_ps(a); r_.m128[1] = simde_mm_set1_ps(a); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = a; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set1_ps #define _mm256_set1_ps(a) simde_mm256_set1_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_set1_pd (simde_float64 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_set1_pd(a); #else simde__m256d_private r_; #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_set1_pd(a); r_.m128d[1] = simde_mm_set1_pd(a); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = a; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_set1_pd #define _mm256_set1_pd(a) simde_mm256_set1_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_x_mm256_deinterleaveeven_epi16 (simde__m256i a, simde__m256i b) { simde__m256i_private r_, a_ = simde__m256i_to_private(a), b_ = simde__m256i_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_x_mm_deinterleaveeven_epi16(a_.m128i[0], b_.m128i[0]); r_.m128i[1] = simde_x_mm_deinterleaveeven_epi16(a_.m128i[1], b_.m128i[1]); #elif defined(SIMDE_SHUFFLE_VECTOR_) r_.i16 = SIMDE_SHUFFLE_VECTOR_(16, 32, a_.i16, b_.i16, 0, 2, 4, 6, 16, 18, 20, 22, 8, 10, 12, 14, 24, 26, 28, 30); #else const size_t halfway_point = (sizeof(r_.i16) / sizeof(r_.i16[0])) / 2; const size_t quarter_point = (sizeof(r_.i16) / sizeof(r_.i16[0])) / 4; for (size_t i = 0 ; i < quarter_point ; i++) { r_.i16[i] = a_.i16[2 * i]; r_.i16[i + quarter_point] = b_.i16[2 * i]; r_.i16[halfway_point + i] = a_.i16[halfway_point + 2 * i]; r_.i16[halfway_point + i + quarter_point] = b_.i16[halfway_point + 2 * i]; } #endif return simde__m256i_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_x_mm256_deinterleaveodd_epi16 (simde__m256i a, simde__m256i b) { simde__m256i_private r_, a_ = simde__m256i_to_private(a), b_ = simde__m256i_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_x_mm_deinterleaveodd_epi16(a_.m128i[0], b_.m128i[0]); r_.m128i[1] = simde_x_mm_deinterleaveodd_epi16(a_.m128i[1], b_.m128i[1]); #elif defined(SIMDE_SHUFFLE_VECTOR_) r_.i16 = SIMDE_SHUFFLE_VECTOR_(16, 32, a_.i16, b_.i16, 1, 3, 5, 7, 17, 19, 21, 23, 9, 11, 13, 15, 25, 27, 29, 31); #else const size_t halfway_point = (sizeof(r_.i16) / sizeof(r_.i16[0])) / 2; const size_t quarter_point = (sizeof(r_.i16) / sizeof(r_.i16[0])) / 4; for (size_t i = 0 ; i < quarter_point ; i++) { r_.i16[i] = a_.i16[2 * i + 1]; r_.i16[i + quarter_point] = b_.i16[2 * i + 1]; r_.i16[halfway_point + i] = a_.i16[halfway_point + 2 * i + 1]; r_.i16[halfway_point + i + quarter_point] = b_.i16[halfway_point + 2 * i + 1]; } #endif return simde__m256i_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_x_mm256_deinterleaveeven_epi32 (simde__m256i a, simde__m256i b) { simde__m256i_private r_, a_ = simde__m256i_to_private(a), b_ = simde__m256i_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_x_mm_deinterleaveeven_epi32(a_.m128i[0], b_.m128i[0]); r_.m128i[1] = simde_x_mm_deinterleaveeven_epi32(a_.m128i[1], b_.m128i[1]); #elif defined(SIMDE_SHUFFLE_VECTOR_) r_.i32 = SIMDE_SHUFFLE_VECTOR_(32, 32, a_.i32, b_.i32, 0, 2, 8, 10, 4, 6, 12, 14); #else const size_t halfway_point = (sizeof(r_.i32) / sizeof(r_.i32[0])) / 2; const size_t quarter_point = (sizeof(r_.i32) / sizeof(r_.i32[0])) / 4; for (size_t i = 0 ; i < quarter_point ; i++) { r_.i32[i] = a_.i32[2 * i]; r_.i32[i + quarter_point] = b_.i32[2 * i]; r_.i32[halfway_point + i] = a_.i32[halfway_point + 2 * i]; r_.i32[halfway_point + i + quarter_point] = b_.i32[halfway_point + 2 * i]; } #endif return simde__m256i_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_x_mm256_deinterleaveodd_epi32 (simde__m256i a, simde__m256i b) { simde__m256i_private r_, a_ = simde__m256i_to_private(a), b_ = simde__m256i_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128i[0] = simde_x_mm_deinterleaveodd_epi32(a_.m128i[0], b_.m128i[0]); r_.m128i[1] = simde_x_mm_deinterleaveodd_epi32(a_.m128i[1], b_.m128i[1]); #elif defined(SIMDE_SHUFFLE_VECTOR_) r_.i32 = SIMDE_SHUFFLE_VECTOR_(32, 32, a_.i32, b_.i32, 1, 3, 9, 11, 5, 7, 13, 15); #else const size_t halfway_point = (sizeof(r_.i32) / sizeof(r_.i32[0])) / 2; const size_t quarter_point = (sizeof(r_.i32) / sizeof(r_.i32[0])) / 4; for (size_t i = 0 ; i < quarter_point ; i++) { r_.i32[i] = a_.i32[2 * i + 1]; r_.i32[i + quarter_point] = b_.i32[2 * i + 1]; r_.i32[halfway_point + i] = a_.i32[halfway_point + 2 * i + 1]; r_.i32[halfway_point + i + quarter_point] = b_.i32[halfway_point + 2 * i + 1]; } #endif return simde__m256i_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_x_mm256_deinterleaveeven_ps (simde__m256 a, simde__m256 b) { simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_x_mm_deinterleaveeven_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_x_mm_deinterleaveeven_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_SHUFFLE_VECTOR_) r_.f32 = SIMDE_SHUFFLE_VECTOR_(32, 32, a_.f32, b_.f32, 0, 2, 8, 10, 4, 6, 12, 14); #else const size_t halfway_point = (sizeof(r_.f32) / sizeof(r_.f32[0])) / 2; const size_t quarter_point = (sizeof(r_.f32) / sizeof(r_.f32[0])) / 4; for (size_t i = 0 ; i < quarter_point ; i++) { r_.f32[i] = a_.f32[2 * i]; r_.f32[i + quarter_point] = b_.f32[2 * i]; r_.f32[halfway_point + i] = a_.f32[halfway_point + 2 * i]; r_.f32[halfway_point + i + quarter_point] = b_.f32[halfway_point + 2 * i]; } #endif return simde__m256_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_x_mm256_deinterleaveodd_ps (simde__m256 a, simde__m256 b) { simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_x_mm_deinterleaveodd_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_x_mm_deinterleaveodd_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_SHUFFLE_VECTOR_) r_.f32 = SIMDE_SHUFFLE_VECTOR_(32, 32, a_.f32, b_.f32, 1, 3, 9, 11, 5, 7, 13, 15); #else const size_t halfway_point = (sizeof(r_.f32) / sizeof(r_.f32[0])) / 2; const size_t quarter_point = (sizeof(r_.f32) / sizeof(r_.f32[0])) / 4; for (size_t i = 0 ; i < quarter_point ; i++) { r_.f32[i] = a_.f32[2 * i + 1]; r_.f32[i + quarter_point] = b_.f32[2 * i + 1]; r_.f32[halfway_point + i] = a_.f32[halfway_point + 2 * i + 1]; r_.f32[halfway_point + i + quarter_point] = b_.f32[halfway_point + 2 * i + 1]; } #endif return simde__m256_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_x_mm256_deinterleaveeven_pd (simde__m256d a, simde__m256d b) { simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_x_mm_deinterleaveeven_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_x_mm_deinterleaveeven_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_SHUFFLE_VECTOR_) r_.f64 = SIMDE_SHUFFLE_VECTOR_(64, 32, a_.f64, b_.f64, 0, 4, 2, 6); #else const size_t halfway_point = (sizeof(r_.f64) / sizeof(r_.f64[0])) / 2; const size_t quarter_point = (sizeof(r_.f64) / sizeof(r_.f64[0])) / 4; for (size_t i = 0 ; i < quarter_point ; i++) { r_.f64[i] = a_.f64[2 * i]; r_.f64[i + quarter_point] = b_.f64[2 * i]; r_.f64[halfway_point + i] = a_.f64[halfway_point + 2 * i]; r_.f64[halfway_point + i + quarter_point] = b_.f64[halfway_point + 2 * i]; } #endif return simde__m256d_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_x_mm256_deinterleaveodd_pd (simde__m256d a, simde__m256d b) { simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_x_mm_deinterleaveodd_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_x_mm_deinterleaveodd_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_SHUFFLE_VECTOR_) r_.f64 = SIMDE_SHUFFLE_VECTOR_(64, 32, a_.f64, b_.f64, 1, 5, 3, 7); #else const size_t halfway_point = (sizeof(r_.f64) / sizeof(r_.f64[0])) / 2; const size_t quarter_point = (sizeof(r_.f64) / sizeof(r_.f64[0])) / 4; for (size_t i = 0 ; i < quarter_point ; i++) { r_.f64[i] = a_.f64[2 * i + 1]; r_.f64[i + quarter_point] = b_.f64[2 * i + 1]; r_.f64[halfway_point + i] = a_.f64[halfway_point + 2 * i + 1]; r_.f64[halfway_point + i + quarter_point] = b_.f64[halfway_point + 2 * i + 1]; } #endif return simde__m256d_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_x_mm256_abs_ps(simde__m256 a) { simde__m256_private r_, a_ = simde__m256_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = simde_math_fabsf(a_.f32[i]); } return simde__m256_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_x_mm256_abs_pd(simde__m256d a) { simde__m256d_private r_, a_ = simde__m256d_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = simde_math_fabs(a_.f64[i]); } return simde__m256d_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_add_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_add_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_add_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_add_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.f32 = a_.f32 + b_.f32; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = a_.f32[i] + b_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_add_ps #define _mm256_add_ps(a, b) simde_mm256_add_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_hadd_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_hadd_ps(a, b); #else return simde_mm256_add_ps(simde_x_mm256_deinterleaveeven_ps(a, b), simde_x_mm256_deinterleaveodd_ps(a, b)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_hadd_ps #define _mm256_hadd_ps(a, b) simde_mm256_hadd_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_add_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_add_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_add_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_add_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.f64 = a_.f64 + b_.f64; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = a_.f64[i] + b_.f64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_add_pd #define _mm256_add_pd(a, b) simde_mm256_add_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_hadd_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_hadd_pd(a, b); #else return simde_mm256_add_pd(simde_x_mm256_deinterleaveeven_pd(a, b), simde_x_mm256_deinterleaveodd_pd(a, b)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_hadd_pd #define _mm256_hadd_pd(a, b) simde_mm256_hadd_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_addsub_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_addsub_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_addsub_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_addsub_ps(a_.m128[1], b_.m128[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i += 2) { r_.f32[ i ] = a_.f32[ i ] - b_.f32[ i ]; r_.f32[i + 1] = a_.f32[i + 1] + b_.f32[i + 1]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_addsub_ps #define _mm256_addsub_ps(a, b) simde_mm256_addsub_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_addsub_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_addsub_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_addsub_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_addsub_pd(a_.m128d[1], b_.m128d[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i += 2) { r_.f64[ i ] = a_.f64[ i ] - b_.f64[ i ]; r_.f64[i + 1] = a_.f64[i + 1] + b_.f64[i + 1]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_addsub_pd #define _mm256_addsub_pd(a, b) simde_mm256_addsub_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_and_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_and_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_and_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_and_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32f = a_.i32f & b_.i32f; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32f) / sizeof(r_.i32f[0])) ; i++) { r_.i32f[i] = a_.i32f[i] & b_.i32f[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_and_ps #define _mm256_and_ps(a, b) simde_mm256_and_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_and_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_and_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_and_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_and_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32f = a_.i32f & b_.i32f; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32f) / sizeof(r_.i32f[0])) ; i++) { r_.i32f[i] = a_.i32f[i] & b_.i32f[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_and_pd #define _mm256_and_pd(a, b) simde_mm256_and_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_andnot_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_andnot_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_andnot_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_andnot_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32f = ~a_.i32f & b_.i32f; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32f) / sizeof(r_.i32f[0])) ; i++) { r_.i32f[i] = ~a_.i32f[i] & b_.i32f[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_andnot_ps #define _mm256_andnot_ps(a, b) simde_mm256_andnot_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_andnot_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_andnot_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_andnot_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_andnot_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32f = ~a_.i32f & b_.i32f; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32f) / sizeof(r_.i32f[0])) ; i++) { r_.i32f[i] = ~a_.i32f[i] & b_.i32f[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_andnot_pd #define _mm256_andnot_pd(a, b) simde_mm256_andnot_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_blend_ps (simde__m256 a, simde__m256 b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 255) { simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = ((imm8 >> i) & 1) ? b_.f32[i] : a_.f32[i]; } return simde__m256_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_blend_ps(a, b, imm8) _mm256_blend_ps(a, b, imm8) #elif SIMDE_NATURAL_VECTOR_SIZE_LE(128) # define simde_mm256_blend_ps(a, b, imm8) \ simde_mm256_set_m128( \ simde_mm_blend_ps(simde_mm256_extractf128_ps(a, 1), simde_mm256_extractf128_ps(b, 1), (imm8) >> 4), \ simde_mm_blend_ps(simde_mm256_extractf128_ps(a, 0), simde_mm256_extractf128_ps(b, 0), (imm8) & 0x0F)) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_blend_ps #define _mm256_blend_ps(a, b, imm8) simde_mm256_blend_ps(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_blend_pd (simde__m256d a, simde__m256d b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 15) { simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = ((imm8 >> i) & 1) ? b_.f64[i] : a_.f64[i]; } return simde__m256d_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_blend_pd(a, b, imm8) _mm256_blend_pd(a, b, imm8) #elif SIMDE_NATURAL_VECTOR_SIZE_LE(128) # define simde_mm256_blend_pd(a, b, imm8) \ simde_mm256_set_m128d( \ simde_mm_blend_pd(simde_mm256_extractf128_pd(a, 1), simde_mm256_extractf128_pd(b, 1), (imm8) >> 2), \ simde_mm_blend_pd(simde_mm256_extractf128_pd(a, 0), simde_mm256_extractf128_pd(b, 0), (imm8) & 3)) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_blend_pd #define _mm256_blend_pd(a, b, imm8) simde_mm256_blend_pd(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_blendv_ps (simde__m256 a, simde__m256 b, simde__m256 mask) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_blendv_ps(a, b, mask); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b), mask_ = simde__m256_to_private(mask); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_blendv_ps(a_.m128[0], b_.m128[0], mask_.m128[0]); r_.m128[1] = simde_mm_blendv_ps(a_.m128[1], b_.m128[1], mask_.m128[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.u32) / sizeof(r_.u32[0])) ; i++) { r_.f32[i] = (mask_.u32[i] & (UINT32_C(1) << 31)) ? b_.f32[i] : a_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_blendv_ps #define _mm256_blendv_ps(a, b, imm8) simde_mm256_blendv_ps(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_blendv_pd (simde__m256d a, simde__m256d b, simde__m256d mask) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_blendv_pd(a, b, mask); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b), mask_ = simde__m256d_to_private(mask); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_blendv_pd(a_.m128d[0], b_.m128d[0], mask_.m128d[0]); r_.m128d[1] = simde_mm_blendv_pd(a_.m128d[1], b_.m128d[1], mask_.m128d[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.u64) / sizeof(r_.u64[0])) ; i++) { r_.f64[i] = (mask_.u64[i] & (UINT64_C(1) << 63)) ? b_.f64[i] : a_.f64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_blendv_pd #define _mm256_blendv_pd(a, b, imm8) simde_mm256_blendv_pd(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_broadcast_pd (simde__m128d const * mem_addr) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_broadcast_pd(mem_addr); #else simde__m256d_private r_; simde__m128d tmp = simde_mm_loadu_pd(HEDLEY_REINTERPRET_CAST(simde_float64 const*, mem_addr)); r_.m128d[0] = tmp; r_.m128d[1] = tmp; return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_broadcast_pd #define _mm256_broadcast_pd(mem_addr) simde_mm256_broadcast_pd(mem_addr) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_broadcast_ps (simde__m128 const * mem_addr) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_broadcast_ps(mem_addr); #else simde__m256_private r_; simde__m128 tmp = simde_mm_loadu_ps(HEDLEY_REINTERPRET_CAST(simde_float32 const*, mem_addr)); r_.m128[0] = tmp; r_.m128[1] = tmp; return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_broadcast_ps #define _mm256_broadcast_ps(mem_addr) simde_mm256_broadcast_ps(HEDLEY_REINTERPRET_CAST(simde__m128 const*, mem_addr)) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_broadcast_sd (simde_float64 const * a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_broadcast_sd(a); #else return simde_mm256_set1_pd(*a); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_broadcast_sd #define _mm256_broadcast_sd(mem_addr) simde_mm256_broadcast_sd(HEDLEY_REINTERPRET_CAST(double const*, mem_addr)) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128 simde_mm_broadcast_ss (simde_float32 const * a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_broadcast_ss(a); #else return simde_mm_set1_ps(*a); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_broadcast_ss #define _mm_broadcast_ss(mem_addr) simde_mm_broadcast_ss(mem_addr) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_broadcast_ss (simde_float32 const * a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_broadcast_ss(a); #else return simde_mm256_set1_ps(*a); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_broadcast_ss #define _mm256_broadcast_ss(mem_addr) simde_mm256_broadcast_ss(mem_addr) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_castpd128_pd256 (simde__m128d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castpd128_pd256(a); #else simde__m256d_private r_; simde__m128d_private a_ = simde__m128d_to_private(a); r_.m128d_private[0] = a_; return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castpd128_pd256 #define _mm256_castpd128_pd256(a) simde_mm256_castpd128_pd256(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128d simde_mm256_castpd256_pd128 (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castpd256_pd128(a); #else simde__m256d_private a_ = simde__m256d_to_private(a); return a_.m128d[0]; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castpd256_pd128 #define _mm256_castpd256_pd128(a) simde_mm256_castpd256_pd128(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_castps128_ps256 (simde__m128 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castps128_ps256(a); #else simde__m256_private r_; simde__m128_private a_ = simde__m128_to_private(a); r_.m128_private[0] = a_; return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castps128_ps256 #define _mm256_castps128_ps256(a) simde_mm256_castps128_ps256(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128 simde_mm256_castps256_ps128 (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castps256_ps128(a); #else simde__m256_private a_ = simde__m256_to_private(a); return a_.m128[0]; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castps256_ps128 #define _mm256_castps256_ps128(a) simde_mm256_castps256_ps128(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_castsi128_si256 (simde__m128i a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castsi128_si256(a); #else simde__m256i_private r_; simde__m128i_private a_ = simde__m128i_to_private(a); r_.m128i_private[0] = a_; return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castsi128_si256 #define _mm256_castsi128_si256(a) simde_mm256_castsi128_si256(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128i simde_mm256_castsi256_si128 (simde__m256i a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_castsi256_si128(a); #else simde__m256i_private a_ = simde__m256i_to_private(a); return a_.m128i[0]; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_castsi256_si128 #define _mm256_castsi256_si128(a) simde_mm256_castsi256_si128(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_round_ps (simde__m256 a, const int rounding) { simde__m256_private r_, a_ = simde__m256_to_private(a); switch (rounding & ~SIMDE_MM_FROUND_NO_EXC) { #if defined(simde_math_nearbyintf) case SIMDE_MM_FROUND_CUR_DIRECTION: for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = simde_math_nearbyintf(a_.f32[i]); } break; #endif #if defined(simde_math_roundf) case SIMDE_MM_FROUND_TO_NEAREST_INT: for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = simde_math_roundf(a_.f32[i]); } break; #endif #if defined(simde_math_floorf) case SIMDE_MM_FROUND_TO_NEG_INF: for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = simde_math_floorf(a_.f32[i]); } break; #endif #if defined(simde_math_ceilf) case SIMDE_MM_FROUND_TO_POS_INF: for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = simde_math_ceilf(a_.f32[i]); } break; #endif #if defined(simde_math_truncf) case SIMDE_MM_FROUND_TO_ZERO: for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = simde_math_truncf(a_.f32[i]); } break; #endif default: HEDLEY_UNREACHABLE_RETURN(simde_mm256_undefined_ps()); } return simde__m256_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_round_ps(a, rounding) _mm256_round_ps(a, rounding) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_round_ps #define _mm256_round_ps(a, rounding) simde_mm256_round_ps(a, rounding) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_round_pd (simde__m256d a, const int rounding) { simde__m256d_private r_, a_ = simde__m256d_to_private(a); switch (rounding & ~SIMDE_MM_FROUND_NO_EXC) { #if defined(simde_math_nearbyint) case SIMDE_MM_FROUND_CUR_DIRECTION: for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = simde_math_nearbyint(a_.f64[i]); } break; #endif #if defined(simde_math_round) case SIMDE_MM_FROUND_TO_NEAREST_INT: for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = simde_math_round(a_.f64[i]); } break; #endif #if defined(simde_math_floor) case SIMDE_MM_FROUND_TO_NEG_INF: for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = simde_math_floor(a_.f64[i]); } break; #endif #if defined(simde_math_ceil) case SIMDE_MM_FROUND_TO_POS_INF: for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = simde_math_ceil(a_.f64[i]); } break; #endif #if defined(simde_math_trunc) case SIMDE_MM_FROUND_TO_ZERO: for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = simde_math_trunc(a_.f64[i]); } break; #endif default: HEDLEY_UNREACHABLE_RETURN(simde_mm256_undefined_pd()); } return simde__m256d_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_round_pd(a, rounding) _mm256_round_pd(a, rounding) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_round_pd #define _mm256_round_pd(a, rounding) simde_mm256_round_pd(a, rounding) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_ceil_pd (simde__m256d a) { return simde_mm256_round_pd(a, SIMDE_MM_FROUND_TO_POS_INF); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_ceil_pd #define _mm256_ceil_pd(a) simde_mm256_ceil_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_ceil_ps (simde__m256 a) { return simde_mm256_round_ps(a, SIMDE_MM_FROUND_TO_POS_INF); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_ceil_ps #define _mm256_ceil_ps(a) simde_mm256_ceil_ps(a) #endif HEDLEY_DIAGNOSTIC_PUSH SIMDE_DIAGNOSTIC_DISABLE_FLOAT_EQUAL /* This implementation does not support signaling NaNs (yet?) */ SIMDE_FUNCTION_ATTRIBUTES simde__m128d simde_mm_cmp_pd (simde__m128d a, simde__m128d b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 31) { switch (imm8) { case SIMDE_CMP_EQ_OQ: case SIMDE_CMP_EQ_UQ: case SIMDE_CMP_EQ_OS: case SIMDE_CMP_EQ_US: return simde_mm_cmpeq_pd(a, b); break; case SIMDE_CMP_LT_OS: case SIMDE_CMP_NGE_US: case SIMDE_CMP_LT_OQ: case SIMDE_CMP_NGE_UQ: return simde_mm_cmplt_pd(a, b); break; case SIMDE_CMP_LE_OS: case SIMDE_CMP_NGT_US: case SIMDE_CMP_LE_OQ: case SIMDE_CMP_NGT_UQ: return simde_mm_cmple_pd(a, b); break; case SIMDE_CMP_NEQ_UQ: case SIMDE_CMP_NEQ_OQ: case SIMDE_CMP_NEQ_US: case SIMDE_CMP_NEQ_OS: return simde_mm_cmpneq_pd(a, b); break; case SIMDE_CMP_NLT_US: case SIMDE_CMP_GE_OS: case SIMDE_CMP_NLT_UQ: case SIMDE_CMP_GE_OQ: return simde_mm_cmpge_pd(a, b); break; case SIMDE_CMP_NLE_US: case SIMDE_CMP_GT_OS: case SIMDE_CMP_NLE_UQ: case SIMDE_CMP_GT_OQ: return simde_mm_cmpgt_pd(a, b); break; case SIMDE_CMP_FALSE_OQ: case SIMDE_CMP_FALSE_OS: return simde_mm_setzero_pd(); break; case SIMDE_CMP_TRUE_UQ: case SIMDE_CMP_TRUE_US: return simde_x_mm_setone_pd(); break; case SIMDE_CMP_UNORD_Q: case SIMDE_CMP_UNORD_S: return simde_mm_cmpunord_pd(a, b); break; case SIMDE_CMP_ORD_Q: case SIMDE_CMP_ORD_S: return simde_mm_cmpord_pd(a, b); break; } HEDLEY_UNREACHABLE_RETURN(simde_mm_setzero_pd()); } #if defined(SIMDE_X86_AVX_NATIVE) && (!defined(__clang__) || !defined(__AVX512F__)) # define simde_mm_cmp_pd(a, b, imm8) _mm_cmp_pd(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_cmp_pd #define _mm_cmp_pd(a, b, imm8) simde_mm_cmp_pd(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128 simde_mm_cmp_ps (simde__m128 a, simde__m128 b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 31) { switch (imm8) { case SIMDE_CMP_EQ_OQ: case SIMDE_CMP_EQ_UQ: case SIMDE_CMP_EQ_OS: case SIMDE_CMP_EQ_US: return simde_mm_cmpeq_ps(a, b); break; case SIMDE_CMP_LT_OS: case SIMDE_CMP_NGE_US: case SIMDE_CMP_LT_OQ: case SIMDE_CMP_NGE_UQ: return simde_mm_cmplt_ps(a, b); break; case SIMDE_CMP_LE_OS: case SIMDE_CMP_NGT_US: case SIMDE_CMP_LE_OQ: case SIMDE_CMP_NGT_UQ: return simde_mm_cmple_ps(a, b); break; case SIMDE_CMP_NEQ_UQ: case SIMDE_CMP_NEQ_OQ: case SIMDE_CMP_NEQ_US: case SIMDE_CMP_NEQ_OS: return simde_mm_cmpneq_ps(a, b); break; case SIMDE_CMP_NLT_US: case SIMDE_CMP_GE_OS: case SIMDE_CMP_NLT_UQ: case SIMDE_CMP_GE_OQ: return simde_mm_cmpge_ps(a, b); break; case SIMDE_CMP_NLE_US: case SIMDE_CMP_GT_OS: case SIMDE_CMP_NLE_UQ: case SIMDE_CMP_GT_OQ: return simde_mm_cmpgt_ps(a, b); break; case SIMDE_CMP_FALSE_OQ: case SIMDE_CMP_FALSE_OS: return simde_mm_setzero_ps(); break; case SIMDE_CMP_TRUE_UQ: case SIMDE_CMP_TRUE_US: return simde_x_mm_setone_ps(); break; case SIMDE_CMP_UNORD_Q: case SIMDE_CMP_UNORD_S: return simde_mm_cmpunord_ps(a, b); break; case SIMDE_CMP_ORD_Q: case SIMDE_CMP_ORD_S: return simde_mm_cmpord_ps(a, b); break; } HEDLEY_UNREACHABLE_RETURN(simde_mm_setzero_ps()); } /* Prior to 9.0 clang has problems with _mm{,256}_cmp_{ps,pd} for all four of the true/false comparisons, but only when AVX-512 is enabled. __FILE_NAME__ was added in 9.0, so that's what we use to check for clang 9 since the version macros are unreliable. */ #if defined(SIMDE_X86_AVX_NATIVE) && (!defined(__clang__) || !defined(__AVX512F__)) # define simde_mm_cmp_ps(a, b, imm8) _mm_cmp_ps(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_cmp_ps #define _mm_cmp_ps(a, b, imm8) simde_mm_cmp_ps(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128d simde_mm_cmp_sd (simde__m128d a, simde__m128d b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 31) { simde__m128d_private r_, a_ = simde__m128d_to_private(a), b_ = simde__m128d_to_private(b); switch (imm8) { case SIMDE_CMP_EQ_OQ: r_.u64[0] = (a_.f64[0] == b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_LT_OS: r_.u64[0] = (a_.f64[0] < b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_LE_OS: r_.u64[0] = (a_.f64[0] <= b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_UNORD_Q: #if defined(simde_math_isnan) r_.u64[0] = (simde_math_isnan(a_.f64[0]) || simde_math_isnan(b_.f64[0])) ? ~UINT64_C(0) : UINT64_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_UQ: r_.u64[0] = (a_.f64[0] != b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NLT_US: r_.u64[0] = (a_.f64[0] >= b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NLE_US: r_.u64[0] = (a_.f64[0] > b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_ORD_Q: #if defined(simde_math_isnan) r_.u64[0] = (!simde_math_isnan(a_.f64[0]) && !simde_math_isnan(b_.f64[0])) ? ~UINT64_C(0) : UINT64_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_UQ: r_.u64[0] = (a_.f64[0] == b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NGE_US: r_.u64[0] = (a_.f64[0] < b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NGT_US: r_.u64[0] = (a_.f64[0] <= b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_FALSE_OQ: r_.u64[0] = UINT64_C(0); break; case SIMDE_CMP_NEQ_OQ: r_.u64[0] = (a_.f64[0] != b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_GE_OS: r_.u64[0] = (a_.f64[0] >= b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_GT_OS: r_.u64[0] = (a_.f64[0] > b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_TRUE_UQ: r_.u64[0] = ~UINT64_C(0); break; case SIMDE_CMP_EQ_OS: r_.u64[0] = (a_.f64[0] == b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_LT_OQ: r_.u64[0] = (a_.f64[0] < b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_LE_OQ: r_.u64[0] = (a_.f64[0] <= b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_UNORD_S: #if defined(simde_math_isnan) r_.u64[0] = (simde_math_isnan(a_.f64[0]) || simde_math_isnan(b_.f64[0])) ? ~UINT64_C(0) : UINT64_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_US: r_.u64[0] = (a_.f64[0] != b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NLT_UQ: r_.u64[0] = (a_.f64[0] >= b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NLE_UQ: r_.u64[0] = (a_.f64[0] > b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_ORD_S: #if defined(simde_math_isnan) r_.u64[0] = (simde_math_isnan(a_.f64[0]) || simde_math_isnan(b_.f64[0])) ? UINT64_C(0) : ~UINT64_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_US: r_.u64[0] = (a_.f64[0] == b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NGE_UQ: r_.u64[0] = (a_.f64[0] < b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NGT_UQ: r_.u64[0] = (a_.f64[0] <= b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_FALSE_OS: r_.u64[0] = UINT64_C(0); break; case SIMDE_CMP_NEQ_OS: r_.u64[0] = (a_.f64[0] != b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_GE_OQ: r_.u64[0] = (a_.f64[0] >= b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_GT_OQ: r_.u64[0] = (a_.f64[0] > b_.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_TRUE_US: r_.u64[0] = ~UINT64_C(0); break; } r_.u64[1] = a_.u64[1]; return simde__m128d_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm_cmp_sd(a, b, imm8) _mm_cmp_sd(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_cmp_sd #define _mm_cmp_sd(a, b, imm8) simde_mm_cmp_sd(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128 simde_mm_cmp_ss (simde__m128 a, simde__m128 b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 31) { simde__m128_private r_, a_ = simde__m128_to_private(a), b_ = simde__m128_to_private(b); switch (imm8) { case SIMDE_CMP_EQ_OQ: r_.u32[0] = (a_.f32[0] == b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_LT_OS: r_.u32[0] = (a_.f32[0] < b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_LE_OS: r_.u32[0] = (a_.f32[0] <= b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_UNORD_Q: #if defined(simde_math_isnanf) r_.u32[0] = (simde_math_isnanf(a_.f32[0]) || simde_math_isnanf(b_.f32[0])) ? ~UINT32_C(0) : UINT32_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_UQ: r_.u32[0] = (a_.f32[0] != b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NLT_US: r_.u32[0] = (a_.f32[0] >= b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NLE_US: r_.u32[0] = (a_.f32[0] > b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_ORD_Q: #if defined(simde_math_isnanf) r_.u32[0] = (!simde_math_isnanf(a_.f32[0]) && !simde_math_isnanf(b_.f32[0])) ? ~UINT32_C(0) : UINT32_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_UQ: r_.u32[0] = (a_.f32[0] == b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NGE_US: r_.u32[0] = (a_.f32[0] < b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NGT_US: r_.u32[0] = (a_.f32[0] <= b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_FALSE_OQ: r_.u32[0] = UINT32_C(0); break; case SIMDE_CMP_NEQ_OQ: r_.u32[0] = (a_.f32[0] != b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_GE_OS: r_.u32[0] = (a_.f32[0] >= b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_GT_OS: r_.u32[0] = (a_.f32[0] > b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_TRUE_UQ: r_.u32[0] = ~UINT32_C(0); break; case SIMDE_CMP_EQ_OS: r_.u32[0] = (a_.f32[0] == b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_LT_OQ: r_.u32[0] = (a_.f32[0] < b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_LE_OQ: r_.u32[0] = (a_.f32[0] <= b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_UNORD_S: #if defined(simde_math_isnanf) r_.u32[0] = (simde_math_isnanf(a_.f32[0]) || simde_math_isnanf(b_.f32[0])) ? ~UINT32_C(0) : UINT32_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_US: r_.u32[0] = (a_.f32[0] != b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NLT_UQ: r_.u32[0] = (a_.f32[0] >= b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NLE_UQ: r_.u32[0] = (a_.f32[0] > b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_ORD_S: #if defined(simde_math_isnanf) r_.u32[0] = (simde_math_isnanf(a_.f32[0]) || simde_math_isnanf(b_.f32[0])) ? UINT32_C(0) : ~UINT32_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_US: r_.u32[0] = (a_.f32[0] == b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NGE_UQ: r_.u32[0] = (a_.f32[0] < b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NGT_UQ: r_.u32[0] = (a_.f32[0] <= b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_FALSE_OS: r_.u32[0] = UINT32_C(0); break; case SIMDE_CMP_NEQ_OS: r_.u32[0] = (a_.f32[0] != b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_GE_OQ: r_.u32[0] = (a_.f32[0] >= b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_GT_OQ: r_.u32[0] = (a_.f32[0] > b_.f32[0]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_TRUE_US: r_.u32[0] = ~UINT32_C(0); break; } r_.u32[1] = a_.u32[1]; r_.u32[2] = a_.u32[2]; r_.u32[3] = a_.u32[3]; return simde__m128_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm_cmp_ss(a, b, imm8) _mm_cmp_ss(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_cmp_ss #define _mm_cmp_ss(a, b, imm8) simde_mm_cmp_ss(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_cmp_pd (simde__m256d a, simde__m256d b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 31) { simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS) switch (imm8) { case SIMDE_CMP_EQ_OQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 == b_.f64)); break; case SIMDE_CMP_LT_OS: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 < b_.f64)); break; case SIMDE_CMP_LE_OS: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 <= b_.f64)); break; case SIMDE_CMP_UNORD_Q: #if defined(simde_math_isnan) for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.u64[i] = (simde_math_isnan(a_.f64[i]) || simde_math_isnan(b_.f64[i])) ? ~UINT64_C(0) : UINT64_C(0); } #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_UQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 != b_.f64)); break; case SIMDE_CMP_NLT_US: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 >= b_.f64)); break; case SIMDE_CMP_NLE_US: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 > b_.f64)); break; case SIMDE_CMP_ORD_Q: #if defined(simde_math_isnan) for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.u64[i] = (!simde_math_isnan(a_.f64[i]) && !simde_math_isnan(b_.f64[i])) ? ~UINT64_C(0) : UINT64_C(0); } #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_UQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 == b_.f64)); break; case SIMDE_CMP_NGE_US: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 < b_.f64)); break; case SIMDE_CMP_NGT_US: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 <= b_.f64)); break; case SIMDE_CMP_FALSE_OQ: r_ = simde__m256d_to_private(simde_mm256_setzero_pd()); break; case SIMDE_CMP_NEQ_OQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 != b_.f64)); break; case SIMDE_CMP_GE_OS: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 >= b_.f64)); break; case SIMDE_CMP_GT_OS: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 > b_.f64)); break; case SIMDE_CMP_TRUE_UQ: r_ = simde__m256d_to_private(simde_x_mm256_setone_pd()); break; case SIMDE_CMP_EQ_OS: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 == b_.f64)); break; case SIMDE_CMP_LT_OQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 < b_.f64)); break; case SIMDE_CMP_LE_OQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 <= b_.f64)); break; case SIMDE_CMP_UNORD_S: #if defined(simde_math_isnan) for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.u64[i] = (simde_math_isnan(a_.f64[i]) || simde_math_isnan(b_.f64[i])) ? ~UINT64_C(0) : UINT64_C(0); } #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_US: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 != b_.f64)); break; case SIMDE_CMP_NLT_UQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 >= b_.f64)); break; case SIMDE_CMP_NLE_UQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 > b_.f64)); break; case SIMDE_CMP_ORD_S: #if defined(simde_math_isnan) for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.u64[i] = (simde_math_isnan(a_.f64[i]) || simde_math_isnan(b_.f64[i])) ? UINT64_C(0) : ~UINT64_C(0); } #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_US: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 == b_.f64)); break; case SIMDE_CMP_NGE_UQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 < b_.f64)); break; case SIMDE_CMP_NGT_UQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 <= b_.f64)); break; case SIMDE_CMP_FALSE_OS: r_ = simde__m256d_to_private(simde_mm256_setzero_pd()); break; case SIMDE_CMP_NEQ_OS: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 != b_.f64)); break; case SIMDE_CMP_GE_OQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 >= b_.f64)); break; case SIMDE_CMP_GT_OQ: r_.i64 = HEDLEY_STATIC_CAST(__typeof__(r_.i64), (a_.f64 > b_.f64)); break; case SIMDE_CMP_TRUE_US: r_ = simde__m256d_to_private(simde_x_mm256_setone_pd()); break; default: HEDLEY_UNREACHABLE(); break; } #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { switch (imm8) { case SIMDE_CMP_EQ_OQ: r_.u64[i] = (a_.f64[i] == b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_LT_OS: r_.u64[i] = (a_.f64[i] < b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_LE_OS: r_.u64[i] = (a_.f64[i] <= b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_UNORD_Q: r_.u64[i] = (simde_math_isnan(a_.f64[i]) || simde_math_isnan(b_.f64[i])) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NEQ_UQ: r_.u64[i] = (a_.f64[i] != b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NLT_US: r_.u64[i] = (a_.f64[i] >= b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NLE_US: r_.u64[i] = (a_.f64[i] > b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_ORD_Q: #if defined(simde_math_isnan) r_.u64[i] = (!simde_math_isnan(a_.f64[i]) && !simde_math_isnan(b_.f64[i])) ? ~UINT64_C(0) : UINT64_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_UQ: r_.u64[i] = (a_.f64[i] == b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NGE_US: r_.u64[i] = (a_.f64[i] < b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NGT_US: r_.u64[i] = (a_.f64[i] <= b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_FALSE_OQ: r_.u64[i] = UINT64_C(0); break; case SIMDE_CMP_NEQ_OQ: r_.u64[i] = (a_.f64[i] != b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_GE_OS: r_.u64[i] = (a_.f64[i] >= b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_GT_OS: r_.u64[i] = (a_.f64[i] > b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_TRUE_UQ: r_.u64[i] = ~UINT64_C(0); break; case SIMDE_CMP_EQ_OS: r_.u64[i] = (a_.f64[i] == b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_LT_OQ: r_.u64[i] = (a_.f64[i] < b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_LE_OQ: r_.u64[i] = (a_.f64[i] <= b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_UNORD_S: #if defined(simde_math_isnan) r_.u64[i] = (simde_math_isnan(a_.f64[i]) || simde_math_isnan(b_.f64[i])) ? ~UINT64_C(0) : UINT64_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_US: r_.u64[i] = (a_.f64[i] != b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NLT_UQ: r_.u64[i] = (a_.f64[i] >= b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NLE_UQ: r_.u64[i] = (a_.f64[i] > b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_ORD_S: #if defined(simde_math_isnan) r_.u64[i] = (simde_math_isnan(a_.f64[i]) || simde_math_isnan(b_.f64[i])) ? UINT64_C(0) : ~UINT64_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_US: r_.u64[i] = (a_.f64[i] == b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NGE_UQ: r_.u64[i] = (a_.f64[i] < b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_NGT_UQ: r_.u64[i] = (a_.f64[i] <= b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_FALSE_OS: r_.u64[i] = UINT64_C(0); break; case SIMDE_CMP_NEQ_OS: r_.u64[i] = (a_.f64[i] != b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_GE_OQ: r_.u64[i] = (a_.f64[i] >= b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_GT_OQ: r_.u64[i] = (a_.f64[i] > b_.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); break; case SIMDE_CMP_TRUE_US: r_.u64[i] = ~UINT64_C(0); break; default: HEDLEY_UNREACHABLE(); break; } } #endif return simde__m256d_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) && (!defined(__clang__) || !defined(__AVX512F__)) # define simde_mm256_cmp_pd(a, b, imm8) _mm256_cmp_pd(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cmp_pd #define _mm256_cmp_pd(a, b, imm8) simde_mm256_cmp_pd(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_cmp_ps (simde__m256 a, simde__m256 b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 31) { simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if defined(SIMDE_VECTOR_SUBSCRIPT_OPS) switch (imm8) { case SIMDE_CMP_EQ_OQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 == b_.f32)); break; case SIMDE_CMP_LT_OS: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 < b_.f32)); break; case SIMDE_CMP_LE_OS: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 <= b_.f32)); break; case SIMDE_CMP_UNORD_Q: #if defined(simde_math_isnanf) for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.u32[i] = (simde_math_isnanf(a_.f32[i]) || simde_math_isnanf(b_.f32[i])) ? ~UINT32_C(0) : UINT32_C(0); } #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_UQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 != b_.f32)); break; case SIMDE_CMP_NLT_US: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 >= b_.f32)); break; case SIMDE_CMP_NLE_US: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 > b_.f32)); break; case SIMDE_CMP_ORD_Q: #if defined(simde_math_isnanf) for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.u32[i] = (!simde_math_isnanf(a_.f32[i]) && !simde_math_isnanf(b_.f32[i])) ? ~UINT32_C(0) : UINT32_C(0); } #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_UQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 == b_.f32)); break; case SIMDE_CMP_NGE_US: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 < b_.f32)); break; case SIMDE_CMP_NGT_US: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 <= b_.f32)); break; case SIMDE_CMP_FALSE_OQ: r_ = simde__m256_to_private(simde_mm256_setzero_ps()); break; case SIMDE_CMP_NEQ_OQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 != b_.f32)); break; case SIMDE_CMP_GE_OS: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 >= b_.f32)); break; case SIMDE_CMP_GT_OS: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 > b_.f32)); break; case SIMDE_CMP_TRUE_UQ: r_ = simde__m256_to_private(simde_x_mm256_setone_ps()); break; case SIMDE_CMP_EQ_OS: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 == b_.f32)); break; case SIMDE_CMP_LT_OQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 < b_.f32)); break; case SIMDE_CMP_LE_OQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 <= b_.f32)); break; case SIMDE_CMP_UNORD_S: #if defined(simde_math_isnanf) for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.u32[i] = (simde_math_isnanf(a_.f32[i]) || simde_math_isnanf(b_.f32[i])) ? ~UINT32_C(0) : UINT32_C(0); } #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_US: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 != b_.f32)); break; case SIMDE_CMP_NLT_UQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 >= b_.f32)); break; case SIMDE_CMP_NLE_UQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 > b_.f32)); break; case SIMDE_CMP_ORD_S: #if defined(simde_math_isnanf) for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.u32[i] = (simde_math_isnanf(a_.f32[i]) || simde_math_isnanf(b_.f32[i])) ? UINT32_C(0) : ~UINT32_C(0); } #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_US: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 == b_.f32)); break; case SIMDE_CMP_NGE_UQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 < b_.f32)); break; case SIMDE_CMP_NGT_UQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 <= b_.f32)); break; case SIMDE_CMP_FALSE_OS: r_ = simde__m256_to_private(simde_mm256_setzero_ps()); break; case SIMDE_CMP_NEQ_OS: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 != b_.f32)); break; case SIMDE_CMP_GE_OQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 >= b_.f32)); break; case SIMDE_CMP_GT_OQ: r_.i32 = HEDLEY_STATIC_CAST(__typeof__(r_.i32), (a_.f32 > b_.f32)); break; case SIMDE_CMP_TRUE_US: r_ = simde__m256_to_private(simde_x_mm256_setone_ps()); break; default: HEDLEY_UNREACHABLE(); break; } #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { switch (imm8) { case SIMDE_CMP_EQ_OQ: r_.u32[i] = (a_.f32[i] == b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_LT_OS: r_.u32[i] = (a_.f32[i] < b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_LE_OS: r_.u32[i] = (a_.f32[i] <= b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_UNORD_Q: #if defined(simde_math_isnanf) r_.u32[i] = (simde_math_isnanf(a_.f32[i]) || simde_math_isnanf(b_.f32[i])) ? ~UINT32_C(0) : UINT32_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_UQ: r_.u32[i] = (a_.f32[i] != b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NLT_US: r_.u32[i] = (a_.f32[i] >= b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NLE_US: r_.u32[i] = (a_.f32[i] > b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_ORD_Q: #if defined(simde_math_isnanf) r_.u32[i] = (!simde_math_isnanf(a_.f32[i]) && !simde_math_isnanf(b_.f32[i])) ? ~UINT32_C(0) : UINT32_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_UQ: r_.u32[i] = (a_.f32[i] == b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NGE_US: r_.u32[i] = (a_.f32[i] < b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NGT_US: r_.u32[i] = (a_.f32[i] <= b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_FALSE_OQ: r_.u32[i] = UINT32_C(0); break; case SIMDE_CMP_NEQ_OQ: r_.u32[i] = (a_.f32[i] != b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_GE_OS: r_.u32[i] = (a_.f32[i] >= b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_GT_OS: r_.u32[i] = (a_.f32[i] > b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_TRUE_UQ: r_.u32[i] = ~UINT32_C(0); break; case SIMDE_CMP_EQ_OS: r_.u32[i] = (a_.f32[i] == b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_LT_OQ: r_.u32[i] = (a_.f32[i] < b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_LE_OQ: r_.u32[i] = (a_.f32[i] <= b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_UNORD_S: #if defined(simde_math_isnanf) r_.u32[i] = (simde_math_isnanf(a_.f32[i]) || simde_math_isnanf(b_.f32[i])) ? ~UINT32_C(0) : UINT32_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_NEQ_US: r_.u32[i] = (a_.f32[i] != b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NLT_UQ: r_.u32[i] = (a_.f32[i] >= b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NLE_UQ: r_.u32[i] = (a_.f32[i] > b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_ORD_S: #if defined(simde_math_isnanf) r_.u32[i] = (simde_math_isnanf(a_.f32[i]) || simde_math_isnanf(b_.f32[i])) ? UINT32_C(0) : ~UINT32_C(0); #else HEDLEY_UNREACHABLE(); #endif break; case SIMDE_CMP_EQ_US: r_.u32[i] = (a_.f32[i] == b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NGE_UQ: r_.u32[i] = (a_.f32[i] < b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_NGT_UQ: r_.u32[i] = (a_.f32[i] <= b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_FALSE_OS: r_.u32[i] = UINT32_C(0); break; case SIMDE_CMP_NEQ_OS: r_.u32[i] = (a_.f32[i] != b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_GE_OQ: r_.u32[i] = (a_.f32[i] >= b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_GT_OQ: r_.u32[i] = (a_.f32[i] > b_.f32[i]) ? ~UINT32_C(0) : UINT32_C(0); break; case SIMDE_CMP_TRUE_US: r_.u32[i] = ~UINT32_C(0); break; default: HEDLEY_UNREACHABLE(); break; } } #endif return simde__m256_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) && (!defined(__clang__) || !defined(__AVX512F__)) # define simde_mm256_cmp_ps(a, b, imm8) _mm256_cmp_ps(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cmp_ps #define _mm256_cmp_ps(a, b, imm8) simde_mm256_cmp_ps(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_x_mm256_copysign_ps(simde__m256 dest, simde__m256 src) { simde__m256_private r_, dest_ = simde__m256_to_private(dest), src_ = simde__m256_to_private(src); #if defined(simde_math_copysignf) SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = simde_math_copysignf(dest_.f32[i], src_.f32[i]); } #else simde__m256 sgnbit = simde_mm256_xor_ps(simde_mm256_set1_ps(SIMDE_FLOAT32_C(0.0)), simde_mm256_set1_ps(-SIMDE_FLOAT32_C(0.0))); return simde_mm256_xor_ps(simde_mm256_and_ps(sgnbit, src), simde_mm256_andnot_ps(sgnbit, dest)); #endif return simde__m256_from_private(r_); } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_x_mm256_copysign_pd(simde__m256d dest, simde__m256d src) { simde__m256d_private r_, dest_ = simde__m256d_to_private(dest), src_ = simde__m256d_to_private(src); #if defined(simde_math_copysign) SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = simde_math_copysign(dest_.f64[i], src_.f64[i]); } #else simde__m256d sgnbit = simde_mm256_xor_pd(simde_mm256_set1_pd(SIMDE_FLOAT64_C(0.0)), simde_mm256_set1_pd(-SIMDE_FLOAT64_C(0.0))); return simde_mm256_xor_pd(simde_mm256_and_pd(sgnbit, src), simde_mm256_andnot_pd(sgnbit, dest)); #endif return simde__m256d_from_private(r_); } HEDLEY_DIAGNOSTIC_POP /* -Wfloat-equal */ SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_cvtepi32_pd (simde__m128i a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_cvtepi32_pd(a); #else simde__m256d_private r_; simde__m128i_private a_ = simde__m128i_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = HEDLEY_STATIC_CAST(simde_float64, a_.i32[i]); } return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvtepi32_pd #define _mm256_cvtepi32_pd(a) simde_mm256_cvtepi32_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_cvtepi32_ps (simde__m256i a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_cvtepi32_ps(a); #else simde__m256_private r_; simde__m256i_private a_ = simde__m256i_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = HEDLEY_STATIC_CAST(simde_float32, a_.i32[i]); } return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvtepi32_ps #define _mm256_cvtepi32_ps(a) simde_mm256_cvtepi32_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128i simde_mm256_cvtpd_epi32 (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_cvtpd_epi32(a); #else simde__m128i_private r_; simde__m256d_private a_ = simde__m256d_to_private(a); #if defined(simde_math_nearbyint) SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(a_.f64) / sizeof(a_.f64[0])) ; i++) { r_.i32[i] = SIMDE_CONVERT_FTOI(int32_t, simde_math_nearbyint(a_.f64[i])); } #else HEDLEY_UNREACHABLE(); #endif return simde__m128i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvtpd_epi32 #define _mm256_cvtpd_epi32(a) simde_mm256_cvtpd_epi32(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128 simde_mm256_cvtpd_ps (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_cvtpd_ps(a); #else simde__m128_private r_; simde__m256d_private a_ = simde__m256d_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = HEDLEY_STATIC_CAST(simde_float32, a_.f64[i]); } return simde__m128_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvtpd_ps #define _mm256_cvtpd_ps(a) simde_mm256_cvtpd_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_cvtps_epi32 (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_cvtps_epi32(a); #else simde__m256i_private r_; simde__m256_private a_ = simde__m256_to_private(a); #if defined(simde_math_nearbyintf) SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(a_.f32) / sizeof(a_.f32[0])) ; i++) { r_.i32[i] = SIMDE_CONVERT_FTOI(int32_t, simde_math_nearbyintf(a_.f32[i])); } #else HEDLEY_UNREACHABLE(); #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvtps_epi32 #define _mm256_cvtps_epi32(a) simde_mm256_cvtps_epi32(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_cvtps_pd (simde__m128 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_cvtps_pd(a); #else simde__m256d_private r_; simde__m128_private a_ = simde__m128_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(a_.f32) / sizeof(a_.f32[0])) ; i++) { r_.f64[i] = HEDLEY_STATIC_CAST(double, a_.f32[i]); } return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvtps_pd #define _mm256_cvtps_pd(a) simde_mm256_cvtps_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde_float64 simde_mm256_cvtsd_f64 (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) && ( \ SIMDE_DETECT_CLANG_VERSION_CHECK(3,9,0) || \ HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ HEDLEY_MSVC_VERSION_CHECK(19,14,0)) return _mm256_cvtsd_f64(a); #else simde__m256d_private a_ = simde__m256d_to_private(a); return a_.f64[0]; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvtsd_f64 #define _mm256_cvtsd_f64(a) simde_mm256_cvtsd_f64(a) #endif SIMDE_FUNCTION_ATTRIBUTES int32_t simde_mm256_cvtsi256_si32 (simde__m256i a) { #if defined(SIMDE_X86_AVX_NATIVE) && ( \ SIMDE_DETECT_CLANG_VERSION_CHECK(3,9,0) || \ HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ HEDLEY_MSVC_VERSION_CHECK(19,14,0)) return _mm256_cvtsi256_si32(a); #else simde__m256i_private a_ = simde__m256i_to_private(a); return a_.i32[0]; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvtsi256_si32 #define _mm256_cvtsi256_si32(a) simde_mm256_cvtsi256_si32(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde_float32 simde_mm256_cvtss_f32 (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) && ( \ SIMDE_DETECT_CLANG_VERSION_CHECK(3,9,0) || \ HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ HEDLEY_MSVC_VERSION_CHECK(19,14,0)) return _mm256_cvtss_f32(a); #else simde__m256_private a_ = simde__m256_to_private(a); return a_.f32[0]; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvtss_f32 #define _mm256_cvtss_f32(a) simde_mm256_cvtss_f32(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128i simde_mm256_cvttpd_epi32 (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_cvttpd_epi32(a); #else simde__m128i_private r_; simde__m256d_private a_ = simde__m256d_to_private(a); #if defined(simde_math_trunc) SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(a_.f64) / sizeof(a_.f64[0])) ; i++) { r_.i32[i] = SIMDE_CONVERT_FTOI(int32_t, simde_math_trunc(a_.f64[i])); } #else HEDLEY_UNREACHABLE(); #endif return simde__m128i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvttpd_epi32 #define _mm256_cvttpd_epi32(a) simde_mm256_cvttpd_epi32(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_cvttps_epi32 (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_cvttps_epi32(a); #else simde__m256i_private r_; simde__m256_private a_ = simde__m256_to_private(a); #if defined(simde_math_truncf) SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(a_.f32) / sizeof(a_.f32[0])) ; i++) { r_.i32[i] = SIMDE_CONVERT_FTOI(int32_t, simde_math_truncf(a_.f32[i])); } #else HEDLEY_UNREACHABLE(); #endif return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_cvttps_epi32 #define _mm256_cvttps_epi32(a) simde_mm256_cvttps_epi32(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_div_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_div_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_div_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_div_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.f32 = a_.f32 / b_.f32; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = a_.f32[i] / b_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_div_ps #define _mm256_div_ps(a, b) simde_mm256_div_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_div_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_div_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_div_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_div_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.f64 = a_.f64 / b_.f64; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = a_.f64[i] / b_.f64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_div_pd #define _mm256_div_pd(a, b) simde_mm256_div_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128d simde_mm256_extractf128_pd (simde__m256d a, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 1) { simde__m256d_private a_ = simde__m256d_to_private(a); return a_.m128d[imm8]; } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_extractf128_pd(a, imm8) _mm256_extractf128_pd(a, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_extractf128_pd #define _mm256_extractf128_pd(a, imm8) simde_mm256_extractf128_pd(a, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128 simde_mm256_extractf128_ps (simde__m256 a, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 1) { simde__m256_private a_ = simde__m256_to_private(a); return a_.m128[imm8]; } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_extractf128_ps(a, imm8) _mm256_extractf128_ps(a, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_extractf128_ps #define _mm256_extractf128_ps(a, imm8) simde_mm256_extractf128_ps(a, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128i simde_mm256_extractf128_si256 (simde__m256i a, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 1) { simde__m256i_private a_ = simde__m256i_to_private(a); return a_.m128i[imm8]; } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_extractf128_si256(a, imm8) _mm256_extractf128_si256(a, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_extractf128_si256 #define _mm256_extractf128_si256(a, imm8) simde_mm256_extractf128_si256(a, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_floor_pd (simde__m256d a) { return simde_mm256_round_pd(a, SIMDE_MM_FROUND_TO_NEG_INF); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_floor_pd #define _mm256_floor_pd(a) simde_mm256_floor_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_floor_ps (simde__m256 a) { return simde_mm256_round_ps(a, SIMDE_MM_FROUND_TO_NEG_INF); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_floor_ps #define _mm256_floor_ps(a) simde_mm256_floor_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_insert_epi8 (simde__m256i a, int8_t i, const int index) SIMDE_REQUIRE_RANGE(index, 0, 31) { simde__m256i_private a_ = simde__m256i_to_private(a); a_.i8[index] = i; return simde__m256i_from_private(a_); } #if defined(SIMDE_X86_AVX_NATIVE) #define simde_mm256_insert_epi8(a, i, index) _mm256_insert_epi8(a, i, index) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_insert_epi8 #define _mm256_insert_epi8(a, i, index) simde_mm256_insert_epi8(a, i, index) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_insert_epi16 (simde__m256i a, int16_t i, const int index) SIMDE_REQUIRE_RANGE(index, 0, 15) { simde__m256i_private a_ = simde__m256i_to_private(a); a_.i16[index] = i; return simde__m256i_from_private(a_); } #if defined(SIMDE_X86_AVX_NATIVE) #define simde_mm256_insert_epi16(a, i, index) _mm256_insert_epi16(a, i, index) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_insert_epi16 #define _mm256_insert_epi16(a, i, imm8) simde_mm256_insert_epi16(a, i, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_insert_epi32 (simde__m256i a, int32_t i, const int index) SIMDE_REQUIRE_RANGE(index, 0, 7) { simde__m256i_private a_ = simde__m256i_to_private(a); a_.i32[index] = i; return simde__m256i_from_private(a_); } #if defined(SIMDE_X86_AVX_NATIVE) #define simde_mm256_insert_epi32(a, i, index) _mm256_insert_epi32(a, i, index) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_insert_epi32 #define _mm256_insert_epi32(a, i, index) simde_mm256_insert_epi32(a, i, index) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_insert_epi64 (simde__m256i a, int64_t i, const int index) SIMDE_REQUIRE_RANGE(index, 0, 3) { simde__m256i_private a_ = simde__m256i_to_private(a); a_.i64[index] = i; return simde__m256i_from_private(a_); } #if defined(SIMDE_X86_AVX_NATIVE) && defined(SIMDE_ARCH_AMD64) && \ (!defined(HEDLEY_MSVC_VERSION) || HEDLEY_MSVC_VERSION_CHECK(19,20,0)) && \ SIMDE_DETECT_CLANG_VERSION_CHECK(3,7,0) #define simde_mm256_insert_epi64(a, i, index) _mm256_insert_epi64(a, i, index) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_insert_epi64 #define _mm256_insert_epi64(a, i, index) simde_mm256_insert_epi64(a, i, index) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_insertf128_pd(simde__m256d a, simde__m128d b, int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 1) { simde__m256d_private a_ = simde__m256d_to_private(a); simde__m128d_private b_ = simde__m128d_to_private(b); a_.m128d_private[imm8] = b_; return simde__m256d_from_private(a_); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_insertf128_pd #define _mm256_insertf128_pd(a, b, imm8) simde_mm256_insertf128_pd(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_insertf128_ps(simde__m256 a, simde__m128 b, int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 1) { simde__m256_private a_ = simde__m256_to_private(a); simde__m128_private b_ = simde__m128_to_private(b); a_.m128_private[imm8] = b_; return simde__m256_from_private(a_); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_insertf128_ps #define _mm256_insertf128_ps(a, b, imm8) simde_mm256_insertf128_ps(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_insertf128_si256(simde__m256i a, simde__m128i b, int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 1) { simde__m256i_private a_ = simde__m256i_to_private(a); simde__m128i_private b_ = simde__m128i_to_private(b); a_.m128i_private[imm8] = b_; return simde__m256i_from_private(a_); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_insertf128_si256 #define _mm256_insertf128_si256(a, b, imm8) simde_mm256_insertf128_si256(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_dp_ps(a, b, imm8) _mm256_dp_ps(a, b, imm8) #else # define simde_mm256_dp_ps(a, b, imm8) \ simde_mm256_set_m128( \ simde_mm_dp_ps(simde_mm256_extractf128_ps(a, 1), simde_mm256_extractf128_ps(b, 1), imm8), \ simde_mm_dp_ps(simde_mm256_extractf128_ps(a, 0), simde_mm256_extractf128_ps(b, 0), imm8)) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_dp_ps #define _mm256_dp_ps(a, b, imm8) simde_mm256_dp_ps(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES int32_t simde_mm256_extract_epi32 (simde__m256i a, const int index) SIMDE_REQUIRE_RANGE(index, 0, 7) { simde__m256i_private a_ = simde__m256i_to_private(a); return a_.i32[index]; } #if defined(SIMDE_X86_AVX_NATIVE) #define simde_mm256_extract_epi32(a, index) _mm256_extract_epi32(a, index) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_extract_epi32 #define _mm256_extract_epi32(a, index) simde_mm256_extract_epi32(a, index) #endif SIMDE_FUNCTION_ATTRIBUTES int64_t simde_mm256_extract_epi64 (simde__m256i a, const int index) SIMDE_REQUIRE_RANGE(index, 0, 3) { simde__m256i_private a_ = simde__m256i_to_private(a); return a_.i64[index]; } #if defined(SIMDE_X86_AVX_NATIVE) && defined(SIMDE_ARCH_AMD64) #if !defined(HEDLEY_MSVC_VERSION) || HEDLEY_MSVC_VERSION_CHECK(19,20,0) #define simde_mm256_extract_epi64(a, index) _mm256_extract_epi64(a, index) #endif #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_extract_epi64 #define _mm256_extract_epi64(a, index) simde_mm256_extract_epi64(a, index) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_lddqu_si256 (simde__m256i const * mem_addr) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_loadu_si256(mem_addr); #else simde__m256i r; simde_memcpy(&r, SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256i), sizeof(r)); return r; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_lddqu_si256 #define _mm256_lddqu_si256(a) simde_mm256_lddqu_si256(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_load_pd (const double mem_addr[HEDLEY_ARRAY_PARAM(4)]) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_load_pd(mem_addr); #else simde__m256d r; simde_memcpy(&r, SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256d), sizeof(r)); return r; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_load_pd #define _mm256_load_pd(a) simde_mm256_load_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_load_ps (const float mem_addr[HEDLEY_ARRAY_PARAM(8)]) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_load_ps(mem_addr); #else simde__m256 r; simde_memcpy(&r, SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256), sizeof(r)); return r; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_load_ps #define _mm256_load_ps(a) simde_mm256_load_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_load_si256 (simde__m256i const * mem_addr) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_load_si256(mem_addr); #else simde__m256i r; simde_memcpy(&r, SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256i), sizeof(r)); return r; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_load_si256 #define _mm256_load_si256(a) simde_mm256_load_si256(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_loadu_pd (const double a[HEDLEY_ARRAY_PARAM(4)]) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_loadu_pd(a); #else simde__m256d r; simde_memcpy(&r, a, sizeof(r)); return r; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_loadu_pd #define _mm256_loadu_pd(a) simde_mm256_loadu_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_loadu_ps (const float a[HEDLEY_ARRAY_PARAM(8)]) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_loadu_ps(a); #else simde__m256 r; simde_memcpy(&r, a, sizeof(r)); return r; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_loadu_ps #define _mm256_loadu_ps(a) simde_mm256_loadu_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_loadu_epi8(void const * mem_addr) { #if defined(SIMDE_X86_AVX512VL_NATIVE) && defined(SIMDE_X86_AVX512BW_NATIVE) && !defined(SIMDE_BUG_GCC_95483) return _mm256_loadu_epi8(mem_addr); #elif defined(SIMDE_X86_AVX_NATIVE) return _mm256_loadu_si256(SIMDE_ALIGN_CAST(__m256i const *, mem_addr)); #else simde__m256i r; simde_memcpy(&r, mem_addr, sizeof(r)); return r; #endif } #define simde_x_mm256_loadu_epi8(mem_addr) simde_mm256_loadu_epi8(mem_addr) #if defined(SIMDE_X86_AVX512VL_ENABLE_NATIVE_ALIASES) || defined(SIMDE_X86_AVX512BW_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && defined(SIMDE_BUG_GCC_95483)) #undef _mm256_loadu_epi8 #define _mm256_loadu_epi8(a) simde_mm256_loadu_epi8(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_loadu_epi16(void const * mem_addr) { #if defined(SIMDE_X86_AVX512VL_NATIVE) && defined(SIMDE_X86_AVX512BW_NATIVE) && !defined(SIMDE_BUG_GCC_95483) return _mm256_loadu_epi16(mem_addr); #elif defined(SIMDE_X86_AVX_NATIVE) return _mm256_loadu_si256(SIMDE_ALIGN_CAST(__m256i const *, mem_addr)); #else simde__m256i r; simde_memcpy(&r, mem_addr, sizeof(r)); return r; #endif } #define simde_x_mm256_loadu_epi16(mem_addr) simde_mm256_loadu_epi16(mem_addr) #if defined(SIMDE_X86_AVX512VL_ENABLE_NATIVE_ALIASES) || defined(SIMDE_X86_AVX512BW_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && defined(SIMDE_BUG_GCC_95483)) #undef _mm256_loadu_epi16 #define _mm256_loadu_epi16(a) simde_mm256_loadu_epi16(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_loadu_epi32(void const * mem_addr) { #if defined(SIMDE_X86_AVX512VL_NATIVE) && !defined(SIMDE_BUG_GCC_95483) return _mm256_loadu_epi32(mem_addr); #elif defined(SIMDE_X86_AVX_NATIVE) return _mm256_loadu_si256(SIMDE_ALIGN_CAST(__m256i const *, mem_addr)); #else simde__m256i r; simde_memcpy(&r, mem_addr, sizeof(r)); return r; #endif } #define simde_x_mm256_loadu_epi32(mem_addr) simde_mm256_loadu_epi32(mem_addr) #if defined(SIMDE_X86_AVX512VL_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && defined(SIMDE_BUG_GCC_95483)) #undef _mm256_loadu_epi32 #define _mm256_loadu_epi32(a) simde_mm256_loadu_epi32(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_loadu_epi64(void const * mem_addr) { #if defined(SIMDE_X86_AVX512VL_NATIVE) && !defined(SIMDE_BUG_GCC_95483) return _mm256_loadu_epi64(mem_addr); #elif defined(SIMDE_X86_AVX_NATIVE) return _mm256_loadu_si256(SIMDE_ALIGN_CAST(__m256i const *, mem_addr)); #else simde__m256i r; simde_memcpy(&r, mem_addr, sizeof(r)); return r; #endif } #define simde_x_mm256_loadu_epi64(mem_addr) simde_mm256_loadu_epi64(mem_addr) #if defined(SIMDE_X86_AVX512VL_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && defined(SIMDE_BUG_GCC_95483)) #undef _mm256_loadu_epi64 #define _mm256_loadu_epi64(a) simde_mm256_loadu_epi64(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_loadu_si256 (void const * mem_addr) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_loadu_si256(SIMDE_ALIGN_CAST(const __m256i*, mem_addr)); #else simde__m256i r; simde_memcpy(&r, mem_addr, sizeof(r)); return r; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_loadu_si256 #define _mm256_loadu_si256(mem_addr) simde_mm256_loadu_si256(mem_addr) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_loadu2_m128 (const float hiaddr[HEDLEY_ARRAY_PARAM(4)], const float loaddr[HEDLEY_ARRAY_PARAM(4)]) { #if defined(SIMDE_X86_AVX_NATIVE) && !defined(SIMDE_BUG_GCC_91341) return _mm256_loadu2_m128(hiaddr, loaddr); #else return simde_mm256_insertf128_ps(simde_mm256_castps128_ps256(simde_mm_loadu_ps(loaddr)), simde_mm_loadu_ps(hiaddr), 1); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_loadu2_m128 #define _mm256_loadu2_m128(hiaddr, loaddr) simde_mm256_loadu2_m128(hiaddr, loaddr) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_loadu2_m128d (const double hiaddr[HEDLEY_ARRAY_PARAM(2)], const double loaddr[HEDLEY_ARRAY_PARAM(2)]) { #if defined(SIMDE_X86_AVX_NATIVE) && !defined(SIMDE_BUG_GCC_91341) return _mm256_loadu2_m128d(hiaddr, loaddr); #else return simde_mm256_insertf128_pd(simde_mm256_castpd128_pd256(simde_mm_loadu_pd(loaddr)), simde_mm_loadu_pd(hiaddr), 1); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_loadu2_m128d #define _mm256_loadu2_m128d(hiaddr, loaddr) simde_mm256_loadu2_m128d(hiaddr, loaddr) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_loadu2_m128i (const simde__m128i* hiaddr, const simde__m128i* loaddr) { #if defined(SIMDE_X86_AVX_NATIVE) && !defined(SIMDE_BUG_GCC_91341) return _mm256_loadu2_m128i(hiaddr, loaddr); #else return simde_mm256_insertf128_si256(simde_mm256_castsi128_si256(simde_mm_loadu_si128(loaddr)), simde_mm_loadu_si128(hiaddr), 1); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_loadu2_m128i #define _mm256_loadu2_m128i(hiaddr, loaddr) simde_mm256_loadu2_m128i(hiaddr, loaddr) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128d simde_mm_maskload_pd (const simde_float64 mem_addr[HEDLEY_ARRAY_PARAM(4)], simde__m128i mask) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_maskload_pd(mem_addr, mask); #else simde__m128d_private mem_ = simde__m128d_to_private(simde_mm_loadu_pd(mem_addr)), r_; simde__m128i_private mask_ = simde__m128i_to_private(mask); #if defined(SIMDE_ARM_NEON_A32V7_NATIVE) r_.neon_i64 = vandq_s64(mem_.neon_i64, vshrq_n_s64(mask_.neon_i64, 63)); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.i64[i] = mem_.i64[i] & (mask_.i64[i] >> 63); } #endif return simde__m128d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_maskload_pd #define _mm_maskload_pd(mem_addr, mask) simde_mm_maskload_pd(HEDLEY_REINTERPRET_CAST(double const*, mem_addr), mask) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_maskload_pd (const simde_float64 mem_addr[HEDLEY_ARRAY_PARAM(4)], simde__m256i mask) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_maskload_pd(mem_addr, mask); #else simde__m256d_private r_; simde__m256i_private mask_ = simde__m256i_to_private(mask); r_ = simde__m256d_to_private(simde_mm256_loadu_pd(mem_addr)); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.i64[i] &= mask_.i64[i] >> 63; } return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_maskload_pd #define _mm256_maskload_pd(mem_addr, mask) simde_mm256_maskload_pd(HEDLEY_REINTERPRET_CAST(double const*, mem_addr), mask) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128 simde_mm_maskload_ps (const simde_float32 mem_addr[HEDLEY_ARRAY_PARAM(4)], simde__m128i mask) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_maskload_ps(mem_addr, mask); #else simde__m128_private mem_ = simde__m128_to_private(simde_mm_loadu_ps(mem_addr)), r_; simde__m128i_private mask_ = simde__m128i_to_private(mask); #if defined(SIMDE_ARM_NEON_A32V7_NATIVE) r_.neon_i32 = vandq_s32(mem_.neon_i32, vshrq_n_s32(mask_.neon_i32, 31)); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.i32) / sizeof(r_.i32[0])) ; i++) { r_.i32[i] = mem_.i32[i] & (mask_.i32[i] >> 31); } #endif return simde__m128_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_maskload_ps #define _mm_maskload_ps(mem_addr, mask) simde_mm_maskload_ps(HEDLEY_REINTERPRET_CAST(float const*, mem_addr), mask) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_maskload_ps (const simde_float32 mem_addr[HEDLEY_ARRAY_PARAM(4)], simde__m256i mask) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_maskload_ps(mem_addr, mask); #else simde__m256_private r_; simde__m256i_private mask_ = simde__m256i_to_private(mask); r_ = simde__m256_to_private(simde_mm256_loadu_ps(mem_addr)); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.i32[i] &= mask_.i32[i] >> 31; } return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_maskload_ps #define _mm256_maskload_ps(mem_addr, mask) simde_mm256_maskload_ps(HEDLEY_REINTERPRET_CAST(float const*, mem_addr), mask) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm_maskstore_pd (simde_float64 mem_addr[HEDLEY_ARRAY_PARAM(2)], simde__m128i mask, simde__m128d a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm_maskstore_pd(mem_addr, mask, a); #else simde__m128i_private mask_ = simde__m128i_to_private(mask); simde__m128d_private a_ = simde__m128d_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(a_.f64) / sizeof(a_.f64[0])) ; i++) { if (mask_.u64[i] >> 63) mem_addr[i] = a_.f64[i]; } #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_maskstore_pd #define _mm_maskstore_pd(mem_addr, mask, a) simde_mm_maskstore_pd(HEDLEY_REINTERPRET_CAST(double*, mem_addr), mask, a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_maskstore_pd (simde_float64 mem_addr[HEDLEY_ARRAY_PARAM(4)], simde__m256i mask, simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_maskstore_pd(mem_addr, mask, a); #else simde__m256i_private mask_ = simde__m256i_to_private(mask); simde__m256d_private a_ = simde__m256d_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(a_.f64) / sizeof(a_.f64[0])) ; i++) { if (mask_.u64[i] & (UINT64_C(1) << 63)) mem_addr[i] = a_.f64[i]; } #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_maskstore_pd #define _mm256_maskstore_pd(mem_addr, mask, a) simde_mm256_maskstore_pd(HEDLEY_REINTERPRET_CAST(double*, mem_addr), mask, a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm_maskstore_ps (simde_float32 mem_addr[HEDLEY_ARRAY_PARAM(4)], simde__m128i mask, simde__m128 a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm_maskstore_ps(mem_addr, mask, a); #else simde__m128i_private mask_ = simde__m128i_to_private(mask); simde__m128_private a_ = simde__m128_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(a_.f32) / sizeof(a_.f32[0])) ; i++) { if (mask_.u32[i] & (UINT32_C(1) << 31)) mem_addr[i] = a_.f32[i]; } #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_maskstore_ps #define _mm_maskstore_ps(mem_addr, mask, a) simde_mm_maskstore_ps(HEDLEY_REINTERPRET_CAST(float*, mem_addr), mask, a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_maskstore_ps (simde_float32 mem_addr[HEDLEY_ARRAY_PARAM(8)], simde__m256i mask, simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_maskstore_ps(mem_addr, mask, a); #else simde__m256i_private mask_ = simde__m256i_to_private(mask); simde__m256_private a_ = simde__m256_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(a_.f32) / sizeof(a_.f32[0])) ; i++) { if (mask_.u32[i] & (UINT32_C(1) << 31)) mem_addr[i] = a_.f32[i]; } #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_maskstore_ps #define _mm256_maskstore_ps(mem_addr, mask, a) simde_mm256_maskstore_ps(HEDLEY_REINTERPRET_CAST(float*, mem_addr), mask, a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_min_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_min_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_min_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_min_ps(a_.m128[1], b_.m128[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = (a_.f32[i] < b_.f32[i]) ? a_.f32[i] : b_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_min_ps #define _mm256_min_ps(a, b) simde_mm256_min_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_min_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_min_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_min_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_min_pd(a_.m128d[1], b_.m128d[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = (a_.f64[i] < b_.f64[i]) ? a_.f64[i] : b_.f64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_min_pd #define _mm256_min_pd(a, b) simde_mm256_min_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_max_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_max_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_max_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_max_ps(a_.m128[1], b_.m128[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = (a_.f32[i] > b_.f32[i]) ? a_.f32[i] : b_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_max_ps #define _mm256_max_ps(a, b) simde_mm256_max_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_max_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_max_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_max_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_max_pd(a_.m128d[1], b_.m128d[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = (a_.f64[i] > b_.f64[i]) ? a_.f64[i] : b_.f64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_max_pd #define _mm256_max_pd(a, b) simde_mm256_max_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_movedup_pd (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_movedup_pd(a); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a); #if defined(SIMDE_SHUFFLE_VECTOR_) r_.f64 = SIMDE_SHUFFLE_VECTOR_(64, 32, a_.f64, a_.f64, 0, 0, 2, 2); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i += 2) { r_.f64[i] = r_.f64[i + 1] = a_.f64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_movedup_pd #define _mm256_movedup_pd(a) simde_mm256_movedup_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_movehdup_ps (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_movehdup_ps(a); #else simde__m256_private r_, a_ = simde__m256_to_private(a); #if defined(SIMDE_SHUFFLE_VECTOR_) r_.f32 = SIMDE_SHUFFLE_VECTOR_(32, 32, a_.f32, a_.f32, 1, 1, 3, 3, 5, 5, 7, 7); #else SIMDE_VECTORIZE for (size_t i = 1 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i += 2) { r_.f32[i - 1] = r_.f32[i] = a_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_movehdup_ps #define _mm256_movehdup_ps(a) simde_mm256_movehdup_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_moveldup_ps (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_moveldup_ps(a); #else simde__m256_private r_, a_ = simde__m256_to_private(a); #if defined(SIMDE_SHUFFLE_VECTOR_) r_.f32 = SIMDE_SHUFFLE_VECTOR_(32, 32, a_.f32, a_.f32, 0, 0, 2, 2, 4, 4, 6, 6); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i += 2) { r_.f32[i] = r_.f32[i + 1] = a_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_moveldup_ps #define _mm256_moveldup_ps(a) simde_mm256_moveldup_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_movemask_ps (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_movemask_ps(a); #else simde__m256_private a_ = simde__m256_to_private(a); int r = 0; SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.f32) / sizeof(a_.f32[0])) ; i++) { r |= (a_.u32[i] >> 31) << i; } return r; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_movemask_ps #define _mm256_movemask_ps(a) simde_mm256_movemask_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_movemask_pd (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_movemask_pd(a); #else simde__m256d_private a_ = simde__m256d_to_private(a); int r = 0; SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.f64) / sizeof(a_.f64[0])) ; i++) { r |= (a_.u64[i] >> 63) << i; } return r; #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_movemask_pd #define _mm256_movemask_pd(a) simde_mm256_movemask_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_mul_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_mul_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_mul_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_mul_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.f32 = a_.f32 * b_.f32; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = a_.f32[i] * b_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_mul_ps #define _mm256_mul_ps(a, b) simde_mm256_mul_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_mul_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_mul_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_mul_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_mul_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.f64 = a_.f64 * b_.f64; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = a_.f64[i] * b_.f64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_mul_pd #define _mm256_mul_pd(a, b) simde_mm256_mul_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_or_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_or_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_or_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_or_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32f = a_.i32f | b_.i32f; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.u32) / sizeof(r_.u32[0])) ; i++) { r_.u32[i] = a_.u32[i] | b_.u32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_or_ps #define _mm256_or_ps(a, b) simde_mm256_or_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_or_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_or_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_or_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_or_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32f = a_.i32f | b_.i32f; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.u64) / sizeof(r_.u64[0])) ; i++) { r_.u64[i] = a_.u64[i] | b_.u64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_or_pd #define _mm256_or_pd(a, b) simde_mm256_or_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_permute_ps (simde__m256 a, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 255) { simde__m256_private r_, a_ = simde__m256_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = a_.m128_private[i >> 2].f32[(imm8 >> ((i << 1) & 7)) & 3]; } return simde__m256_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_permute_ps(a, imm8) _mm256_permute_ps(a, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_permute_ps #define _mm256_permute_ps(a, imm8) simde_mm256_permute_ps(a, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_permute_pd (simde__m256d a, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 15) { simde__m256d_private r_, a_ = simde__m256d_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = a_.f64[((imm8 >> i) & 1) + (i & 2)]; } return simde__m256d_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_permute_pd(a, imm8) _mm256_permute_pd(a, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_permute_pd #define _mm256_permute_pd(a, imm8) simde_mm256_permute_pd(a, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128 simde_mm_permute_ps (simde__m128 a, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 255) { simde__m128_private r_, a_ = simde__m128_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = a_.f32[(imm8 >> ((i << 1) & 7)) & 3]; } return simde__m128_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm_permute_ps(a, imm8) _mm_permute_ps(a, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_permute_ps #define _mm_permute_ps(a, imm8) simde_mm_permute_ps(a, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128d simde_mm_permute_pd (simde__m128d a, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 3) { simde__m128d_private r_, a_ = simde__m128d_to_private(a); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = a_.f64[((imm8 >> i) & 1) + (i & 2)]; } return simde__m128d_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm_permute_pd(a, imm8) _mm_permute_pd(a, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_permute_pd #define _mm_permute_pd(a, imm8) simde_mm_permute_pd(a, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128 simde_mm_permutevar_ps (simde__m128 a, simde__m128i b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_permutevar_ps(a, b); #else simde__m128_private r_, a_ = simde__m128_to_private(a); simde__m128i_private b_ = simde__m128i_to_private(b); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = a_.f32[b_.i32[i] & 3]; } return simde__m128_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_permutevar_ps #define _mm_permutevar_ps(a, b) simde_mm_permutevar_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m128d simde_mm_permutevar_pd (simde__m128d a, simde__m128i b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_permutevar_pd(a, b); #else simde__m128d_private r_, a_ = simde__m128d_to_private(a); simde__m128i_private b_ = simde__m128i_to_private(b); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = a_.f64[(b_.i64[i] & 2) >> 1]; } return simde__m128d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_permutevar_pd #define _mm_permutevar_pd(a, b) simde_mm_permutevar_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_permutevar_ps (simde__m256 a, simde__m256i b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_permutevar_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a); simde__m256i_private b_ = simde__m256i_to_private(b); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = a_.f32[(b_.i32[i] & 3) + (i & 4)]; } return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_permutevar_ps #define _mm256_permutevar_ps(a, b) simde_mm256_permutevar_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_permutevar_pd (simde__m256d a, simde__m256i b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_permutevar_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a); simde__m256i_private b_ = simde__m256i_to_private(b); SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = a_.f64[((b_.i64[i] & 2) >> 1) + (i & 2)]; } return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_permutevar_pd #define _mm256_permutevar_pd(a, b) simde_mm256_permutevar_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_permute2f128_ps (simde__m256 a, simde__m256 b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 255) { simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); r_.m128_private[0] = (imm8 & 0x08) ? simde__m128_to_private(simde_mm_setzero_ps()) : ((imm8 & 0x02) ? b_.m128_private[(imm8 ) & 1] : a_.m128_private[(imm8 ) & 1]); r_.m128_private[1] = (imm8 & 0x80) ? simde__m128_to_private(simde_mm_setzero_ps()) : ((imm8 & 0x20) ? b_.m128_private[(imm8 >> 4) & 1] : a_.m128_private[(imm8 >> 4) & 1]); return simde__m256_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_permute2f128_ps(a, b, imm8) _mm256_permute2f128_ps(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_permute2f128_ps #define _mm256_permute2f128_ps(a, b, imm8) simde_mm256_permute2f128_ps(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_permute2f128_pd (simde__m256d a, simde__m256d b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 255) { simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); r_.m128d_private[0] = (imm8 & 0x08) ? simde__m128d_to_private(simde_mm_setzero_pd()) : ((imm8 & 0x02) ? b_.m128d_private[(imm8 ) & 1] : a_.m128d_private[(imm8 ) & 1]); r_.m128d_private[1] = (imm8 & 0x80) ? simde__m128d_to_private(simde_mm_setzero_pd()) : ((imm8 & 0x20) ? b_.m128d_private[(imm8 >> 4) & 1] : a_.m128d_private[(imm8 >> 4) & 1]); return simde__m256d_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_permute2f128_pd(a, b, imm8) _mm256_permute2f128_pd(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_permute2f128_pd #define _mm256_permute2f128_pd(a, b, imm8) simde_mm256_permute2f128_pd(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_permute2f128_si256 (simde__m256i a, simde__m256i b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 255) { simde__m256i_private r_, a_ = simde__m256i_to_private(a), b_ = simde__m256i_to_private(b); r_.m128i_private[0] = (imm8 & 0x08) ? simde__m128i_to_private(simde_mm_setzero_si128()) : ((imm8 & 0x02) ? b_.m128i_private[(imm8 ) & 1] : a_.m128i_private[(imm8 ) & 1]); r_.m128i_private[1] = (imm8 & 0x80) ? simde__m128i_to_private(simde_mm_setzero_si128()) : ((imm8 & 0x20) ? b_.m128i_private[(imm8 >> 4) & 1] : a_.m128i_private[(imm8 >> 4) & 1]); return simde__m256i_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) # define simde_mm256_permute2f128_si128(a, b, imm8) _mm256_permute2f128_si128(a, b, imm8) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_permute2f128_si256 #define _mm256_permute2f128_si256(a, b, imm8) simde_mm256_permute2f128_si256(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_rcp_ps (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_rcp_ps(a); #else simde__m256_private r_, a_ = simde__m256_to_private(a); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_rcp_ps(a_.m128[0]); r_.m128[1] = simde_mm_rcp_ps(a_.m128[1]); #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = SIMDE_FLOAT32_C(1.0) / a_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_rcp_ps #define _mm256_rcp_ps(a) simde_mm256_rcp_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_rsqrt_ps (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_rsqrt_ps(a); #else simde__m256_private r_, a_ = simde__m256_to_private(a); #if defined(simde_math_sqrtf) SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = 1.0f / simde_math_sqrtf(a_.f32[i]); } #else HEDLEY_UNREACHABLE(); #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_rsqrt_ps #define _mm256_rsqrt_ps(a) simde_mm256_rsqrt_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_setr_epi8 ( int8_t e31, int8_t e30, int8_t e29, int8_t e28, int8_t e27, int8_t e26, int8_t e25, int8_t e24, int8_t e23, int8_t e22, int8_t e21, int8_t e20, int8_t e19, int8_t e18, int8_t e17, int8_t e16, int8_t e15, int8_t e14, int8_t e13, int8_t e12, int8_t e11, int8_t e10, int8_t e9, int8_t e8, int8_t e7, int8_t e6, int8_t e5, int8_t e4, int8_t e3, int8_t e2, int8_t e1, int8_t e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_setr_epi8( e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0); #else return simde_mm256_set_epi8( e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setr_epi8 #define _mm256_setr_epi8(e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) \ simde_mm256_setr_epi8(e31, e30, e29, e28, e27, e26, e25, e24, e23, e22, e21, e20, e19, e18, e17, e16, e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_setr_epi16 ( int16_t e15, int16_t e14, int16_t e13, int16_t e12, int16_t e11, int16_t e10, int16_t e9, int16_t e8, int16_t e7, int16_t e6, int16_t e5, int16_t e4, int16_t e3, int16_t e2, int16_t e1, int16_t e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_setr_epi16( e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0); #else return simde_mm256_set_epi16( e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setr_epi16 #define _mm256_setr_epi16(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) \ simde_mm256_setr_epi16(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_setr_epi32 ( int32_t e7, int32_t e6, int32_t e5, int32_t e4, int32_t e3, int32_t e2, int32_t e1, int32_t e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_setr_epi32(e7, e6, e5, e4, e3, e2, e1, e0); #else return simde_mm256_set_epi32(e0, e1, e2, e3, e4, e5, e6, e7); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setr_epi32 #define _mm256_setr_epi32(e7, e6, e5, e4, e3, e2, e1, e0) \ simde_mm256_setr_epi32(e7, e6, e5, e4, e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_setr_epi64x (int64_t e3, int64_t e2, int64_t e1, int64_t e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_setr_epi64x(e3, e2, e1, e0); #else return simde_mm256_set_epi64x(e0, e1, e2, e3); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setr_epi64x #define _mm256_setr_epi64x(e3, e2, e1, e0) \ simde_mm256_setr_epi64x(e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_setr_ps ( simde_float32 e7, simde_float32 e6, simde_float32 e5, simde_float32 e4, simde_float32 e3, simde_float32 e2, simde_float32 e1, simde_float32 e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_setr_ps(e7, e6, e5, e4, e3, e2, e1, e0); #else return simde_mm256_set_ps(e0, e1, e2, e3, e4, e5, e6, e7); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setr_ps #define _mm256_setr_ps(e7, e6, e5, e4, e3, e2, e1, e0) \ simde_mm256_setr_ps(e7, e6, e5, e4, e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_setr_pd (simde_float64 e3, simde_float64 e2, simde_float64 e1, simde_float64 e0) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_setr_pd(e3, e2, e1, e0); #else return simde_mm256_set_pd(e0, e1, e2, e3); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setr_pd #define _mm256_setr_pd(e3, e2, e1, e0) \ simde_mm256_setr_pd(e3, e2, e1, e0) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_setr_m128 (simde__m128 lo, simde__m128 hi) { #if defined(SIMDE_X86_AVX_NATIVE) && \ !defined(SIMDE_BUG_GCC_REV_247851) && \ SIMDE_DETECT_CLANG_VERSION_CHECK(3,6,0) return _mm256_setr_m128(lo, hi); #else return simde_mm256_set_m128(hi, lo); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setr_m128 #define _mm256_setr_m128(lo, hi) \ simde_mm256_setr_m128(lo, hi) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_setr_m128d (simde__m128d lo, simde__m128d hi) { #if defined(SIMDE_X86_AVX_NATIVE) && \ !defined(SIMDE_BUG_GCC_REV_247851) && \ SIMDE_DETECT_CLANG_VERSION_CHECK(3,6,0) return _mm256_setr_m128d(lo, hi); #else return simde_mm256_set_m128d(hi, lo); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setr_m128d #define _mm256_setr_m128d(lo, hi) \ simde_mm256_setr_m128d(lo, hi) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_setr_m128i (simde__m128i lo, simde__m128i hi) { #if defined(SIMDE_X86_AVX_NATIVE) && \ !defined(SIMDE_BUG_GCC_REV_247851) && \ SIMDE_DETECT_CLANG_VERSION_CHECK(3,6,0) return _mm256_setr_m128i(lo, hi); #else return simde_mm256_set_m128i(hi, lo); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_setr_m128i #define _mm256_setr_m128i(lo, hi) \ simde_mm256_setr_m128i(lo, hi) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_shuffle_ps (simde__m256 a, simde__m256 b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 255) { simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); r_.f32[0] = a_.m128_private[0].f32[(imm8 >> 0) & 3]; r_.f32[1] = a_.m128_private[0].f32[(imm8 >> 2) & 3]; r_.f32[2] = b_.m128_private[0].f32[(imm8 >> 4) & 3]; r_.f32[3] = b_.m128_private[0].f32[(imm8 >> 6) & 3]; r_.f32[4] = a_.m128_private[1].f32[(imm8 >> 0) & 3]; r_.f32[5] = a_.m128_private[1].f32[(imm8 >> 2) & 3]; r_.f32[6] = b_.m128_private[1].f32[(imm8 >> 4) & 3]; r_.f32[7] = b_.m128_private[1].f32[(imm8 >> 6) & 3]; return simde__m256_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) #define simde_mm256_shuffle_ps(a, b, imm8) _mm256_shuffle_ps(a, b, imm8) #elif SIMDE_NATURAL_VECTOR_SIZE_LE(128) #define simde_mm256_shuffle_ps(a, b, imm8) \ simde_mm256_set_m128( \ simde_mm_shuffle_ps(simde_mm256_extractf128_ps(a, 1), simde_mm256_extractf128_ps(b, 1), (imm8)), \ simde_mm_shuffle_ps(simde_mm256_extractf128_ps(a, 0), simde_mm256_extractf128_ps(b, 0), (imm8))) #elif defined(SIMDE_SHUFFLE_VECTOR_) #define simde_mm256_shuffle_ps(a, b, imm8) \ SIMDE_SHUFFLE_VECTOR_(32, 32, a, b, \ (((imm8) >> 0) & 3) + 0, \ (((imm8) >> 2) & 3) + 0, \ (((imm8) >> 4) & 3) + 8, \ (((imm8) >> 6) & 3) + 8, \ (((imm8) >> 0) & 3) + 4, \ (((imm8) >> 2) & 3) + 4, \ (((imm8) >> 4) & 3) + 12, \ (((imm8) >> 6) & 3) + 12) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_shuffle_ps #define _mm256_shuffle_ps(a, b, imm8) simde_mm256_shuffle_ps(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_shuffle_pd (simde__m256d a, simde__m256d b, const int imm8) SIMDE_REQUIRE_CONSTANT_RANGE(imm8, 0, 15) { simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); r_.f64[0] = a_.f64[((imm8 ) & 1) ]; r_.f64[1] = b_.f64[((imm8 >> 1) & 1) ]; r_.f64[2] = a_.f64[((imm8 >> 2) & 1) | 2]; r_.f64[3] = b_.f64[((imm8 >> 3) & 1) | 2]; return simde__m256d_from_private(r_); } #if defined(SIMDE_X86_AVX_NATIVE) #define simde_mm256_shuffle_pd(a, b, imm8) _mm256_shuffle_pd(a, b, imm8) #elif SIMDE_NATURAL_VECTOR_SIZE_LE(128) #define simde_mm256_shuffle_pd(a, b, imm8) \ simde_mm256_set_m128d( \ simde_mm_shuffle_pd(simde_mm256_extractf128_pd(a, 1), simde_mm256_extractf128_pd(b, 1), (imm8 >> 0) & 3), \ simde_mm_shuffle_pd(simde_mm256_extractf128_pd(a, 0), simde_mm256_extractf128_pd(b, 0), (imm8 >> 2) & 3)) #elif defined(SIMDE_SHUFFLE_VECTOR_) #define simde_mm256_shuffle_pd(a, b, imm8) \ SIMDE_SHUFFLE_VECTOR_(64, 32, a, b, \ (((imm8) >> 0) & 1) + 0, \ (((imm8) >> 1) & 1) + 4, \ (((imm8) >> 2) & 1) + 2, \ (((imm8) >> 3) & 1) + 6) #endif #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_shuffle_pd #define _mm256_shuffle_pd(a, b, imm8) simde_mm256_shuffle_pd(a, b, imm8) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_sqrt_ps (simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_sqrt_ps(a); #else simde__m256_private r_, a_ = simde__m256_to_private(a); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_sqrt_ps(a_.m128[0]); r_.m128[1] = simde_mm_sqrt_ps(a_.m128[1]); #elif defined(simde_math_sqrtf) SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = simde_math_sqrtf(a_.f32[i]); } #else HEDLEY_UNREACHABLE(); #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_sqrt_ps #define _mm256_sqrt_ps(a) simde_mm256_sqrt_ps(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_sqrt_pd (simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_sqrt_pd(a); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_sqrt_pd(a_.m128d[0]); r_.m128d[1] = simde_mm_sqrt_pd(a_.m128d[1]); #elif defined(simde_math_sqrt) SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = simde_math_sqrt(a_.f64[i]); } #else HEDLEY_UNREACHABLE(); #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_sqrt_pd #define _mm256_sqrt_pd(a) simde_mm256_sqrt_pd(a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_store_ps (simde_float32 mem_addr[8], simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_store_ps(mem_addr, a); #else simde_memcpy(SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256), &a, sizeof(a)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_store_ps #define _mm256_store_ps(mem_addr, a) simde_mm256_store_ps(HEDLEY_REINTERPRET_CAST(float*, mem_addr), a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_store_pd (simde_float64 mem_addr[4], simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_store_pd(mem_addr, a); #else simde_memcpy(SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256d), &a, sizeof(a)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_store_pd #define _mm256_store_pd(mem_addr, a) simde_mm256_store_pd(HEDLEY_REINTERPRET_CAST(double*, mem_addr), a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_store_si256 (simde__m256i* mem_addr, simde__m256i a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_store_si256(mem_addr, a); #else simde_memcpy(SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256i), &a, sizeof(a)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_store_si256 #define _mm256_store_si256(mem_addr, a) simde_mm256_store_si256(mem_addr, a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_storeu_ps (simde_float32 mem_addr[8], simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_storeu_ps(mem_addr, a); #else simde_memcpy(mem_addr, &a, sizeof(a)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_storeu_ps #define _mm256_storeu_ps(mem_addr, a) simde_mm256_storeu_ps(HEDLEY_REINTERPRET_CAST(float*, mem_addr), a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_storeu_pd (simde_float64 mem_addr[4], simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_storeu_pd(mem_addr, a); #else simde_memcpy(mem_addr, &a, sizeof(a)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_storeu_pd #define _mm256_storeu_pd(mem_addr, a) simde_mm256_storeu_pd(HEDLEY_REINTERPRET_CAST(double*, mem_addr), a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_storeu_si256 (void* mem_addr, simde__m256i a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_storeu_si256(SIMDE_ALIGN_CAST(__m256i*, mem_addr), a); #else simde_memcpy(mem_addr, &a, sizeof(a)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_storeu_si256 #define _mm256_storeu_si256(mem_addr, a) simde_mm256_storeu_si256(mem_addr, a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_storeu2_m128 (simde_float32 hi_addr[4], simde_float32 lo_addr[4], simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) && !defined(SIMDE_BUG_GCC_91341) _mm256_storeu2_m128(hi_addr, lo_addr, a); #else simde_mm_storeu_ps(lo_addr, simde_mm256_castps256_ps128(a)); simde_mm_storeu_ps(hi_addr, simde_mm256_extractf128_ps(a, 1)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_storeu2_m128 #define _mm256_storeu2_m128(hi_addr, lo_addr, a) simde_mm256_storeu2_m128(hi_addr, lo_addr, a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_storeu2_m128d (simde_float64 hi_addr[2], simde_float64 lo_addr[2], simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) && !defined(SIMDE_BUG_GCC_91341) _mm256_storeu2_m128d(hi_addr, lo_addr, a); #else simde_mm_storeu_pd(lo_addr, simde_mm256_castpd256_pd128(a)); simde_mm_storeu_pd(hi_addr, simde_mm256_extractf128_pd(a, 1)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_storeu2_m128d #define _mm256_storeu2_m128d(hi_addr, lo_addr, a) simde_mm256_storeu2_m128d(hi_addr, lo_addr, a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_storeu2_m128i (simde__m128i* hi_addr, simde__m128i* lo_addr, simde__m256i a) { #if defined(SIMDE_X86_AVX_NATIVE) && !defined(SIMDE_BUG_GCC_91341) _mm256_storeu2_m128i(hi_addr, lo_addr, a); #else simde_mm_storeu_si128(lo_addr, simde_mm256_castsi256_si128(a)); simde_mm_storeu_si128(hi_addr, simde_mm256_extractf128_si256(a, 1)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_storeu2_m128i #define _mm256_storeu2_m128i(hi_addr, lo_addr, a) simde_mm256_storeu2_m128i(hi_addr, lo_addr, a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_stream_ps (simde_float32 mem_addr[8], simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_stream_ps(mem_addr, a); #else simde_memcpy(SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256), &a, sizeof(a)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_stream_ps #define _mm256_stream_ps(mem_addr, a) simde_mm256_stream_ps(HEDLEY_REINTERPRET_CAST(float*, mem_addr), a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_stream_pd (simde_float64 mem_addr[4], simde__m256d a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_stream_pd(mem_addr, a); #else simde_memcpy(SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256d), &a, sizeof(a)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_stream_pd #define _mm256_stream_pd(mem_addr, a) simde_mm256_stream_pd(HEDLEY_REINTERPRET_CAST(double*, mem_addr), a) #endif SIMDE_FUNCTION_ATTRIBUTES void simde_mm256_stream_si256 (simde__m256i* mem_addr, simde__m256i a) { #if defined(SIMDE_X86_AVX_NATIVE) _mm256_stream_si256(mem_addr, a); #else simde_memcpy(SIMDE_ALIGN_ASSUME_LIKE(mem_addr, simde__m256i), &a, sizeof(a)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_stream_si256 #define _mm256_stream_si256(mem_addr, a) simde_mm256_stream_si256(mem_addr, a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_sub_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_sub_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_sub_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_sub_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.f32 = a_.f32 - b_.f32; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = a_.f32[i] - b_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_sub_ps #define _mm256_sub_ps(a, b) simde_mm256_sub_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_hsub_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_hsub_ps(a, b); #else return simde_mm256_sub_ps(simde_x_mm256_deinterleaveeven_ps(a, b), simde_x_mm256_deinterleaveodd_ps(a, b)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_hsub_ps #define _mm256_hsub_ps(a, b) simde_mm256_hsub_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_sub_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_sub_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_sub_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_sub_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.f64 = a_.f64 - b_.f64; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = a_.f64[i] - b_.f64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_sub_pd #define _mm256_sub_pd(a, b) simde_mm256_sub_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_hsub_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_hsub_pd(a, b); #else return simde_mm256_sub_pd(simde_x_mm256_deinterleaveeven_pd(a, b), simde_x_mm256_deinterleaveodd_pd(a, b)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_hsub_pd #define _mm256_hsub_pd(a, b) simde_mm256_hsub_pd(a, b) #endif #if defined(SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_) HEDLEY_DIAGNOSTIC_PUSH SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_ #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_undefined_ps (void) { simde__m256_private r_; #if \ defined(SIMDE_X86_AVX_NATIVE) && \ (!defined(HEDLEY_GCC_VERSION) || HEDLEY_GCC_VERSION_CHECK(5,0,0)) && \ (!defined(__has_builtin) || HEDLEY_HAS_BUILTIN(__builtin_ia32_undef256)) r_.n = _mm256_undefined_ps(); #elif !defined(SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_) r_ = simde__m256_to_private(simde_mm256_setzero_ps()); #endif return simde__m256_from_private(r_); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_undefined_ps #define _mm256_undefined_ps() simde_mm256_undefined_ps() #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_undefined_pd (void) { simde__m256d_private r_; #if \ defined(SIMDE_X86_AVX_NATIVE) && \ (!defined(HEDLEY_GCC_VERSION) || HEDLEY_GCC_VERSION_CHECK(5,0,0)) && \ (!defined(__has_builtin) || HEDLEY_HAS_BUILTIN(__builtin_ia32_undef256)) r_.n = _mm256_undefined_pd(); #elif !defined(SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_) r_ = simde__m256d_to_private(simde_mm256_setzero_pd()); #endif return simde__m256d_from_private(r_); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_undefined_pd #define _mm256_undefined_pd() simde_mm256_undefined_pd() #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_undefined_si256 (void) { simde__m256i_private r_; #if \ defined(SIMDE_X86_AVX_NATIVE) && \ (!defined(HEDLEY_GCC_VERSION) || HEDLEY_GCC_VERSION_CHECK(5,0,0)) && \ (!defined(__has_builtin) || HEDLEY_HAS_BUILTIN(__builtin_ia32_undef256)) r_.n = _mm256_undefined_si256(); #elif !defined(SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_) r_ = simde__m256i_to_private(simde_mm256_setzero_si256()); #endif return simde__m256i_from_private(r_); } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_undefined_si256 #define _mm256_undefined_si256() simde_mm256_undefined_si256() #endif #if defined(SIMDE_DIAGNOSTIC_DISABLE_UNINITIALIZED_) HEDLEY_DIAGNOSTIC_POP #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_xor_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_xor_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128[0] = simde_mm_xor_ps(a_.m128[0], b_.m128[0]); r_.m128[1] = simde_mm_xor_ps(a_.m128[1], b_.m128[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32f = a_.i32f ^ b_.i32f; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.u32) / sizeof(r_.u32[0])) ; i++) { r_.u32[i] = a_.u32[i] ^ b_.u32[i]; } #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_xor_ps #define _mm256_xor_ps(a, b) simde_mm256_xor_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_xor_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_xor_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r_.m128d[0] = simde_mm_xor_pd(a_.m128d[0], b_.m128d[0]); r_.m128d[1] = simde_mm_xor_pd(a_.m128d[1], b_.m128d[1]); #elif defined(SIMDE_VECTOR_SUBSCRIPT_OPS) r_.i32f = a_.i32f ^ b_.i32f; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.u64) / sizeof(r_.u64[0])) ; i++) { r_.u64[i] = a_.u64[i] ^ b_.u64[i]; } #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_xor_pd #define _mm256_xor_pd(a, b) simde_mm256_xor_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_x_mm256_xorsign_ps(simde__m256 dest, simde__m256 src) { return simde_mm256_xor_ps(simde_mm256_and_ps(simde_mm256_set1_ps(-0.0f), src), dest); } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_x_mm256_xorsign_pd(simde__m256d dest, simde__m256d src) { return simde_mm256_xor_pd(simde_mm256_and_pd(simde_mm256_set1_pd(-0.0), src), dest); } SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_x_mm256_negate_ps(simde__m256 a) { #if defined(SIMDE_X86_AVX_NATIVE) return simde_mm256_xor_ps(a,_mm256_set1_ps(SIMDE_FLOAT32_C(-0.0))); #else simde__m256_private r_, a_ = simde__m256_to_private(a); #if defined(SIMDE_VECTOR_NEGATE) r_.f32 = -a_.f32; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f32) / sizeof(r_.f32[0])) ; i++) { r_.f32[i] = -a_.f32[i]; } #endif return simde__m256_from_private(r_); #endif } SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_x_mm256_negate_pd(simde__m256d a) { #if defined(SIMDE_X86_AVX2_NATIVE) return simde_mm256_xor_pd(a, _mm256_set1_pd(SIMDE_FLOAT64_C(-0.0))); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a); #if defined(SIMDE_VECTOR_NEGATE) r_.f64 = -a_.f64; #else SIMDE_VECTORIZE for (size_t i = 0 ; i < (sizeof(r_.f64) / sizeof(r_.f64[0])) ; i++) { r_.f64[i] = -a_.f64[i]; } #endif return simde__m256d_from_private(r_); #endif } SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_unpackhi_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_unpackhi_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if defined(SIMDE_SHUFFLE_VECTOR_) r_.f32 = SIMDE_SHUFFLE_VECTOR_(32, 32, a_.f32, b_.f32, 2, 10, 3, 11, 6, 14, 7, 15); #else r_.f32[0] = a_.f32[2]; r_.f32[1] = b_.f32[2]; r_.f32[2] = a_.f32[3]; r_.f32[3] = b_.f32[3]; r_.f32[4] = a_.f32[6]; r_.f32[5] = b_.f32[6]; r_.f32[6] = a_.f32[7]; r_.f32[7] = b_.f32[7]; #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_unpackhi_ps #define _mm256_unpackhi_ps(a, b) simde_mm256_unpackhi_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_unpackhi_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_unpackhi_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if defined(SIMDE_SHUFFLE_VECTOR_) r_.f64 = SIMDE_SHUFFLE_VECTOR_(64, 32, a_.f64, b_.f64, 1, 5, 3, 7); #else r_.f64[0] = a_.f64[1]; r_.f64[1] = b_.f64[1]; r_.f64[2] = a_.f64[3]; r_.f64[3] = b_.f64[3]; #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_unpackhi_pd #define _mm256_unpackhi_pd(a, b) simde_mm256_unpackhi_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_unpacklo_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_unpacklo_ps(a, b); #else simde__m256_private r_, a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); #if defined(SIMDE_SHUFFLE_VECTOR_) r_.f32 = SIMDE_SHUFFLE_VECTOR_(32, 32, a_.f32, b_.f32, 0, 8, 1, 9, 4, 12, 5, 13); #else r_.f32[0] = a_.f32[0]; r_.f32[1] = b_.f32[0]; r_.f32[2] = a_.f32[1]; r_.f32[3] = b_.f32[1]; r_.f32[4] = a_.f32[4]; r_.f32[5] = b_.f32[4]; r_.f32[6] = a_.f32[5]; r_.f32[7] = b_.f32[5]; #endif return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_unpacklo_ps #define _mm256_unpacklo_ps(a, b) simde_mm256_unpacklo_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_unpacklo_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_unpacklo_pd(a, b); #else simde__m256d_private r_, a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); #if defined(SIMDE_SHUFFLE_VECTOR_) r_.f64 = SIMDE_SHUFFLE_VECTOR_(64, 32, a_.f64, b_.f64, 0, 4, 2, 6); #else r_.f64[0] = a_.f64[0]; r_.f64[1] = b_.f64[0]; r_.f64[2] = a_.f64[2]; r_.f64[3] = b_.f64[2]; #endif return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_unpacklo_pd #define _mm256_unpacklo_pd(a, b) simde_mm256_unpacklo_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256 simde_mm256_zextps128_ps256 (simde__m128 a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_insertf128_ps(_mm256_setzero_ps(), a, 0); #else simde__m256_private r_; r_.m128_private[0] = simde__m128_to_private(a); r_.m128_private[1] = simde__m128_to_private(simde_mm_setzero_ps()); return simde__m256_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_zextps128_ps256 #define _mm256_zextps128_ps256(a) simde_mm256_zextps128_ps256(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256d simde_mm256_zextpd128_pd256 (simde__m128d a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_insertf128_pd(_mm256_setzero_pd(), a, 0); #else simde__m256d_private r_; r_.m128d_private[0] = simde__m128d_to_private(a); r_.m128d_private[1] = simde__m128d_to_private(simde_mm_setzero_pd()); return simde__m256d_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_zextpd128_pd256 #define _mm256_zextpd128_pd256(a) simde_mm256_zextpd128_pd256(a) #endif SIMDE_FUNCTION_ATTRIBUTES simde__m256i simde_mm256_zextsi128_si256 (simde__m128i a) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_insertf128_si256(_mm256_setzero_si256(), a, 0); #else simde__m256i_private r_; r_.m128i_private[0] = simde__m128i_to_private(a); r_.m128i_private[1] = simde__m128i_to_private(simde_mm_setzero_si128()); return simde__m256i_from_private(r_); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_zextsi128_si256 #define _mm256_zextsi128_si256(a) simde_mm256_zextsi128_si256(a) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm_testc_ps (simde__m128 a, simde__m128 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_testc_ps(a, b); #else simde__m128_private a_ = simde__m128_to_private(a), b_ = simde__m128_to_private(b); #if defined(SIMDE_WASM_SIMD128_NATIVE) v128_t m = wasm_u32x4_shr(wasm_v128_or(wasm_v128_not(b_.wasm_v128), a_.wasm_v128), 31); m = wasm_v128_and(m, simde_mm_movehl_ps(m, m)); m = wasm_v128_and(m, simde_mm_shuffle_epi32(m, SIMDE_MM_SHUFFLE(3, 2, 0, 1))); return wasm_i32x4_extract_lane(m, 0); #else uint_fast32_t r = 0; SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.u32) / sizeof(a_.u32[0])) ; i++) { r |= ~a_.u32[i] & b_.u32[i]; } return HEDLEY_STATIC_CAST(int, ((~r >> 31) & 1)); #endif #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_testc_ps #define _mm_testc_ps(a, b) simde_mm_testc_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm_testc_pd (simde__m128d a, simde__m128d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_testc_pd(a, b); #else simde__m128d_private a_ = simde__m128d_to_private(a), b_ = simde__m128d_to_private(b); #if defined(SIMDE_WASM_SIMD128_NATIVE) v128_t m = wasm_u64x2_shr(wasm_v128_or(wasm_v128_not(b_.wasm_v128), a_.wasm_v128), 63); return HEDLEY_STATIC_CAST(int, wasm_i64x2_extract_lane(m, 0) & wasm_i64x2_extract_lane(m, 1)); #else uint_fast64_t r = 0; SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.u64) / sizeof(a_.u64[0])) ; i++) { r |= ~a_.u64[i] & b_.u64[i]; } return HEDLEY_STATIC_CAST(int, ((~r >> 63) & 1)); #endif #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_testc_pd #define _mm_testc_pd(a, b) simde_mm_testc_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_testc_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_testc_ps(a, b); #else uint_fast32_t r = 0; simde__m256_private a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.u32) / sizeof(a_.u32[0])) ; i++) { r |= ~a_.u32[i] & b_.u32[i]; } return HEDLEY_STATIC_CAST(int, ((~r >> 31) & 1)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_testc_ps #define _mm256_testc_ps(a, b) simde_mm256_testc_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_testc_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_testc_pd(a, b); #else uint_fast64_t r = 0; simde__m256d_private a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.u64) / sizeof(a_.u64[0])) ; i++) { r |= ~a_.u64[i] & b_.u64[i]; } return HEDLEY_STATIC_CAST(int, ((~r >> 63) & 1)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_testc_pd #define _mm256_testc_pd(a, b) simde_mm256_testc_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_testc_si256 (simde__m256i a, simde__m256i b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_testc_si256(a, b); #else int_fast32_t r = 0; simde__m256i_private a_ = simde__m256i_to_private(a), b_ = simde__m256i_to_private(b); SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.i32f) / sizeof(a_.i32f[0])) ; i++) { r |= ~a_.i32f[i] & b_.i32f[i]; } return HEDLEY_STATIC_CAST(int, !r); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_testc_si256 #define _mm256_testc_si256(a, b) simde_mm256_testc_si256(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm_testz_ps (simde__m128 a, simde__m128 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_testz_ps(a, b); #else simde__m128_private a_ = simde__m128_to_private(a), b_ = simde__m128_to_private(b); #if defined(SIMDE_WASM_SIMD128_NATIVE) v128_t m = wasm_u32x4_shr(wasm_v128_not(wasm_v128_and(a_.wasm_v128, b_.wasm_v128)), 31); m = wasm_v128_and(m, simde_mm_movehl_ps(m, m)); m = wasm_v128_and(m, simde_mm_shuffle_epi32(m, SIMDE_MM_SHUFFLE(3, 2, 0, 1))); return wasm_i32x4_extract_lane(m, 0); #else uint_fast32_t r = 0; SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.u32) / sizeof(a_.u32[0])) ; i++) { r |= a_.u32[i] & b_.u32[i]; } return HEDLEY_STATIC_CAST(int, ((~r >> 31) & 1)); #endif #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_testz_ps #define _mm_testz_ps(a, b) simde_mm_testz_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm_testz_pd (simde__m128d a, simde__m128d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_testz_pd(a, b); #else simde__m128d_private a_ = simde__m128d_to_private(a), b_ = simde__m128d_to_private(b); #if defined(SIMDE_WASM_SIMD128_NATIVE) v128_t m = wasm_u64x2_shr(wasm_v128_not(wasm_v128_and(a_.wasm_v128, b_.wasm_v128)), 63); return HEDLEY_STATIC_CAST(int, wasm_i64x2_extract_lane(m, 0) & wasm_i64x2_extract_lane(m, 1)); #else uint_fast64_t r = 0; SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.u64) / sizeof(a_.u64[0])) ; i++) { r |= a_.u64[i] & b_.u64[i]; } return HEDLEY_STATIC_CAST(int, ((~r >> 63) & 1)); #endif #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_testz_pd #define _mm_testz_pd(a, b) simde_mm_testz_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_testz_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_testz_ps(a, b); #else uint_fast32_t r = 0; simde__m256_private a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.u32) / sizeof(a_.u32[0])) ; i++) { r |= a_.u32[i] & b_.u32[i]; } return HEDLEY_STATIC_CAST(int, ((~r >> 31) & 1)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_testz_ps #define _mm256_testz_ps(a, b) simde_mm256_testz_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_testz_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_testz_pd(a, b); #else uint_fast64_t r = 0; simde__m256d_private a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.u64) / sizeof(a_.u64[0])) ; i++) { r |= a_.u64[i] & b_.u64[i]; } return HEDLEY_STATIC_CAST(int, ((~r >> 63) & 1)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_testz_pd #define _mm256_testz_pd(a, b) simde_mm256_testz_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_testz_si256 (simde__m256i a, simde__m256i b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_testz_si256(a, b); #else int_fast32_t r = 0; simde__m256i_private a_ = simde__m256i_to_private(a), b_ = simde__m256i_to_private(b); #if SIMDE_NATURAL_VECTOR_SIZE_LE(128) r = simde_mm_testz_si128(a_.m128i[0], b_.m128i[0]) && simde_mm_testz_si128(a_.m128i[1], b_.m128i[1]); #else SIMDE_VECTORIZE_REDUCTION(|:r) for (size_t i = 0 ; i < (sizeof(a_.i32f) / sizeof(a_.i32f[0])) ; i++) { r |= a_.i32f[i] & b_.i32f[i]; } r = !r; #endif return HEDLEY_STATIC_CAST(int, r); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_testz_si256 #define _mm256_testz_si256(a, b) simde_mm256_testz_si256(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm_testnzc_ps (simde__m128 a, simde__m128 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_testnzc_ps(a, b); #else simde__m128_private a_ = simde__m128_to_private(a), b_ = simde__m128_to_private(b); #if defined(SIMDE_WASM_SIMD128_NATIVE) v128_t m = wasm_u32x4_shr(wasm_v128_and(a_.wasm_v128, b_.wasm_v128), 31); v128_t m2 = wasm_u32x4_shr(wasm_v128_andnot(b_.wasm_v128, a_.wasm_v128), 31); m = wasm_v128_or(m, simde_mm_movehl_ps(m, m)); m2 = wasm_v128_or(m2, simde_mm_movehl_ps(m2, m2)); m = wasm_v128_or(m, simde_mm_shuffle_epi32(m, SIMDE_MM_SHUFFLE(3, 2, 0, 1))); m2 = wasm_v128_or(m2, simde_mm_shuffle_epi32(m2, SIMDE_MM_SHUFFLE(3, 2, 0, 1))); return wasm_i32x4_extract_lane(m, 0) & wasm_i32x4_extract_lane(m2, 0); #else uint32_t rz = 0, rc = 0; for (size_t i = 0 ; i < (sizeof(a_.u32) / sizeof(a_.u32[0])) ; i++) { rc |= ~a_.u32[i] & b_.u32[i]; rz |= a_.u32[i] & b_.u32[i]; } return (rc >> ((sizeof(rc) * CHAR_BIT) - 1)) & (rz >> ((sizeof(rz) * CHAR_BIT) - 1)); #endif #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_testnzc_ps #define _mm_testnzc_ps(a, b) simde_mm_testnzc_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm_testnzc_pd (simde__m128d a, simde__m128d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm_testnzc_pd(a, b); #else simde__m128d_private a_ = simde__m128d_to_private(a), b_ = simde__m128d_to_private(b); #if defined(SIMDE_WASM_SIMD128_NATIVE) v128_t m = wasm_u64x2_shr(wasm_v128_and(a_.wasm_v128, b_.wasm_v128), 63); v128_t m2 = wasm_u64x2_shr(wasm_v128_andnot(b_.wasm_v128, a_.wasm_v128), 63); return HEDLEY_STATIC_CAST(int, (wasm_i64x2_extract_lane(m, 0) | wasm_i64x2_extract_lane(m, 1)) & (wasm_i64x2_extract_lane(m2, 0) | wasm_i64x2_extract_lane(m2, 1))); #else uint64_t rc = 0, rz = 0; for (size_t i = 0 ; i < (sizeof(a_.u64) / sizeof(a_.u64[0])) ; i++) { rc |= ~a_.u64[i] & b_.u64[i]; rz |= a_.u64[i] & b_.u64[i]; } return (rc >> ((sizeof(rc) * CHAR_BIT) - 1)) & (rz >> ((sizeof(rz) * CHAR_BIT) - 1)); #endif #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm_testnzc_pd #define _mm_testnzc_pd(a, b) simde_mm_testnzc_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_testnzc_ps (simde__m256 a, simde__m256 b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_testnzc_ps(a, b); #else uint32_t rc = 0, rz = 0; simde__m256_private a_ = simde__m256_to_private(a), b_ = simde__m256_to_private(b); for (size_t i = 0 ; i < (sizeof(a_.u32) / sizeof(a_.u32[0])) ; i++) { rc |= ~a_.u32[i] & b_.u32[i]; rz |= a_.u32[i] & b_.u32[i]; } return (rc >> ((sizeof(rc) * CHAR_BIT) - 1)) & (rz >> ((sizeof(rz) * CHAR_BIT) - 1)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_testnzc_ps #define _mm256_testnzc_ps(a, b) simde_mm256_testnzc_ps(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_testnzc_pd (simde__m256d a, simde__m256d b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_testnzc_pd(a, b); #else uint64_t rc = 0, rz = 0; simde__m256d_private a_ = simde__m256d_to_private(a), b_ = simde__m256d_to_private(b); for (size_t i = 0 ; i < (sizeof(a_.u64) / sizeof(a_.u64[0])) ; i++) { rc |= ~a_.u64[i] & b_.u64[i]; rz |= a_.u64[i] & b_.u64[i]; } return (rc >> ((sizeof(rc) * CHAR_BIT) - 1)) & (rz >> ((sizeof(rz) * CHAR_BIT) - 1)); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_testnzc_pd #define _mm256_testnzc_pd(a, b) simde_mm256_testnzc_pd(a, b) #endif SIMDE_FUNCTION_ATTRIBUTES int simde_mm256_testnzc_si256 (simde__m256i a, simde__m256i b) { #if defined(SIMDE_X86_AVX_NATIVE) return _mm256_testnzc_si256(a, b); #else int32_t rc = 0, rz = 0; simde__m256i_private a_ = simde__m256i_to_private(a), b_ = simde__m256i_to_private(b); for (size_t i = 0 ; i < (sizeof(a_.i32f) / sizeof(a_.i32f[0])) ; i++) { rc |= ~a_.i32f[i] & b_.i32f[i]; rz |= a_.i32f[i] & b_.i32f[i]; } return !!(rc & rz); #endif } #if defined(SIMDE_X86_AVX_ENABLE_NATIVE_ALIASES) #undef _mm256_testnzc_si256 #define _mm256_testnzc_si256(a, b) simde_mm256_testnzc_si256(a, b) #endif SIMDE_END_DECLS_ HEDLEY_DIAGNOSTIC_POP #endif /* !defined(SIMDE_X86_AVX_H) */
Siv3D/OpenSiv3D
Siv3D/include/ThirdParty/simde/x86/avx.h
C
mit
196,971
<?php namespace Trainingstats; class Point { public $elevation; public $distance; public $heartrate; public $latitude; public $longitude; public $speed; public $time; public function __construct() { $this->time = new \DateTime(); } public function setElevation($elevation) { $this->elevation = (int) $elevation; } public function getElevation() { return $this->elevation; } public function setDistance($distance) { $this->distance = (float) $distance; } public function getDistance() { return $this->distance; } public function setHeartRate($heartrate) { $this->heartrate = (int) $heartrate; } public function getHeartRate() { return $this->heartrate; } public function setLatitude($latitude) { $this->latitude = (float) $latitude; } public function getLatitude() { return $this->latitude; } public function setLongitude($longitude) { $this->longitude = (float) $longitude; } public function getLongitude() { return $this->longitude; } public function setSpeed($speed) { $this->speed = (float) $speed; } public function getSpeed() { return $this->speed; } public function setTime(\DateTime $time) { $this->time = $time; } public function getTime() { return $this->time; } public function getTimestamp() { return $this->time->getTimestamp(); } }
McGo/trainingstats
src/Point.php
PHP
mit
1,403
$(() => { // Update the contents of the table when user clicks on a scope link $('.template-scope').on('ajax:success', 'a[data-remote="true"]', (e, data) => { $(e.target).closest('.template-scope').find('.paginable').html(data); }); });
CDLUC3/roadmap
app/javascript/views/org_admin/templates/index.js
JavaScript
mit
247
package org.blackchip.scorebored; import java.awt.Color; import java.awt.Font; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Style { public static final Style LED; public static final Style LCD; public static final Style WHITEBOARD; private static final List<Style> STYLES; private String name; private Color backgroundColor = Color.BLACK; private Color buttonTextColor = Color.GRAY; private Color buttonHoverColor = Color.WHITE; private Color textBackgroundColor = Color.WHITE; private Color subtitleColor = Color.WHITE; private Font teamFont = new Font("Inconsolata", Font.BOLD, 125); private Font scoreFont = new Font("Inconsolata", Font.BOLD, 450); private long subtitleFadeTime = 1000; private List<TeamColor> teamColors; static { LED = new Style(); LED.name = "LED"; LED.backgroundColor = new Color(8, 8, 8); LED.textBackgroundColor = new Color(42, 42, 42); LED.buttonTextColor = Color.LIGHT_GRAY; LED.buttonHoverColor = Color.YELLOW; LED.subtitleColor = Color.WHITE; LED.teamFont = new Font("Inconsolata", Font.BOLD, 125); LED.scoreFont = new Font("DS-Digital", Font.PLAIN, 525); LED.teamColors = Collections.unmodifiableList(Arrays.asList( TeamColor.LED_RED, TeamColor.LED_CYAN, TeamColor.LED_AMBER, TeamColor.LED_GREEN )); LCD = new Style(); LCD.name = "LCD"; LCD.backgroundColor = new Color(235, 238, 220); LCD.textBackgroundColor = new Color(255, 255, 250); LCD.buttonTextColor = TeamColor.LCD.getColor(); LCD.buttonHoverColor = LCD.buttonTextColor; LCD.subtitleColor = TeamColor.LCD.getColor(); LCD.scoreFont = new Font("DS-Digital", Font.PLAIN, 550); LCD.teamColors = Collections.unmodifiableList(Arrays.asList( TeamColor.LCD )); WHITEBOARD = new Style(); WHITEBOARD.name = "Whiteboard"; WHITEBOARD.backgroundColor = new Color(255, 255, 255); WHITEBOARD.textBackgroundColor = new Color(240, 240, 240); WHITEBOARD.buttonTextColor = new Color(0, 0, 0); WHITEBOARD.buttonHoverColor = Color.BLACK; WHITEBOARD.subtitleColor = Color.BLACK; WHITEBOARD.scoreFont = new Font("pastel", Font.PLAIN, 500); WHITEBOARD.teamColors = Collections.unmodifiableList(Arrays.asList( TeamColor.DARK_RED, TeamColor.DARK_BLUE, TeamColor.DARK_YELLOW, TeamColor.DARK_GREEN, TeamColor.BLACK)); STYLES = Collections.unmodifiableList(Arrays.asList( LED, LCD, WHITEBOARD )); } public static List<Style> getStyles() { return STYLES; } /** * @return the name */ public String getName() { return name; } /** * @return the backgroundColor */ public Color getBackgroundColor() { return backgroundColor; } /** * @return the teamColors */ public List<TeamColor> getTeamColors() { return teamColors; } @Override public String toString() { return name; } /** * @return the buttonTextColor */ public Color getButtonTextColor() { return buttonTextColor; } /** * @param buttonTextColor the buttonTextColor to set */ public void setButtonTextColor(Color buttonTextColor) { this.buttonTextColor = buttonTextColor; } /** * @return the buttonHoverColor */ public Color getButtonHoverColor() { return buttonHoverColor; } /** * @param buttonHoverColor the buttonHoverColor to set */ public void setButtonHoverColor(Color buttonHoverColor) { this.buttonHoverColor = buttonHoverColor; } /** * @return the textBackgroundColor */ public Color getTextBackgroundColor() { return textBackgroundColor; } /** * @return the subtitleColor */ public Color getSubtitleColor() { return subtitleColor; } public long getSubtitleFadeTime() { return subtitleFadeTime; } public Font getScoreFont() { return scoreFont; } public Font getTeamFont() { return teamFont; } }
scorebored/scorebored
src/main/java/org/blackchip/scorebored/Style.java
Java
mit
4,535
<div class="row"> <div class="col s12"> <table class="bordered highlight responsive-table"> <thead> <tr> <th width='5%'>#</th> <th>Subject</th> <th>From Name</th> <th>From Email</th> <th>Active</th> <th width='20%'>Action</th> </tr> </thead> <tbody> <?php if(!empty($dataSet)){ $intCoounter = $intPageNumber; foreach($dataSet as $dataSetKey => $dataSetValue){?> <tr> <td><?php echo $intCoounter?></td> <td><?php echo $dataSetValue['email_subject']?></td> <td><?php echo $dataSetValue['from_name']?></td> <td><?php echo $dataSetValue['from_email']?></td> <td><?php echo (($dataSetValue['is_active'] == 1)?'Yes':'No');?></td> <td> <a href="javascript:void(0);" onclick="openEditModel('deleteModel','<?php echo getEncyptionValue($dataSetValue['id'])?>',0);" class="waves-effect waves-circle waves-light btn-floating secondary-content red"><i class="material-icons">delete</i></a>&nbsp; <a href="javascript:void(0);" onclick="openEditModel('<?php echo $strDataAddEditPanel?>','<?php echo getEncyptionValue($dataSetValue['id'])?>',1);" class="waves-effect waves-circle waves-light btn-floating secondary-content"><i class="material-icons">edit</i></a> </td> </tr> <?php $intCoounter++;?> <?php } }else{ echo getNoRecordFoundTemplate(6); } ?> </tbody> </table> </div> </div> <!-- Add /Edit Modal Structure --> <div id="<?php echo $strDataAddEditPanel?>" class="modal modal-fixed-footer"> <div class="modal-content"> <h4><span class="spnActionText">Add New</span> <?php echo $moduleTitle?></h4> <form class="col s12" method="post" action="<?php echo SITE_URL?>settings/emailtemplate/setEmailTemplateDetails" name="<?php echo $moduleForm?>" id="<?php echo $moduleForm?>"> <div class='row'> <div class='col s12'> </div> </div> <div class='row'> <div class='input-field col s12'> <input class='validate' type='text' name='txtEmailSubject' id='txtEmailSubject' data-set="email_subject" /> <label for='txtEmailSubject'>Email Subject *</label> </div> </div> <div class='row'> <div class='input-field col s12'> <input class='validate' type='text' name='txtEmailFromName' id='txtEmailFromName' data-set="from_name" /> <label for='txtEmailFromName'>From Name *</label> </div> </div> <div class='row'> <div class='input-field col s12'> <input class='validate' type='text' name='txtEmailFromEmail' id='txtEmailFromEmail' data-set="from_email" /> <label for='txtEmailFromName'>From Email *</label> </div> </div> <div class='row no-search'> <div class='input-field col s12'> <textarea class='materialize-textarea' name='txtEmailBody' id='txtEmailBody' data-set="email_body"></textarea> <label for='txtEmailFromName'>Email Content</label> </div> </div> <div class='row no-search'> <div class='input-field col s12'> <input class='validate' type='text' name='txtBlackListEmailAddress' id='txtBlackListEmailAddress' data-set="black_list_emails" /> <label for='txtBlackListEmailAddress'>Black List Emails(s) [Separated by comma]</label> </div> </div> <div class='row no-search'> <label>Is Active Email Template*</label> <div class='input-field col s12'> <input class="with-gap" name="rdoisDefault" value="1" type="radio" id="isDefaultYes" data-set="is_active" /> <label for="isDefault">Yes</label> <input class="with-gap" name="rdoisDefault" value="0" type="radio" id="isDefaultNo" checked data-set="is_active" /> <label for="isDefault">No</label> </div> </div> <input type="hidden" name="txtEmailTemplateCode" id="txtEmailTemplateCode" value="" data-set="id" /> <input type="hidden" name="eMaIlCoDe" id="eMaIlCoDe" value="<?php echo ($strEmailPCode)?>" /> <input type="hidden" name="txtSearch" id="txtSearch" value="" data-set="" /> </form> </div> <div class="modal-footer"> <a href="javascript:void(0);" class="modal-action modal-close waves-effect waves-green btn-flat">Cancel</a> <button class="btn waves-effect waves-light cmdSearchReset green lighten-2 hide" type="submit" name="cmdSearchReset" id="cmdSearchReset" formName="<?php echo $moduleForm?>" >Clear Filter<i class="material-icons right">find_replace</i></button> <button class="btn waves-effect waves-light cmdStatusManagment" type="submit" name="cmdStatusManagment" id="cmdStatusManagment" formName="<?php echo $moduleForm?>" >Submit<i class="material-icons right">send</i></button> </div> </div>
jaiswarvipin/lms-open-source-framework
application/views/settings/email_templates.php
PHP
mit
5,256
--- layout: post title: '[알고리즘] 연결 성분(Connected Component) 찾는 방법' subtitle: '연결 성분을 이해할 수 있다.' date: 2018-08-16 author: heejeong Kwon cover: '/images/data-structure-graph/connected-component-main.png' tags: algorithm graph connected-component comments: true sitemap : changefreq : daily priority : 1.0 --- ## Goal > - 연결 성분(Connected Component)이란 > - 연결 성분(Connected Component)을 찾는 방법 ## 연결 성분(Connected Component)이란 나누어진 각각의 그래프 * 그래프는 여러 개의 고립된 부분 그래프(Isolated Subgraphs)로 구성될 수 있다. * 즉, 서로 연결되어 있는 여러 개의 고립된 부분 그래프 각각을 연결 성분이라고 부른다. ## 연결 성분의 특징 * 연결 성분에 속한 모든 정점을 연결하는 경로가 있어야 한다. * 또, 다른 연결 성분에 속한 정점과 연결하는 경로가 있으면 안된다. * 연결 성분을 찾는 방법은 BFS, DFS 탐색을 이용하면 된다. ## 연결 성분을 찾는 방법 연결 성분을 찾는 방법은 너비 우선 탐색(BFS), 깊이 우선 탐색(DFS)을 이용하면 된다. 1. BFS, DFS를 시작하면 시작 정점으로부터 도달 가능한 모든 정점들이 하나의 연결 성분이 된다. 2. 다음에 방문하지 않은 정점을 선택해서 다시 탐색을 시작하면 그 정점을 포함하는 연결 성분이 구해진다. 3. 이 과정을 그래프 상의 모든 정점이 방문될 때까지 반복하면 그래프에 존재하는 모든 연결 성분들을 찾을 수 있다. ## 연결 성분의 개수 구하는 방법 ~~~java boolean[] visited = new boolean[N + 1]; // N: 정ㅇ점의 수 int cntComponent = 0; // 각 정점에 대해서 한번씩 확인. for (int i = 1; i <= N; i++) { if (!visited[i]) { // 방문했던 정점은 지나치므로, 연결이 떨어진 정점에 대해서만 카운트++ dfs(arrayLists, i, visited); // dfs 탐색 cntComponent++; } } ~~~ # 관련된 Post * 자료구조 그래프(Graph)에 대해 알고 싶으시면 [그래프(Graph)란](https://gmlwjd9405.github.io/2018/08/13/data-structure-graph.html)을 참고하시기 바랍니다. * 깊이 우선 탐색(DFS, Depth-First Search): [깊이 우선 탐색(DFS)이란](https://gmlwjd9405.github.io/2018/08/14/algorithm-dfs.html) 을 참고하시기 바랍니다. * 너비 우선 탐색(BFS, Breadth-First Search): [너비 우선 탐색(BFS)이란](https://gmlwjd9405.github.io/2018/08/15/algorithm-bfs.html) 을 참고하시기 바랍니다. # References > - [C언어로 쉽게 풀어 쓴 자료구조](http://www.kyobobook.co.kr/product/detailViewKor.laf?ejkGb=KOR&barcode=9788970506432)
gmlwjd9405/gmlwjd9405.github.io
_posts/2018-08-16-algorithm-connected-component.md
Markdown
mit
2,746
# # Enables local Python package installation. # # Authors: # Sorin Ionescu <[email protected]> # Sebastian Wiesner <[email protected]> # Patrick Bos <[email protected]> # # Load dependencies pmodload 'helper' # Load manually installed pyenv into the path if [[ -s "${PYENV_ROOT:=$HOME/.pyenv}/bin/pyenv" ]]; then path=("${PYENV_ROOT}/bin" $path) eval "$(pyenv init - --no-rehash zsh)" # Load pyenv into the current python session elif (( $+commands[pyenv] )); then eval "$(pyenv init - --no-rehash zsh)" # Prepend PEP 370 per user site packages directory, which defaults to # ~/Library/Python on macOS and ~/.local elsewhere, to PATH. The # path can be overridden using PYTHONUSERBASE. else if [[ -n "$PYTHONUSERBASE" ]]; then path=($PYTHONUSERBASE/bin $path) elif is-darwin; then path=($HOME/Library/Python/*/bin(N) $path) else # This is subject to change. path=($HOME/.local/bin $path) fi fi # Return if requirements are not found. if (( ! $+commands[python] && ! $+commands[pyenv] )); then return 1 fi function _python-workon-cwd { # Check if this is a Git repo local GIT_REPO_ROOT="" local GIT_TOPLEVEL="$(git rev-parse --show-toplevel 2> /dev/null)" if [[ $? == 0 ]]; then GIT_REPO_ROOT="$GIT_TOPLEVEL" fi # Get absolute path, resolving symlinks local PROJECT_ROOT="${PWD:A}" while [[ "$PROJECT_ROOT" != "/" && ! -e "$PROJECT_ROOT/.venv" \ && ! -d "$PROJECT_ROOT/.git" && "$PROJECT_ROOT" != "$GIT_REPO_ROOT" ]]; do PROJECT_ROOT="${PROJECT_ROOT:h}" done if [[ "$PROJECT_ROOT" == "/" ]]; then PROJECT_ROOT="." fi # Check for virtualenv name override local ENV_NAME="" if [[ -f "$PROJECT_ROOT/.venv" ]]; then ENV_NAME="$(cat "$PROJECT_ROOT/.venv")" elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]]; then ENV_NAME="$PROJECT_ROOT/.venv" elif [[ "$PROJECT_ROOT" != "." ]]; then ENV_NAME="${PROJECT_ROOT:t}" fi if [[ -n $CD_VIRTUAL_ENV && "$ENV_NAME" != "$CD_VIRTUAL_ENV" ]]; then # We've just left the repo, deactivate the environment # Note: this only happens if the virtualenv was activated automatically deactivate && unset CD_VIRTUAL_ENV fi if [[ "$ENV_NAME" != "" ]]; then # Activate the environment only if it is not already active if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" elif [[ -e "$ENV_NAME/bin/activate" ]]; then source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" fi fi fi } # Load auto workon cwd hook if zstyle -t ':prezto:module:python:virtualenv' auto-switch 'yes'; then # Auto workon when changing directory autoload -Uz add-zsh-hook add-zsh-hook chpwd _python-workon-cwd fi # Load virtualenvwrapper into the shell session, if pre-requisites are met # and unless explicitly requested not to if (( $+VIRTUALENVWRAPPER_VIRTUALENV || $+commands[virtualenv] )) && \ zstyle -T ':prezto:module:python:virtualenv' initialize ; then # Set the directory where virtual environments are stored. export WORKON_HOME="${WORKON_HOME:-$HOME/.virtualenvs}" # Disable the virtualenv prompt. Note that we use the magic value used by the # pure prompt because there's some additional logic in that prompt which tries # to figure out if a user set this variable and disable the python portion of # that prompt based on it which is the exact opposite of what we want to do. export VIRTUAL_ENV_DISABLE_PROMPT=12 # Create a sorted array of available virtualenv related 'pyenv' commands to # look for plugins of interest. Scanning shell '$path' isn't enough as they # can exist in 'pyenv' synthesized paths (e.g., '~/.pyenv/plugins') instead. local -a pyenv_plugins if (( $+commands[pyenv] )); then pyenv_plugins=(${(@oM)${(f)"$(pyenv commands --no-sh 2>/dev/null)"}:#virtualenv*}) fi if (( $pyenv_plugins[(i)virtualenv-init] <= $#pyenv_plugins )); then # Enable 'virtualenv' with 'pyenv'. eval "$(pyenv virtualenv-init - zsh)" # Optionally activate 'virtualenvwrapper' plugin when available. if (( $pyenv_plugins[(i)virtualenvwrapper(_lazy|)] <= $#pyenv_plugins )); then pyenv "$pyenv_plugins[(R)virtualenvwrapper(_lazy|)]" fi else # Fallback to 'virtualenvwrapper' without 'pyenv' wrapper if available # in '$path' or in an alternative location on a Debian based system. # # If homebrew is installed and the python location wasn't overridden via # environment variable we fall back to python3 then python2 in that order. # This is needed to fix an issue with virtualenvwrapper as homebrew no # longer shadows the system python. if [[ -z "$VIRTUALENVWRAPPER_PYTHON" ]] && (( $+commands[brew] )); then if (( $+commands[python3] )); then export VIRTUALENVWRAPPER_PYTHON=$commands[python3] elif (( $+commands[python2] )); then export VIRTUALENVWRAPPER_PYTHON=$commands[python2] fi fi virtenv_sources=( ${(@Ov)commands[(I)virtualenvwrapper(_lazy|).sh]} /usr/share/virtualenvwrapper/virtualenvwrapper(_lazy|).sh(OnN) ) if (( $#virtenv_sources )); then source "${virtenv_sources[1]}" fi unset virtenv_sources fi unset pyenv_plugins fi # Load PIP completion. if (( $#commands[(i)pip(|[23])] )); then cache_file="${XDG_CACHE_HOME:-$HOME/.cache}/prezto/pip-cache.zsh" # Detect and use one available from among 'pip', 'pip2', 'pip3' variants pip_command="$commands[(i)pip(|[23])]" if [[ "$pip_command" -nt "$cache_file" \ || "${ZDOTDIR:-$HOME}/.zpreztorc" -nt "$cache_file" \ || ! -s "$cache_file" ]]; then mkdir -p "$cache_file:h" # pip is slow; cache its output. And also support 'pip2', 'pip3' variants $pip_command completion --zsh \ | sed -e "s/\(compctl -K [-_[:alnum:]]* pip\).*/\1{,2,3}{,.{0..9}}/" \ >! "$cache_file" \ 2> /dev/null fi source "$cache_file" unset cache_file pip_command fi # Load conda into the shell session, if requested zstyle -T ':prezto:module:python' conda-init if (( $? && $+commands[conda] )); then if (( $(conda ..changeps1) )); then echo "To make sure Conda doesn't change your prompt (should do that in the prompt module) run:\n conda config --set changeps1 false" # TODO: # We could just run this ourselves. In an exit hook # (add zsh-hook zshexit [(anonymous) function]) we could then set it back # to the way it was before we changed it. However, I'm not sure if this is # exception safe, so left it like this for now. fi fi # # Aliases # alias py='python' alias py2='python2' alias py3='python3'
ptillemans/prezto
modules/python/init.zsh
Shell
mit
6,741
# encoding: utf-8 # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. module Azure end module Azure::Web end module Azure::Web::Mgmt end module Azure::Web::Mgmt::V2020_09_01 end
Azure/azure-sdk-for-ruby
management/azure_mgmt_web/lib/2020-09-01/generated/azure_mgmt_web/module_definition.rb
Ruby
mit
272
<!doctype html> <html class="no-js" lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Le Jardin de Yilin</title> <meta name="description" content=""> <meta name="author" content="Yilin Wei"> <link rel="stylesheet" href="http://lemonsong.github.io/blog/output/theme/css/foundation.css" /> <link rel="stylesheet" href="http://lemonsong.github.io/blog/output/theme/css/pygment/monokai.css" /> <link rel="stylesheet" href="http://lemonsong.github.io/blog/output/theme/css/custom.css" /> <script src="http://lemonsong.github.io/blog/output/theme/js/modernizr.js"></script> <!-- Feeds --> <script>var _gaq=[['_setAccount','UA-45111796-1'],['_trackPageview']];(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.src='//www.google-analytics.com/ga.js';s.parentNode.insertBefore(g,s)}(document,'script'))</script> <!-- mathjax config similar to math.stackexchange --> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ jax: ["input/TeX", "output/HTML-CSS"], tex2jax: { inlineMath: [ ['$', '$'] ], displayMath: [ ['$$', '$$']], processEscapes: true, skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'] }, messageStyle: "none", "HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"] } }); </script> <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> </head> <body> <div class="off-canvas-wrap"> <div class="inner-wrap"> <!-- mobile top bar to activate nav --> <nav class="tab-bar show-for-small"> <section class="left-small"> <a class="left-off-canvas-toggle menu-icon" ><span></span></a> </section> <section class="middle tab-bar-section"> <h1 class="title">Le&nbsp;Jardin&nbsp;de&nbsp;Yilin</h1> </section> </nav> <!-- mobile side bar nav --> <aside class="left-off-canvas-menu"> <ul class="off-canvas-list"> <li><a href="http://lemonsong.github.io/blog/output">Home</a></li> <li><label>Categories</label></li> <li ><a href="http://lemonsong.github.io/blog/output/category/blog.html">Blog</a></li> <li class="active"><a href="http://lemonsong.github.io/blog/output/category/notes.html">Notes</a></li> <li><label>Links</label></li> <li><a href="http://getpelican.com/">Pelican</a></li> <li><a href="http://python.org/">Python.org</a></li> <li><a href="http://jinja.pocoo.org/">Jinja2</a></li> <li><a href="#">You can modify those links in your config file</a></li> <li><label>Monthly Archives</label></li> <li><a href="/posts/2010/12/index.html">December 2010 (2)</a></li> <li><label>Social</label></li> <li><a href="https://github.com/lemonsong">Github</a></li> <li><a href="https://www.linkedin.com/in/yilinwei">LinkedIn</a></li> <li><a href="https://twitter.com/lemonsonglynn">Twitter</a></li> </ul> </aside> <!-- top bar nav --> <nav class="top-bar hide-for-small-only" data-topbar> <ul class="title-area"> <li class="name"> <!--<h1><a href="http://lemonsong.github.io/blog/output/">Le Jardin de Yilin</a></h1>--> <h1><a href="http://lemonsong.github.io">Le Jardin de Yilin</a></h1> </li> </ul> <section class="top-bar-section"> <ul class="left"> <li ><a href="http://lemonsong.github.io/blog/output/category/blog.html">Blog</a></li> <li class="active"><a href="http://lemonsong.github.io/blog/output/category/notes.html">Notes</a></li> <!--add by me--> <li><a href="http://lemonsong.github.io/blog/output/random.html"><span class="icon-label">Random article</span></a></li> </ul> <ul class="right"> <!--add by me--> <li><a href="http://lemonsong.github.io/blog/output/random.html"><span class="icon-label">Random article</span></a></li> </ul> </section> </nav> <!-- Main Page Content and Sidebar --> <section class="main-section"> <div class="row"> <!-- Main Content --> <div class="medium-9 small-12 columns" role="content"> <article> <h2>Detect Encode for File</h2> <h3>This is the content of my super blog post.</h3> <p>This is the content of my super blog post.</p> <hr/> <h6>Written by <a href="http://lemonsong.github.io/blog/output/author/yilin-wei.html">Yilin Wei</a> in <a href="http://lemonsong.github.io/blog/output/category/notes.html">Notes</a> on Fri 03 December 2010. Tags: <a href="http://lemonsong.github.io/blog/output/tag/python.html">python</a>, <a href="http://lemonsong.github.io/blog/output/tag/encode.html">encode</a>, </h6> </article> <!-- JiaThis Button BEGIN --> <div class="jiathis_style"><span class="jiathis_txt">分享到:</span> <a class="jiathis_button_tsina"></a> <a class="jiathis_button_douban"></a> <a class="jiathis_button_twitter"></a> <a class="jiathis_button_fb"></a> <a class="jiathis_button_linkedin"></a> <a href="http://www.jiathis.com/share?uid=2058140" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a> <a class="jiathis_counter_style"></a> </div> <script type="text/javascript" > var jiathis_config={ data_track_clickback:true, summary:"", shortUrl:false, hideMore:false } </script> <script type="text/javascript" src="http://v3.jiathis.com/code_mini/jia.js?uid=2058140" charset="utf-8"></script> <!-- JiaThis Button END --> <div> <br /> <hr /> <ul> <li> <a href="http://lemonsong.github.io/blog/output/pages/2010/12/03/under construction/"> 上一篇文章:The website is under construction </a> </li> </ul> </div> <hr/> <div class="row"> <div class="small-12 columns"> <h3>Comments</h3> <div id="disqus_thread"></div> <script type="text/javascript"> var disqus_shortname = 'yilinwei'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); </script> <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript> <a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a> </div> </div> </div> <!-- End Main Content --> <!-- Sidebar --> <aside class="medium-3 hide-for-small-only columns"> <div class="panel"> <h5>Links</h5> <ul class="side-nav"> <li><a href="http://getpelican.com/">Pelican</a></li> <li><a href="http://python.org/">Python.org</a></li> <li><a href="http://jinja.pocoo.org/">Jinja2</a></li> <li><a href="#">You can modify those links in your config file</a></li> </ul> </div> <div class="panel"> <h5>Tags</h5> <ul class="tag-cloud"> </ul> </div> <div class="panel"> <h5>Monthly Archives</h5> <ul class="side-nav"> <li><a href="/posts/2010/12/index.html">December 2010 (2)</a></li> </ul> </div> <div class="panel"> <h5>Social</h5> <ul class="side-nav"> <li><a href="https://github.com/lemonsong">Github</a></li> <li><a href="https://www.linkedin.com/in/yilinwei">LinkedIn</a></li> <li><a href="https://twitter.com/lemonsonglynn">Twitter</a></li> </ul> </div> </aside> <!-- End Sidebar --> </div> <!-- Footer --> <footer class="row"> <div class="medium-9 small-12"> <hr/> <p class="text-center">Powered by <a href="http://getpelican.com">Pelican</a> and <a href="http://foundation.zurb.com/">Zurb Foundation</a>. Theme by <a href="http://hamaluik.com">Kenton Hamaluik</a>.</p> </div> </footer> <!-- End Footer --> </section> <a class="exit-off-canvas"></a> </div><!--off-canvas inner--> </div><!--off-canvas wrap--> <script src="http://lemonsong.github.io/blog/output/theme/js/jquery.js"></script> <script src="http://lemonsong.github.io/blog/output/theme/js/foundation.min.js"></script> <script> $(document).foundation(); </script> </body> </html>
lemonsong/lemonsong.github.io
blog/output/pages/2010/12/03/notes2/index.html
HTML
mit
8,861
#! /usr/bin/env python from PyQt4 import QtGui from pandas import to_numeric, concat from poplerGUI import class_inputhandler as ini from poplerGUI import class_modelviewpandas as view from Views import ui_dialog_time as uitime from poplerGUI import ui_logic_preview as tprev from poplerGUI.logiclayer import class_helpers as hlp from poplerGUI.logiclayer import class_timeparse as tmpa from poplerGUI.logiclayer.datalayer import config as orm class TimeDialog(QtGui.QDialog, uitime.Ui_Dialog): def __init__(self, parent=None): super().__init__(parent) self.setupUi(self) # Place holders for user inputs self.timelned = {} # Place holder: Data Model/ Data model view self.timemodel = None self.viewEdit = view.PandasTableModelEdit # Placeholders: Data tables self.timetable = None # Placeholder for maindata Orms self.timeorms = {} # Actions self.btnPreview.clicked.connect(self.submit_change) self.btnSaveClose.clicked.connect(self.submit_change) self.btnCancel.clicked.connect(self.close) # Update boxes/preview box self.message = QtGui.QMessageBox self.error = QtGui.QErrorMessage() self.preview = tprev.TablePreview() def submit_change(self): sender = self.sender() self.timelned = { 'dayname': self.lnedDay.text(), 'dayform': self.cboxDay.currentText(), 'monthname': self.lnedMonth.text(), 'monthform': self.cboxMonth.currentText(), 'yearname': self.lnedYear.text(), 'yearform': self.cboxYear.currentText(), 'jd': self.ckJulian.isChecked(), 'hms': self.ckMonthSpelling.isChecked() } print('dict: ', self.timelned) for i, item in enumerate(self.timelned.values()): print('dict values: ', list(self.timelned.keys())[i], item) # Input handler self.timeini = ini.InputHandler( name='timeinfo', tablename='timetable', lnedentry=self.timelned) self.facade.input_register(self.timeini) # Initiating time parser class self.timetable = tmpa.TimeParse( self.facade._data, self.timelned) # Logger self.facade.create_log_record('timetable') self._log = self.facade._tablelog['timetable'] try: # Calling formater method timeview = self.timetable.formater().copy() timeview_og_col = timeview.columns.values.tolist() timeview.columns = [ x+'_derived' for x in timeview_og_col ] timeview = concat( [timeview, self.facade._data], axis=1) except Exception as e: print(str(e)) self._log.debug(str(e)) self.error.showMessage( 'Could not format dates - ' + 'Check entries for errors' ) raise ValueError( 'Could not format dates - ' + 'Check entries for errors') self.facade._valueregister['sitelevels'] if sender is self.btnPreview: timeview = timeview.applymap(str) self.timemodel = self.viewEdit(timeview) self.preview.tabviewPreview.setModel(self.timemodel) self.preview.show() elif sender is self.btnSaveClose: hlp.write_column_to_log( self.timelned, self._log, 'timetable' ) try: timeview.loc[1, 'day_derived'] = to_numeric( timeview['day_derived']) timeview['month_derived'] = to_numeric( timeview['month_derived']) timeview['year_derived'] = to_numeric( timeview['year_derived']) except Exception as e: print(str(e)) pass try: self.facade.push_tables['timetable'] = ( timeview) except Exception as e: print(str(e)) print('save block: ', timeview.columns) print('save block: ', timeview) try: assert timeview is not None except Exception as e: print(str(e)) self._log.debug(str(e)) self.error.showMessage( 'Could not convert data to integers') raise TypeError( 'Could not convert data to integers') self.close()
bibsian/database-development
poplerGUI/ui_logic_time.py
Python
mit
4,606
# -*- coding: utf-8 -*- # Generated by Django 1.11 on 2017-05-12 14:36 from __future__ import unicode_literals import datetime from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('distances', '0008_auto_20170511_1259'), ] operations = [ migrations.AddField( model_name='exercise', name='text', field=models.CharField(default='description', max_length=300), ), migrations.AlterField( model_name='dates', name='startDate', field=models.DateField(default=datetime.datetime(2017, 5, 5, 17, 36, 6, 917070)), ), ]
tkettu/rokego
distances/migrations/0009_auto_20170512_1736.py
Python
mit
687
/* * This file is part of Cubic Chunks Mod, licensed under the MIT License (MIT). * * Copyright (c) 2015-2021 OpenCubicChunks * Copyright (c) 2015-2021 contributors * * 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. */ package io.github.opencubicchunks.cubicchunks.core.asm.mixin.fixes.common; import io.github.opencubicchunks.cubicchunks.api.world.ICubicWorld; import mcp.MethodsReturnNonnullByDefault; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityMinecart; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; import javax.annotation.ParametersAreNonnullByDefault; @MethodsReturnNonnullByDefault @ParametersAreNonnullByDefault @Mixin(EntityMinecart.class) public abstract class MixinEntityMinecart_KillFix extends Entity { public MixinEntityMinecart_KillFix(World worldIn) { super(worldIn); } /** * Replace -64 constant, to avoid killing minecarts below y=-64 */ @ModifyConstant(method = "onUpdate", constant = @Constant(doubleValue = -64.0D), require = 1) private double getDeathY(double originalY) { return ((ICubicWorld) world).getMinHeight() + originalY; } }
OpenCubicChunks/CubicChunks
src/main/java/io/github/opencubicchunks/cubicchunks/core/asm/mixin/fixes/common/MixinEntityMinecart_KillFix.java
Java
mit
2,336
package me.huding.io.zip; public class ZipStream { public static void main(String[] args) { } }
hujianhong/Java
io/src/main/java/me/huding/io/zip/ZipStream.java
Java
mit
105
<?php namespace FalconSearch\Console\Commands\Crawl; use Carbon\Carbon; use Elasticsearch\Client; use Elasticsearch\Common\Exceptions\ElasticsearchException; use Illuminate\Console\Command; use Illuminate\Contracts\Config\Repository; use Illuminate\Contracts\Redis\Database; class ProcessNodes extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'crawl:process-nodes {--d|debug : Desplaying debuging info and errors}'; /** * The console command description. * * @var string */ protected $description = 'Crawl nodes data and index them'; protected $ignoringTags = [ 'head', 'style', 'script', 'noscript', 'iframe', 'form', 'header', 'footer', 'nav', 'navbar', 'aside', 'button', 'meta', 'link', 'textarea' ]; /** * @var Database */ protected $redis; /** * @var Client */ protected $client; /** * @var \DOMDocument */ protected $dom; /** * @var Repository */ protected $config; protected $counter = [ 'indexed' => 0, 'updated' => 0, 'empty_url' => 0, 'failed_url' => 0, 'failed_index' => 0 ]; protected $time = [ 'start' => null, 'end' => null ]; /** * Create a new command instance. * * @param Database $redis * @param Client $client * @param Repository $config */ public function __construct(Database $redis, Client $client, Repository $config) { parent::__construct(); $this->redis = $redis; $this->client = $client; $this->dom = new \DOMDocument(); $this->config = $config; } /** * Execute the console command. * * @return mixed */ public function handle() { $this->time['start'] = Carbon::createFromTimestamp(time())->toDateTimeString(); $limit = $this->config->get('settings.cron.limit'); while ($limit > 0) { $data = json_decode($this->redis->rPop('nodes-queue'), true); if (is_null($data)) { $this->info("There is no more node in redis queue to process"); break; } $limit--; if (!isset($data['url'])) { $this->counter['failed_url']++; $this->logDebugInfo('Invalid url', $data); continue; } $url = $data['url']; $date = (isset($data['date']) || $data['date']) ? $data['date'] : null; $cachePage = storage_path('caches/' . md5($url) . '.html'); if (!file_exists($cachePage)) { try { $htmlContent = file_get_contents($url); } catch (\Exception $e) { $this->error("# Cannot get content of $url. [{$e->getMessage()}]"); $this->counter['failed_url']++; continue; } file_put_contents($cachePage, html_entity_decode($htmlContent)); } @$this->dom->loadHTMLFile($cachePage); $title = $this->getTitle(); if (is_null($title)) { $this->counter['empty_url']++; $this->logDebugInfo('Empty content', $data); continue; } $content = $this->getContent( $this->pruneContent($this->dom->getElementsByTagName('body')->item(0)) ); $this->saveNode($title, $content, $url, $date); } $this->printResultTable(); } public function error($string) { if ($this->option('debug')) { parent::error($string); } else { $this->logDebugInfo('Error', $string); } } /** * @return string */ protected function getTitle() { try { return $this->dom->getElementsByTagName('title')->item(0)->textContent; } catch (\Exception $e) { return null; } } /** * @param \DOMNode $node * @return \DOMNode|null */ protected function pruneContent($node) { if (is_null($node) || empty($node->textContent)) { return null; } else { if ($node->hasChildNodes()) { $blackList = []; /** @var \DOMNode $child */ foreach ($node->childNodes as $child) { if ($child instanceof \DOMCdataSection) { array_push($blackList, $child); continue; } elseif ($child instanceof \DOMText) { continue; } elseif (!$child instanceof \DOMElement) { array_push($blackList, $child); continue; } /** @var \DOMElement $child */ if ($this->shouldBeIgnored($child)) { array_push($blackList, $child); } else { $newChild = $this->pruneContent($child); if (is_null($newChild)) { array_push($blackList, $child); } else { $node->replaceChild($newChild, $child); } } } $node = $this->removeBlackNodes($node, $blackList); } elseif (empty($node->textContent)) { return null; } return $node; } } protected function shouldBeIgnored(\DOMElement $node) { return in_array($node->tagName, $this->ignoringTags); } protected function removeBlackNodes(\DOMNode $node, array $blackList) { foreach ($blackList as $blackNode) { $node->removeChild($blackNode); } return $node; } /** * @param \DOMNode $content * @return string */ protected function getContent($content) { $cleanContent = ''; if ($content instanceof \DOMElement && $content->hasChildNodes()) { foreach ($content->childNodes as $childNode) { $subContent = $this->getContent($childNode); if (!empty($subContent)) { $cleanContent .= " " . $subContent; } } } elseif (!empty($content->textContent)) { $cleanContent .= " " . $content->textContent; } return trim(preg_replace('/\s+/', ' ', $cleanContent)); } protected function saveNode($title, $content, $url, $date) { $content = $this->cleanContent($content); if (is_null($content)) { $this->counter['empty_url']++; return false; } $hashId = md5($url); $params = [ 'index' => 'sites', 'type' => 'default', 'id' => $hashId, 'body' => [ 'title' => $title, 'content' => $content, 'hash_id' => $hashId, 'date' => ($date) ? Carbon::createFromTimestamp($date)->toW3cString() : null, 'url' => $url ] ]; try { $response = $this->client->index($params); if (!$response['created']) { $this->counter['updated']++; } else { $this->counter['indexed']++; } } catch (ElasticsearchException $e) { $this->error("# Cannot Index content of $url. Check \"failed:$url\" key in redis for more information"); $this->redis->hMSet("failed:$url", [ 'error' => $e->getMessage(), 'params' => $url ]); $this->counter['failed_index']++; } return true; } protected function printResultTable() { $this->time['end'] = Carbon::createFromTimestamp(time())->toDateTimeString(); $this->info("* Cron start at {$this->time['start']} and finished at {$this->time['end']} with the following results:"); $headers = [ 'indexed urls', 'failed urls', 'no content urls', 'failed indexed', 'updated indices' ]; $rows = [ [ $this->counter['indexed'], $this->counter['failed_url'], $this->counter['empty_url'], $this->counter['failed_index'], $this->counter['updated'] ] ]; $this->table($headers, $rows); } protected function cleanContent($content) { return strip_tags(preg_replace('/[\x00-\x1F\x80-\xFF]/', '', utf8_encode($content))); } protected function logDebugInfo($message, $data = null) { if (is_null($data)) { $data = []; } elseif (!is_array($data)) { $data = ['error' => $data]; } \Log::debug($message, $data); } }
behzadsh/falcon-search
app/Console/Commands/Crawl/ProcessNodes.php
PHP
mit
9,309
<!DOCTYPE html> <html lang="en"> <head> {% load static %} <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Pluricentric Global WordNet</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script> <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Raleway" /> <link href="https://fonts.googleapis.com/css?family=Fira+Sans:400,700" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link rel="stylesheet" href='{% static "style.css" %}'> <script src='{% static "language.js" %}'></script> <script src='{% static "index.js" %}'></script> </head> <body> <div class="container"> <div class="topRight"> <a href="#" id="references"> <i class="material-icons md-36">import_contacts</i> </a> <a href="https://github.com/nlx-group/LX-WordNetBrowser" target="_blank"> <i class="material-icons md-36">file_download</i> </a> </div> <header class="topHeader topHeaderContainer" id="header"> <div class="btn-group middle" role="group"> <span class="clickable English language">English</span> | <span class="clickable Portuguese language">Português</span> | <span class="clickable French language">Français</span> | <span class="clickable Chinese language">官话</span> | ... <div class="dropdown dropdown-sm" id="langSelectParent"><button class="btn btn-default btn-xs dropdown-toggle" type="button" id="langSelectBox" data-tool-tip="tooltip" data-placement='right' data-toggle="dropdown" aria-expanded="false"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span></button> <div class="dropdown-menu invis"> <form class="form-horizontal" role="form"> <select id="langSelectList"></select> </form> </div> </div> </div> <div> <img src="/static/assets/images/header.png" height="220px" width="520px" class="headerImage"> </div> </header> <div class="row vertical-center-row"> <div id="langListTarget" class="col-md-12"> <div class="input-group" id="adv-search"> <input type="text" class="form-control" id="searchInput"/> <div class="input-group-btn"> <div class="btn-group" role="group"> <div class="dropdown dropdown-lg" id="parent-dropdown"> <button type="button" id="normal-search" data-tool-tip="tooltip" class="btn btn-primary"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button> <button id="globe" type="button" class="btn btn-default dropdown-toggle" data-tool-tip="tooltip" id="parentdropdown" data-toggle="dropdown" aria-expanded="false"><img src="/static/assets/images/globe.png"></button> <div class="dropdown-menu dropdown-menu-right" role="menu"> <form class="form-horizontal" role="form"> <div class="form-group"> <label id="formLabel"></label> <select class="langmenu" multiple="multiple"> </select> </div> </form> </div> </div> </div> </div> </div> </div> </div> </div> </body> </html>
nlx-group/LX-WordNetBrowser
pluricentric/templates/index.html
HTML
mit
4,415
import { computed, defineProperty, get, set, tagForProperty, tracked, track, notifyPropertyChange, } from '../..'; import { EMBER_METAL_TRACKED_PROPERTIES, EMBER_NATIVE_DECORATOR_SUPPORT, } from '@ember/canary-features'; import { EMBER_ARRAY } from '@ember/-internals/utils'; import { AbstractTestCase, moduleFor } from 'internal-test-helpers'; if (EMBER_METAL_TRACKED_PROPERTIES && EMBER_NATIVE_DECORATOR_SUPPORT) { moduleFor( '@tracked get validation', class extends AbstractTestCase { [`@test autotracking should work with tracked fields`](assert) { class Tracked { @tracked first = undefined; constructor(first) { this.first = first; } } let obj = new Tracked('Tom', 'Dale'); let tag = track(() => obj.first); let snapshot = tag.value(); assert.equal(obj.first, 'Tom', 'The full name starts correct'); assert.equal(tag.validate(snapshot), true); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); obj.first = 'Thomas'; assert.equal(tag.validate(snapshot), false); assert.equal(obj.first, 'Thomas'); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); } [`@test autotracking should work with native getters`](assert) { class Tracked { @tracked first = undefined; @tracked last = undefined; constructor(first, last) { this.first = first; this.last = last; } get full() { return `${this.first} ${this.last}`; } } let obj = new Tracked('Tom', 'Dale'); let tag = track(() => obj.full); let snapshot = tag.value(); assert.equal(obj.full, 'Tom Dale', 'The full name starts correct'); assert.equal(tag.validate(snapshot), true); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); obj.first = 'Thomas'; assert.equal(tag.validate(snapshot), false); assert.equal(obj.full, 'Thomas Dale'); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); } [`@test autotracking should work with native setters`](assert) { class Tracked { @tracked first = undefined; @tracked last = undefined; constructor(first, last) { this.first = first; this.last = last; } get full() { return `${this.first} ${this.last}`; } set full(value) { let [first, last] = value.split(' '); this.first = first; this.last = last; } } let obj = new Tracked('Tom', 'Dale'); let tag = track(() => obj.full); let snapshot = tag.value(); assert.equal(obj.full, 'Tom Dale', 'The full name starts correct'); assert.equal(tag.validate(snapshot), true); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); obj.full = 'Melanie Sumner'; assert.equal(tag.validate(snapshot), false); assert.equal(obj.full, 'Melanie Sumner'); assert.equal(obj.first, 'Melanie'); assert.equal(obj.last, 'Sumner'); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); } [`@test interaction with Ember object model (tracked property depending on Ember property)`]( assert ) { class Tracked { constructor(name) { this.name = name; } get full() { return `${get(this, 'name.first')} ${get(this, 'name.last')}`; } } let tom = { first: 'Tom', last: 'Dale' }; let obj = new Tracked(tom); let tag = track(() => obj.full); let snapshot = tag.value(); assert.equal(obj.full, 'Tom Dale'); assert.equal(tag.validate(snapshot), true); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); set(tom, 'first', 'Thomas'); assert.equal(tag.validate(snapshot), false, 'invalid after setting with Ember set'); assert.equal(obj.full, 'Thomas Dale'); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); set(obj, 'name', { first: 'Ricardo', last: 'Mendes' }); assert.equal(tag.validate(snapshot), false, 'invalid after setting with Ember set'); assert.equal(obj.full, 'Ricardo Mendes'); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); } [`@test interaction with Ember object model (Ember computed property depending on tracked property)`]( assert ) { class EmberObject { constructor(name) { this.name = name; } } defineProperty( EmberObject.prototype, 'full', computed('name.first', 'name.last', function() { let name = get(this, 'name'); return `${name.first} ${name.last}`; }) ); class Name { @tracked first; @tracked last; constructor(first, last) { this.first = first; this.last = last; } } let tom = new Name('Tom', 'Dale'); let obj = new EmberObject(tom); let tag = tagForProperty(obj, 'full'); let snapshot = tag.value(); let full = get(obj, 'full'); assert.equal(full, 'Tom Dale'); assert.equal(tag.validate(snapshot), true); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); tom.first = 'Thomas'; assert.equal( tag.validate(snapshot), false, 'invalid after setting with tracked properties' ); assert.equal(get(obj, 'full'), 'Thomas Dale'); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); } ['@test interaction with the Ember object model (paths going through tracked properties)']( assert ) { let self; class EmberObject { contact; constructor(contact) { this.contact = contact; self = this; } } defineProperty( EmberObject.prototype, 'full', computed('contact.name.first', 'contact.name.last', function() { let contact = get(self, 'contact'); return `${get(contact.name, 'first')} ${get(contact.name, 'last')}`; }) ); class Contact { @tracked name = undefined; constructor(name) { this.name = name; } } class EmberName { first; last; constructor(first, last) { this.first = first; this.last = last; } } let tom = new EmberName('Tom', 'Dale'); let contact = new Contact(tom); let obj = new EmberObject(contact); let tag = tagForProperty(obj, 'full'); let snapshot = tag.value(); let full = get(obj, 'full'); assert.equal(full, 'Tom Dale'); assert.equal(tag.validate(snapshot), true); snapshot = tag.value(); assert.equal(tag.validate(snapshot), true); set(tom, 'first', 'Thomas'); assert.equal(tag.validate(snapshot), false, 'invalid after setting with Ember.set'); assert.equal(get(obj, 'full'), 'Thomas Dale'); snapshot = tag.value(); tom = contact.name = new EmberName('T', 'Dale'); assert.equal(tag.validate(snapshot), false, 'invalid after setting with Ember.set'); assert.equal(get(obj, 'full'), 'T Dale'); snapshot = tag.value(); set(tom, 'first', 'Tizzle'); assert.equal(tag.validate(snapshot), false, 'invalid after setting with Ember.set'); assert.equal(get(obj, 'full'), 'Tizzle Dale'); } ['@test interaction with arrays'](assert) { class EmberObject { @tracked array = []; } let obj = new EmberObject(); let tag = tagForProperty(obj, 'array'); let snapshot = tag.value(); let array = get(obj, 'array'); assert.deepEqual(array, []); assert.equal(tag.validate(snapshot), true); array.push(1); notifyPropertyChange(array, '[]'); assert.equal( tag.validate(snapshot), false, 'invalid after pushing an object and notifying on the array' ); } ['@test interaction with ember arrays'](assert) { class EmberObject { @tracked emberArray = { [EMBER_ARRAY]: true, }; } let obj = new EmberObject(); let tag = tagForProperty(obj, 'emberArray'); let snapshot = tag.value(); let emberArray = get(obj, 'emberArray'); assert.equal(tag.validate(snapshot), true); notifyPropertyChange(emberArray, '[]'); assert.equal( tag.validate(snapshot), false, 'invalid after setting a property on the object' ); } } ); }
cibernox/ember.js
packages/@ember/-internals/metal/tests/tracked/validation_test.js
JavaScript
mit
9,317
<?php namespace BitOasis\Coin\Address; /** * @author David Fiedor <[email protected]> */ class YearnFinanceAddress extends EthereumAddress { }
bit-oasis/coin
src/BitOasis/Coin/Address/YearnFinanceAddress.php
PHP
mit
146
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>mathcomp-multinomials: 1 m 12 s 🏆</title> <link rel="shortcut icon" type="image/png" href="../../../../../favicon.png" /> <link href="../../../../../bootstrap.min.css" rel="stylesheet"> <link href="../../../../../bootstrap-custom.css" rel="stylesheet"> <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"> <script src="../../../../../moment.min.js"></script> <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="container"> <div class="navbar navbar-default" role="navigation"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="../../../../.."><i class="fa fa-lg fa-flag-checkered"></i> Coq bench</a> </div> <div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li><a href="../..">clean / released</a></li> <li class="active"><a href="">8.7.1+2 / mathcomp-multinomials - 1.4</a></li> </ul> </div> </div> </div> <div class="article"> <div class="row"> <div class="col-md-12"> <a href="../..">« Up</a> <h1> mathcomp-multinomials <small> 1.4 <span class="label label-success">1 m 12 s 🏆</span> </small> </h1> <p>📅 <em><script>document.write(moment("2021-10-22 02:42:01 +0000", "YYYY-MM-DD HH:mm:ss Z").fromNow());</script> (2021-10-22 02:42:01 UTC)</em><p> <h2>Context</h2> <pre># Packages matching: installed # Name # Installed # Synopsis base-bigarray base base-num base Num library distributed with the OCaml compiler base-threads base base-unix base camlp5 7.14 Preprocessor-pretty-printer of OCaml conf-findutils 1 Virtual package relying on findutils conf-perl 1 Virtual package relying on perl coq 8.7.1+2 Formal proof management system num 0 The Num library for arbitrary-precision integer and rational arithmetic ocaml 4.04.2 The OCaml compiler (virtual package) ocaml-base-compiler 4.04.2 Official 4.04.2 release ocaml-config 1 OCaml Switch Configuration ocamlfind 1.9.1 A library manager for OCaml # opam file: opam-version: &quot;2.0&quot; name: &quot;coq-mathcomp-multinomials&quot; maintainer: &quot;[email protected]&quot; homepage: &quot;https://github.com/math-comp/multinomials&quot; bug-reports: &quot;https://github.com/math-comp/multinomials/issues&quot; dev-repo: &quot;git+https://github.com/math-comp/multinomials.git&quot; license: &quot;CeCILL-B&quot; authors: [&quot;Pierre-Yves Strub&quot;] build: [ [make &quot;INSTMODE=global&quot; &quot;config&quot;] [make &quot;-j%{jobs}%&quot;] ] install: [ [make &quot;install&quot;] ] depends: [ &quot;coq&quot; {&gt;= &quot;8.7&quot; &amp; &lt; &quot;8.12~&quot;} &quot;coq-mathcomp-ssreflect&quot; {(&gt;= &quot;1.8.0&quot; &amp; &lt; &quot;1.11~&quot;)} &quot;coq-mathcomp-algebra&quot; &quot;coq-mathcomp-bigenough&quot; {&gt;= &quot;1.0.0&quot; &amp; &lt; &quot;1.1~&quot;} &quot;coq-mathcomp-finmap&quot; {&gt;= &quot;1.3.4&quot; &amp; &lt; &quot;1.4~&quot;} ] tags: [ &quot;keyword:multinomials&quot; &quot;keyword:monoid algebra&quot; &quot;category:Math/Algebra/Multinomials&quot; &quot;category:Math/Algebra/Monoid algebra&quot; &quot;date:2019-11-28&quot; &quot;logpath:SsrMultinomials&quot; ] synopsis: &quot;A Multivariate polynomial Library for the Mathematical Components Library&quot; url { src: &quot;https://github.com/math-comp/multinomials/archive/1.4.tar.gz&quot; checksum: &quot;sha512=b8c4f750063b8764275ea3b0ca12b2bbc16d1c52c5b10bd71ef6d6bb0791ecfb1115681c4379ffe286ab8c550c1965ba08cd2c3a1e5600d8b1a17dee627e2aae&quot; } </pre> <h2>Lint</h2> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>true</code></dd> <dt>Return code</dt> <dd>0</dd> </dl> <h2>Dry install 🏜️</h2> <p>Dry install with the current Coq version:</p> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>opam install -y --show-action coq-mathcomp-multinomials.1.4 coq.8.7.1+2</code></dd> <dt>Return code</dt> <dd>0</dd> </dl> <p>Dry install without Coq/switch base, to test if the problem was incompatibility with the current Coq/OCaml version:</p> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>true</code></dd> <dt>Return code</dt> <dd>0</dd> </dl> <h2>Install dependencies</h2> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>opam list; echo; ulimit -Sv 4000000; timeout 4h opam install -y --deps-only coq-mathcomp-multinomials.1.4 coq.8.7.1+2</code></dd> <dt>Return code</dt> <dd>0</dd> <dt>Duration</dt> <dd>8 m 30 s</dd> </dl> <h2>Install 🚀</h2> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>opam list; echo; ulimit -Sv 16000000; timeout 4h opam install -y -v coq-mathcomp-multinomials.1.4 coq.8.7.1+2</code></dd> <dt>Return code</dt> <dd>0</dd> <dt>Duration</dt> <dd>1 m 12 s</dd> </dl> <h2>Installation size</h2> <p>Total: 6 M</p> <ul> <li>2 M <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/mpoly.vo</code></li> <li>1 M <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/mpoly.glob</code></li> <li>511 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/monalg.vo</code></li> <li>419 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/monalg.glob</code></li> <li>386 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/freeg.vo</code></li> <li>374 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/freeg.glob</code></li> <li>184 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/mpoly.v</code></li> <li>135 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/ssrcomplements.vo</code></li> <li>120 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/ssrcomplements.glob</code></li> <li>64 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/monalg.v</code></li> <li>48 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/freeg.v</code></li> <li>36 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/xfinmap.vo</code></li> <li>14 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/ssrcomplements.v</code></li> <li>4 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/xfinmap.glob</code></li> <li>1 K <code>../ocaml-base-compiler.4.04.2/lib/coq/user-contrib/SsrMultinomials/xfinmap.v</code></li> </ul> <h2>Uninstall 🧹</h2> <dl class="dl-horizontal"> <dt>Command</dt> <dd><code>opam remove -y coq-mathcomp-multinomials.1.4</code></dd> <dt>Return code</dt> <dd>0</dd> <dt>Missing removes</dt> <dd> none </dd> <dt>Wrong removes</dt> <dd> none </dd> </dl> </div> </div> </div> <hr/> <div class="footer"> <p class="text-center"> Sources are on <a href="https://github.com/coq-bench">GitHub</a> © Guillaume Claret 🐣 </p> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="../../../../../bootstrap.min.js"></script> </body> </html>
coq-bench/coq-bench.github.io
clean/Linux-x86_64-4.04.2-2.0.5/released/8.7.1+2/mathcomp-multinomials/1.4.html
HTML
mit
9,006
--- title: "Creating the RPG Encounter Flow" date: "2017-12-20" image: creating-the-adventure-12.png series: creating-an-adventure series_weight: 12 weight: 12 --- The first One Shot RPG is structured similar to the plot of a sci-fi horror movie. Each encounter should reveal something about the monster, and the adventure concludes with a showdown against the scummed.<!--more--> Writing a full-length RPG campaign is like writing a TV show. Each adventure---episode---has time to tell its own story while adding to the overall narrative. The campaign’s story unfolds over the course of multiple game sessions, and the plot points that have been building---expertly placed by the GM---pay off. But, I argue that the [game group doesn’t have a lot of motivation to stay together](/blog/creating-the-setting/justification-for-one-shot-rpg/#the-issue-of-organizing-a-group), so a slow build-up of plot elements wouldn’t have time to pan out. That’s why I’m focusing on one shots instead of full campaigns. While writing an RPG campaign is like writing a show, writing a One Shot RPG is like writing a sci-fi horror _movie_. The full plot, setting, and characters have to be introduced and satisfyingly concluded in one session---there is no sequel or next episode. That means I have to carefully think of how the encounters will flow together. ## What is an encounter flow? The encounter flow is the order and pacing in which different encounters---scenes---play out in the one shot. Encounter A leads into B, leads into C, then culminates in D. Each encounter [serves a purpose](/blog/creating-an-adventure/adventure-parts/#rpg-encounters), namely revealing something about the plot and moving the characters further along it. ## Goals It’s important to reiterate some goals when planning the encounter flow. The first is that the encounters should establish a [sci-fi horror atmosphere](/blog/creating-an-adventure/goals-for-a-one-shot/#the-goals-for-an-rpg-one-shot). The RPG one shot is about taking down a monster who has dangerous, unexplainable powers, so it should have some elements of a monster movie. Another goal is that because the session should be kept under 2 hours, each encounter must provide storytelling through other means than GM narration or dialogue. The scummed’s motivations and background should be revealed by what she’s doing, how she does it, and to whom, rather than her telling the party her master plan. ## Initial Thoughts I have some initial thoughts before I do any further planning. The first One Shot RPG should start [_in media res_](http://tvtropes.org/pmwiki/pmwiki.php/Main/InMediasRes), or in the middle of the action. I want to start off with the characters already having suspected a scummed, broken into the facility, and encountering the first victims. Later one shots can play with how the adventure starts, but I want this one to start with action. Next I’m planning on having five steps to the story. The first and last step will be constant, while the remaining three will have two different encounter options. This means that I’ll be creating 8 different encounters. ## The Steps 1. In media res 1. First glimpse of monster 1. Trapped, chase scene 1. Breather, get upper hand 1. Confront scummed ### In Media Res The party will start already have broken into the facility---or they even walked right through the front door. This encounter will take place in one of the farm’s [administration offices](/blog/creating-an-adventure/animal-processes-farm/#admin), which is the first target the scummed strikes. Players will see first-hand that they’re dealing with a scummed with plant powers who has a personal grudge against the farm and its workers. They’ll see workers writhing in agony as the plant parasite bursts forth from their skin. They’ll see computers broken and files scattered. They’ll also notice their [AI chips](/blog/creating-the-characters/ai-and-internet/) are on the fritz and there’s disruption with their communication with the outside world. There’s no doubt that the [scum fighters](/blog/creating-the-setting/expanding-upon-scum-and-horror/#scum-fighters) are going to be fighting a scummed at this farm. ### First Glimpse of Monster The next encounter fulfills two purposes: exploring the setting and giving the party the first glimpse at the monster. The encounter will take place in one of the many [farm facilities](/blog/creating-an-adventure/plant-processes-farm/) outlined. It will show the party what type of location this place is and what it’s supposed to be doing when it’s not taken over by a scummed. The main conflict during this encounter is not with the monster, but something else relating to the location, such as the reprogrammed robots or security forces hired by the company. Though the main conflict is with another faction, the encounter still must reveal something about the scummed, such as her abilities, motivation, or background. When the conflict is over, the monster bursts into the scene, ushering the party into the next encounter. ### Trapped The party is not ready to confront the scummed, they don’t know enough about her to stand a chance, so they must run, or escape. This is a classic horror trope, the characters trying to get to a safe area as the monster pursues them. Characters do things like barricade doors or hide in closets until the monster turns around and shambles off. The party must use this time to figure out what they’re dealing with. The characters can also find a clue as to the scummed’s motivations during all of the commotion. ### Breather, Get Upper Hand After two back-to-back encounters, and the final confrontation looming, it’s time to give the characters a breather. They’ll be able to slowly explore a facility, looking for a way to gain an upper hand against the monster. The facility can offer unexpected allies or more clues to how to deal with the scummed. Ultimately, by the time they’re ready to move on, the players should have a clear understand of _why_ the scummed is doing what she’s doing, and that’s she’s not just an evil monster, but a person who’s hurt. ### Final Confrontation The characters get to choose when they want to confront the scummed. They should have enough information by now to make the decision: kill, cure, or let the scummed be. Every encounter before this one should have been preparing the players for this moment. If the encounters are designed successfully, the players should know enough to stand a chance against the scummed---although that doesn’t mean they’re guaranteed to win. Their final decision should provide the group with a satisfying conclusion to the story, and they should feel like they have just finished a fun and well-paced sci-fi horror movie. With the overall pacing and encounter flow decided, it’s time to define the specific encounter options.
oneshotrpg/oneshotrpg
content/blog/creating-an-adventure/rpg-encounter-flow/index.md
Markdown
mit
6,922
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Chatter</title> <link rel="stylesheet" type="text/css" href="js/vendor/angular-material/angular-material.css"> </head> <body> <script type="text/javascript" src="js/vendor/requirejs/require.js" data-main="js/app/boot"></script> </body> </html>
dimpu/Angular-Material-Chatter
source/index.html
HTML
mit
321
.idTabs .navs { padding:5px; margin: 10px; width:auto; height:auto; overflow:hidden;background:#DEEAF7; height:25px; } .navs li { list-style:none; float:left; width:100px; height:25px; overflow:hidden; } .navs li a{ background:url(../../templates/admin/images/idTabs_nav1.png) no-repeat; display:block; width:100px; height:25px; overflow:hidden; text-align:center; line-height:25px;} .idTabs .navs li a.selected { color:#000;background:url(../../templates/admin/images/idTabs_nav2.png) no-repeat;} .items>div { display:none; clear: both; margin:0.1em 0 0 0.5em; } /* Moz border */ .idTabs .navs ul, .idTabs .navs li a { border-radius:4px; -moz-border-radius:4px; }
kinglion/tttuangou
static/css/jquery.idTabs.css
CSS
mit
666
<?php require_once("support/config.php"); if(!isLoggedIn()){ toLogin(); die(); } if(!AllowUser(array(1))){ redirect("index.php"); } if(!empty($_GET['id'])){ $account=$con->myQuery("SELECT assigned_to, fname, lname, department_id, org_id, home_phone, mobile_phone, office_phone, email, dob, description, profile_pic, id FROM contacts WHERE id=?",array($_GET['id']))->fetch(PDO::FETCH_ASSOC); $assigned_value=$con->myQuery("SELECT id, CONCAT(first_name,' ',middle_name,' ',last_name) as name FROM users WHERE id=?",array($account['assigned_to']))->fetch(PDO::FETCH_ASSOC); $dept_value=$con->myQuery("SELECT id, name FROM departments WHERE id=?",array($account['department_id']))->fetch(PDO::FETCH_ASSOC); $org_value=$con->myQuery("SELECT id, org_name FROM organizations WHERE id=?",array($account['org_id']))->fetch(PDO::FETCH_ASSOC); //$assigned_value=$con->myQuery("SELECT id, CONCAT(first_name,' ',middle_name,' ',last_name) as name FROM users where is_deleted=0 and id=?",array($_GET['id']))->fetchAll(PDO::FETCH_ASSOC); if(empty($account)){ //Alert("Invalid asset selected."); Modal("Invalid Account Selected"); redirect("contacts.php"); die(); } } $assigned=$con->myQuery("SELECT id, CONCAT(first_name,' ',middle_name,' ',last_name) as name FROM users where is_deleted=0")->fetchAll(PDO::FETCH_ASSOC); $dep=$con->myQuery("SELECT id, name FROM departments where is_deleted=0")->fetchAll(PDO::FETCH_ASSOC); $org=$con->myQuery("SELECT id, org_name FROM organizations where is_deleted=0")->fetchAll(PDO::FETCH_ASSOC); $user=$con->myQuery("SELECT id, CONCAT(last_name,' ',first_name,' ',middle_name) as name FROM users")->fetchAll(PDO::FETCH_ASSOC); makeHead("Contacts"); ?> <?php require_once("template/header.php"); require_once("template/sidebar.php"); ?> <div class="content-wrapper"> <!-- Content Header (Page header) --> <section class="content-header"> <h1> Create New Contact </h1> </section> <!-- Main content --> <section class="content"> <!-- Main row --> <div class="row"> <div class='col-md-10 col-md-offset-1'> <?php Alert(); ?> <div class="box box-primary"> <div class="box-body"> <div class="row"> <div class='col-sm-12 col-md-8 col-md-offset-2'> <form class='form-horizontal' method='POST' action='save_contact.php'> <input type='hidden' name='id' value='<?php echo !empty($account)?$account['id']:""?>'> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> </label> <div class='col-sm-12 col-md-9'> <img src='uploads/<?php echo !empty($account['profile_pic'])?$account['profile_pic']:"Default.jpg"?>' class='img-responsive' width='100px' height='100px'> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Photo Upload</label> <div class='col-sm-12 col-md-9'> <input type='file' class='form-control' name='file' > </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Creator</label> <div class='col-sm-12 col-md-9'> <select class='form-control' name='assigned_to' data-placeholder="Select assigned user" <?php echo!(empty($assigned))?"data-selected='".$assigned['id']."'":NULL ?>> <option value='<?php echo !empty($account)?$account['assigned_to']:""?>'><?php echo !empty($assigned_value)?$assigned_value['name']:""?></option> <?php echo makeOptions($assigned); ?> </select> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> First Name*</label> <div class='col-sm-12 col-md-9'> <input type='text' class='form-control' name='fname' placeholder='Enter First Name' value='<?php echo !empty($account)?$account['fname']:"" ?>' required> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Last Name*</label> <div class='col-sm-12 col-md-9'> <input type='text' class='form-control' name='lname' placeholder='Enter Last Name' value='<?php echo !empty($account)?$account['lname']:"" ?>' required> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Department*</label> <div class='col-sm-12 col-md-9'> <select class='form-control' name='department_id' data-placeholder="Select department" <?php echo!(empty($dep))?"data-selected='".$dep['id']."'":NULL ?> required> <option value='<?php echo !empty($account)?$account['department_id']:""?>'><?php echo !empty($dept_value)?$dept_value['name']:""?></option> <?php echo makeOptions($dep); ?> </select> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Company*</label> <div class='col-sm-12 col-md-9'> <select class='form-control' name='org_id' data-placeholder="Select organization" <?php echo!(empty($org))?"data-selected='".$org['org_id']."'":NULL ?>> <option value='<?php echo !empty($account)?$account['org_id']:""?>'><?php echo !empty($dept_value)?$org_value['org_name']:""?></option required> <?php echo makeOptions($org); ?> </select> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Home Phone</label> <div class='col-sm-12 col-md-9'> <input type='text' class='form-control' name='home_phone' placeholder='Enter Home Phone' value='<?php echo !empty($account)?$account['home_phone']:"" ?>'> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Mobile Phone*</label> <div class='col-sm-12 col-md-9'> <input type='text' class='form-control' name='mobile_phone' placeholder='Enter Mobile Phone' value='<?php echo !empty($account)?$account['mobile_phone']:"" ?>' required> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Office Phone</label> <div class='col-sm-12 col-md-9'> <input type='text' class='form-control' name='office_phone' placeholder='Enter Office Phone' value='<?php echo !empty($account)?$account['office_phone']:"" ?>' > </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Email*</label> <div class='col-sm-12 col-md-9'> <input type='text' class='form-control' name='email' placeholder='Enter Email Address' value='<?php echo !empty($account)?$account['email']:"" ?>' required> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Date of Birth*</label> <div class='col-sm-12 col-md-9'> <?php $start_date=""; if(!empty($maintenance)){ $start_date=$maintenance['start_date']; if($start_date=="0000-00-00"){ $start_date=""; } } ?> <input type='date' class='form-control' name='dob' value='<?php echo !empty($account)?$account['dob']:"" ?>' required> </div> </div> <div class='form-group'> <label class='col-sm-12 col-md-3 control-label'> Description</label> <div class='col-sm-12 col-md-9'> <textarea class='form-control' name='description' placeholder="Write a short description."><?php echo !empty($account)?$account['description']:"" ?></textarea> </div> </div> <div class='form-group'> <div class='col-sm-12 col-md-9 col-md-offset-3 '> <a href='contacts.php' class='btn btn-default'>Cancel</a> <button type='submit' class='btn btn-brand'> <span class='fa fa-check'></span> Save</button> </div> </div> </form> </div> </div><!-- /.row --> </div><!-- /.box-body --> </div><!-- /.box --> </div> </div><!-- /.row --> </section><!-- /.content --> </div> <script type="text/javascript"> $(function () { $('#ResultTable').DataTable(); }); </script> <?php makeFoot(); ?>
sgtsi-jenny/crmv2
frm_contacts.php
PHP
mit
12,145
#!/bin/sh # CYBERWATCH SAS - 2017 # # Security fix for USN-2161-1 # # Security announcement date: 2014-04-03 00:00:00 UTC # Script generation date: 2017-01-01 21:03:45 UTC # # Operating System: Ubuntu 12.04 LTS # Architecture: i386 # # Vulnerable packages fix on version: # - libyaml-libyaml-perl:0.38-2ubuntu0.1 # # Last versions recommanded by security team: # - libyaml-libyaml-perl:0.38-2ubuntu0.2 # # CVE List: # - CVE-2013-6393 # - CVE-2014-2525 # # More details: # - https://www.cyberwatch.fr/vulnerabilites # # Licence: Released under The MIT License (MIT), See LICENSE FILE sudo apt-get install --only-upgrade libyaml-libyaml-perl=0.38-2ubuntu0.2 -y
Cyberwatch/cbw-security-fixes
Ubuntu_12.04_LTS/i386/2014/USN-2161-1.sh
Shell
mit
673
/*--------------------------------------------------------------------------*\ | | | Copyright (C) 2016 | | | | , __ , __ | | /|/ \ /|/ \ | | | __/ _ ,_ | __/ _ ,_ | | | \|/ / | | | | \|/ / | | | | | |(__/|__/ |_/ \_/|/|(__/|__/ |_/ \_/|/ | | /| /| | | \| \| | | | | Enrico Bertolazzi | | Dipartimento di Ingegneria Industriale | | Universita` degli Studi di Trento | | email: [email protected] | | | \*--------------------------------------------------------------------------*/ /****************************************************************************\ Copyright (c) 2016, Enrico Bertolazzi All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions 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. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. \****************************************************************************/ #ifndef SPLINES_HH #define SPLINES_HH // Uncomment this if you do not want that Splines uses GenericContainer #define SPLINES_DO_NOT_USE_GENERIC_CONTAINER 1 // some one may force the use of GenericContainer #ifndef SPLINES_DO_NOT_USE_GENERIC_CONTAINER #include "GenericContainer.hh" #endif #include <iostream> #include <fstream> #include <vector> #include <map> #include <utility> // std::pair #include <algorithm> // // file: Splines // // if C++ < C++11 define nullptr #if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) #if _MSC_VER >= 1900 #ifndef DO_NOT_USE_CXX11 #define SPLINES_USE_CXX11 #endif #else #include <cstdlib> #ifndef nullptr #include <cstddef> #define nullptr NULL #endif #endif #ifdef _MSC_VER #include <math.h> #endif #else #if __cplusplus > 199711L #ifndef DO_NOT_USE_CXX11 #define SPLINES_USE_CXX11 #endif #else #include <cstdlib> #ifndef nullptr #include <cstddef> #define nullptr NULL #endif #endif #endif #ifndef SPLINE_ASSERT #include <stdexcept> #include <sstream> #define SPLINE_ASSERT(COND,MSG) \ if ( !(COND) ) { \ std::ostringstream ost ; \ ost << "In spline: " << name() \ << " line: " << __LINE__ \ << " file: " << __FILE__ \ << '\n' << MSG << '\n' ; \ throw std::runtime_error(ost.str()) ; \ } #endif #ifndef SPLINE_WARNING #include <stdexcept> #include <sstream> #define SPLINE_WARNING(COND,MSG) \ if ( !(COND) ) { \ std::cout << "In spline: " << name() \ << " line: " << __LINE__ \ << " file: " << __FILE__ \ << MSG << '\n' ; \ } #endif #ifdef DEBUG #define SPLINE_CHECK_NAN( PTR, MSG, DIM ) Splines::checkNaN( PTR, MSG, DIM ) #else #define SPLINE_CHECK_NAN( PTR, MSG, DIM ) #endif #ifdef __GCC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpadded" #pragma GCC diagnostic ignored "-Wc++98-compat" #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wc++98-compat" #endif //! Various kind of splines namespace Splines { using namespace ::std ; // load standard namespace typedef double valueType ; //!< Floating point type for splines typedef unsigned sizeType ; //!< Unsigned integer type for splines typedef int indexType ; //!< Signed integer type for splines //! Associate a number for each type of splines implemented typedef enum { CONSTANT_TYPE = 0, LINEAR_TYPE = 1, CUBIC_TYPE = 2, AKIMA_TYPE = 3, BESSEL_TYPE = 4, PCHIP_TYPE = 5, QUINTIC_TYPE = 6, HERMITE_TYPE = 7, SPLINE_SET_TYPE = 8, BSPLINE_TYPE = 9 } SplineType ; extern char const *spline_type[] ; extern SplineType string_to_splineType( std::string const & n ) ; #ifndef SPLINES_DO_NOT_USE_GENERIC_CONTAINER using GenericContainerNamespace::GenericContainer ; using GenericContainerNamespace::vec_real_type ; using GenericContainerNamespace::vec_string_type ; using GenericContainerNamespace::vector_type ; using GenericContainerNamespace::map_type ; #endif pair<int,int> quadraticRoots( valueType const a[3], valueType real[2], valueType imag[2] ) ; pair<int,int> cubicRoots( valueType const a[4], valueType real[3], valueType imag[3] ) ; /* _ _ _ _ _ _ // ___| |__ ___ ___| | _| \ | | __ _| \ | | // / __| '_ \ / _ \/ __| |/ / \| |/ _` | \| | // | (__| | | | __/ (__| <| |\ | (_| | |\ | // \___|_| |_|\___|\___|_|\_\_| \_|\__,_|_| \_| */ void checkNaN( valueType const pv[], char const v_name[], sizeType const DIM ) ; /* // _ _ _ _ // | | | | ___ _ __ _ __ ___ (_) |_ ___ // | |_| |/ _ \ '__| '_ ` _ \| | __/ _ \ // | _ | __/ | | | | | | | | || __/ // |_| |_|\___|_| |_| |_| |_|_|\__\___| */ void Hermite3 ( valueType const x, valueType const H, valueType base[4] ) ; void Hermite3_D ( valueType const x, valueType const H, valueType base_D[4] ) ; void Hermite3_DD ( valueType const x, valueType const H, valueType base_DD[4] ) ; void Hermite3_DDD( valueType const x, valueType const H, valueType base_DDD[4] ) ; void Hermite5 ( valueType const x, valueType const H, valueType base[6] ) ; void Hermite5_D ( valueType const x, valueType const H, valueType base_D[6] ) ; void Hermite5_DD ( valueType const x, valueType const H, valueType base_DD[6] ) ; void Hermite5_DDD ( valueType const x, valueType const H, valueType base_DDD[6] ) ; void Hermite5_DDDD ( valueType const x, valueType const H, valueType base_DDDD[6] ) ; void Hermite5_DDDDD( valueType const x, valueType const H, valueType base_DDDDD[6] ) ; /* // ____ _ _ _ // | __ )(_) (_)_ __ ___ __ _ _ __ // | _ \| | | | '_ \ / _ \/ _` | '__| // | |_) | | | | | | | __/ (_| | | // |____/|_|_|_|_| |_|\___|\__,_|_| */ valueType bilinear3( valueType const p[4], valueType const M[4][4], valueType const q[4] ) ; valueType bilinear5( valueType const p[6], valueType const M[6][6], valueType const q[6] ) ; //! Check if cubic spline with this data is monotone, -1 no, 0 yes, 1 strictly monotone indexType checkCubicSplineMonotonicity( valueType const X[], valueType const Y[], valueType const Yp[], sizeType npts ) ; void updateInterval( sizeType & lastInterval, valueType x, valueType const X[], sizeType npts ) ; /* // __ __ _ _ // | \/ | __ _| | | ___ ___ // | |\/| |/ _` | | |/ _ \ / __| // | | | | (_| | | | (_) | (__ // |_| |_|\__,_|_|_|\___/ \___| */ //! Allocate memory template <typename T> class SplineMalloc { typedef T valueType ; typedef valueType* valuePointer ; typedef const valueType* valueConstPointer ; typedef valueType& valueReference ; typedef const valueType& valueConstReference ; typedef long indexType ; typedef indexType* indexPointer ; typedef const indexType* indexConstPointer ; typedef indexType& indexReference ; typedef const indexType& indexConstReference ; private: std::string _name ; size_t numTotValues ; size_t numTotReserved ; size_t numAllocated ; valuePointer pMalloc ; SplineMalloc(SplineMalloc<T> const &) ; // block copy constructor SplineMalloc<T> const & operator = (SplineMalloc<T> &) const ; // block copy constructor public: //! malloc object constructor explicit SplineMalloc( std::string const & __name ) : _name(__name) , numTotValues(0) , numTotReserved(0) , numAllocated(0) , pMalloc(nullptr) {} //! malloc object destructor ~SplineMalloc() { free() ; } //! allocate memory for `n` objects void allocate( size_t n ) { try { if ( n > numTotReserved ) { delete [] pMalloc ; numTotValues = n ; numTotReserved = n + (n>>3) ; // 12% more values pMalloc = new T[numTotReserved] ; } } catch ( std::exception const & exc ) { std::cerr << "Memory allocation failed: " << exc.what() << "\nTry to allocate " << n << " bytes for " << _name << '\n' ; exit(0) ; } catch (...) { std::cerr << "SplineMalloc allocation failed for " << _name << ": memory exausted\n" << "Requesting " << n << " blocks\n"; exit(0) ; } numTotValues = n ; numAllocated = 0 ; } //! free memory void free(void) { if ( pMalloc != 0 ) { delete [] pMalloc ; numTotValues = 0 ; numTotReserved = 0 ; numAllocated = 0 ; pMalloc = nullptr ; } } //! number of objects allocated indexType size(void) const { return numTotValues ; } //! get pointer of allocated memory for `sz` objets T * operator () ( size_t sz ) { size_t offs = numAllocated ; numAllocated += sz ; if ( numAllocated > numTotValues ) { std::ostringstream ost ; ost << "\nMalloc<" << _name << ">::operator () (" << sz << ") -- SplineMalloc EXAUSTED\n" << "request = " << numAllocated << " > " << numTotValues << " = available\n" ; throw std::runtime_error(ost.str()) ; } return pMalloc + offs ; } } ; /* // ____ _ _ // / ___| _ __ | (_)_ __ ___ // \___ \| '_ \| | | '_ \ / _ \ // ___) | |_) | | | | | | __/ // |____/| .__/|_|_|_| |_|\___| // |_| */ //! Spline Management Class class Spline { protected: string _name ; bool _check_range ; sizeType npts, npts_reserved ; valueType *X ; // allocated in the derived class! valueType *Y ; // allocated in the derived class! mutable sizeType lastInterval ; sizeType search( valueType x ) const { SPLINE_ASSERT( npts > 1, "\nsearch(" << x << ") empty spline"); if ( _check_range ) { valueType xl = X[0] ; valueType xr = X[npts-1] ; SPLINE_ASSERT( x >= xl && x <= xr, "method search( " << x << " ) out of range: [" << xl << ", " << xr << "]" ) ; } Splines::updateInterval( lastInterval, x, X, npts ) ; return lastInterval; } Spline(Spline const &) ; // block copy constructor Spline const & operator = (Spline const &) ; // block copy method public: //! spline constructor Spline( string const & name = "Spline", bool ck = false ) : _name(name) , _check_range(ck) , npts(0) , npts_reserved(0) , X(nullptr) , Y(nullptr) , lastInterval(0) {} //! spline destructor virtual ~Spline() {} string const & name() const { return _name ; } void setCheckRange( bool ck ) { _check_range = ck ; } bool getCheckRange() const { return _check_range ; } //! return the number of support points of the spline. sizeType numPoints(void) const { return npts ; } //! return the i-th node of the spline (x component). valueType xNode( sizeType i ) const { return X[i] ; } //! return the i-th node of the spline (y component). valueType yNode( sizeType i ) const { return Y[i] ; } //! return first node of the spline (x component). valueType xBegin() const { return X[0] ; } //! return first node of the spline (y component). valueType yBegin() const { return Y[0] ; } //! return last node of the spline (x component). valueType xEnd() const { return X[npts-1] ; } //! return last node of the spline (y component). valueType yEnd() const { return Y[npts-1] ; } //! Allocate memory for `npts` points virtual void reserve( sizeType npts ) = 0 ; //! Add a support point (x,y) to the spline. void pushBack( valueType x, valueType y ) ; //! Drop a support point to the spline. void dropBack() { if ( npts > 0 ) --npts ; } //! Build a spline. // must be defined in derived classes virtual void build (void) = 0 ; #ifndef SPLINES_DO_NOT_USE_GENERIC_CONTAINER virtual void setup ( GenericContainer const & gc ) ; void build ( GenericContainer const & gc ) { setup(gc) ; } #endif //! Build a spline. /*! * \param x vector of x-coordinates * \param incx access elements as x[0], x[incx], x[2*incx],... * \param y vector of y-coordinates * \param incy access elements as y[0], y[incy], x[2*incy],... * \param n total number of points */ // must be defined in derived classes virtual void build( valueType const x[], sizeType incx, valueType const y[], sizeType incy, sizeType n ) { reserve( n ) ; for ( sizeType i = 0 ; i < n ; ++i ) X[i] = x[i*incx] ; for ( sizeType i = 0 ; i < n ; ++i ) Y[i] = y[i*incy] ; npts = n ; build() ; } //! Build a spline. /*! * \param x vector of x-coordinates * \param y vector of y-coordinates * \param n total number of points */ inline void build( valueType const x[], valueType const y[], sizeType n ) { build( x, 1, y, 1, n ) ; } //! Build a spline. /*! * \param x vector of x-coordinates * \param y vector of y-coordinates */ inline void build ( vector<valueType> const & x, vector<valueType> const & y ) { sizeType N = sizeType(x.size()) ; if ( N > sizeType(y.size()) ) N = sizeType(y.size()) ; build( &x.front(), 1, &y.front(), 1, N ) ; } //! Cancel the support points, empty the spline. virtual void clear(void) = 0 ; //! return x-minumum spline value valueType xMin() const { return X[0] ; } //! return x-maximum spline value valueType xMax() const { return X[npts-1] ; } //! return y-minumum spline value valueType yMin() const { sizeType N = sizeType(npts) ; if ( type() == CONSTANT_TYPE ) --N ; return *std::min_element(Y,Y+N) ; } //! return y-maximum spline value valueType yMax() const { sizeType N = sizeType(npts) ; if ( type() == CONSTANT_TYPE ) --N ; return *std::max_element(Y,Y+N) ; } /////////////////////////////////////////////////////////////////////////// //! change X-origin of the spline void setOrigin( valueType x0 ) ; //! change X-range of the spline void setRange( valueType xmin, valueType xmax ) ; /////////////////////////////////////////////////////////////////////////// //! dump a sample of the spline void dump( ostream & s, sizeType nintervals, char const header[] = "x\ty" ) const ; void dump( char const fname[], sizeType nintervals, char const header[] = "x\ty" ) const { ofstream file(fname) ; dump( file, nintervals, header ) ; file.close() ; } /////////////////////////////////////////////////////////////////////////// //! Evaluate spline value virtual valueType operator () ( valueType x ) const = 0 ; //! First derivative virtual valueType D( valueType x ) const = 0 ; //! Second derivative virtual valueType DD( valueType x ) const = 0 ; //! Third derivative virtual valueType DDD( valueType x ) const = 0 ; //! Some aliases valueType eval( valueType x ) const { return (*this)(x) ; } valueType eval_D( valueType x ) const { return D(x) ; } valueType eval_DD( valueType x ) const { return DD(x) ; } valueType eval_DDD( valueType x ) const { return DDD(x) ; } //! get the piecewise polinomials of the spline virtual sizeType // order coeffs( valueType cfs[], valueType nodes[], bool transpose = false ) const = 0 ; virtual sizeType // order order() const = 0 ; //! Print spline information virtual void info( std::basic_ostream<char> & s ) const ; //! Print spline coefficients virtual void writeToStream( std::basic_ostream<char> & s ) const = 0 ; //! Return spline typename char const * type_name() const { return Splines::spline_type[type()] ; } //! Return spline type (as number) virtual unsigned type() const = 0 ; friend class SplineSet ; } ; /* // ____ _ _ // | __ ) ___ _ __ | (_)_ __ ___ // | _ \ _____/ __| '_ \| | | '_ \ / _ \ // | |_) |_____\__ \ |_) | | | | | | __/ // |____/ |___/ .__/|_|_|_| |_|\___| // |_| */ //! B-spline base class template <int _degree> class BSpline : public Spline { protected: SplineMalloc<valueType> baseValue ; valueType * knots ; valueType * yPolygon ; bool _external_alloc ; sizeType knot_search( valueType x ) const ; // extrapolation valueType s_L, s_R ; valueType ds_L, ds_R ; valueType dds_L, dds_R ; public: using Spline::build ; //! spline constructor BSpline( string const & name = "BSpline", bool ck = false ) : Spline(name,ck) , baseValue(name+"_memory") , knots(nullptr) , yPolygon(nullptr) , _external_alloc(false) {} virtual ~BSpline() {} void copySpline( BSpline const & S ) ; //! return the i-th node of the spline (y' component). valueType yPoly( sizeType i ) const { return yPolygon[i] ; } //! change X-range of the spline void setRange( valueType xmin, valueType xmax ) ; //! Use externally allocated memory for `npts` points void reserve_external( sizeType n, valueType *& p_x, valueType *& p_y, valueType *& p_knots, valueType *& p_yPolygon ) ; // --------------------------- VIRTUALS ----------------------------------- //! Return spline type (as number) virtual unsigned type() const { return BSPLINE_TYPE ; } //! Evaluate spline value virtual valueType operator () ( valueType x ) const ; //! First derivative virtual valueType D( valueType x ) const ; //! Second derivative virtual valueType DD( valueType x ) const ; //! Third derivative virtual valueType DDD( valueType x ) const ; //! Print spline coefficients virtual void writeToStream( std::basic_ostream<char> & s ) const ; // --------------------------- VIRTUALS ----------------------------------- //! Allocate memory for `npts` points virtual void reserve( sizeType npts ) ; virtual void build(void) ; //! Cancel the support points, empty the spline. virtual void clear(void) ; //! get the piecewise polinomials of the spline virtual sizeType // order coeffs( valueType cfs[], valueType nodes[], bool transpose = false ) const ; virtual sizeType // order order() const { return _degree+1 ; } // --------------------------- UTILS ----------------------------------- //! Evaluate spline value static valueType eval( valueType x, sizeType n, valueType const Knots[], valueType const yPolygon[] ) ; //! First derivative static valueType eval_D( valueType x, sizeType n, valueType const Knots[], valueType const yPolygon[] ) ; //! Second derivative static valueType eval_DD( valueType x, sizeType n, valueType const Knots[], valueType const yPolygon[] ) ; //! Third derivative static valueType eval_DDD( valueType x, sizeType n, valueType const Knots[], valueType const yPolygon[] ) ; //! B-spline bases void bases( valueType x, valueType vals[] ) const ; void bases_D( valueType x, valueType vals[] ) const ; void bases_DD( valueType x, valueType vals[] ) const ; void bases_DDD( valueType x, valueType vals[] ) const ; sizeType bases_nz( valueType x, valueType vals[] ) const ; sizeType bases_D_nz( valueType x, valueType vals[] ) const ; sizeType bases_DD_nz( valueType x, valueType vals[] ) const ; sizeType bases_DDD_nz( valueType x, valueType vals[] ) const ; // Utilities static void knots_sequence( sizeType n, valueType const X[], valueType * Knots ) ; static void sample_bases( indexType nx, // number of sample points valueType const X[], indexType nb, // number of bases valueType const Knots[], vector<indexType> & II, // GCC on linux bugged for I vector<indexType> & JJ, vector<valueType> & vals ) ; } ; /* // ____ _ _ ____ _ _ ____ // / ___| _| |__ (_) ___ / ___| _ __ | (_)_ __ ___ | __ ) __ _ ___ ___ // | | | | | | '_ \| |/ __| \___ \| '_ \| | | '_ \ / _ \ | _ \ / _` / __|/ _ \ // | |__| |_| | |_) | | (__ ___) | |_) | | | | | | __/ | |_) | (_| \__ \ __/ // \____\__,_|_.__/|_|\___| |____/| .__/|_|_|_| |_|\___| |____/ \__,_|___/\___| // |_| */ //! cubic spline base class class CubicSplineBase : public Spline { protected: SplineMalloc<valueType> baseValue ; mutable valueType base[4] ; mutable valueType base_D[4] ; mutable valueType base_DD[4] ; mutable valueType base_DDD[4] ; valueType * Yp ; bool _external_alloc ; public: using Spline::build ; //! spline constructor CubicSplineBase( string const & name = "CubicSplineBase", bool ck = false ) : Spline(name,ck) , baseValue(name+"_memory") , Yp(nullptr) , _external_alloc(false) {} virtual ~CubicSplineBase() {} void copySpline( CubicSplineBase const & S ) ; //! return the i-th node of the spline (y' component). valueType ypNode( sizeType i ) const { return Yp[i] ; } //! change X-range of the spline void setRange( valueType xmin, valueType xmax ) ; //! Use externally allocated memory for `npts` points void reserve_external( sizeType n, valueType *& p_x, valueType *& p_y, valueType *& p_dy ) ; // --------------------------- VIRTUALS ----------------------------------- //! Evaluate spline value virtual valueType operator () ( valueType x ) const ; //! First derivative virtual valueType D( valueType x ) const ; //! Second derivative virtual valueType DD( valueType x ) const ; //! Third derivative virtual valueType DDD( valueType x ) const ; //! Print spline coefficients virtual void writeToStream( std::basic_ostream<char> & s ) const ; // --------------------------- VIRTUALS ----------------------------------- //! Allocate memory for `npts` points virtual void reserve( sizeType npts ) ; //! Build a spline. /*! * \param x vector of x-coordinates * \param incx access elements as `x[0]`, `x[incx]`, `x[2*incx]`,... * \param y vector of y-coordinates * \param incy access elements as `y[0]`, `y[incy]`, `x[2*incy]`,... * \param yp vector of y'-coordinates * \param incyp access elements as `yp[0]`, `yp[incy]`, `xp[2*incy]`,... * \param n total number of points */ void build( valueType const x[], sizeType incx, valueType const y[], sizeType incy, valueType const yp[], sizeType incyp, sizeType n ) ; //! Build a spline. /*! * \param x vector of x-coordinates * \param y vector of y-coordinates * \param yp vector of y'-coordinates * \param n total number of points */ inline void build( valueType const x[], valueType const y[], valueType const yp[], sizeType n ) { build ( x, 1, y, 1, yp, 1, n ) ; } //! Build a spline. /*! * \param x vector of x-coordinates * \param y vector of y-coordinates * \param yp vector of y'-coordinates */ inline void build ( vector<valueType> const & x, vector<valueType> const & y, vector<valueType> const & yp ) { sizeType N = sizeType(x.size()) ; if ( N > sizeType(y.size()) ) N = sizeType(y.size()) ; if ( N > sizeType(yp.size()) ) N = sizeType(yp.size()) ; build ( &x.front(), 1, &y.front(), 1, &yp.front(), 1, N ) ; } //! Cancel the support points, empty the spline. virtual void clear(void) ; //! get the piecewise polinomials of the spline virtual sizeType // order coeffs( valueType cfs[], valueType nodes[], bool transpose = false ) const ; virtual sizeType // order order() const ; } ; /* // ____ _ _ ____ _ _ // / ___| _| |__ (_) ___/ ___| _ __ | (_)_ __ ___ // | | | | | | '_ \| |/ __\___ \| '_ \| | | '_ \ / _ \ // | |__| |_| | |_) | | (__ ___) | |_) | | | | | | __/ // \____\__,_|_.__/|_|\___|____/| .__/|_|_|_| |_|\___| // |_| */ //! Cubic Spline Management Class class CubicSpline : public CubicSplineBase { private: valueType ddy0 ; valueType ddyn ; public: using CubicSplineBase::build ; using CubicSplineBase::reserve ; //! spline constructor CubicSpline( string const & name = "CubicSpline", bool ck = false ) : CubicSplineBase( name, ck ) , ddy0(0) , ddyn(0) {} //! spline destructor virtual ~CubicSpline() {} /*! * \param _ddy0 first boundary condition. * The second derivative at initial point. * \param _ddyn second boundary condition. * The second derivative at final point. */ void setbc( valueType _ddy0, valueType _ddyn ) { this -> ddy0 = _ddy0 ; this -> ddyn = _ddyn ; } //! Return spline type (as number) virtual unsigned type() const { return CUBIC_TYPE ; } // --------------------------- VIRTUALS ----------------------------------- virtual void build (void) ; #ifndef SPLINES_DO_NOT_USE_GENERIC_CONTAINER virtual void setup ( GenericContainer const & gc ) ; #endif } ; /* // _ _ _ ____ _ _ // / \ | | _(_)_ __ ___ __ _ / ___| _ __ | (_)_ __ ___ // / _ \ | |/ / | '_ ` _ \ / _` | \___ \| '_ \| | | '_ \ / _ \ // / ___ \| <| | | | | | | (_| | ___) | |_) | | | | | | __/ // /_/ \_\_|\_\_|_| |_| |_|\__,_| |____/| .__/|_|_|_| |_|\___| // |_| */ //! Akima spline class /*! * Reference * ========= * Hiroshi Akima, Journal of the ACM, Vol. 17, No. 4, October 1970, pages 589-602. */ class AkimaSpline : public CubicSplineBase { public: using CubicSplineBase::build ; using CubicSplineBase::reserve ; //! spline constructor AkimaSpline( string const & name = "AkimaSpline", bool ck = false ) : CubicSplineBase( name, ck ) {} //! spline destructor virtual ~AkimaSpline() {} //! Return spline type (as number) virtual unsigned type() const { return AKIMA_TYPE ; } // --------------------------- VIRTUALS ----------------------------------- //! Build an Akima spline from previously inserted points virtual void build (void) ; } ; /* // ____ _ ____ _ _ // | __ ) ___ ___ ___ ___| / ___| _ __ | (_)_ __ ___ // | _ \ / _ \/ __/ __|/ _ \ \___ \| '_ \| | | '_ \ / _ \ // | |_) | __/\__ \__ \ __/ |___) | |_) | | | | | | __/ // |____/ \___||___/___/\___|_|____/| .__/|_|_|_| |_|\___| // |_| */ //! Bessel spline class class BesselSpline : public CubicSplineBase { public: using CubicSplineBase::build ; using CubicSplineBase::reserve ; //! spline constructor BesselSpline( string const & name = "BesselSpline", bool ck = false ) : CubicSplineBase( name, ck ) {} //! spline destructor virtual ~BesselSpline() {} //! Return spline type (as number) virtual unsigned type() const { return BESSEL_TYPE ; } // --------------------------- VIRTUALS ----------------------------------- //! Build a Bessel spline from previously inserted points virtual void build (void) ; } ; /* // ____ _ _ ____ _ _ // | _ \ ___| |__ (_)_ __/ ___| _ __ | (_)_ __ ___ // | |_) / __| '_ \| | '_ \___ \| '_ \| | | '_ \ / _ \ // | __/ (__| | | | | |_) |__) | |_) | | | | | | __/ // |_| \___|_| |_|_| .__/____/| .__/|_|_|_| |_|\___| // |_| |_| */ void pchip( valueType const X[], valueType const Y[], valueType Yp[], sizeType n ) ; //! Pchip (Piecewise Cubic Hermite Interpolating Polynomial) spline class class PchipSpline : public CubicSplineBase { public: using CubicSplineBase::build ; using CubicSplineBase::reserve ; //! spline constructor PchipSpline( string const & name = "PchipSpline", bool ck = false ) : CubicSplineBase( name, ck ) {} //! spline destructor virtual ~PchipSpline() {} //! Return spline type (as number) virtual unsigned type() const { return PCHIP_TYPE ; } // --------------------------- VIRTUALS ----------------------------------- //! Build a Monotone spline from previously inserted points virtual void build (void) ; } ; /* // _ _ ____ _ _ // | | (_)_ __ ___ __ _ _ __/ ___| _ __ | (_)_ __ ___ // | | | | '_ \ / _ \/ _` | '__\___ \| '_ \| | | '_ \ / _ \ // | |___| | | | | __/ (_| | | ___) | |_) | | | | | | __/ // |_____|_|_| |_|\___|\__,_|_| |____/| .__/|_|_|_| |_|\___| // |_| */ //! Linear spline class class LinearSpline : public Spline { SplineMalloc<valueType> baseValue ; bool _external_alloc ; public: using Spline::build ; LinearSpline( string const & name = "LinearSpline", bool ck = false ) : Spline(name,ck) , baseValue( name+"_memory") , _external_alloc(false) {} virtual ~LinearSpline() {} //! Use externally allocated memory for `npts` points void reserve_external( sizeType n, valueType *& p_x, valueType *& p_y ) ; // --------------------------- VIRTUALS ----------------------------------- //! Evalute spline value at `x` virtual valueType operator () ( valueType x ) const { SPLINE_ASSERT( npts > 0, "in LinearSpline::operator(), npts == 0!") ; if ( x < X[0] ) return Y[0] ; if ( x > X[npts-1] ) return Y[npts-1] ; sizeType i = search(x) ; valueType s = (x-X[i])/(X[i+1] - X[i]) ; return (1-s)*Y[i] + s * Y[i+1] ; } //! First derivative virtual valueType D( valueType x ) const { SPLINE_ASSERT( npts > 0, "in LinearSpline::operator(), npts == 0!") ; if ( x < X[0] ) return 0 ; if ( x > X[npts-1] ) return 0 ; sizeType i = search(x) ; return ( Y[i+1] - Y[i] ) / ( X[i+1] - X[i] ) ; } //! Second derivative virtual valueType DD( valueType ) const { return 0 ; } //! Third derivative virtual valueType DDD( valueType ) const { return 0 ; } //! Print spline coefficients virtual void writeToStream( std::basic_ostream<char> & s ) const ; //! Return spline type (as number) virtual unsigned type() const { return LINEAR_TYPE ; } // --------------------------- VIRTUALS ----------------------------------- //! Allocate memory for `npts` points virtual void reserve( sizeType npts ) ; //! added for compatibility with cubic splines virtual void build (void) {} //! Cancel the support points, empty the spline. virtual void clear(void) ; //! get the piecewise polinomials of the spline virtual sizeType // order coeffs( valueType cfs[], valueType nodes[], bool transpose = false ) const ; virtual sizeType // order order() const ; } ; /* // ____ _ _ ____ _ _ // / ___|___ _ __ ___| |_ __ _ _ __ | |_ ___/ ___| _ __ | (_)_ __ ___ // | | / _ \| '_ \/ __| __/ _` | '_ \| __/ __\___ \| '_ \| | | '_ \ / _ \ // | |__| (_) | | | \__ \ || (_| | | | | |_\__ \___) | |_) | | | | | | __/ // \____\___/|_| |_|___/\__\__,_|_| |_|\__|___/____/| .__/|_|_|_| |_|\___| // |_| */ //! Picewise constants spline class class ConstantSpline : public Spline { SplineMalloc<valueType> baseValue ; bool _external_alloc ; public: using Spline::build ; ConstantSpline( string const & name = "ConstantSpline", bool ck = false ) : Spline(name,ck) , baseValue(name+"_memory") , _external_alloc(false) {} ~ConstantSpline() {} //! Use externally allocated memory for `npts` points void reserve_external( sizeType n, valueType *& p_x, valueType *& p_y ) ; // --------------------------- VIRTUALS ----------------------------------- //! Build a spline. virtual void build (void) {} // nothing to do virtual void build( valueType const x[], sizeType incx, valueType const y[], sizeType incy, sizeType n ) ; //! Evaluate spline value at `x` virtual valueType operator () ( valueType x ) const ; //! First derivative virtual valueType D( valueType ) const { return 0 ; } //! Second derivative virtual valueType DD( valueType ) const { return 0 ; } //! Third derivative virtual valueType DDD( valueType ) const { return 0 ; } //! Print spline coefficients virtual void writeToStream( std::basic_ostream<char> & ) const ; //! Return spline type (as number) virtual unsigned type() const { return CONSTANT_TYPE ; } // --------------------------- VIRTUALS ----------------------------------- //! Allocate memory for `npts` points virtual void reserve( sizeType npts ) ; //! Cancel the support points, empty the spline. virtual void clear(void) ; //! get the piecewise polinomials of the spline virtual sizeType // order coeffs( valueType cfs[], valueType nodes[], bool transpose = false ) const ; virtual sizeType // order order() const ; } ; /* // _ _ _ _ ____ _ _ // | | | | ___ _ __ _ __ ___ (_) |_ ___/ ___| _ __ | (_)_ __ ___ // | |_| |/ _ \ '__| '_ ` _ \| | __/ _ \___ \| '_ \| | | '_ \ / _ \ // | _ | __/ | | | | | | | | || __/___) | |_) | | | | | | __/ // |_| |_|\___|_| |_| |_| |_|_|\__\___|____/| .__/|_|_|_| |_|\___| // |_| */ //! Hermite Spline Management Class class HermiteSpline : public CubicSplineBase { public: using CubicSplineBase::build ; using CubicSplineBase::reserve ; //! spline constructor HermiteSpline( string const & name = "HermiteSpline", bool ck = false ) : CubicSplineBase( name, ck ) {} //! spline destructor virtual ~HermiteSpline() {} //! Return spline type (as number) virtual unsigned type() const { return HERMITE_TYPE ; } // --------------------------- VIRTUALS ----------------------------------- virtual void build(void) {} // nothing to do #ifndef SPLINES_DO_NOT_USE_GENERIC_CONTAINER virtual void setup( GenericContainer const & gc ) ; #endif // block method! virtual void build( valueType const [], sizeType, valueType const [], sizeType, sizeType ) ; } ; /* // ___ _ _ _ ____ _ _ ____ // / _ \ _ _(_)_ __ | |_(_) ___/ ___| _ __ | (_)_ __ ___| __ ) __ _ ___ ___ // | | | | | | | | '_ \| __| |/ __\___ \| '_ \| | | '_ \ / _ \ _ \ / _` / __|/ _ \ // | |_| | |_| | | | | | |_| | (__ ___) | |_) | | | | | | __/ |_) | (_| \__ \ __/ // \__\_\\__,_|_|_| |_|\__|_|\___|____/| .__/|_|_|_| |_|\___|____/ \__,_|___/\___| // |_| // */ //! cubic quintic base class class QuinticSplineBase : public Spline { protected: SplineMalloc<valueType> baseValue ; mutable valueType base[6] ; mutable valueType base_D[6] ; mutable valueType base_DD[6] ; mutable valueType base_DDD[6] ; mutable valueType base_DDDD[6] ; mutable valueType base_DDDDD[6] ; valueType * Yp ; valueType * Ypp ; bool _external_alloc ; public: using Spline::build ; //! spline constructor QuinticSplineBase( string const & name = "Spline", bool ck = false ) : Spline(name,ck) , baseValue(name+"_memeory") , Yp(nullptr) , Ypp(nullptr) , _external_alloc(false) {} virtual ~QuinticSplineBase() {} void copySpline( QuinticSplineBase const & S ) ; //! return the i-th node of the spline (y' component). valueType ypNode( sizeType i ) const { return Yp[i] ; } //! return the i-th node of the spline (y'' component). valueType yppNode( sizeType i ) const { return Ypp[i] ; } //! change X-range of the spline void setRange( valueType xmin, valueType xmax ) ; //! Use externally allocated memory for `npts` points void reserve_external( sizeType n, valueType *& p_x, valueType *& p_y, valueType *& p_Yp, valueType *& p_Ypp ) ; // --------------------------- VIRTUALS ----------------------------------- //! Evaluate spline value virtual valueType operator () ( valueType x ) const ; //! First derivative virtual valueType D( valueType x ) const ; //! Second derivative virtual valueType DD( valueType x ) const ; //! Third derivative virtual valueType DDD( valueType x ) const ; //! Fourth derivative virtual valueType DDDD( valueType x ) const ; //! Fifth derivative virtual valueType DDDDD( valueType x ) const ; //! Print spline coefficients virtual void writeToStream( std::basic_ostream<char> & s ) const ; //! Return spline type (as number) virtual unsigned type() const { return QUINTIC_TYPE ; } // --------------------------- VIRTUALS ----------------------------------- //! Allocate memory for `npts` points virtual void reserve( sizeType npts ) ; //! Cancel the support points, empty the spline. virtual void clear(void) ; //! get the piecewise polinomials of the spline virtual sizeType // order coeffs( valueType cfs[], valueType nodes[], bool transpose = false ) const ; virtual sizeType // order order() const ; } ; /* // ___ _ _ _ ____ _ _ // / _ \ _ _(_)_ __ | |_(_) ___/ ___| _ __ | (_)_ __ ___ // | | | | | | | | '_ \| __| |/ __\___ \| '_ \| | | '_ \ / _ \ // | |_| | |_| | | | | | |_| | (__ ___) | |_) | | | | | | __/ // \__\_\\__,_|_|_| |_|\__|_|\___|____/| .__/|_|_|_| |_|\___| // |_| // */ //! Quintic spline class class QuinticSpline : public QuinticSplineBase { public: using Spline::build ; using QuinticSplineBase::reserve ; //! spline constructor QuinticSpline( string const & name = "Spline", bool ck = false ) : QuinticSplineBase( name, ck ) {} //! spline destructor virtual ~QuinticSpline() {} // --------------------------- VIRTUALS ----------------------------------- //! Build a Monotone quintic spline from previously inserted points virtual void build (void) ; } ; /* // ____ _ _ ____ _ // / ___| _ __ | (_)_ __ ___/ ___| ___| |_ // \___ \| '_ \| | | '_ \ / _ \___ \ / _ \ __| // ___) | |_) | | | | | | __/___) | __/ |_ // |____/| .__/|_|_|_| |_|\___|____/ \___|\__| // |_| */ //! Splines Management Class class SplineSet { SplineSet(SplineSet const &) ; // block copy constructor SplineSet const & operator = (SplineSet const &) ; // block copy method protected: string const _name ; SplineMalloc<valueType> baseValue ; SplineMalloc<valueType*> basePointer ; sizeType _npts ; sizeType _nspl ; valueType * _X ; valueType ** _Y ; valueType ** _Yp ; valueType ** _Ypp ; valueType * _Ymin ; valueType * _Ymax ; mutable sizeType lastInterval ; sizeType search( valueType x ) const ; vector<Spline*> splines ; vector<int> is_monotone ; map<string,sizeType> header_to_position ; private: //! find `x` value such that the monotone spline `(spline[spl])(x)` intersect the value `zeta` Spline const * intersect( sizeType spl, valueType zeta, valueType & x ) const ; public: //! spline constructor SplineSet( string const & name = "SplineSet" ) ; //! spline destructor virtual ~SplineSet() ; string const & name() const { return _name ; } string const & header( sizeType const i ) const { return splines[i]->name() ; } // return +1 = strict monotone, 0 weak monotone, -1 non monotone int isMonotone( sizeType const i ) const { return is_monotone[i] ; } //! return the number of support points of the splines sizeType numPoints(void) const { return _npts ; } //! return the number splines in the spline set sizeType numSplines(void) const { return _nspl ; } //! return the column with header(i) == hdr, return -1 if not found sizeType getPosition( char const * hdr ) const ; //! return the vector of values of x-nodes valueType const * xNodes() const { return _X ; } //! return the vector of values of x-nodes valueType const * yNodes( sizeType i ) const { SPLINE_ASSERT( i >=0 && i < _nspl, "SplineSet::yNodes( " << i << ") argument out of range [0," << _nspl-1 << "]" ) ; return _Y[i] ; } //! return the i-th node of the spline (x component). valueType xNode( sizeType npt ) const { return _X[npt] ; } //! return the i-th node of the spline (y component). valueType yNode( sizeType npt, sizeType spl ) const { return _Y[spl][npt] ; } //! return x-minumum spline value valueType xMin() const { return _X[0] ; } //! return x-maximum spline value valueType xMax() const { return _X[_npts-1] ; } //! return y-minumum spline value valueType yMin( sizeType spl ) const { return _Ymin[spl] ; } //! return y-maximum spline value valueType yMax( sizeType spl ) const { return _Ymax[spl] ; } //! return y-minumum spline value valueType yMin( char const spl[] ) const { return _Ymin[getPosition(spl)] ; } //! return y-maximum spline value valueType yMax( char const spl[] ) const { return _Ymax[getPosition(spl)] ; } //! Return pointer to the `i`-th spline Spline * getSpline( sizeType i ) const { SPLINE_ASSERT( i < _nspl, "SplineSet::getSpline( " << i << ") argument out of range [0," << _nspl-1 << "]" ) ; return splines[i] ; } //! Return pointer to the `i`-th spline Spline * getSpline( char const * hdr ) const { return splines[getPosition(hdr)] ; } //! Evaluate spline value valueType operator () ( valueType x, sizeType spl ) const { return (*getSpline(spl))(x) ; } valueType eval( valueType x, sizeType spl ) const { return (*getSpline(spl))(x) ; } //! First derivative valueType D( valueType x, sizeType spl ) const { return getSpline(spl)->D(x) ; } valueType eval_D( valueType x, sizeType spl ) const { return getSpline(spl)->D(x) ; } //! Second derivative valueType DD( valueType x, sizeType spl ) const { return getSpline(spl)->DD(x) ; } valueType eval_DD( valueType x, sizeType spl ) const { return getSpline(spl)->DD(x) ; } //! Third derivative valueType DDD( valueType x, sizeType spl ) const { return getSpline(spl)->DDD(x) ; } valueType eval_DDD( valueType x, sizeType spl ) const { return getSpline(spl)->DDD(x) ; } //! Evaluate spline value valueType eval( valueType x, char const * name ) const { return (*getSpline(name))(x) ; } //! First derivative valueType eval_D( valueType x, char const * name ) const { return getSpline(name)->D(x) ; } //! Second derivative valueType eval_DD( valueType x, char const * name ) const { return getSpline(name)->DD(x) ; } //! Third derivative valueType eval_DDD( valueType x, char const * name ) const { return getSpline(name)->DDD(x) ; } // vectorial values //! fill a vector of strings with the names of the splines void getHeaders( vector<string> & h ) const ; //! Evaluate all the splines at `x` void eval( valueType x, vector<valueType> & vals ) const ; //! Evaluate all the splines at `x` void eval( valueType x, valueType vals[], indexType incy = 1 ) const ; //! Evaluate the fist derivative of all the splines at `x` void eval_D( valueType x, vector<valueType> & vals ) const ; //! Evaluate the fist derivative of all the splines at `x` void eval_D( valueType x, valueType vals[], indexType incy = 1 ) const ; //! Evaluate the second derivative of all the splines at `x` void eval_DD( valueType x, vector<valueType> & vals ) const ; //! Evaluate the second derivative of all the splines at `x` void eval_DD( valueType x, valueType vals[], indexType incy = 1 ) const ; //! Evaluate the third derivative of all the splines at `x` void eval_DDD( valueType x, vector<valueType> & vals ) const ; //! Evaluate the third derivative of all the splines at `x` void eval_DDD( valueType x, valueType vals[], indexType incy = 1 ) const ; // change independent variable //! Evaluate all the splines at `zeta` using spline[spl] as independent void eval2( sizeType spl, valueType zeta, vector<valueType> & vals ) const ; //! Evaluate all the splines at `zeta` using spline[spl] as independent void eval2( sizeType spl, valueType zeta, valueType vals[], indexType incy = 1 ) const ; //! Evaluate the fist derivative of all the splines at `zeta` using spline[spl] as independent void eval2_D( sizeType spl, valueType zeta, vector<valueType> & vals ) const ; //! Evaluate the fist derivative of all the splines at `zeta` using spline[spl] as independent void eval2_D( sizeType spl, valueType zeta, valueType vals[], indexType incy = 1 ) const ; //! Evaluate the second derivative of all the splines at `zeta` using spline[spl] as independent void eval2_DD( sizeType spl, valueType zeta, vector<valueType> & vals ) const ; //! Evaluate the second derivative of all the splines at `zeta` using spline[spl] as independent void eval2_DD( sizeType spl, valueType zeta, valueType vals[], indexType incy = 1 ) const ; //! Evaluate the third derivative of all the splines at `zeta` using spline[spl] as independent void eval2_DDD( sizeType spl, valueType zeta, vector<valueType> & vals ) const ; //! Evaluate the sizeType derivative of all the splines at `zeta` using spline[spl] as independent void eval2_DDD( sizeType spl, valueType zeta, valueType vals[], indexType incy = 1 ) const ; //! Evaluate the spline `name` at `zeta` using spline `indep` as independent valueType eval2( valueType zeta, char const * indep, char const * name ) const ; //! Evaluate first derivative of the spline `name` at `zeta` using spline `indep` as independent valueType eval2_D( valueType zeta, char const * indep, char const * name ) const ; //! Evaluate second derivative of the spline `name` at `zeta` using spline `indep` as independent valueType eval2_DD( valueType zeta, char const * indep, char const * name ) const ; //! Evaluate third derivative of the spline `name` at `zeta` using spline `indep` as independent valueType eval2_DDD( valueType zeta, char const * indep, char const * name ) const ; //! Evaluate the spline `spl` at `zeta` using spline `indep` as independent valueType eval2( valueType zeta, sizeType indep, sizeType spl ) const ; //! Evaluate first derivative of the spline `spl` at `zeta` using spline `indep` as independent valueType eval2_D( valueType zeta, sizeType indep, sizeType spl ) const ; //! Evaluate second derivative of the spline `spl` at `zeta` using spline `indep` as independent valueType eval2_DD( valueType zeta, sizeType indep, sizeType spl ) const ; //! Evaluate third derivative of the spline `spl` at `zeta` using spline `indep` as independent valueType eval2_DDD( valueType zeta, sizeType indep, sizeType spl ) const ; // interface with GenericContainer #ifndef SPLINES_DO_NOT_USE_GENERIC_CONTAINER //! Evaluate all the splines at `x` and fill a map of values in a GenericContainer void eval( valueType x, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` values contained in vec and fill a map of vector in a GenericContainer void eval( vec_real_type const & vec, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` and fill a map of values in a GenericContainer with keys in `columns` void eval( valueType x, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` void eval( vec_real_type const & vec, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer and `indep` as independent spline void eval2( valueType zeta, sizeType indep, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer and `indep` as independent spline void eval2( vec_real_type const & zetas, sizeType indep, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2( valueType zeta, sizeType indep, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2( vec_real_type const & zetas, sizeType indep, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer and `indep` as independent spline void eval2( valueType zeta, char const * indep, GenericContainer & vals ) const { eval2( zeta, getPosition(indep), vals ) ; } //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer and `indep` as independent spline void eval2( vec_real_type const & zetas, char const * indep, GenericContainer & vals ) const { eval2( zetas, getPosition(indep), vals ) ; } //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2( valueType zeta, char const * indep, vec_string_type const & columns, GenericContainer & vals ) const { eval2( zeta, getPosition(indep), columns, vals ) ; } //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2( vec_real_type const & zetas, char const * indep, vec_string_type const & columns, GenericContainer & vals ) const { eval2( zetas, getPosition(indep), columns, vals ) ; } //! Evaluate all the splines at `x` and fill a map of values in a GenericContainer void eval_D( valueType x, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` values contained in vec and fill a map of vector in a GenericContainer void eval_D( vec_real_type const & vec, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` and fill a map of values in a GenericContainer with keys in `columns` void eval_D( valueType x, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` void eval_D( vec_real_type const & vec, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer and `indep` as independent spline void eval2_D( valueType zeta, sizeType indep, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer and `indep` as independent spline void eval2_D( vec_real_type const & zetas, sizeType indep, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_D( valueType zeta, sizeType indep, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_D( vec_real_type const & zetas, sizeType indep, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer and `indep` as independent spline void eval2_D( valueType zeta, char const * indep, GenericContainer & vals ) const { eval2_D( zeta, getPosition(indep), vals ) ; } //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer and `indep` as independent spline void eval2_D( vec_real_type const & zetas, char const * indep, GenericContainer & vals ) const { eval2_D( zetas, getPosition(indep), vals ) ; } //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_D( valueType zeta, char const * indep, vec_string_type const & columns, GenericContainer & vals ) const { eval2_D( zeta, getPosition(indep), columns, vals ) ; } //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_D( vec_real_type const & zetas, char const * indep, vec_string_type const & columns, GenericContainer & vals ) const { eval2_D( zetas, getPosition(indep), columns, vals ) ; } //! Evaluate all the splines at `x` and fill a map of values in a GenericContainer void eval_DD( valueType x, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` values contained in vec and fill a map of vector in a GenericContainer void eval_DD( vec_real_type const & vec, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` and fill a map of values in a GenericContainer with keys in `columns` void eval_DD( valueType x, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` void eval_DD( vec_real_type const & vec, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer and `indep` as independent spline void eval2_DD( valueType zeta, sizeType indep, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer and `indep` as independent spline void eval2_DD( vec_real_type const & zetas, sizeType indep, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_DD( valueType zeta, sizeType indep, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_DD( vec_real_type const & zetas, sizeType indep, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer and `indep` as independent spline void eval2_DD( valueType zeta, char const * indep, GenericContainer & vals ) const { eval2_DD( zeta, getPosition(indep), vals ) ; } //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer and `indep` as independent spline void eval2_DD( vec_real_type const & zetas, char const * indep, GenericContainer & vals ) const { eval2_DD( zetas, getPosition(indep), vals ) ; } //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_DD( valueType zeta, char const * indep, vec_string_type const & columns, GenericContainer & vals ) const { eval2_DD( zeta, getPosition(indep), columns, vals ) ; } //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_DD( vec_real_type const & zetas, char const * indep, vec_string_type const & columns, GenericContainer & vals ) const { eval2_DD( zetas, getPosition(indep), columns, vals ) ; } //! Evaluate all the splines at `x` and fill a map of values in a GenericContainer void eval_DDD( valueType x, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` values contained in vec and fill a map of vector in a GenericContainer void eval_DDD( vec_real_type const & vec, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` and fill a map of values in a GenericContainer with keys in `columns` void eval_DDD( valueType x, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `x` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` void eval_DDD( vec_real_type const & vec, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer and `indep` as independent spline void eval2_DDD( valueType zeta, sizeType indep, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer and `indep` as independent spline void eval2_DDD( vec_real_type const & zetas, sizeType indep, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_DDD( valueType zeta, sizeType indep, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_DDD( vec_real_type const & zetas, sizeType indep, vec_string_type const & columns, GenericContainer & vals ) const ; //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer and `indep` as independent spline void eval2_DDD( valueType zeta, char const * indep, GenericContainer & vals ) const { eval2_DD( zeta, getPosition(indep), vals ) ; } //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer and `indep` as independent spline void eval2_DDD( vec_real_type const & zetas, char const * indep, GenericContainer & vals ) const { eval2_DD( zetas, getPosition(indep), vals ) ; } //! Evaluate all the splines at `zeta` and fill a map of values in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_DDD( valueType zeta, char const * indep, vec_string_type const & columns, GenericContainer & vals ) const { eval2_DD( zeta, getPosition(indep), columns, vals ) ; } //! Evaluate all the splines at `zeta` values contained in vec and fill a map of vector in a GenericContainer with keys in `columns` and `indep` as independent spline void eval2_DDD( vec_real_type const & zetas, char const * indep, vec_string_type const & columns, GenericContainer & vals ) const { eval2_DD( zetas, getPosition(indep), columns, vals ) ; } #endif /////////////////////////////////////////////////////////////////////////// /*! Build a set of splines * \param nspl the number of splines * \param npts the number of points of each splines * \param headers the names of the splines * \param stype the type of each spline * \param X pointer to X independent values * \param Y vector of `nspl` pointers to Y depentendent values. */ void build( sizeType const nspl, sizeType const npts, char const *headers[], SplineType const stype[], valueType const X[], valueType const *Y[], valueType const *Yp[] = nullptr ) ; #ifndef SPLINES_DO_NOT_USE_GENERIC_CONTAINER virtual void setup ( GenericContainer const & gc ) ; void build ( GenericContainer const & gc ) { setup(gc) ; } #endif //! Return spline type (as number) virtual unsigned type() const { return SPLINE_SET_TYPE ; } //! Get info of splines collected void info( std::basic_ostream<char> & s ) const ; void dump_table( std::basic_ostream<char> & s, sizeType num_points ) const ; } ; /* // ____ _ _ ____ __ // / ___| _ __ | (_)_ __ ___/ ___| _ _ _ __ / _| // \___ \| '_ \| | | '_ \ / _ \___ \| | | | '__| |_ // ___) | |_) | | | | | | __/___) | |_| | | | _| // |____/| .__/|_|_|_| |_|\___|____/ \__,_|_| |_| // |_| */ //! Spline Management Class class SplineSurf { SplineSurf(SplineSurf const &) ; // block copy constructor SplineSurf const & operator = (SplineSurf const &) ; // block copy method protected: string const _name ; bool _check_range ; vector<valueType> X, Y, Z ; valueType Z_min, Z_max ; mutable sizeType lastInterval_x ; sizeType search_x( valueType x ) const { sizeType npts_x = sizeType(X.size()) ; SPLINE_ASSERT( npts_x > 1, "\nsearch_x(" << x << ") empty spline"); if ( _check_range ) { valueType xl = X.front() ; valueType xr = X.back() ; SPLINE_ASSERT( x >= xl && x <= xr, "method search_x( " << x << " ) out of range: [" << xl << ", " << xr << "]" ) ; } Splines::updateInterval( lastInterval_x, x, &X.front(), npts_x ) ; return lastInterval_x; } mutable sizeType lastInterval_y ; sizeType search_y( valueType y ) const { sizeType npts_y = sizeType(Y.size()) ; SPLINE_ASSERT( npts_y > 1, "\nsearch_y(" << y << ") empty spline"); if ( _check_range ) { valueType yl = Y.front() ; valueType yr = Y.back() ; SPLINE_ASSERT( y >= yl && y <= yr, "method search_y( " << y << " ) out of range: [" << yl << ", " << yr << "]" ) ; } Splines::updateInterval( lastInterval_y, y, &Y.front(), npts_y ) ; return lastInterval_y; } sizeType ipos_C( sizeType i, sizeType j, sizeType ldZ ) const { return i*ldZ + j ; } sizeType ipos_F( sizeType i, sizeType j, sizeType ldZ ) const { return i + ldZ*j ; } sizeType ipos_C( sizeType i, sizeType j ) const { return ipos_C(i,j,sizeType(Y.size())) ; } sizeType ipos_F( sizeType i, sizeType j ) const { return ipos_F(i,j,sizeType(X.size())) ; } virtual void makeSpline() = 0 ; public: //! spline constructor SplineSurf( string const & name = "Spline", bool ck = false ) : _name(name) , _check_range(ck) , X() , Y() , Z() , Z_min(0) , Z_max(0) , lastInterval_x(0) , lastInterval_y(0) {} //! spline destructor virtual ~SplineSurf() {} string const & name() const { return _name ; } void setCheckRange( bool ck ) { _check_range = ck ; } bool getCheckRange() const { return _check_range ; } //! Cancel the support points, empty the spline. virtual void clear (void) { X.clear() ; Y.clear() ; Z.clear() ; Z_min = Z_max = 0 ; lastInterval_x = 0 ; lastInterval_y = 0 ; } //! return the number of support points of the spline along x direction sizeType numPointX(void) const { return sizeType(X.size()) ; } //! return the number of support points of the spline along y direction sizeType numPointY(void) const { return sizeType(Y.size()) ; } //! return the i-th node of the spline (x component). valueType xNode( sizeType i ) const { return X[i] ; } //! return the i-th node of the spline (y component). valueType yNode( sizeType i ) const { return Y[i] ; } //! return the i-th node of the spline (y component). valueType zNode( sizeType i, sizeType j ) const { return Z[ipos_C(i,j)] ; } //! return x-minumum spline value valueType xMin() const { return X.front() ; } //! return x-maximum spline value valueType xMax() const { return X.back() ; } //! return y-minumum spline value valueType yMin() const { return Y.front() ; } //! return y-maximum spline value valueType yMax() const { return Y.back() ; } //! return z-minumum spline value valueType zMin() const { return Z_min ; } //! return z-maximum spline value valueType zMax() const { return Z_max ; } /////////////////////////////////////////////////////////////////////////// /*! Build surface spline * \param x vector of x-coordinates * \param incx access elements as x[0], x[incx], x[2*incx],... * \param y vector of y-coordinates * \param incy access elements as y[0], y[incy], x[2*incy],... * \param z matrix of z-values * \param ldZ leading dimension of the matrix. Elements are stored * by row Z(i,j) = z[i*ldZ+j] as C-matrix * \param nx total number of points in direction x * \param ny total number of points in direction y * \param fortran_storage if true elements are stored by column * i.e. Z(i,j) = z[i+j*ldZ] as Fortran-matrix * \param transposed if true matrix Z is stored transposed */ void build ( valueType const x[], sizeType incx, valueType const y[], sizeType incy, valueType const z[], sizeType ldZ, sizeType nx, sizeType ny, bool fortran_storage = false, bool transposed = false ) ; /*! Build surface spline * \param x vector of x-coordinates, nx = x.size() * \param y vector of y-coordinates, ny = y.size() * \param z matrix of z-values. Elements are stored * by row Z(i,j) = z[i*ny+j] as C-matrix * \param fortran_storage if true elements are stored by column * i.e. Z(i,j) = z[i+j*nx] as Fortran-matrix * \param transposed if true matrix Z is stored transposed */ void build ( vector<valueType> const & x, vector<valueType> const & y, vector<valueType> const & z, bool fortran_storage = false, bool transposed = false ) { bool xyswp = (fortran_storage && transposed) || (!fortran_storage && !transposed) ; build ( &x.front(), 1, &y.front(), 1, &z.front(), sizeType(xyswp ? y.size() : x.size()), sizeType(x.size()), sizeType(y.size()), fortran_storage, transposed ) ; } /*! Build surface spline * \param z matrix of z-values. Elements are stored * by row Z(i,j) = z[i*ny+j] as C-matrix * \param ldZ leading dimension of the matrix. Elements are stored * by row Z(i,j) = z[i*ldZ+j] as C-matrix * \param fortran_storage if true elements are stored by column * i.e. Z(i,j) = z[i+j*nx] as Fortran-matrix * \param transposed if true matrix Z is stored transposed */ void build ( valueType const z[], sizeType ldZ, sizeType nx, sizeType ny, bool fortran_storage = false, bool transposed = false ) ; /*! Build surface spline * \param z matrix of z-values. Elements are stored * by row Z(i,j) = z[i*ny+j] as C-matrix. * ldZ leading dimension of the matrix is ny for C-storage * and nx for Fortran storage. * \param fortran_storage if true elements are stored by column * i.e. Z(i,j) = z[i+j*nx] as Fortran-matrix * \param transposed if true matrix Z is stored transposed */ void build ( vector<valueType> const & z, sizeType nx, sizeType ny, bool fortran_storage = false, bool transposed = false ) { if ( fortran_storage ) build ( &z.front(), nx, nx, ny, fortran_storage, transposed ) ; else build ( &z.front(), ny, nx, ny, fortran_storage, transposed ) ; } #ifndef SPLINES_DO_NOT_USE_GENERIC_CONTAINER virtual void setup ( GenericContainer const & gc ) ; void build ( GenericContainer const & gc ) { setup(gc) ; } #endif //! Evaluate spline value virtual valueType operator () ( valueType x, valueType y ) const = 0 ; //! First derivative virtual void D( valueType x, valueType y, valueType d[3] ) const = 0 ; virtual valueType Dx( valueType x, valueType y ) const = 0 ; virtual valueType Dy( valueType x, valueType y ) const = 0 ; //! Second derivative virtual void DD( valueType x, valueType y, valueType dd[6] ) const = 0 ; virtual valueType Dxx( valueType x, valueType y ) const = 0 ; virtual valueType Dxy( valueType x, valueType y ) const = 0 ; virtual valueType Dyy( valueType x, valueType y ) const = 0 ; //! Evaluate spline value valueType eval( valueType x, valueType y ) const { return (*this)(x,y) ; } //! First derivative virtual valueType eval_D_1( valueType x, valueType y ) const { return Dx(x,y) ; } virtual valueType eval_D_2( valueType x, valueType y ) const { return Dy(x,y) ; } //! Second derivative virtual valueType eval_D_1_1( valueType x, valueType y ) const { return Dxx(x,y) ; } virtual valueType eval_D_1_2( valueType x, valueType y ) const { return Dxy(x,y) ; } virtual valueType eval_D_2_2( valueType x, valueType y ) const { return Dyy(x,y) ; } //! Print spline information virtual void info( ostream & s ) const ; //! Print spline coefficients virtual void writeToStream( ostream & s ) const = 0 ; //! Return spline typename virtual char const * type_name() const = 0 ; } ; /* // ____ _ _ _ ____ _ _ // | __ )(_) (_)_ __ ___ __ _ _ __/ ___| _ __ | (_)_ __ ___ // | _ \| | | | '_ \ / _ \/ _` | '__\___ \| '_ \| | | '_ \ / _ \ // | |_) | | | | | | | __/ (_| | | ___) | |_) | | | | | | __/ // |____/|_|_|_|_| |_|\___|\__,_|_| |____/| .__/|_|_|_| |_|\___| // |_| */ //! bilinear spline base class class BilinearSpline : public SplineSurf { virtual void makeSpline() {} public: //! spline constructor BilinearSpline( string const & name = "Spline", bool ck = false ) : SplineSurf(name,ck) {} virtual ~BilinearSpline() {} //! Evaluate spline value virtual valueType operator () ( valueType x, valueType y ) const ; //! First derivative virtual void D( valueType x, valueType y, valueType d[3] ) const ; virtual valueType Dx( valueType x, valueType y ) const ; virtual valueType Dy( valueType x, valueType y ) const ; //! Second derivative virtual void DD( valueType x, valueType y, valueType dd[6] ) const { D(x,y,dd) ; dd[3] = dd[4] = dd[5] = 0 ; } virtual valueType Dxx( valueType , valueType ) const { return 0 ; } virtual valueType Dxy( valueType , valueType ) const { return 0 ; } virtual valueType Dyy( valueType , valueType ) const { return 0 ; } //! Print spline coefficients virtual void writeToStream( ostream & s ) const ; //! Return spline typename virtual char const * type_name() const ; } ; /* // ____ _ ____ _ _ ____ _ _ ____ // | __ )(_)/ ___| _| |__ (_) ___/ ___| _ __ | (_)_ __ ___| __ ) __ _ ___ ___ // | _ \| | | | | | | '_ \| |/ __\___ \| '_ \| | | '_ \ / _ \ _ \ / _` / __|/ _ \ // | |_) | | |__| |_| | |_) | | (__ ___) | |_) | | | | | | __/ |_) | (_| \__ \ __/ // |____/|_|\____\__,_|_.__/|_|\___|____/| .__/|_|_|_| |_|\___|____/ \__,_|___/\___| // |_| */ //! Bi-cubic spline base class class BiCubicSplineBase : public SplineSurf { protected: vector<valueType> DX, DY, DXY ; mutable valueType u[4] ; mutable valueType u_D[4] ; mutable valueType u_DD[4] ; mutable valueType v[4] ; mutable valueType v_D[4] ; mutable valueType v_DD[4] ; mutable valueType bili3[4][4] ; void load( sizeType i, sizeType j ) const ; public: //! spline constructor BiCubicSplineBase( string const & name = "Spline", bool ck = false ) : SplineSurf( name, ck ) , DX() , DY() {} virtual ~BiCubicSplineBase() {} valueType DxNode ( sizeType i, sizeType j ) const { return DX[ipos_C(i,j)] ; } valueType DyNode ( sizeType i, sizeType j ) const { return DY[ipos_C(i,j)] ; } valueType DxyNode( sizeType i, sizeType j ) const { return DXY[ipos_C(i,j)] ; } //! Evaluate spline value virtual valueType operator () ( valueType x, valueType y ) const ; //! First derivative virtual void D( valueType x, valueType y, valueType d[3] ) const ; virtual valueType Dx( valueType x, valueType y ) const ; virtual valueType Dy( valueType x, valueType y ) const ; //! Second derivative virtual void DD( valueType x, valueType y, valueType dd[6] ) const ; virtual valueType Dxx( valueType x, valueType y ) const ; virtual valueType Dxy( valueType x, valueType y ) const ; virtual valueType Dyy( valueType x, valueType y ) const ; } ; /* // ____ _ ____ _ _ ____ _ _ // | __ )(_)/ ___| _| |__ (_) ___/ ___| _ __ | (_)_ __ ___ // | _ \| | | | | | | '_ \| |/ __\___ \| '_ \| | | '_ \ / _ \ // | |_) | | |__| |_| | |_) | | (__ ___) | |_) | | | | | | __/ // |____/|_|\____\__,_|_.__/|_|\___|____/| .__/|_|_|_| |_|\___| // |_| */ //! cubic spline base class class BiCubicSpline : public BiCubicSplineBase { virtual void makeSpline() ; public: //! spline constructor BiCubicSpline( string const & name = "Spline", bool ck = false ) : BiCubicSplineBase( name, ck ) {} virtual ~BiCubicSpline() {} //! Print spline coefficients virtual void writeToStream( ostream & s ) const ; //! Return spline typename virtual char const * type_name() const ; } ; /* // _ _ _ ____ ____ _ _ // / \ | | _(_)_ __ ___ __ _|___ \| _ \ ___ _ __ | (_)_ __ ___ // / _ \ | |/ / | '_ ` _ \ / _` | __) | | | / __| '_ \| | | '_ \ / _ \ // / ___ \| <| | | | | | | (_| |/ __/| |_| \__ \ |_) | | | | | | __/ // /_/ \_\_|\_\_|_| |_| |_|\__,_|_____|____/|___/ .__/|_|_|_| |_|\___| // |_| */ //! cubic spline base class class Akima2Dspline : public BiCubicSplineBase { virtual void makeSpline() ; public: //! spline constructor Akima2Dspline( string const & name = "Spline", bool ck = false ) : BiCubicSplineBase( name, ck ) {} virtual ~Akima2Dspline() {} //! Print spline coefficients virtual void writeToStream( ostream & s ) const ; //! Return spline typename virtual char const * type_name() const ; } ; /* // ____ _ ___ _ _ _ ____ _ _ ____ // | __ )(_)/ _ \ _ _(_)_ __ | |_(_) ___/ ___| _ __ | (_)_ __ ___| __ ) __ _ ___ ___ // | _ \| | | | | | | | | '_ \| __| |/ __\___ \| '_ \| | | '_ \ / _ \ _ \ / _` / __|/ _ \ // | |_) | | |_| | |_| | | | | | |_| | (__ ___) | |_) | | | | | | __/ |_) | (_| \__ \ __/ // |____/|_|\__\_\\__,_|_|_| |_|\__|_|\___|____/| .__/|_|_|_| |_|\___|____/ \__,_|___/\___| // |_| */ //! Bi-quintic spline base class class BiQuinticSplineBase : public SplineSurf { protected: vector<valueType> DX, DXX, DY, DYY, DXY, DXYY, DXXY, DXXYY ; mutable valueType u[6] ; mutable valueType u_D[6] ; mutable valueType u_DD[6] ; mutable valueType v[6] ; mutable valueType v_D[6] ; mutable valueType v_DD[6] ; mutable valueType bili5[6][6] ; void load( sizeType i, sizeType j ) const ; public: //! spline constructor BiQuinticSplineBase( string const & name = "Spline", bool ck = false ) : SplineSurf( name, ck ) , DX() , DXX() , DY() , DYY() , DXY() {} virtual ~BiQuinticSplineBase() {} valueType DxNode ( sizeType i, sizeType j ) const { return DX[ipos_C(i,j)] ; } valueType DyNode ( sizeType i, sizeType j ) const { return DY[ipos_C(i,j)] ; } valueType DxxNode( sizeType i, sizeType j ) const { return DXX[ipos_C(i,j)] ; } valueType DyyNode( sizeType i, sizeType j ) const { return DYY[ipos_C(i,j)] ; } valueType DxyNode( sizeType i, sizeType j ) const { return DXY[ipos_C(i,j)] ; } //! Evaluate spline value virtual valueType operator () ( valueType x, valueType y ) const ; //! First derivative virtual void D( valueType x, valueType y, valueType d[3] ) const ; virtual valueType Dx( valueType x, valueType y ) const ; virtual valueType Dy( valueType x, valueType y ) const ; //! Second derivative virtual void DD( valueType x, valueType y, valueType dd[6] ) const ; virtual valueType Dxx( valueType x, valueType y ) const ; virtual valueType Dxy( valueType x, valueType y ) const ; virtual valueType Dyy( valueType x, valueType y ) const ; } ; /* // ____ _ ___ _ _ _ ____ _ _ // | __ )(_)/ _ \ _ _(_)_ __ | |_(_) ___/ ___| _ __ | (_)_ __ ___ // | _ \| | | | | | | | | '_ \| __| |/ __\___ \| '_ \| | | '_ \ / _ \ // | |_) | | |_| | |_| | | | | | |_| | (__ ___) | |_) | | | | | | __/ // |____/|_|\__\_\\__,_|_|_| |_|\__|_|\___|____/| .__/|_|_|_| |_|\___| // |_| */ //! cubic spline base class class BiQuinticSpline : public BiQuinticSplineBase { virtual void makeSpline() ; public: //! spline constructor BiQuinticSpline( string const & name = "Spline", bool ck = false ) : BiQuinticSplineBase( name, ck ) {} virtual ~BiQuinticSpline() {} //! Print spline coefficients virtual void writeToStream( ostream & s ) const ; //! Return spline typename virtual char const * type_name() const ; } ; } namespace SplinesLoad { using Splines::Spline ; using Splines::BSpline ; using Splines::CubicSplineBase ; using Splines::CubicSpline ; using Splines::AkimaSpline ; using Splines::BesselSpline ; using Splines::PchipSpline ; using Splines::LinearSpline ; using Splines::ConstantSpline ; using Splines::QuinticSpline ; using Splines::BilinearSpline ; using Splines::BiCubicSpline ; using Splines::BiQuinticSpline ; using Splines::Akima2Dspline ; using Splines::SplineSet ; using Splines::SplineType ; using Splines::quadraticRoots ; using Splines::cubicRoots ; } #ifdef __GCC__ #pragma GCC diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic pop #endif #endif
OTSimulation/otSim
3rdparty/Splines/src/Splines.hh
C++
mit
84,233
@import url(https://fonts.googleapis.com/css?family=Roboto); html, body { width: 100%; height: 100%; margin: 0; padding: 0; font-family: 'Roboto', sans-serif; } div, h2 { padding: 20px; text-align: center; } h2{ visibility: hidden }
orthros/dart-epub
example/web_ex/web/styles.css
CSS
mit
252
/* ----- Code 3 of 9 Font ----- */ @font-face { font-family: 'Code3of9'; src: url('../font/code3of9.eot'); src: url('../font/code3of9.eot'), url('../font/code3of9.woff') format('woff'), url('../font/code3of9.ttf') format('truetype'), url('../font/code3of9.svg#code_3_of_9regular') format('svg'); } @font-face { font-family: 'Code3of9'; src: url('../font/code3of9-bold.eot'); src: url('../font/code3of9-bold.eot'), url('../font/code3of9-bold.woff') format('woff'), url('../font/code3of9-bold.ttf') format('truetype'), url('../font/code3of9-bold.svg#code_3_of_9bold') format('svg'); font-weight: bold; } @font-face { font-family: 'Code3of9'; src: url('../font/code3of9.eot'); src: url('../font/code3of9.eot'), url('../font/code3of9.woff') format('woff'), url('../font/code3of9.ttf') format('truetype'), url('../font/code3of9.svg#code_3_of_9regular') format('svg'); font-style: italic; } @font-face { font-family: 'Code3of9'; src: url('../font/code3of9-bold.eot'); src: url('../font/code3of9-bold.eot'), url('../font/code3of9-bold.woff') format('woff'), url('../font/code3of9-bold.ttf') format('truetype'), url('../font/code3of9-bold.svg#code_3_of_9bold') format('svg'); font-weight: bold; font-style: italic; } @font-face { font-family: 'Code3of9'; src: url('../font/code3of9.eot'); src: url('../font/code3of9.eot'), url('../font/code3of9.woff') format('woff'), url('../font/code3of9.ttf') format('truetype'), url('../font/code3of9.svg#code_3_of_9regular') format('svg'); font-style: oblique; } @font-face { font-family: 'Code3of9'; src: url('../font/code3of9-bold.eot'); src: url('../font/code3of9-bold.eot'), url('../font/code3of9-bold.woff') format('woff'), url('../font/code3of9-bold.ttf') format('truetype'), url('../font/code3of9-bold.svg#code_3_of_9bold') format('svg'); font-weight: bold; font-style: oblique; } .code39, .barcode { font-family: 'Code3of9'; background-color: #fff; color: #000; line-height: 3em; white-space: nowrap; } .barcode::before { content: '_('; } .barcode::after { content: ')_'; } .barcode.barcode-md, .code39.barcode-md { font-size: 150%; } .barcode.barcode-lg, .code39.barcode-lg { font-size: 200%; } .barcode.barcode-box, .code39.barcode-box { outline: 0.15em solid #f00; padding-top: 0.1em; }
vinorodrigues/font-code3of9
css/code3of9.css
CSS
mit
2,386
JSchema.Binding =============== *Data-driven events and validation for your javascript applications* About ----- JSchema.Binding is a lightweight framework for managing complex, data-driven UIs. It allows for binding UI callbacks to data *Models* (or classes) and *Records* (or instances), and for manipulating those records' data. It also provides JSON schema validation over record data using [JSV](https://github.com/garycourt/JSV) internally to check changes in real time. In a nutshell, it basically serves to keep your UI fresh, synchronised, valid and responsive. Everything else is up to you. If you already use JSON schema with your application, think of JSchema.Binding as adding state to your validation.<br /> For simple data manipulation tasks or applications without the need for clientside data validation, Binding is a more than adequate event engine and data handling layer all on its own - just pass `false` insted of a schema when creating new Models. Binding performs no ajax operations and is not a full MVC framework, but could easily be used as a strong foundation to build one. If you are after something more heavyweight, try the excellent [Backbone.js](http://backbonejs.org/) (which indeed influences some of Binding's design). Please note: you should clone this repository with `git clone --recursive`. Features -------- - **Powerful event engine**<br /> JSchema.Binding's event engine combines namespaced events to allow for fine-grained update callbacks with namespace wildcards to allow even more control. JSchema.EventHandler also provides a robust layer for implementing events on any other non-DOM javascript objects in your applications. - **Event namespacing**<br /> Allows responding to changes in object subproperties with infinite granularity - A modification to the object `addEvent('change', ...);` - A deletion within the object `addEvent('change.delete', ...);` - An update to *propertyA* `addEvent('change.update.propertyA', ...);` - An update to *propertyA* of *objectB* `addEvent('change.update.objectB.propertyA', ...);` - **Event bubbling**<br /> Changes to deeply nested object properties bubble up to their parents with the correct parameters being passed back to bound callbacks. So a change to *objectA.propertyB* would first fire callbacks with the values for *propertyB*, and then again with values for *objectA*. Bubbling can be aborted by returning `false` in callbacks, just like with DOM events. This allows you stop bubbling back up the callback namespace chain early once you have processed everything relevant to a change. - **Callback wildcards**<br /> Allows binding events with even finer control, for example: - An update to *propertyA* `addEvent('change.update.propertyA', ...);` - *propertyA* being initialised `addEvent('change.create.propertyA', ...);` - Any type of modification to *propertyA* `addEvent('change.?.propertyA', ...);` - An update to the record's *propertyA*, or to any *propertyA* within any subobjects of the record `addEvent('change.update.*.propertyA', ...);` - **Event marshalling**<br /> Allows events to be pooled, combined and fired as a single logical 'change'. - **Callback data consistency**<br /> Record state is predictable in all callbacks - firing is deferred until the state of the object has completed updating. - **Change handling**<br /> Records can be checked for modifications to allow intelligent serverside data pushing, and uploaded propertysets can be refined to only those modified. Snapshots of data can be taken at any point in time and compared with one another or checked for changes easily. - **JSON schema validation**<br /> Naturally, all changes to data objects are validated against your schema in real-time and can provide feedback of any changes and errors straight to your UI or other application code. - **Enhanced errors**<br /> JSV's standard error objects are augmented with attributes for the current value, - **Error bubbling**<br /> Using the same event mechanism as with change events, errors bubble up to their parent properties. The array of schema error data at each point in the chain contains all errors relevant for that object and all its child properties. - **Record composition**<br /> Record instances can be seamlessly inserted into each other providing for composite data relationships and sharing of data between records. JSchema allows you to deal directly with the data whilst ensuring that changes to attributes from a parent record immediately propagate to attributes shared with their children, and from child records back up to their parents. - **ID tracking**<br /> When configured to do so, record IDs are automatically tracked and record instances can be retrieved from your models via `getRecordById()`. Compatibility ------------- JSchema.Binding has minimal coupling to any library and uses jQuery only for utility methods. Separate branches exist for compatibility with other libraries, and lines of code dependency are clearly denoted by the comment `LIBCOMPAT`. **Branches**: - `git checkout mootools` (:TODO:) Usage ----- The first thing you'll want to do with a Binding instance is create a *model* (think 'class') for it. To do this, you simply call `JSchema.Binding.Create(schema, options)`: > **Schema**<br /> > The JSON schema document used to validate this record, as a javascript object. > > **Options**<br /> > A map of options for the new record class. > >> - `idField` Setting this property enables you to manage your record objects by primary key or other dentifying information, using the Record method `getId()` to retrieve object IDs, and Model method `getRecordById()` to retrieve record instances by those IDs. > - `doCreateEvents` If true, callbacks bound to any create events will fire when instantiating the record. Defaults to false. >> - `clearIdOnClone` If true, records cloned from others will have their IDs reset. Defaults to false. Do not enable this if your schema prohibits records without an ID field! >> - `validateCreation` If true, records should be validated when they are initialised for the first time. Defaults to false. Once you have your model ready, you can bind events to it and begin creating instances: ``` var person = JSchema.Binding.Create({ ... }); person.prototype.addEvent('change.update.name', function(newName) { alert('My name is now ' + newName); }); var Jimmy = new person({ ... }); Jimmy.set({name : 'Denny'}); // "My name is now Denny" ``` You can add events to particular instances too, if you wish: ``` Jimmy.addEvent('change.update.name', function() { alert('Thank god! Jimmy changed his name back.'); }); Jimmy.set({name : 'Jimmy'}); // "Thank god! Jimmy changed his name back." // "My name is now Jimmy" ``` In normal usage, you'll probably first want to pull down your JSON schema files and record data from an external source. You would typically do something like the following: // create a data model for validation var schema = jQuery.getJSON(/* some URL containing a validation schema... */); var Model = JSchema.Binding.Create(schema, { idField : 'record_id', clearIdOnClone : true }); // bind some events to these records Model.addEvent('change', function(record, prevData) { // update something... }); // ... // load and create a record var data = jQuery.getJSON(/* some URL containing a record... */); var something = new Model(data); // updating the record triggers events something.set({ someProperty : 'some value' }); // change callback triggered, something updated! // later in our program, we can check if the record needs saving... if (something.isDirty()) { // and update by posting the entire record back... jQuery.post(/* some URL for updating the record */, something.getAll()); // ...or just the changes. jQuery.post(/* some URL for updating the record */, something.getChangedAttributes()); // note that we would call something.changesPropagated() upon a successful POST call being completed } My APIs, Let Me Show You Them ----------------------------- ### Events ### JSchema.Binding records recognise the following events: - `error`<br /> Fires in response to an error updating the data record. Receives as parameters the record instance and an array of error objects from JSV, augmented with some of Binding's own: ``` { "uri": "URI of the instance that failed to validate", "schemaUri": "URI of the schema instance that reported the error", "attribute": "The attribute of the schema instance that failed to validate", "message": "Error message", "details": // The value of the schema attribute that failed to validate // JSchema.Binding properties "recordProperty" : // the dot-notated index of the property which failed to validate "current" : // the current, (assumedly) valid value of the errored property "invalid" : // the value of the passed property which invalidated the record } ``` Error callbacks can also be bound to specific properties within the object using dot notation. When bound, these callbacks will recieve the record instance, invalid value that broke the record, dot-notated index of the invalid property and the relevant error object from JSV. One callback is fired for each error object passed to the top-level error callback. - `change`<br /> Fires in response to a change in the record. Receives the current record instance and previous data bundle as parameters. - `change.update`<br /> Fires in response to an update of the record, or an update of a particular value on the record. Receives as parameters the current record instance, previous value, new value, dot-notated index of the property modified and name of the event fired. This callback, as well as `change.create` and `change.delete`, can also be bound to any number of subnamespaces, denoting indexes into the data record and its subproperties. - `change.create`<br /> Fires in response to a property initialisation within the record, in the same manner as `change.update`. The previous value will be undefined in this case. - `change.delete`<br /> Fires in response to a property being deleted within the record, in the same manner as `change.update`. The new value will be undefined in this case. ### Methods ### ### Global Methods ### These methods can be found on the global `JSchema` object. - `registerSchema(schema, uri)`<br /> Allows registering a schema definition with JSV, in order for other schemas to be able to reference it by its URI. If the uri is ommitted, the `id` field of the schema itself will be used instead. - `getSchema(uri)`<br /> Allows retrieving a schema previously registered with `registerSchema()`. - `isRecord(thing[, model])`<br /> Determine whether the passed argument is a JSchema.Binding data record. If the `model` parameter is provided, the method also checks whether the record is an instace of the given model. - `isModel(thing)`<br /> Determine whether the passed argument is a JSchema.Binding data model ### Model Methods ### These methods are available to record Model instances. - `getRecordById(id)`<br /> When the `idField` option is provided, records are automatically referenced in their corresponding models. This method can be used to retrieve them by those IDs. - `getInstanceCount(includeNew = false)`<br /> Retrieve the number of active Records of this Model. By default, only saved records (those with IDs) are returned. To return all objects, pass <tt>true</tt>. - `getAllInstances(includeNew = false)`<br /> Get a map of all active records, indexed by ID. If <tt>true</tt> is passed, unsaved records will be returned as well under the indexes '<tt>new#0</tt>', '<tt>new#1</tt>' etc ### Record Methods ### These methods are available to all individual Record instances. #### Event Handling (`JSchema.EventHandler`) #### - `addEvent(eventName, callbackFn, [context])`<br /> Bind a callback to an event on an object. Optional third parameter specifies the 'this' argument of the callback function. Also available to Model instances. - `addEvents(events)`<br /> Bind a number of callbacks to various events all at once. Callbacks will be bound to events matching the key names of the passed object. Also available to Model instances. - `removeEvent([eventName, [callback]])`<br /> Unregister previously bound callback events. You can remove all events by passing no arguments, a whole callback set by passing the callback name, and a specific callback by passing the callback name and bound function. Also available to Model instances. - `holdEvents()`<br /> Begins event marshalling: data modification will not execute event callbacks, but instead keep a cache of all callbacks called while in this state. Calling `fireHeldEvents()` will execute all callbacks fired while in this state. Usually (as with the below event methods) used internally by JSchema.Binding, but useful elsewhere as well. - `eventQueued(eventName)`<br /> Checks whether an event has been fired whilst marshalling. - `unfireEvent(eventName)`<br /> Remove an event called whilst marshalling from the called event cache to prevent it from firing when marshalled events are applied. - `abortHeldEvents()`<br /> Stop holding events from firing and clear out the held event cache. - `fireHeldEvents()`<br /> Merge and fire all events accumulated during the last hold phase. - `fireEvent(eventName, ...)`<br /> Fire an arbitrarily named event, passing all arguments following the event name to matching callback functions. Callbacks matching all namespaces of the event will be called upward in turn, unless `false` is returned from one of the callbacks to abort the bubbling. - `fireEventUntilDepth(eventName, depthToStopAt = 0, ...)`<br /> Fire event callbacks matching this event, but only up to a certain namespace depth. #### Data Manipulation #### * `set()`<br /> Sets data on a record. Note that all data manipulation operations can be performed with `set()`, they exist mostly for convenience. Accepts two paramter formats: * `object`, `bool`<br /> Merges this object's values in with the record's. To unset values, set `undefined` in their place. The second parameter controls whether (true) or not (false) to suppress event firing. * `string`, `mixed`, `bool`<br /> Sets the attribute at this index (specified by dot notation). Param 2 is the value to set, param 3 controls whether (true) or not (false) to suppress event firing. * `setId(newId)`<br /> Sets the record's Id, which can be any scalar value. `idField` must be configured in options for this method to work. * `unset(attribute, suppressEvent)`<br /> Unsets one of the record's attributes. Accepts 2 parameters: the property to erase (dot notation) and a boolean to allow suppressing event firing. * `clear(suppressEvent)`<br /> Clear all data from the record. You may wish to override this method to reset the record's data to a clean state if your schema prohibits an empty record. * `push(attribute, value, suppressEvent)`<br /> Helper for array data. Allows you to append to arrays using dot notation to locate the array in the record. Accepts the attribute index, value to append and the usual flag to suppress events. * `pop(attribute, suppressEvent)`<br /> Helper for array data. Removes the last element of the specified array attribute. * `clone(cloneEvents)`<br /> Creates a duplicate of the record. If `true` is passed, the original record's instance events are copied as well. If the record's `idField` and `clearIdOnClone` options are set, this may also clear the new record's id attribute. #### Data Validation #### * `validate(newData)`<br /> Manually perform validation of some data against the record. The supplied data will be merged in to the record's current attributes and checked for validity. * `pauseValidation()`<br /> Pause all validation when setting data on the object. * `resumeValidation()`<br /> Resume validation after pausing it to forcibly update the record to an invalid state. * `setSchema(schema)`<br /> Changes the schema used to validate the object. #### Data Reading #### - `isNew()`<br /> Checks whether the record is new. Only works if the `idField` option has been set. - `has(attribute)`<br /> Checks whether an attribute has been set. The attribute is specified in dot notation. - `get(attribute)`<br /> Retrieve a specific data member. The value index in the record is passed in dot notation. - `getId()`<br /> Return the record's ID. Only works if `idField` has been set. - `getAttributes()` / `getAll()`<br /> Retrieve a copy of the complete data record from the Binding. - `getSubrecord(attribute)`<br /> Works as with `get()`, except that only subattributes which are instances of other JSchema records will be returned. Used for pulling child record objects back out of their parents after injection. #### Change Handling #### - `saveState(key)`<br /> Records the attributes of the model as they are now into an internal cache by the name `key`. This can then be used with other change handling methods to query the state of the object between two distinct known times. - `eraseState(key)`<br /> Deletes a state previous saved with `saveState()`. - `revertToState(key)`<br /> Reverts a record to one of its previously saved states. Note that this does not remove the state or perform any kind of 'undo stack' operation, all prior saved states will persist. Any changes to the record will fire as usual. - `getPrevious(attribute, since)`<br /> Retrieve a particular attribute from before the last change using dot notation, or from a particular point in time (previously stored by `saveState()`) if `since` is specified. - `getPreviousAttributes(since)`<br /> Gets the full record from before the last change, or from a particular point in time if `since` is passed. - `hasChanged(attribute, since)`<br /> Check whether the record has changed since last edit or a saved state. If an attribute is specified, checks this property for changes. You may pass `(null, 'statename')` to determine whether the entire record has changed since a previous saved state. - `getChangedAttributes(includePrev, old, now)`<br /> By default, returns an object containing all properties modified in the last edit action. If `includePrev = true`, each value will instead be a 2 element array of the old and new values.<br /> `old` and `now` can be used to check changes between other sets of record attributes - for example, to check changes between the current record and an old state, use `getChangedAttributes(false, myRecord.getPreviousAttributes('oldState'))`. - `isDirty()`<br /> Allows client code to flag to this record that clientside changes to it have been dealt with in some way (propagated to server etc). This method queries whether the record needs saving. - `changesPropagated()`<br /> Flag that changes have been dealt with and reset the status of `isDirty()`. ### Utility Methods ### These methods are internal to JSchema most of the time, but they're there to use if you wish. - `JSchema.pathToSchemaUri(attr, backwards, schema, model)`<br /> Provides translation between the dot-notation syntax used by JSchema and the internal URI format of any JSONSchema. When `backwards` is true, the translation is from a schema URI to JSchema dot-notated string. `model` is an internal argument and can optionally be provided to cache the schema's fragment identifier character somewhere for subsequent runs. - `JSchema.extendAndUnset()`<br /> Exactly the same as [jQuery's `extend()`](http://api.jquery.com/jQuery.extend/), except that it always expects variable length arguments and allows you to unset existing values in the first object by setting properties to `undefined` in subsequent objects. This method both augments the first object passed and returns it. - `JSchema.dotSearchObject(target, attr, returnParent, createSubobjects, topLevelSchema)`<br /> Manages dot notation handling of object properties. This method is capable of performing various tasks on objects depending on the arguments passed in: - To simply retrieve properties from a javascript object, pass the object in as `target` and the attribute to read as a string. The method returns the property or `undefined` if it doesn't exist. - For editing of objects, pass `returnParent = true`. The method then returns a 3-element array consisting of a reference to the object's parent element (or the original target object if reading a top-level property), index of the target object within the parent and dot-notated string targeting the parent element in the object's hierarchy. These three values can be used together to manipulate objects in any other way - deleting & changing values, popping from arrays or calling any other methods on subobjects with attached logic. - Setting deeply nested data can be automated by setting both `returnParent` and `createSubObjects` to `true`. When activated, rather than returning `undefined` when a value is not found, the function will recurse downward and add objects into the target at all passed indexes. Upon reaching the final index, the newly created parent object and other values are returned as before.<br /> If you are setting data within a data record, you may also pass a `topLevelSchema` to the function. This JSONSchema can be used to determine the correct parent datatypes of new values, creating arrays instead of objects as appropriate. - `JSchema.isEqual(a, b)`<br /> Compare any two variables for equality (probably) as efficiently as possible. This method is pretty much taken straight from [underscore.js](http://documentcloud.github.com/underscore/). TODO ---- ### Bugs ### - Fix revertToState() not clearing properties from the current object which aren't set in the reverting state (probably needs to get a diff of all elements, instead of stopping at top-level difference) - Archive old attributes when event deferring is enabled - (symptom?) while marshalling, subsequent edits to the same property only show as the final difference afterwards - Arrays - changing individual array elements directly doesnt fire events - when objects within arrays are set but unmodified, a change is detected on the object - fix trailing star wildcards skipping bottom-level events when bubbling property changes - \* wildcards appear to be working incorrectly with multiple levels ### Incomplete features ### - Record composition: - Fire events from changes in child records - fire `clear()` events properly - Add error callback value passing for dependencies - remove `clearIdOnClone` option or add `storeInstances` option to select between these behaviours - set cache threshold for ID tracking to limit record storage ### Additions ### - Retrieve & set default values from schema when creating records - events should fire from undefined => defaults - validate readonly properties - validate URI format - Allow creating separate environments with JSV - Expose more useful JSV methods & options - allow setting validateReferences & enforceReferences to false in JSV when loading - do mootools branch ### Review ### - fire events in correct order internally in databinding to reduce sort time when firing - ensure all callback contexts are being carried through to execution - refactor some duplicate EventHandler code for reuse Known Issues ------------ - Holding events masks the return values of `fireEvent()`, `fireHeldEvents()` etc and code will be unable to determine whether callbacks have been fired (these functions always return true while marshalling to keep any errors in your own code from being raised prematurely, if anyone has any ideas on how to handle this I'd be very interested to hear them!) - If no error callback is registered (which you should not really do anyway), invalid value setting while holding events with `holdEvents()` will trigger errors internally even if calling `abortHeldEvents()`. It will also prematurely trigger errors multiple times before `fireHeldEvents()` is called due to the same limitation. License ------- This software is provided under an MIT open source license, read the 'LICENSE.txt' file for details.
pospi/jschema.binding
README.md
Markdown
mit
24,298
<?php /** * render is really the entire framework, other than the conceptual layout: * It's a simple function to render a template, hold it for a moment, then * render a layout that can include the rendered template. */ function render($template, $layout = 'layout') { extract($GLOBALS); // Make global variables accessible to the template. ob_start(); // Hold the output of the template. // Load the template (with some filename extensions to keep things obvious, // but so we don't have to specify in the code.) include("templates/$template.template.php"); $content = ob_get_contents(); // Snag what was held. ob_end_clean(); // Clean out the buffer so we don't get two copies. // Now include the layout -- it can use $content to put the template // output where it belongs. include("templates/$layout.template.php"); }
aredridel/php-minimal-framework
framework.php
PHP
mit
862
// test the main pages are working describe('e2e: pages', function() { var ptor; beforeEach(function() { browser.get('/'); ptor = protractor.getInstance(); }); it('check the login page is accasible from the homepage and has a form', function() { element(by.css('a[href="/login"]')).click(); expect(ptor.getCurrentUrl()).toMatch(/\/login/); expect(ptor.findElement(protractor.By.tagName('form')).getAttribute('id')) .toMatch('login'); }); it('check the register page is accasible from the homepage and has a form', function() { element(by.css('a[href="/register"]')).click(); expect(ptor.getCurrentUrl()).toMatch(/\/register/); expect(ptor.findElement(protractor.By.tagName('form')).getAttribute('id')) .toMatch('registration'); }); });
anotheri/cleverstack-visualCaptcha-demo
frontend/tests/e2e/pages.test.js
JavaScript
mit
798
#Validate-Form : Credit Card This package extends the `Validate-Form` package found [here](https://github.com/AdamBrodzinski/validate-form) ## Setup `meteor add forms:validate-credit-card` ## Useage Simply add `data-credit-card` to your fields like so ```html <form id='new-user-form' class='validate'> <div class="form-group"> <input type="text" name="credit-card" data-onblur data-credit-card> </div> </form> ```
meteor-forms/validate-credit-card
README.md
Markdown
mit
432
using System.IO; namespace Id3Lib.Frames { [Frame("PCNT")] internal class FramePlayCounter : FrameBase { #region Ïîëÿ private byte[] _counter = { 0 }; #endregion #region Ñâîéñòâà public ulong Counter { get { return Memory.ToInt64(_counter); } set { _counter = Memory.GetBytes(value); } } #endregion #region Êîíñòðóêòîð public FramePlayCounter(string frameId) : base(frameId) { } #endregion #region Ìåòîäû public override void Parse(byte[] frame) { int index = 0; _counter = Memory.Extract(frame, index, frame.Length - index); } public override byte[] Make() { MemoryStream buffer = new MemoryStream(); BinaryWriter writer = new BinaryWriter(buffer); writer.Write(_counter); return buffer.ToArray(); } public override string ToString() { return null; } #endregion } }
kav-it/SharpLib
Source/SharpLib.Audio/Source/Id3/Frames/FramePlayCounter.cs
C#
mit
1,163
#!/usr/bin/env sh cd build ./bin.out cd ..
Jackojc/Clusterize
run.sh
Shell
mit
43
package models; /** * Created by AsTex on 28.06.2016. */ public class PatientModel { public String firstName; public String lastName; public String secondName; public String email; public String password; public String phone; public String location; public String gender; public String birthDate; public String policyNumber; public String apiKey; public PatientModel(String firstName, String secondName, String lastName, String birthDate, String gender, String policyNumber, String location, String phone, String email, String password) { this.firstName = firstName; this.lastName = lastName; this.secondName = secondName; this.email = email; this.password = password; this.phone = phone; this.location = location; this.gender = gender; this.birthDate = birthDate; this.policyNumber = policyNumber; } }
HealthCareLabs/CancerLab
Test/app/src/main/java/models/PatientModel.java
Java
mit
1,158
--- layout: default --- {% assign assets_base_url = site.url %} {% if site.cdn.jsdelivr.enabled %} {% assign assets_base_url = "https://cdn.jsdelivr.net/gh/" | append: site.repository | append: '@master' %} {% endif %} <section class="collection-head small geopattern" data-pattern-id="{{ page.title | truncate: 15, ''}}"> <div class="container"> <div class="columns"> <div class="column three-fourths"> <div class="collection-title"> <h1 class="collection-header">{{ page.title }}</h1> <div class="collection-info"> {% if page.date %} <span class="meta-info"> <span class="octicon octicon-calendar"></span> {{ page.date | date: "%Y/%m/%d" }} </span> {% endif %} {% for cat in page.categories %} <span class="meta-info"> <span class="octicon octicon-file-directory"></span> <a href="{{ site.url }}/categories/#{{ cat }}" title="{{ cat }}">{{ cat }}</a> </span> {% endfor %} {% if site.word_count.enabled %} <span class="meta-info"> <span class="octicon octicon-clock"></span> 共 {{ page.content | strip_html | strip_newlines | remove: " " | size }} 字,约 {{ page.content | strip_html | strip_newlines | remove: " " | size | divided_by: 350 | plus: 1 }} 分钟 </span> {% endif %} </div> </div> </div> <div class="column one-fourth mobile-hidden"> <div class="collection-title"> {% include sidebar-qrcode.html %} </div> </div> </div> </div> </section> <!-- / .banner --> <section class="container content"> <div class="columns"> <div class="column three-fourths" > {% include content-header-ad.html %} <article class="article-content markdown-body"> {{ content }} <!-- {% include copyright.html %} --> </article> <div class="share"> {% include sns-share.html %} </div> {% include content-footer-ad.html %} <div class="comment"> {% include comments.html %} </div> </div> <div class="column one-fourth"> {% include sidebar-search.html %} {% include sidebar-post-nav.html %} </div> </div> </section> <!-- /section.content -->
mafulong/mafulong.github.io
_layouts/post.html
HTML
mit
2,252
svg-icon ======== An ultimate svg icons collection DONE RIGHT, with **over 10,000 SVG icons** out of the box. ## [Homepage][homepage] ## Download You can download as many SVG icons as you need in [homepage][homepage], or download the whole collection via `npm`: ```shell npm install svg-icon --save ``` ## custom element files: ``` dist/ ├── svg-icon-element.js └── svg-icon-element.css ``` usage: ``` <svg-icon url="http://leungwensen.github.io/svg-icon/dist/sprite/symbol/logos.svg" type="si-logos-javascript"></svg-icon> ``` limitation: * [Can I use custom elements?](http://caniuse.com/#search=custom%20elements) * [webcomponentsjs](https://github.com/webcomponents/webcomponentsjs) ## use it locally ```shell # clone the project git clone https://github.com/leungwensen/svg-icon.git # install dependencies cd svg-icon npm i # startup a local server gulp ``` ## SVG icon collections name | id prefix | source | supported ----|----|----|---- ant-design | ant- | http://ant.design/#/components/icon | yes bootstrap | bootstrap- | https://github.com/twbs/bootstrap | yes devicons | dev- | https://github.com/vorillaz/devicons | yes elusive-iconfont | elusive- | https://github.com/reduxframework/elusive-iconfont | yes entypo | entypo- | https://github.com/danielbruce/entypo | yes evil-icons | evil- | https://github.com/outpunk/evil-icons | yes flag-icon | flag- | https://github.com/lipis/flag-icon-css | yes flat-ui | flat- | https://github.com/designmodo/Flat-UI | yes font-awesome | awesome- | https://github.com/FortAwesome/Font-Awesome | yes foundation | foundation- | https://github.com/zurb/foundation-icon-fonts | yes game-icons | game- | https://github.com/game-icons/icons | yes geomicons-open | geom- | https://github.com/jxnblk/geomicons-open | yes icomoon-free | icomoon- | https://github.com/Keyamoon/IcoMoon-Free | yes ioncons | ionic- | https://github.com/driftyco/ionicons | yes maki | maki- | https://github.com/mapbox/maki | yes map-icons | map- | https://github.com/scottdejonge/map-icons | yes material-design | material- | https://github.com/google/material-design-icons | yes metro-ui-css | metro- | https://github.com/olton/Metro-UI-CSS | yes mfglabs-iconset | mfglabs- | https://github.com/MfgLabs/mfglabs-iconset | yes octicons | oct- | https://github.com/primer/octicons | yes open-iconic | open- | https://github.com/iconic/open-iconic | yes payment-font | payment- | https://github.com/vendocrat/PaymentFont | yes payment-webfont | payment-web- | https://github.com/orlandotm/payment-webfont | yes semantic-ui | (oct-/awesome-) | https://github.com/Semantic-Org/Semantic-UI/ | yes simple-icons | simple- | https://github.com/danleech/simple-icons | yes subway | subway- | https://github.com/mariuszostrowski/subway | yes typicons | typcn- | https://github.com/stephenhutchings/typicons.font | yes weather-icons | weather- | https://github.com/erikflowers/weather-icons | yes windows-icons | windows- | https://github.com/Templarian/WindowsIcons | yes zero | zero- | src/zero | yes zocial | zocial- | https://github.com/smcllns/css-social-buttons | yes logos(svg porn) | logos- | http://svgporn.com | yes Need more? Please leave an [issue][issues] or a [pull request][pull-requests]. ## Build your own collection ### 1. Install `svg-icon` via `npm`: ```shell npm install svg-icon -g ``` ### 2. Define a collection file (JSON format, [demo](https://github.com/leungwensen/svg-icon/blob/master/src/collection/zfinder.json)) ### 3. Build it: ```shell svg-icon build --source $path/to/icons.json --target $path/to/dest --name wow ``` Now you have a SVG sprite file and a demo page. ``` $path/to/dest/wow/ ├── index.html └── svg-symbols.svg ``` ## Contribute ### How did you collect all these SVG icons? There are basically two kinds of icon collections, ones with SVG source files, and others with only icon fonts. * Those with SVG source files: I simply copy the icons to the dest folder, optimise them, trim the pads around every icon, and build an SVG sprite file from them. * Those with icon fonts: I need to separate every icon from a combined SVG font file(locating, transforming, etc.), optimise them, trim them, and build an SVG sprite. So the data flow is like: ``` Sources(SVG icons/icon fonts) ---separating/copying---> SVG icons ---optimising---> mid products(dist/svg/*) ---trimming---> final products(dist/trimmed-svg/*) ---building---> SVG sprite ``` ### Is the contributing toolchain ready for me? Yes, and no. The collection of 10,000+ SVG icons is mostly collected by nodejs scripts(check out these folders for details `bin/`, `gulp` and `lib` ). But I still have to write some code when I want to add icons from a new vendor into this project, because of the uncertainty of icon collections. If you are familiar with nodejs and SVG, and interested in making this collection more useful, please leave a [PR][pull-requests]. Feel free to contact me if you have any question. Of course, the quickest way to add your favorite icons here is to leave an [issue][issues], and let me do the rest for you ;-). ## References ### Projects inspired `svg-icon` * [evil-icons](https://github.com/outpunk/evil-icons) * [Font-Awesome-SVG-PNG](https://github.com/encharm/Font-Awesome-SVG-PNG) ### Projects powered `svg-icon` * [svgo](https://github.com/svg/svgo): transforming and optimizing SVG icons would be impossible without this awesome project. * [vinyl-fs](https://github.com/gulpjs/vinyl-fs): `gulp` and `vinyl-fs` helped me to process large amount of files without any pain. * [phantomjs](http://phantomjs.org/): it is the answer of lots of problems. * [a lot more](https://github.com/leungwensen/svg-icon/blob/master/package.json#L22) ## [Known issues][issues] [homepage]: http://leungwensen.github.io/svg-icon/ "homepage" [issues]: https://github.com/leungwensen/svg-icon/issues "issues" [pull-requests]: https://github.com/leungwensen/svg-icon/pulls "pull requests"
leungwensen/svg-icon
README.md
Markdown
mit
6,809
package unit
WindomZ/go-develop-kit
unit/unit.go
GO
mit
13
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.Similarity; import java.io.StringReader; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathFactory; import org.xml.sax.*; import org.w3c.dom.*; import com.Preprocessing.EscapeSpecialCharacters; public class XmlFileOperations { private String similarity = ""; private String metric = ""; private String numTopics = ""; private String numIterations = ""; private String optimization = ""; private String burninInterval = ""; private String posTags; private String stemmer; private String ngrams; private ArrayList<InputDocument> documentList; private Input in; /** * this method returns the Input of the xml file */ public Input getInput(String xml) throws Exception { parseInputXml(xml); in = new Input(); in.setSimilarity(similarity); in.setMetric(metric); if (similarity.equals("advancedsimilarity")) { in.setNumTopics(Integer.parseInt(numTopics)); in.setNumIterations(Integer.parseInt(numIterations)); in.setOptimization(Integer.parseInt(optimization)); in.setBurninInterval(Integer.parseInt(burninInterval)); } in.setPosTags(posTags); in.setStemmer(stemmer); in.setNgrams(Integer.valueOf(ngrams)); in.setDocumentList(documentList); return in; } /** * This method parses the xml file */ private void parseInputXml(String xml) throws Exception { EscapeSpecialCharacters preproc = new EscapeSpecialCharacters(); //replace <?xml version="1.0"?> if exist if (xml.contains("<?xml")) { xml = xml.replaceAll("\\<\\?xml(.+?)\\?\\>", "").trim(); } documentList = new ArrayList<>(); Document dom = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(xml)); dom = db.parse(is); Element doc = dom.getDocumentElement(); this.similarity = doc.getTagName(); this.metric = getTextValue(doc, "metric", 1); if (similarity.equals("advancedsimilarity")) { this.numTopics = getTextValue(doc, "numTopics", 1); this.numIterations = getTextValue(doc, "numIterations", 1); this.optimization = getTextValue(doc, "optimization", 1); this.burninInterval = getTextValue(doc, "burninInterval", 1); } //preprocessing this.posTags = getTextValue(doc, "POStags", 1); this.stemmer = getTextValue(doc, "stemmer", 1); this.ngrams = getTextValue(doc, "n-grams", 1); //documents InputDocument inDoc; NodeList nl = doc.getElementsByTagName("document"); for (int i = 1; i <= nl.getLength(); i++) { inDoc = new InputDocument(); inDoc.setId(getAttributeValue(doc, "document", "id", i)); inDoc.setType(getAttributeValue(doc, "document", "type", i)); inDoc.setUrl(getAttributeValue(doc, "document", "url", i)); inDoc.setMediasource(getAttributeValue(doc, "mediasource", "", i)); String temp = getTextValue(doc, "document", i); temp = preproc.escapeHtmlSpecialCharacters(temp); inDoc.setText(temp); documentList.add(inDoc); inDoc = null; } //dealoate dom = null; dbf = null; db = null; is = null; nl = null; } /** * this method parse the output of (topic modeling) xml file */ public ArrayList<TopicDocument> parseTopicXml(String xml) throws Exception { //replace <?xml version="1.0"?> if exist if (xml.contains("<?xml")) { xml = xml.replaceAll("\\<\\?xml(.+?)\\?\\>", "").trim(); } documentList = new ArrayList<>(); Document dom = null; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource is = new InputSource(new StringReader(xml)); dom = db.parse(is); XPathFactory xPathFactory = XPathFactory.newInstance(); XPath xPath = xPathFactory.newXPath(); XPathExpression xPathExpression = xPath.compile("//listOfDocs//document"); NodeList documentnodelist = (NodeList) xPathExpression.evaluate(dom, XPathConstants.NODESET); TopicDocument topicdoc; Topic topic; ArrayList<TopicDocument> topicdocList = new ArrayList<>(); for (int i = 0; i < documentnodelist.getLength(); i++) { Node documentnode = documentnodelist.item(i); Element documentElement = (Element) documentnode; ArrayList<Topic> topiclist = new ArrayList<>(); topicdoc = new TopicDocument(); topicdoc.setId(documentElement.getAttribute("id")); NodeList topicnodelist = documentnode.getChildNodes(); for (int j = 0; j < topicnodelist.getLength(); j++) { Node topicNode = topicnodelist.item(j); Element topicElement = (Element) topicNode; topic = new Topic(); Attr topicAtrr = topicElement.getAttributeNode("id"); topic.setId(topicAtrr.getValue()); Attr percentageAtrr = topicElement.getAttributeNode("percentage"); String temp = percentageAtrr.getValue(); temp = temp.replaceAll("%", ""); double percentage = Double.valueOf(temp); percentage = percentage / 100; topic.setPercentage(percentage); topiclist.add(topic); } topicdoc.setList(topiclist); topicdocList.add(topicdoc); } return topicdocList; } /** * This method returns the value of an element */ private String getTextValue(Element doc, String tag, int numOfElements) { String value = ""; NodeList nl; nl = doc.getElementsByTagName(tag); if (nl.getLength() > 0 && nl.item(numOfElements - 1).hasChildNodes()) { value = nl.item(numOfElements - 1).getFirstChild().getNodeValue(); } //dealocate nl = null; return value; } /** * This method returns the value of an attribute */ private String getAttributeValue(Element doc, String ElementTag, String AttributeTag, int numOfElements) { String value = ""; NodeList nl; nl = doc.getElementsByTagName(ElementTag); if (nl.getLength() > 0 && nl.item(numOfElements - 1).hasChildNodes()) { value = nl.item(numOfElements - 1).getAttributes().getNamedItem(AttributeTag).getNodeValue(); } //dealocate nl = null; return value; } /** * This method creates an xml file for topic modeling web service */ public String getTopicXml(Input in) throws Exception { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); // root elements Document doc = docBuilder.newDocument(); //modeling job Element modelingjobElement = doc.createElement("modelingjob"); doc.appendChild(modelingjobElement); //parameters Element parametersElement = doc.createElement("parameters"); modelingjobElement.appendChild(parametersElement); //num of topics Element numTopicsElement = doc.createElement("numTopics"); numTopicsElement.appendChild(doc.createTextNode(String.valueOf(in.getNumTopics()))); parametersElement.appendChild(numTopicsElement); //NumIterations Element numIterationsElement = doc.createElement("numIterations"); numIterationsElement.appendChild(doc.createTextNode(String.valueOf(in.getNumIterations()))); parametersElement.appendChild(numIterationsElement); //optimization Element optimizationElement = doc.createElement("optimization"); optimizationElement.appendChild(doc.createTextNode(String.valueOf(in.getOptimization()))); parametersElement.appendChild(optimizationElement); //burnInterval Element burnIntervalElement = doc.createElement("burninInterval"); burnIntervalElement.appendChild(doc.createTextNode(String.valueOf(in.getBurninInterval()))); parametersElement.appendChild(burnIntervalElement); //preprocessing Element preprocessingElement = doc.createElement("preprocessing"); modelingjobElement.appendChild(preprocessingElement); //POSTags Element postagElement = doc.createElement("POStags"); postagElement.appendChild(doc.createTextNode(in.getPosTags())); preprocessingElement.appendChild(postagElement); //stemmer Element stemmerElement = doc.createElement("stemmer"); stemmerElement.appendChild(doc.createTextNode(in.getStemmer())); preprocessingElement.appendChild(stemmerElement); //ngrams Element ngramsElement = doc.createElement("n-grams"); ngramsElement.appendChild(doc.createTextNode(String.valueOf(in.getNgrams()))); preprocessingElement.appendChild(ngramsElement); //documents Element documentsElement = doc.createElement("documents"); modelingjobElement.appendChild(documentsElement); ArrayList<InputDocument> documentList1 = in.getDocumentList(); for (InputDocument indoc : documentList1) { Element documentElement = doc.createElement("document"); documentElement.setAttribute("id", indoc.getId()); documentElement.setAttribute("type", indoc.getType()); documentElement.setAttribute("url", indoc.getUrl()); documentElement.setAttribute("mediasource", indoc.getMediasource()); documentElement.appendChild(doc.createTextNode(indoc.getText())); documentsElement.appendChild(documentElement); } // write the content into xml file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); doc.setXmlStandalone(true); DOMSource source = new DOMSource(doc); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); java.io.StringWriter sw = new java.io.StringWriter(); StreamResult sr = new StreamResult(sw); transformer.transform(source, sr); String xml = sw.toString(); //dealocate docFactory = null; docBuilder = null; doc = null; transformerFactory = null; transformer = null; source = null; sw = null; sr = null; return xml; } /** * This method creates the output xml file */ public String getOutputXml(ArrayList<OutputSimilarity> list, String metric) throws Exception { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); // root elements Document doc = docBuilder.newDocument(); Element similarityOutput = doc.createElement("similarityOutput"); doc.appendChild(similarityOutput); //metric element Element metricElement = doc.createElement("metric"); metricElement.appendChild(doc.createTextNode(metric)); similarityOutput.appendChild(metricElement); //result Element resultElement = doc.createElement("result"); similarityOutput.appendChild(resultElement); for (OutputSimilarity similarity : list) { //pair Element pairElement = doc.createElement("pair"); pairElement.setAttribute("firstID", similarity.getFirstId()); pairElement.setAttribute("secondID", similarity.getSecondId()); double temp = Double.parseDouble(similarity.getScore()); BigDecimal bd = new BigDecimal(temp); bd = bd.setScale(3, RoundingMode.HALF_UP); temp = bd.doubleValue(); pairElement.setAttribute("score", String.valueOf(temp) ); resultElement.appendChild(pairElement); //dealovate pairElement = null; } // write the content into xml file TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); doc.setXmlStandalone(true); DOMSource source = new DOMSource(doc); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); java.io.StringWriter sw = new java.io.StringWriter(); StreamResult sr = new StreamResult(sw); transformer.transform(source, sr); String xml = sw.toString(); //dealocate docFactory = null; docBuilder = null; doc = null; similarityOutput = null; transformerFactory = null; transformer = null; source = null; sw = null; sr = null; return xml; } }
DimitrisNik/Eu-Community
src/java/com/Similarity/XmlFileOperations.java
Java
mit
14,446
/*jslint indent: 2, maxlen: 80, continue: true, node: true, regexp: true*/ "use strict"; var dgram = require('dgram'), os = require('os'), url = require('url'), http = require('http'), util = require('util'), EventEmitter = require('events').EventEmitter, EasySax = require('easysax'), async = require("async"), Player = require('./player.js'), Sub = require('./sub.js'); var logger = require('./logger'); String.prototype.startsWith = function (str) { return this.indexOf(str) === 0; } // Handles parsing of time represented in the format "HH:mm:ss" String.prototype.parseTime = function () { var chunks = this.split(':').reverse(); var timeInSeconds = 0; for (var i = 0; i < chunks.length; i++) { timeInSeconds += parseInt(chunks[i], 10) * Math.pow(60, i); } return isNaN(timeInSeconds) ? 0 : timeInSeconds; } Number.prototype.zpad = function (width) { var str = this + ""; if (str.length >= width) return str; var padding = new Array(width - str.length + 1).join('0'); return padding + str; } Number.prototype.formatTime = function (alwaysHours) { var chunks = []; var modulus = [60^2, 60]; var remainingTime = this; // hours var hours = Math.floor(remainingTime/3600); if (hours > 0 || alwaysHours) { chunks.push(hours.zpad(2)); remainingTime -= hours * 3600; } // minutes var minutes = Math.floor(remainingTime/60); chunks.push(minutes.zpad(2)); remainingTime -= minutes * 60; // seconds chunks.push(remainingTime.zpad(2)) return chunks.join(':'); } String.prototype.format = function (replaceTable) { return this.replace(/{([a-z]+)}/gi, function (match) { return (replaceTable.hasOwnProperty(RegExp.$1)) ? replaceTable[RegExp.$1] : match; }); } function Discovery(settings) { var _this = this; var timeout; var subscriptionTimeout = 600; var groupVolumeTimer; this.toggleLED = false; this.ignoreFavoritesEvents = false; settings = settings || { household: null }; this.log = settings.log || logger.initialize(); // create a notify server, this will handle all events. var eventServer = http.createServer(handleEventNotification); var sids = {}; // This just keeps a list of IPs that responded to our search this.knownPlayers = []; // instance properties this.players = {}; // sub instance properties this.subs = {}; this.zones = []; this.subscribedTo = undefined; this.notificationPort = 3500; var SONOS_PLAYER_UPNP_URN = 'urn:schemas-upnp-org:device:ZonePlayer:1'; var PLAYER_SEARCH = new Buffer(["M-SEARCH * HTTP/1.1", "HOST: 239.255.255.250:reservedSSDPport", "MAN: ssdp:discover", "MX: 1", "ST: " + SONOS_PLAYER_UPNP_URN].join("\r\n")); var port = 1905; this.log.info("binding SSDP to port", port); var interfaces = os.networkInterfaces(); // find all ip addresses // We use a dummy for a special case where node can't list network interfaces (freeBSD) var sockets = {'dummy': null}; if (settings.disableIpDiscovery) { this.log.info("listen on 0.0.0.0"); } else { for (var name in interfaces) { _this.log.info('discovering all IPs from', name); interfaces[name].forEach(function (ipInfo) { if (ipInfo.internal == false && ipInfo.family == "IPv4") { // this one is interesting, use it delete sockets['dummy']; sockets[ipInfo.address] = null; } }); } this.log.info("relevant IPs", sockets); } // Now, create a socket for each ip for (var ip in sockets) { var socket = dgram.createSocket('udp4', function(buffer, rinfo) { var response = buffer.toString('ascii'); if(response.indexOf(SONOS_PLAYER_UPNP_URN) === -1) { // Ignore false positive from badly-behaved non-Sonos device. return; } var headerCollection = response.split('\r\n'); var headers = {}; if (_this.knownPlayers.indexOf(rinfo.address) > -1) { _this.knownPlayers.push(rinfo.address); } for (var i = 0; i < headerCollection.length; i++) { var headerRow = headerCollection[i]; if (/^([^:]+): (.+)/i.test(headerRow)) { headers[RegExp.$1] = RegExp.$2; } } if (!headers["LOCATION"]) return; if (settings.household && settings.household != headers["X-RINCON-HOUSEHOLD"]) return; // We found a player, reset the scan timeout clearTimeout(timeout); // We try to subscribe to the first unit we find trySubscribe( headers["LOCATION"], rinfo.address ); // OK, now close all sockets for (var ip in sockets) { sockets[ip].close(); } }); socket.on('error', function (e) { _this.log.error(e); }); socket.on('listening', function (socket) { return function () { socket.setMulticastTTL(2); clearTimeout(timeout); // Use a short timeout here, reset if we found players. timeout = setTimeout(scanDevices, 200); } }(socket)); if (ip == 'dummy') socket.bind(port); else socket.bind(port, ip); var lastSocket = socket; sockets[ip] = socket; } // search periodcally function scanDevices() { for (var ip in sockets) { _this.log.info("scanning for players in ip", ip); var socket = sockets[ip]; socket.send(PLAYER_SEARCH, 0, PLAYER_SEARCH.length, 1900, '239.255.255.250'); clearTimeout(timeout); // Use a short timeout here, reset if we found players. timeout = setTimeout(scanDevices, 2000); } } function handleEventNotification(req, res) { res.statusCode = 200; var buffer = []; req.setEncoding("utf-8"); req.on('data', function (chunk) { buffer.push(chunk); }); req.on('end', function () { res.end(); var saxParser = new EasySax(); var notifyState = { sid: req.headers.sid, nts: req.headers.nts }; saxParser.on('error', function (e) { _this.log.error(e, buffer.join("")); }); var nodeContent; saxParser.on('endNode', function (elem, attr, uq, tagend, getStrNode) { // ignored nodes if (elem == "e:property" || elem == "e:propertyset") return; //if (notifyState.type) return; notifyState.type = elem; if (elem == "ZoneGroupState") { updateZoneState( notifyState.body ); } else if (elem == "ContainerUpdateIDs") { if (notifyState.body.indexOf('Q:0') == -1) return; if (/uuid:(.+)_sub/.test(notifyState.sid)) _this.emit('queue-changed', {uuid: RegExp.$1}); } else if (elem == "FavoritesUpdateID") { if (!_this.ignoreFavoritesEvents) { _this.ignoreFavoritesEvents = true; clearTimeout(_this.ignoreFavoritesEventsTimeout); _this.ignoreFavoritesEventsTimeout = setTimeout(function () { _this.ignoreFavoritesEvents = false; }, 500); var player; for (var i in _this.players) { player = _this.players[i]; break; } if (!player) return; player.getFavorites(function (success, favorites) { if (!success) return; _this.emit('favorites', favorites); }); } } else { _this.emit('notify', notifyState); } }); saxParser.on('textNode', function (s, uq) { notifyState.body = uq(s); }); saxParser.parse(buffer.join("")); }); } function updateZoneState( xml ) { var saxParser = new EasySax(); var zones = []; var zone; saxParser.on('startNode', function (elem, attr) { if (elem == "ZoneGroup") { var attributes = attr(); zone = { uuid: attributes.Coordinator, id: attributes.ID, members: [] }; } else if (elem == "ZoneGroupMember") { var attributes = attr(); // This is a bridge or a stereo-paired player // This stereo pair check (the SW, SW part) is a bit of a hack, // but I can't find a better way to identify a paired speaker if (attributes.IsZoneBridge || attributes.Invisible && attributes.ChannelMapSet && attributes.ChannelMapSet.indexOf('SW,SW') == -1) return; if (!attributes.Invisible && !_this.players.hasOwnProperty(attributes.UUID)) { // This player doesn't exists, create it. var player = new Player(attributes.ZoneName, attributes.Location, attributes.UUID, _this); _this.players[attributes.UUID] = player; } else if (!attributes.Invisible) { var player = _this.players[attributes.UUID]; } // This is a sub else if (attributes.Invisible && !_this.subs.hasOwnProperty(attributes.UUID)) { var sub = new Sub(attributes.ZoneName, attributes.Location, attributes.UUID, _this); _this.subs[attributes.UUID] = sub; } else if (attributes.Invisible) { var sub = _this.subs[attributes.UUID]; } if (player) { zone.members.push(player); // Also, add coordinator if (zone.uuid == player.uuid) { zone.coordinator = player; } for (var i in _this.subs) { var sub = _this.subs[i]; if (sub.roomName.toLowerCase() == player.roomName.toLowerCase()) { player.sub=sub; } } } if (sub) { for (var i in _this.players) { var player = _this.players[i]; if (sub.roomName.toLowerCase() == player.roomName.toLowerCase()) { player.sub=sub; } } } } }); saxParser.on('endNode', function (elem) { if (elem == "ZoneGroup" && zone.members.length > 0) { // We ignore empty zones zones.push(zone); } }); saxParser.parse(xml); // update coordinator for each player zones.forEach(function (zone) { var coordinator = _this.players[zone.uuid]; zone.members.forEach(function (player) { player.coordinator = coordinator; }) }); _this.zones = zones; // Emit a zone change event _this.emit('topology-change', _this.getZones() ); } function trySubscribe( deviceDescription, address ) { if (_this.subscribedTo !== undefined) { return; } _this.log.info("subscribing to topology", address); _this.subscribedTo = address; var urlInfo = url.parse(deviceDescription); var options = { localAddress: _this.localEndpoint, hostname: urlInfo.hostname, path: urlInfo.path, port: urlInfo.port }; // Find local endpoint http.get(options, function (res) { // We want to know our endpoint IP to expose the correct event url // In case of multiple interfaces! _this.localEndpoint = res.socket.address().address; _this.log.info("using local endpoint", _this.localEndpoint); // We don't need anything more, subscribe subscribe('/ZoneGroupTopology/Event'); }); } function subscribe(path) { var headers = { 'TIMEOUT': 'Second-' + subscriptionTimeout }; if (sids[path]) { headers['SID'] = sids[path]; } else { headers['CALLBACK'] = '<http://'+ _this.localEndpoint +':' + _this.notificationPort + '/>'; headers['NT'] = 'upnp:event'; } var client = http.request({ host: _this.subscribedTo, port: 1400, path: path, method: 'SUBSCRIBE', headers: headers }, function (res) { // Store sid for renewal sids[path] = res.headers.sid; if (res.statusCode == 200) { setTimeout(function () { subscribe(path); }, subscriptionTimeout * 500); } else { _this.log.error("subscribe failed!", sids[path], res.statusCode); // we lost the subscription, clear sid delete sids[path]; // try again in 30 seconds setTimeout(function () { subscribe(path); }, 30000); } }); client.on('error', function (e) { // If this fails, this player has fallen of the grid _this.log.error(e); }); client.end(); } function decodeXML(str) { var replaceTable = { '&gt;': '>', '&lt;': '<', '&quot;': '"', '&amp;': '&' }; return str.replace(/&[^;];/, function (match) {return replaceTable[match] || match}); } this.getZones = function () { var response = []; _this.zones.forEach(function (zone) { var simpleZone = { uuid: zone.uuid, coordinator: zone.coordinator.convertToSimple(), members: [] }; zone.members.forEach(function (player) { var simplePlayer = player.convertToSimple(); simpleZone.members.push(simplePlayer); }); response.push(simpleZone); }); return response; } this.aggregateGroupVolume = function (volumeData) { clearTimeout(groupVolumeTimer); groupVolumeTimer = setTimeout(function () { _this.log.info('emitting group-volume'); _this.emit('group-volume', volumeData); }, 100); } eventServer.on('error', function (e) { if (e.code == 'EADDRINUSE') { _this.log.error("port in use", _this.notificationPort, "trying new one"); startServerOnPort(++_this.notificationPort); } }); eventServer.on('listening', function () { _this.log.info("notification server listening on port", _this.notificationPort); }); // Start the event server. function startServerOnPort(port) { eventServer.listen(port); } // trying to start on default port. on error, we will try and increment this. startServerOnPort(this.notificationPort); } util.inherits(Discovery, EventEmitter); Discovery.prototype.getPlayer = function (roomName) { for (var i in this.players) { var player = this.players[i]; if (player.roomName.toLowerCase() == roomName.toLowerCase()) { return player; } } } Discovery.prototype.getPlayerByUUID = function (uuid) { for (var i in this.players) { var player = this.players[i]; if (player.uuid == uuid) { return player; } } } Discovery.prototype.getSub = function (roomName) { for (var i in this.subs) { var sub = this.subs[i]; if (sub.roomName.toLowerCase() == roomName.toLowerCase()) { return sub; } } } Discovery.prototype.getSubByUUID = function (uuid) { for (var i in this.subs) { var sub = this.subs[i]; if (sub.uuid == uuid) { return sub; } } } // preset format, will be extended in the future. // The first player will become coordinator. It will automatically start playing // Will add support for random playback, gapless and all that later. // Will implement the possibility to add a Favorite as queue as well. // { // "players": [ // { "roomName": "room1", "volume": 15}, // {"roomName": "room2", "volume": 25} // ] // } Discovery.prototype.applyPreset = function (preset, callback) { console.log("applying preset", preset); this.log.info("applying preset", preset); // cache this reference for closure access var _this = this; if (!preset.players || preset.players.length == 0) { this.log.error("your preset doesn't contain any players"); return; } var playerInfo = preset.players[0]; var coordinator = this.getPlayer(playerInfo.roomName); var coordinatorVolume = playerInfo.volume; var asyncSeries = []; // If pauseothers, first thing, pause all zones if (preset.pauseOthers) { // We wanted to pause all others this.zones.forEach(function (i) { asyncSeries.push(function (callback) { i.coordinator.pause(function (success) { callback(null, 'pausing ' + i.coordinator.roomName); }); }); }); } // If coordinator already is coordinator, skip becomeCoordinatorOfStandaloneGroup // If only one player in preset, it should breakout never the less. if (coordinator.coordinator.uuid == coordinator.uuid && preset.players.length > 1) { this.log.info("skipping breakout because already coordinator"); // Instead we need to detach the players that don't belong. // Find the zone var zone; this.zones.forEach(function (i) { if (i.uuid == coordinator.uuid) { zone = i; } }); // okay found zone. Now, find out which doesn't belong. var playerNames = []; preset.players.forEach(function (playerInfo) { playerNames.push(playerInfo.roomName); }); zone.members.forEach(function (player) { if (playerNames.indexOf(player.roomName) == -1) { // not part of group, should be detached asyncSeries.push(function (callback) { player.becomeCoordinatorOfStandaloneGroup(function (success) { callback(null, 'breakout'); }); }); } }); } else { // This one is not coordinator, just detach it and leave it be. this.log.info("ungrouping", coordinator.roomName, "to prepare for grouping"); asyncSeries.push(function (callback) { coordinator.becomeCoordinatorOfStandaloneGroup(function (success) { callback(null, 'ungrouping'); }); }); } // Only set volume if defined if (coordinatorVolume !== undefined) { // Create a callback chain based on the preset asyncSeries.push(function (callback) { coordinator.setVolume(coordinatorVolume, function (success) { callback(null, 'set volume, coordinator'); }); }); } if (preset.favorite) { asyncSeries.push(function (callback) { coordinator.replaceWithFavorite(preset.favorite, function (success) { callback(null, 'applying favorite'); }); }); } else if (preset.uri) { asyncSeries.push(function (callback) { coordinator.setAVTransportURI(preset.uri, null, function (success) { callback(null, 'setting uri'); }); }); } if (preset.playMode) { asyncSeries.push(function (callback) { coordinator.setPlayMode(preset.playMode, function (success) { callback(null, 'set playmode'); }); }); } for (var i = 1; i < preset.players.length; i++) { var playerInfo = preset.players[i]; var player = _this.getPlayer(playerInfo.roomName); if (!player) { _this.log.error("invalid playerName", playerInfo.roomName); continue; } var streamUrl = "x-rincon:" + coordinator.uuid; if (player.uuid != coordinator.uuid && player.avTransportUri != streamUrl) { asyncSeries.push(function (player, streamUrl) { return function (callback) { player.setAVTransportURI(streamUrl, null, function (success) { callback(success ? null : 'error in setAVTransportURI', 'AVTransportURI'); }); } }(player, streamUrl)); } if (playerInfo.volume !== undefined) { asyncSeries.push(function (player, volume) { return function (callback) { player.setVolume(volume, function (success) { callback(null, 'volume for ' + player.roomName); }); } }(player, playerInfo.volume)); } } if (preset.trackNo) { asyncSeries.push( function (callback) { coordinator.seek(preset.trackNo, function (success) { // we don't care if this breaks or not. callback(null, 'seek'); }); }); } if (preset.elapsedTime) { asyncSeries.push( function (callback) { coordinator.trackSeek(preset.elapsedTime, function (success) { // we don't care if this breaks or not. callback(null, 'trackSeek'); }); }); } if (preset.sleep !== undefined) { asyncSeries.push(function (callback) { coordinator.sleep(preset.sleep, function (success) { // we don't care if this breaks or not. callback(null, 'sleep'); }); }); } async.series(asyncSeries, function (err, result) { if (!preset.state || preset.state.toLowerCase() == "playing") coordinator.play(function (success) { if (callback instanceof Function) callback(success ? null : 'error on play', result); }); else if (callback instanceof Function) callback(err, result); }); } Discovery.prototype.setToggleLED = function (enabled) { this.toggleLED = enabled; this.log.info("update players with setToggleLED"); this.on('transport-state', function (player) { // get zone var zone; for (var i in this.zones) { if (this.zones[i].uuid == player.uuid) { zone = this.zones[i]; break; } } if (!zone) return; zone.members.forEach(function (member) { member.toggleLED(player.state.zoneState == "PLAYING"); }); }); } Discovery.prototype.getAnyPlayer = function () { // returns the player to which we subscribed for topology changes on. Can be anyone, doesn't matter for (var i in this.players) { return this.players[i]; } return null; } module.exports = Discovery;
donholly/alexa-at-home
node_modules/sonos-discovery/lib/sonos.js
JavaScript
mit
21,059
/* * Farseer Physics Engine based on Box2D.XNA port: * Copyright (c) 2010 Ian Qvist * * Box2D.XNA port of Box2D: * Copyright (c) 2009 Brandon Furtwangler, Nathan Furtwangler * * Original source Box2D: * Copyright (c) 2006-2009 Erin Catto http://www.gphysics.com * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ using GameLibrary.Dependencies.Physics.Common; using Microsoft.Xna.Framework; using System; using System.Diagnostics; namespace GameLibrary.Dependencies.Physics.Dynamics.Joints { // Linear constraint (point-to-line) // d = p2 - p1 = x2 + r2 - x1 - r1 // C = dot(perp, d) // Cdot = dot(d, cross(w1, perp)) + dot(perp, v2 + cross(w2, r2) - v1 - cross(w1, r1)) // = -dot(perp, v1) - dot(cross(d + r1, perp), w1) + dot(perp, v2) + dot(cross(r2, perp), v2) // J = [-perp, -cross(d + r1, perp), perp, cross(r2,perp)] // // Angular constraint // C = a2 - a1 + a_initial // Cdot = w2 - w1 // J = [0 0 -1 0 0 1] // // K = J * invM * JT // // J = [-a -s1 a s2] // [0 -1 0 1] // a = perp // s1 = cross(d + r1, a) = cross(p2 - x1, a) // s2 = cross(r2, a) = cross(p2 - x2, a) // Motor/Limit linear constraint // C = dot(ax1, d) // Cdot = = -dot(ax1, v1) - dot(cross(d + r1, ax1), w1) + dot(ax1, v2) + dot(cross(r2, ax1), v2) // J = [-ax1 -cross(d+r1,ax1) ax1 cross(r2,ax1)] // Block Solver // We develop a block solver that includes the joint limit. This makes the limit stiff (inelastic) even // when the mass has poor distribution (leading to large torques about the joint anchor points). // // The Jacobian has 3 rows: // J = [-uT -s1 uT s2] // linear // [0 -1 0 1] // angular // [-vT -a1 vT a2] // limit // // u = perp // v = axis // s1 = cross(d + r1, u), s2 = cross(r2, u) // a1 = cross(d + r1, v), a2 = cross(r2, v) // M * (v2 - v1) = JT * df // J * v2 = bias // // v2 = v1 + invM * JT * df // J * (v1 + invM * JT * df) = bias // K * df = bias - J * v1 = -Cdot // K = J * invM * JT // Cdot = J * v1 - bias // // Now solve for f2. // df = f2 - f1 // K * (f2 - f1) = -Cdot // f2 = invK * (-Cdot) + f1 // // Clamp accumulated limit impulse. // lower: f2(3) = max(f2(3), 0) // upper: f2(3) = min(f2(3), 0) // // Solve for correct f2(1:2) // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:3) * f1 // = -Cdot(1:2) - K(1:2,3) * f2(3) + K(1:2,1:2) * f1(1:2) + K(1:2,3) * f1(3) // K(1:2, 1:2) * f2(1:2) = -Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3)) + K(1:2,1:2) * f1(1:2) // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) + f1(1:2) // // Now compute impulse to be applied: // df = f2 - f1 /// <summary> /// A prismatic joint. This joint provides one degree of freedom: translation /// along an axis fixed in body1. Relative rotation is prevented. You can /// use a joint limit to restrict the range of motion and a joint motor to /// drive the motion or to model joint friction. /// </summary> public class FixedPrismaticJoint : PhysicsJoint { private Mat33 _K; private float _a1, _a2; private Vector2 _axis; private bool _enableLimit; private bool _enableMotor; private Vector3 _impulse; private LimitState _limitState; private Vector2 _localXAxis1; private Vector2 _localYAxis1; private float _lowerTranslation; private float _maxMotorForce; private float _motorMass; // effective mass for motor/limit translational constraint. private float _motorSpeed; private Vector2 _perp; private float _refAngle; private float _s1, _s2; private float _upperTranslation; /// <summary> /// This requires defining a line of /// motion using an axis and an anchor point. The definition uses local /// anchor points and a local axis so that the initial configuration /// can violate the constraint slightly. The joint translation is zero /// when the local anchor points coincide in world space. Using local /// anchors and a local axis helps when saving and loading a game. /// </summary> /// <param name="body">The body.</param> /// <param name="worldAnchor">The anchor.</param> /// <param name="axis">The axis.</param> public FixedPrismaticJoint(PhysicsBody body, Vector2 worldAnchor, Vector2 axis) : base(body) { JointType = JointType.FixedPrismatic; BodyB = BodyA; LocalAnchorA = worldAnchor; LocalAnchorB = BodyB.GetLocalPoint(worldAnchor); _localXAxis1 = axis; _localYAxis1 = MathUtils.Cross(1.0f, _localXAxis1); _refAngle = BodyB.Rotation; _limitState = LimitState.Inactive; } public Vector2 LocalAnchorA { get; set; } public Vector2 LocalAnchorB { get; set; } public override Vector2 WorldAnchorA { get { return LocalAnchorA; } } public override Vector2 WorldAnchorB { get { return BodyA.GetWorldPoint(LocalAnchorB); } set { Debug.Assert(false, "You can't set the world anchor on this joint type."); } } /// <summary> /// Get the current joint translation, usually in meters. /// </summary> /// <value></value> public float JointTranslation { get { Vector2 d = BodyB.GetWorldPoint(LocalAnchorB) - LocalAnchorA; Vector2 axis = _localXAxis1; return Vector2.Dot(d, axis); } } /// <summary> /// Get the current joint translation speed, usually in meters per second. /// </summary> /// <value></value> public float JointSpeed { get { Transform xf2; BodyB.GetTransform(out xf2); Vector2 r1 = LocalAnchorA; Vector2 r2 = MathUtils.Multiply(ref xf2.R, LocalAnchorB - BodyB.LocalCenter); Vector2 p1 = r1; Vector2 p2 = BodyB.Sweep.C + r2; Vector2 d = p2 - p1; Vector2 axis = _localXAxis1; Vector2 v1 = Vector2.Zero; Vector2 v2 = BodyB.LinearVelocityInternal; const float w1 = 0.0f; float w2 = BodyB.AngularVelocityInternal; float speed = Vector2.Dot(d, MathUtils.Cross(w1, axis)) + Vector2.Dot(axis, v2 + MathUtils.Cross(w2, r2) - v1 - MathUtils.Cross(w1, r1)); return speed; } } /// <summary> /// Is the joint limit enabled? /// </summary> /// <value><c>true</c> if [limit enabled]; otherwise, <c>false</c>.</value> public bool LimitEnabled { get { return _enableLimit; } set { Debug.Assert(BodyA.FixedRotation == false, "Warning: limits does currently not work with fixed rotation"); WakeBodies(); _enableLimit = value; } } /// <summary> /// Get the lower joint limit, usually in meters. /// </summary> /// <value></value> public float LowerLimit { get { return _lowerTranslation; } set { WakeBodies(); _lowerTranslation = value; } } /// <summary> /// Get the upper joint limit, usually in meters. /// </summary> /// <value></value> public float UpperLimit { get { return _upperTranslation; } set { WakeBodies(); _upperTranslation = value; } } /// <summary> /// Is the joint motor enabled? /// </summary> /// <value><c>true</c> if [motor enabled]; otherwise, <c>false</c>.</value> public bool MotorEnabled { get { return _enableMotor; } set { WakeBodies(); _enableMotor = value; } } /// <summary> /// Set the motor speed, usually in meters per second. /// </summary> /// <value>The speed.</value> public float MotorSpeed { set { WakeBodies(); _motorSpeed = value; } get { return _motorSpeed; } } /// <summary> /// Set the maximum motor force, usually in N. /// </summary> /// <value>The force.</value> public float MaxMotorForce { set { WakeBodies(); _maxMotorForce = value; } } /// <summary> /// Get the current motor force, usually in N. /// </summary> /// <value></value> public float MotorForce { get; set; } public Vector2 LocalXAxis1 { get { return _localXAxis1; } set { _localXAxis1 = value; _localYAxis1 = MathUtils.Cross(1.0f, _localXAxis1); } } public override Vector2 GetReactionForce(float inv_dt) { return inv_dt * (_impulse.X * _perp + (MotorForce + _impulse.Z) * _axis); } public override float GetReactionTorque(float inv_dt) { return inv_dt * _impulse.Y; } internal override void InitVelocityConstraints(ref TimeStep step) { PhysicsBody bB = BodyB; LocalCenterA = Vector2.Zero; LocalCenterB = bB.LocalCenter; Transform xf2; bB.GetTransform(out xf2); // Compute the effective masses. Vector2 r1 = LocalAnchorA; Vector2 r2 = MathUtils.Multiply(ref xf2.R, LocalAnchorB - LocalCenterB); Vector2 d = bB.Sweep.C + r2 - /* b1._sweep.Center - */ r1; InvMassA = 0.0f; InvIA = 0.0f; InvMassB = bB.InvMass; InvIB = bB.InvI; // Compute motor Jacobian and effective mass. { _axis = _localXAxis1; _a1 = MathUtils.Cross(d + r1, _axis); _a2 = MathUtils.Cross(r2, _axis); _motorMass = InvMassA + InvMassB + InvIA * _a1 * _a1 + InvIB * _a2 * _a2; if (_motorMass > Settings.Epsilon) { _motorMass = 1.0f / _motorMass; } } // Prismatic constraint. { _perp = _localYAxis1; _s1 = MathUtils.Cross(d + r1, _perp); _s2 = MathUtils.Cross(r2, _perp); float m1 = InvMassA, m2 = InvMassB; float i1 = InvIA, i2 = InvIB; float k11 = m1 + m2 + i1 * _s1 * _s1 + i2 * _s2 * _s2; float k12 = i1 * _s1 + i2 * _s2; float k13 = i1 * _s1 * _a1 + i2 * _s2 * _a2; float k22 = i1 + i2; float k23 = i1 * _a1 + i2 * _a2; float k33 = m1 + m2 + i1 * _a1 * _a1 + i2 * _a2 * _a2; _K.Col1 = new Vector3(k11, k12, k13); _K.Col2 = new Vector3(k12, k22, k23); _K.Col3 = new Vector3(k13, k23, k33); } // Compute motor and limit terms. if (_enableLimit) { float jointTranslation = Vector2.Dot(_axis, d); if (Math.Abs(_upperTranslation - _lowerTranslation) < 2.0f * Settings.LinearSlop) { _limitState = LimitState.Equal; } else if (jointTranslation <= _lowerTranslation) { if (_limitState != LimitState.AtLower) { _limitState = LimitState.AtLower; _impulse.Z = 0.0f; } } else if (jointTranslation >= _upperTranslation) { if (_limitState != LimitState.AtUpper) { _limitState = LimitState.AtUpper; _impulse.Z = 0.0f; } } else { _limitState = LimitState.Inactive; _impulse.Z = 0.0f; } } else { _limitState = LimitState.Inactive; } if (_enableMotor == false) { MotorForce = 0.0f; } if (Settings.EnableWarmstarting) { // Account for variable time step. _impulse *= step.dtRatio; MotorForce *= step.dtRatio; Vector2 P = _impulse.X * _perp + (MotorForce + _impulse.Z) * _axis; float L2 = _impulse.X * _s2 + _impulse.Y + (MotorForce + _impulse.Z) * _a2; bB.LinearVelocityInternal += InvMassB * P; bB.AngularVelocityInternal += InvIB * L2; } else { _impulse = Vector3.Zero; MotorForce = 0.0f; } } internal override void SolveVelocityConstraints(ref TimeStep step) { PhysicsBody bB = BodyB; Vector2 v1 = Vector2.Zero; float w1 = 0.0f; Vector2 v2 = bB.LinearVelocityInternal; float w2 = bB.AngularVelocityInternal; // Solve linear motor constraint. if (_enableMotor && _limitState != LimitState.Equal) { float Cdot = Vector2.Dot(_axis, v2 - v1) + _a2 * w2 - _a1 * w1; float impulse = _motorMass * (_motorSpeed - Cdot); float oldImpulse = MotorForce; float maxImpulse = step.dt * _maxMotorForce; MotorForce = MathUtils.Clamp(MotorForce + impulse, -maxImpulse, maxImpulse); impulse = MotorForce - oldImpulse; Vector2 P = impulse * _axis; float L1 = impulse * _a1; float L2 = impulse * _a2; v1 -= InvMassA * P; w1 -= InvIA * L1; v2 += InvMassB * P; w2 += InvIB * L2; } Vector2 Cdot1 = new Vector2(Vector2.Dot(_perp, v2 - v1) + _s2 * w2 - _s1 * w1, w2 - w1); if (_enableLimit && _limitState != LimitState.Inactive) { // Solve prismatic and limit constraint in block form. float Cdot2 = Vector2.Dot(_axis, v2 - v1) + _a2 * w2 - _a1 * w1; Vector3 Cdot = new Vector3(Cdot1.X, Cdot1.Y, Cdot2); Vector3 f1 = _impulse; Vector3 df = _K.Solve33(-Cdot); _impulse += df; if (_limitState == LimitState.AtLower) { _impulse.Z = Math.Max(_impulse.Z, 0.0f); } else if (_limitState == LimitState.AtUpper) { _impulse.Z = Math.Min(_impulse.Z, 0.0f); } // f2(1:2) = invK(1:2,1:2) * (-Cdot(1:2) - K(1:2,3) * (f2(3) - f1(3))) + f1(1:2) Vector2 b = -Cdot1 - (_impulse.Z - f1.Z) * new Vector2(_K.Col3.X, _K.Col3.Y); Vector2 f2r = _K.Solve22(b) + new Vector2(f1.X, f1.Y); _impulse.X = f2r.X; _impulse.Y = f2r.Y; df = _impulse - f1; Vector2 P = df.X * _perp + df.Z * _axis; float L2 = df.X * _s2 + df.Y + df.Z * _a2; v2 += InvMassB * P; w2 += InvIB * L2; } else { // Limit is inactive, just solve the prismatic constraint in block form. Vector2 df = _K.Solve22(-Cdot1); _impulse.X += df.X; _impulse.Y += df.Y; Vector2 P = df.X * _perp; float L2 = df.X * _s2 + df.Y; v2 += InvMassB * P; w2 += InvIB * L2; } bB.LinearVelocityInternal = v2; bB.AngularVelocityInternal = w2; } internal override bool SolvePositionConstraints() { //Body b1 = BodyA; PhysicsBody b2 = BodyB; Vector2 c1 = Vector2.Zero; // b1._sweep.Center; float a1 = 0.0f; // b1._sweep.Angle; Vector2 c2 = b2.Sweep.C; float a2 = b2.Sweep.A; // Solve linear limit constraint. float linearError = 0.0f; bool active = false; float C2 = 0.0f; Mat22 R1 = new Mat22(a1); Mat22 R2 = new Mat22(a2); Vector2 r1 = MathUtils.Multiply(ref R1, LocalAnchorA - LocalCenterA); Vector2 r2 = MathUtils.Multiply(ref R2, LocalAnchorB - LocalCenterB); Vector2 d = c2 + r2 - c1 - r1; if (_enableLimit) { _axis = MathUtils.Multiply(ref R1, _localXAxis1); _a1 = MathUtils.Cross(d + r1, _axis); _a2 = MathUtils.Cross(r2, _axis); float translation = Vector2.Dot(_axis, d); if (Math.Abs(_upperTranslation - _lowerTranslation) < 2.0f * Settings.LinearSlop) { // Prevent large angular corrections C2 = MathUtils.Clamp(translation, -Settings.MaxLinearCorrection, Settings.MaxLinearCorrection); linearError = Math.Abs(translation); active = true; } else if (translation <= _lowerTranslation) { // Prevent large linear corrections and allow some slop. C2 = MathUtils.Clamp(translation - _lowerTranslation + Settings.LinearSlop, -Settings.MaxLinearCorrection, 0.0f); linearError = _lowerTranslation - translation; active = true; } else if (translation >= _upperTranslation) { // Prevent large linear corrections and allow some slop. C2 = MathUtils.Clamp(translation - _upperTranslation - Settings.LinearSlop, 0.0f, Settings.MaxLinearCorrection); linearError = translation - _upperTranslation; active = true; } } _perp = MathUtils.Multiply(ref R1, _localYAxis1); _s1 = MathUtils.Cross(d + r1, _perp); _s2 = MathUtils.Cross(r2, _perp); Vector3 impulse; Vector2 C1 = new Vector2(Vector2.Dot(_perp, d), a2 - a1 - _refAngle); linearError = Math.Max(linearError, Math.Abs(C1.X)); float angularError = Math.Abs(C1.Y); if (active) { float m1 = InvMassA, m2 = InvMassB; float i1 = InvIA, i2 = InvIB; float k11 = m1 + m2 + i1 * _s1 * _s1 + i2 * _s2 * _s2; float k12 = i1 * _s1 + i2 * _s2; float k13 = i1 * _s1 * _a1 + i2 * _s2 * _a2; float k22 = i1 + i2; float k23 = i1 * _a1 + i2 * _a2; float k33 = m1 + m2 + i1 * _a1 * _a1 + i2 * _a2 * _a2; _K.Col1 = new Vector3(k11, k12, k13); _K.Col2 = new Vector3(k12, k22, k23); _K.Col3 = new Vector3(k13, k23, k33); Vector3 C = new Vector3(-C1.X, -C1.Y, -C2); impulse = _K.Solve33(C); // negated above } else { float m1 = InvMassA, m2 = InvMassB; float i1 = InvIA, i2 = InvIB; float k11 = m1 + m2 + i1 * _s1 * _s1 + i2 * _s2 * _s2; float k12 = i1 * _s1 + i2 * _s2; float k22 = i1 + i2; _K.Col1 = new Vector3(k11, k12, 0.0f); _K.Col2 = new Vector3(k12, k22, 0.0f); Vector2 impulse1 = _K.Solve22(-C1); impulse.X = impulse1.X; impulse.Y = impulse1.Y; impulse.Z = 0.0f; } Vector2 P = impulse.X * _perp + impulse.Z * _axis; float L2 = impulse.X * _s2 + impulse.Y + impulse.Z * _a2; c2 += InvMassB * P; a2 += InvIB * L2; // TODO_ERIN remove need for this. b2.Sweep.C = c2; b2.Sweep.A = a2; b2.SynchronizeTransform(); return linearError <= Settings.LinearSlop && angularError <= Settings.AngularSlop; } } }
LostCodeStudios/GGJ14
GameLib/GameLibrary/Dependencies/Physics/Dynamics/Joints/FixedPrismaticJoint.cs
C#
mit
22,028
<!DOCTYPE html> <HTML><head><TITLE>Manpage of ANVIL</TITLE> <meta charset="utf-8"> <link rel="stylesheet" href="/css/main.css" type="text/css"> </head> <body> <header class="site-header"> <div class="wrap"> <div class="site-title"><a href="/manpages/index.html">linux manpages</a></div> <div class="site-description">{"type":"documentation"}</div> </div> </header> <div class="page-content"><div class="wrap"> <H1>ANVIL</H1> Section: Maintenance Commands (8)<BR><A HREF="#index">Index</A> <A HREF="/manpages/index.html">Return to Main Contents</A><HR> <A NAME="lbAB">&nbsp;</A> <H2>NAME</H2> anvil - Postfix session count and request rate control <A NAME="lbAC">&nbsp;</A> <H2>SYNOPSIS</H2> <PRE> <B>anvil</B> [generic Postfix daemon options] </PRE><A NAME="lbAD">&nbsp;</A> <H2>DESCRIPTION</H2> The Postfix <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server maintains statistics about client connection counts or client request rates. This information can be used to defend against clients that hammer a server with either too many simultaneous sessions, or with too many successive requests within a configurable time interval. This server is designed to run under control by the Postfix <B><A HREF="/manpages/index.html?8+master">master</A></B>(8) server. <P> In the following text, <B>ident</B> specifies a (service, client) combination. The exact syntax of that information is application-dependent; the <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server does not care. <A NAME="lbAE">&nbsp;</A> <H2>CONNECTION COUNT/RATE CONTROL</H2> <PRE> </PRE> To register a new connection send the following request to the <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server: <P> <PRE> <B>request=connect</B> <B>ident=</B><I>string</I> </PRE> <P> The <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server answers with the number of simultaneous connections and the number of connections per unit time for the (service, client) combination specified with <B>ident</B>: <P> <PRE> <B>status=0</B> <B>count=</B><I>number</I> <B>rate=</B><I>number</I> </PRE> <P> To register a disconnect event send the following request to the <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server: <P> <PRE> <B>request=disconnect</B> <B>ident=</B><I>string</I> </PRE> <P> The <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server replies with: <P> <PRE> <B>status=0</B> </PRE> <A NAME="lbAF">&nbsp;</A> <H2>MESSAGE RATE CONTROL</H2> <PRE> </PRE> To register a message delivery request send the following request to the <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server: <P> <PRE> <B>request=message</B> <B>ident=</B><I>string</I> </PRE> <P> The <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server answers with the number of message delivery requests per unit time for the (service, client) combination specified with <B>ident</B>: <P> <PRE> <B>status=0</B> <B>rate=</B><I>number</I> </PRE> <A NAME="lbAG">&nbsp;</A> <H2>RECIPIENT RATE CONTROL</H2> <PRE> </PRE> To register a recipient request send the following request to the <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server: <P> <PRE> <B>request=recipient</B> <B>ident=</B><I>string</I> </PRE> <P> The <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server answers with the number of recipient addresses per unit time for the (service, client) combination specified with <B>ident</B>: <P> <PRE> <B>status=0</B> <B>rate=</B><I>number</I> </PRE> <A NAME="lbAH">&nbsp;</A> <H2>TLS SESSION NEGOTIATION RATE CONTROL</H2> <PRE> </PRE> The features described in this section are available with Postfix 2.3 and later. <P> To register a request for a new (i.e. not cached) TLS session send the following request to the <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server: <P> <PRE> <B>request=newtls</B> <B>ident=</B><I>string</I> </PRE> <P> The <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server answers with the number of new TLS session requests per unit time for the (service, client) combination specified with <B>ident</B>: <P> <PRE> <B>status=0</B> <B>rate=</B><I>number</I> </PRE> <P> To retrieve new TLS session request rate information without updating the counter information, send: <P> <PRE> <B>request=newtls_report</B> <B>ident=</B><I>string</I> </PRE> <P> The <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server answers with the number of new TLS session requests per unit time for the (service, client) combination specified with <B>ident</B>: <P> <PRE> <B>status=0</B> <B>rate=</B><I>number</I> </PRE> <A NAME="lbAI">&nbsp;</A> <H2>SECURITY</H2> <PRE> </PRE> The <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server does not talk to the network or to local users, and can run chrooted at fixed low privilege. <P> The <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server maintains an in-memory table with information about recent clients requests. No persistent state is kept because standard system library routines are not sufficiently robust for update-intensive applications. <P> Although the in-memory state is kept only temporarily, this may require a lot of memory on systems that handle connections from many remote clients. To reduce memory usage, reduce the time unit over which state is kept. <A NAME="lbAJ">&nbsp;</A> <H2>DIAGNOSTICS</H2> Problems and transactions are logged to <B><A HREF="/manpages/index.html?8+syslogd">syslogd</A></B>(8). <P> Upon exit, and every <B>anvil_status_update_time</B> seconds, the server logs the maximal count and rate values measured, together with (service, client) information and the time of day associated with those events. In order to avoid unnecessary overhead, no measurements are done for activity that isn't concurrency limited or rate limited. <A NAME="lbAK">&nbsp;</A> <H2>BUGS</H2> Systems behind network address translating routers or proxies appear to have the same client address and can run into connection count and/or rate limits falsely. <P> In this preliminary implementation, a count (or rate) limited server process can have only one remote client at a time. If a server process reports multiple simultaneous clients, state is kept only for the last reported client. <P> The <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server automatically discards client request information after it expires. To prevent the <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) server from discarding client request rate information too early or too late, a rate limited service should always register connect/disconnect events even when it does not explicitly limit them. <A NAME="lbAL">&nbsp;</A> <H2>CONFIGURATION PARAMETERS</H2> <PRE> </PRE> On low-traffic mail systems, changes to <B>main.cf</B> are picked up automatically as <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) processes run for only a limited amount of time. On other mail systems, use the command &quot;<B>postfix reload</B>&quot; to speed up a change. <P> The text below provides only a parameter summary. See <B><A HREF="/manpages/index.html?5+postconf">postconf</A></B>(5) for more details including examples. <DL COMPACT> <DT><B>anvil_rate_time_unit (60s)</B><DD> The time unit over which client connection rates and other rates are calculated. <DT><B>anvil_status_update_time (600s)</B><DD> How frequently the <B><A HREF="/manpages/index.html?8+anvil">anvil</A></B>(8) connection and rate limiting server logs peak usage information. <DT><B>config_directory (see 'postconf -d' output)</B><DD> The default location of the Postfix main.cf and master.cf configuration files. <DT><B>daemon_timeout (18000s)</B><DD> How much time a Postfix daemon process may take to handle a request before it is terminated by a built-in watchdog timer. <DT><B>ipc_timeout (3600s)</B><DD> The time limit for sending or receiving information over an internal communication channel. <DT><B>max_idle (100s)</B><DD> The maximum amount of time that an idle Postfix daemon process waits for an incoming connection before terminating voluntarily. <DT><B>max_use (100)</B><DD> The maximal number of incoming connections that a Postfix daemon process will service before terminating voluntarily. <DT><B>process_id (read-only)</B><DD> The process ID of a Postfix command or daemon process. <DT><B>process_name (read-only)</B><DD> The process name of a Postfix command or daemon process. <DT><B>syslog_facility (mail)</B><DD> The syslog facility of Postfix logging. <DT><B>syslog_name (see 'postconf -d' output)</B><DD> The mail system name that is prepended to the process name in syslog records, so that &quot;smtpd&quot; becomes, for example, &quot;postfix/smtpd&quot;. </DL> <A NAME="lbAM">&nbsp;</A> <H2>SEE ALSO</H2> <PRE> <A HREF="/manpages/index.html?8+smtpd">smtpd</A>(8), Postfix SMTP server <A HREF="/manpages/index.html?5+postconf">postconf</A>(5), configuration parameters <A HREF="/manpages/index.html?5+master">master</A>(5), generic daemon options </PRE><A NAME="lbAN">&nbsp;</A> <H2>README FILES</H2> <PRE> </PRE> Use &quot;<B>postconf readme_directory</B>&quot; or &quot;<B>postconf html_directory</B>&quot; to locate this information. <PRE> TUNING_README, performance tuning </PRE><A NAME="lbAO">&nbsp;</A> <H2>LICENSE</H2> <PRE> </PRE> The Secure Mailer license must be distributed with this software. <A NAME="lbAP">&nbsp;</A> <H2>HISTORY</H2> <PRE> </PRE> The anvil service is available in Postfix 2.2 and later. <A NAME="lbAQ">&nbsp;</A> <H2>AUTHOR(S)</H2> <PRE> Wietse Venema IBM T.J. Watson Research P.O. Box 704 Yorktown Heights, NY 10598, USA </PRE> <HR> <A NAME="index">&nbsp;</A><H2>Index</H2> <DL> <DT><A HREF="#lbAB">NAME</A><DD> <DT><A HREF="#lbAC">SYNOPSIS</A><DD> <DT><A HREF="#lbAD">DESCRIPTION</A><DD> <DT><A HREF="#lbAE">CONNECTION COUNT/RATE CONTROL</A><DD> <DT><A HREF="#lbAF">MESSAGE RATE CONTROL</A><DD> <DT><A HREF="#lbAG">RECIPIENT RATE CONTROL</A><DD> <DT><A HREF="#lbAH">TLS SESSION NEGOTIATION RATE CONTROL</A><DD> <DT><A HREF="#lbAI">SECURITY</A><DD> <DT><A HREF="#lbAJ">DIAGNOSTICS</A><DD> <DT><A HREF="#lbAK">BUGS</A><DD> <DT><A HREF="#lbAL">CONFIGURATION PARAMETERS</A><DD> <DT><A HREF="#lbAM">SEE ALSO</A><DD> <DT><A HREF="#lbAN">README FILES</A><DD> <DT><A HREF="#lbAO">LICENSE</A><DD> <DT><A HREF="#lbAP">HISTORY</A><DD> <DT><A HREF="#lbAQ">AUTHOR(S)</A><DD> </DL> <HR> This document was created by <A HREF="/manpages/index.html">man2html</A>, using the manual pages.<BR> Time: 05:34:24 GMT, December 24, 2015 </div></div> </body> </HTML>
yuweijun/yuweijun.github.io
manpages/man8/anvil.8.html
HTML
mit
10,727
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * General page setup */ #tablelisteServeur {margin:0;padding:0;color: #333;background-color: #E0E0E0;} #tablelisteServeur a {text-decoration: none;font-weight:bold;} #tablelisteServeur .dataTables_filter{text-align:center;} /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * DataTables display */ #listeServ {clear:both;margin:0 auto 0 5%;width:100%;border-collapse:separate;display:inline-block;border-spacing:0px;text-align:center;} #listeServ tr {position:relative;float:left;background-color:#E0E0E0;text-align:center;} #listeServ td {float:left;overflow:auto;margin:10px;width:180px;height:80px;border:2px solid #E0E0E0;padding:5px 5px 5px 5px;text-align:center;-webkit-border-radius: 7px;-moz-border-radius: 7px;border-radius: 7px;background: #1e5799; /* Old browsers */ background: -moz-linear-gradient(top, #1e5799 23%, #2989d8 69%, #7db9e8 98%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(23%,#1e5799), color-stop(69%,#2989d8), color-stop(98%,#7db9e8)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #1e5799 23%,#2989d8 69%,#7db9e8 98%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #1e5799 23%,#2989d8 69%,#7db9e8 98%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #1e5799 23%,#2989d8 69%,#7db9e8 98%); /* IE10+ */ background: linear-gradient(to bottom, #1e5799 23%,#2989d8 69%,#7db9e8 98%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#7db9e8',GradientType=0 ); /* IE6-9 */} #listeServ .jaune td{background: rgb(239,208,4); /* Old browsers */ background: -moz-linear-gradient(top, rgba(239,208,4,1) 0%, rgba(239,208,4,1) 29%, rgba(239,208,4,1) 54%, rgba(252,244,176,1) 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(239,208,4,1)), color-stop(29%,rgba(239,208,4,1)), color-stop(54%,rgba(239,208,4,1)), color-stop(100%,rgba(252,244,176,1))); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, rgba(239,208,4,1) 0%,rgba(239,208,4,1) 29%,rgba(239,208,4,1) 54%,rgba(252,244,176,1) 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, rgba(239,208,4,1) 0%,rgba(239,208,4,1) 29%,rgba(239,208,4,1) 54%,rgba(252,244,176,1) 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, rgba(239,208,4,1) 0%,rgba(239,208,4,1) 29%,rgba(239,208,4,1) 54%,rgba(252,244,176,1) 100%); /* IE10+ */ background: linear-gradient(to bottom, rgba(239,208,4,1) 0%,rgba(239,208,4,1) 29%,rgba(239,208,4,1) 54%,rgba(252,244,176,1) 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#efd004', endColorstr='#fcf4b0',GradientType=0 ); /* IE6-9 */} #listeServ .orange td{background: #ff7f04; /* Old browsers */ background: -moz-linear-gradient(top, #ff7f04 0%, #ff7c00 31%, #ffa73d 82%, #ffa73d 90%, #ffa73d 100%, #ffb76b 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ff7f04), color-stop(31%,#ff7c00), color-stop(82%,#ffa73d), color-stop(90%,#ffa73d), color-stop(100%,#ffa73d), color-stop(100%,#ffb76b)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #ff7f04 0%,#ff7c00 31%,#ffa73d 82%,#ffa73d 90%,#ffa73d 100%,#ffb76b 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #ff7f04 0%,#ff7c00 31%,#ffa73d 82%,#ffa73d 90%,#ffa73d 100%,#ffb76b 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #ff7f04 0%,#ff7c00 31%,#ffa73d 82%,#ffa73d 90%,#ffa73d 100%,#ffb76b 100%); /* IE10+ */ background: linear-gradient(to bottom, #ff7f04 0%,#ff7c00 31%,#ffa73d 82%,#ffa73d 90%,#ffa73d 100%,#ffb76b 100%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff7f04', endColorstr='#ffb76b',GradientType=0 ); /* IE6-9 */} #listeServ .rouge td{background: rgb(240,47,23); /* Old browsers */ background: -moz-linear-gradient(top, rgba(240,47,23,1) 0%, rgba(231,56,39,1) 34%, rgba(248,80,50,1) 61%, rgba(241,111,92,1) 98%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(240,47,23,1)), color-stop(34%,rgba(231,56,39,1)), color-stop(61%,rgba(248,80,50,1)), color-stop(98%,rgba(241,111,92,1))); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, rgba(240,47,23,1) 0%,rgba(231,56,39,1) 34%,rgba(248,80,50,1) 61%,rgba(241,111,92,1) 98%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, rgba(240,47,23,1) 0%,rgba(231,56,39,1) 34%,rgba(248,80,50,1) 61%,rgba(241,111,92,1) 98%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, rgba(240,47,23,1) 0%,rgba(231,56,39,1) 34%,rgba(248,80,50,1) 61%,rgba(241,111,92,1) 98%); /* IE10+ */ background: linear-gradient(to bottom, rgba(240,47,23,1) 0%,rgba(231,56,39,1) 34%,rgba(248,80,50,1) 61%,rgba(241,111,92,1) 98%); /* W3C */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f02f17', endColorstr='#f16f5c',GradientType=0 ); /* IE6-9 */} #listeServ th {padding-right:30px;border:none;} #listeServ td:hover{border : 2px solid black;} #listeServ a{width:100%;height:auto !important;padding: 0px 0px 0px 0px;color:#ffffee;} #listeServ a:hover{text-decoration:underline;color:yellow;} #listeServ span{font-size:15px;} #listeServ p{font-size:12px;color:#f2f5f6;margin:auto;} #listeServ ul{margin:auto;text-align:center;} #listeServ li{margin:auto;text-align:left;} #listeServ li .bold{font-weight:bold;}
chadyred/refapp
web/css/989e337_listeServ_10.css
CSS
mit
5,550
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="generator" content="rustdoc"> <meta name="description" content="API documentation for the Rust `XKB_KEY_dead_breve` constant in crate `wayland_kbd`."> <meta name="keywords" content="rust, rustlang, rust-lang, XKB_KEY_dead_breve"> <title>wayland_kbd::keysyms::XKB_KEY_dead_breve - Rust</title> <link rel="stylesheet" type="text/css" href="../../main.css"> </head> <body class="rustdoc"> <!--[if lte IE 8]> <div class="warning"> This old browser is unsupported and will most likely display funky things. </div> <![endif]--> <section class="sidebar"> <p class='location'><a href='../index.html'>wayland_kbd</a>::<wbr><a href='index.html'>keysyms</a></p><script>window.sidebarCurrent = {name: 'XKB_KEY_dead_breve', ty: 'constant', relpath: ''};</script><script defer src="sidebar-items.js"></script> </section> <nav class="sub"> <form class="search-form js-only"> <div class="search-container"> <input class="search-input" name="search" autocomplete="off" placeholder="Click or press 'S' to search, '?' for more options..." type="search"> </div> </form> </nav> <section id='main' class="content constant"> <h1 class='fqn'><span class='in-band'><a href='../index.html'>wayland_kbd</a>::<wbr><a href='index.html'>keysyms</a>::<wbr><a class='constant' href=''>XKB_KEY_dead_breve</a></span><span class='out-of-band'><span id='render-detail'> <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs"> [<span class='inner'>&#x2212;</span>] </a> </span><a id='src-674' class='srclink' href='../../src/wayland_kbd/ffi/keysyms.rs.html#390' title='goto source code'>[src]</a></span></h1> <pre class='rust const'>pub const XKB_KEY_dead_breve: <a href='http://doc.rust-lang.org/nightly/std/primitive.u32.html'>u32</a><code> = </code><code>0xfe55</code></pre></section> <section id='search' class="content hidden"></section> <section class="footer"></section> <div id="help" class="hidden"> <div class="shortcuts"> <h1>Keyboard shortcuts</h1> <dl> <dt>?</dt> <dd>Show this help dialog</dd> <dt>S</dt> <dd>Focus the search field</dd> <dt>&larrb;</dt> <dd>Move up in search results</dd> <dt>&rarrb;</dt> <dd>Move down in search results</dd> <dt>&#9166;</dt> <dd>Go to active search result</dd> </dl> </div> <div class="infos"> <h1>Search tricks</h1> <p> Prefix searches with a type followed by a colon (e.g. <code>fn:</code>) to restrict the search to a given type. </p> <p> Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>typedef</code> (or <code>tdef</code>). </p> <p> Search functions by type signature (e.g. <code>vec -> usize</code>) </p> </div> </div> <script> window.rootPath = "../../"; window.currentCrate = "wayland_kbd"; window.playgroundUrl = ""; </script> <script src="../../jquery.js"></script> <script src="../../main.js"></script> <script async src="../../search-index.js"></script> </body> </html>
mcanders/bevy
doc/wayland_kbd/keysyms/constant.XKB_KEY_dead_breve.html
HTML
mit
3,839
%% %% Qt5xHb - Bindings libraries for Harbour/xHarbour and Qt Framework 5 %% %% Copyright (C) 2020 Marcos Antonio Gambeta <marcosgambeta AT outlook DOT com> %% $project=Qt5xHb $module=QtDataVisualization $header $includes $beginSlotsClass $slot=|autoColumnCategoriesChanged( bool enable ) $slot=|autoRowCategoriesChanged( bool enable ) $slot=|columnCategoriesChanged() $slot=|columnRoleChanged( const QString & role ) $slot=|columnRolePatternChanged( const QRegExp & pattern ) $slot=|columnRoleReplaceChanged( const QString & replace ) $slot=|itemModelChanged( const QAbstractItemModel * itemModel ) $slot=|multiMatchBehaviorChanged( QItemModelSurfaceDataProxy::MultiMatchBehavior behavior ) $slot=|rowCategoriesChanged() $slot=|rowRoleChanged( const QString & role ) $slot=|rowRolePatternChanged( const QRegExp & pattern ) $slot=|rowRoleReplaceChanged( const QString & replace ) $slot=|useModelCategoriesChanged( bool enable ) $slot=|xPosRoleChanged( const QString & role ) $slot=|xPosRolePatternChanged( const QRegExp & pattern ) $slot=|xPosRoleReplaceChanged( const QString & replace ) $slot=|yPosRoleChanged( const QString & role ) $slot=|yPosRolePatternChanged( const QRegExp & pattern ) $slot=|yPosRoleReplaceChanged( const QString & replace ) $slot=|zPosRoleChanged( const QString & role ) $slot=|zPosRolePatternChanged( const QRegExp & pattern ) $slot=|zPosRoleReplaceChanged( const QString & replace ) $endSlotsClass
marcosgambeta/Qt5xHb
codegen/QtDataVisualization/QItemModelSurfaceDataProxySlots.cpp
C++
mit
1,467
from globals import * import life as lfe import judgement import movement import groups import speech import action import events import brain import stats import jobs def setup(life): if not life['group']: #if not stats.desires_to_create_group(life): # return False #groups.create_group(life) return False if not groups.is_leader_of_any_group(life): return False _group = groups.get_group(life, life['group']) #groups.manage_jobs(life, life['group']) #groups.manage_territory(life, life['group']) groups.manage_combat(life, life['group']) groups.manage_raid(life, life['group']) #groups.manage_resources(life, life['group']) #groups.manage_known_groups(life, life['group']) #groups.manage_combat(life, life['group'])
flags/Reactor-3
alife/alife_group.py
Python
mit
750
#import <Foundation/Foundation.h> #import <CocoaLumberjack/DDLog.h> #import "LSStateMachineTypedefs.h" @class LSEvent; @interface LSStateMachine : NSObject <DDRegisteredDynamicLogging> @property (nonatomic, strong, readonly) NSSet *states; @property (nonatomic, strong, readonly) NSSet *events; @property (nonatomic, strong) NSString *initialState; - (void)addState:(NSString *)state; - (void)when:(NSString *)eventName transitionFrom:(NSString *)from to:(NSString *)to; - (LSEvent *)eventWithName:(NSString *)name; - (void)before:(NSString *)eventName do:(LSStateMachineTransitionCallback)callback; - (void)after:(NSString *)eventName do:(LSStateMachineTransitionCallback)callback; - (NSString *)nextStateFrom:(NSString *)from forEvent:(NSString *)event; @end @class LSStateMachine; #define StateMachine_LOG_CONTEXT 6868
brynbellomy/StateMachine-GCDThreadsafe
StateMachine/LSStateMachine.h
C
mit
833
# Created by PyCharm Pro Edition # User: Kaushik Talukdar # Date: 28-03-17 # Time: 01:55 AM #a lot can be done with lists, specially numerical lists #range function for value in range(1, 10): print(value)
KT26/PythonCourse
3. Working with lists/3.py
Python
mit
271
# frozen_string_literal: true require 'spec_helper' describe ThinkingSphinx::Excerpter do let(:excerpter) { ThinkingSphinx::Excerpter.new('index', 'all words') } let(:connection) { double('connection', :execute => [{'snippet' => 'some highlighted words'}]) } before :each do allow(ThinkingSphinx::Connection).to receive(:take).and_yield(connection) allow(Riddle::Query).to receive_messages :snippets => 'CALL SNIPPETS' end describe '#excerpt!' do it "generates a snippets call" do expect(Riddle::Query).to receive(:snippets). with('all of the words', 'index', 'all words', ThinkingSphinx::Excerpter::DefaultOptions). and_return('CALL SNIPPETS') excerpter.excerpt!('all of the words') end it "respects the provided options" do excerpter = ThinkingSphinx::Excerpter.new('index', 'all words', :before_match => '<b>', :chunk_separator => ' -- ') expect(Riddle::Query).to receive(:snippets). with('all of the words', 'index', 'all words', :before_match => '<b>', :after_match => '</span>', :chunk_separator => ' -- '). and_return('CALL SNIPPETS') excerpter.excerpt!('all of the words') end it "sends the snippets call to Sphinx" do expect(connection).to receive(:execute).with('CALL SNIPPETS'). and_return([{'snippet' => ''}]) excerpter.excerpt!('all of the words') end it "returns the first value returned by Sphinx" do allow(connection).to receive_messages :execute => [{'snippet' => 'some highlighted words'}] expect(excerpter.excerpt!('all of the words')).to eq('some highlighted words') end end end
pat/thinking-sphinx
spec/thinking_sphinx/excerpter_spec.rb
Ruby
mit
1,702
export const oNavPrimary: string; export const nav: string; export const oNavSecondary: string; export const oNavSecondaryBtnList: string;
apparena/patterns
source/patterns/02-organisms/navigation/nav-secondary/index.module.scss.d.ts
TypeScript
mit
139
<?php namespace ErenMustafaOzdal\LaravelDescriptionModule; use Illuminate\Database\Eloquent\Model; use ErenMustafaOzdal\LaravelModulesBase\Traits\ModelDataTrait; class DescriptionLink extends Model { use ModelDataTrait; /** * The database table used by the model. * * @var string */ protected $table = 'description_links'; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'link' ]; /** * All of the relationships to be touched. * * @var array */ protected $touches = ['description']; public $timestamps = false; /* |-------------------------------------------------------------------------- | Model Relations |-------------------------------------------------------------------------- */ /** * Get the photo of the description. */ public function description() { return $this->belongsTo('App\Description'); } /* |-------------------------------------------------------------------------- | Model Set and Get Attributes |-------------------------------------------------------------------------- */ }
erenmustafaozdal/laravel-description-module
src/DescriptionLink.php
PHP
mit
1,223
- 版本 / Version: - 系统信息 / OS Version: 重现Bug步骤 / Steps to Reproduce: 1. 2.
sekaiamber/git-doc
issue_template.md
Markdown
mit
97
--- title: v1.0 Release Notes layout: release-notes deprecated: true --- **Release Date:** 07 June 2009 {% include download-sourceforge.md %} {% include reporting-problems.md %} ## New Features * A permissions caching layer: * Previously all permissions were calculated at runtime, now they are re-calculated for a given user whenever any of that users' permissions or Roles are changed reducing runtime queries by 90% in some cases; * Also allows questions along the lines of "who has access to this project?" to be answered without recalculating all user's permissions; * Provides a screen to review any users' permissions for anything in the system; * Overall permissions improvement: * Now the system assumes no permissions on an object until a Role or specific Permission describes otherwise; * A user interface overhaul - rounded corners, we're web2.0 ready! * Improved installer: * A dotProject to web2project converter detects and handles all versions of dotProject from v2.0; * An upgrade manager detects the current web2project version and applies database changes as required, similar to Migrations; * Added numerous configuration/requirement validations and specific error messages were applicable; * Added a number of new fields to the Contact object to accommodate new IM systems; * Added the beginning of a "hook" system similar to Drupal: * Reworked the queuescanner.php to automatically detect and call any hook_cron methods on system objects; * [Issue 74](http://bugs.web2project.net/view.php?id=74) - Implemented an iCal feed (in ./calendar.php) to automatically detect and call any hook_calendar methods on system objects; * Added the ProjectDesigner to core; * Improved the getUser call to only retrieve active users in the system; * Simplified the various add/edit screens to only retrieve data relevant to the current context; * Added the ability for potential users to request an account for the system, made this ability toggle-able by the admin; * Added the ability for contacts to update their information without logging in, etc; * Added a check that will warn and stop a user from trying to upload/attach a file if the underlying filesystem permissions are incorrect; ## Bugs Closed * Added database indexes/primary keys to selected tables; * Fixed the fonts issue on the gantt charts to use the distributable FreeSans font as opposed to Arial; * Fixed the default priority to zero (normal) for new projects; * Fixed the locales and appearance of the change password interface; * Added proper permissions checking to all dropdowns, selections, etc within the class methods; * Fixed the color picker (Projects) to work on all browsers; * Fixed some broken queries that were showing all contacts regardless of the company filter; * Fixed the permissions so that it is possible to view and edit events with no project association; * Converted the System Lookup Values from being a line-delimited single field to being individual database fields; * Fixed the w2pgetImage function to default to the web2project theme if the image is missing in the selected theme * [Issue 24](http://bugs.web2project.net/view.php?id=24) - Missing Installer PHP Page * [Issue 38](http://bugs.web2project.net/view.php?id=38) - Date format in task logs doesn't make my Short Date Format * [Issue 50](http://bugs.web2project.net/view.php?id=50) - Task name cannot contain quotes. * [Issue 58](http://bugs.web2project.net/view.php?id=58) - Enter key should work the same way as "save" button in creating new task * [Issue 59](http://bugs.web2project.net/view.php?id=59) - Contacts module doest not show all contacts * [Issue 65](http://bugs.web2project.net/view.php?id=65) - Forum permission add/edit does not work well * [Issue 66](http://bugs.web2project.net/view.php?id=66) - Duplicate email notifications * [Issue 68](http://bugs.web2project.net/view.php?id=68) - No validation checking on date ranges in Task Create/Edit * [Issue 70](http://bugs.web2project.net/view.php?id=70) - Can't search for info in the Project Location field. * [Issue 72](http://bugs.web2project.net/view.php?id=72) - file list empty in project view. * [Issue 75](http://bugs.web2project.net/view.php?id=75) - Going from user list to department causes error if default tab on department is projects * [Issue 76](http://bugs.web2project.net/view.php?id=76) - Under certain conditions the task owner ends up set to 0 causing the task to vanish * [Issue 77](http://bugs.web2project.net/view.php?id=77) - Search that contains a parenthesis ( ) causes an error anywhere in search * [Issue 78](http://bugs.web2project.net/view.php?id=78) - Task dependencies not cascading * [Issue 79](http://bugs.web2project.net/view.php?id=79) - Hide forum tab if Forum module is not active * [Issue 81](http://bugs.web2project.net/view.php?id=81) - Contact detail unable (Access Denied) to be edited even by the Admin account * [Issue 82](http://bugs.web2project.net/view.php?id=82) - Event details become unable (Access Denied) to be edited even by the Admin account * [Issue 83](http://bugs.web2project.net/view.php?id=83) - Expected Duration of Hours Calculated is incorrect * [Issue 87](http://bugs.web2project.net/view.php?id=87) - Quotes in Item Names Damage Permissions * [Issue 108](http://bugs.web2project.net/view.php?id=108) - Edit a project, see crash * [Issue 113](http://bugs.web2project.net/view.php?id=113) - Button 'new contact' in contacts tab of department view does not work * [Issue 114](http://bugs.web2project.net/view.php?id=114) - Catchable fatal error when clicking on 'Projects' tab of the department view * [Issue 116](http://bugs.web2project.net/view.php?id=116) - Column count doesn't match value count at row 1 - Forum module configuration * [Issue 117](http://bugs.web2project.net/view.php?id=117) - PDF print out puts the forum topic on the same line as the content * [Issue 118](http://bugs.web2project.net/view.php?id=118) - Selecting contact in a project - CLick Continue nothing happens + not updating contacts immediatly * [Issue 120](http://bugs.web2project.net/view.php?id=120) - Catchable error when clicking on "task per user" button * [Issue 122](http://bugs.web2project.net/view.php?id=122) - Missing argument 1 for CTask::getAssignedUsers() in tasksperuser.php * [Issue 123](http://bugs.web2project.net/view.php?id=123) - White text not readable * [Issue 124](http://bugs.web2project.net/view.php?id=124) - Javascript error when setting user permissions in "View User" mode (Flat View Only) * [Issue 125](http://bugs.web2project.net/view.php?id=125) - Project Location is required by database, but not by UI * [Issue 126](http://bugs.web2project.net/view.php?id=126) - Logging in with no roles results in crash * [Issue 127](http://bugs.web2project.net/view.php?id=127) - Inconsistent security behavior with projects / task assignment * [Issue 128](http://bugs.web2project.net/view.php?id=128) - PHP crash on clicking "Task List" button under "My Tasks To Do" * [Issue 129](http://bugs.web2project.net/view.php?id=129) - Tasks never show in TODO list without elevated permissions * [Issue 130](http://bugs.web2project.net/view.php?id=130) - Editing "Archive" status projects results in crash * [Issue 131](http://bugs.web2project.net/view.php?id=131) - Multiple "archive" tabs exist on project screen after upgrade from dotProject * [Issue 132](http://bugs.web2project.net/view.php?id=132) - Switching companies on the projects tab causes crash * [Issue 133](http://bugs.web2project.net/view.php?id=133) - No departments are being listed in the departments module * [Issue 134](http://bugs.web2project.net/view.php?id=134) - Potential dotProject Conversion Issues * [Issue 136](http://bugs.web2project.net/view.php?id=136) - Go to edit a department, none of the fields are populated * [Issue 140](http://bugs.web2project.net/view.php?id=140) - WPS-Redmond missing some image files in RC1 * [Issue 141](http://bugs.web2project.net/view.php?id=141) - Percent Complete Calculations Vary * [Issue 144](http://bugs.web2project.net/view.php?id=144) - Spelling error in Access Denied message * [Issue 146](http://bugs.web2project.net/view.php?id=146) - Project details not displayed for newly created projects * [Issue 147](http://bugs.web2project.net/view.php?id=147) - Add permission item list <Project> shows inactive projects * [Issue 149](http://bugs.web2project.net/view.php?id=149) - Assigned Users not listed when viewing the task * [Issue 151](http://bugs.web2project.net/view.php?id=151) - Task list on Day View in Calendar is not displayed correctly * [Issue 155](http://bugs.web2project.net/view.php?id=155) - USER's ROLE: "LOCK" Icon takes to EDITing role instead of "clipboard" icon. * [Issue 160](http://bugs.web2project.net/view.php?id=160) - Child tasks not displayed in toto Gantt * [Issue 166](http://bugs.web2project.net/view.php?id=166) - New Project form allows submission of project with no assigned company resulting in orphaned project * [Issue 167](http://bugs.web2project.net/view.php?id=167) - Empty list of tasks when nef file is added * [Issue 171](http://bugs.web2project.net/view.php?id=171) - Project Location, when left empty, causes crash * [Issue 172](http://bugs.web2project.net/view.php?id=172) - Cannot use commas (",") when specifying budgets ## Misc Changes/Improvements * Security: * Improved the datatype validation, SQL Injection protection, and anti-XSS code; * Removed various data access calls from numerous Views, refactored all of these to the Models; * Simplified and centralized all the permissions checks to reduce duplication * Refactoring: * Removed tickets.inc.php from the search objects; * Removed the {class}_func.php files and the ./functions folder by merging the functions into the relevant classes; * Tweaked the module reordering code to keep the order id's contiguous in order to prevent id's from "drifting" out of order; * Cleaned up the double quotes to use single quotes where applicable; * Cleaned up the Installer's sql to get rid of various magic numbers; * Added department email and type fields. Department Types with Lookup values support; * Reduced the overall Lines of Code (LoC) by approximately 18%; * Deprecation: * Replaced all instances of the "dPconfig" variable with the "w2Pconfig"; * Adopted and converted the outgoing mails to PHPMailer lib; * Removed the old gateway.pl code for sending emails; * Removed unnecessary files and code where applicable; ## Open/Known Issues * The cascading dependencies are still not 100%. Although long chains (A->B-C->D->E) work fine and tasks with multiple dependencies work fine, there are a limited number of scenarios where dependencies do not behave as expected. * One such scenario is when you have a Dynamic Task A with children chain (B->C-D->E) and Task F which is dependent on Task A. If B, C, D or E shift, they shift the rest of the chain as expected and the Dynamic Task (A) as expected but unfortunately F does not get updated.
web2project/web2project.github.io
_release-notes/1.0.md
Markdown
mit
11,021
import { ColumnType } from "../../Common/ColumnType"; import { ColumnGeneration } from "../../Common/Enum"; import { GenericType } from "../../Common/Type"; export interface IColumnFormatter<T, TD = any> { from: (source: T) => TD; to: (source: TD) => T; } export interface IColumnOption<T = any> { charset?: string; collation?: string; columnName?: string; columnType?: ColumnType; default?: () => T; description?: string; formatter?: IColumnFormatter<T>; generation?: ColumnGeneration; indexed?: boolean; isProjected?: boolean; isReadOnly?: boolean; nullable?: boolean; type?: GenericType<T>; }
11111991/TypeDBORM
src/Decorator/Option/IColumnOption.ts
TypeScript
mit
658
/*************************************************************************/ /* cp_player_data_envelopes.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ /* */ /* 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. */ /*************************************************************************/ #include "cp_player_data.h" void CPPlayer::Voice_Control::start_envelope(CPEnvelope *p_envelope, Envelope_Control *p_envelope_ctrl, Envelope_Control *p_from_env) { if (p_from_env && p_envelope->is_carry_enabled() && !p_from_env->terminated) { *p_envelope_ctrl = *p_from_env; } else { p_envelope_ctrl->pos_index = 0; p_envelope_ctrl->status = 1; p_envelope_ctrl->sustain_looping = p_envelope->is_sustain_loop_enabled(); p_envelope_ctrl->looping = p_envelope->is_loop_enabled(); p_envelope_ctrl->terminated = false; p_envelope_ctrl->kill = false; p_envelope_ctrl->value = p_envelope->get_height_at_pos(p_envelope_ctrl->pos_index); } } bool CPPlayer::Voice_Control::process_envelope(CPEnvelope *p_envelope, Envelope_Control *p_envelope_ctrl) { if (!p_envelope_ctrl->active) return false; if (note_end_flags & END_NOTE_OFF) p_envelope_ctrl->sustain_looping = false; p_envelope_ctrl->value = p_envelope->get_height_at_pos(p_envelope_ctrl->pos_index); if (p_envelope_ctrl->value == CPEnvelope::NO_POINT) return false; p_envelope_ctrl->pos_index++; if (p_envelope_ctrl->sustain_looping) { if (p_envelope_ctrl->pos_index > p_envelope->get_node(p_envelope->get_sustain_loop_end()).tick_offset) { p_envelope_ctrl->pos_index = p_envelope->get_node(p_envelope->get_sustain_loop_begin()).tick_offset; } } else if (p_envelope_ctrl->looping) { if (p_envelope_ctrl->pos_index > p_envelope->get_node(p_envelope->get_loop_end()).tick_offset) { p_envelope_ctrl->pos_index = p_envelope->get_node(p_envelope->get_loop_begin()).tick_offset; } } if (p_envelope_ctrl->pos_index > p_envelope->get_node(p_envelope->get_node_count() - 1).tick_offset) { p_envelope_ctrl->terminated = true; p_envelope_ctrl->pos_index = p_envelope->get_node(p_envelope->get_node_count() - 1).tick_offset; if (p_envelope->get_node(p_envelope->get_node_count() - 1).value == 0) p_envelope_ctrl->kill = true; } return true; }
pixelpicosean/my-godot-2.1
modules/chibi/cp_player_data_envelopes.cpp
C++
mit
4,153
/* * The MIT License * * Copyright 2018 acepace. * * 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. */ /* globals INITIAL_ARRAY_SIZE - Size of initial array of global variables ARRAY_STEP - Number of objects to add NUM_STEPS - Number of steps to take OBJECT_TYPE - either 0 (integer), 1 (nested objects) */ var ITERATION = 0; function pusher(i, j) { let toPush; let objVal = 4150 + ITERATION; if (0 === OBJECT_TYPE) { toPush = objVal; } else { toPush = {step: i, step_index: j, 'objVal': objVal}; } ITERATION += 1; return toPush; } bp.registerBThread("arraySizer", function () { let GLOBAL_ARRAY = []; for (let init = 0; init < INITIAL_ARRAY_SIZE; init++) { GLOBAL_ARRAY.push(pusher()); } for (let i = 0; i < NUM_STEPS; i++) { for (let j = 0; j < ARRAY_STEP; j++) { GLOBAL_ARRAY.push(pusher(i, j)); } bp.sync({request: bp.Event("A")}); } });
bThink-BGU/BPjs
src/test/resources/benchmarks/variableSizedArrays.js
JavaScript
mit
1,998
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Umbraco.ModelsBuilder.Tests { static class TestOptions { // mssql //public const string ConnectionString = @"server=localhost\sqlexpress;database=dev_umbraco6;user id=sa;password=sa"; //public const string DatabaseProvider = "System.Data.SqlClient"; // mysql public const string ConnectionString = @"server=localhost;database=eurovia_w310;user id=root;password=root;default command timeout=120;"; public const string DatabaseProvider = "MySql.Data.MySqlClient"; } }
zpqrtbnk/Zbu.ModelsBuilder
src/Umbraco.ModelsBuilder.Tests/TestOptions.cs
C#
mit
657
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <meta name="description"> <meta name="keywords" content="static content generator,static site generator,static site,HTML,web development,.NET,C#,Razor,Markdown,YAML"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="/OpenTl.Schema/assets/img/favicon.ico" type="image/x-icon"> <link rel="icon" href="/OpenTl.Schema/assets/img/favicon.ico" type="image/x-icon"> <title>OpenTl.Schema - API - IInputSecureValue.Selfie Property</title> <link href="/OpenTl.Schema/assets/css/mermaid.css" rel="stylesheet"> <link href="/OpenTl.Schema/assets/css/highlight.css" rel="stylesheet"> <link href="/OpenTl.Schema/assets/css/bootstrap/bootstrap.css" rel="stylesheet"> <link href="/OpenTl.Schema/assets/css/adminlte/AdminLTE.css" rel="stylesheet"> <link href="/OpenTl.Schema/assets/css/theme/theme.css" rel="stylesheet"> <link href="//fonts.googleapis.com/css?family=Roboto+Mono:400,700|Roboto:400,400i,700,700i" rel="stylesheet"> <link href="/OpenTl.Schema/assets/css/font-awesome.min.css" rel="stylesheet" type="text/css"> <link href="/OpenTl.Schema/assets/css/override.css" rel="stylesheet"> <script src="/OpenTl.Schema/assets/js/jquery-2.2.3.min.js"></script> <script src="/OpenTl.Schema/assets/js/bootstrap.min.js"></script> <script src="/OpenTl.Schema/assets/js/app.min.js"></script> <script src="/OpenTl.Schema/assets/js/highlight.pack.js"></script> <script src="/OpenTl.Schema/assets/js/jquery.slimscroll.min.js"></script> <script src="/OpenTl.Schema/assets/js/jquery.sticky-kit.min.js"></script> <script src="/OpenTl.Schema/assets/js/mermaid.min.js"></script> <!--[if lt IE 9]> <script src="/OpenTl.Schema/assets/js/html5shiv.min.js"></script> <script src="/OpenTl.Schema/assets/js/respond.min.js"></script> <![endif]--> </head> <body class="hold-transition wyam layout-boxed "> <div class="top-banner"></div> <div class="wrapper with-container"> <!-- Header --> <header class="main-header"> <a href="/OpenTl.Schema/" class="logo"> <span>OpenTl.Schema</span> </a> <nav class="navbar navbar-static-top" role="navigation"> <!-- Sidebar toggle button--> <a href="#" class="sidebar-toggle visible-xs-block" data-toggle="offcanvas" role="button"> <span class="sr-only">Toggle side menu</span> <i class="fa fa-chevron-circle-right"></i> </a> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse"> <span class="sr-only">Toggle side menu</span> <i class="fa fa-chevron-circle-down"></i> </button> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse pull-left" id="navbar-collapse"> <ul class="nav navbar-nav"> <li><a href="/OpenTl.Schema/about.html">About This Project</a></li> <li class="active"><a href="/OpenTl.Schema/api">API</a></li> </ul> </div> <!-- /.navbar-collapse --> <!-- Navbar Right Menu --> </nav> </header> <!-- Left side column. contains the logo and sidebar --> <aside class="main-sidebar "> <section class="infobar" data-spy="affix" data-offset-top="60" data-offset-bottom="200"> <div id="infobar-headings"><h6>On This Page</h6><p><a href="#Syntax">Syntax</a></p> <p><a href="#Value">Value</a></p> <hr class="infobar-hidden"> </div> </section> <section class="sidebar"> <script src="/OpenTl.Schema/assets/js/lunr.min.js"></script> <script src="/OpenTl.Schema/assets/js/searchIndex.js"></script> <div class="sidebar-form"> <div class="input-group"> <input type="text" name="search" id="search" class="form-control" placeholder="Search Types..."> <span class="input-group-btn"> <button class="btn btn-flat"><i class="fa fa-search"></i></button> </span> </div> </div> <div id="search-results"> </div> <script> function runSearch(query){ $("#search-results").empty(); if( query.length < 2 ){ return; } var results = searchModule.search("*" + query + "*"); var listHtml = "<ul class='sidebar-menu'>"; listHtml += "<li class='header'>Type Results</li>"; if(results.length == 0 ){ listHtml += "<li>No results found</li>"; } else { for(var i = 0; i < results.length; ++i){ var res = results[i]; listHtml += "<li><a href='" + res.url + "'>" + htmlEscape(res.title) + "</a></li>"; } } listHtml += "</ul>"; $("#search-results").append(listHtml); } $(document).ready(function(){ $("#search").on('input propertychange paste', function() { runSearch($("#search").val()); }); }); function htmlEscape(html) { return document.createElement('div') .appendChild(document.createTextNode(html)) .parentNode .innerHTML; } </script> <hr> <ul class="sidebar-menu"> <li class="header">Namespace</li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema">OpenTl<wbr>.Schema</a></li> <li class="header">Type</li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue">IInputSecureValue</a></li> <li role="separator" class="divider"></li> <li class="header">Property Members</li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue/A574133D.html">Data</a></li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue/5BC7A274.html">Files</a></li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue/B8C69279.html">Flags</a></li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue/90CCD808.html">FrontSide</a></li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue/62F82B57.html">PlainData</a></li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue/07043DDD.html">ReverseSide</a></li> <li class="selected"><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue/4A6A9737.html">Selfie</a></li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue/C5ED858D.html">Translation</a></li> <li><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue/EFD03E1C.html">Type</a></li> </ul> </section> </aside> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <section class="content-header"> <h3><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue">IInputSecureValue</a>.</h3> <h1>Selfie <small>Property</small></h1> </section> <section class="content"> <div class="panel panel-default"> <div class="panel-body"> <dl class="dl-horizontal"> <dt>Namespace</dt> <dd><a href="/OpenTl.Schema/api/OpenTl.Schema">OpenTl<wbr>.Schema</a></dd> <dt>Containing Type</dt> <dd><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureValue">IInputSecureValue</a></dd> </dl> </div> </div> <h1 id="Syntax">Syntax</h1> <pre><code>IInputSecureFile Selfie { get; set; }</code></pre> <h1 id="Value">Value</h1> <div class="box"> <div class="box-body no-padding table-responsive"> <table class="table table-striped table-hover two-cols"> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody><tr> <td><a href="/OpenTl.Schema/api/OpenTl.Schema/IInputSecureFile">IInputSecureFile</a></td> <td></td> </tr> </tbody></table> </div> </div> </section> </div> <!-- Footer --> <footer class="main-footer"> </footer> </div> <div class="wrapper bottom-wrapper"> <footer class="bottom-footer"> Generated by <a href="https://wyam.io">Wyam</a> </footer> </div> <a href="javascript:" id="return-to-top"><i class="fa fa-chevron-up"></i></a> <script> // Close the sidebar if we select an anchor link $(".main-sidebar a[href^='#']:not('.expand')").click(function(){ $(document.body).removeClass('sidebar-open'); }); $(document).load(function() { mermaid.initialize( { flowchart: { htmlLabels: false, useMaxWidth:false } }); mermaid.init(undefined, ".mermaid") $('svg').addClass('img-responsive'); $('pre code').each(function(i, block) { hljs.highlightBlock(block); }); }); hljs.initHighlightingOnLoad(); // Back to top $(window).scroll(function() { if ($(this).scrollTop() >= 200) { // If page is scrolled more than 50px $('#return-to-top').fadeIn(1000); // Fade in the arrow } else { $('#return-to-top').fadeOut(1000); // Else fade out the arrow } }); $('#return-to-top').click(function() { // When arrow is clicked $('body,html').animate({ scrollTop : 0 // Scroll to top of body }, 500); }); </script> </body></html>
OpenTl/OpenTl.Schema
docs/api/OpenTl.Schema/IInputSecureValue/4A6A9737.html
HTML
mit
11,021
<?php namespace Oro\Bundle\WorkflowBundle\Configuration\Import; use Doctrine\Common\Collections\ArrayCollection; use Oro\Bundle\WorkflowBundle\Configuration\ConfigImportProcessorInterface; class WorkflowImportProcessorSupervisor implements ConfigImportProcessorInterface { /** @var WorkflowImportProcessor[]|ArrayCollection */ private $imports; /** @var WorkflowImportProcessor[]|ArrayCollection */ private $processed; /** @var ConfigImportProcessorInterface */ private $parent; public function __construct() { $this->imports = new ArrayCollection(); $this->processed = new ArrayCollection(); } /** * @param WorkflowImportProcessor $processor * @return $this */ public function addImportProcessor(WorkflowImportProcessor $processor) { $this->imports[] = $processor; return $this; } /** * {@inheritdoc} */ public function process(array $content, \SplFileInfo $contentSource): array { /** @var WorkflowImportProcessor $processor */ $processor = $this->imports->first(); if ($processor === false || $this->shouldSkip($processor)) { return $content; } $this->imports->removeElement($processor); $this->checkCircularReferences($contentSource, $processor); if (null !== $this->parent) { $processor->setParent($this->parent); } $content = $processor->process($content, $contentSource); $this->addProcessed($processor); return $content; } /** * @param WorkflowImportProcessor $processor * @return string */ private function getProcessorKey(WorkflowImportProcessor $processor): string { return sprintf('%s->%s', $processor->getResource(), $processor->getTarget()); } /** * @param WorkflowImportProcessor $processor */ private function addProcessed(WorkflowImportProcessor $processor) { $this->processed[$this->getProcessorKey($processor)] = $processor; } /** * @param WorkflowImportProcessor $processor * @return bool */ private function isProcessed(WorkflowImportProcessor $processor): bool { return isset($this->processed[$this->getProcessorKey($processor)]); } /** {@inheritdoc} */ public function setParent(ConfigImportProcessorInterface $parentProcessor) { $this->parent = $parentProcessor; } /** * @return ArrayCollection|WorkflowImportProcessor[] */ public function getInProgress() { $filter = function (WorkflowImportProcessor $importProcessor) { return $importProcessor->inProgress(); }; return $this->imports->filter($filter); } /** * @param \SplFileInfo $contentSource * @param WorkflowImportProcessor $current */ private function checkCircularReferences(\SplFileInfo $contentSource, WorkflowImportProcessor $current) { foreach ($this->getInProgress() as $importProcessor) { if ($importProcessor->getTarget() !== $current->getResource()) { continue; } throw new \LogicException( sprintf( 'Recursion met. File `%s` tries to import workflow `%s`' . ' for `%s` that currently imports it too in `%s`', $contentSource->getRealPath(), $current->getTarget(), $importProcessor->getTarget(), $importProcessor->getProgressFile() ) ); } } /** * @param WorkflowImportProcessor $current * @return bool */ private function shouldSkip(WorkflowImportProcessor $current): bool { //same import was already processed (incorrect usage) if ($this->isProcessed($current)) { return true; } return false; } }
orocrm/platform
src/Oro/Bundle/WorkflowBundle/Configuration/Import/WorkflowImportProcessorSupervisor.php
PHP
mit
3,986
/** * */ package vn.edu.voer.adapter; import java.util.ArrayList; import java.util.List; import vn.edu.voer.R; import vn.edu.voer.database.dao.MaterialDAO; import vn.edu.voer.object.Material; import android.content.Context; import android.graphics.Typeface; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; /** * @author sidd * * Nov 22, 2014 */ public class LibraryAdapter extends ArrayAdapter<Material> { private Context mCtx; private int mLayoutId; private List<Material> mMaterials; MaterialDAO md; /** * @param context * @param resource */ public LibraryAdapter(Context context, int resource, ArrayList<Material> materials) { super(context, resource); mCtx = context; mLayoutId = resource; mMaterials = materials; md = new MaterialDAO(context); } public void setMaterials(ArrayList<Material> materials) throws NullPointerException { mMaterials = materials; notifyDataSetChanged(); } /* * (non-Javadoc) * * @see android.widget.ArrayAdapter#getCount() */ @Override public int getCount() { return mMaterials.size(); } /* * (non-Javadoc) * * @see android.widget.ArrayAdapter#getView(int, android.view.View, * android.view.ViewGroup) */ @Override public View getView(final int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = LayoutInflater.from(mCtx).inflate(mLayoutId, parent, false); holder = new ViewHolder(); holder.title = (TextView) convertView.findViewById(R.id.frm_library_item_title); holder.btnRemove = (ImageView) convertView.findViewById(R.id.frm_library_item_btn_remove); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } final Material material = mMaterials.get(position); holder.title.setText(material.getTitle()); if (material.getMaterialType() == Material.TYPE_MODULE) { holder.title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_puzzle, 0, 0, 0); } else { holder.title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_book, 0, 0, 0); } if (material.isRead()) { holder.title.setTypeface(null, Typeface.NORMAL); } else { holder.title.setTypeface(null, Typeface.BOLD); } holder.btnRemove.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (md.deleteMaterial(material.getMaterialID())) { mMaterials.remove(position); notifyDataSetChanged(); } } }); return convertView; } /** * ViewHolder */ private static class ViewHolder { TextView title; ImageView btnRemove; // TextView lblAuthorAndYear; } }
hieutn/voer
Voer/src/vn/edu/voer/adapter/LibraryAdapter.java
Java
mit
2,825
# coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. # # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError from msrestazure.azure_operation import AzureOperationPoller import uuid from .. import models class StorageAccountsOperations(object): """StorageAccountsOperations operations. :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An objec model deserializer. """ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self.config = config def check_name_availability( self, account_name, custom_headers={}, raw=False, **operation_config): """ Checks that account name is valid and is not in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: :class:`StorageAccountCheckNameAvailabilityParameters <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccountCheckNameAvailabilityParameters>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`CheckNameAvailabilityResult <fixtures.acceptancetestsstoragemanagementclient.models.CheckNameAvailabilityResult>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('CheckNameAvailabilityResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def create( self, resource_group_name, account_name, parameters, custom_headers={}, raw=False, **operation_config): """ Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of properties, then HTTP 200 would be returned. :param resource_group_name: The name of the resource group within the user’s subscription. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str :param parameters: The parameters to provide for the created account. :type parameters: :class:`StorageAccountCreateParameters <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccountCreateParameters>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`AzureOperationPoller<msrestazure.azure_operation.AzureOperationPoller>` :return: A poller object which can return :class:`StorageAccount <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccount>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'accountName': self._serialize.url("account_name", account_name, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(parameters, 'StorageAccountCreateParameters') # Construct and send request def long_running_send(): request = self._client.put(url, query_parameters) return self._client.send( request, header_parameters, body_content, **operation_config) def get_long_running_status(status_link, headers={}): request = self._client.get(status_link) request.headers.update(headers) return self._client.send( request, header_parameters, **operation_config) def get_long_running_output(response): if response.status_code not in [200, 202]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('StorageAccount', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized long_running_operation_timeout = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) return AzureOperationPoller( long_running_send, get_long_running_output, get_long_running_status, long_running_operation_timeout) def delete( self, resource_group_name, account_name, custom_headers={}, raw=False, **operation_config): """ Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user’s subscription. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'accountName': self._serialize.url("account_name", account_name, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.delete(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200, 204]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_properties( self, resource_group_name, account_name, custom_headers={}, raw=False, **operation_config): """ Returns the properties for the specified storage account including but not limited to name, account type, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user’s subscription. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`StorageAccount <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccount>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'accountName': self._serialize.url("account_name", account_name, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('StorageAccount', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def update( self, resource_group_name, account_name, parameters, custom_headers={}, raw=False, **operation_config): """ Updates the account type or tags for a storage account. It can also be used to add a custom domain (note that custom domains cannot be added via the Create operation). Only one custom domain is supported per storage account. This API can only be used to update one of tags, accountType, or customDomain per call. To update multiple of these properties, call the API multiple times with one change per call. This call does not change the storage keys for the account. If you want to change storage account keys, use the RegenerateKey operation. The location and name of the storage account cannot be changed after creation. :param resource_group_name: The name of the resource group within the user’s subscription. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str :param parameters: The parameters to update on the account. Note that only one property can be changed at a time using this API. :type parameters: :class:`StorageAccountUpdateParameters <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccountUpdateParameters>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`StorageAccount <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccount>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'accountName': self._serialize.url("account_name", account_name, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(parameters, 'StorageAccountUpdateParameters') # Construct and send request request = self._client.patch(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('StorageAccount', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def list_keys( self, resource_group_name, account_name, custom_headers={}, raw=False, **operation_config): """ Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group. :type resource_group_name: str :param account_name: The name of the storage account. :type account_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`StorageAccountKeys <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccountKeys>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'accountName': self._serialize.url("account_name", account_name, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('StorageAccountKeys', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def list( self, custom_headers={}, raw=False, **operation_config): """ Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`StorageAccountPaged <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccountPaged>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp return response # Deserialize response deserialized = models.StorageAccountPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.StorageAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def list_by_resource_group( self, resource_group_name, custom_headers={}, raw=False, **operation_config): """ Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user’s subscription. :type resource_group_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`StorageAccountPaged <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccountPaged>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp return response # Deserialize response deserialized = models.StorageAccountPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.StorageAccountPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def regenerate_key( self, resource_group_name, account_name, key_name=None, custom_headers={}, raw=False, **operation_config): """ Regenerates the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user’s subscription. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. :type account_name: str :param key_name: Possible values include: 'key1', 'key2' :type key_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`StorageAccountKeys <fixtures.acceptancetestsstoragemanagementclient.models.StorageAccountKeys>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ regenerate_key = models.StorageAccountRegenerateKeyParameters(key_name=key_name) # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'accountName': self._serialize.url("account_name", account_name, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('StorageAccountKeys', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
stankovski/AutoRest
AutoRest/Generators/Python/Azure.Python.Tests/Expected/AcceptanceTests/StorageManagementClient/storagemanagementclient/operations/storage_accounts_operations.py
Python
mit
31,696
# HGE2D A 2D game engine written in and for Haskell ## Version 0.1.10.2 ## Install get it via `cabal install HGE2D` (https://hackage.haskell.org/package/HGE2D) or directly via git : `git clone https://github.com/I3ck/HGE2D.git` `cd HGE2D` `cabal install` (to install the lib) `cabal build` (to build the examples) ## Usage You have the state of your game. It should keep all the data you need to store for interactions with your game and rendering it. A very basic example : ```haskell data GameState = GameState { gsSize :: (Double, Double) -- size of the window , time :: Millisecond -- current time of your game's state , player :: Player -- your definition for a player , world :: World -- your definition for the world } ``` Note that none of these parameters are actually required. Just use what you'll need later on. A game which isn't dynamic won't have to store a time etc. As next step you'll have to define the `EngineState` for your `GameState` : ```haskell es = EngineState { getTitle = myGetTitle , getW = myGetW , getH = myGetH , getTime = myGetTime , setTime = mySetTime , moveTime = myMoveTime , click = myClick , hover = myHover , drag = myDrag , resize = myResize , getSize = myGetSize , toGlInstr = myToGlInstr } :: EngineState GameState ``` `EngineState` serves as collection of all the required functions for the game engine. You'll have to define all of these, the definitions are as follows (see examples for implementations) : ```haskell data EngineState a = EngineState { click :: PosX -> PosY -> a -> a -- how your game should change when clicked , hover :: PosX -> PosY -> a -> a -- how your game should change when hovered , drag :: PosX -> PosY -> a -> a -- how your game should change when dragged , resize :: (Width, Height) -> a -> a -- how to resize your game , getSize :: a -> (Width, Height) -- how to get the size of your game , moveTime :: Millisecond -> a -> a -- how your game should change over time , getTime :: a -> Millisecond -- how to get the current time of your game , setTime :: Millisecond -> a -> a -- how to set the time of your game , getTitle :: a -> String -- how to get the title of your game , toGlInstr :: a -> RenderInstruction -- how to receive a render instruction to display your game } ``` ### toGlInstr To actually render your game, `HGE2D` needs to know its RenderInstruction. ```haskell data RenderInstruction = RenderNothing | RenderWithCamera GlPosX GlPosY GlScaleX GlScaleY RenderInstruction | RenderText String | RenderLineStrip GlShape GL.GLfloat | RenderTriangle GlShape | RenderLineLoop GlShape GL.GLfloat | RenderScale GlScaleX GlScaleY | RenderTranslate GlPosX GlPosY | RenderRotate Double | RenderColorize GlColorRGB | RenderColorizeAlpha GlColorRGBA | RenderPreserve RenderInstruction | RenderMany [RenderInstruction] ``` `RenderInstruction` can be used to define pretty much any scene by combining the instructions. `RenderNothing` obviously does nothing and can be used when e.g. shapes shall be invisible / not rendered. `RenderText` is also obvious, since it will simply render a string. `RenderMany` can be used to combine multiple instructions. Your `GameState` will pretty likely be defined as a `RenderMany [player, map, ...]`. Scaling, translating and rotating will affect all the shapes to come. To scope them, use `RenderPreserve`. In combination with `RenderMany` : `RenderPreserve $ RenderMany [RenderTranslate 10 10, RenderRotate 0.1, player]`. See [Shapes.hs](src/HGE2D/Shapes.hs) for functions which will generate some basic shapes. It's also pretty straight forward to define your very own primitives in a similar manner. For more information please take a look at the examples. These will also always be up-to-date since they're compiled on every change. ## Examples [Full tower defense game](https://github.com/I3ck/HGE2Ddemo) [Simple "Hello world", showing draw methods and how to setup the state](src/examples/Example1.hs) [Example showing how to react to mouse actions. Also first example showing how to alter the game state](src/examples/Example2.hs) [Example showing how to add dynamic motions dependend on the time](src/examples/Example3.hs) [Example showing how to nest several RenderInstructions to create a single instruction by combination](src/examples/Example4.hs) ## Contribute Feel free to open an issue whenever you find a bug or are missing a feature. Also new shapes and named colors are always really helpful and should be pretty easy to contribute. Also I'd love to hear if you used this engine to write your own game.
I3ck/HGE2D
README.md
Markdown
mit
5,104
using System; using System.Security.Cryptography; using MasDev.Extensions; using MasDev.Utils; namespace MasDev.Security { public class SHA256PasswordHasher : IPasswordHasher { const int _saltSize = 25; public bool IsPasswordValid (byte[] clearPassword, IHashedPassword password) { var hash = GenerateSaltedHash (clearPassword, password.PasswordSalt); return CompareByteArrays (hash, password.PasswordHash); } public IHashedPassword HashPassword (byte[] clearPassword) { var salt = GenerateSalt (); var hash = GenerateSaltedHash (clearPassword, salt); return new BaseHashedPassword { PasswordSalt = salt, PasswordHash = hash }; } public string HashPassword (string clearText, string password) { return StringUtils.GetString (GenerateSaltedHash (clearText.AsByteArray (), password.AsByteArray ())); } static byte[] GenerateSalt () { using (var generator = RandomNumberGenerator.Create ()) { var bytes = new byte[_saltSize]; generator.GetNonZeroBytes (bytes); return bytes; } } static byte[] GenerateSaltedHash (byte[] plainText, byte[] salt) { var algorithm = new SHA256Managed (); var plainTextWithSaltBytes = new byte[plainText.Length + salt.Length]; for (int i = 0; i < plainText.Length; i++) plainTextWithSaltBytes [i] = plainText [i]; for (int i = 0; i < salt.Length; i++) plainTextWithSaltBytes [plainText.Length + i] = salt [i]; return algorithm.ComputeHash (plainTextWithSaltBytes); } static bool CompareByteArrays (byte[] array1, byte[] array2) { if (array1.Length != array2.Length) return false; for (int i = 0; i < array1.Length; i++) { if (array1 [i] != array2 [i]) return false; } return true; } } }
MasDevProject/CSharp.Common
MasDev.Common/Core/MasDev.Common.Core.Mono/Source/Security/SHA256PasswordHasher.cs
C#
mit
1,792
package gogoogleanalytics import ( "testing" "github.com/stretchr/testify/assert" "github.com/agileproducts/gogoogleclient" "fmt" "encoding/json" ) func TestAccountsList(test *testing.T) { client := gogoogleclient.Client("https://www.googleapis.com/auth/analytics") actual := AccountsList(client) blah, _ := json.Marshal(actual) fmt.Println(string(blah)) assert.NotNil(test, actual, "It should return a list of accounts") }
agileproducts/gogoogleclient
gogoogleanalytics/gogoogleanalytics_test.go
GO
mit
449
'use strict'; const test = require('tape'); const sinon = require('sinon'); const schedule = require('..'); const { _invocations } = require('../lib/Invocation') const { scheduledJobs } = require('../lib/Job') test("Convenience method", function (t) { let clock t.test("Setup", function (t) { clock = sinon.useFakeTimers(); t.end() }) t.test(".scheduleJob", function(t) { t.test("Returns Job instance", function (test) { const job = schedule.scheduleJob(new Date(Date.now() + 1000), function () { }); test.ok(job instanceof schedule.Job); job.cancel(); test.end(); }); t.test("Returns null if fewer than 2 arguments are passed", function (test) { test.plan(1); const fn = function() { return schedule.scheduleJob(function() {}); }; test.throws(fn, RangeError); test.end(); }); t.test("Returns null if the method argument is not a function", function (test) { test.plan(1); const fn = function() { return schedule.scheduleJob(new Date(Date.now() + 1000), {}); }; test.throws(fn, RangeError); test.end(); }); }); t.test(".scheduleJob(Date, fn)", function(t) { t.test("Runs job once at some date and does not cause a leak", function(test) { test.plan(3); schedule.scheduleJob(new Date(Date.now() + 3000), function() { test.ok(true); }); setTimeout(function() { test.equal(_invocations.length, 0) test.equal(Object.keys(scheduledJobs).length, 0) test.end(); }, 3250); clock.tick(3250); }) t.test("Job doesn't emit initial 'scheduled' event", function(test) { const job = schedule.scheduleJob(new Date(Date.now() + 1000), function () { }); job.on('scheduled', function() { test.ok(false); }); setTimeout(function() { test.end(); }, 1250); clock.tick(1250); }) t.test("Won't run job if scheduled in the past", function(test) { test.plan(1); const job = schedule.scheduleJob(new Date(Date.now() - 3000), function () { test.ok(false); }); test.equal(job, null); setTimeout(function() { test.end(); }, 1000); clock.tick(1000); }) }) t.test(".scheduleJob(RecurrenceRule, fn)", function(t) { t.test("Runs job at interval based on recur rule, repeating indefinitely", function(test) { test.plan(3); const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = schedule.scheduleJob(rule, function () { test.ok(true); }); setTimeout(function() { job.cancel(); test.end(); }, 3250); clock.tick(3250); }) t.test("Job doesn't emit initial 'scheduled' event", function(test) { /* * If this was Job#schedule it'd fire 4 times. */ test.plan(3); const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = new schedule.scheduleJob(rule, function () { }); job.on('scheduled', function(runOnDate) { test.ok(true); }); setTimeout(function() { job.cancel(); test.end(); }, 3250); clock.tick(3250); }) t.test("Doesn't invoke job if recur rule schedules it in the past", function(test) { test.plan(1); const rule = new schedule.RecurrenceRule(); rule.year = 1960; const job = schedule.scheduleJob(rule, function () { test.ok(false); }); test.equal(job, null); setTimeout(function() { test.end(); }, 1000); clock.tick(1000); }) }) t.test(".scheduleJob({...}, fn)", function(t) { t.test("Runs job at interval based on object, repeating indefinitely", function(test) { test.plan(3); const job = new schedule.scheduleJob({ second: null // Fire every second }, function () { test.ok(true); }); setTimeout(function() { job.cancel(); test.end(); }, 3250); clock.tick(3250); }) t.test("Job doesn't emit initial 'scheduled' event", function(test) { /* * With Job#schedule this would be 3: * scheduled at time 0 * scheduled at time 1000 * scheduled at time 2000 */ test.plan(2); const job = schedule.scheduleJob({ second: null // fire every second }, function () { }); job.on('scheduled', function() { test.ok(true); }); setTimeout(function() { job.cancel(); test.end(); }, 2250); clock.tick(2250); }) t.test("Doesn't invoke job if object schedules it in the past", function(test) { test.plan(1); const job = schedule.scheduleJob({ year: 1960 }, function () { test.ok(false); }); test.equal(job, null); setTimeout(function() { test.end(); }, 1000); clock.tick(1000); }) }) t.test(".scheduleJob({...}, {...}, fn)", function(t) { t.test("Callback called for each job if callback is provided", function(test) { test.plan(3); const job = new schedule.scheduleJob({ second: null // Fire every second }, function () { }, function () { test.ok(true); }); setTimeout(function() { job.cancel(); test.end(); }, 3250); clock.tick(3250); }) }) t.test(".rescheduleJob(job, {...})", function(t) { t.test("Reschedule jobs from object based to object based", function(test) { test.plan(3); const job = new schedule.scheduleJob({ second: null }, function () { test.ok(true); }); setTimeout(function() { schedule.rescheduleJob(job, { minute: null }); }, 3250); setTimeout(function() { job.cancel(); test.end(); }, 5000); clock.tick(5000); }) t.test("Reschedule jobs from every minutes to every second", function(test) { test.plan(3); const timeout = 60 * 1000; const job = new schedule.scheduleJob({ minute: null }, function () { test.ok(true); }); setTimeout(function() { schedule.rescheduleJob(job, { second: null }); }, timeout); setTimeout(function() { job.cancel(); test.end(); }, timeout + 2250); clock.tick(timeout + 2250); }) }) t.test(".rescheduleJob(job, Date)", function(t) { t.test("Reschedule jobs from Date to Date", function(test) { test.plan(1); const job = new schedule.scheduleJob(new Date(Date.now() + 3000), function () { test.ok(true); }); setTimeout(function() { schedule.rescheduleJob(job, new Date(Date.now() + 5000)); }, 1000); setTimeout(function() { test.end(); }, 6150); clock.tick(6150); }) t.test("Reschedule jobs that has been executed", function(test) { test.plan(2); const job = new schedule.scheduleJob(new Date(Date.now() + 1000), function () { test.ok(true); }); setTimeout(function() { schedule.rescheduleJob(job, new Date(Date.now() + 2000)); }, 2000); setTimeout(function() { test.end(); }, 5150); clock.tick(5150); }) }) t.test(".rescheduleJob(job, RecurrenceRule)", function(t) { t.test("Reschedule jobs from RecurrenceRule to RecurrenceRule", function (test) { test.plan(3); const timeout = 60 * 1000; const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = schedule.scheduleJob(rule, function () { test.ok(true); }); const newRule = new schedule.RecurrenceRule(); newRule.minute = null; setTimeout(function () { schedule.rescheduleJob(job, newRule); }, 2250); setTimeout(function () { job.cancel(); test.end(); }, timeout + 2250); clock.tick(timeout + 2250); }) t.test("Reschedule jobs from RecurrenceRule to Date", function (test) { test.plan(3); const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = schedule.scheduleJob(rule, function () { test.ok(true); }); setTimeout(function () { schedule.rescheduleJob(job, new Date(Date.now() + 2000)); }, 2150); setTimeout(function () { test.end(); }, 4250); clock.tick(4250); }) t.test("Reschedule jobs from RecurrenceRule to {...}", function (test) { test.plan(3); const timeout = 60 * 1000; const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = schedule.scheduleJob(rule, function () { test.ok(true); }); setTimeout(function () { schedule.rescheduleJob(job, { minute: null }); }, 2150); setTimeout(function () { job.cancel(); test.end(); }, timeout + 2150); clock.tick(timeout + 2150); }) t.test("Reschedule jobs that is not available", function (test) { test.plan(4); clock = sinon.useFakeTimers(); const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = schedule.scheduleJob(rule, function () { test.ok(true); }); setTimeout(function () { schedule.rescheduleJob(null, new Date(Date.now() + 2000)); }, 2150); setTimeout(function () { job.cancel(); test.end(); }, 4250); clock.tick(4250); }) }) t.test('.rescheduleJob("job name", {...})', function(t) { t.test("Reschedule jobs from object based to object based", function(test) { test.plan(3); const job = new schedule.scheduleJob({ second: null }, function () { test.ok(true); }); setTimeout(function() { schedule.rescheduleJob(job.name, { minute: null }); }, 3250); setTimeout(function() { job.cancel(); test.end(); }, 5000); clock.tick(5000); }) t.test("Reschedule jobs from every minutes to every second", function(test) { test.plan(3); const timeout = 60 * 1000; const job = new schedule.scheduleJob({ minute: null }, function () { test.ok(true); }); setTimeout(function() { schedule.rescheduleJob(job.name, { second: null }); }, timeout); setTimeout(function() { job.cancel(); test.end(); }, timeout + 2250); clock.tick(timeout + 2250); }) }) t.test('.rescheduleJob("job name", Date)', function(t) { t.test("Reschedule jobs from Date to Date", function(test) { test.plan(1); const job = new schedule.scheduleJob(new Date(Date.now() + 3000), function () { test.ok(true); }); setTimeout(function() { schedule.rescheduleJob(job.name, new Date(Date.now() + 5000)); }, 1000); setTimeout(function() { test.end(); }, 6150); clock.tick(6150); }) t.test("Rescheduling one-off job that has been executed by name throws an error", function(test) { test.plan(2); const job = new schedule.scheduleJob(new Date(Date.now() + 1000), function () { test.ok(true); }); setTimeout(function() { test.throws(function() { schedule.rescheduleJob(job.name, new Date(Date.now() + 2000)); }, /Error: Cannot reschedule one-off job by name, pass job reference instead/) }, 2000); setTimeout(function() { test.end(); }, 5150); clock.tick(5150); }) }) t.test('.rescheduleJob("job name", RecurrenceRule)', function(t) { t.test("Reschedule jobs from RecurrenceRule to RecurrenceRule", function(test) { test.plan(3); clock = sinon.useFakeTimers(); const timeout = 60 * 1000; const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = schedule.scheduleJob(rule, function () { test.ok(true); }); const newRule = new schedule.RecurrenceRule(); newRule.minute = null; setTimeout(function() { schedule.rescheduleJob(job.name, newRule); }, 2250); setTimeout(function() { job.cancel(); test.end(); }, timeout + 2250); clock.tick(timeout + 2250); }) t.test("Reschedule jobs from RecurrenceRule to Date", function(test) { test.plan(3); const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = schedule.scheduleJob(rule, function () { test.ok(true); }); setTimeout(function() { schedule.rescheduleJob(job.name, new Date(Date.now() + 2000)); }, 2150); setTimeout(function() { test.end(); }, 4250); clock.tick(4250); }) t.test("Reschedule jobs from RecurrenceRule to {...}", function(test) { test.plan(3); const timeout = 60 * 1000; const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = schedule.scheduleJob(rule, function () { test.ok(true); }); setTimeout(function() { schedule.rescheduleJob(job.name, { minute: null }); }, 2150); setTimeout(function() { job.cancel(); test.end(); }, timeout + 2150); clock.tick(timeout + 2150); }) t.test("Reschedule jobs that does not exist", function(test) { test.plan(5); const rule = new schedule.RecurrenceRule(); rule.second = null; // fire every second const job = schedule.scheduleJob(rule, function () { test.ok(true); }); setTimeout(function() { test.throws(function() { schedule.rescheduleJob("Blah", new Date(Date.now() + 2000)); }, /Error: Cannot reschedule one-off job by name, pass job reference instead/) }, 2150); setTimeout(function() { job.cancel(); test.end(); }, 4250); clock.tick(4250); }) }) t.test(".cancelJob(Job)", function(t) { t.test("Prevents all future invocations of Job passed in", function(test) { test.plan(2); clock = sinon.useFakeTimers(); const job = schedule.scheduleJob({ second: null }, function () { test.ok(true); }); setTimeout(function() { schedule.cancelJob(job); }, 2250); setTimeout(function() { test.end(); }, 3250); clock.tick(3250); }) t.test("Can cancel Jobs scheduled with Job#schedule", function(test) { test.plan(2); clock = sinon.useFakeTimers(); const job = new schedule.Job(function () { test.ok(true); }); job.schedule({ second: null }); setTimeout(function() { schedule.cancelJob(job); }, 2250); setTimeout(function() { test.end(); }, 3250); clock.tick(3250); }) t.test("Job emits 'canceled' event", function(test) { test.plan(1); const job = schedule.scheduleJob({ second: null }, function () { }); job.on('canceled', function() { test.ok(true); }); setTimeout(function() { schedule.cancelJob(job); test.end(); }, 1250); clock.tick(1250); }) }) t.test('.cancelJob("job name")', function(t) { t.test("Prevents all future invocations of Job identified by name", function(test) { test.plan(2); const job = schedule.scheduleJob({ second: null }, function () { test.ok(true); }); setTimeout(function() { schedule.cancelJob(job.name); }, 2250); setTimeout(function() { test.end(); }, 3250); clock.tick(3250); }) /* "Can cancel Jobs scheduled with Job#schedule", function(test) { test.plan(2); const job = new schedule.Job(function() { test.ok(true); }); job.schedule({ second: null }); setTimeout(function() { schedule.cancelJob(job.name); }, 2250); setTimeout(function() { test.end(); }, 3250); },*/ t.test("Job emits 'canceled' event", function(test) { test.plan(1); const job = schedule.scheduleJob({ second: null }, function () { }); job.on('canceled', function() { test.ok(true); }); setTimeout(function() { schedule.cancelJob(job.name); test.end(); }, 1250); clock.tick(1250); }) t.test("Does nothing if no job found by that name", function(test) { test.plan(3); clock = sinon.useFakeTimers(); const job = schedule.scheduleJob({ second: null }, function () { test.ok(true); }); setTimeout(function() { // This cancel should not affect anything schedule.cancelJob('blah'); }, 2250); setTimeout(function() { job.cancel(); // prevent tests from hanging test.end(); }, 3250); clock.tick(3250); }) }) t.test('.pendingInvocations()', function(t) { t.test("Retrieves pendingInvocations of the job", function(test) { const job = schedule.scheduleJob(new Date(Date.now() + 1000), function () { }); test.ok(job instanceof schedule.Job); test.ok(job.pendingInvocations[0].job); job.cancel(); test.end(); }) }) t.test("Restore", function (t) { clock.restore(); t.end() }) })
tejasmanohar/node-schedule
test/convenience-method-test.js
JavaScript
mit
18,008
# FreshcoMenu JPKE Assignment
Hmzhh/FreshcoMenu
README.md
Markdown
mit
30
#define MIN(x, y) (((x) < (y)) ? (x) : (y)) #define MAX(x, y) (((x) > (y)) ? (x) : (y)) #include "petscmat.h" #include "petsc_matvec_utils.h" #undef __FUNCT__ #define __FUNCT__ "MatAXPBYmy" PetscErrorCode MatAXPBYmy(PetscScalar a,PetscScalar b,Mat X,Mat Y,Mat *Z) { /* Compute Z = a*X + b*Y, where X,Y,Z are matrices, and a,b are scalars */ /* If Z doesn't already exist, it is created */ PetscErrorCode ierr; if ((*Z)) { ierr=MatCopy(Y,*Z,SAME_NONZERO_PATTERN);CHKERRQ(ierr); /* Z=Y */ } else { ierr=MatDuplicate(Y,MAT_COPY_VALUES,Z);CHKERRQ(ierr); } ierr=MatScale(*Z,b);CHKERRQ(ierr); /* Z=b*Z */ ierr=MatAXPY(*Z,a,X,SAME_NONZERO_PATTERN);CHKERRQ(ierr); /* Z=a*X+Z */ return 0; } #undef __FUNCT__ #define __FUNCT__ "VecAXPBYmy" PetscErrorCode VecAXPBYmy(PetscScalar a,PetscScalar b,Vec x,Vec y,Vec *z) { /* Compute z = a*x + b*y, where x,y,z are vectors, and a,b are scalars */ /* If z doesn't already exist, it is created */ PetscErrorCode ierr; if ((*z)) { ierr=VecCopy(y,*z);CHKERRQ(ierr); /* z=y */ } else { ierr=VecDuplicate(y,z);CHKERRQ(ierr); } ierr=VecScale(*z,b);CHKERRQ(ierr); /* z=b*z */ ierr=VecAXPY(*z,a,x); CHKERRQ(ierr); /* z=a*x+z */ return 0; } #undef __FUNCT__ #define __FUNCT__ "VecLoadIntoVectorRandomAccess" PetscErrorCode VecLoadIntoVectorRandomAccess(PetscViewer viewer,Vec vec, PetscInt length, PetscInt iRec) { /* Random access version of VecLoadIntoVector */ /* This version takes two additional arguments: */ /* length: length of the vector */ /* iRec: the record to read (iRec=1 is the first record; iRec=numRecs is the last record) */ PetscErrorCode ierr; int fp; off_t off,offset; PetscFunctionBegin; off = PETSC_BINARY_SCALAR_SIZE*(length+1)*(iRec-1); ierr = PetscViewerBinaryGetDescriptor(viewer,&fp);CHKERRQ(ierr); ierr = PetscBinarySeek(fp,off,PETSC_BINARY_SEEK_SET,&offset);CHKERRQ(ierr); ierr = VecLoad(vec,viewer);CHKERRQ(ierr); /* IntoVector */ PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "VecLoadVecIntoArray" PetscErrorCode VecLoadVecIntoArray(Vec v, const char filename[], PetscScalar *arr) { /* Loads vector from file and copies over local piece of the data to an array */ /* You MUST preallocate memory for the array before calling this routine */ /* Input vector v is used as a template so that processor partioning is preserved */ /* as desired */ Vec tmpVec; PetscScalar *localtmpVec; PetscErrorCode ierr; PetscViewer fd; PetscInt lDim, i; PetscFunctionBegin; /* Load data into vector */ ierr = VecDuplicate(v,&tmpVec);CHKERRQ(ierr); ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,filename,FILE_MODE_READ,&fd);CHKERRQ(ierr); ierr = VecLoad(tmpVec,fd);CHKERRQ(ierr); /* IntoVector */ ierr = PetscViewerDestroy(&fd);CHKERRQ(ierr); /* Get pointer to local data */ ierr = VecGetArray(tmpVec,&localtmpVec);CHKERRQ(ierr); ierr = VecGetLocalSize(tmpVec,&lDim);CHKERRQ(ierr); /* Copy data to array. First allocate memory */ /* ierr = PetscMalloc(lDim*sizeof(PetscScalar),&arr);CHKERRQ(ierr); */ for (i=0; i<lDim; i++) { arr[i]=localtmpVec[i]; } /* Destroy objects */ ierr = VecRestoreArray(tmpVec,&localtmpVec);CHKERRQ(ierr); ierr = VecDestroy(&tmpVec);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNCT__ #define __FUNCT__ "MatGetSizeFromFile" PetscErrorCode MatGetSizeFromFile(const char filename[], PetscInt *M, PetscInt *N, PetscInt *nnz) { /* Function to read matrix size from file filename. */ /* USAGE: MatGetSizeFromFile(filename,&M,&N,&nnz); */ /* You can pass PETSC_NULL for any of the size arguments */ PetscErrorCode ierr; PetscInt header[4]; int fp; PetscViewer viewer; PetscFunctionBegin; ierr = PetscViewerBinaryOpen(PETSC_COMM_SELF,filename,FILE_MODE_READ,&viewer);CHKERRQ(ierr); ierr = PetscViewerBinaryGetDescriptor(viewer,&fp);CHKERRQ(ierr); /* Read header */ ierr = PetscBinaryRead(fp,(char *)header,4,NULL,PETSC_INT);CHKERRQ(ierr); ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); /* error checking on file */ if (header[0] != MAT_FILE_CLASSID) SETERRQ(PETSC_COMM_WORLD,PETSC_ERR_FILE_UNEXPECTED,"not matrix object"); if (M) *M = header[1]; if (N) *N = header[2]; if (nnz) *nnz = header[3]; PetscFunctionReturn(0); } // #undef __FUNCT__ // #define __FUNCT__ "VecWrite" // PetscErrorCode VecWrite(const char *fileName, Vec v, PetscBool appendToFile) // { // PetscErrorCode ierr; // PetscViewer viewer; // // if (appendToFile) { // ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,fileName,FILE_MODE_APPEND,&viewer);CHKERRQ(ierr); // } else { // ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD,fileName,FILE_MODE_WRITE,&viewer);CHKERRQ(ierr); // } // // ierr = VecView(v,viewer);CHKERRQ(ierr); // ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr); // // return 0; // }
samarkhatiwala/tmm
driver/current/petsc_matvec_utils.c
C
mit
4,935
package proxy.lab; public interface IRow { }
ashrafeme/ASD
ASD/src/proxy/lab/IRow.java
Java
mit
52
# rplotfriend R package to help with plotting I made this package to help me make and/or edit ggplots. Installation (requires devtools package): ``` install_github('AliciaSchep/rplotfriend') ```
AliciaSchep/rplotfriend
README.md
Markdown
mit
200
package org.psjava.example.algo; import org.junit.Assert; import org.junit.Test; import org.psjava.algo.sequence.sort.MergeSort; import org.psjava.ds.array.MutableArray; import org.psjava.ds.array.MutableArrayFromVarargs; import org.psjava.util.DefaultComparator; /** * @implementation {@link MergeSort} * @see {@link SortingAlgorithmExample} */ public class MergeSortExample { @Test public void example() { MutableArray<Integer> array = MutableArrayFromVarargs.create(2, 1, 3); MergeSort.getInstance().sort(array, new DefaultComparator<Integer>()); Assert.assertEquals("(1,2,3)", array.toString()); } }
psjava/psjava
src/test/java/org/psjava/example/algo/MergeSortExample.java
Java
mit
666
package core.driver; import org.openqa.selenium.remote.DesiredCapabilities; /** * This interface has method for get Capabilities, Implementing class need to * define that * * @author prat3ik * */ public interface CapabilitiesManager { public DesiredCapabilities getCapabilities(); }
prat3ik/SeleniumFramework
src/test/java/core/driver/CapabilitiesManager.java
Java
mit
294
const mongoose = require('mongoose'); const accountSchema = new mongoose.Schema({ instagram_id: String, //id full_name: String, username: String, profile_picture: String, bio: String, posts: Number, follows: Number, followed_by: Number, //marks: [String] marks: [{type: mongoose.Schema.Types.ObjectId, ref: 'Mark'}] }, { timestamps: true }); const Account = mongoose.model('Account', accountSchema); module.exports = Account;
k-wong/LookMark
models/Account.js
JavaScript
mit
449
using System; using System.Collections.Generic; using System.Threading.Tasks; using Baseline; using Jasper.Logging; using Jasper.Persistence.Durability; using Jasper.Transports; using Jasper.Util; using Lamar; namespace Jasper.Runtime { public class CommandBus : ICommandBus { // TODO -- smelly that this is protected, stop that! protected readonly List<Envelope> _outstanding = new List<Envelope>(); [DefaultConstructor] public CommandBus(IMessagingRoot root) : this(root, Guid.NewGuid().ToString()) { } public CommandBus(IMessagingRoot root, string correlationId) { Root = root; Persistence = root.Persistence; CorrelationId = correlationId; } public string CorrelationId { get; protected set; } public IMessagingRoot Root { get; } public IEnvelopePersistence Persistence { get; } public IMessageLogger Logger => Root.MessageLogger; public IEnumerable<Envelope> Outstanding => _outstanding; public Task Invoke(object message) { return Root.Pipeline.InvokeNow(new Envelope(message) { ReplyUri = TransportConstants.RepliesUri, CorrelationId = CorrelationId }); } public async Task<T> Invoke<T>(object message) { if (message == null) throw new ArgumentNullException(nameof(message)); var envelope = new Envelope(message) { ReplyUri = TransportConstants.RepliesUri, ReplyRequested = typeof(T).ToMessageTypeName(), ResponseType = typeof(T), CorrelationId = CorrelationId }; await Root.Pipeline.InvokeNow(envelope); if (envelope.Response == null) { return default(T); } return (T)envelope.Response; } public Task Enqueue<T>(T message) { var envelope = Root.Router.RouteLocally(message); return persistOrSend(envelope); } public Task Enqueue<T>(T message, string workerQueue) { var envelope = Root.Router.RouteLocally(message, workerQueue); return persistOrSend(envelope); } public async Task<Guid> Schedule<T>(T message, DateTimeOffset executionTime) { var envelope = new Envelope(message) { ExecutionTime = executionTime, Destination = TransportConstants.DurableLocalUri }; var endpoint = Root.Runtime.EndpointFor(TransportConstants.DurableLocalUri); var writer = endpoint.DefaultSerializer; envelope.Data = writer.Write(message); envelope.ContentType = writer.ContentType; envelope.Status = EnvelopeStatus.Scheduled; envelope.OwnerId = TransportConstants.AnyNode; await ScheduleEnvelope(envelope); return envelope.Id; } public Task<Guid> Schedule<T>(T message, TimeSpan delay) { return Schedule(message, DateTimeOffset.UtcNow.Add(delay)); } internal Task ScheduleEnvelope(Envelope envelope) { if (envelope.Message == null) throw new ArgumentOutOfRangeException(nameof(envelope), "Envelope.Message is required"); if (!envelope.ExecutionTime.HasValue) throw new ArgumentOutOfRangeException(nameof(envelope), "No value for ExecutionTime"); envelope.OwnerId = TransportConstants.AnyNode; envelope.Status = EnvelopeStatus.Scheduled; if (EnlistedInTransaction) { return Transaction.ScheduleJob(envelope); } if (Persistence is NulloEnvelopePersistence) { Root.ScheduledJobs.Enqueue(envelope.ExecutionTime.Value, envelope); return Task.CompletedTask; } return Persistence.ScheduleJob(envelope); } private Task persistOrSend(Envelope envelope) { if (EnlistedInTransaction) { _outstanding.Fill(envelope); return envelope.Sender.IsDurable ? Transaction.Persist(envelope) : Task.CompletedTask; } return envelope.Send(); } public bool EnlistedInTransaction { get; protected set; } public Task EnlistInTransaction(IEnvelopeTransaction transaction) { var original = Transaction; Transaction = transaction; EnlistedInTransaction = true; return original?.CopyTo(transaction) ?? Task.CompletedTask; } public IEnvelopeTransaction Transaction { get; protected set; } } }
JasperFx/jasper
src/Jasper/Runtime/CommandBus.cs
C#
mit
4,899
#include "PICKUP.H" #include "CALCLARA.H" #include "CDTRACKS.H" #include "COLLIDE.H" #include "CONTROL.H" #include "DRAW.H" #include "EFFECTS.H" #include "GAMEFLOW.H" #include "HEALTH.H" #include "LARA.H" #include INPUT_H #include "OBJECTS.H" #include "SOUND.H" #include "SPECIFIC.H" #include "SWITCH.H" #include "ITEMS.H" #include "DELTAPAK.H" #ifdef PC_VERSION #include "GAME.H" #elif PSX_VERSION || PSXPC_VERSION || SAT_VERSION #include "SETUP.H" #include "CD.H" #include "GETSTUFF.H" #include "COLLIDE_S.H" #endif static short PickUpBounds[12] = // offset 0xA1338 { -256, 256, -200, 200, -256, 256, -1820, 1820, 0, 0, 0, 0 }; static struct PHD_VECTOR PickUpPosition = { 0, 0, -100 }; // offset 0xA1350 static short HiddenPickUpBounds[12] = // offset 0xA135C { -256, 256, -100, 100, -800, -256, -1820, 1820, -5460, 5460, 0, 0 }; static struct PHD_VECTOR HiddenPickUpPosition = { 0, 0, -690 }; // offset 0xA1374 static short CrowbarPickUpBounds[12] = // offset 0xA1380 { -256, 256, -100, 100, 200, 512, -1820, 1820, -5460, 5460, 0, 0 }; static struct PHD_VECTOR CrowbarPickUpPosition = { 0, 0, 215 }; // offset 0xA1398 static short JobyCrowPickUpBounds[12] = // offset 0xA13A4 { -512, 0, -100, 100, 0, 512, -1820, 1820, -5460, 5460, 0, 0 }; static struct PHD_VECTOR JobyCrowPickUpPosition = { -224, 0, 240 }; // offset 0xA13BC static short PlinthPickUpBounds[12] = // offset 0xA13C8 { -256, 256, -640, 640, -511, 0, -1820, 1820, -5460, 5460, 0, 0 }; static struct PHD_VECTOR PlinthPickUpPosition = { 0, 0, -460 }; // offset 0xA13E0 static short PickUpBoundsUW[12] = // offset 0xA13EC { -512, 512, -512, 512, -512, 512, -8190, 8190, -8190, 8190, -8190, 8190 }; static struct PHD_VECTOR PickUpPositionUW = { 0, -200, -350 }; // offset 0xA1404 static short KeyHoleBounds[12] = // offset 0xA1410 { -256, 256, 0, 0, 0, 412, -1820, 1820, -5460, 5460, -1820, 1820 }; static struct PHD_VECTOR KeyHolePosition = { 0, 0, 312 }; // offset 0xA1428 static short PuzzleBounds[12] = // offset 0xA1434 { 0, 0, -256, 256, 0, 0, -1820, 1820, -5460, 5460, -1820, 1820 }; static short SOBounds[12] = // offset 0xA144C { 0, 0, 0, 0, 0, 0, -1820, 1820, -5460, 5460, -1820, 1820 }; static struct PHD_VECTOR SOPos = { 0, 0, 0 }; // offset 0xA1464 short SearchCollectFrames[4] = { 180, 100, 153, 83 }; short SearchAnims[4] = { 464, 465, 466, 472 }; short SearchOffsets[4] = { 160, 96, 160, 112 }; static short MSBounds[12] = // offset 0xA1488 { 0, 0, 0, 0, 0, 0, -1820, 1820, -5460, 5460, -1820, 1820 }; static struct PHD_VECTOR MSPos = { 0, 0, 0 }; // offset 0xA14A0 unsigned char NumRPickups; // offset 0xA390C unsigned char RPickups[16]; struct PHD_VECTOR OldPickupPos; void MonitorScreenCollision(short item_num, struct ITEM_INFO* l, struct COLL_INFO* coll)//53428(<), 5388C(<) (F) { struct ITEM_INFO* item; short* bounds; item = &items[item_num]; if (l->anim_number == ANIMATION_LARA_BUTTON_PUSH && l->frame_number == anims[ANIMATION_LARA_BUTTON_PUSH].frame_base + 24) TestTriggersAtXYZ(item->pos.x_pos, item->pos.y_pos, item->pos.z_pos, item->room_number, 1, 0); if ((!(input & IN_ACTION) || l->current_anim_state != STATE_LARA_STOP || l->anim_number != ANIMATION_LARA_STAY_IDLE || lara.gun_status || item->status != ITEM_INACTIVE) && (!lara.IsMoving || lara.GeneralPtr != (void *)item_num)) { ObjectCollision(item_num, l, coll); } else { bounds = GetBoundsAccurate(item); MSBounds[0] = bounds[0] - 256; MSBounds[1] = bounds[1] + 256; MSBounds[4] = bounds[4] - 512; MSBounds[5] = bounds[5] + 512; MSPos.z = bounds[4] - 256; if (TestLaraPosition(MSBounds, item, l)) { if (MoveLaraPosition(&MSPos, item, l)) { l->current_anim_state = STATE_LARA_SWITCH_DOWN; l->anim_number = ANIMATION_LARA_BUTTON_PUSH; l->frame_number = anims[ANIMATION_LARA_BUTTON_PUSH].frame_base; lara.IsMoving = 0; lara.head_y_rot = 0; lara.head_x_rot = 0; lara.torso_y_rot = 0; lara.torso_x_rot = 0; lara.gun_status = LG_HANDS_BUSY; item->flags |= 0x20u; item->status = ITEM_ACTIVE; } else { lara.GeneralPtr = (void *)item_num; } } else if (lara.IsMoving && lara.GeneralPtr == (void *)item_num) { lara.IsMoving = 0; lara.gun_status = LG_NO_ARMS; } } } void CollectCarriedItems(struct ITEM_INFO* item/*$s3*/)//5339C, 53800 { struct ITEM_INFO* pickup; short pickup_number; pickup_number = item->carried_item; if (pickup_number != -1) { //loc_533CC while (pickup_number != -1) { pickup = &items[pickup_number]; AddDisplayPickup(pickup->object_number); KillItem(pickup_number); pickup_number = pickup->carried_item; } }//loc_53404 } void SearchObjectCollision(short item_num, struct ITEM_INFO* l, struct COLL_INFO* coll)//53080, 534E4 { UNIMPLEMENTED(); } void SearchObjectControl(short item_number)//52D54, 531B8 { UNIMPLEMENTED(); } int PickupTrigger(short item_num)//52CC0(<), 53124(<) (F) { struct ITEM_INFO* item = &items[item_num]; if (item->flags & IFLAG_KILLED && item->status != ITEM_INVISIBLE && item->item_flags[3] != 1 && item->trigger_flags & 0x80) { return 0; } KillItem(item_num); return 1; } int KeyTrigger(short item_num)//52C14(<), 53078(<) (F) { struct ITEM_INFO* item = &items[item_num]; int oldkey; if ((item->status != ITEM_ACTIVE || lara.gun_status == LG_HANDS_BUSY) && (!KeyTriggerActive || lara.gun_status != LG_HANDS_BUSY)) { return -1; } oldkey = KeyTriggerActive; if (!oldkey) { item->status = ITEM_DEACTIVATED; } KeyTriggerActive = FALSE; return oldkey; } void PuzzleHoleCollision(short item_num, struct ITEM_INFO* l, struct COLL_INFO* coll)//52520, 52984 { UNIMPLEMENTED(); } void PuzzleDoneCollision(short item_num, struct ITEM_INFO* l, struct COLL_INFO* coll)//524C8(<), 5292C (F) { if (items[item_num].trigger_flags > 999) { ObjectCollision(item_num, l, coll); } } void KeyHoleCollision(short item_num, struct ITEM_INFO* l, struct COLL_INFO* coll)//52188, 525EC { UNIMPLEMENTED(); } void PickUpCollision(short item_num, struct ITEM_INFO* l, struct COLL_INFO* coll)//516C8, 51B2C { UNIMPLEMENTED(); } void RegeneratePickups()//515AC, 51A10 (F) { int i; for(i = 0; i < NumRPickups; i++) { struct ITEM_INFO* item = &items[RPickups[i]]; if (item->status == ITEM_INVISIBLE) { short* ammo = NULL; if (item->object_number == CROSSBOW_AMMO1_ITEM) ammo = &lara.num_crossbow_ammo1; if (item->object_number == CROSSBOW_AMMO2_ITEM) ammo = &lara.num_crossbow_ammo2; if (item->object_number == HK_AMMO_ITEM) ammo = &lara.num_hk_ammo1; if (item->object_number == REVOLVER_AMMO_ITEM) ammo = &lara.num_revolver_ammo; if (item->object_number == SHOTGUN_AMMO1_ITEM) ammo = &lara.num_shotgun_ammo1; if (item->object_number == SHOTGUN_AMMO1_ITEM) ammo = &lara.num_shotgun_ammo2; if (ammo && *ammo == 0) { item->status = ITEM_INACTIVE; } } } } void AnimatingPickUp(short item_number)//51450(<), 518B4 (F) { struct ITEM_INFO* item; short room_number; item = &items[item_number]; if ((item->trigger_flags & 0x3F) == 5) { item->fallspeed += 6; item->pos.y_pos += item->fallspeed; room_number = item->room_number; GetFloor(item->pos.x_pos, item->pos.y_pos, item->pos.z_pos, &room_number); if (item->item_flags[0] < item->pos.y_pos) { item->pos.y_pos = item->item_flags[0]; if (item->fallspeed > 64) { item->fallspeed = -item->fallspeed >> 2; } else { //$5150C item->trigger_flags &= 0xFFC0; } }//$5151C if (item->room_number != room_number) { ItemNewRoom(item_number, room_number); }//$51598 }//$51540 else if ((item->trigger_flags & 0x3F) == 2 || (item->trigger_flags & 0x3F) == 6 || (item->trigger_flags & 0x3F) == 7 || (item->trigger_flags & 0x3F) == 8) { AnimateItem(item); } else if ((item->trigger_flags & 0x3F) == 9 || (item->trigger_flags == 0xB)) { //v1 = RelocPtr[45]; //a1 = v1[0]; //jalr a1(item_number); } } short* FindPlinth(struct ITEM_INFO* item)//51200, 51664 { UNIMPLEMENTED(); return 0; } void PuzzleDone(struct ITEM_INFO* item, short item_num)//51004, 51468 (F) { if (item->object_number == PUZZLE_HOLE1 && gfCurrentLevel == LVL5_GALLOWS_TREE) { IsAtmospherePlaying = 0; S_CDPlay(CDA_XA6_SPOOKY03, 0); SoundEffect(SFX_HANGMAN_LAUGH_OFFCAM, &item->pos, SFX_DEFAULT); } item->object_number += 8; // PUZZLE_HOLEx -> PUZZLE_DONEx item->anim_number = objects[item->object_number].anim_index; item->frame_number = anims[item->anim_number].frame_base; item->required_anim_state = 0; item->goal_anim_state = anims[item->anim_number].current_anim_state; item->current_anim_state = anims[item->anim_number].current_anim_state; AddActiveItem(item_num); item->flags |= IFLAG_ACTIVATION_MASK; item->status = ITEM_ACTIVE; if (item->trigger_flags == 0x3E6 && level_items > 0) { int i; for (i = 0; i < level_items; i++) { if (items[i].object_number == AIRLOCK_SWITCH && items[i].pos.x_pos == item->pos.x_pos && items[i].pos.z_pos == item->pos.z_pos) { FlipMap(items[i].trigger_flags - 7); flipmap[items[i].trigger_flags - 7] ^= IFLAG_ACTIVATION_MASK; items[i].status = ITEM_INACTIVE; items[i].flags |= 0x20; } } } if (item->trigger_flags > 1024) { cutrot = 0; cutseq_num = item->trigger_flags - 1024; } }
TOMB5/TOMB5
GAME/PICKUP.C
C++
mit
9,324
// // AppDelegate.h // iOSDesignPattern // // Created by xp_mac on 16/4/8. // Copyright © 2016年 xp_mac. All rights reserved. // #import <UIKit/UIKit.h> @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end
wxp2012/iOS_DesignPattern
iOSDesignPattern/AppDelegate.h
C
mit
279
define(['exports', 'module', './element/_element', './event/_event', './fix/_fix', './get/_get', './is/_is', './maintain/_maintain', './map/_map', './observe/_observe', './query/_query', './style/_style', './when/_when', './version'], function (exports, module, _element_element, _event_event, _fix_fix, _get_get, _is_is, _maintain_maintain, _map_map, _observe_observe, _query_query, _style_style, _when_when, _version) { // this builds up the UMD bundle 'use strict'; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _element = _interopRequireDefault(_element_element); var _event = _interopRequireDefault(_event_event); var _fix = _interopRequireDefault(_fix_fix); var _get = _interopRequireDefault(_get_get); var _is = _interopRequireDefault(_is_is); var _maintain = _interopRequireDefault(_maintain_maintain); var _map = _interopRequireDefault(_map_map); var _observe = _interopRequireDefault(_observe_observe); var _query = _interopRequireDefault(_query_query); var _style = _interopRequireDefault(_style_style); var _when = _interopRequireDefault(_when_when); var _version2 = _interopRequireDefault(_version); // save current window.ally for noConflict() var conflicted = typeof window !== 'undefined' && window.ally; module.exports = { element: _element['default'], event: _event['default'], fix: _fix['default'], get: _get['default'], is: _is['default'], maintain: _maintain['default'], map: _map['default'], observe: _observe['default'], query: _query['default'], style: _style['default'], when: _when['default'], version: _version2['default'], noConflict: function noConflict() { if (typeof window !== 'undefined' && window.ally === this) { window.ally = conflicted; } return this; } }; }); //# sourceMappingURL=ally.js.map
DNACodeStudios/ally.js
dist/amd/ally.js
JavaScript
mit
1,923
/** @jsx createElement */ /* eslint-disable import/no-extraneous-dependencies */ import { createElement } from 'rax'; import View from 'rax-view'; import { makeDecorator } from '@storybook/addons'; import parameters from './parameters'; import styles from './styles'; function centered(storyFn) { return ( <View style={styles.style}> <View style={styles.innerStyle}>{storyFn()}</View> </View> ); } export default makeDecorator({ ...parameters, wrapper: centered, }); if (module && module.hot && module.hot.decline) { module.hot.decline(); }
storybooks/react-storybook
addons/centered/src/rax.js
JavaScript
mit
568
Sequel::Model.plugin :active_model Sequel::Model.db.extension(:pagination)
jlefley/dabster
config/initializers/sequel.rb
Ruby
mit
75
var baseDir = process.env.PWD || ''; Server.upload = { init: { tmpDir: baseDir + '/.uploads/tmp', uploadDir: baseDir + '/.uploads', checkCreateDirectories: true, maxFileSize: 10000000, acceptFileTypes: /.(gif|jpe?g|png)$/i, getFileName: function (fileInfo, formData) { var name = fileInfo.name; var ext = name.substring(name.lastIndexOf(".")).toLowerCase(); return formData._id + ext; } }, deleteMaxRetries: 3, deleteRetriesDelay: 60000, delete: function(id, fileName, tryCount, fsUnlink) { if (! _.isNumber(tryCount)) tryCount = 0; if (tryCount < Server.upload.deleteMaxRetries) { if (! Contacts.findOne(id)) { var file = Server.upload.init.uploadDir + "/" + fileName; if (! fsUnlink) fsUnlink = fs.unlink; fsUnlink(file, Meteor.bindEnvironment(function (err) { if (err) { Meteor.setTimeout(function () { Server.upload.delete(id, fileName, tryCount + 1, fsUnlink); }, Server.upload.deleteRetriesDelay) } })); } } else { Email.send({ from: '[email protected]', to: '[email protected]', subject: 'Error deleting image ' + fileName, text: 'id: ' + id + ' - fileName: ' + fileName }); } } };
ManuelDeLeon/phonebook
server/lib/server_upload.js
JavaScript
mit
1,326
--- layout: post title: 容器间跨主机访问——自定义网桥 date: 2016-04-10 categories: Docker进阶 tags: Docker进阶 --- * content {:toc} 通过自定义网桥,实现容器互连。 [转:Linux 网桥配置命令:brctl](http://blog.csdn.net/dapao123456789/article/details/17204745) [LINUX下的网络设置 ifconfig ,route,gateway(转)](http://blog.sina.com.cn/s/blog_682686610100tn5h.html) ## Linux远程连接 >(其中涉及的一点)Linux系统中是通过ssh服务实现的远程登录功能。默认ssh服务开启了22端口,而且当我们安装完系统时,这个服务已经安装,并且是开机启动的。所以不需要我们额外配置什么就能直接远程登录linux系统。ssh服务的配置文件为 /etc/ssh/sshd_config,你可以修改这个配置文件来实现你想要的ssh服务。比如你可以更改启动端口为36000. > >因为是远程登录,所以你要登录的服务器一定会有一个IP或者主机名。 >【使用密钥认证机制远程登录linux】 >SSH服务支持一种安全认证机制,即密钥认证。所谓的密钥认证,实际上是使用一对加密字符串,一个称为公钥(public key), 任何人都可以看到其内容,用于加密;另一个称为密钥(private key),只有拥有者才能看到,用于解密。 通过公钥加密过的密文使用密钥可以轻松解密,但根据公钥来猜测密钥却十分困难。 ssh 的密钥认证就是使用了这一特性。服务器和客户端都各自拥有自己的公钥和密钥。 ### 通过自定义网桥 假设Host1:202.117.16.183 Host2:202.117.16.189 1.分别在Host1和Host2创建虚拟网桥 ``` ## create bridge on host1,2 respectively host1-ubuntu$ sudo apt-get install bridge-utils host1-ubuntu$ sudo brctl addbr br0 host2-ubuntu$ sudo brctl addbr br1 ## set bridge port and IP GW host1-ubuntu$ sudo ifconfig br0 202.117.16.183 netmask 255.255.255.0 host1-ubuntu$ sudo ifconfig addif br0 eth0 host1-ubuntu$ sudo route add default gw 202.117.16.1 sudo ifup br0 host2-ubuntu$ sudo ifconfig br1 202.117.16.189 netmask 255.255.255.0 host2-ubuntu$ sudo ifconfig addif br1 eth0 host2-ubuntu$ sudo route add default gw 202.117.16.1 sudo ifup br1 ``` 2.更改Docker配置自定义网桥并设置容器IP地址范围 ``` ## Host1 host1-ubuntu$ sudo vim /etc/default/docker ## add at last DOCKER_OPS= -b=br0 --fixed-cidr=同主机网段ip host1-ubuntu$ sudo service docker restart host1-ubuntu$ sudo ps -ef | grep docker root 16771 1 0 Jan12 ? 00:00:05 /usr/bin/docker daemon -b=br0 ## Host2 as Host1 ``` 至此Host1上新建的容器可以直接ping到Host2上创建的容器 3.总结 优点:配置简单,不依赖第三方软件 缺点:容器与主机在同网段,需要小心划分容器ip地址;需要网段控制权,在生产环境中不易实现(保证整个网段可用,容器与主机同一网段);不容易控制;兼容性不佳。
zam121118/zam121118.github.io
_posts/2016-04-10-3d5623e7-0762-4d47-9c4e-1d4f72fdb44b.md
Markdown
mit
2,978
--- version: v0.33.0 category: Development title: 'Build Instructions Windows' source_url: 'https://github.com/atom/electron/blob/master/docs/development/build-instructions-windows.md' --- # Build Instructions (Windows) Follow the guidelines below for building Electron on Windows. ## Prerequisites * Windows 7 / Server 2008 R2 or higher * Visual Studio 2013 - [download VS 2013 Community Edition for free](https://www.visualstudio.com/downloads/download-visual-studio-vs). * [Python 2.7](http://www.python.org/download/releases/2.7/) * [Node.js](http://nodejs.org/download/) * [Git](http://git-scm.com) If you don't currently have a Windows installation, [modern.ie](https://www.modern.ie/en-us/virtualization-tools#downloads) has timebombed versions of Windows that you can use to build Electron. Building Electron is done entirely with command-line scripts and cannot be done with Visual Studio. You can develop Electron with any editor but support for building with Visual Studio will come in the future. **Note:** Even though Visual Studio is not used for building, it's still **required** because we need the build toolchains it provides. **Note:** Visual Studio 2015 will not work. Please make sure to get MSVS **2013**. ## Getting the Code ```powershell $ git clone https://github.com/atom/electron.git ``` ## Bootstrapping The bootstrap script will download all necessary build dependencies and create the build project files. Notice that we're using `ninja` to build Electron so there is no Visual Studio project generated. ```powershell $ cd electron $ python script\bootstrap.py -v ``` ## Building Build both Release and Debug targets: ```powershell $ python script\build.py ``` You can also only build the Debug target: ```powershell $ python script\build.py -c D ``` After building is done, you can find `electron.exe` under `out\D` (debug target) or under `out\R` (release target). ## 64bit Build To build for the 64bit target, you need to pass `--target_arch=x64` when running the bootstrap script: ```powershell $ python script\bootstrap.py -v --target_arch=x64 ``` The other building steps are exactly the same. ## Tests Test your changes conform to the project coding style using: ```powershell $ python script\cpplint.py ``` Test functionality using: ```powershell $ python script\test.py ``` Tests that include native modules (e.g. `runas`) can't be executed with the debug build (see [#2558](https://github.com/atom/electron/issues/2558) for details), but they will work with the release build. To run the tests with the release build use: ```powershell $ python script\test.py -R ``` ## Troubleshooting ### Command xxxx not found If you encountered an error like `Command xxxx not found`, you may try to use the `VS2012 Command Prompt` console to execute the build scripts. ### Fatal internal compiler error: C1001 Make sure you have the latest Visual Studio update installed. ### Assertion failed: ((handle))->activecnt >= 0 If building under Cygwin, you may see `bootstrap.py` failed with following error: ``` Assertion failed: ((handle))->activecnt >= 0, file src\win\pipe.c, line 1430 Traceback (most recent call last): File "script/bootstrap.py", line 87, in <module> sys.exit(main()) File "script/bootstrap.py", line 22, in main update_node_modules('.') File "script/bootstrap.py", line 56, in update_node_modules execute([NPM, 'install']) File "/home/zcbenz/codes/raven/script/lib/util.py", line 118, in execute raise e subprocess.CalledProcessError: Command '['npm.cmd', 'install']' returned non-zero exit status 3 ``` This is caused by a bug when using Cygwin Python and Win32 Node together. The solution is to use the Win32 Python to execute the bootstrap script (assuming you have installed Python under `C:\Python27`): ```powershell $ /cygdrive/c/Python27/python.exe script/bootstrap.py ``` ### LNK1181: cannot open input file 'kernel32.lib' Try reinstalling 32bit Node.js. ### Error: ENOENT, stat 'C:\Users\USERNAME\AppData\Roaming\npm' Simply making that directory [should fix the problem](http://stackoverflow.com/a/25095327/102704): ```powershell $ mkdir ~\AppData\Roaming\npm ``` ### node-gyp is not recognized as an internal or external command You may get this error if you are using Git Bash for building, you should use PowerShell or VS2012 Command Prompt instead.
Kaizhi/electron.atom.io
_docs/v0.33.0/development/build-instructions-windows.md
Markdown
mit
4,384
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>17.4. signal — Set handlers for asynchronous events &mdash; Python 2.7.12 documentation</title> <link rel="stylesheet" href="../_static/classic.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.12', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.12 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.12 documentation" href="../contents.html" /> <link rel="up" title="17. Interprocess Communication and Networking" href="ipc.html" /> <link rel="next" title="17.5. popen2 — Subprocesses with accessible I/O streams" href="popen2.html" /> <link rel="prev" title="17.3. ssl — TLS/SSL wrapper for socket objects" href="ssl.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> <script type="text/javascript" src="../_static/version_switch.js"></script> </head> <body role="document"> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="popen2.html" title="17.5. popen2 — Subprocesses with accessible I/O streams" accesskey="N">next</a> |</li> <li class="right" > <a href="ssl.html" title="17.3. ssl — TLS/SSL wrapper for socket objects" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> &raquo;</li> <li> <span class="version_switcher_placeholder">2.7.12</span> <a href="../index.html">Documentation</a> &raquo; </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li> <li class="nav-item nav-item-2"><a href="ipc.html" accesskey="U">17. Interprocess Communication and Networking</a> &raquo;</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="module-signal"> <span id="signal-set-handlers-for-asynchronous-events"></span><h1>17.4. <a class="reference internal" href="#module-signal" title="signal: Set handlers for asynchronous events."><code class="xref py py-mod docutils literal"><span class="pre">signal</span></code></a> &#8212; Set handlers for asynchronous events<a class="headerlink" href="#module-signal" title="Permalink to this headline">¶</a></h1> <p>This module provides mechanisms to use signal handlers in Python. Some general rules for working with signals and their handlers:</p> <ul class="simple"> <li>A handler for a particular signal, once set, remains installed until it is explicitly reset (Python emulates the BSD style interface regardless of the underlying implementation), with the exception of the handler for <code class="xref py py-const docutils literal"><span class="pre">SIGCHLD</span></code>, which follows the underlying implementation.</li> <li>There is no way to &#8220;block&#8221; signals temporarily from critical sections (since this is not supported by all Unix flavors).</li> <li>Although Python signal handlers are called asynchronously as far as the Python user is concerned, they can only occur between the &#8220;atomic&#8221; instructions of the Python interpreter. This means that signals arriving during long calculations implemented purely in C (such as regular expression matches on large bodies of text) may be delayed for an arbitrary amount of time.</li> <li>When a signal arrives during an I/O operation, it is possible that the I/O operation raises an exception after the signal handler returns. This is dependent on the underlying Unix system&#8217;s semantics regarding interrupted system calls.</li> <li>Because the C signal handler always returns, it makes little sense to catch synchronous errors like <code class="xref py py-const docutils literal"><span class="pre">SIGFPE</span></code> or <code class="xref py py-const docutils literal"><span class="pre">SIGSEGV</span></code>.</li> <li>Python installs a small number of signal handlers by default: <code class="xref py py-const docutils literal"><span class="pre">SIGPIPE</span></code> is ignored (so write errors on pipes and sockets can be reported as ordinary Python exceptions) and <code class="xref py py-const docutils literal"><span class="pre">SIGINT</span></code> is translated into a <a class="reference internal" href="exceptions.html#exceptions.KeyboardInterrupt" title="exceptions.KeyboardInterrupt"><code class="xref py py-exc docutils literal"><span class="pre">KeyboardInterrupt</span></code></a> exception. All of these can be overridden.</li> <li>Some care must be taken if both signals and threads are used in the same program. The fundamental thing to remember in using signals and threads simultaneously is: always perform <a class="reference internal" href="#module-signal" title="signal: Set handlers for asynchronous events."><code class="xref py py-func docutils literal"><span class="pre">signal()</span></code></a> operations in the main thread of execution. Any thread can perform an <a class="reference internal" href="#signal.alarm" title="signal.alarm"><code class="xref py py-func docutils literal"><span class="pre">alarm()</span></code></a>, <a class="reference internal" href="#signal.getsignal" title="signal.getsignal"><code class="xref py py-func docutils literal"><span class="pre">getsignal()</span></code></a>, <a class="reference internal" href="#signal.pause" title="signal.pause"><code class="xref py py-func docutils literal"><span class="pre">pause()</span></code></a>, <a class="reference internal" href="#signal.setitimer" title="signal.setitimer"><code class="xref py py-func docutils literal"><span class="pre">setitimer()</span></code></a> or <a class="reference internal" href="#signal.getitimer" title="signal.getitimer"><code class="xref py py-func docutils literal"><span class="pre">getitimer()</span></code></a>; only the main thread can set a new signal handler, and the main thread will be the only one to receive signals (this is enforced by the Python <a class="reference internal" href="#module-signal" title="signal: Set handlers for asynchronous events."><code class="xref py py-mod docutils literal"><span class="pre">signal</span></code></a> module, even if the underlying thread implementation supports sending signals to individual threads). This means that signals can&#8217;t be used as a means of inter-thread communication. Use locks instead.</li> </ul> <p>The variables defined in the <a class="reference internal" href="#module-signal" title="signal: Set handlers for asynchronous events."><code class="xref py py-mod docutils literal"><span class="pre">signal</span></code></a> module are:</p> <dl class="data"> <dt id="signal.SIG_DFL"> <code class="descclassname">signal.</code><code class="descname">SIG_DFL</code><a class="headerlink" href="#signal.SIG_DFL" title="Permalink to this definition">¶</a></dt> <dd><p>This is one of two standard signal handling options; it will simply perform the default function for the signal. For example, on most systems the default action for <code class="xref py py-const docutils literal"><span class="pre">SIGQUIT</span></code> is to dump core and exit, while the default action for <code class="xref py py-const docutils literal"><span class="pre">SIGCHLD</span></code> is to simply ignore it.</p> </dd></dl> <dl class="data"> <dt id="signal.SIG_IGN"> <code class="descclassname">signal.</code><code class="descname">SIG_IGN</code><a class="headerlink" href="#signal.SIG_IGN" title="Permalink to this definition">¶</a></dt> <dd><p>This is another standard signal handler, which will simply ignore the given signal.</p> </dd></dl> <dl class="data"> <dt> <code class="descname">SIG*</code></dt> <dd><p>All the signal numbers are defined symbolically. For example, the hangup signal is defined as <code class="xref py py-const docutils literal"><span class="pre">signal.SIGHUP</span></code>; the variable names are identical to the names used in C programs, as found in <code class="docutils literal"><span class="pre">&lt;signal.h&gt;</span></code>. The Unix man page for &#8216;<code class="xref c c-func docutils literal"><span class="pre">signal()</span></code>&#8216; lists the existing signals (on some systems this is <em class="manpage">signal(2)</em>, on others the list is in <em class="manpage">signal(7)</em>). Note that not all systems define the same set of signal names; only those names defined by the system are defined by this module.</p> </dd></dl> <dl class="data"> <dt id="signal.CTRL_C_EVENT"> <code class="descclassname">signal.</code><code class="descname">CTRL_C_EVENT</code><a class="headerlink" href="#signal.CTRL_C_EVENT" title="Permalink to this definition">¶</a></dt> <dd><p>The signal corresponding to the <code class="kbd docutils literal"><span class="pre">Ctrl+C</span></code> keystroke event. This signal can only be used with <a class="reference internal" href="os.html#os.kill" title="os.kill"><code class="xref py py-func docutils literal"><span class="pre">os.kill()</span></code></a>.</p> <p>Availability: Windows.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.7.</span></p> </div> </dd></dl> <dl class="data"> <dt id="signal.CTRL_BREAK_EVENT"> <code class="descclassname">signal.</code><code class="descname">CTRL_BREAK_EVENT</code><a class="headerlink" href="#signal.CTRL_BREAK_EVENT" title="Permalink to this definition">¶</a></dt> <dd><p>The signal corresponding to the <code class="kbd docutils literal"><span class="pre">Ctrl+Break</span></code> keystroke event. This signal can only be used with <a class="reference internal" href="os.html#os.kill" title="os.kill"><code class="xref py py-func docutils literal"><span class="pre">os.kill()</span></code></a>.</p> <p>Availability: Windows.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.7.</span></p> </div> </dd></dl> <dl class="data"> <dt id="signal.NSIG"> <code class="descclassname">signal.</code><code class="descname">NSIG</code><a class="headerlink" href="#signal.NSIG" title="Permalink to this definition">¶</a></dt> <dd><p>One more than the number of the highest signal number.</p> </dd></dl> <dl class="data"> <dt id="signal.ITIMER_REAL"> <code class="descclassname">signal.</code><code class="descname">ITIMER_REAL</code><a class="headerlink" href="#signal.ITIMER_REAL" title="Permalink to this definition">¶</a></dt> <dd><p>Decrements interval timer in real time, and delivers <code class="xref py py-const docutils literal"><span class="pre">SIGALRM</span></code> upon expiration.</p> </dd></dl> <dl class="data"> <dt id="signal.ITIMER_VIRTUAL"> <code class="descclassname">signal.</code><code class="descname">ITIMER_VIRTUAL</code><a class="headerlink" href="#signal.ITIMER_VIRTUAL" title="Permalink to this definition">¶</a></dt> <dd><p>Decrements interval timer only when the process is executing, and delivers SIGVTALRM upon expiration.</p> </dd></dl> <dl class="data"> <dt id="signal.ITIMER_PROF"> <code class="descclassname">signal.</code><code class="descname">ITIMER_PROF</code><a class="headerlink" href="#signal.ITIMER_PROF" title="Permalink to this definition">¶</a></dt> <dd><p>Decrements interval timer both when the process executes and when the system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL, this timer is usually used to profile the time spent by the application in user and kernel space. SIGPROF is delivered upon expiration.</p> </dd></dl> <p>The <a class="reference internal" href="#module-signal" title="signal: Set handlers for asynchronous events."><code class="xref py py-mod docutils literal"><span class="pre">signal</span></code></a> module defines one exception:</p> <dl class="exception"> <dt id="signal.ItimerError"> <em class="property">exception </em><code class="descclassname">signal.</code><code class="descname">ItimerError</code><a class="headerlink" href="#signal.ItimerError" title="Permalink to this definition">¶</a></dt> <dd><p>Raised to signal an error from the underlying <a class="reference internal" href="#signal.setitimer" title="signal.setitimer"><code class="xref py py-func docutils literal"><span class="pre">setitimer()</span></code></a> or <a class="reference internal" href="#signal.getitimer" title="signal.getitimer"><code class="xref py py-func docutils literal"><span class="pre">getitimer()</span></code></a> implementation. Expect this error if an invalid interval timer or a negative time is passed to <a class="reference internal" href="#signal.setitimer" title="signal.setitimer"><code class="xref py py-func docutils literal"><span class="pre">setitimer()</span></code></a>. This error is a subtype of <a class="reference internal" href="exceptions.html#exceptions.IOError" title="exceptions.IOError"><code class="xref py py-exc docutils literal"><span class="pre">IOError</span></code></a>.</p> </dd></dl> <p>The <a class="reference internal" href="#module-signal" title="signal: Set handlers for asynchronous events."><code class="xref py py-mod docutils literal"><span class="pre">signal</span></code></a> module defines the following functions:</p> <dl class="function"> <dt id="signal.alarm"> <code class="descclassname">signal.</code><code class="descname">alarm</code><span class="sig-paren">(</span><em>time</em><span class="sig-paren">)</span><a class="headerlink" href="#signal.alarm" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>time</em> is non-zero, this function requests that a <code class="xref py py-const docutils literal"><span class="pre">SIGALRM</span></code> signal be sent to the process in <em>time</em> seconds. Any previously scheduled alarm is canceled (only one alarm can be scheduled at any time). The returned value is then the number of seconds before any previously set alarm was to have been delivered. If <em>time</em> is zero, no alarm is scheduled, and any scheduled alarm is canceled. If the return value is zero, no alarm is currently scheduled. (See the Unix man page <em class="manpage">alarm(2)</em>.) Availability: Unix.</p> </dd></dl> <dl class="function"> <dt id="signal.getsignal"> <code class="descclassname">signal.</code><code class="descname">getsignal</code><span class="sig-paren">(</span><em>signalnum</em><span class="sig-paren">)</span><a class="headerlink" href="#signal.getsignal" title="Permalink to this definition">¶</a></dt> <dd><p>Return the current signal handler for the signal <em>signalnum</em>. The returned value may be a callable Python object, or one of the special values <a class="reference internal" href="#signal.SIG_IGN" title="signal.SIG_IGN"><code class="xref py py-const docutils literal"><span class="pre">signal.SIG_IGN</span></code></a>, <a class="reference internal" href="#signal.SIG_DFL" title="signal.SIG_DFL"><code class="xref py py-const docutils literal"><span class="pre">signal.SIG_DFL</span></code></a> or <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal"><span class="pre">None</span></code></a>. Here, <a class="reference internal" href="#signal.SIG_IGN" title="signal.SIG_IGN"><code class="xref py py-const docutils literal"><span class="pre">signal.SIG_IGN</span></code></a> means that the signal was previously ignored, <a class="reference internal" href="#signal.SIG_DFL" title="signal.SIG_DFL"><code class="xref py py-const docutils literal"><span class="pre">signal.SIG_DFL</span></code></a> means that the default way of handling the signal was previously in use, and <code class="docutils literal"><span class="pre">None</span></code> means that the previous signal handler was not installed from Python.</p> </dd></dl> <dl class="function"> <dt id="signal.pause"> <code class="descclassname">signal.</code><code class="descname">pause</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#signal.pause" title="Permalink to this definition">¶</a></dt> <dd><p>Cause the process to sleep until a signal is received; the appropriate handler will then be called. Returns nothing. Not on Windows. (See the Unix man page <em class="manpage">signal(2)</em>.)</p> </dd></dl> <dl class="function"> <dt id="signal.setitimer"> <code class="descclassname">signal.</code><code class="descname">setitimer</code><span class="sig-paren">(</span><em>which</em>, <em>seconds</em><span class="optional">[</span>, <em>interval</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#signal.setitimer" title="Permalink to this definition">¶</a></dt> <dd><p>Sets given interval timer (one of <a class="reference internal" href="#signal.ITIMER_REAL" title="signal.ITIMER_REAL"><code class="xref py py-const docutils literal"><span class="pre">signal.ITIMER_REAL</span></code></a>, <a class="reference internal" href="#signal.ITIMER_VIRTUAL" title="signal.ITIMER_VIRTUAL"><code class="xref py py-const docutils literal"><span class="pre">signal.ITIMER_VIRTUAL</span></code></a> or <a class="reference internal" href="#signal.ITIMER_PROF" title="signal.ITIMER_PROF"><code class="xref py py-const docutils literal"><span class="pre">signal.ITIMER_PROF</span></code></a>) specified by <em>which</em> to fire after <em>seconds</em> (float is accepted, different from <a class="reference internal" href="#signal.alarm" title="signal.alarm"><code class="xref py py-func docutils literal"><span class="pre">alarm()</span></code></a>) and after that every <em>interval</em> seconds. The interval timer specified by <em>which</em> can be cleared by setting seconds to zero.</p> <p>When an interval timer fires, a signal is sent to the process. The signal sent is dependent on the timer being used; <a class="reference internal" href="#signal.ITIMER_REAL" title="signal.ITIMER_REAL"><code class="xref py py-const docutils literal"><span class="pre">signal.ITIMER_REAL</span></code></a> will deliver <code class="xref py py-const docutils literal"><span class="pre">SIGALRM</span></code>, <a class="reference internal" href="#signal.ITIMER_VIRTUAL" title="signal.ITIMER_VIRTUAL"><code class="xref py py-const docutils literal"><span class="pre">signal.ITIMER_VIRTUAL</span></code></a> sends <code class="xref py py-const docutils literal"><span class="pre">SIGVTALRM</span></code>, and <a class="reference internal" href="#signal.ITIMER_PROF" title="signal.ITIMER_PROF"><code class="xref py py-const docutils literal"><span class="pre">signal.ITIMER_PROF</span></code></a> will deliver <code class="xref py py-const docutils literal"><span class="pre">SIGPROF</span></code>.</p> <p>The old values are returned as a tuple: (delay, interval).</p> <p>Attempting to pass an invalid interval timer will cause an <a class="reference internal" href="#signal.ItimerError" title="signal.ItimerError"><code class="xref py py-exc docutils literal"><span class="pre">ItimerError</span></code></a>. Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="signal.getitimer"> <code class="descclassname">signal.</code><code class="descname">getitimer</code><span class="sig-paren">(</span><em>which</em><span class="sig-paren">)</span><a class="headerlink" href="#signal.getitimer" title="Permalink to this definition">¶</a></dt> <dd><p>Returns current value of a given interval timer specified by <em>which</em>. Availability: Unix.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="signal.set_wakeup_fd"> <code class="descclassname">signal.</code><code class="descname">set_wakeup_fd</code><span class="sig-paren">(</span><em>fd</em><span class="sig-paren">)</span><a class="headerlink" href="#signal.set_wakeup_fd" title="Permalink to this definition">¶</a></dt> <dd><p>Set the wakeup fd to <em>fd</em>. When a signal is received, a <code class="docutils literal"><span class="pre">'\0'</span></code> byte is written to the fd. This can be used by a library to wakeup a poll or select call, allowing the signal to be fully processed.</p> <p>The old wakeup fd is returned. <em>fd</em> must be non-blocking. It is up to the library to remove any bytes before calling poll or select again.</p> <p>When threads are enabled, this function can only be called from the main thread; attempting to call it from other threads will cause a <a class="reference internal" href="exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><code class="xref py py-exc docutils literal"><span class="pre">ValueError</span></code></a> exception to be raised.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="signal.siginterrupt"> <code class="descclassname">signal.</code><code class="descname">siginterrupt</code><span class="sig-paren">(</span><em>signalnum</em>, <em>flag</em><span class="sig-paren">)</span><a class="headerlink" href="#signal.siginterrupt" title="Permalink to this definition">¶</a></dt> <dd><p>Change system call restart behaviour: if <em>flag</em> is <a class="reference internal" href="constants.html#False" title="False"><code class="xref py py-const docutils literal"><span class="pre">False</span></code></a>, system calls will be restarted when interrupted by signal <em>signalnum</em>, otherwise system calls will be interrupted. Returns nothing. Availability: Unix (see the man page <em class="manpage">siginterrupt(3)</em> for further information).</p> <p>Note that installing a signal handler with <a class="reference internal" href="#module-signal" title="signal: Set handlers for asynchronous events."><code class="xref py py-func docutils literal"><span class="pre">signal()</span></code></a> will reset the restart behaviour to interruptible by implicitly calling <code class="xref c c-func docutils literal"><span class="pre">siginterrupt()</span></code> with a true <em>flag</em> value for the given signal.</p> <div class="versionadded"> <p><span class="versionmodified">New in version 2.6.</span></p> </div> </dd></dl> <dl class="function"> <dt id="signal.signal"> <code class="descclassname">signal.</code><code class="descname">signal</code><span class="sig-paren">(</span><em>signalnum</em>, <em>handler</em><span class="sig-paren">)</span><a class="headerlink" href="#signal.signal" title="Permalink to this definition">¶</a></dt> <dd><p>Set the handler for signal <em>signalnum</em> to the function <em>handler</em>. <em>handler</em> can be a callable Python object taking two arguments (see below), or one of the special values <a class="reference internal" href="#signal.SIG_IGN" title="signal.SIG_IGN"><code class="xref py py-const docutils literal"><span class="pre">signal.SIG_IGN</span></code></a> or <a class="reference internal" href="#signal.SIG_DFL" title="signal.SIG_DFL"><code class="xref py py-const docutils literal"><span class="pre">signal.SIG_DFL</span></code></a>. The previous signal handler will be returned (see the description of <a class="reference internal" href="#signal.getsignal" title="signal.getsignal"><code class="xref py py-func docutils literal"><span class="pre">getsignal()</span></code></a> above). (See the Unix man page <em class="manpage">signal(2)</em>.)</p> <p>When threads are enabled, this function can only be called from the main thread; attempting to call it from other threads will cause a <a class="reference internal" href="exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><code class="xref py py-exc docutils literal"><span class="pre">ValueError</span></code></a> exception to be raised.</p> <p>The <em>handler</em> is called with two arguments: the signal number and the current stack frame (<code class="docutils literal"><span class="pre">None</span></code> or a frame object; for a description of frame objects, see the <a class="reference internal" href="../reference/datamodel.html#frame-objects"><span>description in the type hierarchy</span></a> or see the attribute descriptions in the <a class="reference internal" href="inspect.html#module-inspect" title="inspect: Extract information and source code from live objects."><code class="xref py py-mod docutils literal"><span class="pre">inspect</span></code></a> module).</p> <p>On Windows, <a class="reference internal" href="#module-signal" title="signal: Set handlers for asynchronous events."><code class="xref py py-func docutils literal"><span class="pre">signal()</span></code></a> can only be called with <code class="xref py py-const docutils literal"><span class="pre">SIGABRT</span></code>, <code class="xref py py-const docutils literal"><span class="pre">SIGFPE</span></code>, <code class="xref py py-const docutils literal"><span class="pre">SIGILL</span></code>, <code class="xref py py-const docutils literal"><span class="pre">SIGINT</span></code>, <code class="xref py py-const docutils literal"><span class="pre">SIGSEGV</span></code>, or <code class="xref py py-const docutils literal"><span class="pre">SIGTERM</span></code>. A <a class="reference internal" href="exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><code class="xref py py-exc docutils literal"><span class="pre">ValueError</span></code></a> will be raised in any other case.</p> </dd></dl> <div class="section" id="example"> <span id="signal-example"></span><h2>17.4.1. Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> <p>Here is a minimal example program. It uses the <a class="reference internal" href="#signal.alarm" title="signal.alarm"><code class="xref py py-func docutils literal"><span class="pre">alarm()</span></code></a> function to limit the time spent waiting to open a file; this is useful if the file is for a serial device that may not be turned on, which would normally cause the <a class="reference internal" href="os.html#os.open" title="os.open"><code class="xref py py-func docutils literal"><span class="pre">os.open()</span></code></a> to hang indefinitely. The solution is to set a 5-second alarm before opening the file; if the operation takes too long, the alarm signal will be sent, and the handler raises an exception.</p> <div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">signal</span><span class="o">,</span> <span class="nn">os</span> <span class="k">def</span> <span class="nf">handler</span><span class="p">(</span><span class="n">signum</span><span class="p">,</span> <span class="n">frame</span><span class="p">):</span> <span class="k">print</span> <span class="s1">&#39;Signal handler called with signal&#39;</span><span class="p">,</span> <span class="n">signum</span> <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;Couldn&#39;t open device!&quot;</span><span class="p">)</span> <span class="c1"># Set the signal handler and a 5-second alarm</span> <span class="n">signal</span><span class="o">.</span><span class="n">signal</span><span class="p">(</span><span class="n">signal</span><span class="o">.</span><span class="n">SIGALRM</span><span class="p">,</span> <span class="n">handler</span><span class="p">)</span> <span class="n">signal</span><span class="o">.</span><span class="n">alarm</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span> <span class="c1"># This open() may hang indefinitely</span> <span class="n">fd</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;/dev/ttyS0&#39;</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">O_RDWR</span><span class="p">)</span> <span class="n">signal</span><span class="o">.</span><span class="n">alarm</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="c1"># Disable the alarm</span> </pre></div> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">17.4. <code class="docutils literal"><span class="pre">signal</span></code> &#8212; Set handlers for asynchronous events</a><ul> <li><a class="reference internal" href="#example">17.4.1. Example</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="ssl.html" title="previous chapter">17.3. <code class="docutils literal"><span class="pre">ssl</span></code> &#8212; TLS/SSL wrapper for socket objects</a></p> <h4>Next topic</h4> <p class="topless"><a href="popen2.html" title="next chapter">17.5. <code class="docutils literal"><span class="pre">popen2</span></code> &#8212; Subprocesses with accessible I/O streams</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/signal.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="popen2.html" title="17.5. popen2 — Subprocesses with accessible I/O streams" >next</a> |</li> <li class="right" > <a href="ssl.html" title="17.3. ssl — TLS/SSL wrapper for socket objects" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="https://www.python.org/">Python</a> &raquo;</li> <li> <span class="version_switcher_placeholder">2.7.12</span> <a href="../index.html">Documentation</a> &raquo; </li> <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li> <li class="nav-item nav-item-2"><a href="ipc.html" >17. Interprocess Communication and Networking</a> &raquo;</li> </ul> </div> <div class="footer"> &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="https://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Jun 25, 2016. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3. </div> </body> </html>
ShiKaiWi/python-practice
resources/python-doc/library/signal.html
HTML
mit
33,361
/* tslint:disable */ import { ReaderFragment } from "relay-runtime"; import { FragmentRefs } from "relay-runtime"; export type ShowArtworks_show = { readonly id: string; readonly slug: string; readonly internalID: string; readonly " $fragmentRefs": FragmentRefs<"FilteredInfiniteScrollGrid_entity">; readonly " $refType": "ShowArtworks_show"; }; const node: ReaderFragment = { "kind": "Fragment", "name": "ShowArtworks_show", "type": "Show", "metadata": null, "argumentDefinitions": [], "selections": [ { "kind": "ScalarField", "alias": null, "name": "id", "args": null, "storageKey": null }, { "kind": "ScalarField", "alias": null, "name": "slug", "args": null, "storageKey": null }, { "kind": "ScalarField", "alias": null, "name": "internalID", "args": null, "storageKey": null }, { "kind": "FragmentSpread", "name": "FilteredInfiniteScrollGrid_entity", "args": null } ] }; (node as any).hash = 'd18ae5be25656a4cea38614cf43825e9'; export default node;
artsy/emission
src/__generated__/ShowArtworks_show.graphql.ts
TypeScript
mit
1,132
using System; namespace FCGagarin.PL.Admin.Models { public class ErrorViewModel { public string RequestId { get; set; } public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); } }
logical8/FCGagarin
FCGagarin.PL.Admin/Models/ErrorViewModel.cs
C#
mit
216
# Motion Planning: A simple based algorithm This is a sample-based algorithm called rapidly-exploring random tree, which implemented in C++ using OpenRAVE. ## What is the RRTs A Rapidly-exploring Random Tree (RRT) is a data structure and algorithm that is designed for efficiently searching nonconvex high-dimensional spaces. RRTs are constructed incrementally in a way that quickly reduces the expected distance of a randomly-chosen point to the tree. RRTs are particularly suited for path planning problems that involve obstacles and differential constraints (nonholonomic or kinodynamic). RRTs can be considered as a technique for generating open-loop trajectories for nonlinear systems with state constraints. An RRT can be intuitively considered as a Monte-Carlo way of biasing search into largest Voronoi regions. Some variations can be considered as stochastic fractals. Usually, an RRT alone is insufficient to solve a planning problem. Thus, it can be considered as a component that can be incorporated into the development of a variety of different planning algorithms.
xiao00li/RRT
README.md
Markdown
mit
1,080
define('MAF.control.InputButton', function () { var onValueNeeded = function (event) { var config = this.config, method = 'changeValue', callback = onValueCallback.bindTo(this), value = this.getValue(); callback.__event__ = event; if (config[method] && config[method].apply) { config[method].apply(this, [callback, value]); } else { this[method](callback, value); } }; var onValueCallback = function (value) { var event = arguments.callee.caller.__event__ || null; this.setValue(value); this.fire('onSelect', null, event); }; var createValueDisplay = function () { var dispayValue = this.getDisplayValue(); if (this.config.valueOnSubline) { this.valueDisplay = new MAF.element.Text({ ClassName: 'ControlValueContainerSubline', label: dispayValue }).appendTo(this); (function () { this.valueDisplay.data = this.getDisplayValue(); }).subscribeTo(this, ['onValueInitialized', 'onValueChanged'], this); } else if (this.ClassName !== 'ImageToggleButton') { this.valueDisplay = new MAF.control.ValueDisplay({ source: this, styles: { height: 'inherit' } }).appendTo(this); } else { this.valueDisplay = new MAF.element.Image({ src: dispayValue.src, styles: Object.merge({ hAlign: 'right', vAlign: 'center' }, this.config.toggleStyles || {}) }).appendTo(this); (function () { this.valueDisplay.setSource(this.getDisplayValue().src); }).subscribeTo(this, ['onValueInitialized', 'onValueChanged'], this); } }; return new MAF.Class({ ClassName: 'ControlInputButton', Extends: MAF.control.TextButton, Protected: { valueDisplayWidth: function (event) { if (!this.config.valueOnSubline && this.ClassName !== 'ImageToggleButton' && this.valueDisplay && !event.payload.skip) { this.valueDisplay.width = this.width; } }, dispatchEvents: function (event, payload) { if (event.type === 'select') { event.stopPropagation(); event.preventDefault(); return onValueNeeded.call(this); } this.parent(event, payload); } }, config: { options: [], value: null, valueOnSubline: false }, initialize: function () { this.ClassName += this.config.valueOnSubline ? 'Subline' : ''; this.parent(); this.valueDisplayWidth.subscribeTo(this, 'onAppend' , this); if (this.config.options) { this.setOptions(this.config.options); delete this.config.options; } this.setValue(this.config.value || ''); delete this.config.value; }, adjustAccessories: function () { var maxRight = this.width; if (this.secureIndicator && this.secure) { maxRight = this.secureIndicator.hOffset - this.secureIndicator.width; } if (this.valueDisplay && this.valueDisplay.config && this.valueDisplay.config.styles && (this.valueDisplay.config.styles.hAlign === 'right')) { this.valueDisplay.setStyles({ hOffset: maxRight }); } }, createContent: function () { var dispayValue = this.getDisplayValue(), config = this.config, onSubline = config.valueOnSubline || false, textKey = onSubline ? 'ControlValueContainerMainline' : 'ControlTextButtonText', textStyles = Object.clone(config.textStyles || Theme.getStyles(textKey) || {}); delete textStyles.width; this.content = new MAF.element.Text({ ClassName: textKey, label: config.label, styles: textStyles }).appendTo(this); createValueDisplay.call(this); }, getValue: function () { return String(this.retrieve('value') || ''); }, setValue: function (value) { var firstBlush = isEmpty(this.retrieve('value')), stringValue = value === null ? '' : String(value); if ((this.retrieve('value') || '') === stringValue) { return ''; } this.store('value', stringValue); this.fire(firstBlush ? 'onValueInitialized' : 'onValueChanged', { value: stringValue }); return this.getValue(); }, changeValue: function (callback, value) { callback(value); }, getDisplayValue: function (value) { value = value || this.getValue(); var label = value; this.getOptions().forEach(function (option) { if (option.value == value) { label = option.label; } }); return label; }, setOptions: function (values, labels) { values = [].concat(values); var options = values.map(function (value, v) { var o = typeOf(value) === 'object', l = labels && labels.length || 0; return value ? { value: o && 'value' in value ? value.value : value, label: l > v ? labels[v] : o && 'label' in value ? value.label : value } : value; }); this.store('options', options); this.fire('onOptionsChanged', { options: this.getOptions() }); }, getOptions: function () { return this.retrieve('options') || []; }, getOptionValues: function () { return this.getOptions().map(function (option) { return option.value; }); }, getOptionLabels: function () { return this.getOptions().map(function (option) { return option.label; }); }, generateStatePacket: function (packet) { packet = packet || {}; return this.parent(Object.merge({ value: this.getValue() }, packet)); }, inspectStatePacket: function (packet, focusOnly) { var data = this.parent(packet, focusOnly), type = typeOf(data); if (focusOnly) { return; } if (data === packet) { return packet; } switch(type) { case 'boolean': case 'string': return this.setValue(data); } for (var item in data) { switch (item) { case 'optionCancelled': if (data[item]) { this.fire('onOptionCancelled', data); data[item] = null; return data; } break; case 'optionSelected': if (data[item] && 'option' in data) { this.fire('onOptionSelected',data.option); data[item] = null; continue; } else if (data[item]===false) { this.fire('onOptionCancelled', data); data[item] = null; return data; } break; case 'option': this.setValue(data[item].value); break; case 'value': this.setValue(data[item]); break; } } return data; }, suicide: function () { this.valueDisplay.suicide(); delete this.valueDisplay; this.parent(); } }); }, { ControlInputButton: 'ControlButton', ControlInputButtonSubline: { renderSkin: function (state, w, h, args, theme) { var ff = new Frame(); theme.applyLayer('BaseGlow', ff); if (state === 'focused') { theme.applyLayer('BaseFocus', ff); } theme.applyLayer('BaseHighlight', ff); return ff; }, styles: { width: 'inherit', height: '91px' } }, ControlValueContainerMainline: { styles: { width: '100%', height: 'inherit', vOffset: 6, fontSize: 28, paddingLeft: 10, paddingRight: 10, anchorStyle: 'leftTop', truncation: 'end' } }, ControlValueContainerSubline: { styles: { width: '100%', height: 'inherit', truncation: 'end', paddingLeft: 10, anchorStyle: 'leftBottom', fontSize: 23, paddingBottom: 4, color: 'rgba(255,255,255,.7)' } } });
LibertyGlobal/maf3-test-runner
maf3-sdk/src/MAF/control/InputButton.js
JavaScript
mit
7,173
// @flow /* eslint-env mocha */ /* global suite, benchmark */ import getTime from '.' import moment from 'moment' suite('getTime', function () { benchmark('date-fns', function () { return getTime(this.date) }) benchmark('Moment.js', function () { return this.moment.valueOf() }) }, { setup: function () { this.date = new Date() this.moment = moment() } })
js-fns/date-fns
src/getTime/benchmark.js
JavaScript
mit
387
using System.Globalization; using Sitecore.Web.UI.WebControls; using Synthesis.FieldTypes.Interfaces; namespace Synthesis.FieldTypes { public class IntegerField : FieldType, IIntegerField { public IntegerField(LazyField field, string indexValue) : base(field, indexValue) { } /// <summary> /// Gets the value of the field. If the field does not have a value or the value isn't parseable, returns default(int). /// </summary> public virtual int Value { get { int value; if (int.TryParse(InnerField.Value, out value)) return value; return default(int); } set { SetFieldValue(value.ToString(CultureInfo.InvariantCulture)); } } /// <summary> /// Renders the field using a Sitecore FieldRenderer and returns the result /// </summary> public virtual string RenderedValue { get { return FieldRenderer.Render(InnerItem, InnerField.ID.ToString()); } } /// <summary> /// Checks if the field has a valid integer value /// </summary> /// <remarks>Note that Value will always return a valid int (0) even if HasValue is false. So check this first :)</remarks> public override bool HasValue { get { if (InnerField == null) return false; int value; return int.TryParse(InnerField.Value, out value); } } public override string ToString() { return Value.ToString(CultureInfo.InvariantCulture); } } }
roberthardy/Synthesis
Source/Synthesis/FieldTypes/IntegerField.cs
C#
mit
1,396
# Changelog ## 3.0.1 * Improved Travis CI testing. * Changed dependency of `symfony/http-foundation` to `~2.0`. * Fixed broken test. * Code cleanup. ## 3.0.0 * Renamed `Session` to `Request` (and `SessionInterface` to `RequestInterface`). * `Curl` will now always return an array with instances of `Response`. * Changed dependency of `symfony/http-foundation` to `~2.3`. ## 2.1 * Refactored Curl to be more testable. * Added more tests to improve coverage. ## 2.0.2 * Fixed an issue with empty responses. ## 2.0.1 * Fixed many issues with `Response::forge()` by using `CURLINFO_HEADER_SIZE`. * Changed dependency of `symfony/http-foundation` from `2.2.*` to `~2.2`. * Removed unused excepetions. * Improved documentation of the code. ## 2.0.0 Version 2.0 introduces a new library flow which changes the way `Dispatcher` and `Session` interacts with each other. If you've only used the static helper `Curl` in the past these changes shouldn't affect you that much. `Dispatcher` is stripped down to only be a wrapper around `curl_multi_init()` while `Session` continues to wrap around `curl_init()` but with more functionality previously located in `Dispatcher`.
Chnapy/Videotheque
vendor/jyggen/curl/changelog.md
Markdown
mit
1,173
package storm.hnsubscribe; import backtype.storm.Config; import backtype.storm.LocalCluster; import backtype.storm.StormSubmitter; import backtype.storm.spout.SpoutOutputCollector; import backtype.storm.task.OutputCollector; import backtype.storm.task.TopologyContext; import backtype.storm.topology.OutputFieldsDeclarer; import backtype.storm.topology.TopologyBuilder; import backtype.storm.topology.base.BaseRichBolt; import backtype.storm.topology.base.BaseRichSpout; import backtype.storm.tuple.Fields; import backtype.storm.tuple.Tuple; import backtype.storm.tuple.Values; import yieldbot.storm.spout.RedisPubSubSpout; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.select.Elements; import org.jsoup.nodes.Element; import java.io.IOException; import java.util.Map; public class PostTopology { public static class HomepageSpout extends BaseRichSpout { SpoutOutputCollector _collector; @Override public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) { _collector = collector; } @Override public void nextTuple() { Document doc = null; try { doc = Jsoup.connect("http://news.ycombinator.com").get(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (doc != null) { Elements elements = doc.select("td.title a"); for (Element el : elements) { _collector.emit(new Values(el.attr("href"))); } } } @Override public void declareOutputFields(OutputFieldsDeclarer declarer) { declarer.declare(new Fields("links")); } } public static class ParsePostBolt extends BaseRichBolt { OutputCollector _collector; @Override public void prepare(Map conf, TopologyContext context, OutputCollector collector) { _collector = collector; } @Override public void execute(Tuple tuple) { Document doc = null; try { doc = Jsoup.connect(tuple.getString(0)).get(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (doc != null) { Element title = doc.select("td.title a").first(); if (title != null) _collector.emit(tuple, new Values(title.text())); _collector.ack(tuple); } } @Override public void declareOutputFields(OutputFieldsDeclarer declarer) { declarer.declare(new Fields("title")); } } public static void main(String[] args) throws Exception { TopologyBuilder builder = new TopologyBuilder(); // builder.setSpout("post", new RedisPubSubSpout("127.0.0.1", 6379, "post")); builder.setSpout("link", new HomepageSpout()); builder.setBolt("parse", new ParsePostBolt(), 1).shuffleGrouping("link"); Config conf = new Config(); conf.setDebug(true); if (args != null && args.length > 0) { conf.setNumWorkers(3); StormSubmitter.submitTopology(args[0], conf, builder.createTopology()); } else { LocalCluster cluster = new LocalCluster(); cluster.submitTopology("test", conf, builder.createTopology()); // Utils.sleep(10000); // cluster.killTopology("test"); // cluster.shutdown(); } } }
pheuter/HN-Subscribe
src/storm/hnsubscribe/PostTopology.java
Java
mit
3,363
<html> <head> <title>Marion Roe's panel show appearances</title> <script type="text/javascript" src="../common.js"></script> <link rel="stylesheet" media="all" href="../style.css" type="text/css"/> <script type="text/javascript" src="../people.js"></script> <!--#include virtual="head.txt" --> </head> <body> <!--#include virtual="nav.txt" --> <div class="page"> <h1>Marion Roe's panel show appearances</h1> <p>Marion Roe (born 1936-07-15<sup><a href="https://en.wikipedia.org/wiki/Marion_Roe">[ref]</a></sup>) has appeared in <span class="total">2</span> episodes between 1982-1988. <a href="https://en.wikipedia.org/wiki/Marion_Roe">Marion Roe on Wikipedia</a>.</p> <div class="performerholder"> <table class="performer"> <tr style="vertical-align:bottom;"> <td><div style="height:100px;" class="performances female" title="1"></div><span class="year">1982</span></td> <td><div style="height:0px;" class="performances female" title=""></div><span class="year">1983</span></td> <td><div style="height:0px;" class="performances female" title=""></div><span class="year">1984</span></td> <td><div style="height:0px;" class="performances female" title=""></div><span class="year">1985</span></td> <td><div style="height:0px;" class="performances female" title=""></div><span class="year">1986</span></td> <td><div style="height:0px;" class="performances female" title=""></div><span class="year">1987</span></td> <td><div style="height:100px;" class="performances female" title="1"></div><span class="year">1988</span></td> </tr> </table> </div> <ol class="episodes"> <li><strong>1988-03-24</strong> / <a href="../shows/question-time.html">Question Time</a></li> <li><strong>1982-01-14</strong> / <a href="../shows/question-time.html">Question Time</a></li> </ol> </div> </body> </html>
slowe/panelshows
people/rjdpi477.html
HTML
mit
1,830
#include <iostream> #include <cassert> #include "CVirtualMachine.h" #include "common/Instructions.h" #include "common/Deserialize.h" CVirtualMachine::SFunctionFrame::SFunctionFrame() {} CVirtualMachine::SFunctionFrame::SFunctionFrame(uint32_t funcIndex, uint32_t instrIndex, uint32_t stackBaseIndex) { functionIndex = funcIndex; instructionIndex = instrIndex; runtimeStackBaseIndex = stackBaseIndex; } CVirtualMachine::CVirtualMachine() { // Reserve runtime stack size. // TODO Remove hardcoded value m_runtimeStack.reserve(1024 * 256); } bool CVirtualMachine::load(std::istream &byteCode) { // Load string constants if (!deserializeStrings(byteCode)) { return false; } // Load extern functions if (!deserializeExternFunctions(byteCode)) { return false; } // Load script functions if (!deserializeFunctions(byteCode)) { return false; } return true; } void CVirtualMachine::clearScripts() { m_currentFunctionIndex = 0; m_currentInstructionIndex = 0; m_currentRuntimeStackBaseIndex = 0; // Clear script data m_strings.clear(); m_externFunctions.clear(); m_functions.clear(); } bool CVirtualMachine::callFunction(const std::string &functionName) { // Retrieve function index if exists if (!getFunctionIndexByName(functionName, m_currentFunctionIndex)) { return false; } m_currentInstructionIndex = 0; m_runtimeStack.resize(m_functions.at(m_currentFunctionIndex).stackSize); // Execute function bool running = true; while (running) { // Single step execution until finished running = execute(); } return true; } void CVirtualMachine::addFunction(const std::string &functionName, kern::IExternFunction *function) { m_externFunctionsMap[functionName].reset(function); } void CVirtualMachine::removeFunction(const ::std::string &functionName) { m_externFunctionsMap.erase(functionName); } bool CVirtualMachine::popParameter(int &value) { bool ret = m_runtimeStack.back().convert(value); m_runtimeStack.pop_back(); return ret; } bool CVirtualMachine::popParameter(float &value) { bool ret = m_runtimeStack.back().convert(value); m_runtimeStack.pop_back(); return ret; } bool CVirtualMachine::popParameter(::std::string &value) { bool ret = m_runtimeStack.back().convert(value); m_runtimeStack.pop_back(); return ret; } void CVirtualMachine::setReturnValue() { return; } void CVirtualMachine::setReturnValue(int value) { pushValue(CValue(value)); } void CVirtualMachine::setReturnValue(float value) { pushValue(CValue(value)); } void CVirtualMachine::setReturnValue(const std::string &value) { pushValue(CValue(value)); } bool CVirtualMachine::deserializeStrings(std::istream &stream) { // Get string table size and reserve space uint32_t size = 0; if (!deserialize(stream, size)) { return false; } m_strings.resize(size); // Read strings into string table for (auto &str : m_strings) { if (!deserialize(stream, str)) { return false; } } return true; } bool CVirtualMachine::deserializeExternFunctions(std::istream &stream) { // Read size uint32_t size = 0; stream.read((char *)&size, sizeof(size)); m_externFunctions.resize(size); for (auto &externFunction : m_externFunctions) { if (!deserialize(stream, externFunction)) { return false; } } return stream.good(); } bool CVirtualMachine::deserializeFunctions(std::istream &stream) { // Read size uint32_t size = 0; stream.read((char *)&size, sizeof(size)); // Reserve space m_functions.resize(size); // Read function data for (auto &function : m_functions) { // Read function name uint32_t length = 0; stream.read((char *)&length, sizeof(length)); function.name.reserve(length); for (uint32_t i = 0; i < length; ++i) { char c; stream.read(&c, 1); function.name.push_back(c); } // Read stack size stream.read((char *)&function.stackSize, sizeof(function.stackSize)); // Read parameter size stream.read((char *)&function.parameterSize, sizeof(function.parameterSize)); // Read instructions // Instructions size stream.read((char *)&size, sizeof(size)); function.instructions.resize(size); // Instructions for (auto &instruction : function.instructions) { if (!deserialize(instruction, stream)) { return false; } } // Cache size for fast lookup function.instructionSize = size; } return stream.good(); } bool CVirtualMachine::getFunctionIndexByName(const std::string &functionName, uint32_t &index) { index = 0; for (const auto &function : m_functions) { if (function.name == functionName) { return true; } ++index; } return false; } bool CVirtualMachine::getFunctionByName( const std::string &functionName, const CVirtualMachine::SFunction *function_out) const { for (const auto &function : m_functions) { if (function.name == functionName) { function_out = &function; return true; } } return false; } bool CVirtualMachine::execute() { // Cache current function const SFunction &currentFunction = m_functions.at(m_currentFunctionIndex); // Default current instruction to implicit return SInstruction instruction; instruction.id = EInstruction::Ret; // Check for out of bounds instruction index if (currentFunction.instructionSize > m_currentInstructionIndex) { // Retrieve current instruction instruction = currentFunction.instructions.at(m_currentInstructionIndex); } // Debug // printRuntimeStack(); std::cout << "Executing instruction " << toString(instruction) << std::endl; switch (instruction.id) { case EInstruction::Nop: ++m_currentInstructionIndex; break; case EInstruction::Break: // Not implemented ++m_currentInstructionIndex; break; case EInstruction::Exit: // Return false to signal end of script return false; break; case EInstruction::Movv: // Move variable to variable // Arg 0 is variable index of destination // Arg 1 is variable index of source m_runtimeStack[m_currentRuntimeStackBaseIndex + *((uint32_t *)&instruction.args[0])] = m_runtimeStack.at(m_currentRuntimeStackBaseIndex + *((uint32_t *)&instruction.args[1])); break; case EInstruction::Movi: // Move integer to variable // Arg 0 is variable index of destination // Arg 1 is source integer value m_runtimeStack[m_currentRuntimeStackBaseIndex + *((uint32_t *)&instruction.args[0])] = instruction.args[1]; break; case EInstruction::Movf: // Move float to variable // Arg 0 is variable index of destination // Arg 1 is source float value m_runtimeStack[m_currentRuntimeStackBaseIndex + *((uint32_t *)&instruction.args[0])] = *((float *)&instruction.args[1]); break; case EInstruction::Movs: // Move string to variable // Arg 0 is variable index of destination // Arg 1 is source index of string m_runtimeStack[m_currentRuntimeStackBaseIndex + *((uint32_t *)&instruction.args[0])] = m_strings.at(*((uint32_t *)&instruction.args[1])); ++m_currentInstructionIndex; break; case EInstruction::Pushi: // Push signed 32 bit integer value to // Arg 0 is integer value pushValue(CValue(instruction.args[0])); ++m_currentInstructionIndex; break; case EInstruction::Pushf: // Arg 0 is float value pushValue(CValue(*((float *)&instruction.args[0]))); ++m_currentInstructionIndex; break; case EInstruction::Pushv: // Arg 0 is variable index pushValue(m_runtimeStack.at(m_currentRuntimeStackBaseIndex + *((uint32_t *)&instruction.args[0]))); ++m_currentInstructionIndex; break; case EInstruction::Pushs: // Arg 0 is string index pushValue(m_strings.at(*((uint32_t *)&instruction.args[0]))); ++m_currentInstructionIndex; break; case EInstruction::Pop: // Remove top element from runtime stack m_runtimeStack.pop_back(); ++m_currentInstructionIndex; break; case EInstruction::Popv: { // Remove top of the stack and store it in variable // Arg 0 is variable index m_runtimeStack[m_currentRuntimeStackBaseIndex + *((uint32_t *)&instruction.args[0])] = m_runtimeStack.back(); m_runtimeStack.pop_back(); ++m_currentInstructionIndex; } break; case EInstruction::Call: { // Push current function index, next instruction index and base stack index // for // return call. m_callStack.push(SFunctionFrame(m_currentFunctionIndex, m_currentInstructionIndex + 1, m_currentRuntimeStackBaseIndex)); // Arg 0 is function index of the called function m_currentFunctionIndex = *((uint32_t *)&instruction.args[0]); // Reset instruction index m_currentInstructionIndex = 0; // Set new runtime stack base index for the called function uint32_t runtimeStackSize = static_cast<uint32_t>(m_runtimeStack.size()); m_currentRuntimeStackBaseIndex = runtimeStackSize; // Modify by function parameter size const SFunction &newCurrentFunction = m_functions.at(m_currentFunctionIndex); m_currentRuntimeStackBaseIndex -= newCurrentFunction.parameterSize; // Resize runtime stack with local stack size of called function m_runtimeStack.resize(runtimeStackSize + newCurrentFunction.stackSize - newCurrentFunction.parameterSize); break; } case EInstruction::Calle: { // Call external, arg 0 is extern function index const SExternFunction &externFunction = m_externFunctions.at(instruction.args[0]); // Check if function exists // TODO Check if arg count ok auto entry = m_externFunctionsMap.find(externFunction.name); if (entry == m_externFunctionsMap.end()) { // Function does not exist std::cout << "The extern function '" << externFunction.name << "' does not exist." << std::endl; return false; } // Call if found entry->second->call(*this); ++m_currentInstructionIndex; break; } case EInstruction::Ret: // Return from script function if (m_callStack.empty()) { // Empty stack indicates either error state or end of script return false; } // Resize runtime stack to remove local function variables. m_runtimeStack.resize(m_currentRuntimeStackBaseIndex); // Retrieve function index of previous function m_currentFunctionIndex = m_callStack.top().functionIndex; // Restore active function index m_currentInstructionIndex = m_callStack.top().instructionIndex; // Restore runtime stack base index for the active function m_currentRuntimeStackBaseIndex = m_callStack.top().runtimeStackBaseIndex; m_callStack.pop(); break; case EInstruction::Retv: { // Returns variable from script function if (m_callStack.empty()) { // Empty stack indicates either error state or end of script return false; } // Arg 0 is local variable index // Store return value at local stack position 0 uint32_t varIndex = *((uint32_t *)&instruction.args[0]); if (varIndex != 0) { m_runtimeStack[m_currentRuntimeStackBaseIndex + 1] = m_runtimeStack.at(m_currentRuntimeStackBaseIndex + varIndex); } // Resize runtime stack to remove local function variables but the one // holding the return value. m_runtimeStack.resize(m_currentRuntimeStackBaseIndex + 1); // Retrieve function index of previous function m_currentFunctionIndex = m_callStack.top().functionIndex; // Restore active function index m_currentInstructionIndex = m_callStack.top().instructionIndex; // Restore runtime stack base index for the active function m_currentRuntimeStackBaseIndex = m_callStack.top().runtimeStackBaseIndex; m_callStack.pop(); break; } case EInstruction::Reti: { // Returns variable from script function if (m_callStack.empty()) { // Empty stack indicates either error state or end of script return false; } // Arg 0 is integer constant // Store return value at local stack position 0 m_runtimeStack[m_currentRuntimeStackBaseIndex + 1] = *((int32_t *)&instruction.args[0]); // Resize runtime stack to remove local function variables but the one // holding the return value. m_runtimeStack.resize(m_currentRuntimeStackBaseIndex + 1); // Retrieve function index of previous function m_currentFunctionIndex = m_callStack.top().functionIndex; // Restore active function index m_currentInstructionIndex = m_callStack.top().instructionIndex; // Restore runtime stack base index for the active function m_currentRuntimeStackBaseIndex = m_callStack.top().runtimeStackBaseIndex; m_callStack.pop(); break; } case EInstruction::Add: { CValue x; // 2 Values needed if (!popValue(x) || m_runtimeStack.empty()) { return false; } m_runtimeStack.back() += x; ++m_currentInstructionIndex; } break; case EInstruction::Sub: { CValue x; // 2 Values needed if (!popValue(x) || m_runtimeStack.empty()) { return false; } m_runtimeStack.back() -= x; ++m_currentInstructionIndex; } break; case EInstruction::Mul: // Not implemented return false; break; case EInstruction::Div: // Not implemented return false; break; case EInstruction::Inc: // Not implemented return false; break; case EInstruction::Dec: // Not implemented return false; break; case EInstruction::And: // Not implemented return false; break; case EInstruction::Or: // Not implemented return false; break; case EInstruction::Not: // Not implemented return false; break; case EInstruction::Xor: // Not implemented return false; break; case EInstruction::Jmp: // Not implemented return false; break; case EInstruction::Je: { // Compare top 2 values from stack, x == y CValue y; CValue x; if (!popValue(y) || !popValue(x)) { // Not enough values on stack return false; } if (x == y) { // Arg 0 is target instruction index for jump uint32_t jumpIndex = *((uint32_t *)&instruction.args[0]); m_currentInstructionIndex = jumpIndex; } else { ++m_currentInstructionIndex; } } break; case EInstruction::Jne: { // Compare top 2 values from stack, x != y CValue y; CValue x; if (!popValue(y) || !popValue(x)) { // Not enough values on stack return false; } if (x != y) { // Arg 0 is target instruction index for jump uint32_t jumpIndex = *((uint32_t *)&instruction.args[0]); m_currentInstructionIndex = jumpIndex; } else { ++m_currentInstructionIndex; } } break; case EInstruction::Jle: { // Compare top 2 values from stack, x <= y CValue y; CValue x; if (!popValue(y) || !popValue(x)) { // Not enough values on stack return false; } if (x <= y) { // Arg 0 is target instruction index for jump uint32_t jumpIndex = *((uint32_t *)&instruction.args[0]); m_currentInstructionIndex = jumpIndex; } else { ++m_currentInstructionIndex; } } break; default: assert(false); return false; } return true; } void CVirtualMachine::pushValue(const CValue &val) { assert(val.getType() != CValue::EType::Invalid); m_runtimeStack.push_back(val); } bool CVirtualMachine::popValue(CValue &val) { if (m_runtimeStack.empty()) { return false; } val = std::move(m_runtimeStack.back()); assert(val.getType() != CValue::EType::Invalid); m_runtimeStack.pop_back(); return true; } void CVirtualMachine::printRuntimeStack() const { unsigned int index = 0; for (const auto &value : m_runtimeStack) { std::cout << "Index: " << index << ", Value: " << value.toString() << std::endl; ++index; } }
redagito/KernScript
Lib/source/vm/CVirtualMachine.cpp
C++
mit
16,573
=begin #OEML - REST API #This section will provide necessary information about the `CoinAPI OEML REST API` protocol. <br/> This API is also available in the Postman application: <a href=\"https://postman.coinapi.io/\" target=\"_blank\">https://postman.coinapi.io/</a> <br/><br/> Implemented Standards: * [HTTP1.0](https://datatracker.ietf.org/doc/html/rfc1945) * [HTTP1.1](https://datatracker.ietf.org/doc/html/rfc2616) * [HTTP2.0](https://datatracker.ietf.org/doc/html/rfc7540) The version of the OpenAPI document: v1 Contact: [email protected] Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.4.0 =end require 'spec_helper' require 'json' # Unit tests for OpenapiClient::OrdersApi # Automatically generated by openapi-generator (https://openapi-generator.tech) # Please update as you see appropriate describe 'OrdersApi' do before do # run before each test @api_instance = OpenapiClient::OrdersApi.new end after do # run after each test end describe 'test an instance of OrdersApi' do it 'should create an instance of OrdersApi' do expect(@api_instance).to be_instance_of(OpenapiClient::OrdersApi) end end # unit tests for v1_orders_cancel_all_post # Cancel all orders request # This request cancels all open orders on single specified exchange. # @param order_cancel_all_request OrderCancelAllRequest object. # @param [Hash] opts the optional parameters # @return [MessageReject] describe 'v1_orders_cancel_all_post test' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for v1_orders_cancel_post # Cancel order request # Request cancel for an existing order. The order can be canceled using the &#x60;client_order_id&#x60; or &#x60;exchange_order_id&#x60;. # @param order_cancel_single_request OrderCancelSingleRequest object. # @param [Hash] opts the optional parameters # @return [OrderExecutionReport] describe 'v1_orders_cancel_post test' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for v1_orders_get # Get open orders # Get last execution reports for open orders across all or single exchange. # @param [Hash] opts the optional parameters # @option opts [String] :exchange_id Filter the open orders to the specific exchange. # @return [Array<OrderExecutionReport>] describe 'v1_orders_get test' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for v1_orders_post # Send new order # This request creating new order for the specific exchange. # @param order_new_single_request OrderNewSingleRequest object. # @param [Hash] opts the optional parameters # @return [OrderExecutionReport] describe 'v1_orders_post test' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end # unit tests for v1_orders_status_client_order_id_get # Get order execution report # Get the last order execution report for the specified order. The requested order does not need to be active or opened. # @param client_order_id The unique identifier of the order assigned by the client. # @param [Hash] opts the optional parameters # @return [OrderExecutionReport] describe 'v1_orders_status_client_order_id_get test' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end end end
coinapi/coinapi-sdk
oeml-sdk/ruby/spec/api/orders_api_spec.rb
Ruby
mit
3,721
require File.expand_path('../boot', __FILE__) require "rails" # Pick the frameworks you want: require "active_model/railtie" require "active_job/railtie" require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" require "action_view/railtie" require "sprockets/railtie" # require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module RailsRedis class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true end end
dmitrypol/rails_redis
config/application.rb
Ruby
mit
1,399
using System; using System.Numerics; using System.Runtime.CompilerServices; using System.Text; namespace ImGuiNET { public unsafe partial struct ImFont { public ImVector IndexAdvanceX; public float FallbackAdvanceX; public float FontSize; public ImVector IndexLookup; public ImVector Glyphs; public ImFontGlyph* FallbackGlyph; public ImFontAtlas* ContainerAtlas; public ImFontConfig* ConfigData; public short ConfigDataCount; public ushort FallbackChar; public ushort EllipsisChar; public ushort DotChar; public byte DirtyLookupTables; public float Scale; public float Ascent; public float Descent; public int MetricsTotalSurface; public fixed byte Used4kPagesMap[2]; } public unsafe partial struct ImFontPtr { public ImFont* NativePtr { get; } public ImFontPtr(ImFont* nativePtr) => NativePtr = nativePtr; public ImFontPtr(IntPtr nativePtr) => NativePtr = (ImFont*)nativePtr; public static implicit operator ImFontPtr(ImFont* nativePtr) => new ImFontPtr(nativePtr); public static implicit operator ImFont* (ImFontPtr wrappedPtr) => wrappedPtr.NativePtr; public static implicit operator ImFontPtr(IntPtr nativePtr) => new ImFontPtr(nativePtr); public ImVector<float> IndexAdvanceX => new ImVector<float>(NativePtr->IndexAdvanceX); public ref float FallbackAdvanceX => ref Unsafe.AsRef<float>(&NativePtr->FallbackAdvanceX); public ref float FontSize => ref Unsafe.AsRef<float>(&NativePtr->FontSize); public ImVector<ushort> IndexLookup => new ImVector<ushort>(NativePtr->IndexLookup); public ImPtrVector<ImFontGlyphPtr> Glyphs => new ImPtrVector<ImFontGlyphPtr>(NativePtr->Glyphs, Unsafe.SizeOf<ImFontGlyph>()); public ImFontGlyphPtr FallbackGlyph => new ImFontGlyphPtr(NativePtr->FallbackGlyph); public ImFontAtlasPtr ContainerAtlas => new ImFontAtlasPtr(NativePtr->ContainerAtlas); public ImFontConfigPtr ConfigData => new ImFontConfigPtr(NativePtr->ConfigData); public ref short ConfigDataCount => ref Unsafe.AsRef<short>(&NativePtr->ConfigDataCount); public ref ushort FallbackChar => ref Unsafe.AsRef<ushort>(&NativePtr->FallbackChar); public ref ushort EllipsisChar => ref Unsafe.AsRef<ushort>(&NativePtr->EllipsisChar); public ref ushort DotChar => ref Unsafe.AsRef<ushort>(&NativePtr->DotChar); public ref bool DirtyLookupTables => ref Unsafe.AsRef<bool>(&NativePtr->DirtyLookupTables); public ref float Scale => ref Unsafe.AsRef<float>(&NativePtr->Scale); public ref float Ascent => ref Unsafe.AsRef<float>(&NativePtr->Ascent); public ref float Descent => ref Unsafe.AsRef<float>(&NativePtr->Descent); public ref int MetricsTotalSurface => ref Unsafe.AsRef<int>(&NativePtr->MetricsTotalSurface); public RangeAccessor<byte> Used4kPagesMap => new RangeAccessor<byte>(NativePtr->Used4kPagesMap, 2); public void AddGlyph(ImFontConfigPtr src_cfg, ushort c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x) { ImFontConfig* native_src_cfg = src_cfg.NativePtr; ImGuiNative.ImFont_AddGlyph((ImFont*)(NativePtr), native_src_cfg, c, x0, y0, x1, y1, u0, v0, u1, v1, advance_x); } public void AddRemapChar(ushort dst, ushort src) { byte overwrite_dst = 1; ImGuiNative.ImFont_AddRemapChar((ImFont*)(NativePtr), dst, src, overwrite_dst); } public void AddRemapChar(ushort dst, ushort src, bool overwrite_dst) { byte native_overwrite_dst = overwrite_dst ? (byte)1 : (byte)0; ImGuiNative.ImFont_AddRemapChar((ImFont*)(NativePtr), dst, src, native_overwrite_dst); } public void BuildLookupTable() { ImGuiNative.ImFont_BuildLookupTable((ImFont*)(NativePtr)); } public void ClearOutputData() { ImGuiNative.ImFont_ClearOutputData((ImFont*)(NativePtr)); } public void Destroy() { ImGuiNative.ImFont_destroy((ImFont*)(NativePtr)); } public ImFontGlyphPtr FindGlyph(ushort c) { ImFontGlyph* ret = ImGuiNative.ImFont_FindGlyph((ImFont*)(NativePtr), c); return new ImFontGlyphPtr(ret); } public ImFontGlyphPtr FindGlyphNoFallback(ushort c) { ImFontGlyph* ret = ImGuiNative.ImFont_FindGlyphNoFallback((ImFont*)(NativePtr), c); return new ImFontGlyphPtr(ret); } public float GetCharAdvance(ushort c) { float ret = ImGuiNative.ImFont_GetCharAdvance((ImFont*)(NativePtr), c); return ret; } public string GetDebugName() { byte* ret = ImGuiNative.ImFont_GetDebugName((ImFont*)(NativePtr)); return Util.StringFromPtr(ret); } public void GrowIndex(int new_size) { ImGuiNative.ImFont_GrowIndex((ImFont*)(NativePtr), new_size); } public bool IsLoaded() { byte ret = ImGuiNative.ImFont_IsLoaded((ImFont*)(NativePtr)); return ret != 0; } public void RenderChar(ImDrawListPtr draw_list, float size, Vector2 pos, uint col, ushort c) { ImDrawList* native_draw_list = draw_list.NativePtr; ImGuiNative.ImFont_RenderChar((ImFont*)(NativePtr), native_draw_list, size, pos, col, c); } public void SetGlyphVisible(ushort c, bool visible) { byte native_visible = visible ? (byte)1 : (byte)0; ImGuiNative.ImFont_SetGlyphVisible((ImFont*)(NativePtr), c, native_visible); } } }
mellinoe/ImGui.NET
src/ImGui.NET/Generated/ImFont.gen.cs
C#
mit
5,868
# 2.1.0 * use `@epiijs/minion` runner instead of raw command line * add animation for dialog * add notification for mirror mode actions # 2.0.0 * use `@epiijs/minion` instead of raw server * change file URL and data API * change old MPA into SPA * reduce bundle size * **Broken** => remove notification temporarily
sartrey/firecell
CHANGELOG.md
Markdown
mit
318
namespace HomeCloud.DataAccess.Components { #region Usings using HomeCloud.DataAccess.Contracts; using HomeCloud.DataAccess.Services; using HomeCloud.DataAccess.Services.Factories; #endregion /// <summary> /// Provides methods for operations within data context executed as single scope. /// </summary> /// <seealso cref="IDbContextScope" /> public class DbContextScope : IDbContextScope { #region Private Members /// <summary> /// The <see cref="IDbRepositoryFactory"/> member. /// </summary> private static IDbRepositoryFactory repositoryFactory = null; /// <summary> /// The <see cref="IDbQueryHandlerFactory"/> member. /// </summary> private static IDbQueryHandlerFactory queryHandlerFactory = null; /// <summary> /// The <see cref="IDbCommandHandlerFactory"/> member. /// </summary> private static IDbCommandHandlerFactory commandHandlerFactory = null; /// <summary> /// The <see cref="ITransactionalDbContext"/> member. /// </summary> private readonly ITransactionalDbContext context = null; #endregion #region Constructors /// <summary> /// Initializes a new instance of the <see cref="DbContextScope" /> class. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="isTransactional">Indicates whether the scope should support database transactions.</param> /// <param name="repositoryFactory">The <see cref="IDbRepositoryFactory" /> factory.</param> /// <param name="queryHandlerFactory">The <see cref="IDbQueryHandlerFactory" /> factory.</param> /// <param name="commandHandlerFactory">The <see cref="IDbCommandHandlerFactory" /> factory.</param> public DbContextScope(string connectionString, bool isTransactional, IDbRepositoryFactory repositoryFactory = null, IDbQueryHandlerFactory queryHandlerFactory = null, IDbCommandHandlerFactory commandHandlerFactory = null) { DbContextScope.repositoryFactory = repositoryFactory; DbContextScope.queryHandlerFactory = queryHandlerFactory; DbContextScope.commandHandlerFactory = commandHandlerFactory; this.context = new DbContext(connectionString, isTransactional); } #endregion #region IDataContextScope Implementations /// <summary> /// Gets the <see cref="T:HomeCloud.DataAccess.Services.IDbRepository" /> repository. /// </summary> /// <typeparam name="T">The type of the repository derived from <see cref="T:HomeCloud.DataAccess.Services.IDbRepository" />.</typeparam> /// <returns> /// The instance of <see cref="T:HomeCloud.DataAccess.Services.IDbRepository" />. /// </returns> public T GetRepository<T>() where T : IDbRepository { return repositoryFactory.GetRepository<T>(this.context); } /// <summary> /// Gets the <see cref="T:HomeCloud.DataAccess.Services.IDbQueryHandler" /> handler. /// </summary> /// <typeparam name="T">The type of the query handler derived from <see cref="T:HomeCloud.DataAccess.Services.IDbQueryHandler" />.</typeparam> /// <returns> /// The instance of <see cref="T:HomeCloud.DataAccess.Services.IDbQueryHandler" />. /// </returns> public T GetQueryHandler<T>() where T : IDbQueryHandler { return queryHandlerFactory.GetHandler<T>(this.context); } /// <summary> /// Gets the <see cref="T:HomeCloud.DataAccess.Services.IDbCommandHandler" /> handler. /// </summary> /// <typeparam name="T">The type of the command handler derived from <see cref="T:HomeCloud.DataAccess.Services.IDbQueryHandler" />.</typeparam> /// <returns> /// The instance of <see cref="T:HomeCloud.DataAccess.Services.IDbCommandHandler" />. /// </returns> public T GetCommandHandler<T>() where T : IDbCommandHandler { return commandHandlerFactory.GetHandler<T>(this.context); } /// <summary> /// Commits the existing changes in database. /// </summary> public void Commit() { this.context.Commit(); } #endregion #region IDisposable Implementations /// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { this.context.Dispose(); } #endregion } }
olegsivakov/HomeCloud
Common/DataAccess/HomeCloud.DataAccess.Components/DbContextScope.cs
C#
mit
4,172
from typing import Any, Dict, List, Set from ..utils.access_permissions import BaseAccessPermissions, required_user from ..utils.auth import async_has_perm from ..utils.utils import get_model_from_collection_string class UserAccessPermissions(BaseAccessPermissions): """ Access permissions container for User and UserViewSet. """ async def get_restricted_data( self, full_data: List[Dict[str, Any]], user_id: int ) -> List[Dict[str, Any]]: """ Returns the restricted serialized data for the instance prepared for the user. Removes several fields for non admins so that they do not get the fields they should not get. """ from .serializers import ( USERCANSEEEXTRASERIALIZER_FIELDS, USERCANSEESERIALIZER_FIELDS, ) def filtered_data(full_data, whitelist, whitelist_operator=None): """ Returns a new dict like full_data but only with whitelisted keys. If the whitelist_operator is given and the full_data-user is the oeperator (the user with user_id), the whitelist_operator will be used instead of the whitelist. """ if whitelist_operator is not None and full_data["id"] == user_id: return {key: full_data[key] for key in whitelist_operator} else: return {key: full_data[key] for key in whitelist} # We have some sets of data to be sent: # * full data i. e. all fields (including session_auth_hash), # * all data i. e. all fields but not session_auth_hash, # * many data i. e. all fields but not the default password and session_auth_hash, # * little data i. e. all fields but not the default password, session_auth_hash, # comments, gender, email, last_email_send, active status and auth_type # * own data i. e. all little data fields plus email and gender. This is applied # to the own user, if he just can see little or no data. # * no data. # Prepare field set for users with "all" data, "many" data and with "little" data. all_data_fields = set(USERCANSEEEXTRASERIALIZER_FIELDS) all_data_fields.add("groups_id") all_data_fields.discard("groups") all_data_fields.add("default_password") many_data_fields = all_data_fields.copy() many_data_fields.discard("default_password") little_data_fields = set(USERCANSEESERIALIZER_FIELDS) little_data_fields.add("groups_id") little_data_fields.discard("groups") own_data_fields = set(little_data_fields) own_data_fields.add("email") own_data_fields.add("gender") own_data_fields.add("vote_delegated_to_id") own_data_fields.add("vote_delegated_from_users_id") # Check user permissions. if await async_has_perm(user_id, "users.can_see_name"): whitelist_operator = None if await async_has_perm(user_id, "users.can_see_extra_data"): if await async_has_perm(user_id, "users.can_manage"): whitelist = all_data_fields else: whitelist = many_data_fields else: whitelist = little_data_fields whitelist_operator = own_data_fields # for managing {motion, assignment} polls the users needs to know # the vote delegation structure. if await async_has_perm( user_id, "motion.can_manage_polls" ) or await async_has_perm(user_id, "assignments.can_manage"): whitelist.add("vote_delegated_to_id") whitelist.add("vote_delegated_from_users_id") data = [ filtered_data(full, whitelist, whitelist_operator) for full in full_data ] else: # Build a list of users, that can be seen without any permissions (with little fields). # Everybody can see himself. Also everybody can see every user # that is required e. g. as speaker, motion submitter or # assignment candidate. can_see_collection_strings: Set[str] = set() for collection_string in required_user.get_collection_strings(): if await async_has_perm( user_id, get_model_from_collection_string( collection_string ).can_see_permission, ): can_see_collection_strings.add(collection_string) required_user_ids = await required_user.get_required_users( can_see_collection_strings ) # Add oneself. if user_id: required_user_ids.add(user_id) # add vote delegations # Find our model in full_data and get vote_delegated_from_users_id from it. for user in full_data: if user["id"] == user_id: required_user_ids.update(user["vote_delegated_from_users_id"]) break # Parse data. data = [ filtered_data(full, little_data_fields, own_data_fields) for full in full_data if full["id"] in required_user_ids ] return data class GroupAccessPermissions(BaseAccessPermissions): """ Access permissions container for Groups. Everyone can see them """ class PersonalNoteAccessPermissions(BaseAccessPermissions): """ Access permissions container for personal notes. Every authenticated user can handle personal notes. """ async def get_restricted_data( self, full_data: List[Dict[str, Any]], user_id: int ) -> List[Dict[str, Any]]: """ Returns the restricted serialized data for the instance prepared for the user. Everybody gets only his own personal notes. """ # Parse data. if not user_id: data: List[Dict[str, Any]] = [] else: for full in full_data: if full["user_id"] == user_id: data = [full] break else: data = [] return data
jwinzer/OpenSlides
server/openslides/users/access_permissions.py
Python
mit
6,329
using System; // //Module : AAEQUATIONOFTIME.CPP //Purpose: Implementation for the algorithms to calculate the "Equation of Time" //Created: PJN / 29-12-2003 //History: PJN / 05-07-2005 1. Fix for a bug to ensure that values returned from CAAEquationOfTime::Calculate // does not return discontinuities. Instead it now returns negative values when // required. // //Copyright (c) 2003 - 2007 by PJ Naughter (Web: www.naughter.com, Email: [email protected]) // //All rights reserved. // //Copyright / Usage Details: // //You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) //when your product is released in binary form. You are allowed to modify the source code in any way you want //except you cannot modify the copyright details at the top of each module. If you want to distribute source //code with your application, then you are only allowed to distribute versions released by the author. This is //to maintain a single distribution point for the source code. // // ///////////////////////// Includes //////////////////////////////////////////// /////////////////////// Classes /////////////////////////////////////////////// public class EOT // was CAAEquationOfTime { //Static methods ///////////////////////// Implementation ////////////////////////////////////// public static double Calculate(double JD) { double rho = (JD - 2451545) / 365250; double rhosquared = rho *rho; double rhocubed = rhosquared *rho; double rho4 = rhocubed *rho; double rho5 = rho4 *rho; //Calculate the Suns mean longitude double L0 = CT.M360(280.4664567 + 360007.6982779 *rho + 0.03032028 *rhosquared + rhocubed / 49931 - rho4 / 15300 - rho5 / 2000000); //Calculate the Suns apparent right ascension double SunLong = CAASun.ApparentEclipticLongitude(JD); double SunLat = CAASun.ApparentEclipticLatitude(JD); double epsilon = CAANutation.TrueObliquityOfEcliptic(JD); COR Equatorial = CT.Ec2Eq(SunLong, SunLat, epsilon); epsilon = CT.D2R(epsilon); double E = L0 - 0.0057183 - Equatorial.X *15 + CT.DMS2D(0, 0, CAANutation.NutationInLongitude(JD))*Math.Cos(epsilon); if (E > 180) E = -(360 - E); E *= 4; //Convert to minutes of time return E; } }
juoni/wwt-web-client
HTML5SDK/wwtlib/AstroCalc/AAEquationOfTime.cs
C#
mit
2,289
<div class="bkg-config"> </br></br></br></br><p>Hey {{dog}}, this is the partial for config.html </p> <!-- <input ng-model="oldItem" type="text"> --> {{idx}}</br> {{litem}} </div>
mckennatim/s2g-ngio
app/partials/config.html
HTML
mit
181
'use strict' var config = require('../config') function filterByPath (list, path) { if (path.length === 0) { return list } else { var newList = [] var filterPath = config.BASE_URL + '/' + path list.forEach(function (item) { if (item.loc.indexOf(filterPath) > -1) { newList.push(item) } }) return newList } } module.exports = filterByPath
telemark/utdaterte-artikler
lib/filter-by-path.js
JavaScript
mit
391