hexsha stringlengths 40 40 | size int64 7 1.05M | ext stringclasses 13
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 4 269 | max_stars_repo_name stringlengths 5 108 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count int64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringlengths 24 24 ⌀ | max_stars_repo_stars_event_max_datetime stringlengths 24 24 ⌀ | max_issues_repo_path stringlengths 4 269 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 9 | max_issues_count int64 1 67k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 4 269 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 9 | max_forks_count int64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 7 1.05M | avg_line_length float64 1.21 330k | max_line_length int64 6 990k | alphanum_fraction float64 0.01 0.99 | author_id stringlengths 2 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
386571a198228468494086ae7f1b41225322b7ce | 164,218 | cpp | C++ | code_reading/oceanbase-master/src/sql/session/ob_basic_session_info.cpp | wangcy6/weekly_read | 3a8837ee9cd957787ee1785e4066dd623e02e13a | [
"Apache-2.0"
] | null | null | null | code_reading/oceanbase-master/src/sql/session/ob_basic_session_info.cpp | wangcy6/weekly_read | 3a8837ee9cd957787ee1785e4066dd623e02e13a | [
"Apache-2.0"
] | null | null | null | code_reading/oceanbase-master/src/sql/session/ob_basic_session_info.cpp | wangcy6/weekly_read | 3a8837ee9cd957787ee1785e4066dd623e02e13a | [
"Apache-2.0"
] | 1 | 2020-10-18T12:59:31.000Z | 2020-10-18T12:59:31.000Z | /**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SQL_SESSION
#include "sql/session/ob_basic_session_info.h"
#include "lib/string/ob_sql_string.h"
#include "lib/timezone/ob_oracle_format_models.h"
#include "common/sql_mode/ob_sql_mode_utils.h"
#include "common/ob_smart_call.h"
#include "share/config/ob_server_config.h"
#include "share/schema/ob_schema_getter_guard.h"
#include "share/schema/ob_sys_variable_mgr.h"
#include "sql/engine/ob_exec_context.h"
#include "sql/plan_cache/ob_plan_cache_util.h"
#include "sql/plan_cache/ob_prepare_stmt_struct.h"
#include "sql/ob_sql_trans_util.h"
#include "observer/ob_server_struct.h"
#include "sql/engine/ob_physical_plan.h"
#include "storage/transaction/ob_weak_read_util.h" //ObWeakReadUtil
#include "observer/omt/ob_tenant_timezone_mgr.h"
using namespace oceanbase::common;
using namespace oceanbase::share;
using namespace oceanbase::share::schema;
using namespace oceanbase::transaction;
namespace oceanbase {
namespace sql {
ObBasicSessionInfo::ObBasicSessionInfo()
: query_mutex_(),
thread_data_mutex_(),
is_valid_(true),
is_deserialized_(false),
tenant_id_(OB_INVALID_ID),
effective_tenant_id_(OB_INVALID_ID),
rpc_tenant_id_(0),
is_changed_to_temp_tenant_(false),
user_id_(OB_INVALID_ID),
client_version_(),
driver_version_(),
sessid_(0),
master_sessid_(INVALID_SESSID),
version_(0),
proxy_sessid_(VALID_PROXY_SESSID),
// in_transaction_(false),
variables_last_modify_time_(0),
global_vars_version_(0),
sys_var_base_version_(OB_INVALID_VERSION),
des_sys_var_base_version_(OB_INVALID_VERSION),
trans_desc_(),
trans_consistency_type_(transaction::ObTransConsistencyType::UNKNOWN),
// minus 32 is used for alignment of ObMalloc, preventing memory allocation more than 8K.
block_allocator_(
SMALL_BLOCK_SIZE, common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32, ObMalloc(ObModIds::OB_SQL_SESSION_SBLOCK)),
ps_session_info_allocator_(
sizeof(ObPsSessionInfo), common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32, ObMalloc("PsSessionInfo")),
name_pool_(ObModIds::OB_SQL_SESSION, OB_MALLOC_NORMAL_BLOCK_SIZE),
base_sys_var_alloc_(ObModIds::OB_SQL_SESSION, OB_MALLOC_NORMAL_BLOCK_SIZE),
trans_flags_(),
bucket_allocator_wrapper_(&block_allocator_),
user_var_val_map_(SMALL_BLOCK_SIZE, ObWrapperAllocator(&block_allocator_)),
influence_plan_var_indexs_(),
is_first_gen_(true),
sys_var_fac_(),
consistency_level_(INVALID_CONSISTENCY),
tz_info_wrap_(),
next_tx_read_only_(-1),
next_tx_isolation_(transaction::ObTransIsolation::UNKNOWN),
log_id_level_map_valid_(false),
cur_phy_plan_(NULL),
capability_(),
proxy_capability_(),
client_mode_(OB_MIN_CLIENT_MODE),
changed_sys_vars_(),
changed_user_vars_(),
changed_var_pool_(ObModIds::OB_SQL_SESSION, OB_MALLOC_NORMAL_BLOCK_SIZE),
is_database_changed_(false),
feedback_manager_(),
trans_spec_status_(TRANS_SPEC_NOT_SET),
debug_sync_actions_(),
partition_hit_(),
magic_num_(0x13572468),
current_execution_id_(-1),
database_id_(OB_INVALID_ID),
retry_info_(),
last_query_trace_id_(),
nested_count_(-1),
safe_weak_read_snapshot_(0),
weak_read_snapshot_source_(0),
curr_trans_last_stmt_end_time_(0),
read_snapshot_version_(OB_INVALID_VERSION),
check_sys_variable_(true),
is_foreign_key_cascade_(false),
is_foreign_key_check_exist_(false),
acquire_from_pool_(false),
release_to_pool_(true),
is_tenant_killed_(0),
reused_count_(0),
first_stmt_type_(stmt::T_NONE),
exec_min_cluster_version_(GET_MIN_CLUSTER_VERSION()),
stmt_type_(stmt::T_NONE),
thread_id_(0),
is_password_expired_(false)
{
MEMSET(sys_vars_, 0, sizeof(sys_vars_));
log_id_level_map_.reset_level();
CHAR_CARRAY_INIT(tenant_);
CHAR_CARRAY_INIT(effective_tenant_);
CHAR_CARRAY_INIT(trace_id_buff_);
ssl_cipher_buff_[0] = '\0';
}
ObBasicSessionInfo::~ObBasicSessionInfo()
{
destroy();
}
bool ObBasicSessionInfo::is_server_status_in_transaction() const
{
bool result = get_in_transaction() ||
(!get_local_autocommit() && trans_desc_.get_standalone_stmt_desc().is_snapshot_version_valid());
return result;
}
// for test
int ObBasicSessionInfo::test_init(
uint32_t version, uint32_t sessid, uint64_t proxy_sessid, common::ObIAllocator* bucket_allocator)
{
int ret = OB_SUCCESS;
if (NULL != bucket_allocator) {
bucket_allocator_wrapper_.set_alloc(bucket_allocator);
}
ret = user_var_val_map_.init(1024 * 1024 * 2,
256, // # of user variables
(NULL == bucket_allocator ? NULL : &bucket_allocator_wrapper_));
if (OB_FAIL(ret)) {
LOG_WARN("fail to init user_var_val_map", K(ret));
} else if (OB_FAIL(debug_sync_actions_.init(SMALL_BLOCK_SIZE, bucket_allocator_wrapper_))) {
LOG_WARN("fail to init debug sync actions", K(ret));
} else if (OB_FAIL(set_session_state(SESSION_INIT))) {
LOG_WARN("fail to set session stat", K(ret));
} else if (OB_FAIL(trans_desc_.test_init())) {
LOG_WARN("transaction desc init error", K(ret));
} else if (OB_FAIL(set_time_zone(ObString("+8:00"), is_oracle_compatible(), true /* check_timezone_valid */))) {
LOG_WARN("fail to set time zone", K(ret));
} else {
// tz_info_wrap_.set_tz_info_map(GCTX.tz_info_mgr_->get_tz_info_map());
version_ = version;
sessid_ = sessid;
proxy_sessid_ = proxy_sessid;
}
return ret;
}
bool ObBasicSessionInfo::is_use_inner_allocator() const
{
return bucket_allocator_wrapper_.get_alloc() == &block_allocator_;
}
int ObBasicSessionInfo::init(uint32_t version, uint32_t sessid, uint64_t proxy_sessid,
common::ObIAllocator* bucket_allocator, const ObTZInfoMap* tz_info)
{
int ret = OB_SUCCESS;
ObWrapperAllocator* user_var_allocator_wrapper = NULL;
if (is_acquire_from_pool()) {
reused_count_++;
if (OB_NOT_NULL(bucket_allocator) || !is_use_inner_allocator()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("session from pool must use inner allocator", K(ret));
}
} else {
if (NULL != bucket_allocator) {
bucket_allocator_wrapper_.set_alloc(bucket_allocator);
user_var_allocator_wrapper = &bucket_allocator_wrapper_;
}
}
if (OB_FAIL(ret)) {
} else if (!is_acquire_from_pool() &&
OB_FAIL(user_var_val_map_.init(1024 * 1024 * 2, 256, user_var_allocator_wrapper))) {
LOG_WARN("fail to init user_var_val_map", K(ret));
} else if (!is_acquire_from_pool() &&
OB_FAIL(debug_sync_actions_.init(SMALL_BLOCK_SIZE, bucket_allocator_wrapper_))) {
LOG_WARN("fail to init debug sync actions", K(ret));
} else if (OB_FAIL(set_session_state(SESSION_INIT))) {
LOG_WARN("fail to set session stat", K(ret));
} else if (OB_FAIL(trans_desc_.init(this))) {
LOG_WARN("transaction desc init error", K(ret));
} else if (FALSE_IT(trans_result_.set_trans_desc(&trans_desc_))) {
} else {
version_ = version;
sessid_ = sessid;
proxy_sessid_ = proxy_sessid;
uint64_t tenant_id = tenant_id_;
if (OB_ISNULL(tz_info)) {
ObTZMapWrap tz_map_wrap;
if (OB_FAIL(OTTZ_MGR.get_tenant_tz(tenant_id, tz_map_wrap))) {
LOG_WARN("get tenant timezone map failed", K(ret));
} else {
tz_info_wrap_.set_tz_info_map(tz_map_wrap.get_tz_map());
}
} else {
tz_info_wrap_.set_tz_info_map(tz_info);
}
}
return ret;
}
int ObBasicSessionInfo::update_safe_weak_read_snapshot(
const uint64_t tenant_id, const int64_t& safe_weak_read_snapshot, const int64_t& safe_weak_read_snapshot_source)
{
int ret = OB_SUCCESS;
if (!ObWeakReadUtil::enable_monotonic_weak_read(tenant_id)) {
LOG_WARN("observer not support causal order slave read", K(safe_weak_read_snapshot));
} else if (safe_weak_read_snapshot < 0) {
TRANS_LOG(WARN, "invalid argument", K(safe_weak_read_snapshot));
ret = OB_INVALID_ARGUMENT;
} else {
if (safe_weak_read_snapshot_ < safe_weak_read_snapshot) {
safe_weak_read_snapshot_ = safe_weak_read_snapshot;
weak_read_snapshot_source_ = safe_weak_read_snapshot_source;
}
}
return ret;
}
void ObBasicSessionInfo::destroy()
{
if (magic_num_ != 0x13572468) {
LOG_ERROR("ObBasicSessionInfo may be double free!!!", K(magic_num_));
}
trans_desc_.destroy();
trans_result_.reset();
trans_consistency_type_ = transaction::ObTransConsistencyType::UNKNOWN;
magic_num_ = 0x86427531;
if (thread_data_.cur_query_ != nullptr) {
ob_free(thread_data_.cur_query_);
thread_data_.cur_query_ = nullptr;
thread_data_.cur_query_buf_len_ = 0;
}
total_stmt_tables_.reset();
cur_stmt_tables_.reset();
}
void ObBasicSessionInfo::clean_status()
{
// in_transaction_ = false;
trans_flags_.reset();
trans_spec_status_ = TRANS_SPEC_NOT_SET;
// trans_desc_.reset();
trans_consistency_type_ = transaction::ObTransConsistencyType::UNKNOWN;
set_valid(true);
thread_data_.cur_query_start_time_ = 0;
thread_data_.cur_query_len_ = 0;
thread_data_.last_active_time_ = 0;
reset_session_changed_info();
}
void ObBasicSessionInfo::reset(bool skip_sys_var)
{
set_valid(false);
is_deserialized_ = false;
CHAR_CARRAY_INIT(tenant_);
tenant_id_ = OB_INVALID_ID;
CHAR_CARRAY_INIT(effective_tenant_);
effective_tenant_id_ = OB_INVALID_ID;
is_changed_to_temp_tenant_ = false;
user_id_ = OB_INVALID_ID;
client_version_.reset();
driver_version_.reset();
sessid_ = 0;
master_sessid_ = INVALID_SESSID;
version_ = 0;
proxy_sessid_ = VALID_PROXY_SESSID;
variables_last_modify_time_ = 0;
global_vars_version_ = 0;
des_sys_var_base_version_ = OB_INVALID_VERSION;
trans_desc_.reset();
trans_consistency_type_ = transaction::ObTransConsistencyType::UNKNOWN;
trans_result_.reset();
total_stmt_tables_.reset();
cur_stmt_tables_.reset();
// reset() of user_var_val_map_ and debug_sync_actions_ will keep some memory
// allocated from block_allocator_ / bucket_allocator_wrapper_, so we skip
// reset() of block_allocator_ and bucket_allocator_wrapper_.
// block_allocator_.reset();
ps_session_info_allocator_.reset();
trans_flags_.reset();
// bucket_allocator_wrapper_.reset();
user_var_val_map_.reuse();
if (!skip_sys_var) {
memset(sys_vars_, 0, sizeof(sys_vars_));
influence_plan_var_indexs_.reset();
} else {
const SysVarIds& all_sys_var_ids = sys_var_inc_info_.get_all_sys_var_ids();
for (int i = 0; i < all_sys_var_ids.count(); i++) {
int ret = OB_SUCCESS;
int64_t store_idx = -1;
ObSysVarClassType sys_var_id = all_sys_var_ids.at(i);
OZ(ObSysVarFactory::calc_sys_var_store_idx(sys_var_id, store_idx));
OV(0 <= store_idx && store_idx < ObSysVarFactory::ALL_SYS_VARS_COUNT);
OV(OB_NOT_NULL(sys_vars_[store_idx]));
OX(sys_vars_[store_idx]->clean_inc_value());
}
sys_var_inc_info_.reset();
reset_timezone();
}
sys_var_in_pc_str_.reset();
is_first_gen_ = true;
CHAR_CARRAY_INIT(trace_id_buff_);
// consistency_level_ = INVALID_CONSISTENCY;
next_tx_read_only_ = -1;
next_tx_isolation_ = transaction::ObTransIsolation::UNKNOWN;
log_id_level_map_valid_ = false;
log_id_level_map_.reset_level();
cur_phy_plan_ = NULL;
capability_.capability_ = 0;
proxy_capability_.capability_ = 0;
client_mode_ = OB_MIN_CLIENT_MODE;
reset_session_changed_info();
trans_spec_status_ = TRANS_SPEC_NOT_SET;
debug_sync_actions_.reset();
partition_hit_.reset();
// magic_num_ = 0x86427531;
current_execution_id_ = -1;
last_trace_id_.reset();
app_trace_id_.reset();
database_id_ = OB_INVALID_ID;
retry_info_.reset();
last_query_trace_id_.reset();
thread_data_.reset();
nested_count_ = -1;
if (!skip_sys_var) {
sys_vars_cache_.reset();
} else {
sys_vars_cache_.clean_inc();
}
safe_weak_read_snapshot_ = 0;
weak_read_snapshot_source_ = 0;
curr_trans_last_stmt_end_time_ = 0;
read_snapshot_version_ = OB_INVALID_VERSION;
check_sys_variable_ = true;
is_foreign_key_cascade_ = false;
is_foreign_key_check_exist_ = false;
acquire_from_pool_ = false;
// skip release_to_pool_, see comments in .h file.
is_tenant_killed_ = 0;
first_stmt_type_ = stmt::T_NONE;
exec_min_cluster_version_ = GET_MIN_CLUSTER_VERSION();
thread_id_ = 0;
is_password_expired_ = false;
// release all allocators at last, otherwise some members may keep invalid pointers,
// and for_each_session() of session mgr may core if access these invalid pointers.
name_pool_.reset();
if (!skip_sys_var) {
base_sys_var_alloc_.reset();
sys_var_fac_.destroy();
}
}
void ObBasicSessionInfo::reset_timezone()
{
int ret = OB_SUCCESS;
ObObj tmp_obj1;
if (OB_FAIL(get_sys_variable(SYS_VAR_TIME_ZONE, tmp_obj1))) {
LOG_WARN("get sys var failed", K(ret));
} else if (OB_FAIL(process_session_time_zone_value(tmp_obj1, false))) {
LOG_WARN("set time zone failed", K(ret));
}
ObObj tmp_obj2;
if (OB_FAIL(get_sys_variable(SYS_VAR_ERROR_ON_OVERLAP_TIME, tmp_obj2))) {
LOG_WARN("get sys var failed", K(ret));
} else if (OB_FAIL(process_session_overlap_time_value(tmp_obj2))) {
LOG_WARN("process session overlap time value failed", K(ret), K(tmp_obj2));
}
}
int ObBasicSessionInfo::init_tenant(const ObString& tenant_name, const uint64_t tenant_id)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id))) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant id", K(tenant_id), K(ret));
} else if (tenant_name.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name is empty", K(tenant_name), K(ret));
} else if (tenant_name.length() > OB_MAX_TENANT_NAME_LENGTH) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name too long", K(tenant_name), K(ret));
} else if (OB_FAIL(ob_cstrcopy(tenant_, sizeof(tenant_), tenant_name))) {
LOG_WARN("failed to copy tenant name", K(tenant_name), K(ret));
} else if (OB_FAIL(ob_cstrcopy(effective_tenant_, sizeof(effective_tenant_), tenant_name))) {
LOG_WARN("failed to copy effective tenant name", K(tenant_name), K(ret));
} else {
ObTZMapWrap tz_map_wrap;
if (OB_FAIL(OTTZ_MGR.get_tenant_tz(tenant_id, tz_map_wrap))) {
LOG_WARN("get tenant timezone map failed", K(ret));
} else {
tz_info_wrap_.set_tz_info_map(tz_map_wrap.get_tz_map());
tenant_id_ = tenant_id;
effective_tenant_id_ = tenant_id;
LOG_DEBUG("init session tenant", K(tenant_name), K(tenant_id));
}
}
return ret;
}
int ObBasicSessionInfo::set_tenant(const common::ObString& tenant_name, const uint64_t tenant_id)
{
int ret = OB_SUCCESS;
if (!is_valid_tenant_id(tenant_id)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant id", K(tenant_id), K(ret));
} else if (tenant_name.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name is empty", K(tenant_name), K(ret));
} else if (tenant_name.length() > OB_MAX_TENANT_NAME_LENGTH) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name too long", K(tenant_name), K(ret));
} else if (OB_FAIL(ob_cstrcopy(tenant_, sizeof(tenant_), tenant_name))) {
LOG_WARN("tenant name too long", K(tenant_name));
} else {
tenant_id_ = tenant_id;
LOG_TRACE("set tenant", K(tenant_name), K(tenant_id));
}
return ret;
}
int ObBasicSessionInfo::set_tenant(const common::ObString& tenant_name, const uint64_t tenant_id, char* ori_tenant_name,
const uint64_t length, uint64_t& ori_tenant_id)
{
int ret = OB_SUCCESS;
if (!is_valid_tenant_id(tenant_id)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant id", K(tenant_id), K(ret));
} else if (OB_ISNULL(ori_tenant_name)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("ori_tenant_name is NULL", K(ret));
} else if (length < OB_MAX_TENANT_NAME_LENGTH + 1) {
ret = OB_INVALID_ARGUMENT_FOR_LENGTH;
LOG_WARN("tenant_name length is not enough ");
} else if (tenant_name.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name is empty", K(tenant_name), K(ret));
} else if (tenant_name.length() > OB_MAX_TENANT_NAME_LENGTH) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tenant name too long", K(tenant_name), K(ret));
} else if (OB_FAIL(ob_cstrcopy(ori_tenant_name, length, tenant_, strlen(tenant_)))) {
LOG_ERROR("tenant_name is longer than ori_tenant_name", K(length), K(strlen(tenant_)));
} else if (OB_FAIL(ob_cstrcopy(tenant_, sizeof(tenant_), tenant_name))) {
LOG_ERROR("tenant name too long", K(tenant_name));
} else {
ori_tenant_id = tenant_id_;
tenant_id_ = tenant_id;
}
return ret;
}
int ObBasicSessionInfo::switch_tenant(uint64_t effective_tenant_id)
{
int ret = OB_SUCCESS;
if (OB_SYS_TENANT_ID != tenant_id_) {
ret = OB_NOT_SUPPORTED;
LOG_WARN("only support sys tenant switch tenant", K(ret), K(tenant_id_), K(effective_tenant_id_));
} else if (effective_tenant_id <= 0) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant_id", K(ret), K(effective_tenant_id));
} else {
#ifndef NDEBUG
if (effective_tenant_id_ != effective_tenant_id) {
LOG_INFO(
"switch tenant", K(effective_tenant_id), K(effective_tenant_id_), "priv_tenant_id", tenant_id_, K(lbt()));
}
#endif
effective_tenant_id_ = effective_tenant_id;
}
return ret;
}
const common::ObString ObBasicSessionInfo::get_tenant_name() const
{
return ObString::make_string(tenant_);
}
const common::ObString ObBasicSessionInfo::get_effective_tenant_name() const
{
return ObString::make_string(effective_tenant_);
}
int ObBasicSessionInfo::set_user(const ObString& user_name, const ObString& host_name, const uint64_t user_id)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(user_name.length() > common::OB_MAX_USER_NAME_LENGTH) ||
OB_UNLIKELY(host_name.length() > common::OB_MAX_HOST_NAME_LENGTH)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("name length invalid_", K(user_name), K(host_name), K(ret));
} else {
char tmp_buf[common::OB_MAX_USER_NAME_LENGTH + common::OB_MAX_HOST_NAME_LENGTH + 2] = {};
snprintf(tmp_buf,
sizeof(tmp_buf),
"%.*s@%.*s",
user_name.length(),
user_name.ptr(),
host_name.length(),
host_name.ptr());
ObString tmp_string(tmp_buf);
LockGuard lock_guard(thread_data_mutex_);
if (OB_FAIL(name_pool_.write_string(user_name, &thread_data_.user_name_))) {
LOG_WARN("fail to write username to string_buf_", K(user_name), K(ret));
} else if (OB_FAIL(name_pool_.write_string(host_name, &thread_data_.host_name_))) {
LOG_WARN("fail to write hostname to string_buf_", K(host_name), K(ret));
} else if (OB_FAIL(name_pool_.write_string(tmp_string, &thread_data_.user_at_host_name_))) {
LOG_WARN("fail to write user_at_host_name to string_buf_", K(tmp_string), K(ret));
} else {
user_id_ = user_id;
}
}
return ret;
}
int ObBasicSessionInfo::set_real_client_ip(const common::ObString& client_ip)
{
int ret = OB_SUCCESS;
char tmp_buf[common::OB_MAX_USER_NAME_LENGTH + common::OB_MAX_HOST_NAME_LENGTH + 2] = {};
snprintf(tmp_buf,
sizeof(tmp_buf),
"%.*s@%.*s",
thread_data_.user_name_.length(),
thread_data_.user_name_.ptr(),
client_ip.length(),
client_ip.ptr());
ObString tmp_string(tmp_buf);
LockGuard lock_guard(thread_data_mutex_);
if (OB_FAIL(name_pool_.write_string(client_ip, &thread_data_.client_ip_))) {
LOG_WARN("fail to write client_ip to string_buf_", K(client_ip), K(ret));
} else if (OB_FAIL(name_pool_.write_string(tmp_string, &thread_data_.user_at_client_ip_))) {
LOG_WARN("fail to write user_at_host_name to string_buf_", K(tmp_string), K(ret));
} else {
thread_data_.user_client_addr_.set_ip_addr(client_ip, 0);
}
return ret;
}
int ObBasicSessionInfo::check_and_init_retry_info(const ObCurTraceId::TraceId& cur_trace_id, const ObString& sql)
{
int ret = OB_SUCCESS;
if (last_query_trace_id_.equals(cur_trace_id)) { // is retrying.
if (OB_UNLIKELY(!retry_info_.is_inited())) {
LOG_ERROR("is retry packet, but retry info is not inited, will init it",
K(last_query_trace_id_),
K(cur_trace_id),
K(retry_info_),
K(get_sessid()),
K(sql));
if (OB_FAIL(retry_info_.init())) {
LOG_WARN("fail to init retry info", K(ret), K(retry_info_), K(sql));
}
}
} else {
if (OB_UNLIKELY(retry_info_.is_inited())) {
retry_info_.reset();
}
if (OB_FAIL(retry_info_.init())) {
LOG_WARN("fail to init retry info", K(ret), K(retry_info_), K(sql));
} else {
last_query_trace_id_.set(cur_trace_id);
}
}
return ret;
}
void ObBasicSessionInfo::check_and_reset_retry_info(const ObCurTraceId::TraceId& cur_trace_id, bool is_packet_retry)
{
if (!is_packet_retry) {
retry_info_.reset();
}
last_query_trace_id_.set(cur_trace_id);
}
const ObLogIdLevelMap* ObBasicSessionInfo::get_log_id_level_map() const
{
return (log_id_level_map_valid_ ? (&log_id_level_map_) : NULL);
}
int ObBasicSessionInfo::set_client_version(const ObString& client_version)
{
int ret = OB_SUCCESS;
if (client_version.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("client version is empty", K(client_version), K(ret));
} else if (OB_FAIL(name_pool_.write_string(client_version, &client_version_))) {
LOG_WARN("failed to write client_version to string_buf_", K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::set_driver_version(const ObString& driver_version)
{
int ret = OB_SUCCESS;
if (driver_version.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("driver version is empty", K(driver_version), K(ret));
} else if (OB_FAIL(name_pool_.write_string(driver_version, &driver_version_))) {
LOG_WARN("failed to write driver_version to string_buf_", K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::set_default_database(
const ObString& database_name, const ObCollationType coll_type /*= CS_TYPE_INVALID */)
{
int ret = OB_SUCCESS;
if (database_name.length() > OB_MAX_DATABASE_NAME_LENGTH) {
ret = OB_INVALID_ARGUMENT_FOR_LENGTH;
LOG_WARN("invalid length for database_name", K(database_name), K(ret));
} else {
if (CS_TYPE_INVALID != coll_type) {
const int64_t coll_val = static_cast<int64_t>(coll_type);
if (OB_FAIL(update_sys_variable(SYS_VAR_CHARACTER_SET_DATABASE, coll_val))) {
LOG_WARN("failed to update variable", K(ret));
} else if (OB_FAIL(update_sys_variable(SYS_VAR_COLLATION_DATABASE, coll_val))) {
LOG_WARN("failed to update variable", K(ret));
} else {
}
}
if (OB_SUCC(ret)) {
LockGuard lock_guard(thread_data_mutex_);
MEMCPY(thread_data_.database_name_, database_name.ptr(), database_name.length());
thread_data_.database_name_[database_name.length()] = '\0';
if (is_track_session_info()) {
is_database_changed_ = true;
}
}
}
return ret;
}
int ObBasicSessionInfo::update_database_variables(ObSchemaGetterGuard* schema_guard)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(schema_guard)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid schema guard is NULL", K(ret));
} else {
if ('\0' == thread_data_.database_name_[0]) {
// no default database
ObObj val;
if (OB_FAIL(get_sys_variable(SYS_VAR_CHARACTER_SET_SERVER, val))) {
LOG_WARN("failed to get sys variable", K(ret));
} else if (OB_FAIL(update_sys_variable(SYS_VAR_CHARACTER_SET_DATABASE, val))) {
LOG_WARN("failed to update sys variable", K(ret));
} else if (OB_FAIL(get_sys_variable(SYS_VAR_COLLATION_SERVER, val))) {
LOG_WARN("failed to get sys variable", K(ret));
} else if (OB_FAIL(update_sys_variable(SYS_VAR_COLLATION_DATABASE, val))) {
LOG_WARN("failed to update sys variable", K(ret));
} else {
}
} else {
const share::schema::ObDatabaseSchema* db_schema = NULL;
ObString db_name(thread_data_.database_name_);
if (OB_FAIL(schema_guard->get_database_schema(effective_tenant_id_, db_name, db_schema))) {
LOG_WARN("get database schema failed", K(effective_tenant_id_), K(db_name), K(ret));
} else if (NULL == db_schema) {
ret = OB_ERR_BAD_DATABASE;
LOG_WARN("database not exist", K(effective_tenant_id_), K(db_name), K(ret));
LOG_USER_ERROR(OB_ERR_BAD_DATABASE, db_name.length(), db_name.ptr());
} else {
const int64_t db_coll = static_cast<int64_t>(db_schema->get_collation_type());
if (OB_FAIL(update_sys_variable(SYS_VAR_CHARACTER_SET_DATABASE, db_coll))) {
LOG_WARN("failed to update sys variable", K(ret));
} else if (OB_FAIL(update_sys_variable(SYS_VAR_COLLATION_DATABASE, db_coll))) {
LOG_WARN("failed to update sys variable", K(ret));
} else {
}
}
}
}
return ret;
}
int ObBasicSessionInfo::update_max_packet_size()
{
int ret = OB_SUCCESS;
int64_t max_allowed_pkt = 0;
int64_t net_buffer_len = 0;
if (OB_FAIL(get_max_allowed_packet(max_allowed_pkt))) {
LOG_WARN("fail to get_max_allowed_packet", K(ret));
} else if (OB_FAIL(get_net_buffer_length(net_buffer_len))) {
LOG_WARN("fail to get_net_buffer_length", K(ret));
} else {
thread_data_.max_packet_size_ = std::max(max_allowed_pkt, net_buffer_len);
}
return ret;
}
const ObString ObBasicSessionInfo::get_database_name() const
{
ObString str_ret;
str_ret.assign_ptr(
const_cast<char*>(thread_data_.database_name_), static_cast<int32_t>(strlen(thread_data_.database_name_)));
return str_ret;
}
//// FIXME:
// int ObBasicSessionInfo::get_database_id(
// ObSchemaGetterGuard *schema_guard,
// uint64_t &db_id) const
//{
// int ret = OB_SUCCESS;
// db_id = OB_INVALID_ID;
// if (get_database_name().empty()) {
// //do nothing
// } else if (OB_UNLIKELY(NULL == schema_guard)) {
// ret = OB_INVALID_ARGUMENT;
// LOG_WARN("Schema guard should not be NULL", K(ret));
// } else if (OB_FAIL(schema_guard->get_database_id(get_effective_tenant_id(), get_database_name(),
// db_id))) {
// db_id = OB_INVALID_ID;
// LOG_WARN("failed to get database id", K(db_id), K(ret));
// } else { }//do nothing
// return ret;
//}
////////////////////////////////////////////////////////////////
int ObBasicSessionInfo::get_global_sys_variable(
const ObBasicSessionInfo* session, ObIAllocator& calc_buf, const ObString& var_name, ObObj& val)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(session)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("session is NULL", K(ret), K(var_name));
} else {
// const ObDataTypeCastParams dtc_params(session->get_timezone_info(),
// session->get_local_nls_formats(),
// session->get_nls_collation(),
// session->get_nls_collation_nation());
ObDataTypeCastParams dtc_params = session->get_dtc_params();
if (OB_FAIL(get_global_sys_variable(session->get_effective_tenant_id(), calc_buf, dtc_params, var_name, val))) {
LOG_WARN("fail to get global sys variable", K(ret), K(var_name));
}
}
return ret;
}
int ObBasicSessionInfo::get_global_sys_variable(const uint64_t actual_tenant_id, // tenant may be switched
ObIAllocator& calc_buf, const ObDataTypeCastParams& dtc_params, const ObString& var_name, ObObj& val)
{
int ret = OB_SUCCESS;
ObSchemaGetterGuard schema_guard;
const ObTenantSchema* tenant_schema = NULL;
const ObSysVarSchema* sysvar_schema = NULL;
const ObSysVariableSchema* sys_variable_schema = NULL;
if (OB_UNLIKELY(!is_valid_tenant_id(actual_tenant_id))) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid tenant id", K(actual_tenant_id), K(ret));
} else if (OB_ISNULL(GCTX.schema_service_)) {
ret = OB_INVALID_ARGUMENT;
OB_LOG(WARN, "invalid argument", K(GCTX.schema_service_));
} else if (OB_FAIL(GCTX.schema_service_->get_tenant_schema_guard(actual_tenant_id, schema_guard))) {
ret = OB_SCHEMA_ERROR;
OB_LOG(WARN, "fail get schema guard", K(ret));
} else if (OB_FAIL(schema_guard.get_tenant_info(actual_tenant_id, tenant_schema))) {
LOG_WARN("get tenant info failed", K(ret), K(actual_tenant_id));
} else if (OB_ISNULL(tenant_schema)) {
ret = OB_SCHEMA_ERROR;
LOG_WARN("tenant_schema is NULL", K(ret));
} else if (OB_FAIL(schema_guard.get_sys_variable_schema(actual_tenant_id, sys_variable_schema))) {
LOG_WARN("get sys variable schema failed", K(ret));
} else if (OB_ISNULL(sys_variable_schema)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("sys variable schema is null", K(ret));
} else if (OB_FAIL(sys_variable_schema->get_sysvar_schema(var_name, sysvar_schema))) {
ret = OB_ERR_SYS_VARIABLE_UNKNOWN;
LOG_WARN("failed to get sysvar", K(ret), K(var_name));
} else if (OB_ISNULL(sysvar_schema)) {
ret = OB_SCHEMA_ERROR;
LOG_WARN("tenant_schema is NULL", K(ret));
} else if (OB_FAIL(sysvar_schema->get_value(&calc_buf, dtc_params, val))) {
LOG_WARN("failed to get value", K(ret), K(var_name));
} else if (OB_FAIL(ObBasicSessionInfo::change_value_for_special_sys_var(var_name, val, val))) {
LOG_ERROR("fail to change value for special sys var", K(ret), K(var_name), K(val));
} else {
LOG_DEBUG("get global sysvar", K(var_name), K(val));
}
return ret;
}
const ObBasicSysVar* ObBasicSessionInfo::get_sys_var(const int64_t idx) const
{
const ObBasicSysVar* var = NULL;
if (idx >= 0 && idx < ObSysVarFactory::ALL_SYS_VARS_COUNT) {
var = sys_vars_[idx];
}
return var;
}
int ObBasicSessionInfo::init_system_variables(const bool print_info_log, const bool is_sys_tenant)
{
int ret = OB_SUCCESS;
ObString name;
ObObj type;
ObObj value;
ObObj min_val;
ObObj max_val;
ObObjType var_type = ObNullType;
int64_t var_flag = ObSysVarFlag::NONE;
int64_t var_amount = ObSysVariables::get_amount();
ObObj casted_value;
ObArenaAllocator calc_buf(ObModIds::OB_SQL_SESSION);
ObCastCtx cast_ctx(&calc_buf, NULL, CM_NONE, ObCharset::get_system_collation());
for (int64_t i = 0; OB_SUCC(ret) && i < var_amount; ++i) {
name.assign_ptr(const_cast<char*>(ObSysVariables::get_name(i).ptr()),
static_cast<ObString::obstr_size_t>(strlen(ObSysVariables::get_name(i).ptr())));
bool is_exist = false;
if (OB_FAIL(sys_variable_exists(name, is_exist))) {
LOG_WARN("failed to check if sys variable exists", K(name), K(ret));
} else if (!is_exist) {
var_type = ObSysVariables::get_type(i);
var_flag = ObSysVariables::get_flags(i);
value.set_varchar(ObSysVariables::get_value(i));
value.set_collation_type(ObCharset::get_system_collation());
min_val.set_varchar(ObSysVariables::get_min(i));
min_val.set_collation_type(ObCharset::get_system_collation());
max_val.set_varchar(ObSysVariables::get_max(i));
max_val.set_collation_type(ObCharset::get_system_collation());
type.set_type(var_type);
if (is_sys_tenant) {
if (OB_FAIL(process_variable_for_tenant(name, value))) {
LOG_WARN("process system variable for tenant error", K(name), K(value), K(ret));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(load_sys_variable(name, type, value, min_val, max_val, var_flag))) {
LOG_WARN("fail to load default system variable", K(name), K(ret));
} else if (OB_NOT_NULL(sys_vars_[i]) && sys_vars_[i]->is_influence_plan() &&
OB_FAIL(influence_plan_var_indexs_.push_back(i))) {
LOG_WARN("fail to add influence plan sys var", K(name), K(ret));
} else if (print_info_log) {
LOG_INFO("load default system variable", name.ptr(), value.get_string().ptr());
}
}
}
} // end for
if (OB_SUCC(ret)) {
if (OB_FAIL(gen_sys_var_in_pc_str())) {
LOG_INFO("fail to generate system variables in pc str");
} else {
global_vars_version_ = 0;
sys_var_base_version_ = 0;
}
}
return ret;
}
int ObBasicSessionInfo::update_query_sensitive_system_variable(ObSchemaGetterGuard& schema_guard)
{
int ret = OB_SUCCESS;
const ObSysVarSchema* sysvar = NULL;
int64_t schema_version = -1;
const ObSimpleSysVariableSchema* sys_variable_schema = NULL;
const uint64_t tenant_id = get_effective_tenant_id();
int64_t refreshed_schema_version = OB_INVALID_VERSION;
if (!check_sys_variable_) {
// skip to avoid circular dependency.
} else if (OB_FAIL(schema_guard.get_schema_version(tenant_id, refreshed_schema_version))) {
LOG_WARN("fail to get tenant schema version", K(ret), K(tenant_id));
} else if (OB_CORE_SCHEMA_VERSION >= refreshed_schema_version) {
// if in tenant creation process or the tenant creation fails or the local schema is not refreshed,
// the system variables can not be obtained, skip this step.
} else if (OB_FAIL(schema_guard.get_sys_variable_schema(tenant_id, sys_variable_schema))) {
LOG_WARN("get tenant schema version failed", K(ret), K(tenant_id));
} else if (OB_ISNULL(sys_variable_schema)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("sys variable schema should not be null", K(ret), K(tenant_id));
} else if (FALSE_IT(schema_version = sys_variable_schema->get_schema_version())) {
ret = OB_ERR_UNEXPECTED;
} else if (schema_version > get_global_vars_version() && schema_version > OB_CORE_SCHEMA_VERSION) {
const ObTenantSchema* tenant_info = NULL;
bool need_update_version = false;
const ObSysVariableSchema* sys_variable_schema = NULL;
if (OB_FAIL(schema_guard.get_tenant_info(get_effective_tenant_id(), tenant_info))) {
LOG_WARN("get tenant info from schema guard failed", K(ret));
} else if (OB_FAIL(schema_guard.get_sys_variable_schema(get_effective_tenant_id(), sys_variable_schema))) {
if (OB_TENANT_NOT_EXIST == ret) {
LOG_INFO("tenant maybe creating, just skip", K(ret), K(ret));
ret = OB_SUCCESS;
} else {
LOG_WARN("get sys variable schema failed", K(ret));
}
} else if (OB_ISNULL(sys_variable_schema)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("sys variable schema is null", K(ret));
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < sys_variable_schema->get_sysvar_count(); ++i) {
sysvar = sys_variable_schema->get_sysvar_schema(i);
if (sysvar != NULL && sysvar->is_query_sensitive()) {
if (OB_FAIL(update_sys_variable(sysvar->get_name(), sysvar->get_value()))) {
if (OB_ERR_SYS_VARIABLE_UNKNOWN == ret) {
// this system variable may come from a higher version,
// which is not available locally, ignore it.
ret = OB_SUCCESS;
} else {
LOG_WARN("update system variable failed", K(ret), K(*sysvar));
}
} else {
need_update_version = true;
}
}
}
if (OB_SUCC(ret) && need_update_version) {
set_global_vars_version(schema_version);
}
}
}
return ret;
}
// used for bootstarp, in which we can not get system variables from inner table.
int ObBasicSessionInfo::load_default_sys_variable(const bool print_info_log, const bool is_sys_tenant)
{
int ret = OB_SUCCESS;
if (OB_FAIL(init_system_variables(print_info_log, is_sys_tenant))) {
LOG_WARN("Init system variables failed !", K(ret));
} else {
variables_last_modify_time_ = ObTimeUtility::current_time();
}
return ret;
}
// used for session deserialization from lower version observer,
// and some system variables may be supported in current version.
int ObBasicSessionInfo::load_default_sys_variable(int64_t var_idx)
{
int ret = OB_SUCCESS;
ObString name;
ObObj type;
ObObj value;
ObObj min_val;
ObObj max_val;
ObObjType var_type = ObNullType;
int64_t var_flag = ObSysVarFlag::NONE;
if (var_idx < 0 || var_idx >= ObSysVarFactory::ALL_SYS_VARS_COUNT) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("the value of var_idx is unexpected", K(ret));
} else {
name.assign_ptr(const_cast<char*>(ObSysVariables::get_name(var_idx).ptr()),
static_cast<ObString::obstr_size_t>(strlen(ObSysVariables::get_name(var_idx).ptr())));
var_type = ObSysVariables::get_type(var_idx);
var_flag = ObSysVariables::get_flags(var_idx);
value.set_varchar(ObSysVariables::get_value(var_idx));
value.set_collation_type(ObCharset::get_system_collation());
min_val.set_varchar(ObSysVariables::get_min(var_idx));
min_val.set_collation_type(ObCharset::get_system_collation());
max_val.set_varchar(ObSysVariables::get_max(var_idx));
max_val.set_collation_type(ObCharset::get_system_collation());
type.set_type(var_type);
if (OB_FAIL(load_sys_variable(name, type, value, min_val, max_val, var_flag))) {
LOG_WARN("fail to load default system variable", K(name), K(ret));
}
}
return ret;
}
int ObBasicSessionInfo::process_variable_for_tenant(const ObString& var, ObObj& val)
{
int ret = OB_SUCCESS;
if (0 == var.compare(OB_SV_LOWER_CASE_TABLE_NAMES)) {
val.set_varchar("2");
val.set_collation_type(ObCharset::get_system_collation());
}
return ret;
}
int ObBasicSessionInfo::create_sys_var(ObSysVarClassType sys_var_id, int64_t store_idx, ObBasicSysVar*& sys_var)
{
int ret = OB_SUCCESS;
OV(0 <= store_idx && store_idx < ObSysVarFactory::ALL_SYS_VARS_COUNT, OB_ERR_UNEXPECTED, sys_var_id, store_idx);
if (OB_NOT_NULL(sys_vars_[store_idx])) {
OV(sys_vars_[store_idx]->get_type() == sys_var_id,
OB_ERR_UNEXPECTED,
sys_var_id,
store_idx,
sys_vars_[store_idx]->get_type());
OX(sys_var = sys_vars_[store_idx]);
} else {
OZ(sys_var_fac_.create_sys_var(sys_var_id, sys_var), sys_var_id);
OV(OB_NOT_NULL(sys_var), OB_ERR_UNEXPECTED, sys_var_id, store_idx);
OX(sys_vars_[store_idx] = sys_var);
}
return ret;
}
int ObBasicSessionInfo::inner_get_sys_var(const ObString& sys_var_name, ObBasicSysVar*& sys_var) const
{
int ret = OB_SUCCESS;
ObSysVarClassType sys_var_id = SYS_VAR_INVALID;
int64_t store_idx = -1;
if (OB_UNLIKELY(SYS_VAR_INVALID == (sys_var_id = ObSysVarFactory::find_sys_var_id_by_name(sys_var_name)))) {
ret = OB_ERR_SYS_VARIABLE_UNKNOWN;
LOG_WARN("fail to find sys var id by name", K(ret), K(sys_var_name), K(lbt()));
} else if (OB_FAIL(ObSysVarFactory::calc_sys_var_store_idx(sys_var_id, store_idx))) {
LOG_WARN("fail to calc sys var store idx", K(ret), K(sys_var_id), K(sys_var_name), K(lbt()));
} else if (OB_UNLIKELY(store_idx < 0) || OB_UNLIKELY(store_idx >= ObSysVarFactory::ALL_SYS_VARS_COUNT)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("got store_idx is invalid", K(ret), K(store_idx));
} else if (OB_ISNULL(sys_vars_[store_idx])) {
ret = OB_ENTRY_NOT_EXIST;
LOG_WARN("sys var is NULL", K(ret), K(store_idx), K(sys_var_name), K(lbt()));
} else {
sys_var = sys_vars_[store_idx];
}
return ret;
}
int ObBasicSessionInfo::inner_get_sys_var(const ObSysVarClassType sys_var_id, ObBasicSysVar*& sys_var) const
{
int ret = OB_SUCCESS;
int64_t store_idx = -1;
if (OB_UNLIKELY(SYS_VAR_INVALID == sys_var_id)) {
ret = OB_INVALID_ARGUMENT;
LOG_ERROR("invalid sys var id", K(ret), K(sys_var_id), K(lbt()));
} else if (OB_FAIL(ObSysVarFactory::calc_sys_var_store_idx(sys_var_id, store_idx))) {
LOG_WARN("fail to calc sys var store idx", K(ret), K(sys_var_id), K(lbt()));
} else if (OB_UNLIKELY(store_idx < 0) || OB_UNLIKELY(store_idx >= ObSysVarFactory::ALL_SYS_VARS_COUNT)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("got store_idx is invalid", K(ret), K(store_idx));
} else if (OB_ISNULL(sys_vars_[store_idx])) {
ret = OB_ENTRY_NOT_EXIST;
LOG_WARN("sys var is NULL", K(ret), K(store_idx), K(lbt()));
} else {
sys_var = sys_vars_[store_idx];
}
return ret;
}
int ObBasicSessionInfo::change_value_for_special_sys_var(
const ObString& sys_var_name, const ObObj& ori_val, ObObj& new_val)
{
int ret = OB_SUCCESS;
ObSysVarClassType sys_var_id = ObSysVarFactory::find_sys_var_id_by_name(sys_var_name);
if (OB_UNLIKELY(SYS_VAR_INVALID == sys_var_id)) {
LOG_WARN("fail to find sys var id by name", K(ret), K(sys_var_name));
} else if (OB_FAIL(ObBasicSessionInfo::change_value_for_special_sys_var(sys_var_id, ori_val, new_val))) {
LOG_WARN("fail to change value for special sys var", K(ret), K(sys_var_name), K(sys_var_id), K(ori_val));
}
return ret;
}
int ObBasicSessionInfo::change_value_for_special_sys_var(
const ObSysVarClassType sys_var_id, const ObObj& ori_val, ObObj& new_val)
{
int ret = OB_SUCCESS;
int64_t sys_var_store_idx = -1;
if (SYS_VAR_VERSION_COMMENT == sys_var_id || SYS_VAR_VERSION == sys_var_id ||
SYS_VAR_SYSTEM_TIME_ZONE == sys_var_id) {
if (OB_FAIL(ObSysVarFactory::calc_sys_var_store_idx(sys_var_id, sys_var_store_idx))) {
LOG_WARN("fail to calc sys var store idx", K(ret), K(sys_var_id));
} else {
new_val = ObSysVariables::get_default_value(sys_var_store_idx);
}
} else {
new_val = ori_val;
}
return ret;
}
int ObBasicSessionInfo::load_sys_variable(const ObString& name, const ObObj& type, const ObObj& value,
const ObObj& min_val, const ObObj& max_val, const int64_t flags, bool is_from_sys_table /*= false*/)
{
int ret = OB_SUCCESS;
ObObj casted_cell;
ObBasicSysVar* sys_var = NULL;
ObSysVarClassType var_id = SYS_VAR_INVALID;
ObObj real_val;
ObObj val_ptr;
ObObj min_ptr;
ObObj max_ptr;
ObObj val_type;
ObObj tmp_type;
int64_t store_idx = -1;
if (SYS_VAR_INVALID == (var_id = ObSysVarFactory::find_sys_var_id_by_name(name, is_from_sys_table))) {
if (is_from_sys_table) {
ret = OB_SUCCESS;
} else {
ret = OB_ERR_SYS_VARIABLE_UNKNOWN;
LOG_ERROR("failed to find system variable", K(ret), K(name));
}
} else if (OB_FAIL(ObSysVarFactory::calc_sys_var_store_idx(var_id, store_idx))) {
LOG_WARN("fail to calc sys var store idx", K(ret), K(var_id));
} else if (OB_FAIL(cast_sys_variable(false, var_id, type, value, flags, val_type, val_ptr))) {
LOG_WARN("fail to cast system variable", K(var_id), K(type), K(value), K(flags), K(val_ptr), K(ret));
} else if (OB_FAIL(cast_sys_variable(true, var_id, type, min_val, flags, tmp_type, min_ptr))) {
LOG_WARN("fail to cast system variable", K(var_id), K(type), K(min_val), K(flags), K(min_val), K(min_ptr), K(ret));
} else if (OB_FAIL(cast_sys_variable(true, var_id, type, max_val, flags, tmp_type, max_ptr))) {
LOG_WARN("fail to cast system variable", K(var_id), K(type), K(max_val), K(flags), K(max_ptr), K(ret));
} else if (OB_FAIL(create_sys_var(var_id, store_idx, sys_var))) {
LOG_WARN("fail to create sys var", K(name), K(value), K(ret));
} else if (OB_ISNULL(sys_var)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("sys var is NULL", K(name), K(value), K(ret));
} else if (OB_FAIL(ObBasicSessionInfo::change_value_for_special_sys_var(var_id, val_ptr, real_val))) {
LOG_WARN("fail to change value for special sys var", K(ret), K(var_id), K(val_ptr));
} else if (OB_FAIL(sys_var->init(real_val, min_ptr, max_ptr, val_type.get_type(), flags))) {
LOG_WARN("fail to init sys var", K(ret), K(sys_var->get_type()), K(real_val), K(name), K(value));
} else if (OB_FAIL(process_session_variable(var_id, real_val, false, false /*check_timezone_valid*/))) {
LOG_WARN("process system variable error", K(name), K(type), K(real_val), K(value), K(ret));
} else {
variables_last_modify_time_ = ObTimeUtility::current_time();
}
return ret;
}
int ObBasicSessionInfo::load_sys_variable(const ObString& name, const int64_t dtype, const ObString& value_str,
const ObString& min_val_str, const ObString& max_val_str, const int64_t flags, bool is_from_sys_table /*= false*/)
{
int ret = OB_SUCCESS;
ObObj value, min_val, max_val;
ObObj otype;
value.set_varchar(value_str);
value.set_collation_type(ObCharset::get_system_collation());
min_val.set_varchar(min_val_str);
min_val.set_collation_type(ObCharset::get_system_collation());
max_val.set_varchar(max_val_str);
max_val.set_collation_type(ObCharset::get_system_collation());
otype.set_type(static_cast<ObObjType>(dtype));
if (OB_FAIL(load_sys_variable(name, otype, value, min_val, max_val, flags, is_from_sys_table))) {
LOG_WARN("fail to load system variable",
K(name),
K(otype),
K(value),
K(min_val),
K(max_val),
K(flags),
K(is_from_sys_table),
K(ret));
}
return ret;
}
int ObBasicSessionInfo::cast_sys_variable(bool is_range_value, const ObSysVarClassType sys_var_id, const ObObj& type,
const ObObj& value, int64_t flags, ObObj& out_type, ObObj& out_value)
{
UNUSED(sys_var_id);
int ret = OB_SUCCESS;
ObObj casted_cell;
ObArenaAllocator calc_buf(ObModIds::OB_SQL_SESSION);
if (ObVarcharType != value.get_type()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid type", K(value), K(ret));
} else {
if (is_range_value && value.get_varchar() == ObString::make_string(ObBasicSysVar::EMPTY_STRING)) {
out_value.set_null();
} else if (ObBasicSysVar::is_null_value(value.get_varchar(), flags)) {
out_value.set_null();
} else {
ObDataTypeCastParams dtc_params = get_dtc_params();
ObCastCtx cast_ctx(&calc_buf, &dtc_params, CM_NONE, ObCharset::get_system_collation());
if (OB_FAIL(
ObObjCaster::to_type(type.get_type(), ObCharset::get_system_collation(), cast_ctx, value, casted_cell))) {
_LOG_WARN("failed to cast object, cell=%s from_type=%s to_type=%s ret=%d ",
to_cstring(value),
ob_obj_type_str(value.get_type()),
ob_obj_type_str(type.get_type()),
ret);
} else if (OB_FAIL(base_sys_var_alloc_.write_obj(casted_cell, &out_value))) {
LOG_WARN("fail to store variable value", K(casted_cell), K(value), K(ret));
} else {
if (ob_is_string_type(out_value.get_type())) {
out_value.set_collation_level(CS_LEVEL_SYSCONST);
if (CS_TYPE_INVALID == out_value.get_collation_type()) {
out_value.set_collation_type(ObCharset::get_system_collation());
}
}
}
}
if (OB_SUCC(ret)) {
out_type.set_type(type.get_type());
}
}
return ret;
}
bool sys_var_compare(const SysVarNameVal& left, const SysVarNameVal& right)
{
return left.name_ < right.name_;
}
/*
*the following system variables affect plan cache:
*read_only
*ob_enable_transformation
*binlog_row_image
*collation_connection
*sql_auto_is_null
*div_precision_increment
*ob_enable_aggregation_pushdown
*ob_enable_index_direct_select
*sql_mode
*ob_max_parallel_degree
*ob_route_policy
*ob_read_consistency
*/
int ObBasicSessionInfo::get_influence_plan_sys_var(ObSysVarInPC& sys_vars) const
{
int ret = OB_SUCCESS;
// get influence_plan_sys_var from sys_var_val_map
int64_t index = 0;
for (int64_t i = 0; OB_SUCC(ret) && i < get_influence_plan_var_count(); ++i) {
index = influence_plan_var_indexs_.at(i);
if (index >= ObSysVarFactory::ALL_SYS_VARS_COUNT) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("influence plan system var indexs out of range", K(i), K(ret));
} else if (NULL == sys_vars_[index]) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("influence plan system var is NULL", K(i), K(ret));
} else if (OB_FAIL(sys_vars.push_back(sys_vars_[index]->get_value()))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("influence plan system variables push failed", K(ret));
}
}
return ret;
}
int ObBasicSessionInfo::gen_sys_var_in_pc_str()
{
int ret = OB_SUCCESS;
const int64_t MAX_SYS_VARS_STR_SIZE = 1024;
ObSysVarInPC sys_vars;
char* buf = NULL;
int64_t pos = 0;
if (is_first_gen_) {
if (NULL == (buf = (char*)name_pool_.alloc(MAX_SYS_VARS_STR_SIZE))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("fail to allocator memory", K(ret), K(MAX_SYS_VARS_STR_SIZE));
}
is_first_gen_ = false;
} else {
buf = sys_var_in_pc_str_.ptr();
MEMSET(buf, 0, sys_var_in_pc_str_.length());
sys_var_in_pc_str_.reset();
}
if (OB_FAIL(ret)) {
} else if (OB_FAIL(get_influence_plan_sys_var(sys_vars))) {
LOG_WARN("fail to get influence plan system variables", K(ret));
} else if (OB_FAIL(sys_vars.serialize_sys_vars(buf, MAX_SYS_VARS_STR_SIZE, pos))) {
LOG_WARN("fail to serialize system vars");
} else {
(void)sys_var_in_pc_str_.assign(buf, int32_t(pos));
}
return ret;
}
int ObBasicSessionInfo::update_sys_variable_by_name(const ObString& var, const ObObj& val)
{
int ret = OB_SUCCESS;
ObSysVarClassType var_id = SYS_VAR_INVALID;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(val), K(ret));
} else if (SYS_VAR_INVALID == (var_id = ObSysVarFactory::find_sys_var_id_by_name(var))) {
ret = OB_ERR_SYS_VARIABLE_UNKNOWN;
LOG_WARN("unknown variable", K(var), K(val), K(ret));
} else if (OB_FAIL(update_sys_variable(var_id, val))) {
LOG_WARN("failed to update sys variable", K(var), K(val), K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::update_sys_variable_by_name(const common::ObString& var, int64_t val)
{
ObObj obj;
obj.set_int(val);
return update_sys_variable_by_name(var, obj);
}
int ObBasicSessionInfo::update_sys_variable(const ObSysVarClassType sys_var_id, const ObString& val)
{
ObObj obj;
obj.set_varchar(val);
obj.set_collation_type(ObCharset::get_system_collation());
return update_sys_variable(sys_var_id, obj);
}
int ObBasicSessionInfo::update_sys_variable(const ObSysVarClassType sys_var_id, const int64_t val)
{
ObObj obj;
obj.set_int(val);
return update_sys_variable(sys_var_id, obj);
}
int ObBasicSessionInfo::update_sys_variable(const ObString& var, const ObString& val)
{
int ret = OB_SUCCESS;
ObSysVarClassType sys_var_id = SYS_VAR_INVALID;
ObBasicSysVar* sys_var = NULL;
if (OB_UNLIKELY(SYS_VAR_INVALID == (sys_var_id = ObSysVarFactory::find_sys_var_id_by_name(var)))) {
ret = OB_ERR_SYS_VARIABLE_UNKNOWN;
LOG_WARN("unknown variable", K(var), K(val), K(ret));
} else if (OB_FAIL(inner_get_sys_var(sys_var_id, sys_var))) {
LOG_WARN("fail to inner get sys var", K(ret), K(var), K(val));
} else if (OB_ISNULL(sys_var)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret), K(var));
} else {
// trim quotation marks
ObString tmp_val;
if (val.length() > 1 &&
(('\'' == val[0] && '\'' == val[val.length() - 1]) || ('\"' == val[0] && '\"' == val[val.length() - 1]))) {
tmp_val.assign_ptr(val.ptr() + 1, val.length() - 2);
} else {
tmp_val.assign_ptr(val.ptr(), val.length());
}
ObObj in_obj;
in_obj.set_varchar(tmp_val);
in_obj.set_collation_type(ObCharset::get_system_collation());
const ObObj* out_obj = NULL;
ObObj buf_obj;
ObArenaAllocator calc_buf(ObModIds::OB_SQL_SESSION);
ObDataTypeCastParams dtc_params = get_dtc_params();
ObCastCtx cast_ctx(&calc_buf, &dtc_params, CM_NONE, ObCharset::get_system_collation());
if (OB_FAIL(ObObjCaster::to_type(sys_var->get_data_type(), cast_ctx, in_obj, buf_obj, out_obj))) {
LOG_WARN("failed to cast obj", "expected type", sys_var->get_meta_type(), K(ret), K(var), K(in_obj));
} else if (OB_ISNULL(out_obj)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("casted success, but out_obj is NULL", K(in_obj), K(ret));
} else if (OB_FAIL(update_sys_variable(sys_var_id, *out_obj))) {
LOG_WARN("fail to update sys variable", K(ret), K(var), K(*out_obj));
}
}
return ret;
}
int ObBasicSessionInfo::update_sys_variable(const ObSysVarClassType sys_var_id, const ObObj& val)
{
int ret = OB_SUCCESS;
ObObj obj;
ObBasicSysVar* sys_var = NULL;
if (SYS_VAR_INVALID == sys_var_id) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid sys_var_id", K(sys_var_id), K(ret));
} else if (OB_FAIL(inner_get_sys_var(sys_var_id, sys_var))) {
LOG_WARN("failed to inner get sys var", K(ret), K(sys_var_id), K(val));
} else if (OB_ISNULL(sys_var)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("failed to inner get sys var, sys var is null", K(ret), K(sys_var_id), K(val));
} else if (is_track_session_info()) {
if (OB_FAIL(track_sys_var(sys_var_id, sys_var->get_value()))) {
LOG_WARN("failed to track sys var", K(ret), K(sys_var_id), K(val));
} else {
variables_last_modify_time_ = ObTimeUtility::current_time();
LOG_DEBUG("succ to track system variable", K(ret), K(sys_var_id), K(val), K(sys_var->get_value()));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(deep_copy_sys_variable(sys_var_id, val, &obj))) {
LOG_WARN("fail to update system variable", K(sys_var_id), K(val), K(ret));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(process_session_variable(sys_var_id, val, true, false /*check_timezone_valid*/))) {
LOG_WARN("process system variable error", K(sys_var_id), K(val), K(ret));
} else if (OB_FAIL(sys_var_inc_info_.add_sys_var_id(sys_var_id))) {
LOG_WARN("add sys var id error", K(sys_var_id), K(ret));
} else {
if (SYS_VAR_TIME_ZONE == sys_var_id && !tz_info_wrap_.is_position_class()) {
const int64_t buf_len = 16;
char tmp_buf[buf_len] = {0};
int64_t pos = 0;
ObObj tmp_obj = val;
if (OB_ISNULL(tz_info_wrap_.get_time_zone_info())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("time zone info is null", K(ret));
} else if (OB_FAIL(tz_info_wrap_.get_time_zone_info()->timezone_to_str(tmp_buf, buf_len, pos))) {
LOG_WARN("timezone to str failed", K(ret));
} else {
tmp_obj.set_common_value(ObString(pos, tmp_buf));
if (OB_FAIL(deep_copy_sys_variable(sys_var_id, tmp_obj, &obj))) {
LOG_WARN("deep copy sys var failed", K(ret));
}
}
}
if (OB_SUCC(ret)) {
if (ob_is_string_type(obj.get_type())) {
obj.set_collation_level(CS_LEVEL_SYSCONST);
if (CS_TYPE_INVALID == obj.get_collation_type()) {
obj.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset()));
}
}
sys_var->set_value(obj);
}
}
}
if (OB_SUCC(ret) && !is_deserialized_ && sys_var->is_influence_plan() && OB_FAIL(gen_sys_var_in_pc_str())) {
LOG_ERROR("fail to gen sys var in pc str", K(ret));
}
return ret;
}
int ObBasicSessionInfo::deep_copy_trace_id_var(const ObObj& src_val, ObObj* dest_val_ptr)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(dest_val_ptr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("dest val ptr is NULL", K(ret));
} else {
*dest_val_ptr = src_val;
ObString new_str;
ObString src_str;
const int64_t STR_BUFF_LEN = sizeof(trace_id_buff_);
int64_t src_str_len = 0;
if (OB_FAIL(src_val.get_varchar(src_str))) {
LOG_WARN("fail to get varchar", K(src_val), K(ret));
} else if (OB_UNLIKELY((src_str_len = src_str.length()) == 0)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid string", K(src_str), K(ret));
} else if (STR_BUFF_LEN <= src_str_len) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid src str len", K(src_str_len), K(ret));
} else {
MEMCPY(trace_id_buff_, src_str.ptr(), src_str_len);
trace_id_buff_[src_str_len] = '\0';
new_str.assign_ptr(trace_id_buff_, static_cast<ObString::obstr_size_t>(src_str_len));
dest_val_ptr->set_varchar(new_str);
}
}
return ret;
}
// name_pool_ is an allocator that only alloc but not free,
// now we optimize for trace_id only, which will be accessed frequently.
int ObBasicSessionInfo::deep_copy_sys_variable(
const ObSysVarClassType sys_var_id, const ObObj& src_val, ObObj* dest_val_ptr)
{
int ret = OB_SUCCESS;
if (sys_var_id == SYS_VAR_OB_STATEMENT_TRACE_ID) {
if (OB_FAIL(deep_copy_trace_id_var(src_val, dest_val_ptr))) {
LOG_WARN("fail to deep copy trace id", K(ret));
}
} else if (OB_FAIL(name_pool_.write_obj(src_val, dest_val_ptr))) {
LOG_WARN("fail to write obj", K(src_val), K(ret));
}
return ret;
}
int ObBasicSessionInfo::update_session_sys_variable(ObExecContext& ctx, const ObString& var, const ObObj& val)
{
int ret = OB_SUCCESS;
ObBasicSysVar* sys_var = NULL;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(ret), K(var));
} else if (OB_FAIL(inner_get_sys_var(var, sys_var))) {
LOG_WARN("fail to inner get sys var", K(ret), K(var), K(val));
} else if (OB_ISNULL(sys_var)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret), K(var), K(val));
} else {
ObMySQLProxy sql_proxy;
ObSetVar set_var(var, ObSetVar::SET_SCOPE_SESSION, false, OB_INVALID_ID, ctx.get_allocator(), sql_proxy);
if (OB_FAIL(sys_var->session_update(ctx, set_var, val))) {
LOG_WARN("session update system variable failed", K(ret), K(set_var));
} else if (OB_FAIL(sys_var->update(ctx, set_var, val))) {
LOG_WARN("fail to update sys var", K(ret), K(var), K(val));
}
}
return ret;
}
int ObBasicSessionInfo::get_sys_variable_by_name(const ObString& var, ObBasicSysVar*& val) const
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(var.empty())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(ret));
} else if (OB_FAIL(inner_get_sys_var(var, val))) {
LOG_WARN("fail to inner get sys var", K(var), K(ret));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret), K(var));
} else {
}
return ret;
}
int ObBasicSessionInfo::get_sys_variable_by_name(const ObString& var, ObObj& val) const
{
int ret = OB_SUCCESS;
ObBasicSysVar* sys_var = NULL;
if (OB_UNLIKELY(var.empty())) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(ret));
} else if (OB_FAIL(inner_get_sys_var(var, sys_var))) {
LOG_WARN("fail to get sys var", K(ret), K(var));
} else if (OB_ISNULL(sys_var)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to get sys var, but sys var is NULL", K(ret), K(var));
} else {
val = sys_var->get_value();
}
return ret;
}
int ObBasicSessionInfo::get_sys_variable_by_name(const common::ObString& var, int64_t& val) const
{
int ret = OB_SUCCESS;
ObObj obj;
if (OB_FAIL(get_sys_variable_by_name(var, obj))) {
} else if (OB_FAIL(obj.get_int(val))) {
LOG_WARN("wrong obj type for system variable", K(var), K(obj), K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::get_sys_variable(const ObSysVarClassType sys_var_id, common::ObObj& val) const
{
int ret = OB_SUCCESS;
ObBasicSysVar* var = NULL;
if (OB_UNLIKELY(SYS_VAR_INVALID == sys_var_id)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid sys_var_id", K(ret), K(sys_var_id));
} else if (OB_FAIL(inner_get_sys_var(sys_var_id, var))) {
LOG_WARN("fail to get sys var", K(ret), K(var));
} else if (OB_ISNULL(var)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to get sys var, but sys var is NULL", K(ret), K(var));
} else {
val = var->get_value();
}
return ret;
}
int ObBasicSessionInfo::get_sys_variable(const ObSysVarClassType sys_var_id, common::ObString& val) const
{
int ret = OB_SUCCESS;
ObObj obj;
if (SYS_VAR_INVALID == sys_var_id) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid sys_var_id", K(sys_var_id), K(ret));
} else if (OB_FAIL(get_sys_variable(sys_var_id, obj))) {
LOG_WARN("failed to get system variable", K(sys_var_id), K(ret));
} else if (OB_FAIL(obj.get_varchar(val))) {
LOG_WARN("wrong obj type for system variable", K(sys_var_id), K(obj), K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::get_sys_variable(const ObSysVarClassType sys_var_id, int64_t& val) const
{
int ret = OB_SUCCESS;
ObObj obj;
if (OB_FAIL(get_sys_variable(sys_var_id, obj))) {
LOG_WARN("failed to get system variable", K(sys_var_id), K(obj), K(ret));
} else if (OB_FAIL(obj.get_int(val))) {
LOG_WARN("wrong obj type for system variable", K(sys_var_id), K(obj), K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::get_sys_variable(const ObSysVarClassType sys_var_id, uint64_t& val) const
{
int ret = OB_SUCCESS;
ObObj obj;
if (OB_FAIL(get_sys_variable(sys_var_id, obj))) {
LOG_WARN("failed to get system variable", K(sys_var_id), K(obj), K(ret));
} else if (OB_FAIL(obj.get_uint64(val))) {
LOG_WARN("wrong obj type for system variable", K(ret), K(sys_var_id), K(obj));
} else {
}
return ret;
}
int ObBasicSessionInfo::sys_variable_exists(const ObString& var, bool& is_exists) const
{
int ret = OB_SUCCESS;
is_exists = false;
ObSysVarClassType sys_var_id = SYS_VAR_INVALID;
int64_t store_idx = -1;
if (SYS_VAR_INVALID == (sys_var_id = ObSysVarFactory::find_sys_var_id_by_name(var))) {
LOG_DEBUG("sys var is not exist", K(var), K(ret));
} else if (OB_FAIL(ObSysVarFactory::calc_sys_var_store_idx(sys_var_id, store_idx))) {
LOG_WARN("fail to calc sys var store idx", K(sys_var_id), K(var), K(ret));
} else if (store_idx < 0 || store_idx >= ObSysVarFactory::ALL_SYS_VARS_COUNT) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("got store_idx is invalid", K(store_idx), K(ret));
} else {
is_exists = (NULL != sys_vars_[store_idx]);
}
return ret;
}
ObPhysicalPlan* ObBasicSessionInfo::get_cur_phy_plan() const
{
return cur_phy_plan_;
}
int ObBasicSessionInfo::set_cur_phy_plan(ObPhysicalPlan* cur_phy_plan)
{
int ret = OB_SUCCESS;
if (OB_ISNULL(cur_phy_plan)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("current physical plan is NULL", K(lbt()), K(ret));
} else {
cur_phy_plan_ = cur_phy_plan;
}
return ret;
}
void ObBasicSessionInfo::reset_cur_phy_plan_to_null()
{
cur_phy_plan_ = NULL;
}
ObObjType ObBasicSessionInfo::get_sys_variable_type(const ObString& var_name) const
{
int ret = OB_SUCCESS;
ObObjType obj_type = ObMaxType;
ObBasicSysVar* val = NULL;
if (OB_FAIL(inner_get_sys_var(var_name, val))) {
LOG_WARN("fail to inner get sys var", K(ret), K(var_name));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret), K(var_name));
} else {
obj_type = val->get_data_type();
}
return obj_type;
}
ObObjType ObBasicSessionInfo::get_sys_variable_meta_type(const ObString& var_name) const
{
int ret = OB_SUCCESS;
ObObjType obj_type = ObMaxType;
ObBasicSysVar* val = NULL;
if (OB_FAIL(inner_get_sys_var(var_name, val))) {
LOG_WARN("fail to inner get sys var", K(ret), K(var_name));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret), K(var_name));
} else {
obj_type = val->get_meta_type();
}
return obj_type;
}
#define PROCESS_SESSION_INT_VARIABLE(sys_var) \
do { \
ObArenaAllocator allocator(ObModIds::OB_SQL_SESSION); \
int64_t val_int = 0; \
ObCastCtx cast_ctx(&allocator, NULL, CM_NONE, CS_TYPE_INVALID); \
EXPR_GET_INT64_V2(val, val_int); \
if (OB_SUCC(ret)) { \
sys_var = val_int; \
} \
} while (0)
OB_INLINE int ObBasicSessionInfo::process_session_variable(
ObSysVarClassType var, const ObObj& val, bool is_inc, const bool check_timezone_valid /*true*/)
{
int ret = OB_SUCCESS;
switch (var) {
case SYS_VAR_OB_LOG_LEVEL: {
OZ(process_session_log_level(val), val);
break;
}
case SYS_VAR_OB_COMPATIBILITY_MODE: {
OZ(process_session_compatibility_mode_value(val, is_inc), val);
break;
}
case SYS_VAR_SQL_MODE: {
OZ(process_session_sql_mode_value(val, is_inc), val);
break;
}
case SYS_VAR_TIME_ZONE: {
OZ(process_session_time_zone_value(val, check_timezone_valid));
break;
}
case SYS_VAR_ERROR_ON_OVERLAP_TIME: {
OZ(process_session_overlap_time_value(val));
break;
}
case SYS_VAR_WAIT_TIMEOUT: {
LockGuard lock_guard(thread_data_mutex_);
PROCESS_SESSION_INT_VARIABLE(thread_data_.wait_timeout_);
break;
}
case SYS_VAR_DEBUG_SYNC: {
const bool is_global = false;
ret = process_session_debug_sync(val, is_global);
break;
}
case SYS_VAR_OB_GLOBAL_DEBUG_SYNC: {
const bool is_global = true;
ret = process_session_debug_sync(val, is_global);
break;
}
case SYS_VAR_OB_READ_CONSISTENCY: {
int64_t consistency = 0;
PROCESS_SESSION_INT_VARIABLE(consistency);
if (OB_SUCC(ret)) {
consistency_level_ = static_cast<ObConsistencyLevel>(consistency);
}
break;
}
case SYS_VAR_AUTO_INCREMENT_INCREMENT: {
uint64_t uint_val = 0;
OZ(val.get_uint64(uint_val), val);
OX(sys_vars_cache_.set_auto_increment_increment(uint_val, is_inc));
break;
}
case SYS_VAR_SQL_THROTTLE_CURRENT_PRIORITY: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_sql_throttle_current_priority(int_val, is_inc));
break;
}
case SYS_VAR_OB_LAST_SCHEMA_VERSION: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_last_schema_version(int_val, is_inc));
break;
}
case SYS_VAR_SQL_SELECT_LIMIT: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_sql_select_limit(int_val, is_inc));
break;
}
case SYS_VAR_AUTO_INCREMENT_OFFSET: {
uint64_t uint_val = 0;
OZ(val.get_uint64(uint_val), val);
OX(sys_vars_cache_.set_auto_increment_offset(uint_val, is_inc));
break;
}
case SYS_VAR_LAST_INSERT_ID: {
uint64_t uint_val = 0;
OZ(val.get_uint64(uint_val), val);
OX(sys_vars_cache_.set_last_insert_id(uint_val, is_inc));
break;
}
case SYS_VAR_BINLOG_ROW_IMAGE: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_binlog_row_image(int_val, is_inc));
break;
}
case SYS_VAR_FOREIGN_KEY_CHECKS: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_foreign_key_checks(int_val, is_inc));
break;
}
case SYS_VAR_TX_ISOLATION: {
ObString str_val;
int32_t isolation = ObTransIsolation::UNKNOWN;
OZ(val.get_string(str_val));
OX(isolation = ObTransIsolation::get_level(str_val));
OV(isolation != ObTransIsolation::UNKNOWN, OB_ERR_UNEXPECTED, isolation);
OX(sys_vars_cache_.set_tx_isolation(isolation, is_inc));
break;
}
case SYS_VAR_TX_READ_ONLY: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_tx_read_only(int_val != 0, is_inc));
break;
}
case SYS_VAR_OB_ENABLE_PLAN_CACHE: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_enable_plan_cache(int_val != 0, is_inc));
break;
}
case SYS_VAR_OPTIMIZER_USE_SQL_PLAN_BASELINES: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_optimizer_use_sql_plan_baselines(int_val != 0, is_inc));
break;
}
case SYS_VAR_OPTIMIZER_CAPTURE_SQL_PLAN_BASELINES: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_optimizer_capture_sql_plan_baselines(int_val != 0, is_inc));
break;
}
case SYS_VAR_IS_RESULT_ACCURATE: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_is_result_accurate(int_val != 0, is_inc));
break;
}
case SYS_VAR__OB_USE_PARALLEL_EXECUTION: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set__ob_use_parallel_execution(int_val != 0, is_inc));
break;
}
case SYS_VAR__OPTIMIZER_ADAPTIVE_CURSOR_SHARING: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set__optimizer_adaptive_cursor_sharing(int_val != 0, is_inc));
break;
}
case SYS_VAR_CHARACTER_SET_RESULTS: {
int64_t coll_int64 = 0;
if (val.is_null()) {
OX(sys_vars_cache_.set_character_set_results(CHARSET_INVALID, is_inc));
} else if (OB_FAIL(val.get_int(coll_int64))) {
LOG_WARN("fail to get int from value", K(val), K(ret));
} else if (OB_UNLIKELY(false == ObCharset::is_valid_collation(coll_int64))) {
// do not set error code.
LOG_WARN("invalid collation", K(coll_int64), K(val));
OX(sys_vars_cache_.set_character_set_results(CHARSET_INVALID, is_inc));
} else {
OX(sys_vars_cache_.set_character_set_results(
ObCharset::charset_type_by_coll(static_cast<ObCollationType>(coll_int64)), is_inc));
}
break;
}
case SYS_VAR_OB_ENABLE_SQL_AUDIT: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_enable_sql_audit(int_val != 0, is_inc));
break;
}
case SYS_VAR_NLS_LENGTH_SEMANTICS: {
ObString str_val;
ObLengthSemantics nls_length_semantics = LS_BYTE;
OZ(val.get_string(str_val));
OX(nls_length_semantics = get_length_semantics(str_val));
OV(nls_length_semantics != LS_INVALIED, OB_ERR_UNEXPECTED, nls_length_semantics);
OX(sys_vars_cache_.set_nls_length_semantics(nls_length_semantics, is_inc));
break;
}
case SYS_VAR_AUTOCOMMIT: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_autocommit(int_val != 0, is_inc));
break;
}
case SYS_VAR_OB_ENABLE_TRACE_LOG: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_enable_trace_log(int_val != 0, is_inc));
break;
}
case SYS_VAR_OB_ORG_CLUSTER_ID: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_org_cluster_id(int_val, is_inc));
break;
}
case SYS_VAR_OB_QUERY_TIMEOUT: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_query_timeout(int_val, is_inc));
break;
}
case SYS_VAR_OB_PL_BLOCK_TIMEOUT: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_pl_block_timeout(int_val, is_inc));
break;
}
case SYS_VAR_OB_TRX_TIMEOUT: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_trx_timeout(int_val, is_inc));
break;
}
case SYS_VAR_OB_TRX_IDLE_TIMEOUT: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_trx_idle_timeout(int_val, is_inc));
break;
}
case SYS_VAR_OB_TRX_LOCK_TIMEOUT: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_ob_trx_lock_timeout(int_val, is_inc));
break;
}
case SYS_VAR_COLLATION_CONNECTION: {
int64_t int_val = 0;
OZ(val.get_int(int_val), val);
OX(sys_vars_cache_.set_collation_connection(int_val, is_inc));
break;
}
case SYS_VAR_TIMESTAMP: {
// the unit of set timestamp operation is second,
// but we store it in microsecond, after a round operation.
if (val.get_number().is_zero()) {
sys_vars_cache_.set_timestamp(0, is_inc);
} else {
const ObObj* res_obj = NULL;
ObArenaAllocator allocator(common::ObModIds::OB_SQL_EXPR_CALC);
number::ObNumber value;
number::ObNumber unit;
if (OB_FAIL(unit.from(static_cast<int64_t>(USECS_PER_SEC * 10), allocator))) {
LOG_WARN("failed to get the number", K(ret));
} else if (OB_FAIL(val.get_number().mul(unit, value, allocator))) {
LOG_WARN("failed to get the result of timestamp to microsecond", K(ret));
} else {
ObObj param_obj;
param_obj.set_number(value);
ObCollationType cast_coll_type = static_cast<ObCollationType>(get_local_collation_connection());
// const ObDataTypeCastParams dtc_params(TZ_INFO(this), GET_NLS_FORMATS(this), get_nls_collation(),
// get_nls_collation_nation());;
ObDataTypeCastParams dtc_params = get_dtc_params();
ObCastCtx cast_ctx(&allocator,
&dtc_params,
0, /*number_int useless*/
CM_NONE,
cast_coll_type,
NULL /* time zone info */);
EXPR_CAST_OBJ_V2(ObIntType, param_obj, res_obj);
if (OB_SUCC(ret)) {
if (OB_ISNULL(res_obj)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("result obj is null");
} else {
sys_vars_cache_.set_timestamp((res_obj->get_int() + 5) / 10, is_inc);
}
} else {
LOG_WARN("failed to convert the number to int", K(ret));
}
}
}
break;
}
case SYS_VAR_NLS_DATE_FORMAT:
case SYS_VAR_NLS_TIMESTAMP_FORMAT:
case SYS_VAR_NLS_TIMESTAMP_TZ_FORMAT: {
ObString format;
if (OB_FAIL(val.get_string(format))) {
LOG_WARN("fail to get nls_date_format str value", K(ret), K(var));
} else {
int64_t nls_enum = ObNLSFormatEnum::NLS_DATE;
ObDTMode mode = DT_TYPE_DATETIME;
if (SYS_VAR_NLS_TIMESTAMP_FORMAT == var) {
mode |= DT_TYPE_ORACLE;
nls_enum = ObNLSFormatEnum::NLS_TIMESTAMP;
} else if (SYS_VAR_NLS_TIMESTAMP_TZ_FORMAT == var) {
mode |= DT_TYPE_ORACLE;
mode |= DT_TYPE_TIMEZONE;
nls_enum = ObNLSFormatEnum::NLS_TIMESTAMP_TZ;
}
ObSEArray<ObDFMElem, ObDFMUtil::COMMON_ELEMENT_NUMBER> dfm_elems;
ObBitSet<ObDFMFlag::MAX_FLAG_NUMBER> elem_flags;
// 1. parse and check semantic of format string
if (OB_FAIL(ObDFMUtil::parse_datetime_format_string(format, dfm_elems))) {
LOG_WARN("fail to parse oracle datetime format string", K(ret), K(format));
} else if (OB_FAIL(ObDFMUtil::check_semantic(dfm_elems, elem_flags, mode))) {
LOG_WARN("check semantic of format string failed", K(ret), K(format));
} else {
switch (nls_enum) {
case ObNLSFormatEnum::NLS_DATE:
sys_vars_cache_.set_nls_date_format(format, is_inc);
break;
case ObNLSFormatEnum::NLS_TIMESTAMP:
sys_vars_cache_.set_nls_timestamp_format(format, is_inc);
break;
case ObNLSFormatEnum::NLS_TIMESTAMP_TZ:
sys_vars_cache_.set_nls_timestamp_tz_format(format, is_inc);
break;
default:
break;
}
}
LOG_DEBUG("succ to set SYS_VAR_NLS_FORMAT", K(ret), K(var), K(nls_enum), K(format));
}
break;
}
case SYS_VAR_NLS_NCHAR_CHARACTERSET:
case SYS_VAR_NLS_CHARACTERSET: {
ObString str_val;
ObCharsetType charset = CHARSET_INVALID;
ObCollationType collation = CS_TYPE_INVALID;
OZ(val.get_string(str_val), val);
OX(charset = ObCharset::charset_type_by_name_oracle(str_val));
OX(collation = ObCharset::get_default_collation_oracle(charset));
OV(ObCharset::is_valid_charset(charset) && ObCharset::is_valid_collation(collation),
OB_ERR_INVALID_CHARACTER_STRING,
str_val,
charset,
collation);
if (var == SYS_VAR_NLS_CHARACTERSET) {
OX(sys_vars_cache_.set_nls_collation(collation, is_inc));
} else {
OX(sys_vars_cache_.set_nls_nation_collation(collation, is_inc));
}
break;
}
case SYS_VAR_OB_TRACE_INFO: {
ObString trace_info;
if (OB_FAIL(val.get_string(trace_info))) {
LOG_WARN("fail to get str value", K(ret), K(var));
} else {
sys_vars_cache_.set_ob_trace_info(trace_info, is_inc);
}
break;
}
default: {
// do nothing
}
}
return ret;
}
int ObBasicSessionInfo::process_session_variable_fast()
{
int ret = OB_SUCCESS;
int64_t store_idx = -1;
// SYS_VAR_OB_LOG_LEVEL
OZ(ObSysVarFactory::calc_sys_var_store_idx(SYS_VAR_OB_LOG_LEVEL, store_idx));
OV(ObSysVarFactory::is_valid_sys_var_store_idx(store_idx));
OZ(process_session_log_level(sys_vars_[store_idx]->get_value()));
// SYS_VAR_DEBUG_SYNC
OZ(ObSysVarFactory::calc_sys_var_store_idx(SYS_VAR_DEBUG_SYNC, store_idx));
OV(ObSysVarFactory::is_valid_sys_var_store_idx(store_idx));
OZ(process_session_debug_sync(sys_vars_[store_idx]->get_value(), false));
// SYS_VAR_OB_GLOBAL_DEBUG_SYNC
OZ(ObSysVarFactory::calc_sys_var_store_idx(SYS_VAR_OB_GLOBAL_DEBUG_SYNC, store_idx));
OV(ObSysVarFactory::is_valid_sys_var_store_idx(store_idx));
OZ(process_session_debug_sync(sys_vars_[store_idx]->get_value(), true));
// SYS_VAR_OB_READ_CONSISTENCY
OZ(ObSysVarFactory::calc_sys_var_store_idx(SYS_VAR_OB_READ_CONSISTENCY, store_idx));
OV(ObSysVarFactory::is_valid_sys_var_store_idx(store_idx));
if (OB_SUCC(ret)) {
const ObObj& val = sys_vars_[store_idx]->get_value();
int64_t consistency = 0;
PROCESS_SESSION_INT_VARIABLE(consistency);
OX(consistency_level_ = static_cast<ObConsistencyLevel>(consistency));
}
// SYS_VAR_WAIT_TIMEOUT
{
LockGuard lock_guard(thread_data_mutex_);
get_int64_sys_var(SYS_VAR_WAIT_TIMEOUT, thread_data_.wait_timeout_);
}
return ret;
}
int ObBasicSessionInfo::process_session_sql_mode_value(const ObObj& value, bool is_inc)
{
int ret = OB_SUCCESS;
ObSQLMode sql_mode = 0;
if (value.is_string_type()) {
const ObString& sql_mode_str = value.get_string();
if (OB_FAIL(ob_str_to_sql_mode(sql_mode_str, sql_mode))) {
LOG_WARN("failed to get sql mode", K(sql_mode_str), K(value), K(ret));
}
} else if (ObUInt64Type == value.get_type()) {
sql_mode = value.get_uint64();
} else if (ObIntType == value.get_type()) {
sql_mode = static_cast<ObSQLMode>(value.get_int());
} else {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid sql mode val type", K(value.get_type()), K(value), K(ret));
}
if (OB_FAIL(ret)) {
} else if (!is_sql_mode_supported(sql_mode)) {
ret = OB_NOT_SUPPORTED;
LOG_USER_ERROR(OB_NOT_SUPPORTED, "Value for sql_mode");
LOG_WARN("invalid sql mode val", K(value.get_type()), K(value), K(ret));
} else {
set_sql_mode(sql_mode, is_inc);
}
return ret;
}
int ObBasicSessionInfo::check_compatibility_mode() const
{
int ret = OB_SUCCESS;
ObCompatibilityMode mode = get_compatibility_mode();
if (ORACLE_MODE == mode && is_oracle_mode()) {
} else if (MYSQL_MODE == mode && is_mysql_mode()) {
} else {
// sometimes mode is OCEANBASE_MODE because mode is not assigned, we can accept that,
// but at least they must be consistent in oracle mode.
if (ORACLE_MODE == mode && !is_oracle_mode()) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("compatibility mode is not match", K(mode), K(is_oracle_mode()), K(lbt()), K(ret));
}
}
return ret;
}
int ObBasicSessionInfo::process_session_compatibility_mode_value(const ObObj& value, bool is_inc)
{
int ret = OB_SUCCESS;
ObCompatibilityMode comp_mode = ObCompatibilityMode::OCEANBASE_MODE;
if (value.is_string_type()) {
const ObString& comp_mode_str = value.get_string();
if (comp_mode_str.case_compare("ORACLE")) {
comp_mode = ObCompatibilityMode::ORACLE_MODE;
} else if (comp_mode_str.case_compare("MYSQL")) {
comp_mode = ObCompatibilityMode::MYSQL_MODE;
} else {
ret = OB_NOT_SUPPORTED;
LOG_WARN("not supported sql mode", K(ret), K(value), K(comp_mode_str));
}
} else if (ObUInt64Type == value.get_type()) {
comp_mode = static_cast<ObCompatibilityMode>(value.get_uint64());
} else if (ObIntType == value.get_type()) {
comp_mode = static_cast<ObCompatibilityMode>(value.get_int());
} else {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid sql mode val type", K(value.get_type()), K(value), K(ret));
}
if (OB_SUCC(ret)) {
set_compatibility_mode(comp_mode, is_inc);
LOG_DEBUG("set compatibility mode", K(ret), K(comp_mode), K(value), K(get_compatibility_mode()), K(lbt()));
}
return ret;
}
int ObBasicSessionInfo::process_session_time_zone_value(const ObObj& value, const bool check_timezone_valid)
{
int ret = OB_SUCCESS;
ObString str_val;
const bool is_oralce_mode = is_oracle_compatible();
if (OB_FAIL(value.get_string(str_val))) {
LOG_WARN("fail to get string value", K(value), K(ret));
} else if (OB_FAIL(set_time_zone(str_val, is_oralce_mode, check_timezone_valid))) {
LOG_WARN("failed to set time zone",
K(str_val),
K(is_oralce_mode),
"is_oracle_compatible",
is_oracle_compatible(),
K(ret));
}
return ret;
}
int ObBasicSessionInfo::process_session_overlap_time_value(const ObObj& value)
{
int ret = OB_SUCCESS;
if (OB_FAIL(tz_info_wrap_.set_error_on_overlap_time(value.get_bool()))) {
LOG_WARN("fail to set error on overlap time", K(value), K(ret));
}
return ret;
}
int ObBasicSessionInfo::process_session_log_level(const ObObj& val)
{
int ret = OB_SUCCESS;
int32_t valid_length = 0;
ObString val_str;
if (OB_SUCC(val.get_varchar(val_str))) {
if (0 == val_str.case_compare("disabled")) {
log_id_level_map_valid_ = false;
log_id_level_map_.reset_level();
} else if (OB_FAIL(OB_LOGGER.parse_set(val_str.ptr(), val_str.length(), valid_length, log_id_level_map_))) {
LOG_WARN("Failed to parse set log_level", K(ret), "log_level", val_str);
} else {
log_id_level_map_valid_ = true;
}
}
return ret;
}
int ObBasicSessionInfo::process_session_debug_sync(const ObObj& val, const bool is_global)
{
int ret = OB_SUCCESS;
if (OB_SYS_TENANT_ID == tenant_id_ && GCONF.is_debug_sync_enabled()) {
ObString debug_sync;
if (OB_FAIL(val.get_varchar(debug_sync))) {
LOG_WARN("varchar expected", K(ret));
} else {
if (!debug_sync.empty()) {
if (OB_FAIL(GDS.add_debug_sync(debug_sync, is_global, debug_sync_actions_))) {
LOG_WARN("set debug sync string failed", K(debug_sync), K(ret));
}
}
}
}
return ret;
}
int ObBasicSessionInfo::get_int64_sys_var(const ObSysVarClassType sys_var_id, int64_t& int64_val) const
{
int ret = OB_SUCCESS;
ObBasicSysVar* val = NULL;
if (OB_FAIL(inner_get_sys_var(sys_var_id, val))) {
LOG_WARN("fail to inner get sys var", K(ret), K(sys_var_id));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret), K(sys_var_id));
} else {
int64_t int_val = 0;
if (OB_FAIL(val->get_value().get_int(int_val))) {
LOG_WARN("fail to get int from value", K(*val), K(ret));
} else {
int64_val = int_val;
}
}
return ret;
}
int ObBasicSessionInfo::get_uint64_sys_var(const ObSysVarClassType sys_var_id, uint64_t& uint64_val) const
{
int ret = OB_SUCCESS;
ObBasicSysVar* val = NULL;
if (OB_FAIL(inner_get_sys_var(sys_var_id, val))) {
LOG_WARN("fail to inner get sys var", K(ret), K(sys_var_id));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret), K(sys_var_id));
} else {
uint64_t uint_val = 0;
if (OB_FAIL(val->get_value().get_uint64(uint_val))) {
LOG_ERROR("fail to get uint64 from value", K(*val), K(ret));
} else {
uint64_val = uint_val;
}
}
return ret;
}
int ObBasicSessionInfo::get_bool_sys_var(const ObSysVarClassType sys_var_id, bool& bool_val) const
{
int ret = OB_SUCCESS;
ObBasicSysVar* val = NULL;
if (OB_FAIL(inner_get_sys_var(sys_var_id, val))) {
LOG_WARN("fail to inner get sys var", K(ret), K(sys_var_id));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret), K(sys_var_id));
} else {
int64_t int_val = 0;
if (OB_SUCCESS != (ret = val->get_value().get_int(int_val))) {
LOG_ERROR("fail to get int from value", K(*val), K(ret));
} else {
bool_val = (0 != int_val);
}
}
return ret;
}
int ObBasicSessionInfo::get_charset_sys_var(const ObSysVarClassType sys_var_id, ObCharsetType& cs_type) const
{
int ret = OB_SUCCESS;
ObBasicSysVar* val = NULL;
if (OB_FAIL(inner_get_sys_var(sys_var_id, val))) {
LOG_WARN("fail to inner get sys var", K(ret), K(sys_var_id));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret), K(sys_var_id));
} else {
int64_t coll_int64 = 0;
if (val->get_value().is_null()) {
cs_type = CHARSET_INVALID;
} else if (OB_FAIL(val->get_value().get_int(coll_int64))) {
LOG_ERROR("fail to get int from value", K(*val), K(ret));
} else if (OB_UNLIKELY(false == ObCharset::is_valid_collation(coll_int64))) {
LOG_ERROR("invalid collation", K(sys_var_id), K(coll_int64), K(*val));
} else {
cs_type = ObCharset::charset_type_by_coll(static_cast<ObCollationType>(coll_int64));
}
}
return ret;
}
int ObBasicSessionInfo::get_collation_sys_var(ObSysVarClassType sys_var_id, ObCollationType& coll_type) const
{
int ret = OB_SUCCESS;
ObBasicSysVar* val = NULL;
if (OB_FAIL(inner_get_sys_var(sys_var_id, val))) {
LOG_WARN("fail to inner get sys var", K(ret), K(sys_var_id));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get sys var, but sys var is NULL", K(ret));
} else {
int64_t coll_int64 = 0;
if (OB_FAIL(val->get_value().get_int(coll_int64))) {
LOG_ERROR("fail to get int from value", K(ret), K(*val));
} else if (OB_UNLIKELY(false == ObCharset::is_valid_collation(coll_int64))) {
LOG_ERROR("invalid collation", K(sys_var_id), K(coll_int64), K(*val));
} else {
coll_type = static_cast<ObCollationType>(coll_int64);
}
}
return ret;
}
int ObBasicSessionInfo::get_string_sys_var(ObSysVarClassType sys_var_id, ObString& str) const
{
int ret = OB_SUCCESS;
ObBasicSysVar* val = NULL;
if (OB_FAIL(inner_get_sys_var(sys_var_id, val))) {
LOG_WARN("fail to inner get sys var", K(ret), K(sys_var_id));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("succ to inner get says var, but sys var is NULL", K(ret));
} else {
if (OB_FAIL(val->get_value().get_string(str))) {
LOG_ERROR("fail to get int from value", K(ret), K(*val));
}
}
return ret;
}
int ObBasicSessionInfo::if_aggr_pushdown_allowed(bool& aggr_pushdown_allowed) const
{
return get_bool_sys_var(SYS_VAR_OB_ENABLE_AGGREGATION_PUSHDOWN, aggr_pushdown_allowed);
}
int ObBasicSessionInfo::is_use_trace_log(bool& use_trace_log) const
{
use_trace_log = sys_vars_cache_.get_ob_enable_trace_log();
return OB_SUCCESS;
}
int ObBasicSessionInfo::is_use_transmission_checksum(bool& use_transmission_checksum) const
{
return get_bool_sys_var(SYS_VAR_OB_ENABLE_TRANSMISSION_CHECKSUM, use_transmission_checksum);
}
int ObBasicSessionInfo::get_name_case_mode(ObNameCaseMode& case_mode) const
{
int ret = OB_SUCCESS;
int64_t int64_val = -1;
if (OB_FAIL(get_sys_variable(SYS_VAR_LOWER_CASE_TABLE_NAMES, int64_val))) {
LOG_WARN("failed to load sys param", "var_name", OB_SV_LOWER_CASE_TABLE_NAMES, K(ret));
} else {
int32_t value = static_cast<int32_t>(int64_val);
if (value <= OB_NAME_CASE_INVALID || value >= OB_NAME_CASE_MAX) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("invalid value", "var_name", OB_SV_LOWER_CASE_TABLE_NAMES, K(value), K(ret));
} else {
case_mode = static_cast<ObNameCaseMode>(value);
}
}
return ret;
}
int ObBasicSessionInfo::get_init_connect(ObString& str) const
{
return get_string_sys_var(SYS_VAR_INIT_CONNECT, str);
}
int ObBasicSessionInfo::is_transformation_enabled(bool& transformation_enabled) const
{
return get_bool_sys_var(SYS_VAR_OB_ENABLE_TRANSFORMATION, transformation_enabled);
}
int ObBasicSessionInfo::is_select_index_enabled(bool& select_index_enabled) const
{
return get_bool_sys_var(SYS_VAR_OB_ENABLE_INDEX_DIRECT_SELECT, select_index_enabled);
}
int ObBasicSessionInfo::is_create_table_strict_mode(bool& strict_mode) const
{
return get_bool_sys_var(SYS_VAR_OB_CREATE_TABLE_STRICT_MODE, strict_mode);
}
void ObBasicSessionInfo::set_autocommit(bool autocommit)
{
sys_vars_cache_.set_autocommit(autocommit, true);
}
int ObBasicSessionInfo::get_autocommit(bool& autocommit) const
{
autocommit = sys_vars_cache_.get_autocommit();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_explicit_defaults_for_timestamp(bool& explicit_defaults_for_timestamp) const
{
return get_bool_sys_var(SYS_VAR_EXPLICIT_DEFAULTS_FOR_TIMESTAMP, explicit_defaults_for_timestamp);
}
int ObBasicSessionInfo::get_sql_auto_is_null(bool& sql_auto_is_null) const
{
return get_bool_sys_var(SYS_VAR_SQL_AUTO_IS_NULL, sql_auto_is_null);
}
int ObBasicSessionInfo::get_is_result_accurate(bool& is_result_accurate) const
{
is_result_accurate = sys_vars_cache_.get_is_result_accurate();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_div_precision_increment(int64_t& div_precision_increment) const
{
int ret = get_int64_sys_var(SYS_VAR_DIV_PRECISION_INCREMENT, div_precision_increment);
return ret;
}
int ObBasicSessionInfo::get_tx_timeout(int64_t& tx_timeout) const
{
tx_timeout = sys_vars_cache_.get_ob_trx_timeout();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_query_timeout(int64_t& query_timeout) const
{
query_timeout = sys_vars_cache_.get_ob_query_timeout();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_sql_throttle_current_priority(int64_t& sql_throttle_current_priority)
{
sql_throttle_current_priority = sys_vars_cache_.get_sql_throttle_current_priority();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_ob_last_schema_version(int64_t& ob_last_schema_version)
{
ob_last_schema_version = sys_vars_cache_.get_ob_last_schema_version();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_pl_block_timeout(int64_t& pl_block_timeout) const
{
pl_block_timeout = sys_vars_cache_.get_ob_pl_block_timeout();
return OB_SUCCESS;
}
int64_t ObBasicSessionInfo::get_trx_lock_timeout() const
{
return sys_vars_cache_.get_ob_trx_lock_timeout();
}
int ObBasicSessionInfo::get_binlog_row_image(int64_t& binlog_row_image) const
{
binlog_row_image = sys_vars_cache_.get_binlog_row_image();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_ob_read_consistency(int64_t& ob_read_consistency) const
{
return get_int64_sys_var(SYS_VAR_OB_READ_CONSISTENCY, ob_read_consistency);
}
int ObBasicSessionInfo::get_sql_select_limit(int64_t& sql_select_limit) const
{
sql_select_limit = sys_vars_cache_.get_sql_select_limit();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_ob_stmt_parallel_degree(int64_t& ob_stmt_parallel_degree) const
{
return get_int64_sys_var(SYS_VAR_OB_STMT_PARALLEL_DEGREE, ob_stmt_parallel_degree);
}
int ObBasicSessionInfo::use_parallel_execution(bool& v) const
{
v = sys_vars_cache_.get__ob_use_parallel_execution();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_ob_stmt_parallel_degree_min_max(
int64_t& min_ob_stmt_parallel_degree, int64_t& max_ob_stmt_parallel_degree) const
{
int ret = OB_SUCCESS;
ObBasicSysVar* val = NULL;
if (OB_FAIL(inner_get_sys_var(SYS_VAR_OB_STMT_PARALLEL_DEGREE, val))) {
LOG_WARN("fail to inner get sys var", K(ret));
} else if (OB_ISNULL(val)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("succ to inner get sys var, but sys var is NULL", K(ret));
} else if (OB_FAIL(val->get_min_val().get_int(min_ob_stmt_parallel_degree))) {
LOG_WARN("fail to get int from value", K(*val), K(ret));
} else if (OB_FAIL(val->get_max_val().get_int(max_ob_stmt_parallel_degree))) {
LOG_WARN("fail to get int from value", K(*val), K(ret));
}
return ret;
}
int ObBasicSessionInfo::get_group_concat_max_len(uint64_t& group_concat_max_len) const
{
return get_uint64_sys_var(SYS_VAR_GROUP_CONCAT_MAX_LEN, group_concat_max_len);
}
int ObBasicSessionInfo::get_ob_interm_result_mem_limit(int64_t& ob_interm_result_mem_limit) const
{
return get_int64_sys_var(SYS_VAR_OB_INTERM_RESULT_MEM_LIMIT, ob_interm_result_mem_limit);
}
int ObBasicSessionInfo::get_ob_org_cluster_id(int64_t& ob_org_cluster_id) const
{
ob_org_cluster_id = sys_vars_cache_.get_ob_org_cluster_id();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_max_allowed_packet(int64_t& max_allowed_pkt) const
{
return get_int64_sys_var(SYS_VAR_MAX_ALLOWED_PACKET, max_allowed_pkt);
}
int ObBasicSessionInfo::get_net_buffer_length(int64_t& net_buffer_len) const
{
return get_int64_sys_var(SYS_VAR_NET_BUFFER_LENGTH, net_buffer_len);
}
////////////////////////////////////////////////////////////////
int ObBasicSessionInfo::replace_user_variables(const ObSessionValMap& user_var_map)
{
int ret = OB_SUCCESS;
if (user_var_map.size() > 0) {
const sql::ObSessionValMap::VarNameValMap& new_map = user_var_map.get_val_map();
for (sql::ObSessionValMap::VarNameValMap::const_iterator iter = new_map.begin();
OB_SUCC(ret) && iter != new_map.end();
iter++) {
const common::ObString& key = iter->first;
const sql::ObSessionVariable& value = iter->second;
if (OB_FAIL(replace_user_variable(key, value))) {
LOG_WARN("fail to replace user var", K(ret), K(key), K(value));
}
}
}
return ret;
}
int ObBasicSessionInfo::replace_user_variable(const ObString& var, const ObSessionVariable& val)
{
int ret = OB_SUCCESS;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid var name", K(var), K(ret));
} else if (OB_FAIL(user_var_val_map_.set_refactored(var, val))) {
LOG_ERROR("fail to add variable", K(var), K(ret));
} else {
if (is_track_session_info()) {
if (OB_FAIL(track_user_var(var))) {
LOG_WARN("fail to track user var", K(var), K(ret));
}
}
if (OB_SUCC(ret)) {
variables_last_modify_time_ = ObTimeUtility::current_time();
}
}
return ret;
}
int ObBasicSessionInfo::remove_user_variable(const ObString& var)
{
int ret = OB_SUCCESS;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(ret));
} else if (OB_SUCCESS != user_var_val_map_.erase_refactored(var)) {
ret = OB_ERR_USER_VARIABLE_UNKNOWN;
LOG_WARN("unknown variable", K(var), K(ret));
} else {
variables_last_modify_time_ = ObTimeUtility::current_time();
}
return ret;
}
int ObBasicSessionInfo::get_user_variable(const ObString& var, ObSessionVariable& val) const
{
int ret = OB_SUCCESS;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(ret));
} else if (OB_SUCCESS != user_var_val_map_.get_refactored(var, val)) {
ret = OB_ERR_USER_VARIABLE_UNKNOWN;
LOG_WARN("unknown user variable", K(var), K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::get_user_variable_value(const ObString& var, common::ObObj& val) const
{
int ret = OB_SUCCESS;
ObSessionVariable sess_var;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(ret));
} else if (OB_SUCCESS != user_var_val_map_.get_refactored(var, sess_var)) {
ret = OB_ERR_USER_VARIABLE_UNKNOWN;
LOG_WARN("unknown user variable", K(var), K(ret));
} else {
val = sess_var.value_;
}
return ret;
}
int ObBasicSessionInfo::get_user_variable_meta(const ObString& var, ObObjMeta& meta) const
{
int ret = OB_SUCCESS;
ObSessionVariable val;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(ret));
} else if (OB_SUCCESS != user_var_val_map_.get_refactored(var, val)) {
ret = OB_ERR_USER_VARIABLE_UNKNOWN;
LOG_WARN("unknown user variable", K(var), K(ret));
} else {
meta = val.meta_;
}
return ret;
}
bool ObBasicSessionInfo::user_variable_exists(const ObString& var) const
{
ObSessionVariable val;
bool exist = false;
int ret = OB_SUCCESS;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(ret));
} else {
exist = (OB_SUCCESS == user_var_val_map_.get_refactored(var, val));
}
return exist;
}
const ObSessionVariable* ObBasicSessionInfo::get_user_variable(const common::ObString& var) const
{
const ObSessionVariable* sess_var = NULL;
int ret = OB_SUCCESS;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(ret));
} else {
sess_var = user_var_val_map_.get(var);
}
return sess_var;
}
const common::ObObj* ObBasicSessionInfo::get_user_variable_value(const ObString& var) const
{
const ObObj* val_obj = NULL;
const ObSessionVariable* sess_var = NULL;
int ret = OB_SUCCESS;
if (var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid variable name", K(var), K(ret));
} else if (NULL != (sess_var = user_var_val_map_.get(var))) {
val_obj = &(sess_var->value_);
} else {
} // just return NULL
return val_obj;
}
////////////////////////////////////////////////////////////////
int64_t ObBasicSessionInfo::to_string(char* buf, const int64_t buf_len) const
{
int64_t pos = 0;
J_KV(N_TENANT,
get_tenant_name(),
N_EFFECTIVE_TENANT,
get_effective_tenant_name(),
N_DATABASE,
get_database_name(),
N_USER,
(lib::is_oracle_mode() ? get_user_name() : get_user_at_host()),
"consistency_level",
consistency_level_,
"consistency_type",
trans_consistency_type_,
"safe_weak_snapshot_version",
safe_weak_read_snapshot_,
"weak_read_snapshot_source",
weak_read_snapshot_source_,
"weak_read_snapshot_source_str",
source_to_string(weak_read_snapshot_source_));
return pos;
}
int ObBasicSessionInfo::calc_need_serialize_vars(
ObIArray<ObSysVarClassType>& sys_var_ids, ObIArray<ObString>& user_var_names, int64_t ser_version) const
{
int ret = OB_SUCCESS;
sys_var_ids.reset();
user_var_names.reset();
if (ser_version == CUR_SER_VERSION) {
if (OB_FAIL(sys_var_ids.assign(sys_var_inc_info_.get_all_sys_var_ids()))) {
LOG_WARN("fail to assign ser_sys_var_ids", K(ret));
}
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < ObSysVariables::get_all_sys_var_count(); ++i) {
bool can_serialize = true;
if (exec_min_cluster_version_ < CLUSTER_VERSION_2230) {
can_serialize = true;
} else {
can_serialize = !(is_mysql_mode() && (ObSysVariables::get_flags(i) & ObSysVarFlag::ORACLE_ONLY));
}
if (((ObSysVariables::get_flags(i) & ObSysVarFlag::NEED_SERIALIZE) ||
(ObSysVariables::get_flags(i) & ObSysVarFlag::QUERY_SENSITIVE)) &&
can_serialize) {
if (OB_FAIL(sys_var_ids.push_back(ObSysVariables::get_sys_var_id(i)))) {
LOG_WARN("fail to push back sys var id", K(i), K(ObSysVariables::get_sys_var_id(i)), K(sys_var_ids), K(ret));
}
}
}
}
CK(OB_NOT_NULL(cur_phy_plan_));
if (OB_SUCC(ret)) {
// process user variables and system variables that need to be serialized for current query.
const ObIArray<ObVarInfo>& extra_serialize_vars = cur_phy_plan_->get_vars();
for (int64_t i = 0; OB_SUCC(ret) && i < extra_serialize_vars.count(); ++i) {
const ObVarInfo& var_info = extra_serialize_vars.at(i);
if (USER_VAR == var_info.type_) {
if (OB_FAIL(user_var_names.push_back(var_info.name_))) {
LOG_WARN("fail to push user var name", K(var_info), K(user_var_names), K(ret));
}
} else if (SYS_VAR == var_info.type_) {
ObSysVarClassType sys_var_id = ObSysVarFactory::find_sys_var_id_by_name(var_info.name_);
if (SYS_VAR_INVALID == sys_var_id) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("invalid sys var id", K(sys_var_id), K(var_info), K(ret));
} else {
bool sys_var_exist = false;
for (int64_t j = 0; OB_SUCC(ret) && !sys_var_exist && j < sys_var_ids.count(); ++j) {
if (sys_var_id == sys_var_ids.at(j)) {
sys_var_exist = true;
}
}
if (OB_SUCCESS == ret && !sys_var_exist) {
if (OB_FAIL(sys_var_ids.push_back(sys_var_id))) {
LOG_WARN("fail to push back sys var id", K(sys_var_id), K(var_info), K(sys_var_ids), K(ret));
}
}
}
} else {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("invalid var info type", K(var_info.type_), K(var_info), K(ret));
}
}
}
return ret;
}
OB_SERIALIZE_MEMBER(ObBasicSessionInfo::TableStmtType, table_id_, stmt_type_);
OB_DEF_SERIALIZE(ObBasicSessionInfo::SysVarsCacheData)
{
int ret = OB_SUCCESS;
LST_DO_CODE(OB_UNIS_ENCODE,
autocommit_,
ob_enable_trace_log_,
ob_org_cluster_id_,
ob_query_timeout_,
ob_trx_timeout_,
collation_connection_,
sql_mode_,
ob_trx_idle_timeout_,
nls_collation_,
nls_nation_collation_,
ob_enable_sql_audit_,
nls_length_semantics_,
nls_formats_[NLS_DATE],
nls_formats_[NLS_TIMESTAMP],
nls_formats_[NLS_TIMESTAMP_TZ],
ob_trx_lock_timeout_,
ob_trace_info_);
return ret;
}
OB_DEF_DESERIALIZE(ObBasicSessionInfo::SysVarsCacheData)
{
int ret = OB_SUCCESS;
LST_DO_CODE(OB_UNIS_DECODE,
autocommit_,
ob_enable_trace_log_,
ob_org_cluster_id_,
ob_query_timeout_,
ob_trx_timeout_,
collation_connection_,
sql_mode_,
ob_trx_idle_timeout_,
nls_collation_,
nls_nation_collation_,
ob_enable_sql_audit_,
nls_length_semantics_,
nls_formats_[NLS_DATE],
nls_formats_[NLS_TIMESTAMP],
nls_formats_[NLS_TIMESTAMP_TZ],
ob_trx_lock_timeout_,
ob_trace_info_);
set_nls_date_format(nls_formats_[NLS_DATE]);
set_nls_timestamp_format(nls_formats_[NLS_TIMESTAMP]);
set_nls_timestamp_tz_format(nls_formats_[NLS_TIMESTAMP_TZ]);
set_ob_trace_info(ob_trace_info_);
return ret;
}
OB_DEF_SERIALIZE_SIZE(ObBasicSessionInfo::SysVarsCacheData)
{
int64_t len = 0;
LST_DO_CODE(OB_UNIS_ADD_LEN,
autocommit_,
ob_enable_trace_log_,
ob_org_cluster_id_,
ob_query_timeout_,
ob_trx_timeout_,
collation_connection_,
sql_mode_,
ob_trx_idle_timeout_,
nls_collation_,
nls_nation_collation_,
ob_enable_sql_audit_,
nls_length_semantics_,
nls_formats_[NLS_DATE],
nls_formats_[NLS_TIMESTAMP],
nls_formats_[NLS_TIMESTAMP_TZ],
ob_trx_lock_timeout_,
ob_trace_info_);
return len;
}
int64_t ObBasicSessionInfo::get_ser_version(uint64_t tenant_id, uint64_t eff_tenant_id) const
{
return (GET_UNIS_CLUSTER_VERSION() < CLUSTER_VERSION_2250 || tenant_id == OB_SYS_TENANT_ID ||
eff_tenant_id == OB_SYS_TENANT_ID)
? PRE_SER_VERSION
: CUR_SER_VERSION;
}
OB_DEF_SERIALIZE(ObBasicSessionInfo)
{
int ret = OB_SUCCESS;
int64_t ser_version = get_ser_version(tenant_id_, effective_tenant_id_);
ObTimeZoneInfo tmp_tz_info; // for compatibility with old version
bool in_transaction = trans_flags_.is_in_transaction();
// To be compatible with old version which store sql_mode and compatibility mode in ObSQLModeManager;
int64_t compatibility_mode_index = 0;
if (OB_FAIL(compatibility_mode2index(get_compatibility_mode(), compatibility_mode_index))) {
LOG_WARN("convert compatibility mode to index failed", K(ret));
}
LST_DO_CODE(OB_UNIS_ENCODE,
in_transaction,
trans_desc_,
consistency_level_,
compatibility_mode_index,
tmp_tz_info,
// NOTE: rpc_tenant_id may cause compatability problem,
// But only in diagnose tenant, so keep the stupid hack as it is.
tenant_id_ | (rpc_tenant_id_ << 32),
effective_tenant_id_,
is_changed_to_temp_tenant_,
user_id_,
is_master_session() ? sessid_ : master_sessid_,
capability_.capability_,
thread_data_.database_name_);
// serialize user variables and system variables.
ObSEArray<ObSysVarClassType, 128> sys_var_ids;
ObSEArray<ObString, 32> user_var_names;
if (OB_FAIL(ret)) {
} else if (OB_FAIL(calc_need_serialize_vars(sys_var_ids, user_var_names, ser_version))) {
LOG_WARN("fail to calc need serialize vars", K(ret));
} else {
ObSEArray<std::pair<ObString, ObSessionVariable>, 32> actual_ser_user_vars;
ObSessionVariable user_var_val;
for (int64_t i = 0; OB_SUCC(ret) && i < user_var_names.count(); ++i) {
user_var_val.reset();
const ObString& user_var_name = user_var_names.at(i);
ret = user_var_val_map_.get_refactored(user_var_name, user_var_val);
if (OB_SUCCESS != ret && OB_HASH_NOT_EXIST != ret) {
LOG_WARN("fail to get user var from session user var map",
K(i),
K(user_var_name),
K(user_var_val_map_.size()),
K(ret));
} else {
if (OB_SUCCESS == ret && OB_FAIL(actual_ser_user_vars.push_back(std::make_pair(user_var_name, user_var_val)))) {
LOG_WARN("fail to push back pair(user_var_name, user_var_val)",
K(buf_len),
K(pos),
K(user_var_name),
K(user_var_val),
K(ret));
} else {
ret = OB_SUCCESS;
}
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(serialization::encode(buf, buf_len, pos, actual_ser_user_vars.count()))) {
LOG_WARN("fail to serialize user var count", K(ret), K(buf_len), K(pos), K(actual_ser_user_vars.count()));
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < actual_ser_user_vars.count(); ++i) {
const ObString& user_var_name = actual_ser_user_vars.at(i).first;
const ObSessionVariable& user_var_val = actual_ser_user_vars.at(i).second;
if (OB_FAIL(serialization::encode(buf, buf_len, pos, user_var_name))) {
LOG_WARN("fail to serialize user var name", K(buf_len), K(pos), K(user_var_name), K(ret));
} else if (OB_FAIL(serialization::encode(buf, buf_len, pos, user_var_val.meta_))) {
LOG_WARN("fail to serialize user var val meta", K(buf_len), K(pos), K(user_var_val.meta_), K(ret));
} else if (OB_FAIL(serialization::encode(buf, buf_len, pos, user_var_val.value_))) {
LOG_WARN("fail to serialize user var val value", K(buf_len), K(pos), K(user_var_val.value_), K(ret));
} else {
}
}
}
}
}
if (OB_SUCC(ret)) {
if (ser_version == CUR_SER_VERSION) {
OB_UNIS_ENCODE(sys_var_base_version_);
OB_UNIS_ENCODE(sys_var_inc_info_);
}
if (OB_FAIL(serialization::encode(buf, buf_len, pos, sys_var_ids.count()))) {
LOG_WARN("fail to serialize sys var count", K(buf_len), K(pos), K(sys_var_ids.count()), K(ret));
}
for (int64_t i = 0; OB_SUCC(ret) && i < sys_var_ids.count(); ++i) {
int64_t sys_var_idx = -1;
if (OB_FAIL(ObSysVarFactory::calc_sys_var_store_idx(sys_var_ids.at(i), sys_var_idx))) {
LOG_WARN("fail to calc sys var store idx", K(i), K(sys_var_idx), K(sys_var_ids.at(i)), K(ret));
} else if (sys_var_idx < 0 || get_sys_var_count() <= sys_var_idx) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("sys var idx is invalid", K(sys_var_idx), K(get_sys_var_count()), K(ret));
} else if (OB_ISNULL(sys_vars_[sys_var_idx])) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("sys var is NULL", K(ret), K(sys_var_idx), K(get_sys_var_count()));
} else {
int16_t sys_var_id = static_cast<int16_t>(sys_vars_[sys_var_idx]->get_type());
if (OB_FAIL(serialization::encode(buf, buf_len, pos, sys_var_id))) {
LOG_ERROR("fail to serialize sys var id", K(buf_len), K(pos), K(sys_var_id), K(ret));
} else if (OB_FAIL(sys_vars_[sys_var_idx]->serialize(buf, buf_len, pos))) {
LOG_ERROR("fail to serialize sys var",
K(buf_len),
K(pos),
K(i),
K(sys_var_idx),
K(*sys_vars_[sys_var_idx]),
K(ret));
}
}
}
}
if (OB_FAIL(ret)) {
LOG_WARN("fail to encode session info", K(ret));
} else {
bool tx_read_only = get_tx_read_only();
if (OB_FAIL(serialization::encode_bool(buf, buf_len, pos, tx_read_only))) {
LOG_WARN("fail to encode tx_read_only", K(ret));
}
}
// for compatibility with old version
bool unused_literal_query = false;
int64_t unused_inner_safe_weak_read_snapshot = safe_weak_read_snapshot_;
bool need_serial_exec = trans_flags_.need_serial_exec();
LST_DO_CODE(OB_UNIS_ENCODE,
sys_vars_cache_.inc_data_,
trans_consistency_type_,
safe_weak_read_snapshot_,
unused_inner_safe_weak_read_snapshot,
unused_literal_query,
tz_info_wrap_,
app_trace_id_,
proxy_capability_.capability_,
client_mode_,
proxy_sessid_,
nested_count_,
thread_data_.user_name_,
next_tx_isolation_,
read_snapshot_version_,
check_sys_variable_,
weak_read_snapshot_source_,
database_id_,
thread_data_.user_at_host_name_,
thread_data_.user_at_client_ip_,
current_execution_id_,
total_stmt_tables_,
cur_stmt_tables_,
is_foreign_key_cascade_,
sys_var_in_pc_str_,
is_foreign_key_check_exist_,
need_serial_exec);
return ret;
}
OB_DEF_DESERIALIZE(ObBasicSessionInfo)
{
int ret = OB_SUCCESS;
ObTimeZoneInfo tmp_tz_info; // for compatibility with old version
bool in_transaction = false;
int64_t compatibility_mode_index = 0;
is_deserialized_ = true;
LST_DO_CODE(OB_UNIS_DECODE,
in_transaction,
trans_desc_,
consistency_level_,
compatibility_mode_index,
tmp_tz_info,
tenant_id_,
effective_tenant_id_,
is_changed_to_temp_tenant_,
user_id_,
master_sessid_,
capability_.capability_,
thread_data_.database_name_);
int64_t ser_version = get_ser_version(tenant_id_, effective_tenant_id_);
trans_flags_.set_is_in_transaction(in_transaction);
rpc_tenant_id_ = (tenant_id_ >> 32);
tenant_id_ = (tenant_id_ << 32 >> 32);
// deserialize user variables and system variables.
int64_t deserialize_user_var_count = 0;
int64_t deserialize_sys_var_count = 0;
if (OB_FAIL(ret)) {
} else if (OB_FAIL(serialization::decode(buf, data_len, pos, deserialize_user_var_count))) {
LOG_WARN("fail to deserialize user var count", K(data_len), K(pos), K(ret));
} else {
ObSessionVariable user_var_val;
for (int64_t i = 0; OB_SUCC(ret) && i < deserialize_user_var_count; ++i) {
ObString user_var_name;
user_var_val.reset();
if (OB_FAIL(serialization::decode(buf, data_len, pos, user_var_name))) {
LOG_WARN("fail to deserialize user var name", K(i), K(data_len), K(pos), K(ret));
} else if (OB_FAIL(serialization::decode(buf, data_len, pos, user_var_val.meta_))) {
LOG_WARN("fail to deserialize user var val meta", K(i), K(data_len), K(pos), K(ret));
} else if (OB_FAIL(serialization::decode(buf, data_len, pos, user_var_val.value_))) {
LOG_WARN("fail to deserialize user var val value", K(i), K(data_len), K(pos), K(ret));
} else {
if (OB_FAIL(user_var_val_map_.set_refactored(user_var_name, user_var_val))) {
LOG_WARN("Insert value into map failed", K(user_var_name), K(user_var_val), K(ret));
} else {
ret = OB_SUCCESS;
}
}
}
}
if (ser_version == CUR_SER_VERSION) {
OB_UNIS_DECODE(des_sys_var_base_version_);
OB_UNIS_DECODE(sys_var_inc_info_);
OV(des_sys_var_base_version_ > OB_INVALID_VERSION);
if (des_sys_var_base_version_ == sys_var_base_version_) {
// skip.
} else if (des_sys_var_base_version_ > 0) {
ObSchemaGetterGuard schema_guard;
OZ(GCTX.schema_service_->get_tenant_schema_guard(effective_tenant_id_, schema_guard, des_sys_var_base_version_));
OZ(load_all_sys_vars(schema_guard));
if (OB_FAIL(ret) && is_schema_error(ret)) {
ret = OB_ERR_WAIT_REMOTE_SCHEMA_REFRESH;
}
} else {
OZ(load_all_sys_vars_default());
}
}
if (OB_SUCC(ret)) {
ObTZMapWrap tz_map_wrap;
if (OB_FAIL(OTTZ_MGR.get_tenant_tz(tenant_id_, tz_map_wrap))) {
LOG_WARN("get tenant timezone map failed", K(ret));
} else {
tz_info_wrap_.set_tz_info_map(tz_map_wrap.get_tz_map());
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(serialization::decode(buf, data_len, pos, deserialize_sys_var_count))) {
LOG_WARN("fail to deserialize sys var count", K(data_len), K(pos), K(ret));
} else {
const bool check_timezone_valid = false;
for (int64_t i = 0; OB_SUCC(ret) && i < deserialize_sys_var_count; ++i) {
ObObj tmp_val;
ObBasicSysVar* sys_var = NULL;
ObSysVarClassType sys_var_id = SYS_VAR_INVALID;
int16_t tmp_sys_var_id = -1;
int64_t store_idx = -1;
if (OB_FAIL(serialization::decode(buf, data_len, pos, tmp_sys_var_id))) {
LOG_WARN("fail to deserialize sys var id", K(data_len), K(pos), K(ret));
} else if (FALSE_IT(sys_var_id = static_cast<ObSysVarClassType>(tmp_sys_var_id))) {
} else if (ser_version == PRE_SER_VERSION && OB_FAIL(sys_var_inc_info_.add_sys_var_id(sys_var_id))) {
LOG_WARN("fail to add sys var id", K(sys_var_id), K(ret));
} else if (OB_FAIL(ObSysVarFactory::calc_sys_var_store_idx(sys_var_id, store_idx))) {
if (OB_SYS_VARS_MAYBE_DIFF_VERSION == ret) {
// observer of higher version serialized some system variables which are
// not supported in current version, just skip this data and continue.
ret = OB_SUCCESS;
int64_t sys_var_version = 0;
int64_t sys_var_len = 0;
OB_UNIS_DECODEx(sys_var_version);
OB_UNIS_DECODEx(sys_var_len);
if (OB_SUCC(ret)) {
pos += sys_var_len;
LOG_WARN("invalid sys var id, maybe version is different, skip it", K(sys_var_id));
}
} else {
LOG_ERROR("invalid sys var id", K(sys_var_id), K(ret));
}
} else if (OB_FAIL(create_sys_var(sys_var_id, store_idx, sys_var))) {
LOG_WARN("fail to create sys var", K(sys_var_id), K(ret));
} else if (OB_ISNULL(sys_var)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("create sys var is NULL", K(ret));
} else if (OB_FAIL(sys_var->deserialize(buf, data_len, pos))) {
LOG_WARN("fail to deserialize sys var", K(data_len), K(pos), K(sys_var_id), K(ret));
} else if (OB_FAIL(deep_copy_sys_variable(sys_var_id, sys_var->get_value(), &tmp_val))) {
LOG_WARN("fail to update system variable", K(sys_var_id), K(sys_var->get_value()), K(ret));
} else if (FALSE_IT(sys_var->set_value(tmp_val))) {
} else if (OB_FAIL(process_session_variable(sys_var_id, sys_var->get_value(), true, check_timezone_valid))) {
LOG_ERROR("process system variable error", K(ret), K(*sys_var));
}
}
}
if (OB_SUCC(ret)) {
bool tx_read_only = false;
if (OB_FAIL(serialization::decode_bool(buf, data_len, pos, &tx_read_only))) {
LOG_WARN("fail to decode tx_read_only", K(ret));
} else {
// direct assignment because in this case we won't track trans_specified_status
next_tx_read_only_ = tx_read_only;
}
}
}
int64_t unused_inner_safe_weak_read_snapshot = 0;
bool unused_literal_query = false;
bool need_serial_exec = false;
// sys_var_in_pc_str_ may be set when deserialize system variables,
// so reset it before deserialization of itself.
sys_var_in_pc_str_.reset();
const ObTZInfoMap* tz_info_map = tz_info_wrap_.get_tz_info_offset().get_tz_info_map();
LST_DO_CODE(OB_UNIS_DECODE,
sys_vars_cache_.inc_data_,
trans_consistency_type_,
safe_weak_read_snapshot_,
unused_inner_safe_weak_read_snapshot,
unused_literal_query,
tz_info_wrap_,
app_trace_id_,
proxy_capability_.capability_,
client_mode_,
proxy_sessid_,
nested_count_,
thread_data_.user_name_,
next_tx_isolation_,
read_snapshot_version_,
check_sys_variable_,
weak_read_snapshot_source_,
database_id_,
thread_data_.user_at_host_name_,
thread_data_.user_at_client_ip_,
current_execution_id_,
total_stmt_tables_,
cur_stmt_tables_,
is_foreign_key_cascade_,
sys_var_in_pc_str_,
is_foreign_key_check_exist_,
need_serial_exec);
trans_flags_.set_need_serial_exec(need_serial_exec);
is_deserialized_ = true;
tz_info_wrap_.set_tz_info_map(tz_info_map);
if (OB_SUCC(ret)) {
if (unused_inner_safe_weak_read_snapshot > safe_weak_read_snapshot_) {
LOG_INFO("ObBasicSessionInfo::deserialize: use inner safe weak read snapshot, "
"which comes from cluster before 2.2",
K(unused_inner_safe_weak_read_snapshot),
K(safe_weak_read_snapshot_),
K(*this));
safe_weak_read_snapshot_ = unused_inner_safe_weak_read_snapshot;
}
}
if (OB_SUCC(ret) && GET_MIN_CLUSTER_VERSION() < CLUSTER_CURRENT_VERSION) {
for (int64_t i = 0; OB_SUCC(ret) && i < get_sys_var_count(); ++i) {
if ((ObSysVariables::get_flags(i) & ObSysVarFlag::NEED_SERIALIZE) && OB_ISNULL(sys_vars_[i])) {
if (OB_FAIL(load_default_sys_variable(i))) {
LOG_WARN("fail to load default sys variable", K(ret), K(i));
}
}
}
}
release_to_pool_ = OB_SUCC(ret);
return ret;
}
OB_DEF_SERIALIZE(ObBasicSessionInfo::SysVarIncInfo)
{
int ret = OB_SUCCESS;
OB_UNIS_ENCODE(all_sys_var_ids_);
return ret;
}
OB_DEF_DESERIALIZE(ObBasicSessionInfo::SysVarIncInfo)
{
int ret = OB_SUCCESS;
OB_UNIS_DECODE(all_sys_var_ids_);
return ret;
}
OB_DEF_SERIALIZE_SIZE(ObBasicSessionInfo::SysVarIncInfo)
{
int64_t len = 0;
OB_UNIS_ADD_LEN(all_sys_var_ids_);
return len;
}
ObBasicSessionInfo::SysVarIncInfo::SysVarIncInfo() : all_sys_var_ids_()
{}
ObBasicSessionInfo::SysVarIncInfo::~SysVarIncInfo()
{}
int ObBasicSessionInfo::SysVarIncInfo::add_sys_var_id(ObSysVarClassType sys_var_id)
{
int ret = OB_SUCCESS;
OZ(add_var_to_array_no_dup(all_sys_var_ids_, sys_var_id), all_sys_var_ids_, sys_var_id);
return ret;
}
int ObBasicSessionInfo::SysVarIncInfo::get_des_sys_var_id(int64_t idx, ObSysVarClassType& sys_var_id) const
{
int ret = OB_SUCCESS;
OV(0 <= idx && idx < all_sys_var_ids_.count());
OX(sys_var_id = all_sys_var_ids_.at(idx));
return ret;
}
bool ObBasicSessionInfo::SysVarIncInfo::all_has_sys_var_id(ObSysVarClassType sys_var_id) const
{
return has_exist_in_array(all_sys_var_ids_, sys_var_id);
}
int64_t ObBasicSessionInfo::SysVarIncInfo::all_count() const
{
return all_sys_var_ids_.count();
}
const ObBasicSessionInfo::SysVarIds& ObBasicSessionInfo::SysVarIncInfo::get_all_sys_var_ids() const
{
return all_sys_var_ids_;
}
int ObBasicSessionInfo::SysVarIncInfo::assign(const SysVarIncInfo& other)
{
int ret = OB_SUCCESS;
if (this != &other) {
OZ(all_sys_var_ids_.assign(other.all_sys_var_ids_));
}
return ret;
}
int ObBasicSessionInfo::SysVarIncInfo::reset()
{
int ret = OB_SUCCESS;
OX(all_sys_var_ids_.reset());
return ret;
}
int ObBasicSessionInfo::load_all_sys_vars_default()
{
int ret = OB_SUCCESS;
OZ(clean_all_sys_vars());
OZ(load_default_sys_variable(false, false));
return ret;
}
int ObBasicSessionInfo::clean_all_sys_vars()
{
int ret = OB_SUCCESS;
for (int64_t i = 0; OB_SUCC(ret) && i < get_sys_var_count(); ++i) {
if (OB_NOT_NULL(sys_vars_[i])) {
OX(sys_vars_[i]->clean_value());
}
}
OX(base_sys_var_alloc_.reset());
return ret;
}
int ObBasicSessionInfo::load_all_sys_vars(ObSchemaGetterGuard& schema_guard)
{
int ret = OB_SUCCESS;
const ObSysVariableSchema* sys_var_schema = NULL;
OZ(schema_guard.get_sys_variable_schema(effective_tenant_id_, sys_var_schema));
OV(OB_NOT_NULL(sys_var_schema));
OZ(load_all_sys_vars(*sys_var_schema));
return ret;
}
int ObBasicSessionInfo::load_all_sys_vars(const ObSysVariableSchema& sys_var_schema)
{
int ret = OB_SUCCESS;
if (sys_var_base_version_ == sys_var_schema.get_schema_version()) {
OZ(process_session_variable_fast());
} else {
OZ(clean_all_sys_vars());
OX(influence_plan_var_indexs_.reset());
for (int64_t i = 0; OB_SUCC(ret) && i < get_sys_var_count(); i++) {
ObSysVarClassType sys_var_id = ObSysVariables::get_sys_var_id(i);
const ObSysVarSchema* sys_var = NULL;
OZ(sys_var_schema.get_sysvar_schema(sys_var_id, sys_var));
OV(OB_NOT_NULL(sys_var));
OZ(load_sys_variable(sys_var->get_name(),
sys_var->get_data_type(),
sys_var->get_value(),
sys_var->get_min_val(),
sys_var->get_max_val(),
sys_var->get_flags(),
true));
if (OB_NOT_NULL(sys_vars_[i]) && sys_vars_[i]->is_influence_plan()) {
OZ(influence_plan_var_indexs_.push_back(i));
}
}
OX(sys_var_base_version_ = sys_var_schema.get_schema_version());
}
if (!is_deserialized_) {
OZ(gen_sys_var_in_pc_str());
}
return ret;
}
OB_DEF_SERIALIZE_SIZE(ObBasicSessionInfo)
{
int64_t len = 0;
int64_t ser_version = get_ser_version(tenant_id_, effective_tenant_id_);
ObTimeZoneInfo tmp_tz_info; // for compatibility with old version
int ret = OB_SUCCESS;
bool in_transaction = trans_flags_.is_in_transaction();
// To be compatible with old version which store sql_mode and compatibility mode in ObSQLModeManager;
int64_t compatibility_mode_index = 0;
if (OB_FAIL(compatibility_mode2index(get_compatibility_mode(), compatibility_mode_index))) {
LOG_WARN("convert compatibility mode to index failed", K(ret));
}
LST_DO_CODE(OB_UNIS_ADD_LEN,
in_transaction,
trans_desc_,
consistency_level_,
compatibility_mode_index,
tmp_tz_info,
tenant_id_ | (rpc_tenant_id_ << 32),
effective_tenant_id_,
is_changed_to_temp_tenant_,
user_id_,
is_master_session() ? sessid_ : master_sessid_,
capability_.capability_,
thread_data_.database_name_);
// calc the length of user variables and system variables.
ObSEArray<ObSysVarClassType, 128> sys_var_ids;
ObSEArray<ObString, 32> user_var_names;
if (OB_FAIL(ret)) {
} else if (OB_FAIL(calc_need_serialize_vars(sys_var_ids, user_var_names, ser_version))) {
LOG_WARN("fail to calc need serialize vars", K(ret));
} else {
int64_t actual_ser_user_var_count = 0;
ObSessionVariable user_var_val;
for (int64_t i = 0; OB_SUCC(ret) && i < user_var_names.count(); ++i) {
user_var_val.reset();
const ObString& user_var_name = user_var_names.at(i);
ret = user_var_val_map_.get_refactored(user_var_name, user_var_val);
if (OB_SUCCESS != ret && OB_HASH_NOT_EXIST != ret) {
LOG_WARN("fail to get user var from session user var map",
K(i),
K(user_var_name),
K(user_var_val_map_.size()),
K(ret));
} else {
if (OB_SUCCESS == ret) {
actual_ser_user_var_count++;
len += serialization::encoded_length(user_var_name);
len += serialization::encoded_length(user_var_val.meta_);
len += serialization::encoded_length(user_var_val.value_);
}
ret = OB_SUCCESS;
}
}
len += serialization::encoded_length(actual_ser_user_var_count);
}
if (OB_SUCC(ret)) {
if (ser_version == CUR_SER_VERSION) {
OB_UNIS_ADD_LEN(sys_var_base_version_);
OB_UNIS_ADD_LEN(sys_var_inc_info_);
}
len += serialization::encoded_length(sys_var_ids.count());
for (int64_t i = 0; OB_SUCC(ret) && i < sys_var_ids.count(); ++i) {
int64_t sys_var_idx = -1;
ObSysVarClassType& type = sys_var_ids.at(i);
if (OB_FAIL(ObSysVarFactory::calc_sys_var_store_idx(type, sys_var_idx))) {
LOG_WARN("fail to calc sys var store idx", K(i), K(sys_var_idx), K(type), K(ret));
} else if (sys_var_idx < 0 || get_sys_var_count() <= sys_var_idx) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("sys var idx is invalid", K(sys_var_idx), K(get_sys_var_count()), K(ret));
} else if (OB_ISNULL(sys_vars_[sys_var_idx])) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("sys var is NULL", K(ret), K(sys_var_idx), K(get_sys_var_count()));
} else {
int16_t sys_var_id = static_cast<int16_t>(sys_vars_[sys_var_idx]->get_type());
len += serialization::encoded_length(sys_var_id);
len += sys_vars_[sys_var_idx]->get_serialize_size();
}
}
}
if (OB_SUCC(ret)) {
bool tx_read_only = get_tx_read_only();
len += serialization::encoded_length_bool(tx_read_only);
}
bool unused_literal_query = false;
int64_t unused_inner_safe_weak_read_snapshot = safe_weak_read_snapshot_;
bool need_serial_exec = trans_flags_.need_serial_exec();
LST_DO_CODE(OB_UNIS_ADD_LEN,
sys_vars_cache_.inc_data_,
trans_consistency_type_,
safe_weak_read_snapshot_,
unused_inner_safe_weak_read_snapshot,
unused_literal_query,
tz_info_wrap_,
app_trace_id_,
proxy_capability_.capability_,
client_mode_,
proxy_sessid_,
nested_count_,
thread_data_.user_name_,
next_tx_isolation_,
read_snapshot_version_,
check_sys_variable_,
weak_read_snapshot_source_,
database_id_,
thread_data_.user_at_host_name_,
thread_data_.user_at_client_ip_,
current_execution_id_,
total_stmt_tables_,
cur_stmt_tables_,
is_foreign_key_cascade_,
sys_var_in_pc_str_,
is_foreign_key_check_exist_,
need_serial_exec);
return len;
}
////////////////////////////////////////////////////////////////
void ObBasicSessionInfo::reset_session_changed_info()
{
changed_sys_vars_.reset();
changed_user_vars_.reset();
is_database_changed_ = false;
changed_var_pool_.reset();
feedback_manager_.reset();
}
bool ObBasicSessionInfo::is_already_tracked(
const ObSysVarClassType& sys_var_id, const ObIArray<ChangedVar>& array) const
{
bool found = false;
for (int64_t i = 0; !found && i < array.count(); ++i) {
if (array.at(i).id_ == sys_var_id) {
found = true;
break;
}
}
return found;
}
bool ObBasicSessionInfo::is_already_tracked(const ObString& name, const ObIArray<ObString>& array) const
{
bool found = false;
for (int64_t i = 0; !found && i < array.count(); ++i) {
if (array.at(i) == name) {
found = true;
break;
}
}
return found;
}
int ObBasicSessionInfo::add_changed_sys_var(
const ObSysVarClassType& sys_var_id, const ObObj& old_val, ObIArray<ChangedVar>& array)
{
int ret = OB_SUCCESS;
ObObj val;
if (SYS_VAR_INVALID == sys_var_id) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid input value", K(sys_var_id), K(old_val), K(ret));
} else if (OB_FAIL(deep_copy_obj(changed_var_pool_, old_val, val))) {
LOG_WARN("failed to deep copy system var old value", K(ret), K(old_val));
} else if (OB_FAIL(array.push_back(ChangedVar(sys_var_id, val)))) {
LOG_WARN("fail to push back", K(sys_var_id), K(old_val), K(ret));
}
return ret;
}
int ObBasicSessionInfo::add_changed_user_var(const ObString& name, common::ObIArray<common::ObString>& array)
{
return array.push_back(name);
}
int ObBasicSessionInfo::track_sys_var(const ObSysVarClassType& sys_var_id, const ObObj& old_val)
{
int ret = OB_SUCCESS;
if (SYS_VAR_INVALID == sys_var_id) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid input value", K(sys_var_id), K(ret));
} else if (!is_already_tracked(sys_var_id, changed_sys_vars_)) {
if (OB_FAIL(add_changed_sys_var(sys_var_id, old_val, changed_sys_vars_))) {
LOG_WARN("fail to add changed system var", K(sys_var_id), K(old_val), K(ret));
} else {
LOG_DEBUG("add changed var success", K(sys_var_id), K(old_val), K(changed_sys_vars_));
}
}
return ret;
}
int ObBasicSessionInfo::track_user_var(const common::ObString& user_var)
{
int ret = OB_SUCCESS;
if (user_var.empty()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid input value", K(user_var), K(ret));
} else if (!is_already_tracked(user_var, changed_user_vars_)) {
ObString name;
if (OB_FAIL(ob_write_string(changed_var_pool_, user_var, name))) {
LOG_WARN("fail to write string", K(user_var), K(ret));
} else if (OB_FAIL(add_changed_user_var(name, changed_user_vars_))) {
LOG_WARN("fail to add changed user var", K(name), K(ret));
}
}
return ret;
}
int ObBasicSessionInfo::is_sys_var_actully_changed(
const ObSysVarClassType& sys_var_id, const ObObj& old_val, ObObj& new_val, bool& changed)
{
int ret = OB_SUCCESS;
changed = true;
OZ(get_sys_variable(sys_var_id, new_val));
if (OB_SUCC(ret)) {
switch (sys_var_id) {
case SYS_VAR_AUTO_INCREMENT_INCREMENT:
case SYS_VAR_AUTO_INCREMENT_OFFSET:
case SYS_VAR_LAST_INSERT_ID:
case SYS_VAR_TX_READ_ONLY:
case SYS_VAR_OB_ENABLE_PLAN_CACHE:
case SYS_VAR_OB_ENABLE_SQL_AUDIT:
case SYS_VAR_AUTOCOMMIT:
case SYS_VAR_OB_ENABLE_TRACE_LOG:
case SYS_VAR_OB_ORG_CLUSTER_ID:
case SYS_VAR_OB_QUERY_TIMEOUT:
case SYS_VAR_OB_TRX_TIMEOUT:
case SYS_VAR_OB_TRX_IDLE_TIMEOUT:
case SYS_VAR_COLLATION_CONNECTION:
case SYS_VAR_OB_PL_BLOCK_TIMEOUT:
case SYS_VAR_OB_COMPATIBILITY_MODE: {
changed = old_val.get_meta() == new_val.get_meta() ? old_val != new_val : true;
} break;
default: {
break;
}
}
}
LOG_DEBUG("is_sys_var_actully_changed", K(sys_var_id), K(changed), K(old_val), K(new_val));
return ret;
}
int ObBasicSessionInfo::set_partition_hit(const bool is_hit)
{
int ret = OB_SUCCESS;
ObObj obj;
obj.set_bool(is_hit);
if (OB_FAIL(update_sys_variable(SYS_VAR_OB_PROXY_PARTITION_HIT, obj))) {
LOG_WARN("fail to update_system_variable", K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::set_proxy_user_privilege(const int64_t user_priv_set)
{
int ret = OB_SUCCESS;
ObObj obj;
obj.set_int(user_priv_set);
if (OB_FAIL(update_sys_variable(SYS_VAR_OB_PROXY_USER_PRIVILEGE, obj))) {
LOG_WARN("fail to update_system_variable", K(SYS_VAR_OB_PROXY_USER_PRIVILEGE), K(user_priv_set), K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::update_last_trace_id(const ObCurTraceId::TraceId& trace_id)
{
int ret = OB_SUCCESS;
const int64_t TEMP_STR_BUF_LEN = 128;
// 128 is enough to tracd_id, or will be truncated
char tmp_str_buf[TEMP_STR_BUF_LEN]; // no need init
int64_t pos = trace_id.to_string(tmp_str_buf, TEMP_STR_BUF_LEN);
ObString trace_id_str(static_cast<ObString::obstr_size_t>(pos), tmp_str_buf);
ObObj obj;
obj.set_string(ObVarcharType, trace_id_str);
if (OB_FAIL(update_sys_variable(SYS_VAR_OB_STATEMENT_TRACE_ID, obj))) {
LOG_WARN("fail to update_system_variable", K(SYS_VAR_OB_STATEMENT_TRACE_ID), K(trace_id_str), K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::set_proxy_capability(const uint64_t cap)
{
int ret = OB_SUCCESS;
ObObj obj;
obj.set_int(cap);
if (OB_FAIL(update_sys_variable(SYS_VAR_OB_CAPABILITY_FLAG, obj))) {
LOG_WARN("fail to update_system_variable", K(SYS_VAR_OB_CAPABILITY_FLAG), K(cap), K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::set_trans_specified(const bool is_spec)
{
int ret = OB_SUCCESS;
ObObj obj;
obj.set_bool(is_spec);
if (OB_FAIL(update_sys_variable(SYS_VAR_OB_PROXY_SET_TRX_EXECUTED, obj))) {
LOG_WARN("fail to update_system_variable", K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::set_safe_weak_read_snapshot_variable(const int64_t safe_snapshot)
{
int ret = OB_SUCCESS;
ObObj obj;
obj.set_int(safe_snapshot);
if (OB_FAIL(update_sys_variable(SYS_VAR_OB_SAFE_WEAK_READ_SNAPSHOT, obj))) {
LOG_WARN("fail to update_system_variable", K(SYS_VAR_OB_SAFE_WEAK_READ_SNAPSHOT), K(safe_snapshot), K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::set_init_connect(const ObString& init_sql)
{
int ret = OB_SUCCESS;
ObObj obj;
obj.set_string(ObVarcharType, init_sql);
if (OB_FAIL(update_sys_variable(SYS_VAR_INIT_CONNECT, obj))) {
LOG_WARN("fail to update_system_variable", K(ret));
} else {
}
return ret;
}
int ObBasicSessionInfo::save_trans_status()
{
int ret = OB_SUCCESS;
switch (trans_spec_status_) {
case TRANS_SPEC_SET:
ret = set_trans_specified(true);
break;
case TRANS_SPEC_COMMIT:
ret = set_trans_specified(false);
trans_spec_status_ = TRANS_SPEC_NOT_SET;
break;
case TRANS_SPEC_NOT_SET:
// do nothing
break;
default:
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("Unknown trans specified status", K(trans_spec_status_), K(ret));
break;
}
return ret;
}
int ObBasicSessionInfo::get_character_set_client(ObCharsetType& character_set_client) const
{
return get_charset_sys_var(SYS_VAR_CHARACTER_SET_CLIENT, character_set_client);
}
int ObBasicSessionInfo::get_character_set_connection(ObCharsetType& character_set_connection) const
{
return get_charset_sys_var(SYS_VAR_CHARACTER_SET_CONNECTION, character_set_connection);
}
int ObBasicSessionInfo::get_character_set_database(ObCharsetType& character_set_database) const
{
return get_charset_sys_var(SYS_VAR_CHARACTER_SET_DATABASE, character_set_database);
}
int ObBasicSessionInfo::get_character_set_results(ObCharsetType& character_set_results) const
{
if (CHARSET_INVALID == (character_set_results = sys_vars_cache_.get_character_set_results())) {
get_charset_sys_var(SYS_VAR_CHARACTER_SET_RESULTS, character_set_results);
}
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_character_set_server(ObCharsetType& character_set_server) const
{
return get_charset_sys_var(SYS_VAR_CHARACTER_SET_SERVER, character_set_server);
}
int ObBasicSessionInfo::get_character_set_system(ObCharsetType& character_set_system) const
{
return get_charset_sys_var(SYS_VAR_CHARACTER_SET_SYSTEM, character_set_system);
}
int ObBasicSessionInfo::get_character_set_filesystem(ObCharsetType& character_set_filesystem) const
{
return get_charset_sys_var(SYS_VAR_CHARACTER_SET_FILESYSTEM, character_set_filesystem);
}
int ObBasicSessionInfo::get_collation_database(ObCollationType& collation_database) const
{
return get_collation_sys_var(SYS_VAR_COLLATION_DATABASE, collation_database);
}
int ObBasicSessionInfo::get_collation_server(ObCollationType& collation_server) const
{
return get_collation_sys_var(SYS_VAR_COLLATION_SERVER, collation_server);
}
int ObBasicSessionInfo::get_foreign_key_checks(int64_t& foreign_key_checks) const
{
foreign_key_checks = sys_vars_cache_.get_foreign_key_checks();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_capture_plan_baseline(bool& v) const
{
v = sys_vars_cache_.get_optimizer_capture_sql_plan_baselines();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_use_plan_baseline(bool& v) const
{
v = sys_vars_cache_.get_optimizer_use_sql_plan_baselines();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_adaptive_cursor_sharing(bool& acs) const
{
acs = sys_vars_cache_.get__optimizer_adaptive_cursor_sharing();
return OB_SUCCESS;
}
int ObBasicSessionInfo::get_nlj_batching_enabled(bool& v) const
{
return get_bool_sys_var(SYS_VAR__NLJ_BATCHING_ENABLED, v);
}
int ObBasicSessionInfo::get_auto_increment_cache_size(int64_t& auto_increment_cache_size)
{
int ret = OB_SUCCESS;
if (OB_FAIL(get_sys_variable(SYS_VAR_AUTO_INCREMENT_CACHE_SIZE, auto_increment_cache_size))) {
LOG_WARN("fail to get variables", K(ret));
}
return ret;
}
int ObBasicSessionInfo::get_enable_parallel_dml(bool& v) const
{
return get_bool_sys_var(SYS_VAR__ENABLE_PARALLEL_DML, v);
}
int ObBasicSessionInfo::get_enable_parallel_query(bool& v) const
{
return get_bool_sys_var(SYS_VAR__ENABLE_PARALLEL_QUERY, v);
}
int ObBasicSessionInfo::get_force_parallel_query_dop(uint64_t& v) const
{
int ret = OB_SUCCESS;
if (exec_min_cluster_version_ >= CLUSTER_VERSION_3100) {
ret = get_uint64_sys_var(SYS_VAR__FORCE_PARALLEL_QUERY_DOP, v);
} else {
v = 1;
}
return ret;
}
int ObBasicSessionInfo::get_force_parallel_dml_dop(uint64_t& v) const
{
int ret = OB_SUCCESS;
if (exec_min_cluster_version_ >= CLUSTER_VERSION_3100) {
ret = get_uint64_sys_var(SYS_VAR__FORCE_PARALLEL_DML_DOP, v);
} else {
v = 1;
}
return ret;
}
int ObBasicSessionInfo::get_secure_file_priv(ObString& v) const
{
return get_string_sys_var(SYS_VAR_SECURE_FILE_PRIV, v);
}
int ObBasicSessionInfo::get_sql_safe_updates(bool& v) const
{
return get_bool_sys_var(SYS_VAR_SQL_SAFE_UPDATES, v);
}
void ObBasicSessionInfo::reset_tx_variable()
{
// this function will be called in end_trans phase, and must be idempotent.
// trans_desc will be reset in start_trans phase, not here, because end_trans may use it.
reset_tx_isolation();
reset_tx_read_only();
reset_trans_flags();
clear_trans_consistency_type();
clear_app_trace_id();
}
int32_t ObBasicSessionInfo::get_tx_isolation() const
{
int32_t isolation = -1;
const int32_t TX_NOT_SET = -1;
if (next_tx_isolation_ != TX_NOT_SET) {
isolation = next_tx_isolation_;
} else {
isolation = sys_vars_cache_.get_tx_isolation();
}
return isolation;
}
bool ObBasicSessionInfo::is_isolation_serializable() const
{
return ObTransIsolation::SERIALIZABLE == get_tx_isolation();
}
void ObBasicSessionInfo::set_tx_isolation(int32_t isolation)
{
next_tx_isolation_ = isolation;
trans_spec_status_ = TRANS_SPEC_SET;
}
void ObBasicSessionInfo::reset_tx_isolation()
{
next_tx_isolation_ = transaction::ObTransIsolation::UNKNOWN;
if (TRANS_SPEC_SET == trans_spec_status_) {
trans_spec_status_ = TRANS_SPEC_COMMIT;
}
}
void ObBasicSessionInfo::set_tx_read_only(bool read_only)
{
next_tx_read_only_ = read_only;
trans_spec_status_ = TRANS_SPEC_SET;
}
void ObBasicSessionInfo::reset_tx_read_only()
{
next_tx_read_only_ = -1;
if (TRANS_SPEC_SET == trans_spec_status_) {
trans_spec_status_ = TRANS_SPEC_COMMIT;
}
}
int ObBasicSessionInfo::check_tx_read_only_privilege(const ObSqlTraits& sql_traits)
{
int ret = OB_SUCCESS;
if (sql_traits.is_cause_implicit_commit_) {
reset_tx_read_only();
} else {
}
if (get_tx_read_only() && !sql_traits.is_readonly_stmt_) {
ret = OB_ERR_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION;
} else {
}
return ret;
}
int ObBasicSessionInfo::reset_tx_variable_if_remote_trans(const ObPhyPlanType& type)
{
int ret = OB_SUCCESS;
if (ObSqlTransUtil::is_remote_trans(get_local_autocommit(), trans_flags_.is_in_transaction(), type)) {
reset_tx_variable();
} else {
// nothing to do
}
return ret;
}
bool ObBasicSessionInfo::get_tx_read_only() const
{
bool tx_read_only = false;
const int32_t TX_NOT_SET = -1;
if (next_tx_read_only_ != TX_NOT_SET) {
tx_read_only = next_tx_read_only_;
} else {
tx_read_only = sys_vars_cache_.get_tx_read_only();
}
return tx_read_only;
}
int ObBasicSessionInfo::store_query_string(const ObString& stmt)
{
LockGuard lock_guard(thread_data_mutex_);
return store_query_string_(stmt);
}
int ObBasicSessionInfo::store_query_string_(const ObString& stmt)
{
int ret = OB_SUCCESS;
int64_t truncated_len = std::min(MAX_CUR_QUERY_LEN - 1, static_cast<int64_t>(stmt.length()));
if (truncated_len < 0) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid str length", K(ret), K(truncated_len));
} else if (thread_data_.cur_query_buf_len_ - 1 < truncated_len) {
if (thread_data_.cur_query_ != nullptr) {
ob_free(thread_data_.cur_query_);
thread_data_.cur_query_ = NULL;
thread_data_.cur_query_buf_len_ = 0;
}
int64_t len = MAX(MIN_CUR_QUERY_LEN, truncated_len + 1);
char* buf = reinterpret_cast<char*>(ob_malloc(len, ObModIds::OB_SQL_SESSION_QUERY_SQL));
if (OB_ISNULL(buf)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("alloc memory failed", K(ret));
} else {
thread_data_.cur_query_ = buf;
thread_data_.cur_query_buf_len_ = len;
}
}
if (OB_SUCC(ret)) {
MEMCPY(thread_data_.cur_query_, stmt.ptr(), truncated_len);
thread_data_.cur_query_[truncated_len] = '\0';
thread_data_.cur_query_len_ = truncated_len;
}
return ret;
}
void ObBasicSessionInfo::reset_query_string()
{
thread_data_.cur_query_[0] = '\0';
thread_data_.cur_query_len_ = 0;
}
int ObBasicSessionInfo::update_session_timeout()
{
int ret = OB_SUCCESS;
ObObj val;
if (thread_data_.is_interactive_) {
val.set_int(thread_data_.interactive_timeout_);
if (OB_FAIL(update_sys_variable(SYS_VAR_WAIT_TIMEOUT, val))) {
LOG_WARN("failed to update session_timeout", K(ret));
}
}
return ret;
}
const char* ObBasicSessionInfo::get_session_state_str() const
{
const char* str_ret = NULL;
switch (thread_data_.state_) {
case SESSION_INIT:
str_ret = "INIT";
break;
case SESSION_SLEEP:
str_ret = "SLEEP";
break;
case QUERY_ACTIVE:
str_ret = "ACTIVE";
break;
case QUERY_KILLED:
str_ret = "QUERY_KILLED";
break;
case SESSION_KILLED:
str_ret = "SESSION_KILLED";
break;
default:
str_ret = "INVALID SESSION STATE";
break;
}
return str_ret;
}
int ObBasicSessionInfo::is_timeout(bool& is_timeout)
{
int ret = OB_SUCCESS;
int64_t timeout = 0;
is_timeout = false;
if (SESSION_SLEEP == thread_data_.state_) {
timeout = thread_data_.is_interactive_ ? thread_data_.interactive_timeout_ : thread_data_.wait_timeout_;
int64_t cur_time = ::oceanbase::common::ObTimeUtility::current_time();
if (OB_UNLIKELY(timeout < 0)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("session timeout setting is invalid", K(ret), K(timeout));
} else if (OB_UNLIKELY(timeout > INT64_MAX / 1000 / 1000)) {
ret = OB_ERR_UNEXPECTED;
LOG_ERROR("session timeout setting is too larger, skip check timeout", K(ret), K(timeout));
} else if (0 == timeout) {
// no timeout check for timeout == 0
} else if (SESSION_SLEEP == thread_data_.state_ &&
thread_data_.last_active_time_ + timeout * 1000 * 1000 < cur_time) {
const ObString& user_name = get_user_name();
char addr_buf[common::OB_IP_PORT_STR_BUFF];
if (OB_FAIL(get_peer_addr().ip_port_to_string(addr_buf, OB_IP_PORT_STR_BUFF))) {
LOG_WARN("failed to get peer addr string", K(ret), K(get_peer_addr()), K(addr_buf));
} else {
_LOG_INFO("sessionkey %u, proxy_sessid %lu: %.*s from %s timeout: last active time=%s, cur=%s, timeout=%lds",
sessid_,
proxy_sessid_,
user_name.length(),
user_name.ptr(),
addr_buf,
time2str(thread_data_.last_active_time_),
time2str(cur_time),
timeout);
}
is_timeout = true;
}
}
return ret;
}
int ObBasicSessionInfo::is_trx_idle_timeout(bool& timeout)
{
int ret = OB_SUCCESS;
int64_t cur_time = ::oceanbase::common::ObTimeUtility::current_time();
LOG_DEBUG("check trx_idle_timeout : ",
K_(sessid),
K(trans_flags_.is_in_transaction()),
K(curr_trans_last_stmt_end_time_),
K(cur_time),
K(get_query_start_time()));
if (get_query_start_time() < curr_trans_last_stmt_end_time_) {
int64_t ob_trx_idle_timeout =
sys_vars_cache_.get_ob_trx_idle_timeout() > 0 ? sys_vars_cache_.get_ob_trx_idle_timeout() : 120 * 1000 * 1000;
if (trans_flags_.is_in_transaction() && curr_trans_last_stmt_end_time_ > 0 &&
curr_trans_last_stmt_end_time_ + ob_trx_idle_timeout < cur_time) {
LOG_WARN("ob_trx_idle_timeout happen", K_(sessid), K_(curr_trans_last_stmt_end_time), K(ob_trx_idle_timeout));
curr_trans_last_stmt_end_time_ = 0; // flip
timeout = true;
}
}
return ret;
}
int ObBasicSessionInfo::get_pc_mem_conf(ObPCMemPctConf& pc_mem_conf)
{
int ret = OB_SUCCESS;
if (OB_FAIL(get_sys_variable(SYS_VAR_OB_PLAN_CACHE_PERCENTAGE, pc_mem_conf.limit_pct_))) {
LOG_WARN("fail to get plan cache system variables", K(pc_mem_conf.limit_pct_), K(ret));
} else if (OB_FAIL(get_sys_variable(SYS_VAR_OB_PLAN_CACHE_EVICT_HIGH_PERCENTAGE, pc_mem_conf.high_pct_))) {
LOG_WARN("fail to get plan cache system variables", K(pc_mem_conf.high_pct_), K(ret));
} else if (OB_FAIL(get_sys_variable(SYS_VAR_OB_PLAN_CACHE_EVICT_LOW_PERCENTAGE, pc_mem_conf.low_pct_))) {
LOG_WARN("fail to get plan cache system variables", K(pc_mem_conf.low_pct_), K(ret));
}
return ret;
}
int ObBasicSessionInfo::get_sql_audit_mem_conf(int64_t& mem_pct)
{
int ret = OB_SUCCESS;
if (OB_FAIL(get_sys_variable(SYS_VAR_OB_SQL_AUDIT_PERCENTAGE, mem_pct))) {
LOG_WARN("failed to get memory percentage for sql audit", K(ret));
}
return ret;
}
void ObBasicSessionInfo::set_conn(easy_connection_t* conn)
{
LockGuard lock_guard(thread_data_mutex_);
thread_data_.conn_ = conn;
}
void ObBasicSessionInfo::set_session_data(ObSQLSessionState state, obmysql::ObMySQLCmd mysql_cmd, int64_t thread_id)
{
LockGuard lock_guard(thread_data_mutex_);
set_session_state_(state);
thread_data_.mysql_cmd_ = mysql_cmd;
thread_id_ = thread_id;
}
int ObBasicSessionInfo::set_session_state(ObSQLSessionState state)
{
LockGuard lock_guard(thread_data_mutex_);
return set_session_state_(state);
}
int ObBasicSessionInfo::set_session_state_(ObSQLSessionState state)
{
int ret = OB_SUCCESS;
if (OB_UNLIKELY(SESSION_KILLED == thread_data_.state_)) {
ret = OB_ERR_SESSION_INTERRUPTED;
LOG_WARN("session is killed", K(ret), K(sessid_), K(proxy_sessid_), K(version_), K(state));
} else if (OB_UNLIKELY(SESS_NOT_IN_RETRY != thread_data_.is_in_retry_ && QUERY_KILLED == thread_data_.state_ &&
SESSION_KILLED != state)) {
ret = OB_ERR_QUERY_INTERRUPTED;
LOG_WARN("query is killed", K(ret), K(sessid_), K(proxy_sessid_), K(version_), K(state));
} else {
thread_data_.state_ = state;
thread_data_.cur_state_start_time_ = ::oceanbase::common::ObClockGenerator::getClock();
}
return ret;
}
int ObBasicSessionInfo::set_session_active(
const ObString& sql, const int64_t query_receive_ts, const int64_t last_active_time_ts, obmysql::ObMySQLCmd cmd)
{
int ret = OB_SUCCESS;
LockGuard lock_guard(thread_data_mutex_);
if (OB_FAIL(store_query_string_(sql))) {
LOG_WARN("store query string fail", K(ret));
} else if (OB_FAIL(set_session_state_(QUERY_ACTIVE))) {
LOG_WARN("fail to set session state", K(ret));
} else {
thread_data_.cur_query_start_time_ = query_receive_ts;
thread_data_.mysql_cmd_ = cmd;
thread_data_.last_active_time_ = last_active_time_ts;
}
return ret;
}
int ObBasicSessionInfo::base_save_session(BaseSavedValue& saved_value, bool skip_cur_stmt_tables)
{
int ret = OB_SUCCESS;
// OZ (saved_value.trans_desc_.stmt_deep_copy(trans_desc_));
// OX (saved_value.in_transaction_ = trans_flags_.is_in_transaction());
OX(saved_value.cur_phy_plan_ = cur_phy_plan_);
OX(cur_phy_plan_ = NULL);
int len = MIN(thread_data_.cur_query_len_, static_cast<int64_t>(sizeof(saved_value.cur_query_) - 1));
if (thread_data_.cur_query_ != nullptr) {
OX(MEMCPY(&saved_value.cur_query_, thread_data_.cur_query_, len));
OX(thread_data_.cur_query_[0] = 0);
}
OX(saved_value.cur_query_len_ = len);
OX(thread_data_.cur_query_len_ = 0);
// OX (saved_value.cur_query_start_time_ = thread_data_.cur_query_start_time_);
// OX (thread_data_.cur_query_start_time_ = 0);
OZ(saved_value.total_stmt_tables_.assign(total_stmt_tables_));
if (!skip_cur_stmt_tables) {
OZ(append_array_no_dup(total_stmt_tables_, cur_stmt_tables_));
}
OZ(saved_value.cur_stmt_tables_.assign(cur_stmt_tables_));
OX(cur_stmt_tables_.reset());
OX(sys_vars_cache_.get_autocommit_info(
saved_value.base_autocommit_, saved_value.inc_autocommit_, saved_value.is_inc_autocommit_));
OX(sys_vars_cache_.set_autocommit_info(false, false, false));
OX(saved_value.is_foreign_key_cascade_ = is_foreign_key_cascade_);
OX(is_foreign_key_cascade_ = false);
OX(saved_value.is_foreign_key_check_exist_ = is_foreign_key_check_exist_);
OX(is_foreign_key_check_exist_ = false);
OX(saved_value.need_serial_exec_ = trans_flags_.need_serial_exec());
if (OB_NOT_NULL(saved_value.cur_phy_plan_) && saved_value.cur_phy_plan_->get_need_serial_exec()) {
OX(trans_flags_.set_need_serial_exec(true));
}
return ret;
}
int ObBasicSessionInfo::stmt_save_session(StmtSavedValue& saved_value, bool skip_cur_stmt_tables)
{
int ret = OB_SUCCESS;
OZ(base_save_session(saved_value, skip_cur_stmt_tables));
OZ(saved_value.trans_desc_.stmt_deep_copy(trans_desc_));
OX(saved_value.in_transaction_ = trans_flags_.is_in_transaction());
OX(saved_value.cur_query_start_time_ = thread_data_.cur_query_start_time_);
OX(thread_data_.cur_query_start_time_ = 0);
OZ(saved_value.trans_result_.assign(trans_result_));
OX(trans_result_.reset());
return ret;
}
int ObBasicSessionInfo::save_basic_session(StmtSavedValue& saved_value, bool skip_cur_stmt_tables)
{
return stmt_save_session(saved_value, skip_cur_stmt_tables);
}
int ObBasicSessionInfo::begin_nested_session(StmtSavedValue& saved_value, bool skip_cur_stmt_tables)
{
int ret = OB_SUCCESS;
OZ(SMART_CALL(save_basic_session(saved_value, skip_cur_stmt_tables)));
OX(trans_flags_.set_is_in_transaction(true));
return ret;
}
int ObBasicSessionInfo::base_restore_session(BaseSavedValue& saved_value)
{
int ret = OB_SUCCESS;
OX(trans_flags_.set_need_serial_exec(saved_value.need_serial_exec_));
OX(is_foreign_key_check_exist_ = saved_value.is_foreign_key_check_exist_);
OX(is_foreign_key_cascade_ = saved_value.is_foreign_key_cascade_);
OX(sys_vars_cache_.set_autocommit_info(
saved_value.base_autocommit_, saved_value.inc_autocommit_, saved_value.is_inc_autocommit_));
OZ(cur_stmt_tables_.assign(saved_value.cur_stmt_tables_));
OZ(total_stmt_tables_.assign(saved_value.total_stmt_tables_));
// OX (thread_data_.cur_query_start_time_ = saved_value.cur_query_start_time_);
int64_t len = MIN(saved_value.cur_query_len_, thread_data_.cur_query_buf_len_ - 1);
OX(thread_data_.cur_query_len_ = len);
if (thread_data_.cur_query_ != nullptr) {
OX(MEMCPY(thread_data_.cur_query_, saved_value.cur_query_, len));
thread_data_.cur_query_[len] = '\0';
}
OX(cur_phy_plan_ = saved_value.cur_phy_plan_);
return ret;
}
int ObBasicSessionInfo::stmt_restore_session(StmtSavedValue& saved_value)
{
int ret = OB_SUCCESS;
OZ(trans_result_.merge_result(saved_value.trans_result_));
OX(thread_data_.cur_query_start_time_ = saved_value.cur_query_start_time_);
OX(trans_flags_.set_is_in_transaction(saved_value.in_transaction_));
OZ(trans_desc_.stmt_deep_copy(saved_value.trans_desc_));
OZ(base_restore_session(saved_value));
return ret;
}
int ObBasicSessionInfo::restore_basic_session(StmtSavedValue& saved_value)
{
return stmt_restore_session(saved_value);
}
int ObBasicSessionInfo::end_nested_session(StmtSavedValue& saved_value)
{
int ret = OB_SUCCESS;
int64_t max_sql_no = MAX(trans_desc_.get_max_sql_no(), trans_result_.get_max_sql_no());
OZ(SMART_CALL(restore_basic_session(saved_value)));
OX(saved_value.reset());
OX(trans_desc_.restore_max_sql_no(max_sql_no));
OX(trans_result_.set_max_sql_no(max_sql_no));
return ret;
}
int ObBasicSessionInfo::trans_save_session(TransSavedValue& saved_value)
{
int ret = OB_SUCCESS;
OZ(base_save_session(saved_value, false));
OZ(saved_value.trans_desc_.trans_deep_copy(trans_desc_));
OX(trans_desc_.reset());
OZ(trans_desc_.init(this));
OX(saved_value.trans_flags_ = trans_flags_);
OX(trans_flags_.reset());
OZ(saved_value.trans_result_.assign(trans_result_));
OX(trans_result_.reset());
OX(saved_value.nested_count_ = nested_count_);
OX(nested_count_ = -1);
return ret;
}
int ObBasicSessionInfo::trans_restore_session(TransSavedValue& saved_value)
{
int ret = OB_SUCCESS;
OX(nested_count_ = saved_value.nested_count_);
OZ(trans_result_.assign(saved_value.trans_result_));
OX(trans_flags_ = saved_value.trans_flags_);
OZ(trans_desc_.trans_deep_copy(saved_value.trans_desc_));
OZ(base_restore_session(saved_value));
return ret;
}
int ObBasicSessionInfo::begin_autonomous_session(TransSavedValue& saved_value)
{
return trans_save_session(saved_value);
}
int ObBasicSessionInfo::end_autonomous_session(TransSavedValue& saved_value)
{
return trans_restore_session(saved_value);
}
int ObBasicSessionInfo::set_start_stmt()
{
int ret = OB_SUCCESS;
OV(nested_count_ == -1, OB_ERR_UNEXPECTED, nested_count_);
OX(nested_count_ = 0);
return ret;
}
int ObBasicSessionInfo::set_end_stmt()
{
int ret = OB_SUCCESS;
OV(nested_count_ == 0, OB_ERR_UNEXPECTED, nested_count_);
OX(nested_count_ = -1);
return ret;
}
int ObBasicSessionInfo::set_cur_stmt_tables(const ObIArray<ObPartitionKey>& stmt_partitions, stmt::StmtType stmt_type)
{
int ret = OB_SUCCESS;
if (!is_nested_session()) {
// cur stmt is top stmt.
total_stmt_tables_.reset();
cur_stmt_tables_.reset();
}
if (!is_foreign_key_cascade() && !is_foreign_key_check_exist()) {
TableStmtType table_stmt_type;
int64_t idx = -1;
table_stmt_type.stmt_type_ = stmt_type;
for (int i = 0; OB_SUCC(ret) && i < stmt_partitions.count(); i++) {
OX(table_stmt_type.table_id_ = stmt_partitions.at(i).table_id_);
if (has_exist_in_array(total_stmt_tables_, table_stmt_type, &idx)) {
OV(0 <= idx && idx < total_stmt_tables_.count());
OV(table_stmt_type.is_select_stmt() && total_stmt_tables_.at(idx).is_select_stmt(),
OB_ERR_MUTATING_TABLE_OPERATION,
total_stmt_tables_,
table_stmt_type,
is_foreign_key_cascade_,
is_foreign_key_check_exist_);
}
OZ(add_var_to_array_no_dup(cur_stmt_tables_, table_stmt_type), cur_stmt_tables_, table_stmt_type);
}
}
return ret;
}
int ObBasicSessionInfo::set_time_zone(
const ObString& str_val, const bool is_oralce_mode, const bool check_timezone_valid)
{
int ret = OB_SUCCESS;
int32_t offset = 0;
int ret_more = OB_SUCCESS;
if (OB_FAIL(ObTimeConverter::str_to_offset(str_val, offset, ret_more, is_oralce_mode, check_timezone_valid))) {
if (ret != OB_ERR_UNKNOWN_TIME_ZONE) {
LOG_WARN("fail to convert time zone", K(str_val), K(ret));
}
} else {
tz_info_wrap_.set_tz_info_offset(offset);
}
if (OB_ERR_UNKNOWN_TIME_ZONE == ret) {
ObTZMapWrap tz_map_wrap;
ObTimeZoneInfoManager* tz_info_mgr = NULL;
if (OB_FAIL(OTTZ_MGR.get_tenant_timezone(tenant_id_, tz_map_wrap, tz_info_mgr))) {
LOG_WARN("get tenant timezone with lock failed", K(ret));
} else if (OB_ISNULL(tz_info_mgr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("tenant timezone mgr is null", K(tz_info_mgr));
} else {
const int64_t orig_version = tz_info_wrap_.get_cur_version();
tz_info_wrap_.set_cur_version(tz_info_mgr->get_version());
ObCollationType coll_type = ObCharset::get_default_collation(ObCharset::get_default_charset());
int32_t no_sp_len =
static_cast<int32_t>(ObCharset::strlen_byte_no_sp(coll_type, str_val.ptr(), str_val.length()));
ObString val_no_sp(no_sp_len, str_val.ptr());
if (is_oralce_mode) {
val_no_sp = val_no_sp.trim();
}
int64_t start_service_time = GCTX.start_service_time_;
if (OB_FAIL(tz_info_mgr->find_time_zone_info(val_no_sp, tz_info_wrap_.get_tz_info_pos()))) {
LOG_WARN("fail to find time zone", K(str_val), K(val_no_sp), K(ret));
tz_info_wrap_.set_cur_version(orig_version);
} else {
tz_info_wrap_.set_tz_info_position();
}
if (OB_ERR_UNKNOWN_TIME_ZONE == ret) {
if (0 == start_service_time) {
LOG_INFO(
"ignore unknow time zone, perhaps in remote/distribute task processer when server start_time is zero",
K(str_val));
ret = OB_SUCCESS;
if (OB_FAIL(tz_info_wrap_.get_tz_info_pos().set_tz_name(str_val.ptr(), no_sp_len))) {
LOG_WARN("fail to set time zone info name", K(str_val), K(ret));
} else {
tz_info_wrap_.set_tz_info_position();
}
}
}
}
}
return ret;
}
int ObBasicSessionInfo::update_timezone_info()
{
int ret = OB_SUCCESS;
ObTZMapWrap tz_map_wrap;
ObTimeZoneInfoManager* tz_info_mgr = NULL;
if (OB_FAIL(OTTZ_MGR.get_tenant_timezone(tenant_id_, tz_map_wrap, tz_info_mgr))) {
LOG_WARN("get tenant timezone with lock failed", K(ret));
} else if (OB_ISNULL(tz_info_mgr)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("tenant timezone mgr is null", K(tz_info_mgr));
} else if (OB_UNLIKELY(
tz_info_wrap_.is_position_class() && tz_info_mgr->get_version() > tz_info_wrap_.get_cur_version())) {
ObString tz_name;
if (OB_UNLIKELY(!tz_info_wrap_.get_tz_info_pos().is_valid())) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("time zone info is invalid", K(tz_info_wrap_.get_tz_info_pos()), K(ret));
} else if (OB_FAIL(tz_info_wrap_.get_tz_info_pos().get_tz_name(tz_name))) {
LOG_WARN("fal to get time zone name", K(tz_info_wrap_.get_tz_info_pos()), K(ret));
} else {
int64_t orig_version = tz_info_wrap_.get_cur_version();
tz_info_wrap_.set_cur_version(tz_info_mgr->get_version());
if (OB_FAIL(tz_info_mgr->find_time_zone_info(tz_name, tz_info_wrap_.get_tz_info_pos()))) {
LOG_WARN("fail to find time zone info", K(tz_name), K(ret));
tz_info_wrap_.set_cur_version(orig_version);
} else {
tz_info_wrap_.get_tz_info_pos().set_error_on_overlap_time(tz_info_wrap_.is_error_on_overlap_time());
}
}
}
return ret;
}
constexpr ObSysVarClassType ObExecEnv::ExecEnvMap[MAX_ENV + 1];
void ObExecEnv::reset()
{
sql_mode_ = DEFAULT_OCEANBASE_MODE;
charset_client_ = CS_TYPE_INVALID;
collation_connection_ = CS_TYPE_INVALID;
collation_database_ = CS_TYPE_INVALID;
}
bool ObExecEnv::operator==(const ObExecEnv& other) const
{
return sql_mode_ == other.sql_mode_ && charset_client_ == other.charset_client_ &&
collation_connection_ == other.collation_connection_ && collation_database_ == other.collation_database_;
}
bool ObExecEnv::operator!=(const ObExecEnv& other) const
{
return !(*this == other);
}
int ObExecEnv::gen_exec_env(const ObBasicSessionInfo& session, char* buf, int64_t len, int64_t& pos)
{
int ret = OB_SUCCESS;
ObObj val;
for (int64_t i = 0; OB_SUCC(ret) && i < MAX_ENV; ++i) {
int64_t size = 0;
val.reset();
if (OB_FAIL(session.get_sys_variable(ExecEnvMap[i], val))) {
LOG_WARN("failed to get sys_variable", K(ExecEnvMap[i]), K(ret));
} else if (OB_FAIL(val.print_plain_str_literal(buf + pos, len - pos, size))) {
LOG_WARN("fail to encode obj", K(i), K(buf + pos), K(len), K(pos), K(val), K(ret));
} else {
pos += size;
buf[pos++] = ',';
}
}
return ret;
}
int ObExecEnv::get_exec_env(const ObString& exec_env, ExecEnvType type, ObString& value)
{
int ret = OB_SUCCESS;
if (exec_env.empty()) {
ret = common::OB_ERR_UNEXPECTED;
LOG_WARN("Invalid exec_env", K(exec_env), K(type), K(ret));
} else {
ObString result;
ObString start = exec_env;
const char* end = NULL;
int64_t i = 0;
while (!start.empty() && i++ < type) {
start = start.after(',');
}
end = start.find(',');
value.assign(start.ptr(), static_cast<ObString::obstr_size_t>(end - start.ptr()));
}
return ret;
}
#define SET_ENV_VALUE(env, type) \
do { \
int64_t value = 0; \
int64_t pos = 0; \
if (OB_FAIL(extract_int(value_str, 0, pos, value))) { \
LOG_WARN("Failed to extract int", K(value_str), K(ret)); \
} else { \
env = static_cast<type>(value); \
} \
} while (0)
int ObExecEnv::init(const ObString& exec_env)
{
int ret = OB_SUCCESS;
ObString value_str;
for (int64_t i = 0; OB_SUCC(ret) && i < MAX_ENV; ++i) {
value_str.reset();
if (OB_FAIL(get_exec_env(exec_env, static_cast<ExecEnvType>(i), value_str))) {
LOG_WARN("failed to get exec_env", K(exec_env), K(i), K(ret));
} else {
switch (i) {
case SQL_MODE: {
SET_ENV_VALUE(sql_mode_, ObSQLMode);
} break;
case CHARSET_CLIENT: {
SET_ENV_VALUE(charset_client_, ObCollationType);
} break;
case COLLATION_CONNECTION: {
SET_ENV_VALUE(collation_connection_, ObCollationType);
} break;
case COLLATION_DATABASE: {
SET_ENV_VALUE(collation_database_, ObCollationType);
} break;
default: {
ret = common::OB_ERR_UNEXPECTED;
LOG_WARN("Invalid env type", K(exec_env), K(i), K(ret));
} break;
}
}
}
return ret;
}
int ObExecEnv::load(ObBasicSessionInfo& session)
{
int ret = OB_SUCCESS;
ObObj val;
for (int64_t i = 0; OB_SUCC(ret) && i < MAX_ENV; ++i) {
val.reset();
if (OB_FAIL(session.get_sys_variable(ExecEnvMap[i], val))) {
LOG_WARN("failed to get sys_variable", K(ExecEnvMap[i]), K(ret));
} else {
switch (i) {
case SQL_MODE: {
sql_mode_ = static_cast<ObSQLMode>(val.get_int());
} break;
case CHARSET_CLIENT: {
charset_client_ = static_cast<ObCollationType>(val.get_int());
} break;
case COLLATION_CONNECTION: {
collation_connection_ = static_cast<ObCollationType>(val.get_int());
} break;
case COLLATION_DATABASE: {
collation_database_ = static_cast<ObCollationType>(val.get_int());
} break;
default: {
ret = common::OB_ERR_UNEXPECTED;
LOG_WARN("Invalid env type", K(i), K(ret));
} break;
}
}
}
return ret;
}
int ObExecEnv::store(ObBasicSessionInfo& session)
{
int ret = OB_SUCCESS;
ObObj val;
for (int64_t i = 0; OB_SUCC(ret) && i < MAX_ENV; ++i) {
val.reset();
switch (i) {
case SQL_MODE: {
val.set_uint64(sql_mode_);
} break;
case CHARSET_CLIENT: {
val.set_int(charset_client_);
} break;
case COLLATION_CONNECTION: {
val.set_int(collation_connection_);
} break;
case COLLATION_DATABASE: {
val.set_int(collation_database_);
} break;
default: {
ret = common::OB_ERR_UNEXPECTED;
LOG_WARN("Invalid env type", K(i), K(ret));
} break;
}
if (OB_SUCC(ret)) {
if (OB_FAIL(session.update_sys_variable(ExecEnvMap[i], val))) {
LOG_WARN("failed to get sys_variable", K(ExecEnvMap[i]), K(ret));
}
}
}
return ret;
}
} // end of namespace sql
} // end of namespace oceanbase
| 35.792938 | 120 | 0.698023 | wangcy6 |
386658bfe8227e7876d887bdf5eec76f45a745ca | 742 | cc | C++ | src/lingx/core/path.cc | chrisxjzhu/lingx | 703d3b1b71b96ee87a8db0fdb37c786da0e299dd | [
"MIT"
] | null | null | null | src/lingx/core/path.cc | chrisxjzhu/lingx | 703d3b1b71b96ee87a8db0fdb37c786da0e299dd | [
"MIT"
] | null | null | null | src/lingx/core/path.cc | chrisxjzhu/lingx | 703d3b1b71b96ee87a8db0fdb37c786da0e299dd | [
"MIT"
] | 1 | 2021-05-21T10:04:07.000Z | 2021-05-21T10:04:07.000Z | #include <lingx/core/path.h>
namespace lnx {
Path Path::parent_path() const
{
std::string path = path_;
size_t pos = path_.rfind(Separator);
if (pos == std::string::npos)
return Path("");
while (pos != 0 && path_[pos] == Separator)
--pos;
return Path(path_.substr(0, pos + 1));
}
void Path::Tail_separator(std::string& path)
{
if (!path.empty() && path.back() != Separator)
path += Separator;
}
std::string Path::Get_full_name(const std::string& prefix,
const std::string& name)
{
if (name.c_str()[0] == Separator)
return name;
std::string fullname = prefix;
Tail_separator(fullname);
fullname += name;
return fullname;
}
}
| 19.025641 | 58 | 0.576819 | chrisxjzhu |
38685c15ac073f376d10a12e9c1ded8f7eaf85dd | 1,395 | cpp | C++ | backtracking/knight_tour.cpp | kashyap99saksham/Code | 96658d0920eb79c007701d2a3cc9dbf453d78f96 | [
"MIT"
] | 16 | 2020-06-02T19:22:45.000Z | 2022-02-05T10:35:28.000Z | backtracking/knight_tour.cpp | codezoned/Code | de91ffc7ef06812a31464fb40358e2436734574c | [
"MIT"
] | null | null | null | backtracking/knight_tour.cpp | codezoned/Code | de91ffc7ef06812a31464fb40358e2436734574c | [
"MIT"
] | 2 | 2020-08-27T17:40:06.000Z | 2022-02-05T10:33:52.000Z | #include <bits/stdc++.h>
using namespace std;
#define N 8
int isSafe(int x, int y, int sol[N][N]){
return (x >= 0 && x < N && y >= 0 && y < N && sol[x][y] == -1);
}
void printSolution(int sol[N][N]){
for(int x = 0; x < N; x++){
for (int y = 0; y < N; y++)
cout<<sol[x][y]<<" ";
cout<< endl;
}
}
int solveKT(int x, int y, int movei,int sol[N][N], int xMove[N],int yMove[N]){
int k, next_x, next_y;
if (movei == N*N)
return 1;
// Try all next moves from the current coordinate x, y
for (k = 0; k < 8; k++)
{
next_x = x + xMove[k];
next_y = y + yMove[k];
if (isSafe(next_x, next_y, sol)){
sol[next_x][next_y] = movei;
if (solveKT(next_x, next_y,movei + 1, sol,xMove, yMove) == 1)
return 1;
else sol[next_x][next_y] = -1; // backtrack
}
}
return 0;
}
int main(){
int sol[N][N];
memset(sol, -1, sizeof(sol));
// xMove[] and yMove[] define next move of Knight
// xMove[] is for next value of x coordinate
// yMove[] is for next value of y coordinate */
int xMove[8] = { 2, 1, -1, -2, -2, -1, 1, 2 };
int yMove[8] = { 1, 2, 2, 1, -1, -2, -2, -1 };
// Since the Knight is initially at the first block
sol[0][0] = 0;
// Start from 0,0 and explore all tours using solveKT
if (solveKT(0, 0, 1, sol, xMove, yMove) == 0){ // <x, y, move number, output, xmoves, ymoves>
cout << "Solution does not exist";
}
else printSolution(sol);
}
| 22.5 | 95 | 0.566308 | kashyap99saksham |
386e5c3806e7291df6367a1e3b47f4353e6aa0e2 | 408 | cpp | C++ | cpp/src/dp/util/error.cpp | robotalks/think | a734a6496b796e4e4435cc9214e6ede9847dc3c3 | [
"MIT"
] | null | null | null | cpp/src/dp/util/error.cpp | robotalks/think | a734a6496b796e4e4435cc9214e6ede9847dc3c3 | [
"MIT"
] | null | null | null | cpp/src/dp/util/error.cpp | robotalks/think | a734a6496b796e4e4435cc9214e6ede9847dc3c3 | [
"MIT"
] | null | null | null | #include <unistd.h>
#include <errno.h>
#include <cstring>
#include "dp/util/error.h"
namespace dp {
using namespace std;
string _error_msg_at(const char* fn, int line, const string& prefix) {
char loc[32], buf[32];
sprintf(loc, ":%d: ", line);
sprintf(buf, ": (%d) ", errno);
return string(fn) + string(loc) + prefix + string(buf) + string(strerror(errno));
}
}
| 25.5 | 89 | 0.598039 | robotalks |
386f282e2d117fda6f6fa0f7193db7d3459fe6c8 | 13,700 | cpp | C++ | Source/Core/GL/GLExtensions.cpp | nathanlink169/3D-Shaders-Test | 2493fb71664d75100fbb4a80ac70f657a189593d | [
"MIT"
] | null | null | null | Source/Core/GL/GLExtensions.cpp | nathanlink169/3D-Shaders-Test | 2493fb71664d75100fbb4a80ac70f657a189593d | [
"MIT"
] | null | null | null | Source/Core/GL/GLExtensions.cpp | nathanlink169/3D-Shaders-Test | 2493fb71664d75100fbb4a80ac70f657a189593d | [
"MIT"
] | null | null | null | #include "CommonHeader.h"
#pragma warning(push)
#pragma warning(disable:4191) // unsafe conversion from 'type of expression' to 'type required'
PFNGLUNIFORM1FPROC glUniform1f = 0;
PFNGLUNIFORM2FPROC glUniform2f = 0;
PFNGLUNIFORM3FPROC glUniform3f = 0;
PFNGLUNIFORM4FPROC glUniform4f = 0;
PFNGLUNIFORM1IPROC glUniform1i = 0;
PFNGLUNIFORM2IPROC glUniform2i = 0;
PFNGLUNIFORM3IPROC glUniform3i = 0;
PFNGLUNIFORM4IPROC glUniform4i = 0;
PFNGLUNIFORM1FVPROC glUniform1fv = 0;
PFNGLUNIFORM2FVPROC glUniform2fv = 0;
PFNGLUNIFORM3FVPROC glUniform3fv = 0;
PFNGLUNIFORM4FVPROC glUniform4fv = 0;
PFNGLUNIFORM1IVPROC glUniform1iv = 0;
PFNGLUNIFORM2IVPROC glUniform2iv = 0;
PFNGLUNIFORM3IVPROC glUniform3iv = 0;
PFNGLUNIFORM4IVPROC glUniform4iv = 0;
PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv = 0;
PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f = 0;
PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f = 0;
PFNGLVERTEXATTRIB3FPROC glVertexAttrib3f = 0;
PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f = 0;
PFNGLVERTEXATTRIB1FVPROC glVertexAttrib1fv = 0;
PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv = 0;
PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv = 0;
PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv = 0;
PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = 0;
PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation = 0;
PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = 0;
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = 0;
PFNGLCREATESHADERPROC glCreateShader = 0;
PFNGLSHADERSOURCEPROC glShaderSource = 0;
PFNGLCOMPILESHADERPROC glCompileShader = 0;
PFNGLCREATEPROGRAMPROC glCreateProgram = 0;
PFNGLATTACHSHADERPROC glAttachShader = 0;
PFNGLLINKPROGRAMPROC glLinkProgram = 0;
PFNGLDETACHSHADERPROC glDetachShader = 0;
PFNGLDELETEPROGRAMPROC glDeleteProgram = 0;
PFNGLDELETESHADERPROC glDeleteShader = 0;
PFNGLUSEPROGRAMPROC glUseProgram = 0;
PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation = 0;
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog = 0;
PFNGLGETPROGRAMIVPROC glGetProgramiv = 0;
PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog = 0;
PFNGLGETSHADERSOURCEPROC glGetShaderSource = 0;
PFNGLGETSHADERIVPROC glGetShaderiv = 0;
PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation = 0;
PFNGLACTIVETEXTUREPROC glActiveTexture = 0;
PFNGLGENBUFFERSPROC glGenBuffers = 0;
PFNGLBINDBUFFERPROC glBindBuffer = 0;
PFNGLBUFFERDATAPROC glBufferData = 0;
PFNGLBUFFERSUBDATAPROC glBufferSubData = 0;
PFNGLDELETEBUFFERSPROC glDeleteBuffers = 0;
PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = 0;
PFNGLBLENDCOLORPROC glBlendColor = 0;
PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers = 0;
PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers = 0;
PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer = 0;
PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D = 0;
PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus = 0;
PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers = 0;
PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer = 0;
PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer = 0;
PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage = 0;
PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers = 0;
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays = 0;
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays = 0;
PFNGLBINDVERTEXARRAYPROC glBindVertexArray = 0;
PFNGLGENERATEMIPMAPPROC glGenerateMipmap = 0;
void OpenGL_InitExtensions()
{
glUniform1i = (PFNGLUNIFORM1IPROC) wglGetProcAddress( "glUniform1i" );
glUniform2i = (PFNGLUNIFORM2IPROC) wglGetProcAddress( "glUniform2i" );
glUniform3i = (PFNGLUNIFORM3IPROC) wglGetProcAddress( "glUniform3i" );
glUniform4i = (PFNGLUNIFORM4IPROC) wglGetProcAddress( "glUniform4i" );
glUniform1iv = (PFNGLUNIFORM1IVPROC) wglGetProcAddress( "glUniform1iv" );
glUniform2iv = (PFNGLUNIFORM2IVPROC) wglGetProcAddress( "glUniform2iv" );
glUniform3iv = (PFNGLUNIFORM3IVPROC) wglGetProcAddress( "glUniform3iv" );
glUniform4iv = (PFNGLUNIFORM4IVPROC) wglGetProcAddress( "glUniform4iv" );
glUniform1f = (PFNGLUNIFORM1FPROC) wglGetProcAddress( "glUniform1f" );
glUniform2f = (PFNGLUNIFORM2FPROC) wglGetProcAddress( "glUniform2f" );
glUniform3f = (PFNGLUNIFORM3FPROC) wglGetProcAddress( "glUniform3f" );
glUniform4f = (PFNGLUNIFORM4FPROC) wglGetProcAddress( "glUniform4f" );
glUniform1fv = (PFNGLUNIFORM1FVPROC) wglGetProcAddress( "glUniform1fv" );
glUniform2fv = (PFNGLUNIFORM2FVPROC) wglGetProcAddress( "glUniform2fv" );
glUniform3fv = (PFNGLUNIFORM3FVPROC) wglGetProcAddress( "glUniform3fv" );
glUniform4fv = (PFNGLUNIFORM4FVPROC) wglGetProcAddress( "glUniform4fv" );
glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) wglGetProcAddress( "glUniformMatrix4fv" );
glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC) wglGetProcAddress( "glVertexAttrib1f" );
glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC) wglGetProcAddress( "glVertexAttrib2f" );
glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC) wglGetProcAddress( "glVertexAttrib3f" );
glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC) wglGetProcAddress( "glVertexAttrib4f" );
glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC) wglGetProcAddress( "glVertexAttrib1fv" );
glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC) wglGetProcAddress( "glVertexAttrib2fv" );
glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC) wglGetProcAddress( "glVertexAttrib3fv" );
glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC) wglGetProcAddress( "glVertexAttrib4fv" );
glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) wglGetProcAddress( "glEnableVertexAttribArray" );
glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) wglGetProcAddress( "glBindAttribLocation" );
glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) wglGetProcAddress( "glDisableVertexAttribArray" );
glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) wglGetProcAddress( "glVertexAttribPointer" );
glCreateShader = (PFNGLCREATESHADERPROC) wglGetProcAddress( "glCreateShader" );
glShaderSource = (PFNGLSHADERSOURCEPROC) wglGetProcAddress( "glShaderSource" );
glCompileShader = (PFNGLCOMPILESHADERPROC) wglGetProcAddress( "glCompileShader" );
glCreateProgram = (PFNGLCREATEPROGRAMPROC) wglGetProcAddress( "glCreateProgram" );
glAttachShader = (PFNGLATTACHSHADERPROC) wglGetProcAddress( "glAttachShader" );
glLinkProgram = (PFNGLLINKPROGRAMPROC) wglGetProcAddress( "glLinkProgram" );
glDetachShader = (PFNGLDETACHSHADERPROC) wglGetProcAddress( "glDetachShader" );
glDeleteShader = (PFNGLDELETESHADERPROC) wglGetProcAddress( "glDeleteShader" );
glDeleteProgram = (PFNGLDELETEPROGRAMPROC) wglGetProcAddress( "glDeleteProgram" );
glUseProgram = (PFNGLUSEPROGRAMPROC) wglGetProcAddress( "glUseProgram" );
glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) wglGetProcAddress( "glGetAttribLocation" );
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) wglGetProcAddress( "glGetProgramInfoLog" );
glGetProgramiv = (PFNGLGETPROGRAMIVPROC) wglGetProcAddress( "glGetProgramiv" );
glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) wglGetProcAddress( "glGetShaderInfoLog" );
glGetShaderSource = (PFNGLGETSHADERSOURCEPROC) wglGetProcAddress( "glShaderSource" );
glGetShaderiv = (PFNGLGETSHADERIVPROC) wglGetProcAddress( "glGetShaderiv" );
glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) wglGetProcAddress( "glGetUniformLocation" );
glActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress( "glActiveTexture" );
glGenBuffers = (PFNGLGENBUFFERSPROC) wglGetProcAddress( "glGenBuffers" );
glBindBuffer = (PFNGLBINDBUFFERPROC) wglGetProcAddress( "glBindBuffer" );
glBufferData = (PFNGLBUFFERDATAPROC) wglGetProcAddress( "glBufferData" );
glBufferSubData = (PFNGLBUFFERSUBDATAPROC) wglGetProcAddress( "glBufferSubData" );
glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) wglGetProcAddress( "glDeleteBuffers" );
glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) wglGetProcAddress( "glBlendFuncSeparate" );
glBlendColor = (PFNGLBLENDCOLORPROC) wglGetProcAddress( "glBlendColor" );
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress( "glDeleteFramebuffers" );
if( glDeleteFramebuffers == 0 )
glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) wglGetProcAddress( "glDeleteFramebuffersEXT" );
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress( "glGenFramebuffers" );
if( glGenFramebuffers == 0 )
glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) wglGetProcAddress( "glGenFramebuffersEXT" );
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress( "glBindFramebuffer" );
if( glBindFramebuffer == 0 )
glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) wglGetProcAddress( "glBindFramebufferEXT" );
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress( "glFramebufferTexture2D" );
if( glFramebufferTexture2D == 0 )
glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) wglGetProcAddress( "glFramebufferTexture2DEXT" );
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress( "glCheckFramebufferStatus" );
if( glCheckFramebufferStatus == 0 )
glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) wglGetProcAddress( "glCheckFramebufferStatusEXT" );
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress( "glGenRenderbuffers" );
if( glGenRenderbuffers == 0 )
glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) wglGetProcAddress( "glGenRenderbuffersEXT" );
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress( "glBindRenderbuffer" );
if( glBindRenderbuffer == 0 )
glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) wglGetProcAddress( "glBindRenderbufferEXT" );
glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress( "glFramebufferRenderbuffer" );
if( glFramebufferRenderbuffer == 0 )
glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) wglGetProcAddress( "glFramebufferRenderbufferEXT" );
glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress( "glRenderbufferStorage" );
if( glRenderbufferStorage == 0 )
glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) wglGetProcAddress( "glRenderbufferStorageEXT" );
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress( "glDeleteRenderbuffers" );
if( glDeleteRenderbuffers == 0 )
glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) wglGetProcAddress( "glDeleteRenderbuffersEXT" );
glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) wglGetProcAddress( "glGenVertexArrays" );
glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) wglGetProcAddress( "glDeleteVertexArrays" );
glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) wglGetProcAddress( "glBindVertexArray" );
glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) wglGetProcAddress( "glGenerateMipmap" );
}
#pragma warning(pop)
| 69.543147 | 128 | 0.641752 | nathanlink169 |
386fbb5ebfeb5c64fc380fef5c0fd62cf9cc7afe | 2,520 | cc | C++ | DomainSymbolicPlanner/smartsoft/src-gen/DomainSymbolicPlanner/CommSymbolicPlannerRequestACE.cc | canonical-robots/DomainModelsRepositories | 68b9286d84837e5feb7b200833b158ab9c2922a4 | [
"BSD-3-Clause"
] | null | null | null | DomainSymbolicPlanner/smartsoft/src-gen/DomainSymbolicPlanner/CommSymbolicPlannerRequestACE.cc | canonical-robots/DomainModelsRepositories | 68b9286d84837e5feb7b200833b158ab9c2922a4 | [
"BSD-3-Clause"
] | 2 | 2020-08-20T14:49:47.000Z | 2020-10-07T16:10:07.000Z | DomainSymbolicPlanner/smartsoft/src-gen/DomainSymbolicPlanner/CommSymbolicPlannerRequestACE.cc | canonical-robots/DomainModelsRepositories | 68b9286d84837e5feb7b200833b158ab9c2922a4 | [
"BSD-3-Clause"
] | 8 | 2018-06-25T08:41:28.000Z | 2020-08-13T10:39:30.000Z | //--------------------------------------------------------------------------
// Code generated by the SmartSoft MDSD Toolchain
// The SmartSoft Toolchain has been developed by:
//
// Service Robotics Research Center
// University of Applied Sciences Ulm
// Prittwitzstr. 10
// 89075 Ulm (Germany)
//
// Information about the SmartSoft MDSD Toolchain is available at:
// www.servicerobotik-ulm.de
//
// Please do not modify this file. It will be re-generated
// running the code generator.
//--------------------------------------------------------------------------
#include "DomainSymbolicPlanner/CommSymbolicPlannerRequestACE.hh"
#include <ace/SString.h>
// serialization operator for element CommSymbolicPlannerRequest
ACE_CDR::Boolean operator<<(ACE_OutputCDR &cdr, const DomainSymbolicPlannerIDL::CommSymbolicPlannerRequest &data)
{
ACE_CDR::Boolean good_bit = true;
// serialize list-element plannertype
good_bit = good_bit && cdr << ACE_CString(data.plannertype.c_str());
// serialize list-element domaindescription
good_bit = good_bit && cdr << ACE_CString(data.domaindescription.c_str());
// serialize list-element factdescription
good_bit = good_bit && cdr << ACE_CString(data.factdescription.c_str());
return good_bit;
}
// de-serialization operator for element CommSymbolicPlannerRequest
ACE_CDR::Boolean operator>>(ACE_InputCDR &cdr, DomainSymbolicPlannerIDL::CommSymbolicPlannerRequest &data)
{
ACE_CDR::Boolean good_bit = true;
// deserialize string-type element plannertype
ACE_CString data_plannertype_str;
good_bit = good_bit && cdr >> data_plannertype_str;
data.plannertype = data_plannertype_str.c_str();
// deserialize string-type element domaindescription
ACE_CString data_domaindescription_str;
good_bit = good_bit && cdr >> data_domaindescription_str;
data.domaindescription = data_domaindescription_str.c_str();
// deserialize string-type element factdescription
ACE_CString data_factdescription_str;
good_bit = good_bit && cdr >> data_factdescription_str;
data.factdescription = data_factdescription_str.c_str();
return good_bit;
}
// serialization operator for CommunicationObject CommSymbolicPlannerRequest
ACE_CDR::Boolean operator<<(ACE_OutputCDR &cdr, const DomainSymbolicPlanner::CommSymbolicPlannerRequest &obj)
{
return cdr << obj.get();
}
// de-serialization operator for CommunicationObject CommSymbolicPlannerRequest
ACE_CDR::Boolean operator>>(ACE_InputCDR &cdr, DomainSymbolicPlanner::CommSymbolicPlannerRequest &obj)
{
return cdr >> obj.set();
}
| 39.375 | 113 | 0.746429 | canonical-robots |
3873f9366bb3c16c9822e7719cbbe25903449864 | 14,817 | cpp | C++ | OpenCLExample/DeviceQuery.cpp | zwakrim/mastethesis | c687e2389dbb81f50066aef881076161aa3079b9 | [
"MIT"
] | null | null | null | OpenCLExample/DeviceQuery.cpp | zwakrim/mastethesis | c687e2389dbb81f50066aef881076161aa3079b9 | [
"MIT"
] | null | null | null | OpenCLExample/DeviceQuery.cpp | zwakrim/mastethesis | c687e2389dbb81f50066aef881076161aa3079b9 | [
"MIT"
] | null | null | null | #include <exception>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#define __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>
const bool DEBUG = false;
using namespace std;
const char *readableStatus(cl_int status);
void showPlatformAndDeviceInfo(const cl::Platform& platform, int platform_id, const cl::Device& device, int device_id)
{
std::string platformName, platformVendor, platformProfile, platformVersion, platformExtensions;
platform.getInfo(CL_PLATFORM_NAME, &platformName);
platform.getInfo(CL_PLATFORM_VENDOR, &platformVendor);
platform.getInfo(CL_PLATFORM_PROFILE, &platformProfile);
platform.getInfo(CL_PLATFORM_VERSION, &platformVersion);
platform.getInfo(CL_PLATFORM_EXTENSIONS, &platformExtensions);
std::cout << "Platform " << platform_id << std::endl;
std::cout << " Name: " << platformName << std::endl;
std::cout << " Vendor: " << platformVendor << std::endl;
std::cout << " Profile: " << platformProfile << std::endl;
std::cout << " Version: " << platformVersion << std::endl;
std::cout << std::endl;
std::string deviceName, openCLCVersion, openCLExtensions;
size_t image2dMaxHeight, image2dMaxWidth;
size_t image3dMaxDepth, image3dMaxHeight, image3dMaxWidth;
size_t maxWorkGroupSize, timerResolution;
cl_ulong maxSize, localMemSize;
cl_uint nativeVectorWidthFloat, clockFrequency;
device.getInfo<std::string>(CL_DEVICE_NAME, &deviceName);
device.getInfo<std::string>(CL_DEVICE_OPENCL_C_VERSION, &openCLCVersion);
device.getInfo<std::string>(CL_DEVICE_EXTENSIONS, &openCLExtensions);
device.getInfo<cl_ulong>(CL_DEVICE_MAX_MEM_ALLOC_SIZE, &maxSize);
//device.getInfo<size_t>(CL_DEVICE_IMAGE2D_MAX_HEIGHT, &image2dMaxHeight);
//device.getInfo<size_t>(CL_DEVICE_IMAGE2D_MAX_WIDTH, &image2dMaxWidth);
//device.getInfo<size_t>(CL_DEVICE_IMAGE3D_MAX_DEPTH, &image3dMaxDepth);
//device.getInfo<size_t>(CL_DEVICE_IMAGE3D_MAX_HEIGHT, &image3dMaxHeight);
//device.getInfo<size_t>(CL_DEVICE_IMAGE3D_MAX_WIDTH, &image3dMaxWidth);
device.getInfo<cl_ulong>(CL_DEVICE_LOCAL_MEM_SIZE, &localMemSize);
device.getInfo<size_t>(CL_DEVICE_MAX_WORK_GROUP_SIZE, &maxWorkGroupSize);
device.getInfo<cl_uint>(CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, &nativeVectorWidthFloat);
device.getInfo<size_t>(CL_DEVICE_PROFILING_TIMER_RESOLUTION, &timerResolution);
device.getInfo<cl_uint>(CL_DEVICE_MAX_CLOCK_FREQUENCY, &clockFrequency);
std::cout << " Device " << device_id << std::endl;
std::cout << " Name : " << deviceName << std::endl;
std::cout << " OpenCL C Version : " << openCLCVersion << std::endl;
//std::cout << " 2D Image limits : "
// << image2dMaxHeight << "x" << image2dMaxWidth << std::endl;
//std::cout << " 3D Image limits : "
// << image3dMaxDepth << "x" << image3dMaxHeight << "x"
// << image2dMaxWidth << std::endl;
std::cout << " Maximum buffer size [MB]: "
<< maxSize/(1024*1024) << std::endl;
std::cout << " Local memory size [KB] : "
<< localMemSize/1024 << std::endl;
std::cout << " Maximum workgroup size : " << maxWorkGroupSize << std::endl;
std::cout << " Native vector width : " << nativeVectorWidthFloat << std::endl;
std::cout << " Timer resolution : " << timerResolution << std::endl;
std::cout << " Clock frequency : " << clockFrequency << std::endl;
std::cout << std::endl;
}
void showDevice(const cl::Device& device, int i)
{
std::string deviceName, openCLCVersion, openCLExtensions;
size_t image2dMaxHeight, image2dMaxWidth;
size_t image3dMaxDepth, image3dMaxHeight, image3dMaxWidth;
size_t maxWorkGroupSize, timerResolution;
cl_ulong maxSize, localMemSize;
cl_uint nbrComputeUnits, nativeVectorWidthFloat, clockFrequency;
device.getInfo<std::string>(CL_DEVICE_NAME, &deviceName);
device.getInfo<cl_uint>(CL_DEVICE_MAX_COMPUTE_UNITS, &nbrComputeUnits);
device.getInfo<std::string>(CL_DEVICE_OPENCL_C_VERSION, &openCLCVersion);
device.getInfo<std::string>(CL_DEVICE_EXTENSIONS, &openCLExtensions);
device.getInfo<cl_ulong>(CL_DEVICE_MAX_MEM_ALLOC_SIZE, &maxSize);
device.getInfo<size_t>(CL_DEVICE_IMAGE2D_MAX_HEIGHT, &image2dMaxHeight);
device.getInfo<size_t>(CL_DEVICE_IMAGE2D_MAX_WIDTH, &image2dMaxWidth);
device.getInfo<size_t>(CL_DEVICE_IMAGE3D_MAX_DEPTH, &image3dMaxDepth);
device.getInfo<size_t>(CL_DEVICE_IMAGE3D_MAX_HEIGHT, &image3dMaxHeight);
device.getInfo<size_t>(CL_DEVICE_IMAGE3D_MAX_WIDTH, &image3dMaxWidth);
device.getInfo<cl_ulong>(CL_DEVICE_LOCAL_MEM_SIZE, &localMemSize);
device.getInfo<size_t>(CL_DEVICE_MAX_WORK_GROUP_SIZE, &maxWorkGroupSize);
device.getInfo<cl_uint>(CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, &nativeVectorWidthFloat);
device.getInfo<size_t>(CL_DEVICE_PROFILING_TIMER_RESOLUTION, &timerResolution);
device.getInfo<cl_uint>(CL_DEVICE_MAX_CLOCK_FREQUENCY, &clockFrequency);
std::cout << " Device: " << i << std::endl;
std::cout << " Name : " << deviceName << std::endl;
std::cout << " OpenCL C Version : " << openCLCVersion << std::endl;
std::cout << " #Compute Units (cores) : " << nbrComputeUnits << std::endl;
std::cout << " Native vector width : " << nativeVectorWidthFloat << std::endl;
std::cout << " 2D Image limits : " << image2dMaxHeight << "x" << image2dMaxWidth << std::endl;
std::cout << " 3D Image limits : " << image3dMaxDepth << "x" << image3dMaxHeight << "x" << image2dMaxWidth << std::endl;
std::cout << " Maximum buffer size [MB]: " << maxSize / (1024 * 1024) << std::endl;
std::cout << " Local memory size [KB] : " << localMemSize / 1024 << std::endl;
std::cout << " Maximum workgroup size : " << maxWorkGroupSize << std::endl;
std::cout << " Timer resolution : " << timerResolution << std::endl;
std::cout << " Clock frequency : " << clockFrequency << std::endl;
std::cout << std::endl;
}
void showPlatform(const cl::Platform& platform, int i)
{
std::string platformName, platformVendor, platformProfile, platformVersion, platformExtensions;
platform.getInfo(CL_PLATFORM_NAME, &platformName);
platform.getInfo(CL_PLATFORM_VENDOR, &platformVendor);
platform.getInfo(CL_PLATFORM_PROFILE, &platformProfile);
platform.getInfo(CL_PLATFORM_VERSION, &platformVersion);
platform.getInfo(CL_PLATFORM_EXTENSIONS, &platformExtensions);
std::cout << "Platform " << i << std::endl;
std::cout << " Name: " << platformName << std::endl;
std::cout << " Vendor: " << platformVendor << std::endl;
std::cout << " Profile: " << platformProfile << std::endl;
std::cout << " Version: " << platformVersion << std::endl;
std::cout << std::endl;
std::vector<cl::Device> devices;
platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);
for (int i = 0; i < devices.size(); ++i) {
showDevice(devices[i], i);
}
}
void showAllOpenCLDevices()
{
try {
std::vector<cl::Platform> platforms;
std::vector<cl::Device> devices;
cl::Platform::get(&platforms);
for (int i = 0; i < platforms.size(); ++i) {
showPlatform(platforms[i], i);
}
}
catch (cl::Error &e) {
std::cerr << e.what() << ":" << readableStatus(e.err());
return;
}
catch (std::exception& e) {
std::cerr << e.what();
return;
}
catch (...) {
std::cerr << "Unforeseen error";
return;
}
//cout << endl << "Press ENTER to close window...";
//char c = cin.get();
}
void showAllGPUs() {
try {
std::vector<cl::Platform> platforms;
std::vector<cl::Device> devices;
cl::Platform::get(&platforms);
for (int i = 0; i < platforms.size(); ++i) {
cl::Platform platform = platforms[i];
std::string platformName, platformVendor;
platform.getInfo(CL_PLATFORM_NAME, &platformName);
platform.getInfo(CL_PLATFORM_VENDOR, &platformVendor);
std::vector<cl::Device> devices;
platform.getDevices(CL_DEVICE_TYPE_GPU, &devices);
for (int j = 0; j < devices.size(); ++j) {
cl::Device device = devices[j];
std::string deviceName, openCLCVersion, openCLExtensions;
size_t maxWorkGroupSize, timerResolution;
cl_ulong maxSize, localMemSize;
cl_uint nativeVectorWidthFloat, clockFrequency, nbrComputeUnits;
device.getInfo<std::string>(CL_DEVICE_NAME, &deviceName);
device.getInfo<std::string>(CL_DEVICE_OPENCL_C_VERSION, &openCLCVersion);
device.getInfo<std::string>(CL_DEVICE_EXTENSIONS, &openCLExtensions);
device.getInfo<cl_ulong>(CL_DEVICE_MAX_MEM_ALLOC_SIZE, &maxSize);
device.getInfo<cl_uint>(CL_DEVICE_MAX_COMPUTE_UNITS, &nbrComputeUnits);
device.getInfo<size_t>(CL_DEVICE_MAX_WORK_GROUP_SIZE, &maxWorkGroupSize);
device.getInfo<cl_uint>(CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, &nativeVectorWidthFloat);
device.getInfo<size_t>(CL_DEVICE_PROFILING_TIMER_RESOLUTION, &timerResolution);
device.getInfo<cl_uint>(CL_DEVICE_MAX_CLOCK_FREQUENCY, &clockFrequency);
std::cout << " - " << deviceName << " on " << platformName<<": " << nbrComputeUnits <<" cores " << clockFrequency <<
"MHz " << " vector width="<< nativeVectorWidthFloat <<std::endl;
//std::cout << " OpenCL C Version :" << openCLCVersion << std::endl;
//std::cout << " Maximum workgroup size :" << maxWorkGroupSize << std::endl;
//std::cout << " Native vector width :" << nativeVectorWidthFloat << std::endl;
//std::cout << " Timer resolution :" << timerResolution << std::endl;
//std::cout << " Clock frequency :" << clockFrequency << std::endl;
//std::cout << std::endl;
}
}
}
catch (cl::Error &e) {
std::cerr << e.what() << ":" << readableStatus(e.err());
return;
}
catch (std::exception& e) {
std::cerr << e.what();
return;
}
catch (...) {
std::cerr << "Unforeseen error";
return;
}
}
int numberPlatforms() {
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
return platforms.size();
}
int numberDevices(int platformID) {
std::vector<cl::Platform> platforms;
std::vector<cl::Device> devices;
cl::Platform::get(&platforms);
if (platformID >= platforms.size() || platformID < 0)
return 0;
platforms[platformID].getDevices(CL_DEVICE_TYPE_ALL, &devices);
return devices.size();
}
string deviceName(int platformID, int deviceID) {
std::vector<cl::Platform> platforms;
std::vector<cl::Device> devices;
cl::Platform::get(&platforms);
if (platformID >= platforms.size() || platformID < 0)
return string("");
platforms[platformID].getDevices(CL_DEVICE_TYPE_ALL, &devices);
if (deviceID >= devices.size() || deviceID < 0)
return string("");
cl::Device device = devices[deviceID];
std::string deviceName;
device.getInfo<std::string>(CL_DEVICE_NAME, &deviceName);
return deviceName;
}
const char *readableStatus(cl_int status)
{
switch (status) {
case CL_SUCCESS:
return "CL_SUCCESS";
case CL_DEVICE_NOT_FOUND:
return "CL_DEVICE_NOT_FOUND";
case CL_DEVICE_NOT_AVAILABLE:
return "CL_DEVICE_NOT_AVAILABLE";
case CL_COMPILER_NOT_AVAILABLE:
return "CL_COMPILER_NOT_AVAILABLE";
case CL_MEM_OBJECT_ALLOCATION_FAILURE:
return "CL_COMPILER_NOT_AVAILABLE";
case CL_OUT_OF_RESOURCES:
return "CL_OUT_OF_RESOURCES";
case CL_OUT_OF_HOST_MEMORY:
return "CL_OUT_OF_HOST_MEMORY";
case CL_PROFILING_INFO_NOT_AVAILABLE:
return "CL_PROFILING_INFO_NOT_AVAILABLE";
case CL_MEM_COPY_OVERLAP:
return "CL_MEM_COPY_OVERLAP";
case CL_IMAGE_FORMAT_MISMATCH:
return "CL_IMAGE_FORMAT_MISMATCH";
case CL_IMAGE_FORMAT_NOT_SUPPORTED:
return "CL_IMAGE_FORMAT_NOT_SUPPORTED";
case CL_BUILD_PROGRAM_FAILURE:
return "CL_BUILD_PROGRAM_FAILURE";
case CL_MAP_FAILURE:
return "CL_MAP_FAILURE";
#ifndef CL_VERSION_1_0
case CL_MISALIGNED_SUB_BUFFER_OFFSET:
return "CL_MISALIGNED_SUB_BUFFER_OFFSET";
case CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST:
return "CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST";
#endif
case CL_INVALID_VALUE:
return "CL_INVALID_VALUE";
case CL_INVALID_DEVICE_TYPE:
return "CL_INVALID_DEVICE_TYPE";
case CL_INVALID_PLATFORM:
return "CL_INVALID_PLATFORM";
case CL_INVALID_DEVICE:
return "CL_INVALID_DEVICE";
case CL_INVALID_CONTEXT:
return "CL_INVALID_CONTEXT";
case CL_INVALID_QUEUE_PROPERTIES:
return "CL_INVALID_QUEUE_PROPERTIES";
case CL_INVALID_COMMAND_QUEUE:
return "CL_INVALID_COMMAND_QUEUE";
case CL_INVALID_HOST_PTR:
return "CL_INVALID_HOST_PTR";
case CL_INVALID_MEM_OBJECT:
return "CL_INVALID_MEM_OBJECT";
case CL_INVALID_IMAGE_FORMAT_DESCRIPTOR:
return "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR";
case CL_INVALID_IMAGE_SIZE:
return "CL_INVALID_IMAGE_SIZE";
case CL_INVALID_SAMPLER:
return "CL_INVALID_SAMPLER";
case CL_INVALID_BINARY:
return "CL_INVALID_BINARY";
case CL_INVALID_BUILD_OPTIONS:
return "CL_INVALID_BUILD_OPTIONS";
case CL_INVALID_PROGRAM:
return "CL_INVALID_PROGRAM";
case CL_INVALID_PROGRAM_EXECUTABLE:
return "CL_INVALID_PROGRAM_EXECUTABLE";
case CL_INVALID_KERNEL_NAME:
return "CL_INVALID_KERNEL_NAME";
case CL_INVALID_KERNEL_DEFINITION:
return "CL_INVALID_KERNEL_DEFINITION";
case CL_INVALID_KERNEL:
return "CL_INVALID_KERNEL";
case CL_INVALID_ARG_INDEX:
return "CL_INVALID_ARG_INDEX";
case CL_INVALID_ARG_VALUE:
return "CL_INVALID_ARG_VALUE";
case CL_INVALID_ARG_SIZE:
return "CL_INVALID_ARG_SIZE";
case CL_INVALID_KERNEL_ARGS:
return "CL_INVALID_KERNEL_ARGS";
case CL_INVALID_WORK_DIMENSION:
return "CL_INVALID_WORK_DIMENSION";
case CL_INVALID_WORK_GROUP_SIZE:
return "CL_INVALID_WORK_GROUP_SIZE";
case CL_INVALID_WORK_ITEM_SIZE:
return "CL_INVALID_WORK_ITEM_SIZE";
case CL_INVALID_GLOBAL_OFFSET:
return "CL_INVALID_GLOBAL_OFFSET";
case CL_INVALID_EVENT_WAIT_LIST:
return "CL_INVALID_EVENT_WAIT_LIST";
case CL_INVALID_EVENT:
return "CL_INVALID_EVENT";
case CL_INVALID_OPERATION:
return "CL_INVALID_OPERATION";
case CL_INVALID_GL_OBJECT:
return "CL_INVALID_GL_OBJECT";
case CL_INVALID_BUFFER_SIZE:
return "CL_INVALID_BUFFER_SIZE";
case CL_INVALID_MIP_LEVEL:
return "CL_INVALID_MIP_LEVEL";
case CL_INVALID_GLOBAL_WORK_SIZE:
return "CL_INVALID_GLOBAL_WORK_SIZE";
#ifndef CL_VERSION_1_0
case CL_INVALID_PROPERTY:
return "CL_INVALID_PROPERTY";
#endif
default:
return "CL_UNKNOWN_CODE";
}
}
| 40.373297 | 137 | 0.694878 | zwakrim |
3874d625e2a08fbb3cf47c2c74870600372192f4 | 537 | cpp | C++ | UVa 10918 tri tiling/sample/sol.cpp | tadvi/uva | 0ac0cbdf593879b4fb02a3efc09adbb031cb47d5 | [
"MIT"
] | 1 | 2020-11-24T03:17:21.000Z | 2020-11-24T03:17:21.000Z | UVa 10918 tri tiling/sample/sol.cpp | tadvi/uva | 0ac0cbdf593879b4fb02a3efc09adbb031cb47d5 | [
"MIT"
] | null | null | null | UVa 10918 tri tiling/sample/sol.cpp | tadvi/uva | 0ac0cbdf593879b4fb02a3efc09adbb031cb47d5 | [
"MIT"
] | 1 | 2021-04-11T16:22:31.000Z | 2021-04-11T16:22:31.000Z | #include <stdio.h>
int dp[32];
int solve(int n)
{
if (dp[n] != -1)
return dp[n];
else
{
int i;
int res = 3 * solve(n - 2);
for (i = 4; i <= n; i += 2)
res += 2 * solve(n - i);
return dp[n] = res;
}
}
int main()
{
int i;
for (i = 0; i < 32; i += 2)
dp[i] = -1;
for (i = 1; i < 32; i += 2)
dp[i] = 0;
dp[0] = 1;
scanf("%d", &i);
while (i != -1)
{
printf("%d\n", solve(i));
scanf("%d", &i);
}
return 0;
} | 17.322581 | 36 | 0.346369 | tadvi |
38754964ae7b296390a58f638cfbae82335574bf | 957 | cc | C++ | modificacion/src/complejos.cc | ULL-ESIT-IB-2020-2021/ib-practica12-oop-gtests-exercism-Saul-Sosa-Diaz | f1b8daf92fc55061d8bf73858653d3b336420b03 | [
"MIT"
] | null | null | null | modificacion/src/complejos.cc | ULL-ESIT-IB-2020-2021/ib-practica12-oop-gtests-exercism-Saul-Sosa-Diaz | f1b8daf92fc55061d8bf73858653d3b336420b03 | [
"MIT"
] | null | null | null | modificacion/src/complejos.cc | ULL-ESIT-IB-2020-2021/ib-practica12-oop-gtests-exercism-Saul-Sosa-Diaz | f1b8daf92fc55061d8bf73858653d3b336420b03 | [
"MIT"
] | null | null | null | /**
* Universidad de La Laguna
* Escuela Superior de Ingeniería y Tecnología
* Grado en Ingeniería Informática
* Informática Básica
*
* @author Saúl Sosa
* @date 3.enero.2021
* @brief Calculadora elemental de números complejos
*/
#include "complejo.h"
int main(int argc, char* argv[]){
Usage(argc, argv);//Modo de uso del programa
Complejo complejo1(1,4);
Complejo complejo2(4,-7);
Complejo complejo3 = complejo1 - 7.9;
Complejo complejo4 = complejo1 + 7.9;
std::cout << complejo1 << " - " << complejo2 << " = " << complejo1 - complejo2 << std::endl;
std::cout << complejo1 << " - 7.9 = ";
print(complejo3);
std::cout << std::endl;
std::cout << complejo1 << " + 7.9 = ";
print(complejo4);
std::cout << std::endl;
std::cout << complejo1 << " + " << complejo2 << " = " << complejo1 + complejo2 << std::endl;
std::cout << complejo1 << " * " << complejo2 << " = " << complejo1 * complejo2 << std::endl;
return 0;
} | 29 | 94 | 0.615465 | ULL-ESIT-IB-2020-2021 |
387680f34e028b41512d881e1b37e82dcfc3c12e | 1,543 | cpp | C++ | hardware_layer/hardware_camera/src/gazebo_image_pub.cpp | shubhamkorde/AnahitaPlus | 0fc99ad774640c8dc8572ffb58d10fa18bb1a4b1 | [
"BSD-3-Clause"
] | 5 | 2018-10-22T20:04:24.000Z | 2022-01-04T09:24:46.000Z | hardware_layer/hardware_camera/src/gazebo_image_pub.cpp | shubhamkorde/AnahitaPlus | 0fc99ad774640c8dc8572ffb58d10fa18bb1a4b1 | [
"BSD-3-Clause"
] | 19 | 2018-10-03T12:14:35.000Z | 2019-07-07T09:33:14.000Z | hardware_layer/hardware_camera/src/gazebo_image_pub.cpp | shubhamkorde/AnahitaPlus | 0fc99ad774640c8dc8572ffb58d10fa18bb1a4b1 | [
"BSD-3-Clause"
] | 15 | 2018-09-09T12:35:15.000Z | 2020-01-03T09:28:19.000Z | #include <ros/ros.h>
#include <iostream>
#include <cv_bridge/cv_bridge.h>
#include <image_transport/image_transport.h>
#include <sensor_msgs/image_encodings.h>
#include "sensor_msgs/Image.h"
sensor_msgs::Image front_image;
sensor_msgs::Image bottom_image;
void bottomCB (const sensor_msgs::Image::ConstPtr &msg) {
try
{
bottom_image = *msg;
}
catch (cv_bridge::Exception &e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
}
catch (cv::Exception &e)
{
ROS_ERROR("cv exception: %s", e.what());
}
}
void frontCB (const sensor_msgs::Image::ConstPtr &msg) {
try
{
front_image = *msg;
}
catch (cv_bridge::Exception &e)
{
ROS_ERROR("cv_bridge exception: %s", e.what());
}
catch (cv::Exception &e)
{
ROS_ERROR("cv exception: %s", e.what());
}
}
int main (int argc, char** argv) {
ros::init (argc, argv, "gazebo_camera_pub");
ros::NodeHandle nh;
image_transport::ImageTransport it (nh);
image_transport::Subscriber front_sub = it.subscribe("/rezrov/bottomCamera/image", 1, &bottomCB);
image_transport::Subscriber bottom_sub = it.subscribe("/rezrov/frontCamera/image", 1, &bottomCB);
image_transport::Publisher front_pub = it.advertise("/anahita/front_camera/image_raw", 1);
image_transport::Publisher bottom_pub = it.advertise("/anahita/bottom_camera/image_raw", 1);
ros::Rate loop_rate(20);
while (ros::ok()) {
front_pub.publish (front_image);
bottom_pub.publish (bottom_image);
loop_rate.sleep ();
ros::spinOnce ();
}
return 0;
} | 24.109375 | 101 | 0.679196 | shubhamkorde |
3876b4ce2d04a36444d5a0d33c88120f9f0b064f | 297 | cpp | C++ | sandbox/t_GVectorsGen1.cpp | f-fathurrahman/ffr-pspw-dft-c | 5e673e33385eb467d99fcd992b350614c2709740 | [
"MIT"
] | 1 | 2018-05-17T09:01:12.000Z | 2018-05-17T09:01:12.000Z | sandbox/t_GVectorsGen1.cpp | f-fathurrahman/ffr-pspw-dft-c | 5e673e33385eb467d99fcd992b350614c2709740 | [
"MIT"
] | null | null | null | sandbox/t_GVectorsGen1.cpp | f-fathurrahman/ffr-pspw-dft-c | 5e673e33385eb467d99fcd992b350614c2709740 | [
"MIT"
] | null | null | null | #include "../common_pspw_cuda.h"
void GVectorsGen1();
int main(int argc, char **argv)
{
NR1 = 20; NR2 = 20; NR3 = 20;
GCUT = 88.855355;
B1[0] = 1.0; B1[1] = 0.0; B1[2] = 0.0;
B2[0] = 0.0; B2[1] = 1.0; B2[2] = 0.0;
B3[0] = 0.0; B3[1] = 0.0; B3[2] = 1.0;
GVectorsGen1();
return 0;
}
| 16.5 | 39 | 0.515152 | f-fathurrahman |
38784e4add198bd0ed27fbb555149b3d2778c4e0 | 1,798 | cpp | C++ | src/backtrace/current_stack_frame.cpp | vinzenz/fcppt | 3f8cc5babdee178a9bbd06ca3ce7ad405d19aa6a | [
"BSL-1.0"
] | null | null | null | src/backtrace/current_stack_frame.cpp | vinzenz/fcppt | 3f8cc5babdee178a9bbd06ca3ce7ad405d19aa6a | [
"BSL-1.0"
] | null | null | null | src/backtrace/current_stack_frame.cpp | vinzenz/fcppt | 3f8cc5babdee178a9bbd06ca3ce7ad405d19aa6a | [
"BSL-1.0"
] | null | null | null | // Copyright Carl Philipp Reh 2009 - 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <fcppt/backtrace/current_stack_frame.hpp>
#include <fcppt/backtrace/stack_frame.hpp>
#include <fcppt/backtrace/stack_limit.hpp>
#include <fcppt/private_config.hpp>
#if defined(FCPPT_HAVE_BACKTRACE)
#include <fcppt/make_int_range_count.hpp>
#include <fcppt/unique_ptr.hpp>
#include <fcppt/algorithm/map.hpp>
#include <fcppt/cast/size.hpp>
#include <fcppt/cast/to_signed.hpp>
#include <fcppt/container/raw_vector.hpp>
#include <fcppt/c_deleter.hpp>
#include <fcppt/from_std_string.hpp>
#include <execinfo.h>
#endif
fcppt::backtrace::stack_frame
fcppt::backtrace::current_stack_frame(
backtrace::stack_limit const &
#if defined(FCPPT_HAVE_BACKTRACE)
max
#endif
)
{
#if defined(FCPPT_HAVE_BACKTRACE)
typedef
fcppt::container::raw_vector<
void *
>
symbol_sequence;
symbol_sequence resulting_symbols(
fcppt::cast::size<
symbol_sequence::size_type
>(
max.get()
)
);
int const number_of_symbols(
::backtrace(
resulting_symbols.data(),
fcppt::cast::size<
int
>(
fcppt::cast::to_signed(
max.get()
)
)
)
);
fcppt::unique_ptr<
char *,
fcppt::c_deleter
> raw_symbols(
::backtrace_symbols(
resulting_symbols.data(),
number_of_symbols
)
);
return
fcppt::algorithm::map<
fcppt::backtrace::stack_frame
>(
fcppt::make_int_range_count(
number_of_symbols
),
[
&raw_symbols
](
int const _index
)
{
return
fcppt::from_std_string(
raw_symbols.get_pointer()[
_index
]
);
}
);
#else
return
fcppt::backtrace::stack_frame();
#endif
}
| 18.729167 | 61 | 0.69188 | vinzenz |
387945736d836e3946120fc725e046a12030f210 | 3,072 | cpp | C++ | OpenCV_C++/Programs/Chapter-5~Perspective_Transform_and_Warp_version-II.cpp | Balaji-Ganesh/Furnishing-OpenCV-Basics | 54cd8fa09cc6f1298861b12ffb190432f412bd1f | [
"MIT"
] | null | null | null | OpenCV_C++/Programs/Chapter-5~Perspective_Transform_and_Warp_version-II.cpp | Balaji-Ganesh/Furnishing-OpenCV-Basics | 54cd8fa09cc6f1298861b12ffb190432f412bd1f | [
"MIT"
] | null | null | null | OpenCV_C++/Programs/Chapter-5~Perspective_Transform_and_Warp_version-II.cpp | Balaji-Ganesh/Furnishing-OpenCV-Basics | 54cd8fa09cc6f1298861b12ffb190432f412bd1f | [
"MIT"
] | null | null | null | /*
* This version is a bit improvement to the previous one. In that version, the co-ordinates of the card are
hard-coded.
* This version solves that issue of taking the co-ordinates as "HARD-CODED".
* In this version, a cards image is displayed to the user (Should once look the console for directions)..
* Should select the 4-corners of the card, when done should press "Esc".
Then those selected corners are taken as the points. From here.. as similar to the previous one.
Done on 30th Dec, 2020 and 1st Jan, 2021
*/
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
using namespace cv;
#include <iostream>
using namespace std;
// Global declaration of functions and variables..
void click_events(int mouse_event, int x, int y, int flags, void* param);
int click_count = 0;
float img_width = 250.0f, img_height = 350.0f; // These are the dimensions of the playing_card
cv::Point2f roi_src_pts[4];
string path = "Resources/cards.jpg";
cv::Mat work_img = imread("Resources/cards.jpg");
int main()
{
cv::Mat image = imread(path), perspectivePointsMat, imgWarped;
cv::namedWindow("Image", WINDOW_AUTOSIZE);
cout <<"--- GUIDE --- \nClick the corners of cards in this order:\nTop-Left --> Top-Right --> Bottom-Left --> Bottom right\n When done clicking all 4 corners, press Esc.\n\nREQUEST: Right now, code is not that much optimized to findout the incorrect points and values which are clicked.\n\n";
cv::imshow("Image", work_img);
//cv::MouseCallback(*mouse_click)(int, int, int, int, int) = click_events;
cv::setMouseCallback("Image", click_events, NULL);
if (cv::waitKey(0) == 27)
destroyWindow("Image");
cout << "No. of clicks captured till now are: "<< click_count << endl << endl;
// The target warp points... they should get mapped to..
cv::Point2f dst[4] = { {0.0f, 0.0f}, {img_width, 0.0f}, {0.0f, img_height}, {img_width, img_height} };
// Get the Persepective transform of the src and dst points..
perspectivePointsMat = getPerspectiveTransform(roi_src_pts, dst);
// Get the warped image out of the original image via help of perspectivePointsMat..
warpPerspective(image, imgWarped, perspectivePointsMat, Point(img_width, img_height));
/* -------- -------- --- Display the results ----- ----- ------- */
//cv::imshow("Actual Image", image);
//cv::imshow("Copy Image", work_img);
cv::imshow("Warped Image", imgWarped);
if (cv::waitKey(0) == 27)
destroyAllWindows();
return 0;
}
// Definition for Globally declared functions..
void click_events(int mouse_event, int x, int y, int flags, void* param)
{
//Mat *image = (Mat*)param;
if (mouse_event == EVENT_LBUTTONDOWN && click_count <4)
{
roi_src_pts[click_count++] = Point(x, y); // Place the clicked co=ordinate points in the array for usage in main()
circle(work_img, Point(x, y), 10, Scalar(100, 200, 255), FILLED);
cout << "Left Button Clicked" << endl;
imshow("Image", work_img);
}
//cout << "(" << x << ", " << y << ")";
} | 42.666667 | 294 | 0.678711 | Balaji-Ganesh |
38795cb08411dd8cba123633fe41d9210f15ea4a | 7,783 | cpp | C++ | libs/opengl/src/CGeneralizedEllipsoidTemplate.cpp | feroze/mrpt-shivang | 95bf524c5e10ed2e622bd199f1b0597951b45370 | [
"BSD-3-Clause"
] | 2 | 2017-03-25T18:09:17.000Z | 2017-05-22T08:14:48.000Z | libs/opengl/src/CGeneralizedEllipsoidTemplate.cpp | feroze/mrpt-shivang | 95bf524c5e10ed2e622bd199f1b0597951b45370 | [
"BSD-3-Clause"
] | null | null | null | libs/opengl/src/CGeneralizedEllipsoidTemplate.cpp | feroze/mrpt-shivang | 95bf524c5e10ed2e622bd199f1b0597951b45370 | [
"BSD-3-Clause"
] | 1 | 2018-07-29T09:40:46.000Z | 2018-07-29T09:40:46.000Z | /* +---------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| http://www.mrpt.org/ |
| |
| Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
| See: http://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See details in http://www.mrpt.org/License |
+---------------------------------------------------------------------------+ */
#include "opengl-precomp.h" // Precompiled header
#include <mrpt/opengl/CGeneralizedEllipsoidTemplate.h>
#include <mrpt/opengl/gl_utils.h>
#include "opengl_internals.h"
using namespace mrpt;
using namespace mrpt::opengl;
using namespace mrpt::utils;
using namespace mrpt::math;
using namespace std;
/*---------------------------------------------------------------
Render: 2D implementation
---------------------------------------------------------------*/
namespace mrpt {
namespace opengl {
namespace detail {
template <>
void renderGeneralizedEllipsoidTemplate<2>(
const std::vector<mrpt::math::CMatrixFixedNumeric<float,2,1> > & pts,
const float lineWidth,
const uint32_t slices,
const uint32_t stacks)
{
#if MRPT_HAS_OPENGL_GLUT
glEnable(GL_BLEND); gl_utils::checkOpenGLError();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_utils::checkOpenGLError();
glLineWidth(lineWidth); gl_utils::checkOpenGLError();
glDisable(GL_LIGHTING); // Disable lights when drawing lines
glBegin( GL_LINE_LOOP );
const size_t N = pts.size();
for (size_t i=0;i<N;i++)
glVertex2f( pts[i][0], pts[i][1] );
glEnd();
glEnable(GL_LIGHTING);
glDisable(GL_BLEND);
#else
MRPT_UNUSED_PARAM(pts); MRPT_UNUSED_PARAM(lineWidth); MRPT_UNUSED_PARAM(slices); MRPT_UNUSED_PARAM(stacks);
#endif
}
/*---------------------------------------------------------------
Render: 3D implementation
---------------------------------------------------------------*/
template <>
void renderGeneralizedEllipsoidTemplate<3>(
const std::vector<mrpt::math::CMatrixFixedNumeric<float,3,1> > & pts,
const float lineWidth,
const uint32_t slices,
const uint32_t stacks
)
{
#if MRPT_HAS_OPENGL_GLUT
glEnable(GL_BLEND); gl_utils::checkOpenGLError();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_utils::checkOpenGLError();
glLineWidth(lineWidth); gl_utils::checkOpenGLError();
glDisable(GL_LIGHTING); // Disable lights when drawing lines
// Points in the ellipsoid:
// * "#slices" slices, with "#stacks" points each, but for the two ends
// * 1 point at each end slice
// #total points = stacks*(slices-2) + 2
ASSERT_EQUAL_((slices-2)*stacks+2, pts.size())
const size_t idx_1st_slice = 1;
// 1st slice: triangle fan (if it were solid)
// ----------------------------
glBegin( GL_LINES );
for (size_t i=0;i<stacks;i++)
{
glVertex3fv(&pts[0][0]);
glVertex3fv(&pts[idx_1st_slice+i][0]);
}
glEnd();
// Middle slices: triangle strip (if it were solid)
// ----------------------------
for (size_t s=0;s<slices-3;s++)
{
size_t idx_this_slice = idx_1st_slice + stacks*s;
size_t idx_next_slice = idx_this_slice + stacks;
for (size_t i=0;i<stacks;i++)
{
const size_t ii = (i==(stacks-1) ? 0 : i+1); // next i with wrapping
glBegin( GL_LINE_STRIP );
glVertex3fv(&pts[idx_this_slice+i][0]);
glVertex3fv(&pts[idx_next_slice+ii][0]);
glVertex3fv(&pts[idx_next_slice+i][0]);
glVertex3fv(&pts[idx_this_slice+i][0]);
glVertex3fv(&pts[idx_this_slice+ii][0]);
glVertex3fv(&pts[idx_next_slice+ii][0]);
glEnd();
}
}
// Last slice: triangle fan (if it were solid)
// ----------------------------
const size_t idx_last_pt = pts.size()-1;
const size_t idx_last_slice = idx_1st_slice + (slices-3)*stacks;
glBegin( GL_LINES );
for (size_t i=0;i<stacks;i++)
{
glVertex3fv(&pts[idx_last_pt][0]);
glVertex3fv(&pts[idx_last_slice+i][0]);
}
glEnd();
//glBegin( GL_POINTS );
//const size_t N = pts.size();
//for (size_t i=0;i<N;i++)
// glVertex3f( pts[i][0], pts[i][1], pts[i][2] );
//glEnd();
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
#else
MRPT_UNUSED_PARAM(pts); MRPT_UNUSED_PARAM(lineWidth); MRPT_UNUSED_PARAM(slices); MRPT_UNUSED_PARAM(stacks);
#endif
}
/*---------------------------------------------------------------
generalizedEllipsoidPoints: 2D
---------------------------------------------------------------*/
template <>
void OPENGL_IMPEXP generalizedEllipsoidPoints<2>(
const mrpt::math::CMatrixFixedNumeric<double,2,2> & U,
const mrpt::math::CMatrixFixedNumeric<double,2,1> & mean,
std::vector<mrpt::math::CMatrixFixedNumeric<float,2,1> > &out_params_pts,
const uint32_t numSegments,
const uint32_t numSegments_unused)
{
MRPT_UNUSED_PARAM(numSegments_unused);
out_params_pts.clear();
out_params_pts.reserve(numSegments);
const double Aa = 2*M_PI/numSegments;
for (double ang=0;ang<2*M_PI;ang+=Aa)
{
const double ccos = cos(ang);
const double ssin = sin(ang);
out_params_pts.resize(out_params_pts.size()+1);
Eigen::Matrix<float,2,1> &pt = out_params_pts.back();
pt[0] = mean[0] + ccos * U.get_unsafe(0,0) + ssin * U.get_unsafe(0,1);
pt[1] = mean[1] + ccos * U.get_unsafe(1,0) + ssin * U.get_unsafe(1,1);
}
}
inline
void aux_add3DpointWithEigenVectors(
const double x,
const double y,
const double z,
std::vector<mrpt::math::CMatrixFixedNumeric<float,3,1> > & pts,
const mrpt::math::CMatrixFixedNumeric<double,3,3> & M,
const mrpt::math::CMatrixFixedNumeric<double,3,1> & mean)
{
pts.resize(pts.size()+1);
mrpt::math::CMatrixFixedNumeric<float,3,1> &pt= pts.back();
pt[0] = mean[0] + x * M.get_unsafe(0,0) + y * M.get_unsafe(0,1) + z * M.get_unsafe(0,2);
pt[1] = mean[1] + x * M.get_unsafe(1,0) + y * M.get_unsafe(1,1) + z * M.get_unsafe(1,2);
pt[2] = mean[2] + x * M.get_unsafe(2,0) + y * M.get_unsafe(2,1) + z * M.get_unsafe(2,2);
}
/*---------------------------------------------------------------
generalizedEllipsoidPoints: 3D
---------------------------------------------------------------*/
template <>
void OPENGL_IMPEXP generalizedEllipsoidPoints<3>(
const mrpt::math::CMatrixFixedNumeric<double,3,3> & U,
const mrpt::math::CMatrixFixedNumeric<double,3,1> & mean,
std::vector<mrpt::math::CMatrixFixedNumeric<float,3,1> > & pts,
const uint32_t slices,
const uint32_t stacks)
{
MRPT_START
ASSERT_ABOVEEQ_(slices,3)
ASSERT_ABOVEEQ_(stacks,3)
// sin/cos cache --------
// Slices: [0,pi]
std::vector<double> slice_cos(slices),slice_sin(slices);
for (uint32_t i = 0; i < slices; i++)
{
double angle = M_PI * i / double(slices-1);
slice_sin[i] = sin(angle);
slice_cos[i] = cos(angle);
}
// Stacks: [0,2*pi]
std::vector<double> stack_sin(stacks),stack_cos(stacks);
for (uint32_t i = 0; i < stacks; i++)
{
double angle = 2*M_PI * i / double(stacks);
stack_sin[i] = sin(angle);
stack_cos[i] = cos(angle);
}
// Points in the ellipsoid:
// * "#slices" slices, with "#stacks" points each, but for the two ends
// * 1 point at each end slice
// #total points = stacks*(slices-2) + 2
pts.clear();
pts.reserve((slices-2)*stacks+2);
for (uint32_t i=0;i<slices;i++)
{
if (i==0)
aux_add3DpointWithEigenVectors(1,0,0, pts,U,mean);
else if (i==(slices-1))
aux_add3DpointWithEigenVectors(-1,0,0, pts,U,mean);
else
{
const double x = slice_cos[i];
const double R = slice_sin[i];
for (uint32_t j=0;j<stacks;j++)
{
const double y = R*stack_cos[j];
const double z = R*stack_sin[j];
aux_add3DpointWithEigenVectors(x,y,z, pts,U,mean);
}
}
}
MRPT_END
}
}}} // end namespaces
| 30.884921 | 108 | 0.602724 | feroze |
387a4cac9693d42172ca2c7f43343f335500188c | 3,342 | cpp | C++ | Code/Lib/golSerialSharedGame.cpp | carlosparaciari/ParallelGameOfLife | 98b0251446adca123b7f2469073c5322c81b3824 | [
"BSD-3-Clause"
] | 1 | 2021-02-01T13:10:08.000Z | 2021-02-01T13:10:08.000Z | Code/Lib/golSerialSharedGame.cpp | carlosparaciari/ParallelGameOfLife | 98b0251446adca123b7f2469073c5322c81b3824 | [
"BSD-3-Clause"
] | null | null | null | Code/Lib/golSerialSharedGame.cpp | carlosparaciari/ParallelGameOfLife | 98b0251446adca123b7f2469073c5322c81b3824 | [
"BSD-3-Clause"
] | null | null | null | /*=============================================================================
GameOfLife: Let us mix together the Game of Life and parallel programming.
Copyright (c) University College London (UCL). All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
See LICENSE.txt in the top level directory for details.
=============================================================================*/
#include "golSerialSharedGame.h"
namespace gol {
/// The class constructor.
SerialSharedGame::SerialSharedGame(game_parameters game_settings) {
m_game_settings = game_settings;
}
/// Method to evolve a frame by one time step.
void SerialSharedGame::evolve(frame & current_frame) {
if ( current_frame.empty() ) {
std::string message = std::string("The frame is empty.");
throw std::runtime_error(message);
}
bool notsame_x_size = current_frame.size() != m_game_settings.number_x_cells;
bool notsame_y_size = current_frame[0].size() != m_game_settings.number_y_cells;
if ( notsame_x_size || notsame_y_size ) {
std::string message = std::string("The frame size is not correct.");
throw std::runtime_error(message);
}
frame next_frame(m_game_settings.number_x_cells, std::vector<gol::cell>(m_game_settings.number_y_cells, gol::dead));
int number_alive_cells;
#pragma omp parallel private(number_alive_cells), shared(next_frame)
{
#pragma omp for collapse(2)
for ( int i = 0 ; i < m_game_settings.number_x_cells ; ++i ) {
for ( int j = 0 ; j < m_game_settings.number_y_cells ; ++j ) {
number_alive_cells = count_alive_neighbours(i, j, current_frame);
next_frame[i][j] = change_state_cell(number_alive_cells, current_frame[i][j]);
}
}
}
current_frame = next_frame;
}
/// Method to count the alive cells in the neighbourhood of a given cell.
int SerialSharedGame::count_alive_neighbours(int x_coord, int y_coord, frame & current_frame) {
int number_alive_cells = 0;
bool alive_centre = current_frame[x_coord][y_coord] == alive;
if ( alive_centre )
number_alive_cells += -1;
int delta = 1;
for ( int i = x_coord - delta ; i <= x_coord + delta ; ++i ) {
for ( int j = y_coord - delta ; j <= y_coord + delta ; ++j ) {
bool bad_coord = (i < 0) ||
(j < 0) ||
(i >= m_game_settings.number_x_cells) ||
(j >= m_game_settings.number_y_cells);
if ( !bad_coord ) {
bool alive_cell = current_frame[i][j] == alive;
if ( alive_cell )
number_alive_cells += 1;
}
}
}
return number_alive_cells;
}
/// Method to change the state of a cell depending on the number of closeby alive cells.
cell SerialSharedGame::change_state_cell(int alive_neighbours, cell current_state) {
if ( current_state == alive) {
if ( alive_neighbours < 2 )
return dead;
if ( (alive_neighbours == 2) || (alive_neighbours == 3) )
return alive;
if ( alive_neighbours > 3 )
return dead;
}
if ( current_state == dead) {
if ( alive_neighbours == 3 )
return alive;
else
return dead;
}
}
} // end namespace
| 30.66055 | 119 | 0.61939 | carlosparaciari |
387a9903da14d6a0119ccaf26e2d63c2435d054b | 405 | cc | C++ | src/runner.cc | dkozinski/uvgRTP | c74d6a75a7c226cec919ab2639d13f6a770d069c | [
"BSD-2-Clause"
] | null | null | null | src/runner.cc | dkozinski/uvgRTP | c74d6a75a7c226cec919ab2639d13f6a770d069c | [
"BSD-2-Clause"
] | null | null | null | src/runner.cc | dkozinski/uvgRTP | c74d6a75a7c226cec919ab2639d13f6a770d069c | [
"BSD-2-Clause"
] | null | null | null | #include "runner.hh"
uvg_rtp::runner::runner():
active_(false), runner_(nullptr)
{
}
uvg_rtp::runner::~runner()
{
active_ = false;
if (runner_)
delete runner_;
}
rtp_error_t uvg_rtp::runner::start()
{
active_ = true;
return RTP_OK;
}
rtp_error_t uvg_rtp::runner::stop()
{
active_ = false;
return RTP_OK;
}
bool uvg_rtp::runner::active()
{
return active_;
}
| 11.911765 | 36 | 0.624691 | dkozinski |
387abae9c3f8e233b5629d4945a89830d4880884 | 1,388 | cpp | C++ | shadows-of-the-knight/main_codingame.cpp | dubzzz/property-based-testing-cpp | 418c0e952cdb50633bd43e73faa545e52cc1af63 | [
"MIT"
] | 11 | 2018-03-14T17:12:10.000Z | 2021-12-12T04:15:53.000Z | shadows-of-the-knight/main_codingame.cpp | dubzzz/property-based-testing-cpp | 418c0e952cdb50633bd43e73faa545e52cc1af63 | [
"MIT"
] | null | null | null | shadows-of-the-knight/main_codingame.cpp | dubzzz/property-based-testing-cpp | 418c0e952cdb50633bd43e73faa545e52cc1af63 | [
"MIT"
] | 3 | 2019-06-19T16:45:19.000Z | 2021-07-13T10:22:16.000Z | #include <cstddef>
#include <iostream>
#include <string>
class Space
{
const std::size_t m_dim_x, m_dim_y;
std::size_t m_current_x, m_current_y;
std::string m_hint;
public:
Space(
std::size_t dim_x, std::size_t dim_y,
std::size_t current_x, std::size_t current_y)
: m_dim_x(dim_x)
, m_dim_y(dim_y)
, m_current_x(current_x)
, m_current_y(current_y)
, m_hint()
{
std::cin >> m_hint;
std::cin.ignore();
}
std::size_t dimension_x() const { return m_dim_x; }
std::size_t dimension_y() const { return m_dim_y; }
std::size_t previous_x() const { return m_current_x; }
std::size_t previous_y() const { return m_current_y; }
std::string const& hint() const { return m_hint; }
void move(std::size_t x, std::size_t y)
{
std::cout << x << " " << y << std::endl;
m_current_x = x;
m_current_y = y;
std::cin >> m_hint;
std::cin.ignore();
}
bool solved() const
{
return m_hint.empty();
}
};
/* COPY PASTE the code of "implem.inl.hpp"
HERE */
int main()
{
std::size_t W, H;
std::cin >> W >> H;
std::cin.ignore();
std::size_t N;
std::cin >> N;
std::cin.ignore();
std::size_t X0, Y0;
std::cin >> X0 >> Y0;
std::cin.ignore();
Space sp {W, H, X0, Y0};
locate_in_space(sp, N);
}
| 20.115942 | 56 | 0.561239 | dubzzz |
387b842d71f1e9ad201cbe78cc367cbd79d90234 | 9,579 | cpp | C++ | silkrpc/core/storage_walker.cpp | torquem-ch/silkrpc | 38441b1852345aae846071e36fc1a4745968caeb | [
"Apache-2.0"
] | 9 | 2021-03-08T13:26:46.000Z | 2022-02-25T23:23:16.000Z | silkrpc/core/storage_walker.cpp | torquem-ch/silkrpc | 38441b1852345aae846071e36fc1a4745968caeb | [
"Apache-2.0"
] | 151 | 2020-11-22T15:42:58.000Z | 2022-03-31T20:12:18.000Z | silkrpc/core/storage_walker.cpp | torquem-ch/silkrpc | 38441b1852345aae846071e36fc1a4745968caeb | [
"Apache-2.0"
] | 5 | 2021-03-15T11:01:34.000Z | 2022-03-12T15:45:00.000Z | /*
Copyright 2020 The Silkrpc Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "storage_walker.hpp"
#include <sstream>
#include <boost/endian/conversion.hpp>
#include <silkworm/core/silkworm/common/endian.hpp>
#include <silkworm/node/silkworm/db/bitmap.hpp>
#include <silkworm/node/silkworm/db/util.hpp>
#include <silkrpc/common/log.hpp>
#include <silkrpc/core/rawdb/chain.hpp>
#include <silkrpc/core/state_reader.hpp>
#include <silkrpc/ethdb/cursor.hpp>
#include <silkrpc/ethdb/tables.hpp>
#include <silkrpc/ethdb/transaction_database.hpp>
#include <silkrpc/json/types.hpp>
namespace silkrpc {
silkworm::Bytes make_key(const evmc::address& address, const evmc::bytes32& location) {
silkworm::Bytes res(silkworm::kAddressLength + silkworm::kHashLength, '\0');
std::memcpy(&res[0], address.bytes, silkworm::kAddressLength);
std::memcpy(&res[silkworm::kAddressLength], location.bytes, silkworm::kHashLength);
return res;
}
silkworm::Bytes make_key(const evmc::address& address, uint64_t incarnation, const evmc::bytes32& location) {
silkworm::Bytes res(silkworm::kAddressLength + silkworm::kHashLength + 8, '\0');
std::memcpy(&res[0], address.bytes, silkworm::kAddressLength);
boost::endian::store_big_u64(&res[silkworm::kAddressLength], incarnation);
std::memcpy(&res[silkworm::kAddressLength + 8], location.bytes, silkworm::kHashLength);
return res;
}
asio::awaitable<silkrpc::ethdb::SplittedKeyValue> next(silkrpc::ethdb::SplitCursor& cursor, uint64_t number) {
auto kv = co_await cursor.next();
if (kv.key2.empty()) {
co_return kv;
}
uint64_t block = silkworm::endian::load_big_u64(kv.key3.data());
SILKRPC_TRACE << "Curson on StorageHistory NEXT"
<< " addr 0x" << silkworm::to_hex(kv.key1)
<< " loc " << silkworm::to_hex(kv.key2)
<< " tsEnc " << silkworm::to_hex(kv.key3)
<< " v " << silkworm::to_hex(kv.value)
<< "\n";
while (block < number) {
kv = co_await cursor.next();
if (kv.key2.empty()) {
break;
}
block = silkworm::endian::load_big_u64(kv.key3.data());
SILKRPC_TRACE << "Curson on StorageHistory NEXT"
<< " addr 0x" << silkworm::to_hex(kv.key1)
<< " loc " << silkworm::to_hex(kv.key2)
<< " tsEnc " << silkworm::to_hex(kv.key3)
<< " v " << silkworm::to_hex(kv.value)
<< "\n";
}
co_return kv;
}
asio::awaitable<void> StorageWalker::walk_of_storages(uint64_t block_number, const evmc::address& start_address,
const evmc::bytes32& location_hash, uint64_t incarnation, Collector& collector) {
auto ps_cursor = co_await transaction_.cursor(db::table::kPlainState);
auto ps_key{make_key(start_address, incarnation, location_hash)};
silkrpc::ethdb::SplitCursor ps_split_cursor{*ps_cursor,
ps_key,
8 * (silkworm::kAddressLength + 8),
silkworm::kAddressLength,
silkworm::kAddressLength + 8,
silkworm::kAddressLength + 8 + silkworm::kHashLength};
SILKRPC_TRACE << "Curson on PlainState"
<< " ps_key 0x" << silkworm::to_hex(ps_key)
<< " key len " << ps_key.length()
<< " match_bits " << 8 * (silkworm::kAddressLength + 8)
<< " length1 " << silkworm::kAddressLength
<< " length2 " << 8
<< "\n";
auto sh_key{make_key(start_address, location_hash)};
auto sh_cursor = co_await transaction_.cursor(db::table::kStorageHistory);
silkrpc::ethdb::SplitCursor sh_split_cursor{*sh_cursor,
sh_key,
8 * silkworm::kAddressLength,
silkworm::kAddressLength,
silkworm::kAddressLength,
silkworm::kAddressLength + silkworm::kHashLength};
SILKRPC_TRACE << "Curson on StorageHistory"
<< " sh_key 0x" << silkworm::to_hex(sh_key)
<< " key len " << sh_key.length()
<< " match_bits " << 8 * silkworm::kAddressLength
<< " length1 " << silkworm::kAddressLength
<< " length2 " << 8
<< "\n";
auto ps_skv = co_await ps_split_cursor.seek();
SILKRPC_TRACE << "Curson on PlainState SEEK"
<< " addr 0x" << silkworm::to_hex(ps_skv.key1)
<< " loc " << silkworm::to_hex(ps_skv.key2)
<< " kk " << silkworm::to_hex(ps_skv.key3)
<< " v " << silkworm::to_hex(ps_skv.value)
<< "\n";
auto sh_skv = co_await sh_split_cursor.seek();
uint64_t block = silkworm::endian::load_big_u64(sh_skv.key3.data());
SILKRPC_TRACE << "Curson on StorageHistory SEEK"
<< " addr 0x" << silkworm::to_hex(sh_skv.key1)
<< " loc " << silkworm::to_hex(sh_skv.key2)
<< " tsEnc " << silkworm::to_hex(sh_skv.key3)
<< " v " << silkworm::to_hex(sh_skv.value)
<< "\n";
auto cs_cursor = co_await transaction_.cursor_dup_sort(db::table::kPlainStorageChangeSet);
if (block < block_number) {
sh_skv = co_await next(sh_split_cursor, block_number);
}
auto count = 0;
auto go_on = true;
while (go_on && count < 10) {
count++;
if (ps_skv.key1.empty() && sh_skv.key1.empty()) {
SILKRPC_TRACE << "Both keys1 are empty: break loop\n";
break;
}
auto cmp = ps_skv.key1.compare(sh_skv.key1);
SILKRPC_TRACE << "ITERATE ** KeyCmp: addr 0x" << silkworm::to_hex(ps_skv.key1)
<< " hAddr 0x" << silkworm::to_hex(sh_skv.key1)
<< " cmp " << cmp
<< "\n";
if (cmp == 0) {
if (ps_skv.key2.empty() && sh_skv.key2.empty()) {
SILKRPC_TRACE << "Both keys2 are empty: break loop\n";
break;
}
auto cmp = ps_skv.key2.compare(sh_skv.key2);
SILKRPC_TRACE << "ITERATE ** KeyCmp: loc 0x" << silkworm::to_hex(ps_skv.key2)
<< " hLoc 0x" << silkworm::to_hex(sh_skv.key2)
<< " cmp " << cmp
<< "\n";
}
if (cmp < 0) {
auto address = silkworm::to_address(ps_skv.key1);
go_on = collector(address, ps_skv.key2, ps_skv.value);
SILKRPC_TRACE << "ITERATE ** COLLECTOR CALLED: address 0x" << silkworm::to_hex(address)
<< " loc 0x" << silkworm::to_hex(ps_skv.key2)
<< " data 0x" << silkworm::to_hex(ps_skv.value)
<< " go_on " << go_on
<< "\n";
} else {
SILKRPC_TRACE << "ITERATE ** built roaring64 from " << silkworm::to_hex(sh_skv.value) << "\n";
const auto bitmap = silkworm::db::bitmap::read(sh_skv.value);
std::optional<silkworm::Account> result;
if (bitmap.contains(block_number)) {
auto dup_key{silkworm::db::storage_change_key(block_number, start_address, incarnation)};
SILKRPC_TRACE << "Curson on StorageHistory"
<< " dup_key 0x" << silkworm::to_hex(dup_key)
<< " key len " << dup_key.length()
<< " hLoc " << silkworm::to_hex(sh_skv.key2)
<< "\n";
auto data = co_await cs_cursor->seek_both(dup_key, sh_skv.key2);
SILKRPC_TRACE << "Curson on StorageHistory"
<< " found data 0x" << silkworm::to_hex(data)
<< "\n";
data = data.substr(silkworm::kHashLength);
if (data.length() > 0) { // Skip deleted entries
auto address = silkworm::to_address(ps_skv.key1);
go_on = collector(address, ps_skv.key2, data);
SILKRPC_TRACE << "ITERATE ** COLLECTOR CALLED: address 0x" << silkworm::to_hex(address)
<< " loc 0x" << silkworm::to_hex(sh_skv.key2)
<< " data 0x" << silkworm::to_hex(data)
<< " go_on " << go_on
<< "\n";
}
} else if (cmp == 0) {
auto address = silkworm::to_address(ps_skv.key1);
go_on = collector(address, ps_skv.key2, ps_skv.value);
SILKRPC_TRACE << "ITERATE ** COLLECTOR CALLED: address 0x" << silkworm::to_hex(address)
<< " loc 0x" << silkworm::to_hex(ps_skv.key2)
<< " data 0x" << silkworm::to_hex(ps_skv.value)
<< " go_on " << go_on
<< "\n";
}
}
if (go_on) {
if (cmp <= 0) {
ps_skv = co_await ps_split_cursor.next();
SILKRPC_TRACE << "Curson on PlainState NEXT"
<< " addr 0x" << silkworm::to_hex(ps_skv.key1)
<< " loc " << silkworm::to_hex(ps_skv.key2)
<< " kk " << silkworm::to_hex(ps_skv.key3)
<< " v " << silkworm::to_hex(ps_skv.value)
<< "\n";
}
if (cmp >= 0) {
sh_skv = co_await next(sh_split_cursor, block_number);
}
}
}
co_return;
}
} // namespace silkrpc
| 40.935897 | 112 | 0.573233 | torquem-ch |
387f24f11bd3321cba759133bb1cf5b63ed1d26b | 1,945 | cpp | C++ | Heap/06 HeapifyFunctionFasterMethodtoCreateHeap.cpp | GajuuKool/DSA_CPP | c63b64783238680fcb97f908298c7378f9109063 | [
"MIT"
] | 9 | 2020-09-30T17:57:18.000Z | 2021-11-14T18:27:49.000Z | Heap/06 HeapifyFunctionFasterMethodtoCreateHeap.cpp | GajuuKool/DSA_CPP | c63b64783238680fcb97f908298c7378f9109063 | [
"MIT"
] | 1 | 2020-10-06T11:15:20.000Z | 2021-01-02T11:35:57.000Z | Heap/06 HeapifyFunctionFasterMethodtoCreateHeap.cpp | GajuuKool/DSA_CPP | c63b64783238680fcb97f908298c7378f9109063 | [
"MIT"
] | 13 | 2020-09-30T17:56:50.000Z | 2022-03-15T11:07:08.000Z | #include <iostream>
using namespace std;
void swap(int A[], int i, int j){
int temp = A[i];
A[i] = A[j];
A[j] = temp;
}
int Delete(int A[], int n){
int x = A[0]; // Max element
A[0] = A[n-1];
int i = 0;
int j = 2 * i + 1;
while (j < n-1){
// Compare left and right children
if (A[j] < A[j+1]){
j = j+1;
}
// Compare parent and largest child
if (A[i] < A[j]){
swap(A, i, j);
i = j;
j = 2 * i + 1;
} else {
break;
}
}
return x;
}
void Heapify(int A[], int n){
// # of leaf elements: (n+1)/2, index of last leaf element's parent = (n/2)-1
for (int i=(n/2)-1; i>=0; i--){
int j = 2 * i + 1; // Left child for current i
while(j < n-1){
// Compare left and right children of current i
if (A[j] < A[j+1]){
j = j+1;
}
// Compare parent and largest child
if (A[i] < A[j]){
swap(A, i, j);
i = j;
j = 2 * i + 1;
} else {
break;
}
}
}
}
template <class T>
void Print(T& vec, int n, string s){
cout << s << ": [" << flush;
for (int i=0; i<n; i++){
cout << vec[i] << flush;
if (i < n-1){
cout << ", " << flush;
}
}
cout << "]" << endl;
}
int main() {
int A[] = {5, 10, 30, 20, 35, 40, 15};
Print(A, sizeof(A)/sizeof(A[0]), "A");
Heapify(A, sizeof(A)/sizeof(A[0]));
Print(A, sizeof(A)/sizeof(A[0]), "Heapified A");
cout << endl;
int B[] = {5, 10, 30, 20};
Print(B, sizeof(B)/sizeof(B[0]), "B");
Heapify(B, sizeof(B)/sizeof(B[0]));
Print(B, sizeof(B)/sizeof(B[0]), "Heapified B");
return 0;
} | 22.102273 | 82 | 0.382519 | GajuuKool |
38814d3e6fa1fed332afb5b4d0a555dca6af6b20 | 520 | cpp | C++ | sem1/hw6/hw6.1/hw6.1/main.cpp | Daria-Donina/Homework | 8853fb65c7a0ad62556a49d12908098af9caf7ed | [
"Apache-2.0"
] | 1 | 2018-11-29T11:12:51.000Z | 2018-11-29T11:12:51.000Z | sem1/hw6/hw6.1/hw6.1/main.cpp | Daria-Donina/Homework | 8853fb65c7a0ad62556a49d12908098af9caf7ed | [
"Apache-2.0"
] | null | null | null | sem1/hw6/hw6.1/hw6.1/main.cpp | Daria-Donina/Homework | 8853fb65c7a0ad62556a49d12908098af9caf7ed | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <string>
#include "stack.h"
#include "resultCounting.h"
#include "test.h"
using namespace std;
int main()
{
if (test())
{
cout << "Tests passed" << endl;
}
else
{
cout << "Tests failed" << endl;
}
Stack *stack = createStack();
cout << "Enter postfix expression: ";
string expression = "";
getline(cin, expression);
int expressionResult = result(stack, expression);
cout << "The result of the expression is: " << expressionResult << endl;
deleteStack(stack);
return 0;
}
| 17.931034 | 73 | 0.659615 | Daria-Donina |
3883bcbfa2445ea9d30f38ef1a737f5ddfa2bd9b | 14,137 | cpp | C++ | drlvm/vm/vmcore/src/exception/exceptions_impl.cpp | sirinath/Harmony | 724deb045a85b722c961d8b5a83ac7a697319441 | [
"Apache-2.0"
] | 8 | 2015-11-04T06:06:35.000Z | 2021-07-04T13:47:36.000Z | drlvm/vm/vmcore/src/exception/exceptions_impl.cpp | sirinath/Harmony | 724deb045a85b722c961d8b5a83ac7a697319441 | [
"Apache-2.0"
] | 1 | 2021-10-17T13:07:28.000Z | 2021-10-17T13:07:28.000Z | drlvm/vm/vmcore/src/exception/exceptions_impl.cpp | sirinath/Harmony | 724deb045a85b722c961d8b5a83ac7a697319441 | [
"Apache-2.0"
] | 13 | 2015-11-27T03:14:50.000Z | 2022-02-26T15:12:20.000Z | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Intel, Pavel Afremov
*/
#define LOG_DOMAIN "exn"
#include "clog.h"
#include "open/vm_class_manipulation.h"
#include "vtable.h"
#include "Class.h"
#include "classloader.h"
#include "exceptions.h"
#include "exceptions_impl.h"
#include "exceptions_jit.h"
#include "exceptions_type.h"
#include "environment.h"
#include "heap.h"
#include "ini.h"
#include "vm_strings.h"
Class *get_exc_class(const char *exception_name)
{
ASSERT_RAISE_AREA;
assert(hythread_is_suspend_enabled());
Global_Env *env = VM_Global_State::loader_env;
String *exc_str = env->string_pool.lookup(exception_name);
Class *exc_class =
env->bootstrap_class_loader->LoadVerifyAndPrepareClass(env, exc_str);
if (exc_class == NULL) {
return NULL;
}
tmn_suspend_disable();
class_initialize(exc_class);
tmn_suspend_enable();
if (exn_raised()) {
return NULL;
}
return exc_class;
}
Method* lookup_exc_constructor(Class * exc_class, const char *signature)
{
ASSERT_RAISE_AREA;
Global_Env *env = VM_Global_State::loader_env;
// Get the method for the constructor
String *init_name = env->Init_String;
String *init_descr = env->string_pool.lookup(signature);
Method *exc_init = exc_class->lookup_method(init_name, init_descr);
return exc_init;
}
//FIXME LAZY EXCEPTION (2006.05.13)
// internal declaration of functions should be moved to exception_impl.h
static Method* prepare_exc_creating(Class* exc_class, jvalue* args,
const char* exc_message);
static Method* prepare_exc_creating(Class* exc_class, jvalue* args,
const char* exc_message, jthrowable exc_cause);
//FIXME LAZY EXCEPTION (2006.05.13)
// cause can be null
static Method* prepare_exc_creating(Class* exc_class, jvalue* args) {
ASSERT_RAISE_AREA;
assert(hythread_is_suspend_enabled());
// Finds corresponding constructor
Method* exc_init = lookup_exc_constructor(exc_class, "()V");
// Check that constructor is found
if (NULL == exc_init) {
return prepare_exc_creating(exc_class, args, "");
}
// Returns found constructor
return exc_init;
}
static Method* prepare_exc_creating(Class* exc_class, jvalue* args,
jthrowable exc_cause) {
ASSERT_RAISE_AREA;
assert(hythread_is_suspend_enabled());
// Checks that it's corresponding method
if (NULL == exc_cause) {
return prepare_exc_creating(exc_class, args);
}
// Finds corresponding constructor
Method* exc_init = lookup_exc_constructor(exc_class, "(Ljava/lang/Throwable;)V");
// Check that constructor is found
if (exc_init == NULL){
return prepare_exc_creating(exc_class, args, "", exc_cause);
}
// Fills arguments for constructor
args[1].l = exc_cause;
// Returns found constructor
return exc_init;
}
static Method* prepare_exc_creating(Class* exc_class, jvalue* args,
const char* exc_message) {
ASSERT_RAISE_AREA;
assert(hythread_is_suspend_enabled());
// Checks that it's corresponding method
if (NULL == exc_message) {
return prepare_exc_creating(exc_class, args);
}
// Finds corresponding constructor
Method* exc_init = lookup_exc_constructor(exc_class, "(Ljava/lang/String;)V");
// Check that constructor is found
if (NULL == exc_init){
return NULL;
}
// Creates string object
tmn_suspend_disable();
ManagedObject *arg_obj =
string_create_from_utf8(exc_message, (unsigned) strlen(exc_message));
if (!arg_obj) {
exn_raise_object(VM_Global_State::loader_env->java_lang_OutOfMemoryError);
tmn_suspend_enable();
return NULL;
}
jobject arg = oh_allocate_local_handle();
arg->object = arg_obj;
tmn_suspend_enable();
// Fills arguments for constructor
args[1].l = arg;
// Returns found constructor
return exc_init;
}
static Method* prepare_exc_creating(Class* exc_class, jvalue* args,
const char* exc_message, jthrowable exc_cause) {
ASSERT_RAISE_AREA;
assert(hythread_is_suspend_enabled());
// Checks that it's corresponding method
if (NULL == exc_message) {
return prepare_exc_creating(exc_class, args, exc_cause);
}
// Checks that it's corresponding method
if (NULL == exc_cause) {
return prepare_exc_creating(exc_class, args, exc_message);
}
// Finds corresponding constructor
Method* exc_init = lookup_exc_constructor(exc_class, "(Ljava/lang/String;Ljava/lang/Throwable;)V");
// Check that constructor is found
if (NULL == exc_init){
return NULL;
}
// Creates string object
tmn_suspend_disable_recursive();
ManagedObject *arg_obj =
string_create_from_utf8(exc_message, (unsigned) strlen(exc_message));
if (!arg_obj) {
exn_raise_object(VM_Global_State::loader_env->java_lang_OutOfMemoryError);
return NULL;
}
jobject arg = oh_allocate_local_handle();
arg->object = arg_obj;
tmn_suspend_enable_recursive();
// Fills arguments for constructor
args[1].l = arg;
args[2].l = exc_cause;
// Returns found constructor
return exc_init;
}
void init_cause(jthrowable exc_object, jthrowable exc_cause) {
ASSERT_RAISE_AREA;
assert(exc_cause);
assert(hythread_is_suspend_enabled());
tmn_suspend_disable();
Class* exc_class = exc_object->object->vt()->clss;
Method *init_cause_method = class_lookup_method_recursive(exc_class,
"initCause", "(Ljava/lang/Throwable;)Ljava/lang/Throwable;");
assert(init_cause_method);
jvalue args[2];
args[0].l = exc_object;
args[1].l = exc_cause;
jvalue ret_val;
vm_execute_java_method_array((jmethodID) init_cause_method, &ret_val,
args);
tmn_suspend_enable();
}
jthrowable create_exception(Class* exc_class, Method* exc_init, jvalue* args) {
ASSERT_RAISE_AREA;
assert(hythread_is_suspend_enabled());
bool suspended_enabled = hythread_is_suspend_enabled();
if (suspended_enabled) {
tmn_suspend_disable();
}
ManagedObject *man_obj = class_alloc_new_object(exc_class);
if (!man_obj) {
exn_raise_object(VM_Global_State::loader_env->java_lang_OutOfMemoryError);
if (suspended_enabled) {
tmn_suspend_enable();
}
return NULL;
}
jthrowable exc_object = oh_allocate_local_handle();
exc_object->object = man_obj;
args[0].l = exc_object;
if (exn_raised()) { //if RuntimeException or Error
if (suspended_enabled) {
tmn_suspend_enable();
}
return NULL;
}
vm_execute_java_method_array((jmethodID) exc_init, 0, args);
if (suspended_enabled) {
tmn_suspend_enable();
}
return exc_object;
}
jthrowable create_exception(Class* exc_class,
const char* exc_message, jthrowable exc_cause)
{
ASSERT_RAISE_AREA;
assert(hythread_is_suspend_enabled());
jvalue args[3];
Method *exc_init =
prepare_exc_creating(exc_class, args, exc_message, exc_cause);
if (exc_init == NULL){
return NULL;
}
return create_exception(exc_class, exc_init, args);
} // create_exception(Class *exc_class, const char *exc_message, jthrowable exc_cause)
jthrowable create_exception(Exception* exception)
{
ASSERT_RAISE_AREA;
assert(hythread_is_suspend_enabled());
if ( NULL != exception->exc_class) {
jthrowable exc_cause = NULL;
Class* exc_class = exception->exc_class;
const char* exc_message = exception->exc_message;
if (NULL != exception->exc_cause) {
tmn_suspend_disable_recursive();
exc_cause = oh_allocate_local_handle();
exc_cause->object = exception->exc_cause;
tmn_suspend_enable_recursive();
}
exn_clear();
jthrowable exc_exception = NULL;
exc_exception = exn_create(exc_class, exc_message, exc_cause);
return exc_exception;
} else {
return NULL;
}
}
void exn_throw_object_internal(jthrowable exc_object)
{
BEGIN_RAISE_AREA;
// functions can be invoked in suspend disabled and enabled state
if (hythread_is_suspend_enabled()) {
tmn_suspend_disable();
}
assert(!hythread_is_suspend_enabled());
CTRACE(("%s", "exn_throw_object(), delegating to exn_throw_for_JIT()"));
exn_throw_for_JIT(exc_object->object, NULL, NULL, NULL, NULL);
END_RAISE_AREA;
}
void exn_throw_by_class_internal(Class* exc_class, const char* exc_message,
jthrowable exc_cause)
{
BEGIN_RAISE_AREA;
// functions can be invoked in suspend disabled and enabled state
if (!hythread_is_suspend_enabled()) {
// exception is throwing, so suspend can be enabled safely
tmn_suspend_enable();
}
assert(hythread_is_suspend_enabled());
#ifdef VM_LAZY_EXCEPTION
//set_unwindable(false);
jvalue args[3];
Method* exc_init = prepare_exc_creating(
exc_class, args, exc_message, exc_cause);
if (NULL == exc_init) {
CTRACE(("%s",
"exn_throw_by_class(),create exception and delegating to exn_throw_for_JIT()"));
jthrowable exc_object = exn_create(exc_class, exc_message, exc_cause);
exn_rethrow_if_pending();
//set_unwindable(true);
exn_throw_object_internal(exc_object);
} else {
CTRACE(("%s", "exn_throw_by_class(), lazy delegating to exn_throw_for_JIT()"));
//set_unwindable(true);
// no return, so enable isn't required
tmn_suspend_disable();
exn_throw_for_JIT(NULL, exc_class, exc_init, NULL, args);
//tmn_suspend_enable();
}
#else
jthrowable exc_object = exn_create(exc_class, exc_message, exc_cause);
exn_rethrow_if_pending();
exn_throw_object_internal(exc_object);
#endif
END_RAISE_AREA;
}
void exn_throw_by_name_internal(const char* exc_name, const char* exc_message,
jthrowable exc_cause)
{
BEGIN_RAISE_AREA;
// functions can be invoked in suspend disabled and enabled state
if (!hythread_is_suspend_enabled()) {
// exception is throwing, so suspend can be enabled safely
tmn_suspend_enable();
}
assert(hythread_is_suspend_enabled());
Class *exc_class = get_exc_class(exc_name);
if (exc_class == NULL) {
assert(exn_raised());
exn_rethrow();
return; // unreachable code
}
exn_throw_by_class_internal(exc_class, exc_message, exc_cause);
END_RAISE_AREA;
}
void exn_raise_object_internal(jthrowable exc_object)
{
CTRACE(("%s", "exn_raise_object(), propagating non-destructively"));
tmn_suspend_disable_recursive();
p_TLS_vmthread->thread_exception.exc_object = exc_object->object;
tmn_suspend_enable_recursive();
}
void exn_raise_by_class_internal(Class* exc_class, const char* exc_message,
jthrowable exc_cause)
{
#ifdef VM_LAZY_EXCEPTION
CTRACE(("%s", "exn_raise_object(), propagating lazy & non-destructively"));
tmn_suspend_disable_recursive();
p_TLS_vmthread->thread_exception.exc_class = exc_class;
p_TLS_vmthread->thread_exception.exc_message = exc_message;
if (exc_cause != NULL) {
p_TLS_vmthread->thread_exception.exc_cause = exc_cause->object;
} else {
p_TLS_vmthread->thread_exception.exc_cause = NULL;
}
tmn_suspend_enable_recursive();
#else
assert(hythread_is_suspend_enabled());
jthrowable exc_object = exn_create(exc_class, exc_message, exc_cause);
if (exn_raised()){
return;
}
exn_raise_object_internal(exc_object);
#endif
}
void exn_raise_by_name_internal(const char* exc_name, const char* exc_message,
jthrowable exc_cause)
{
assert(hythread_is_suspend_enabled());
Class *exc_class = get_exc_class(exc_name);
if (exc_class == NULL) {
assert(exn_raised());
return;
}
exn_raise_by_class_internal(exc_class, exc_message, exc_cause);
}
// function should be called in disable mode
void __stdcall clear_exception_internal()
{
assert(!hythread_is_suspend_enabled());
p_TLS_vmthread->thread_exception.exc_object = NULL;
p_TLS_vmthread->thread_exception.exc_class = NULL;
p_TLS_vmthread->thread_exception.exc_cause = NULL;
p_TLS_vmthread->thread_exception.exc_message = NULL;
} // clear_exception_internal
// function should be called in disable mode
void __stdcall set_exception_object_internal(ManagedObject * exc)
{
assert(!hythread_is_suspend_enabled());
p_TLS_vmthread->thread_exception.exc_object = exc;
} // set_exc_object_internal
// function is safe point & should be called in disable mode in safe enviroment
ManagedObject* __stdcall get_exception_object_internal()
{
assert(!hythread_is_suspend_enabled());
if (NULL != p_TLS_vmthread->thread_exception.exc_object) {
return p_TLS_vmthread->thread_exception.exc_object;
} else if (NULL != p_TLS_vmthread->thread_exception.exc_class) {
Exception* exception = (Exception*)&(p_TLS_vmthread->thread_exception);
// suspend can be enabeled in safe enviroment
tmn_suspend_enable();
jthrowable exc_object = create_exception(exception);
tmn_suspend_disable();
return exc_object->object;
} else {
return NULL;
}
} // get_exc_object_internal
| 29.887949 | 103 | 0.699795 | sirinath |
3885337c7a198cf05f1321f6c5c9e94031e80a53 | 422 | cpp | C++ | src/lib/parser/ParserParamInstr.cpp | WasmVM/wass | e35962e1637a1445ab8ad97e5a06ee4d59b49fd7 | [
"BSD-3-Clause"
] | null | null | null | src/lib/parser/ParserParamInstr.cpp | WasmVM/wass | e35962e1637a1445ab8ad97e5a06ee4d59b49fd7 | [
"BSD-3-Clause"
] | null | null | null | src/lib/parser/ParserParamInstr.cpp | WasmVM/wass | e35962e1637a1445ab8ad97e5a06ee4d59b49fd7 | [
"BSD-3-Clause"
] | null | null | null | #include <parser/ParserParamInstr.hpp>
#include <Util.hpp>
#include <structure/BaseInstr.hpp>
ParserParamInstr::ParserParamInstr(ParserContext& context){
if(Util::matchString(context.cursor, context.end, "select")){
context.cursor += 6;
emplace<SelectInstr>(SelectInstr());
}else if(Util::matchString(context.cursor, context.end, "drop")){
context.cursor += 4;
emplace<DropInstr>(DropInstr());
}
}
| 28.133333 | 67 | 0.71564 | WasmVM |
38896a42093b9decd3392576e02e5e9134eff018 | 3,145 | cc | C++ | lib/spot-2.8.1/spot/misc/formater.cc | AlessandroCaste/SynkrisisJupyter | a9c2b21ec1ae7ac0c05ef5deebc63a369274650f | [
"Unlicense"
] | 1 | 2018-03-02T14:29:57.000Z | 2018-03-02T14:29:57.000Z | lib/spot-2.8.1/spot/misc/formater.cc | AlessandroCaste/SynkrisisJupyter | a9c2b21ec1ae7ac0c05ef5deebc63a369274650f | [
"Unlicense"
] | null | null | null | lib/spot-2.8.1/spot/misc/formater.cc | AlessandroCaste/SynkrisisJupyter | a9c2b21ec1ae7ac0c05ef5deebc63a369274650f | [
"Unlicense"
] | 1 | 2015-06-05T12:42:07.000Z | 2015-06-05T12:42:07.000Z | // -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013, 2016 Laboratoire de Recherche et
// Développement de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config.h"
#include <spot/misc/formater.hh>
#include <spot/misc/escape.hh>
#include <iostream>
#include <sstream>
#include <cstring>
namespace spot
{
static void unclosed_bracket(const char* s)
{
std::ostringstream ss;
ss << '\'' << s << "' has unclosed bracket";
throw std::runtime_error(ss.str());
}
void
formater::scan(const char* fmt, std::vector<bool>& has) const
{
for (const char* pos = fmt; *pos; ++pos)
if (*pos == '%')
{
char c = *++pos;
// %[...]c
const char* mark = pos;
if (c == '[')
{
do
{
++pos;
if (SPOT_UNLIKELY(!*pos))
unclosed_bracket(mark - 1);
}
while (*pos != ']');
c = *++pos;
}
has[c] = true;
if (!c)
break;
}
}
void
formater::prime(const char* fmt)
{
scan(fmt, has_);
}
std::ostream&
formater::format(const char* fmt)
{
for (const char* pos = fmt; *pos; ++pos)
{
if (*pos == '"')
{
*output_ << '"';
const char* end = strchr(pos + 1, '"');
if (!end)
continue;
std::string tmp(pos + 1, end - (pos + 1));
std::ostringstream os;
format(os, tmp);
escape_rfc4180(*output_, os.str());
pos = end;
// the end double-quote will be printed below
}
if (*pos != '%')
{
*output_ << *pos;
}
else
{
char c = *++pos;
const char* next = pos;
// in case we have %[...]X... , we want to pass
// [...]X... to the printer, and continue after the X once
// that is done.
if (c == '[')
{
do
{
++next;
if (SPOT_UNLIKELY(*next == 0))
unclosed_bracket(pos - 1);
}
while (*next != ']');
c = *++next;
}
call_[c]->print(*output_, pos);
if (!c)
break;
pos = next;
}
}
return *output_;
}
}
| 26.652542 | 72 | 0.47186 | AlessandroCaste |
388b7b699bba660dd4b5b1eb9027048e978008b5 | 3,764 | cpp | C++ | Extensions/GlyphKinect2/Kinect2SkeletonActor.cpp | zgpxgame/hieroglyph3 | bb1c59d82a69062bb76431b691fbcb381930768a | [
"MIT"
] | 25 | 2017-08-05T07:29:00.000Z | 2022-02-02T06:28:27.000Z | Extensions/GlyphKinect2/Kinect2SkeletonActor.cpp | zgpxgame/hieroglyph3 | bb1c59d82a69062bb76431b691fbcb381930768a | [
"MIT"
] | null | null | null | Extensions/GlyphKinect2/Kinect2SkeletonActor.cpp | zgpxgame/hieroglyph3 | bb1c59d82a69062bb76431b691fbcb381930768a | [
"MIT"
] | 9 | 2018-07-14T08:40:29.000Z | 2021-03-19T08:51:30.000Z | //--------------------------------------------------------------------------------
// This file is a portion of the Hieroglyph 3 Rendering Engine. It is distributed
// under the MIT License, available in the root of this distribution and
// at the following URL:
//
// http://www.opensource.org/licenses/mit-license.php
//
// Copyright (c) Jason Zink
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
#include "GlyphKinect2/Kinect2SkeletonActor.h"
//--------------------------------------------------------------------------------
using namespace Glyph3;
//--------------------------------------------------------------------------------
Kinect2SkeletonActor::Kinect2SkeletonActor()
{
}
//--------------------------------------------------------------------------------
Kinect2SkeletonActor::~Kinect2SkeletonActor()
{
}
//--------------------------------------------------------------------------------
void Kinect2SkeletonActor::UpdateSkeleton( const Kinect2Skeleton& body )
{
ResetGeometry();
SetColor( Vector4f( 1.0f, 1.0f, 0.0f, 0.0f ) );
for ( int joint = 0; joint < 25; ++joint ) {
DrawSphere( body.jointPositions[joint], 0.03f );
}
SetColor( Vector4f( 0.0f, 1.0f, 0.0f, 0.0f ) );
// Head to hips
DrawLinkage( body, Kinect2JointType::Head, Kinect2JointType::Neck);
DrawLinkage( body, Kinect2JointType::Neck, Kinect2JointType::SpineShoulder);
DrawLinkage( body, Kinect2JointType::SpineShoulder, Kinect2JointType::SpineMid);
DrawLinkage( body, Kinect2JointType::SpineMid, Kinect2JointType::SpineBase);
// Left arm
DrawLinkage( body, Kinect2JointType::SpineShoulder, Kinect2JointType::ShoulderLeft );
DrawLinkage( body, Kinect2JointType::ShoulderLeft, Kinect2JointType::ElbowLeft );
DrawLinkage( body, Kinect2JointType::ElbowLeft, Kinect2JointType::WristLeft );
DrawLinkage( body, Kinect2JointType::WristLeft, Kinect2JointType::HandLeft );
DrawLinkage( body, Kinect2JointType::HandLeft, Kinect2JointType::HandTipLeft );
DrawLinkage( body, Kinect2JointType::HandLeft, Kinect2JointType::ThumbLeft );
// Right arm
DrawLinkage( body, Kinect2JointType::SpineShoulder, Kinect2JointType::ShoulderRight );
DrawLinkage( body, Kinect2JointType::ShoulderRight, Kinect2JointType::ElbowRight );
DrawLinkage( body, Kinect2JointType::ElbowRight, Kinect2JointType::WristRight );
DrawLinkage( body, Kinect2JointType::WristRight, Kinect2JointType::HandRight );
DrawLinkage( body, Kinect2JointType::HandRight, Kinect2JointType::HandTipRight );
DrawLinkage( body, Kinect2JointType::HandRight, Kinect2JointType::ThumbRight );
// Left leg
DrawLinkage( body, Kinect2JointType::SpineBase, Kinect2JointType::HipLeft );
DrawLinkage( body, Kinect2JointType::HipLeft, Kinect2JointType::KneeLeft );
DrawLinkage( body, Kinect2JointType::KneeLeft, Kinect2JointType::AnkleLeft );
DrawLinkage( body, Kinect2JointType::AnkleLeft, Kinect2JointType::FootLeft );
// Right leg
DrawLinkage( body, Kinect2JointType::SpineBase, Kinect2JointType::HipRight );
DrawLinkage( body, Kinect2JointType::HipRight, Kinect2JointType::KneeRight );
DrawLinkage( body, Kinect2JointType::KneeRight, Kinect2JointType::AnkleRight );
DrawLinkage( body, Kinect2JointType::AnkleRight, Kinect2JointType::FootRight );
}
//--------------------------------------------------------------------------------
void Kinect2SkeletonActor::DrawLinkage( const Kinect2Skeleton& body, Kinect2JointType i1, Kinect2JointType i2 )
{
Vector3f p1, p2;
p1 = body.jointPositions[static_cast<int>(i1)];
p2 = body.jointPositions[static_cast<int>(i2)];
DrawCylinder( p1, p2, 0.015f, 0.015f );
}
//-------------------------------------------------------------------------------- | 47.64557 | 112 | 0.623804 | zgpxgame |
388c6d66c74c568fb14315b1f8a71f347fa27056 | 2,645 | hh | C++ | include/ignition/sensors/BrownDistortionModel.hh | david-alejo/ign-sensors | 13308478b6f88c99a3685181439ab51ed7ed63f6 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | include/ignition/sensors/BrownDistortionModel.hh | david-alejo/ign-sensors | 13308478b6f88c99a3685181439ab51ed7ed63f6 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | include/ignition/sensors/BrownDistortionModel.hh | david-alejo/ign-sensors | 13308478b6f88c99a3685181439ab51ed7ed63f6 | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | /*
* Copyright (C) 2022 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef IGNITION_SENSORS_BROWNDISTORTIONMODEL_HH_
#define IGNITION_SENSORS_BROWNDISTORTIONMODEL_HH_
#include <sdf/sdf.hh>
#include "ignition/sensors/Distortion.hh"
#include "ignition/sensors/Export.hh"
#include "ignition/sensors/config.hh"
#include "ignition/utils/ImplPtr.hh"
namespace ignition
{
namespace sensors
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
//
// Forward declarations
class BrownDistortionModelPrivate;
/** \class BrownDistortionModel BrownDistortionModel.hh \
ignition/sensors/BrownDistortionModel.hh
**/
/// \brief Brown Distortion Model class
class IGNITION_SENSORS_VISIBLE BrownDistortionModel : public Distortion
{
/// \brief Constructor.
public: BrownDistortionModel();
/// \brief Destructor.
public: virtual ~BrownDistortionModel();
// Documentation inherited.
public: virtual void Load(const sdf::Camera &_sdf) override;
/// \brief Get the radial distortion coefficient k1.
/// \return Distortion coefficient k1.
public: double K1() const;
/// \brief Get the radial distortion coefficient k2.
/// \return Distortion coefficient k2.
public: double K2() const;
/// \brief Get the radial distortion coefficient k3.
/// \return Distortion coefficient k3.
public: double K3() const;
/// \brief Get the tangential distortion coefficient p1.
/// \return Distortion coefficient p1.
public: double P1() const;
/// \brief Get the tangential distortion coefficient p2.
/// \return Distortion coefficient p2.
public: double P2() const;
/// \brief Get the distortion center.
/// \return Distortion center.
public: math::Vector2d Center() const;
/// Documentation inherited
public: virtual void Print(std::ostream &_out) const override;
/// \brief Private data pointer.
IGN_UTILS_IMPL_PTR(dataPtr)
};
}
}
}
#endif
| 30.056818 | 75 | 0.697921 | david-alejo |
388e5ec5e64e14d2b3d64e9982892b58c140e8fd | 2,590 | cpp | C++ | src/minerfund.cpp | danhper/bitcoin-abc | d2b4bfc4d42d054cfebb5d951d23bbe96115f262 | [
"MIT"
] | 2 | 2020-07-17T17:09:58.000Z | 2020-07-17T17:10:09.000Z | src/minerfund.cpp | danhper/bitcoin-abc | d2b4bfc4d42d054cfebb5d951d23bbe96115f262 | [
"MIT"
] | null | null | null | src/minerfund.cpp | danhper/bitcoin-abc | d2b4bfc4d42d054cfebb5d951d23bbe96115f262 | [
"MIT"
] | 1 | 2020-05-17T23:32:17.000Z | 2020-05-17T23:32:17.000Z | // Copyright (c) 2020 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <minerfund.h>
#include <chainparams.h>
#include <consensus/activation.h>
#include <key_io.h> // For DecodeDestination
#include <util/system.h>
#include <validation.h> // For VersionBitsBlockState
static CTxDestination BuildDestination(const std::string &dest) {
const auto mainNetParams = CreateChainParams(CBaseChainParams::MAIN);
return DecodeDestination(dest, *mainNetParams);
}
static const CTxDestination &GetMinerFundDestination() {
static CTxDestination dest =
BuildDestination("pqv2r67sgz3qumufap3h2uuj0zfmnzuv8vqhqfgddk");
return dest;
}
static const CTxDestination &GetMinerABCDestination() {
static CTxDestination dest =
BuildDestination("qzvz0es48sf8wrqy7kn5j5cugka95ztskcanc9laay");
return dest;
}
static const CTxDestination &GetMinerBCHDDestination() {
static CTxDestination dest =
BuildDestination("qrhea03074073ff3zv9whh0nggxc7k03ssh8jv9mkx");
return dest;
}
static const CTxDestination &GetMinerElectronCashDestination() {
static CTxDestination dest =
BuildDestination("pp8d685l8kecnmtyy52ndvq625arz2qwmu42qeeqek");
return dest;
}
std::vector<CTxDestination>
GetMinerFundWhitelist(const Consensus::Params ¶ms,
const CBlockIndex *pindexPrev) {
if (!gArgs.GetBoolArg("-enableminerfund", params.enableMinerFund)) {
return {};
}
if (!IsPhononEnabled(params, pindexPrev)) {
return {};
}
std::vector<CTxDestination> whitelist{};
if (VersionBitsBlockState(params, Consensus::DEPLOYEMENT_MINER_FUND,
pindexPrev) == ThresholdState::ACTIVE) {
whitelist.push_back(GetMinerFundDestination());
}
if (VersionBitsBlockState(params, Consensus::DEPLOYEMENT_MINER_FUND_ABC,
pindexPrev) == ThresholdState::ACTIVE) {
whitelist.push_back(GetMinerABCDestination());
}
if (VersionBitsBlockState(params, Consensus::DEPLOYEMENT_MINER_FUND_BCHD,
pindexPrev) == ThresholdState::ACTIVE) {
whitelist.push_back(GetMinerBCHDDestination());
}
if (VersionBitsBlockState(params,
Consensus::DEPLOYEMENT_MINER_FUND_ELECTRON_CASH,
pindexPrev) == ThresholdState::ACTIVE) {
whitelist.push_back(GetMinerElectronCashDestination());
}
return whitelist;
}
| 33.636364 | 78 | 0.700772 | danhper |
388e8620647ac8baecffe6a25f64b80296a6dc33 | 1,604 | cpp | C++ | assignments/a5/main.cpp | elipwns/Data-Structures | 6c9d6da1254aefd31dfed5edad5987a70c4423a9 | [
"MIT"
] | null | null | null | assignments/a5/main.cpp | elipwns/Data-Structures | 6c9d6da1254aefd31dfed5edad5987a70c4423a9 | [
"MIT"
] | null | null | null | assignments/a5/main.cpp | elipwns/Data-Structures | 6c9d6da1254aefd31dfed5edad5987a70c4423a9 | [
"MIT"
] | null | null | null | /***********************************************************
* Author: eli kloft
* Lab Number: a5
* Filename: a5.cpp
* Date Created: 4/23/13
* Modifications:
*
* Overview:
* a wrapper around the double linked list class in the form of
* an iterator.
*
* Input:
*
*
* Output:
* tests the various funcitons
************************************************************/
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <iostream>
using std::cout;
#include "AbstractIterator.h"
#include "doublelinkedlist.h"
#include "ListIterator.h"
#include "node.h"
#include "BackwardsIterator.h"
#include "ForwardIterator.h"
int main()
{
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
DoubleLinkedList<int> * list = new DoubleLinkedList<int>();
for(int i = 0; i < 8; ++i)
{
list->Append(i);
}
cout <<"Testing forwards\n";
ForwardIterator<int> forward(*list);
while(!forward.IsDone())
{
cout << forward.GetCurrent() << "\n";
forward.MoveNext();
}
cout << forward.GetCurrent() << "\n";
cout << "testing reset\n";
forward.Reset();
cout << forward.GetCurrent() << "\n";
cout << "\n" << "Testing Backwards\n";
BackwardsIterator<int> back(*list);
while(!back.IsDone())
{
cout << back.GetCurrent() << "\n";
back.MoveNext();
}
cout << back.GetCurrent() << "\n";
cout <<"testing reset\n";
back.Reset();
cout << back.GetCurrent() << "\n";
cout << "testing copy and op=" << "\n";
ForwardIterator<int> copyForward(forward);
cout << copyForward.GetCurrent() << " " << forward.GetCurrent() << "\n";
system("Pause");
delete list;
return 0;
} | 22.277778 | 73 | 0.604115 | elipwns |
389193fd20eeddfa2f8d9e99338ae3d1b6913402 | 3,463 | cpp | C++ | DNP3Test/TestVtoLoopbackIntegration.cpp | rajive/dnp3 | f5d8dbcec2085eaeb980e66d07df19b7bb9c20aa | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | DNP3Test/TestVtoLoopbackIntegration.cpp | rajive/dnp3 | f5d8dbcec2085eaeb980e66d07df19b7bb9c20aa | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | DNP3Test/TestVtoLoopbackIntegration.cpp | rajive/dnp3 | f5d8dbcec2085eaeb980e66d07df19b7bb9c20aa | [
"ECL-2.0",
"Apache-2.0"
] | 2 | 2019-03-31T15:27:05.000Z | 2019-09-17T16:12:53.000Z | /*
* Licensed to Green Energy Corp (www.greenenergycorp.com) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. Green Enery
* Corp licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
#include <boost/test/unit_test.hpp>
#include <APL/PhysLoopback.h>
#include <APL/RandomizedBuffer.h>
#include <APLTestTools/MockPhysicalLayerMonitor.h>
#include "VtoIntegrationTestBase.h"
using namespace apl;
using namespace apl::dnp;
class VtoLoopbackTestStack : public VtoIntegrationTestBase
{
public:
VtoLoopbackTestStack(
bool clientOnSlave = true,
bool aImmediateOutput = false,
bool aLogToFile = false,
FilterLevel level = LEV_INFO,
boost::uint16_t port = MACRO_PORT_VALUE) :
VtoIntegrationTestBase(clientOnSlave, aImmediateOutput, aLogToFile, level, port),
loopback(mLog.GetLogger(level, "loopback"), &vtoServer, &timerSource),
local(mLog.GetLogger(level, "mock-client-connection"), &vtoClient, &timerSource, 500) {
}
virtual ~VtoLoopbackTestStack() {
local.Shutdown();
loopback.Shutdown();
}
bool WaitForLocalState(PhysicalLayerState aState, millis_t aTimeout = 30000) {
return testObj.ProceedUntil(boost::bind(&MockPhysicalLayerMonitor::NextStateIs, &local, aState), aTimeout);
}
bool WaitForExpectedDataToBeReceived(millis_t aTimeout = 30000) {
return testObj.ProceedUntil(boost::bind(&MockPhysicalLayerMonitor::AllExpectedDataHasBeenReceived, &local), aTimeout);
}
PhysLoopback loopback;
MockPhysicalLayerMonitor local;
};
BOOST_AUTO_TEST_SUITE(VtoLoopbackIntegrationSuite)
void TestLargeDataLoopback(VtoLoopbackTestStack& arTest, size_t aSizeInBytes)
{
// start everything
arTest.loopback.Start();
arTest.local.Start();
BOOST_REQUIRE(arTest.WaitForLocalState(PLS_OPEN));
// test that a large set of data flowing one way works
CopyableBuffer data(aSizeInBytes);
for(size_t i = 0; i < data.Size(); ++i) data[i] = static_cast<boost::uint8_t>(i % (0xAA));
arTest.local.ExpectData(data);
arTest.local.WriteData(data);
BOOST_REQUIRE(arTest.WaitForExpectedDataToBeReceived(60000));
// this will cause an exception if we receive any more data beyond what we wrote
arTest.testObj.ProceedForTime(1000);
}
#define MACRO_BUFFER_SIZE 1<<20 // 1 << 20 == 1MB, 1<<24 == 16MB
BOOST_AUTO_TEST_CASE(LargeDataLoopbackMasterWritesSlaveEchoes)
{
VtoLoopbackTestStack stack(true, false);
stack.tcpPipe.client.SetCorruptionProbability(0.005);
stack.tcpPipe.server.SetCorruptionProbability(0.005);
TestLargeDataLoopback(stack, MACRO_BUFFER_SIZE);
}
BOOST_AUTO_TEST_CASE(LargeDataLoopbackSlaveWritesMasterEchoes)
{
VtoLoopbackTestStack stack(false, false);
stack.tcpPipe.client.SetCorruptionProbability(0.005);
stack.tcpPipe.server.SetCorruptionProbability(0.005);
TestLargeDataLoopback(stack, MACRO_BUFFER_SIZE);
}
BOOST_AUTO_TEST_SUITE_END()
/* vim: set ts=4 sw=4: */
| 32.980952 | 120 | 0.775628 | rajive |
3891c70b3509b33d381a105e642c254e13a2be8b | 11,071 | cc | C++ | voice_server/src/worker.cc | houbin/alarm | 3c0c150ac85a0f1092d26de55ee3af6beac4fc15 | [
"Apache-2.0"
] | null | null | null | voice_server/src/worker.cc | houbin/alarm | 3c0c150ac85a0f1092d26de55ee3af6beac4fc15 | [
"Apache-2.0"
] | null | null | null | voice_server/src/worker.cc | houbin/alarm | 3c0c150ac85a0f1092d26de55ee3af6beac4fc15 | [
"Apache-2.0"
] | null | null | null | #include <unistd.h>
#include <errno.h>
#include "../util/common.h"
#include "worker.h"
#include <event2/event.h>
#include <event2/bufferevent.h>
#include <event2/buffer.h>
#include "connection.h"
#include "global.h"
#include "../util/slice.h"
#include "../include/utils.h"
#include "tlv_define.h"
#include "master.h"
#include "dispatcher.h"
using namespace util;
// master的连接分配通知
void RecvNotifiedCb(int fd, short event, void *arg)
{
assert(arg != NULL);
Worker *worker = (Worker *)arg;
worker->RecvNotifiedCb(fd, event, arg);
return;
}
void CloseConn(ConnectionInfo *conn_info, uint32_t op_type)
{
assert(conn_info != NULL);
Worker *worker = conn_info->worker;
string data_protocol = worker->GetDataProtocol();
Dispatcher *dispatcher = worker->GetDispatcher();
switch(op_type)
{
case D_TIMEOUT:
dispatcher->HandleTimeout(conn_info);
break;
case D_CLOSE:
dispatcher->HandleClose(conn_info);
break;
case D_ERROR:
dispatcher->HandleError(conn_info);
break;
default:
LOG_ERROR(g_logger, "invalid op type");
break;
}
conn_info->in_buffer_len = 0;
bufferevent_free(conn_info->buffer_event);
delete conn_info;
}
void CloseErrorConn(ConnectionInfo *conn_info)
{
assert(conn_info != NULL);
CloseConn(conn_info, D_ERROR);
}
void ClientTcpReadCb(struct bufferevent *bev, void *arg)
{
int ret = 0;
//uint32_t msg_length = 0;
ConnectionInfo *conn_info = (ConnectionInfo *)arg;
assert(conn_info != NULL);
Worker *worker = conn_info->worker;
string data_protocol = worker->GetDataProtocol();
Dispatcher *dispatcher = worker->GetDispatcher();
while (true)
{
// read util no data or full buffer
uint32_t left_size = 0;
while (true)
{
left_size = CONN_BUFFER_LEN - conn_info->in_buffer_len;
if (left_size == 0)
break;
ret = bufferevent_read(bev, conn_info->in_buffer + conn_info->in_buffer_len, CONN_BUFFER_LEN - conn_info->in_buffer_len);
if (ret <= 0)
break;
conn_info->in_buffer_len += ret;
}
// 处理所有信息
while (true)
{
if (data_protocol == DATA_PROTOCOL_JSON)
{
// json协议是以\r\n为消息边界
string recv_str(conn_info->in_buffer, conn_info->in_buffer_len);
vector<string> json_data_vec;
if (utils::FindCRLF(recv_str))
{
utils::SplitData(recv_str, CRLF, json_data_vec);
unsigned int i = 0;
for(; i < json_data_vec.size(); i++)
{
ret = dispatcher->HandleMsg(conn_info, json_data_vec[i]);
if (ret != 0)
{
CloseErrorConn(conn_info);
return;
}
}
int len = recv_str.find_last_of(CRLF) + 1;
memmove(conn_info->in_buffer, conn_info->in_buffer + len, CONN_BUFFER_LEN - len);
conn_info->in_buffer_len -= len;
if (left_size == 0)
{
break;
}
else
return;
}
}
else if (data_protocol == DATA_PROTOCOL_TLV)
{
// tlv是自己根据消息长度划分消息
if (conn_info->in_buffer_len < kMsgHeaderSize)
{
if (left_size == 0)
break;
else
return;
}
uint32_t type = DecodeFixed32(conn_info->in_buffer);
uint32_t length = DecodeFixed32(conn_info->in_buffer + 4);
uint32_t msg_length = DecodeFixed32(conn_info->in_buffer + 8);
if (type != TYPE_LENGTH || length != 4 || msg_length > CONN_BUFFER_LEN || msg_length < kMsgHeaderSize)
{
// 请求包不合法
LOG_ERROR(g_logger, "pkt invalid, type is %u, length is %u, msg length is %u", type, length, msg_length);
CloseErrorConn(conn_info);
return;
}
if (conn_info->in_buffer_len < msg_length)
{
if (left_size == 0)
break;
else
continue;
}
// 处理数据
//Slice tlv_data(conn_info->in_buffer + 12, msg_length - 12);
string tlv_data(conn_info->in_buffer + 12, msg_length - 12);
ret = dispatcher->HandleMsg(conn_info, tlv_data);
if (ret != 0)
{
CloseErrorConn(conn_info);
return;
}
// 处理下一个协议包,或者继续读
conn_info->in_buffer_len -= msg_length;
if (conn_info == 0)
{
if (left_size == 0)
break;
else
return;
}
memmove(conn_info->in_buffer, conn_info->in_buffer + msg_length, conn_info->in_buffer_len);
}
else
{
LOG_ERROR(g_logger, "data protocol invalid");
}
}
}
return;
}
void ClientTcpErrorCb(struct bufferevent *bev, short event, void *arg)
{
assert(arg != NULL);
ConnectionInfo *conn_info = (ConnectionInfo *)arg;
uint32_t op_type;
if (event & BEV_EVENT_TIMEOUT)
{
LOG_WARN(g_logger, "client tcp event timeout, conn id %" PRIu64 ", cfd %d, ip %s, port %u",
conn_info->conn_id, conn_info->cfd, conn_info->cip.c_str(), conn_info->cport);
op_type = D_TIMEOUT;
}
else if (event & BEV_EVENT_EOF)
{
LOG_WARN(g_logger, "client tcp event eof, conn id %" PRIu64 ", cfd %d, ip %s, port %u",
conn_info->conn_id, conn_info->cfd, conn_info->cip.c_str(), conn_info->cport);
op_type = D_CLOSE;
}
else if (event & BEV_EVENT_ERROR)
{
int error_code = EVUTIL_SOCKET_ERROR();
LOG_DEBUG(g_logger, "client tcp event error, error code %d, msg %s, conn id %" PRIu64 ", cfd %d, ip %s, port %u",
error_code, evutil_socket_error_to_string(error_code), conn_info->conn_id, conn_info->cfd,
conn_info->cip.c_str(), conn_info->cport);
op_type = D_ERROR;
}
CloseConn(conn_info, op_type);
return;
}
Worker::Worker(int i, uint32_t worker_conn_count, int read_timeout, int write_timeout, Master *master)
: id_(i), worker_conn_count_(worker_conn_count), read_timeout_(read_timeout),
write_timeout_(write_timeout), master_(master), conn_info_queue_mutex_("Worker::ConnectionInfoQueueMutex")
{
base_ = NULL;
notified_wfd_ = -1;
notified_rfd_ = -1;
notified_event_ = NULL;
}
Worker::~Worker()
{
}
int32_t Worker::Init()
{
int ret = 0;
int fds[2];
ret = pipe(fds);
if (ret != 0)
{
LOG_ERROR(g_logger, "create pipe error, error %d, msg %d", -errno, strerror(errno));
return -1;
}
notified_rfd_ = fds[0];
notified_wfd_ = fds[1];
base_ = event_base_new();
if(base_ == NULL)
{
LOG_ERROR(g_logger, "event_base_new error");
return -1;
}
notified_event_ = event_new(base_, notified_rfd_, EV_READ|EV_PERSIST, ::RecvNotifiedCb, (void *)this);
if (notified_event_ == NULL)
{
LOG_ERROR(g_logger, "event_new error");
return -1;
}
ret = event_add(notified_event_, NULL);
if (ret != 0)
{
LOG_ERROR(g_logger, "event_add error");
return -1;
}
return 0;
}
int32_t Worker::Start()
{
Create();
return 0;
}
void* Worker::Entry()
{
//int ret = 0;
LOG_INFO(g_logger, "worker %d run", id_);
event_base_dispatch(base_);
event_free(notified_event_);
event_base_free(base_);
LOG_INFO(g_logger, "worker %d done", id_);
return NULL;
}
void Worker::Wait()
{
Join();
return;
}
void Worker::Shutdown()
{
LOG_INFO(g_logger, "worker %d try to shutdown", id_);
event_base_loopbreak(base_);
Wait();
LOG_INFO(g_logger, "worker %d shutdown ok", id_);
return;
}
int Worker::GetId()
{
return id_;
}
int Worker::GetNotifiedWFd()
{
return notified_wfd_;
}
void Worker::RecvNotifiedCb(int fd, short event, void *arg)
{
//int ret = 0;
char buf[1] = {0};
if (read(fd, buf, 1) != 1)
{
LOG_ERROR(g_logger, "read master -> worker notify error");
return;
}
ConnectionInfo *conn_info = NULL;
{
Mutex::Locker lock(conn_info_queue_mutex_);
conn_info = conn_info_queue_.front();
conn_info_queue_.pop_front();
assert(conn_info != NULL);
assert(conn_info->cfd > 0);
}
LOG_DEBUG(g_logger, "pop conn info, conn id %" PRIu64 ", cfd %d, ip %s, port %u", conn_info->conn_id, conn_info->cfd,
conn_info->cip.c_str(), conn_info->cport);
int be_flags = BEV_OPT_CLOSE_ON_FREE;
conn_info->buffer_event = bufferevent_socket_new(base_, conn_info->cfd, be_flags);
if (conn_info->buffer_event == NULL)
{
int error_code = EVUTIL_SOCKET_ERROR();
LOG_ERROR(g_logger, "bufferevent_socket_new error, error %d, msg %s", error_code, evutil_socket_error_to_string(error_code));
return;
}
bufferevent_setcb(conn_info->buffer_event, ::ClientTcpReadCb, NULL, ::ClientTcpErrorCb, (void *)conn_info);
bufferevent_enable(conn_info->buffer_event, EV_READ|EV_PERSIST);
struct timeval hb_val;
if (GetDataProtocol() == "json")
{
hb_val.tv_sec = g_config->Read("json_read_timeout", 60);
}
else
hb_val.tv_sec = g_config->Read("tlv_read_timeout", 60);
hb_val.tv_usec = 0;
bufferevent_set_timeouts(conn_info->buffer_event, &hb_val, NULL);
conn_info->in_buffer_len = 0;
memset(conn_info->in_buffer, 0, sizeof(conn_info->in_buffer));
//conn_info->out_buffer_len = 0;
//memset(conn_info->out_buffer, 0, sizeof(conn_info->out_buffer));
//test sleep 10s
//sleep(10);
LOG_DEBUG(g_logger, "add client to worker, conn id %" PRIu64 ", cfd %d, ip %s, port %u", conn_info->conn_id, conn_info->cfd,
conn_info->cip.c_str(), conn_info->cport);
return;
}
int32_t Worker::PutConnInfo(ConnectionInfo *conn_info)
{
LOG_DEBUG(g_logger, "put conn info, conn id %" PRIu64 "", conn_info->conn_id);
Mutex::Locker lock(conn_info_queue_mutex_);
conn_info_queue_.push_back(conn_info);
return 0;
}
string Worker::GetDataProtocol()
{
return master_->GetDataProtocol();
}
Dispatcher* Worker::GetDispatcher()
{
return master_->GetDispatcher();
}
| 27.816583 | 133 | 0.561738 | houbin |
38969d2c8f0912baf0a68da35c0fea8c0764cd68 | 2,384 | cpp | C++ | native/Sparky-core/src/sp/debug/DebugMenu.cpp | Itay2805/Sparky4j-core-3D | 0ac75c217c4d74c2fb8a9c226992ac6c4662718d | [
"Apache-2.0"
] | null | null | null | native/Sparky-core/src/sp/debug/DebugMenu.cpp | Itay2805/Sparky4j-core-3D | 0ac75c217c4d74c2fb8a9c226992ac6c4662718d | [
"Apache-2.0"
] | null | null | null | native/Sparky-core/src/sp/debug/DebugMenu.cpp | Itay2805/Sparky4j-core-3D | 0ac75c217c4d74c2fb8a9c226992ac6c4662718d | [
"Apache-2.0"
] | null | null | null | #include "sp/sp.h"
#include "DebugMenu.h"
#include "sp/app/Window.h"
#include "sp/graphics/ui/Button.h"
namespace sp { namespace debug {
using namespace maths;
using namespace graphics::ui;
DebugMenu* DebugMenu::s_Instance = nullptr;
DebugMenu::DebugMenu()
: m_Visible(false), m_Slider(nullptr)
{
s_Instance = this;
m_Settings.padding = 0.75f;
m_Settings.fontSize = 24.0f;
Add("Padding", &m_Settings.padding, 0.0f, 2.0f);
Add("Font Size", &m_Settings.fontSize, 8.0f, 48.0f);
m_Slider = nullptr;
m_Panel = new Panel();
}
DebugMenu* DebugMenu::Get()
{
return s_Instance;
}
void DebugMenu::Init()
{
s_Instance = new DebugMenu();
}
void DebugMenu::Add(const String& name)
{
s_Instance->m_ActionList.push_back(new EmptyAction(name));
}
void DebugMenu::Add(const String& name, float* value)
{
Add(name, value, 0.0f, 100.0f);
}
void DebugMenu::Add(const String& name, float* value, float minimum, float maximum)
{
s_Instance->m_ActionList.push_back(new FloatAction(name, [value]() { return *value; }, [value](float v) { *value = v; }, minimum, maximum));
}
bool DebugMenu::IsVisible()
{
return s_Instance->m_Visible;
}
void DebugMenu::SetVisible(bool visible)
{
s_Instance->m_Visible = visible;
if (visible)
s_Instance->OnActivate();
else
s_Instance->OnDeactivate();
}
DebugMenuSettings& DebugMenu::GetSettings()
{
return s_Instance->m_Settings;
}
bool DebugMenu::OnMousePressed(events::MousePressedEvent& e)
{
return false;
}
bool DebugMenu::OnMouseReleased(events::MouseReleasedEvent& e)
{
return false;
}
void DebugMenu::OnActivate()
{
float width = 5.0f + m_Settings.padding;
float height = 1.0f + m_Settings.padding;
float yOffset = height;
for (IAction* action : m_ActionList)
{
float y = 18.0f - yOffset;
m_Panel->Add(new DebugMenuItem(action, Rectangle(0.0f, y, width, height)));
yOffset += height;
}
m_Slider = new Slider({ width, 0.0f, 1.5f, 18.0f }, true);
m_Panel->Add(m_Slider)->SetActive(false);
}
void DebugMenu::OnDeactivate()
{
m_Panel->Clear();
}
void DebugMenu::EditValue(float value, const Slider::ValueChangedCallback& callback)
{
m_Slider->SetCallback(callback);
m_Slider->SetActive(true);
m_Slider->SetValue(value);
}
void DebugMenu::OnUpdate()
{
}
void DebugMenu::OnRender(graphics::Renderer2D& renderer)
{
}
} } | 20.033613 | 142 | 0.687081 | Itay2805 |
38981dcd5cb04af23ffb8d5c92af511fbee7fb06 | 3,628 | cpp | C++ | tests/tests.cpp | FelixVi/PurpleMesa | a2db126be7c9cd7a5ecf53aaa3a5042cf754a23b | [
"MIT"
] | 7 | 2019-06-24T09:08:28.000Z | 2021-03-16T08:57:15.000Z | tests/tests.cpp | FelixVi/PurpleMesa | a2db126be7c9cd7a5ecf53aaa3a5042cf754a23b | [
"MIT"
] | null | null | null | tests/tests.cpp | FelixVi/PurpleMesa | a2db126be7c9cd7a5ecf53aaa3a5042cf754a23b | [
"MIT"
] | null | null | null | #include <NodeFactory.h>
#include <Visitors/AstPrintVisitor.h>
#include <Traversals/PreOrder.h>
#include "vhdl_parser/vhdl_parser_driver.h"
#include "gtest/gtest.h"
#include "Visitors/RTIL/RTILVisitor.h"
#include "Passes/BindArchPass.h"
#include "PurpleMesa.h"
#include "AstNode.h"
TEST(VisitorTests, simple) {
PreOrderTraversal t;
AstPrintVisitor v;
PurpleMesa PM;
auto AST = PM.parseFile("../tests/hdl/simple.vhd");
std::cout << "\n\nTraversing AST ports...\n";
v.setFilter(AstTraversalFilter::ShowPorts);
t.traverse(*AST, v);
std::cout << "End traversing AST ports...\n";
std::cout << "\nTraversing AST...\n";
PM.printAST(*AST);
std::cout << "End traversing AST...\n";
std::cout << "\nCopy AST...\n";
auto newAst = NodeFactory::copy_node(*AST);
std::cout << "Starting RTIL translation of AST copy...\n";
std::static_pointer_cast<TopNode>(newAst)->run();
auto pass = BindArchPass();
pass.run();
//TODO
//Need to handle configuration here
for(auto const& arch : newAst->getChildren()){
if(arch->type() == AstNodeType::ARCHITECTURE){
for(auto const& entity : newAst->getChildren()) {
if (entity->type() == AstNodeType::ENTITYDECLARATION) {
entity->addChild(arch);
newAst->deleteChild(arch);
}
}
}
}
RTILVisitor translator;
t.traverse(*newAst, translator);
ASSERT_FALSE(0);
}
TEST(FIFOTests, simple) {
PreOrderTraversal t;
AstPrintVisitor v;
PurpleMesa PM;
auto AST = PM.parseFile("../tests/hdl/fifo_async.vhd");
std::cout << "\n\nTraversing AST ports...\n";
//v.setFilter(AstTraversalFilter::ShowPorts);
//t.traverse(*AST, v);
std::cout << "End traversing AST ports...\n";
std::cout << "\nTraversing AST...\n";
//PM.printAST(*AST);
std::cout << "End traversing AST...\n";
std::cout << "\nCopy AST...\n";
//auto newAst = NodeFactory::copy_node(*AST);
//We're not doing any RTIL translation (yet)
//std::cout << "Starting RTIL translation of AST copy...\n";
//std::static_pointer_cast<TopNode>(newAst)->run();
//auto pass = BindArchPass();
//pass.run();
//TODO
//Need to handle configuration here
//for(auto const& arch : newAst->getChildren()){
// if(arch->type() == AstNodeType::ARCHITECTURE){
// for(auto const& entity : newAst->getChildren()) {
// if (entity->type() == AstNodeType::ENTITYDECLARATION) {
// entity->addChild(arch);
// newAst->deleteChild(arch);
// }
// }
// }
//}
//RTILVisitor translator;
//t.traverse(*newAst, translator);
ASSERT_FALSE(0);
}
TEST(ParserTests, simple) {
vhdl_driver driver;
std::cout << "\n\n";
ASSERT_FALSE(driver.parse ("../tests/hdl/simple.vhd"));
}
TEST(ASTTests, simple) {
PreOrderTraversal t;
AstPrintVisitor v;
auto nf = NodeFactory();
auto top = nf.make_node(AstNodeType::TOP, nullptr);
auto child1 = nf.make_node(AstNodeType::ENTITYDECLARATION, top);
child1->setProperty("identifier", "testentity");
auto child2 = nf.make_node(AstNodeType::IDENTIFIER, top);
child2->setProperty("identifier", "testsignal");
top->addChild(child1);
top->addChild(child2);
std::cout << "\n\n";
v.setFilter(AstTraversalFilter::ShowAll);
t.traverse(*top, v);
ASSERT_FALSE(0);
}
int main(int argc, char **argv){
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
} | 24.849315 | 73 | 0.60226 | FelixVi |
3898a81e317b195c4634e9ccd30ba4faf4928c02 | 2,429 | hpp | C++ | windows/include/boost/spirit/home/karma/nonterminal/meta_grammar.hpp | jaredhoberock/gotham | e3551cc355646530574d086d7cc2b82e41e8f798 | [
"Apache-2.0"
] | 6 | 2015-12-29T07:21:01.000Z | 2020-05-29T10:47:38.000Z | windows/include/boost/spirit/home/karma/nonterminal/meta_grammar.hpp | jaredhoberock/gotham | e3551cc355646530574d086d7cc2b82e41e8f798 | [
"Apache-2.0"
] | null | null | null | windows/include/boost/spirit/home/karma/nonterminal/meta_grammar.hpp | jaredhoberock/gotham | e3551cc355646530574d086d7cc2b82e41e8f798 | [
"Apache-2.0"
] | null | null | null | // Copyright (c) 2001-2008 Hartmut Kaiser
// Copyright (c) 2001-2007 Joel de Guzman
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#if !defined(BOOST_SPIRIT_KARMA_META_GRAMMAR_MAR_05_2007_0436PM)
#define BOOST_SPIRIT_KARMA_META_GRAMMAR_MAR_05_2007_0436PM
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once // MS compatible compilers support #pragma once
#endif
#include <boost/spirit/home/support/nonterminal/nonterminal.hpp>
#include <boost/spirit/home/karma/nonterminal/nonterminal.hpp>
#include <boost/spirit/home/karma/domain.hpp>
#include <boost/spirit/home/support/meta_grammar.hpp>
#include <boost/utility/enable_if.hpp>
namespace boost { namespace spirit { namespace karma
{
///////////////////////////////////////////////////////////////////////////
// forwards
///////////////////////////////////////////////////////////////////////////
struct nonterminal_director;
template <typename Expr, typename Enable>
struct is_valid_expr;
template <typename Expr, typename Enable>
struct expr_transform;
///////////////////////////////////////////////////////////////////////////
// nonterminal meta-grammar
///////////////////////////////////////////////////////////////////////////
struct nonterminal_meta_grammar
: meta_grammar::terminal_rule<
karma::domain,
nonterminal_holder<proto::_, proto::_>,
nonterminal_director
>
{
};
///////////////////////////////////////////////////////////////////////////
// These specializations non-intrusively hook into the Karma meta-grammar.
// (see karma/meta_grammar.hpp)
///////////////////////////////////////////////////////////////////////////
template <typename Expr>
struct is_valid_expr<
Expr,
typename enable_if<
proto::matches<Expr, nonterminal_meta_grammar>
>::type
>
: mpl::true_
{
};
template <typename Expr>
struct expr_transform<
Expr,
typename enable_if<
proto::matches<Expr, nonterminal_meta_grammar>
>::type
>
: mpl::identity<nonterminal_meta_grammar>
{
};
}}}
#endif
| 33.273973 | 82 | 0.517085 | jaredhoberock |
389a74479864bfee444a9274f3cc97b58e356e29 | 1,575 | cpp | C++ | dependencies/libics/support/cpp_interface/test_ics2a.cpp | slokhorst/diplib | 6e0f420243fd4e84888b5a5c25f805570fafd36d | [
"Apache-2.0"
] | 1 | 2021-07-07T01:02:57.000Z | 2021-07-07T01:02:57.000Z | dependencies/libics/support/cpp_interface/test_ics2a.cpp | slokhorst/diplib | 6e0f420243fd4e84888b5a5c25f805570fafd36d | [
"Apache-2.0"
] | null | null | null | dependencies/libics/support/cpp_interface/test_ics2a.cpp | slokhorst/diplib | 6e0f420243fd4e84888b5a5c25f805570fafd36d | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <memory>
#include <cstdint>
#include <cstring>
#include "libics.hpp"
int main(int argc, const char* argv[]) {
if (argc != 3) {
std::cerr << "Two file names required: in out\n";
exit(-1);
}
try {
// Read image
ics::ICS ip(argv[1], "r");
auto layout = ip.GetLayout();
std::size_t bufsize = ip.GetDataSize();
std::unique_ptr<std::uint8_t[]> buf1{new std::uint8_t[bufsize]};
ip.GetData(buf1.get(), bufsize);
ip.Close();
// Write image
ip.Open(argv[2], "w2");
ip.SetLayout(layout.dataType, layout.dimensions);
std::string datafile{argv[1]};
auto pos = datafile.rfind('.');
if (pos != std::string::npos) {
datafile.erase(pos);
}
datafile += ".ids";
ip.SetSource(datafile, 0);
ip.SetByteOrder(ics::ByteOrder::LittleEndian);
ip.SetCompression(ics::Compression::Uncompressed, 0);
ip.Close();
// Read image
ip.Open(argv[2], "r");
if (bufsize != ip.GetDataSize()) {
std::cerr << "Data in output file not same size as written.\n";
exit(-1);
}
std::unique_ptr<std::uint8_t[]> buf2{new std::uint8_t[bufsize]};
ip.GetData(buf2.get(), bufsize);
ip.Close();
if (memcmp(buf1.get(), buf2.get(), bufsize) != 0) {
std::cerr << "Data in output file does not match data in input.\n";
exit(-1);
}
} catch (std::exception const& e) {
std::cerr << "Exception thrown in libics: " << e.what() << '\n';
exit(-1);
}
}
| 28.125 | 76 | 0.553016 | slokhorst |
389b36b01b3e3100324facfdc6b4d4319dfe51b6 | 2,137 | cpp | C++ | platform/shared/common/Tokenizer.cpp | mensfeld/rhodes | 2962610a314ed563a0b7c83fcae6136913a1b033 | [
"MIT"
] | 173 | 2015-01-02T11:14:08.000Z | 2022-03-05T09:54:54.000Z | platform/shared/common/Tokenizer.cpp | sdwood/rhodes | 8228aa40708dcbcc1d3967a479d1d84364022255 | [
"MIT"
] | 263 | 2015-01-05T04:35:22.000Z | 2021-09-07T06:00:02.000Z | platform/shared/common/Tokenizer.cpp | sdwood/rhodes | 8228aa40708dcbcc1d3967a479d1d84364022255 | [
"MIT"
] | 77 | 2015-01-12T20:57:18.000Z | 2022-02-17T15:15:14.000Z | /*------------------------------------------------------------------------
* (The MIT License)
*
* Copyright (c) 2008-2011 Rhomobile, Inc.
*
* 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.
*
* http://rhomobile.com
*------------------------------------------------------------------------*/
#include "Tokenizer.h"
namespace rho{
namespace common{
CTokenizer::CTokenizer(String str,String delims) {
m_delims = delims;
m_str = str;
m_length = str.length();
m_position = 0;
}
String CTokenizer::nextToken()
{
//eatDelimeters();
int start = m_position;
while (m_position<m_length && m_delims.find(m_str.at(m_position)) == String::npos ) {
m_position++;
}
String strToken = m_str.substr(start,m_position-start);
eatDelimeters();
return strToken;
}
void CTokenizer::eatDelimeters()
{
if ( m_position == m_length )
m_position++;
else if (m_position<m_length)
{
char c = m_str.at(m_position);
if (m_delims.find(c) != String::npos ) {
m_position++;
} else {
return;
}
}
}
boolean CTokenizer::hasMoreTokens()
{
//eatDelimeters();
return (m_position <= m_length);
}
}
}
| 28.493333 | 86 | 0.671502 | mensfeld |
389b7e00dfb963010c182ec18768483d9d48943e | 1,440 | cpp | C++ | src/gui/component-interface/states.cpp | nkrim/cloth-sim | 1bec7313663bafa25250158f575d694486453af2 | [
"MIT"
] | null | null | null | src/gui/component-interface/states.cpp | nkrim/cloth-sim | 1bec7313663bafa25250158f575d694486453af2 | [
"MIT"
] | null | null | null | src/gui/component-interface/states.cpp | nkrim/cloth-sim | 1bec7313663bafa25250158f575d694486453af2 | [
"MIT"
] | null | null | null | /* **************************************************************************** *
* AUTHOR: Noah Krim
* ASSIGNMENT: GUI Cloth Sim
* CLASS: CS_08
* ---------------------------------------------------------------------------- *
* File: states.cpp
* Definition file for States class
* **************************************************************************** */
#include "states.h"
// constructor
States::States()
: _states{0}
{ }
States::States(unsigned states)
: _states{states}
{ }
// mutators
void States::setState(StateBit state, bool value) {
setStates((unsigned)state, value);
}
void States::setStates(unsigned states, bool value) {
if(value)
_states |= states;
else
_states &= ~states;
}
void States::setAllStates(unsigned states) {
_states = states;
}
void States::toggleState(StateBit state) {
_states ^= state;
}
void States::toggleStates(unsigned states) {
_states ^= states;
}
// accessors
unsigned States::getFullStates() const {
return _states;
}
bool States::getState(StateBit state) const {
return _states&state;
}
bool States::anyStates(unsigned states) const {
return _states&states;
}
bool States::allStates(unsigned states) const {
return (_states&states) == states;
}
// specific state combos
bool States::isInteractable() const {
// returns true when neither Disabled nor Hidden
return !(_states & (Disabled|Hidden));
} | 24.827586 | 82 | 0.5625 | nkrim |
389edfecf3adce37290f756b3fde829598f7c082 | 1,222 | cpp | C++ | src/Cancel.11/OutpThrd.cpp | jimbeveridge/multithreading | b092dde13968f91dfb9b86e3d7e760a50f799a96 | [
"MIT"
] | 2 | 2021-11-23T10:43:45.000Z | 2022-01-03T14:51:32.000Z | src/Cancel.11/OutpThrd.cpp | jimbeveridge/multithreading | b092dde13968f91dfb9b86e3d7e760a50f799a96 | [
"MIT"
] | null | null | null | src/Cancel.11/OutpThrd.cpp | jimbeveridge/multithreading | b092dde13968f91dfb9b86e3d7e760a50f799a96 | [
"MIT"
] | 1 | 2020-10-28T15:11:55.000Z | 2020-10-28T15:11:55.000Z | /*
* OutpThrd.cpp
*
* Sample code for "Multithreading Applications in Win32"
* This is from Chapter 11. This sample is discussed in
* the text, but there is no associated listing.
*
* Launch a dialog in another thread using both
* MFC and Win32. Demonstrate the related problems.
*/
#include "stdafx.h"
#include "Cancel.h"
#include "OutpThrd.h"
#include "OutDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////
// COutputCancelDlgThread
IMPLEMENT_DYNCREATE(COutputCancelDlgThread, CWinThread)
COutputCancelDlgThread::COutputCancelDlgThread()
{
}
COutputCancelDlgThread::~COutputCancelDlgThread()
{
}
BOOL COutputCancelDlgThread::InitInstance()
{
m_pDlg->Go();
return TRUE;
}
int COutputCancelDlgThread::ExitInstance()
{
// TODO: perform any per-thread cleanup here
return CWinThread::ExitInstance();
}
BEGIN_MESSAGE_MAP(COutputCancelDlgThread, CWinThread)
//{{AFX_MSG_MAP(COutputCancelDlgThread)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COutputCancelDlgThread message handlers
| 22.218182 | 77 | 0.667758 | jimbeveridge |
389f714370be975472e2f654a71ef11cd3a31abf | 399 | hpp | C++ | library/ATF/$2E938192DD5FA5274C06DCBFB060397F.hpp | lemkova/Yorozuya | f445d800078d9aba5de28f122cedfa03f26a38e4 | [
"MIT"
] | 29 | 2017-07-01T23:08:31.000Z | 2022-02-19T10:22:45.000Z | library/ATF/$2E938192DD5FA5274C06DCBFB060397F.hpp | kotopes/Yorozuya | 605c97d3a627a8f6545cc09f2a1b0a8afdedd33a | [
"MIT"
] | 90 | 2017-10-18T21:24:51.000Z | 2019-06-06T02:30:33.000Z | library/ATF/$2E938192DD5FA5274C06DCBFB060397F.hpp | kotopes/Yorozuya | 605c97d3a627a8f6545cc09f2a1b0a8afdedd33a | [
"MIT"
] | 44 | 2017-12-19T08:02:59.000Z | 2022-02-24T23:15:01.000Z | // This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
#include <__GENERIC_BINDING_INFO.hpp>
START_ATF_NAMESPACE
union $2E938192DD5FA5274C06DCBFB060397F
{
void **pAutoHandle;
void **pPrimitiveHandle;
__GENERIC_BINDING_INFO *pGenericBindingInfo;
};
END_ATF_NAMESPACE
| 24.9375 | 108 | 0.741855 | lemkova |
38a14db8c58a9b74ebff7e08eb548894d3ea62aa | 655 | hpp | C++ | headers/Helpers.hpp | DetlevCM/chemical-kinetics-solver | 7010fd6c72c29a0d912ad0c353ff13a5b643cc04 | [
"MIT"
] | 3 | 2015-07-03T20:14:00.000Z | 2021-02-02T13:45:31.000Z | headers/Helpers.hpp | DetlevCM/chemical-kinetics-solver | 7010fd6c72c29a0d912ad0c353ff13a5b643cc04 | [
"MIT"
] | null | null | null | headers/Helpers.hpp | DetlevCM/chemical-kinetics-solver | 7010fd6c72c29a0d912ad0c353ff13a5b643cc04 | [
"MIT"
] | 4 | 2017-11-09T19:49:18.000Z | 2020-08-04T18:29:28.000Z | /*
* Helpers.h
*
* Created on: 14 May 2016
* Author: DetlevCM
*/
#ifndef HEADERS_HELPERS_HPP_
#define HEADERS_HELPERS_HPP_
string Strip_Single_Line_Comments(
string input ,
vector<string> tokens
);
vector< string > Tokenise_String_To_String(
string input,
string tokens
);
void Tokenise_String_To_String_Append(
vector< string >& data ,
string input, string tokens
);
vector< double > Tokenise_String_To_Double(
string input,
string tokens
);
bool Line_Not_Comment_Or_Empty(
string InputLine
);
bool Test_If_Word_Found(
string string_to_search,
string search_term
);
#endif /* HEADERS_HELPERS_HPP_ */
| 15.595238 | 43 | 0.729771 | DetlevCM |
38a285d19ef0c0e179945b07f012cdf4a1191bc9 | 3,603 | cpp | C++ | object-oriented-programming/Matrix/matrix.cpp | stoimenoff/OOP-Cpp | 5bd60f2ad1bd8c433c786bb9716853946b37b875 | [
"MIT"
] | 3 | 2017-01-07T23:37:14.000Z | 2017-02-23T06:00:56.000Z | object-oriented-programming/Matrix/matrix.cpp | stoimenoff/OOP-Cpp | 5bd60f2ad1bd8c433c786bb9716853946b37b875 | [
"MIT"
] | null | null | null | object-oriented-programming/Matrix/matrix.cpp | stoimenoff/OOP-Cpp | 5bd60f2ad1bd8c433c786bb9716853946b37b875 | [
"MIT"
] | null | null | null | #include "matrix.h"
#include <iostream>
void Matrix::initArray(int rows, int columns)
{
rows = (rows <= 0) ? 1 : rows;
columns = (columns <= 0) ? 1 : columns;
this->rows = rows;
this->columns = columns;
matrix = new int*[rows];
for (int i = 0; i < rows; ++i)
{
matrix[i] = new int[columns];
}
}
void Matrix::copyArray(int** array)
{
for (int i = 0; i < rows; ++i)
{
for (int j = 0; j < columns; ++j)
{
matrix[i][j] = array[i][j];
}
}
}
void Matrix::deleteArray()
{
for (int i = 0; i < rows; ++i)
{
delete[] matrix[i];
}
delete[] matrix;
}
Matrix::Matrix(int rows, int columns)
{
initArray(rows, columns);
}
Matrix::Matrix(int** array, int rows, int columns)
{
initArray(rows, columns);
copyArray(array);
}
Matrix::Matrix(const Matrix &other)
{
initArray(other.rows, other.columns);
copyArray(other.matrix);
}
Matrix::~Matrix()
{
deleteArray();
}
Matrix& Matrix::operator = (const Matrix &other)
{
if (this != &other)
{
deleteArray();
initArray(other.rows, other.columns);
copyArray(other.matrix);
}
return *this;
}
Matrix Matrix::operator * (const Matrix &other) const
{
if (columns != other.rows)
{
std::cout << "Multiplication error, sizes differ!" << std::endl;
//exit(1);
}
Matrix result(rows, other.columns);
int cell;
for (int i = 0; i < rows; ++i)
{
for (int j = 0; j < other.columns; ++j)
{
cell = 0;
for (int k = 0; k < other.rows; ++k)
{
cell += (matrix[i][k] * other.matrix[k][j]);
}
result.matrix[i][j] = cell;
}
}
return result;
}
Matrix Matrix::operator * (const int &lambda) const
{
Matrix result(rows, columns);
for (int i = 0; i < rows; ++i)
{
for (int j = 0; j < columns; ++j)
{
result.matrix[i][j] = matrix[i][j] * lambda;
}
}
return result;
}
Matrix Matrix::operator + (const Matrix &other) const
{
if (rows != other.rows || columns != other.columns)
{
std::cout << "Addition error, sizes differ!" << std::endl;
//exit(1);
}
Matrix result(rows, columns);
for (int i = 0; i < rows; ++i)
{
for (int j = 0; j < columns; ++j)
{
result.matrix[i][j] = matrix[i][j] + other.matrix[i][j];
}
}
return result;
}
Matrix::Row::Row(int* array, int size)
{
this->array = array;
this->size = size;
}
int& Matrix::Row::operator [] (int j)
{
if (j >= size || j < 0)
{
std::cout << "Index out of bounds !" << std::endl;
//exit(1);
}
return array[j];
}
int Matrix::Row::operator [] (int j) const
{
if (j >= size || j < 0)
{
std::cout << "Index out of bounds !" << std::endl;
//exit(1);
}
return array[j];
}
Matrix::Row Matrix::operator [] (int i)
{
if (i >= rows || i < 0)
{
std::cout << "Index out of bounds !" << std::endl;
//exit(1);
}
return Row(matrix[i], columns);
}
const Matrix::Row Matrix::operator [] (int i) const
{
if (i >= rows || i < 0)
{
std::cout << "Index out of bounds !" << std::endl;
//exit(1);
}
return Row(matrix[i], columns);
}
void Matrix::print() const
{
for (int i = 0; i < rows; ++i)
{
for (int j = 0; j < columns; ++j)
{
std::cout << matrix[i][j] << " ";
}
std::cout << std::endl;
}
std::cout << std::endl;
}
//stream operators
std::ostream& operator << (std::ostream& stream, const Matrix& matrix)
{
for (int i = 0; i < matrix.rows; ++i)
{
for (int j = 0; j < matrix.columns; ++j)
{
stream << matrix[i][j] << " ";
}
stream << std::endl;
}
stream << std::endl;
return stream;
}
std::istream& operator >> (std::istream& stream, Matrix& matrix)
{
for (int i = 0; i < matrix.rows; ++i)
{
for (int j = 0; j < matrix.columns; ++j)
{
stream >> matrix[i][j];
}
}
return stream;
}
| 18.28934 | 70 | 0.56897 | stoimenoff |
38a4d815f10abe02d871cd6aa75742802053f007 | 613 | cpp | C++ | Baekjoon/4435.cpp | Twinparadox/AlgorithmProblem | 0190d17555306600cfd439ad5d02a77e663c9a4e | [
"MIT"
] | null | null | null | Baekjoon/4435.cpp | Twinparadox/AlgorithmProblem | 0190d17555306600cfd439ad5d02a77e663c9a4e | [
"MIT"
] | null | null | null | Baekjoon/4435.cpp | Twinparadox/AlgorithmProblem | 0190d17555306600cfd439ad5d02a77e663c9a4e | [
"MIT"
] | null | null | null | #include <iostream>
using namespace std;
int main(void)
{
int t, g, s, gan[6] = { 1,2,3,3,4,10 }, sa[7] = { 1,2, 2,2,3,5,10 }, ganScore, saScore;
cin >> t;
for (int i = 1; i <= t; i++)
{
ganScore = saScore = 0;
for (int i = 0; i < 6; i++)
{
cin >> g;
ganScore += gan[i] * g;
}
for (int i = 0; i < 7; i++)
{
cin >> s;
saScore += sa[i] * s;
}
cout << "Battle " << i << ": ";
if (ganScore > saScore)
cout << "Good triumphs over Evil\n";
else if (ganScore == saScore)
cout << "No victor on this battle field\n";
else
cout << "Evil eradicates all trace of Good\n";
}
}
| 20.433333 | 88 | 0.508972 | Twinparadox |
38a6599e013cdf5890b169e101bd8f6f56c09f89 | 263,058 | cpp | C++ | scipy/integrate/vode.cpp | jasonmccampbell/scipy-refactor | 52708e04bca51e7043248d56383780b1e51e0d8f | [
"BSD-3-Clause"
] | 8 | 2015-10-07T00:37:32.000Z | 2022-01-21T17:02:33.000Z | scipy/integrate/vode.cpp | enthought/scipy-refactor | 52708e04bca51e7043248d56383780b1e51e0d8f | [
"BSD-3-Clause"
] | null | null | null | scipy/integrate/vode.cpp | enthought/scipy-refactor | 52708e04bca51e7043248d56383780b1e51e0d8f | [
"BSD-3-Clause"
] | 8 | 2015-05-09T14:23:57.000Z | 2018-11-15T05:56:00.000Z | /* Cython code section 'h_code' */
#define PY_LONG_LONG long long
using namespace System::Collections;
using namespace System::Numerics;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime;
using namespace System::Security::Permissions;
using namespace System::Linq::Expressions;
using namespace Microsoft::Scripting::Actions;
using namespace Microsoft::Scripting::Runtime;
using namespace Microsoft::Scripting;
using namespace IronPython;
using namespace IronPython::Runtime;
using namespace IronPython::Runtime::Operations;
#define Py_None nullptr
typedef int Py_ssize_t; // IronPython uses "int" for sizes even on 64-bit platforms
#define PY_SSIZE_T_MAX 2147483647
enum class Markers { Default };
static CodeContext^ mk_empty_context(CodeContext^ ctx) {
PythonDictionary^ dict = gcnew PythonDictionary;
dict["__module__"] = "scipy.integrate.vode";
return gcnew CodeContext(dict, ctx->ModuleContext);
}
#define PyBUF_SIMPLE 0
#define PyBUF_WRITABLE 0x0001
#define PyBUF_FORMAT 0x0004
#define PyBUF_ND 0x0008
#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
/* inline attribute */
#ifndef CYTHON_INLINE
#if defined(__GNUC__)
#define CYTHON_INLINE __inline__
#elif defined(_MSC_VER)
#define CYTHON_INLINE __inline
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define CYTHON_INLINE inline
#else
#define CYTHON_INLINE
#endif
#endif
/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
# elif defined(__ICC) || defined(__INTEL_COMPILER)
# define CYTHON_UNUSED __attribute__ ((__unused__))
# else
# define CYTHON_UNUSED
# endif
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE_API__scipy__integrate__vode
#include "npy_common.h"
#include "npy_defs.h"
#include "npy_descriptor.h"
#include "npy_arrayobject.h"
#include "npy_ufunc_object.h"
#include "npy_api.h"
#include "npy_iterators.h"
#include "npy_ironpython.h"
#include "fwrap_ktp_header.h"
#include "vode_fc.h"
#include "setjmp.h"
#include "string.h"
#if !defined(CYTHON_CCOMPLEX)
#define CYTHON_CCOMPLEX 1
#endif
#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x) (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
static const char * __pyx_cfilenm= __FILE__;
#if !defined(CYTHON_CCOMPLEX)
#if defined(__cplusplus)
#define CYTHON_CCOMPLEX 1
#elif defined(_Complex_I)
#define CYTHON_CCOMPLEX 1
#else
#define CYTHON_CCOMPLEX 0
#endif
#endif
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#include <complex>
#else
#include <complex.h>
#endif
#endif
#if CYTHON_CCOMPLEX && !defined(__cplusplus) && defined(__sun__) && defined(__GNUC__)
#undef _Complex_I
#define _Complex_I 1.0fj
#endif
/* Cython code section 'filename_table' */
static const char *__pyx_f[] = {
0
};
/* Cython code section 'utility_code_proto_before_types' */
/* Cython code section 'numeric_typedefs' */
typedef signed char __pyx_t_5numpy_npy_byte;
typedef signed short __pyx_t_5numpy_npy_short;
typedef signed int __pyx_t_5numpy_npy_int;
typedef signed long __pyx_t_5numpy_npy_long;
typedef signed PY_LONG_LONG __pyx_t_5numpy_npy_longlong;
typedef unsigned char __pyx_t_5numpy_npy_ubyte;
typedef unsigned short __pyx_t_5numpy_npy_ushort;
typedef unsigned int __pyx_t_5numpy_npy_uint;
typedef unsigned long __pyx_t_5numpy_npy_ulong;
typedef unsigned PY_LONG_LONG __pyx_t_5numpy_npy_ulonglong;
typedef float __pyx_t_5numpy_npy_float;
typedef double __pyx_t_5numpy_npy_double;
typedef long double __pyx_t_5numpy_npy_longdouble;
typedef double __pyx_t_5numpy_double_t;
typedef int __pyx_t_5numpy_npy_intp;
typedef unsigned int __pyx_t_5numpy_npy_uintp;
typedef __pyx_t_5numpy_npy_byte __pyx_t_5numpy_npy_int8;
typedef __pyx_t_5numpy_npy_short __pyx_t_5numpy_npy_int16;
typedef __pyx_t_5numpy_npy_int __pyx_t_5numpy_npy_int32;
typedef __pyx_t_5numpy_npy_longlong __pyx_t_5numpy_npy_int64;
typedef __pyx_t_5numpy_npy_ubyte __pyx_t_5numpy_npy_uint8;
typedef __pyx_t_5numpy_npy_ushort __pyx_t_5numpy_npy_uint16;
typedef __pyx_t_5numpy_npy_uint __pyx_t_5numpy_npy_uint32;
typedef __pyx_t_5numpy_npy_ulonglong __pyx_t_5numpy_npy_uint64;
typedef __pyx_t_5numpy_npy_float __pyx_t_5numpy_npy_float32;
typedef __pyx_t_5numpy_npy_double __pyx_t_5numpy_npy_float64;
typedef __pyx_t_5numpy_npy_intp __pyx_t_5numpy_intp_t;
typedef __pyx_t_5numpy_npy_int8 __pyx_t_5numpy_int8_t;
typedef __pyx_t_5numpy_npy_int16 __pyx_t_5numpy_int16_t;
typedef __pyx_t_5numpy_npy_int32 __pyx_t_5numpy_int32_t;
typedef __pyx_t_5numpy_npy_int64 __pyx_t_5numpy_int64_t;
typedef __pyx_t_5numpy_npy_uint8 __pyx_t_5numpy_uint8_t;
typedef __pyx_t_5numpy_npy_uint16 __pyx_t_5numpy_uint16_t;
typedef __pyx_t_5numpy_npy_uint32 __pyx_t_5numpy_uint32_t;
typedef __pyx_t_5numpy_npy_uint64 __pyx_t_5numpy_uint64_t;
typedef __pyx_t_5numpy_npy_float32 __pyx_t_5numpy_float32_t;
typedef __pyx_t_5numpy_npy_float64 __pyx_t_5numpy_float64_t;
/* Cython code section 'complex_type_declarations' */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< float > __pyx_t_float_complex;
#else
typedef float _Complex __pyx_t_float_complex;
#endif
#else
typedef struct { float real, imag; } __pyx_t_float_complex;
#endif
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
typedef ::std::complex< double > __pyx_t_double_complex;
#else
typedef double _Complex __pyx_t_double_complex;
#endif
#else
typedef struct { double real, imag; } __pyx_t_double_complex;
#endif
/* Cython code section 'type_declarations' */
/* Type declarations */
typedef void (*__pyx_t_5numpy_NpyUFuncGenericFunction)(char **, __pyx_t_5numpy_npy_intp *, __pyx_t_5numpy_npy_intp *, void *);
typedef __pyx_t_5numpy_NpyUFuncGenericFunction __pyx_t_5numpy_PyUFuncGenericFunction;
typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
typedef npy_cdouble __pyx_t_5numpy_complex_t;
typedef void (*__pyx_t_5numpy_PyArray_CopySwapFunc)(void *, void *, int, NpyArray *);
typedef System::Object^ __pyx_t_5scipy_9integrate_9fwrap_ktp_fw_bytes;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":306
*
*
* cdef np.ndarray fw_asfortranarray(object value, int typenum, int ndim, # <<<<<<<<<<<<<<
* np.npy_intp * coerced_shape,
* bint copy, bint create, int alignment=1):
*/
public ref struct __pyx_opt_args_5scipy_9integrate_4vode_fw_asfortranarray {
int __pyx_n;
int alignment;
};
/* Cython code section 'utility_code_proto' */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
#define __Pyx_CREAL(z) ((z).real())
#define __Pyx_CIMAG(z) ((z).imag())
#else
#define __Pyx_CREAL(z) (__real__(z))
#define __Pyx_CIMAG(z) (__imag__(z))
#endif
#else
#define __Pyx_CREAL(z) ((z).real)
#define __Pyx_CIMAG(z) ((z).imag)
#endif
#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX
#define __Pyx_SET_CREAL(z,x) ((z).real(x))
#define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
#else
#define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
#define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
#endif
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float, float);
#if CYTHON_CCOMPLEX
#define __Pyx_c_eqf(a, b) ((a)==(b))
#define __Pyx_c_sumf(a, b) ((a)+(b))
#define __Pyx_c_difff(a, b) ((a)-(b))
#define __Pyx_c_prodf(a, b) ((a)*(b))
#define __Pyx_c_quotf(a, b) ((a)/(b))
#define __Pyx_c_negf(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zerof(z) ((z)==(float)0)
#define __Pyx_c_conjf(z) (::std::conj(z))
/*#define __Pyx_c_absf(z) (::std::abs(z))*/
#else
#define __Pyx_c_is_zerof(z) ((z)==0)
#define __Pyx_c_conjf(z) (conjf(z))
/*#define __Pyx_c_absf(z) (cabsf(z))*/
#endif
#else
static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex, __pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex);
static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex);
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex);
/*static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex);*/
#endif
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double, double);
#if CYTHON_CCOMPLEX
#define __Pyx_c_eq(a, b) ((a)==(b))
#define __Pyx_c_sum(a, b) ((a)+(b))
#define __Pyx_c_diff(a, b) ((a)-(b))
#define __Pyx_c_prod(a, b) ((a)*(b))
#define __Pyx_c_quot(a, b) ((a)/(b))
#define __Pyx_c_neg(a) (-(a))
#ifdef __cplusplus
#define __Pyx_c_is_zero(z) ((z)==(double)0)
#define __Pyx_c_conj(z) (::std::conj(z))
/*#define __Pyx_c_abs(z) (::std::abs(z))*/
#else
#define __Pyx_c_is_zero(z) ((z)==0)
#define __Pyx_c_conj(z) (conj(z))
/*#define __Pyx_c_abs(z) (cabs(z))*/
#endif
#else
static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex, __pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex);
static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex);
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex);
/*static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex);*/
#endif
/* Cython code section 'module_declarations' */
/* Module declarations from numpy */
/* Module declarations from numpy */
static CYTHON_INLINE NumpyDotNet::dtype^ NpyArray_FindArrayType_2args(System::Object^, NumpyDotNet::dtype^); /*proto*/
static CYTHON_INLINE System::Object^ PyUFunc_FromFuncAndData(__pyx_t_5numpy_PyUFuncGenericFunction *, void **, char *, int, int, int, int, char *, char *, int); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_DescrFromType(int); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_ZEROS(int, __pyx_t_5numpy_npy_intp *, int, int); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_EMPTY(int, __pyx_t_5numpy_npy_intp *, int, int); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_Empty(int, __pyx_t_5numpy_npy_intp *, NumpyDotNet::dtype^, int); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_New(void *, int, __pyx_t_5numpy_npy_intp *, int, __pyx_t_5numpy_npy_intp *, void *, int, int, void *); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_SimpleNew(int, __pyx_t_5numpy_npy_intp *, int); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_SimpleNewFromData(int, __pyx_t_5numpy_npy_intp *, int, void *); /*proto*/
static CYTHON_INLINE int PyArray_CHKFLAGS(NumpyDotNet::ndarray^, int); /*proto*/
static CYTHON_INLINE void *PyArray_DATA(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_intp_t *PyArray_DIMS(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_DESCR(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE int PyArray_ITEMSIZE(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_Return(System::Object^); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_intp_t PyArray_DIM(NumpyDotNet::ndarray^, int); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_NDIM(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_intp_t PyArray_SIZE(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_npy_intp *PyArray_STRIDES(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE __pyx_t_5numpy_npy_intp PyArray_NBYTES(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE NpyArray *PyArray_ARRAY(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE int PyArray_TYPE(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE void *PyArray_Zero(System::Object^); /*proto*/
static CYTHON_INLINE System::Object^ NpyArray_Return(NpyArray *); /*proto*/
static CYTHON_INLINE int PyDataType_TYPE_NUM(NumpyDotNet::dtype^); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_FromAny(System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_CopyFromObject(System::Object^, System::Object^, System::Object^, System::Object^); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_FROMANY(System::Object^, System::Object^, System::Object^, System::Object^, System::Object^); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_ContiguousFromObject(System::Object^, System::Object^, System::Object^, System::Object^); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_CheckFromAny(System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_Check(System::Object^); /*proto*/
static CYTHON_INLINE System::Object^ PyArray_Cast(System::Object^, System::Object^); /*proto*/
static CYTHON_INLINE void import_array(void); /*proto*/
static CYTHON_INLINE System::Object^ PyNumber_Check(System::Object^); /*proto*/
static CYTHON_INLINE NpyArrayIterObject *PyArray_IterNew(NumpyDotNet::ndarray^); /*proto*/
static CYTHON_INLINE NpyArrayIterObject *PyArray_IterAllButAxis(NumpyDotNet::ndarray^, int *); /*proto*/
static CYTHON_INLINE void PyArray_ITER_NEXT(NpyArrayIterObject *); /*proto*/
static CYTHON_INLINE void PyArray_ITER_RESET(NpyArrayIterObject *); /*proto*/
static CYTHON_INLINE void *PyArray_ITER_DATA(NpyArrayIterObject *); /*proto*/
static CYTHON_INLINE NpyArrayNeighborhoodIterObject *PyArray_NeighborhoodIterNew(NpyArrayIterObject *, __pyx_t_5numpy_npy_intp *, int, void *, npy_free_func); /*proto*/
static CYTHON_INLINE int PyArrayNeighborhoodIter_Reset(NpyArrayNeighborhoodIterObject *); /*proto*/
static CYTHON_INLINE int PyArrayNeighborhoodIter_Next(NpyArrayNeighborhoodIterObject *); /*proto*/
static CYTHON_INLINE NumpyDotNet::ndarray^ NpyIter_ARRAY(NpyArrayIterObject *); /*proto*/
/* Module declarations from scipy.integrate.fwrap_ktp */
/* Module declarations from scipy.integrate.vode_fc */
/* Module declarations from scipy.integrate.vode */
[InteropServices::UnmanagedFunctionPointer(InteropServices::CallingConvention::Cdecl)]
public delegate void __pyx_delegate_t_5scipy_9integrate_4vode_dvode_f_cb_wrapper_core(fwi_integer_t *, fwr_dbl_t *, fwr_dbl_t *, fwr_dbl_t *, void *, void *);
static void dvode_f_cb_wrapper_core(fwi_integer_t *, fwr_dbl_t *, fwr_dbl_t *, fwr_dbl_t *, void *, void *); /*proto*/
[InteropServices::UnmanagedFunctionPointer(InteropServices::CallingConvention::Cdecl)]
public delegate void __pyx_delegate_t_5scipy_9integrate_4vode_dvode_jac_cb_wrapper_core(fwi_integer_t *, fwr_dbl_t *, fwr_dbl_t *, fwi_integer_t *, fwi_integer_t *, fwr_dbl_t *, fwi_integer_t *, void *, void *);
static void dvode_jac_cb_wrapper_core(fwi_integer_t *, fwr_dbl_t *, fwr_dbl_t *, fwi_integer_t *, fwi_integer_t *, fwr_dbl_t *, fwi_integer_t *, void *, void *); /*proto*/
[InteropServices::UnmanagedFunctionPointer(InteropServices::CallingConvention::Cdecl)]
public delegate void __pyx_delegate_t_5scipy_9integrate_4vode_zvode_f_cb_wrapper_core(fwi_integer_t *, fwr_dbl_t *, __pyx_t_double_complex *, __pyx_t_double_complex *, void *, void *);
static void zvode_f_cb_wrapper_core(fwi_integer_t *, fwr_dbl_t *, __pyx_t_double_complex *, __pyx_t_double_complex *, void *, void *); /*proto*/
[InteropServices::UnmanagedFunctionPointer(InteropServices::CallingConvention::Cdecl)]
public delegate void __pyx_delegate_t_5scipy_9integrate_4vode_zvode_jac_cb_wrapper_core(fwi_integer_t *, fwr_dbl_t *, __pyx_t_double_complex *, fwi_integer_t *, fwi_integer_t *, __pyx_t_double_complex *, fwi_integer_t *, void *, void *);
static void zvode_jac_cb_wrapper_core(fwi_integer_t *, fwr_dbl_t *, __pyx_t_double_complex *, fwi_integer_t *, fwi_integer_t *, __pyx_t_double_complex *, fwi_integer_t *, void *, void *); /*proto*/
static NumpyDotNet::ndarray^ fw_asfortranarray(System::Object^, int, int, __pyx_t_5numpy_npy_intp *, int, int, ref struct __pyx_opt_args_5scipy_9integrate_4vode_fw_asfortranarray ^__pyx_optional_args); /*proto*/
/* Cython code section 'typeinfo' */
/* Cython code section 'before_global_var' */
#define __Pyx_MODULE_NAME "scipy.integrate.vode"
/* Implementation of scipy.integrate.vode */
namespace clr_vode {
public ref class module_vode sealed abstract {
/* Cython code section 'global_var' */
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_62_36;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_ARGS_64_36;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_68_32;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_exc_info_73_17;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^ >^ >^ __site_call0_73_26;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_90_35;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_ARGS_92_35;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_96_32;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_exc_info_101_17;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^ >^ >^ __site_call0_101_26;
static CallSite< System::Func< CallSite^, System::Object^, fwr_dbl_t >^ >^ __site_cvt_cvt_fwr_dbl_t_104_0;
static CallSite< System::Func< CallSite^, System::Object^, fwr_dbl_t >^ >^ __site_cvt_cvt_fwr_dbl_t_104_0_1;
static CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >^ __site_cvt_cvt_fwi_integer_t_104_0;
static CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >^ __site_cvt_cvt_fwi_integer_t_104_0_1;
static CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >^ __site_cvt_cvt_fwi_integer_t_104_0_2;
static CallSite< System::Func< CallSite^, System::Object^, int >^ >^ __site_cvt_cvt_int_104_0;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_148_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_150_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_152_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_154_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_156_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_158_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_160_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_162_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_164_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_165_47;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_166_51;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_188_36;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_ARGS_190_36;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_194_32;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_exc_info_199_17;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^ >^ >^ __site_call0_199_26;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_215_35;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_ARGS_217_35;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_221_32;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_exc_info_226_17;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^ >^ >^ __site_call0_226_26;
static CallSite< System::Func< CallSite^, System::Object^, fwr_dbl_t >^ >^ __site_cvt_cvt_fwr_dbl_t_228_0;
static CallSite< System::Func< CallSite^, System::Object^, fwr_dbl_t >^ >^ __site_cvt_cvt_fwr_dbl_t_228_0_1;
static CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >^ __site_cvt_cvt_fwi_integer_t_228_0;
static CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >^ __site_cvt_cvt_fwi_integer_t_228_0_1;
static CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >^ __site_cvt_cvt_fwi_integer_t_228_0_2;
static CallSite< System::Func< CallSite^, System::Object^, int >^ >^ __site_cvt_cvt_int_228_0;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_275_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_277_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_279_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_281_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_283_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_285_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_287_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_289_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_291_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_293_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_295_24;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_296_47;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_297_51;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_318_27;
static CallSite< System::Func< CallSite^, System::Object^, bool >^ >^ __site_istrue_323_59;
static CallSite< System::Func< CallSite^, System::Object^, int >^ >^ __site_cvt_cvt_int_330_29;
static CallSite< System::Func< CallSite^, System::Object^, System::Object^, System::Object^ >^ >^ __site_op_mod_332_60;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_332_24;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_append_323_18;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_323_25;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_zeros_325_16;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call3_325_22;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_append_331_18;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_331_25;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_empty_333_16;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call3_333_22;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_append_339_18;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_339_25;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_empty_341_16;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call3_341_22;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_356_53;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_356_53;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_359_48;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_359_48;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_362_48;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_362_48;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_365_69;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_365_69;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_368_52;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_368_52;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_ndarray_375_22;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_ArrayReturn_375_30;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_375_42;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_378_47;
static CallSite< System::Func< CallSite^, System::Object^, PY_LONG_LONG >^ >^ __site_cvt_cvt_PY_LONG_LONG_378_47;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_ndim_381_14;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_384_48;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_384_48;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_387_51;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_387_51;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_390_51;
static CallSite< System::Func< CallSite^, System::Object^, PY_LONG_LONG >^ >^ __site_cvt_cvt_PY_LONG_LONG_390_51;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_393_34;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_393_34;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_396_48;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_396_48;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_NpyArray_401_40;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Zero_401_49;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call1_401_54;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_401_54;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Dtype_409_62;
static CallSite< System::Func< CallSite^, System::Object^, PY_LONG_LONG >^ >^ __site_cvt_cvt_PY_LONG_LONG_409_62;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_NpyArray_414_22;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_FromAny_414_31;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call6_414_39;
static CallSite< System::Func< CallSite^, System::Object^, System::Object^, System::Object^ >^ >^ __site_op_and_423_13;
static CallSite< System::Func< CallSite^, System::Object^, bool >^ >^ __site_istrue_423_13;
static CallSite< System::Func< CallSite^, System::Object^, System::Object^, System::Object^ >^ >^ __site_op_ior_424_14;
static CallSite< System::Func< CallSite^, System::Object^, int >^ >^ __site_cvt_cvt_int_425_77;
static CallSite< System::Func< CallSite^, System::Object^, int >^ >^ __site_cvt_cvt_int_428_78;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_NpyArray_434_22;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_CheckFromAny_434_31;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call6_434_44;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_ndarray_438_29;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_438_21;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_NpyCoreApi_443_22;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_CastToType_443_33;
static CallSite< System::Func< CallSite^, System::Object^, int >^ >^ __site_cvt_cvt_int_443_100;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call3_443_44;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_451_21;
static CallSite< System::Func< CallSite^, System::Object^, bool >^ >^ __site_cvt_bool_451_45;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_ScalarGeneric_451_73;
static CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >^ __site_call2_451_58;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_454_51;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_454_51;
static CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >^ __site_get_Array_457_58;
static CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >^ __site_cvt_cvt___pyx_t_5numpy_npy_intp_457_58;
static CodeContext^ __pyx_context;
/* Cython code section 'decls' */
static int^ __pyx_int_0;
static int^ __pyx_int_1;
static int^ __pyx_int_2;
/* Cython code section 'all_the_rest' */
public:
static System::String^ __module__ = __Pyx_MODULE_NAME;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":31
* void *memcpy(void *dest, void *src, int n)
*
* cdef class fw_CallbackInfo(object): # <<<<<<<<<<<<<<
* def __init__(self, callback, extra_args):
* self.callback = callback
*/
[PythonType]
ref struct fw_CallbackInfo {
System::Object^ callback;
System::Object^ extra_args;
System::Object^ exc;
System::Object^ arg0;
System::Object^ arg1;
System::Object^ arg2;
System::Object^ arg3;
System::Object^ arg4;
System::Object^ arg5;
System::Object^ arg6;
System::Object^ arg7;
System::Object^ arg8;
System::Object^ arg9;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":32
*
* cdef class fw_CallbackInfo(object):
* def __init__(self, callback, extra_args): # <<<<<<<<<<<<<<
* self.callback = callback
* self.extra_args = extra_args
*/
[SpecialName]
virtual int __init__(System::Object^ callback, System::Object^ extra_args) {
System::Object^ __pyx_v_callback = nullptr;
System::Object^ __pyx_v_extra_args = nullptr;
int __pyx_r;
System::Object^ __pyx_v_self = this;
__pyx_v_callback = callback;
__pyx_v_extra_args = extra_args;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":33
* cdef class fw_CallbackInfo(object):
* def __init__(self, callback, extra_args):
* self.callback = callback # <<<<<<<<<<<<<<
* self.extra_args = extra_args
*
*/
((fw_CallbackInfo^)__pyx_v_self)->callback = __pyx_v_callback;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":34
* def __init__(self, callback, extra_args):
* self.callback = callback
* self.extra_args = extra_args # <<<<<<<<<<<<<<
*
* # Callable object to call
*/
((fw_CallbackInfo^)__pyx_v_self)->extra_args = __pyx_v_extra_args;
__pyx_r = 0;
return __pyx_r;
}
};
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":50
*
* cdef fw_CallbackInfo dvode_f_cb_info
* cdef void dvode_f_cb_wrapper_core(fwi_integer_t * n, fwr_dbl_t * t, fwr_dbl_t * y, fwr_dbl_t * ydot, void * rpar, void * ipar): # <<<<<<<<<<<<<<
* global dvode_f_cb_info;
* cdef fw_CallbackInfo info
*/
static void (*__pyx_function_pointer_dvode_f_cb_wrapper_core)(fwi_integer_t *, fwr_dbl_t *, fwr_dbl_t *, fwr_dbl_t *, void *, void *);
typedef void (*__pyx_fp_t_dvode_f_cb_wrapper_core)(fwi_integer_t *, fwr_dbl_t *, fwr_dbl_t *, fwr_dbl_t *, void *, void *);
static __pyx_delegate_t_5scipy_9integrate_4vode_dvode_f_cb_wrapper_core^ __pyx_delegate_val_dvode_f_cb_wrapper_core;
static void dvode_f_cb_wrapper_core(fwi_integer_t *__pyx_v_n, fwr_dbl_t *__pyx_v_t, fwr_dbl_t *__pyx_v_y, fwr_dbl_t *__pyx_v_ydot, void *__pyx_v_rpar, void *__pyx_v_ipar) {
fw_CallbackInfo^ __pyx_v_info;
NumpyDotNet::ndarray^ __pyx_v_y_;
NumpyDotNet::ndarray^ __pyx_v_ydot_;
__pyx_t_5numpy_npy_intp __pyx_v_y_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_ydot_shape[1];
System::Object^ __pyx_v_ydot_ret;
System::Object^ __pyx_t_3 = nullptr;
int __pyx_t_4;
System::Object^ __pyx_t_5 = nullptr;
System::Object^ __pyx_t_6 = nullptr;
__pyx_v_info = nullptr;
__pyx_v_y_ = nullptr;
__pyx_v_ydot_ = nullptr;
__pyx_v_ydot_ret = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":55
* cdef np.ndarray y_, ydot_
* cdef np.npy_intp y_shape[1], ydot_shape[1]
* info = dvode_f_cb_info # <<<<<<<<<<<<<<
* try:
* y_shape[0] = n[0]
*/
__pyx_v_info = __pyx_v_5scipy_9integrate_4vode_dvode_f_cb_info;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":56
* cdef np.npy_intp y_shape[1], ydot_shape[1]
* info = dvode_f_cb_info
* try: # <<<<<<<<<<<<<<
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
*/
try {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":57
* info = dvode_f_cb_info
* try:
* y_shape[0] = n[0] # <<<<<<<<<<<<<<
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* ydot_shape[0] = n[0]
*/
(__pyx_v_y_shape[0]) = (__pyx_v_n[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":58
* try:
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL) # <<<<<<<<<<<<<<
* ydot_shape[0] = n[0]
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwr_dbl_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL)
*/
__pyx_t_3 = PyArray_New(NULL, 1, __pyx_v_y_shape, NPY_DOUBLE, NULL, ((char *)__pyx_v_y), 0, NPY_FARRAY, NULL);
if (__pyx_t_3 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_3) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_y_ = ((NumpyDotNet::ndarray^)__pyx_t_3);
__pyx_t_3 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":59
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* ydot_shape[0] = n[0] # <<<<<<<<<<<<<<
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwr_dbl_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None:
*/
(__pyx_v_ydot_shape[0]) = (__pyx_v_n[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":60
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* ydot_shape[0] = n[0]
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwr_dbl_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL) # <<<<<<<<<<<<<<
* if info.extra_args is None:
* ydot_ret = info.callback(t[0], y_)
*/
__pyx_t_3 = PyArray_New(NULL, 1, __pyx_v_ydot_shape, NPY_DOUBLE, NULL, ((char *)__pyx_v_ydot), 0, NPY_FARRAY, NULL);
if (__pyx_t_3 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_3) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_ydot_ = ((NumpyDotNet::ndarray^)__pyx_t_3);
__pyx_t_3 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":61
* ydot_shape[0] = n[0]
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwr_dbl_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None: # <<<<<<<<<<<<<<
* ydot_ret = info.callback(t[0], y_)
* else:
*/
__pyx_t_4 = (__pyx_v_info->extra_args == nullptr);
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":62
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwr_dbl_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None:
* ydot_ret = info.callback(t[0], y_) # <<<<<<<<<<<<<<
* else:
* ydot_ret = info.callback(t[0], y_, *info.extra_args)
*/
__pyx_t_3 = (__pyx_v_t[0]);
__pyx_t_5 = __site_call2_62_36->Target(__site_call2_62_36, __pyx_context, __pyx_v_info->callback, __pyx_t_3, ((System::Object^)__pyx_v_y_));
__pyx_t_3 = nullptr;
__pyx_v_ydot_ret = __pyx_t_5;
__pyx_t_5 = nullptr;
goto __pyx_L3;
}
/*else*/ {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":64
* ydot_ret = info.callback(t[0], y_)
* else:
* ydot_ret = info.callback(t[0], y_, *info.extra_args) # <<<<<<<<<<<<<<
* if ydot_ is not ydot_ret:
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwr_dbl_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS)
*/
__pyx_t_5 = (__pyx_v_t[0]);
__pyx_t_3 = __site_call2_ARGS_64_36->Target(__site_call2_ARGS_64_36, __pyx_context, __pyx_v_info->callback, __pyx_t_5, ((System::Object^)__pyx_v_y_), __pyx_v_info->extra_args);
__pyx_t_5 = nullptr;
__pyx_v_ydot_ret = __pyx_t_3;
__pyx_t_3 = nullptr;
}
__pyx_L3:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":65
* else:
* ydot_ret = info.callback(t[0], y_, *info.extra_args)
* if ydot_ is not ydot_ret: # <<<<<<<<<<<<<<
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwr_dbl_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS)
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]:
*/
__pyx_t_4 = (((System::Object^)__pyx_v_ydot_) != __pyx_v_ydot_ret);
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":66
* ydot_ret = info.callback(t[0], y_, *info.extra_args)
* if ydot_ is not ydot_ret:
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwr_dbl_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS) # <<<<<<<<<<<<<<
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]:
* raise ValueError("Array returned from callback has illegal shape")
*/
__pyx_t_3 = (System::Object^)(long long)(NPY_DOUBLE);
__pyx_t_5 = (System::Object^)(long long)((NPY_C_CONTIGUOUS | NPY_F_CONTIGUOUS));
__pyx_t_6 = PyArray_FROMANY(__pyx_v_ydot_ret, __pyx_t_3, __pyx_int_1, __pyx_int_1, __pyx_t_5);
__pyx_t_3 = nullptr;
__pyx_t_5 = nullptr;
if (__pyx_t_6 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_6) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_ydot_ = ((NumpyDotNet::ndarray^)__pyx_t_6);
__pyx_t_6 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":67
* if ydot_ is not ydot_ret:
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwr_dbl_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS)
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]: # <<<<<<<<<<<<<<
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_))
*/
__pyx_t_4 = ((__pyx_v_ydot_shape[0]) != (PyArray_DIMS(__pyx_v_ydot_)[0]));
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":68
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwr_dbl_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS)
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]:
* raise ValueError("Array returned from callback has illegal shape") # <<<<<<<<<<<<<<
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_))
* dvode_f_cb_info = info
*/
__pyx_t_6 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_5 = __site_call1_68_32->Target(__site_call1_68_32, __pyx_context, __pyx_t_6, ((System::Object^)"Array returned from callback has illegal shape"));
__pyx_t_6 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_5, nullptr, nullptr);
__pyx_t_5 = nullptr;
goto __pyx_L5;
}
__pyx_L5:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":69
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]:
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_)) # <<<<<<<<<<<<<<
* dvode_f_cb_info = info
* except:
*/
memcpy(__pyx_v_ydot, PyArray_DATA(__pyx_v_ydot_), PyArray_NBYTES(__pyx_v_ydot_));
goto __pyx_L4;
}
__pyx_L4:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":70
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_))
* dvode_f_cb_info = info # <<<<<<<<<<<<<<
* except:
* dvode_f_cb_info = info
*/
__pyx_v_5scipy_9integrate_4vode_dvode_f_cb_info = __pyx_v_info;
} catch (System::Exception^ __pyx_lt_1) {
System::Object^ __pyx_lt_2 = PythonOps::SetCurrentException(__pyx_context, __pyx_lt_1);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":71
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_))
* dvode_f_cb_info = info
* except: # <<<<<<<<<<<<<<
* dvode_f_cb_info = info
* raise sys.exc_info()
*/
/*except:*/ {
// XXX should update traceback here __Pyx_AddTraceback("scipy.integrate.vode.dvode_f_cb_wrapper_core");
PythonOps::BuildExceptionInfo(__pyx_context, __pyx_lt_1);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":72
* dvode_f_cb_info = info
* except:
* dvode_f_cb_info = info # <<<<<<<<<<<<<<
* raise sys.exc_info()
*
*/
__pyx_v_5scipy_9integrate_4vode_dvode_f_cb_info = __pyx_v_info;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":73
* except:
* dvode_f_cb_info = info
* raise sys.exc_info() # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = PythonOps::GetGlobal(__pyx_context, "sys");
__pyx_t_6 = __site_get_exc_info_73_17->Target(__site_get_exc_info_73_17, __pyx_t_5, __pyx_context);
__pyx_t_5 = nullptr;
__pyx_t_5 = __site_call0_73_26->Target(__site_call0_73_26, __pyx_context, __pyx_t_6);
__pyx_t_6 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_5, nullptr, nullptr);
__pyx_t_5 = nullptr;
}
PythonOps::ExceptionHandled(__pyx_context);
}
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":78
*
* cdef fw_CallbackInfo dvode_jac_cb_info
* cdef void dvode_jac_cb_wrapper_core(fwi_integer_t * n, fwr_dbl_t * t, fwr_dbl_t * y, fwi_integer_t * ml, fwi_integer_t * mu, fwr_dbl_t * jac, fwi_integer_t * nrowpd, void * rpar, void * ipar): # <<<<<<<<<<<<<<
* global dvode_jac_cb_info;
* cdef fw_CallbackInfo info
*/
static void (*__pyx_function_pointer_dvode_jac_cb_wrapper_core)(fwi_integer_t *, fwr_dbl_t *, fwr_dbl_t *, fwi_integer_t *, fwi_integer_t *, fwr_dbl_t *, fwi_integer_t *, void *, void *);
typedef void (*__pyx_fp_t_dvode_jac_cb_wrapper_core)(fwi_integer_t *, fwr_dbl_t *, fwr_dbl_t *, fwi_integer_t *, fwi_integer_t *, fwr_dbl_t *, fwi_integer_t *, void *, void *);
static __pyx_delegate_t_5scipy_9integrate_4vode_dvode_jac_cb_wrapper_core^ __pyx_delegate_val_dvode_jac_cb_wrapper_core;
static void dvode_jac_cb_wrapper_core(fwi_integer_t *__pyx_v_n, fwr_dbl_t *__pyx_v_t, fwr_dbl_t *__pyx_v_y, fwi_integer_t *__pyx_v_ml, fwi_integer_t *__pyx_v_mu, fwr_dbl_t *__pyx_v_jac, fwi_integer_t *__pyx_v_nrowpd, void *__pyx_v_rpar, void *__pyx_v_ipar) {
fw_CallbackInfo^ __pyx_v_info;
NumpyDotNet::ndarray^ __pyx_v_y_;
NumpyDotNet::ndarray^ __pyx_v_jac_;
__pyx_t_5numpy_npy_intp __pyx_v_y_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_jac_shape[2];
System::Object^ __pyx_v_jac_ret;
System::Object^ __pyx_t_3 = nullptr;
int __pyx_t_4;
System::Object^ __pyx_t_5 = nullptr;
System::Object^ __pyx_t_6 = nullptr;
int __pyx_t_7;
int __pyx_t_8;
__pyx_v_info = nullptr;
__pyx_v_y_ = nullptr;
__pyx_v_jac_ = nullptr;
__pyx_v_jac_ret = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":83
* cdef np.ndarray y_, jac_
* cdef np.npy_intp y_shape[1], jac_shape[2]
* info = dvode_jac_cb_info # <<<<<<<<<<<<<<
* try:
* y_shape[0] = n[0]
*/
__pyx_v_info = __pyx_v_5scipy_9integrate_4vode_dvode_jac_cb_info;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":84
* cdef np.npy_intp y_shape[1], jac_shape[2]
* info = dvode_jac_cb_info
* try: # <<<<<<<<<<<<<<
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
*/
try {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":85
* info = dvode_jac_cb_info
* try:
* y_shape[0] = n[0] # <<<<<<<<<<<<<<
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0]
*/
(__pyx_v_y_shape[0]) = (__pyx_v_n[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":86
* try:
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL) # <<<<<<<<<<<<<<
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0]
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwr_dbl_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL)
*/
__pyx_t_3 = PyArray_New(NULL, 1, __pyx_v_y_shape, NPY_DOUBLE, NULL, ((char *)__pyx_v_y), 0, NPY_FARRAY, NULL);
if (__pyx_t_3 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_3) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_y_ = ((NumpyDotNet::ndarray^)__pyx_t_3);
__pyx_t_3 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":87
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0] # <<<<<<<<<<<<<<
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwr_dbl_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None:
*/
(__pyx_v_jac_shape[0]) = (__pyx_v_nrowpd[0]);
(__pyx_v_jac_shape[1]) = (__pyx_v_n[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":88
* y_ = np.PyArray_New(NULL, 1, y_shape, fwr_dbl_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0]
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwr_dbl_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL) # <<<<<<<<<<<<<<
* if info.extra_args is None:
* jac_ret = info.callback(t[0], y_)
*/
__pyx_t_3 = PyArray_New(NULL, 2, __pyx_v_jac_shape, NPY_DOUBLE, NULL, ((char *)__pyx_v_jac), 0, NPY_FARRAY, NULL);
if (__pyx_t_3 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_3) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_jac_ = ((NumpyDotNet::ndarray^)__pyx_t_3);
__pyx_t_3 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":89
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0]
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwr_dbl_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None: # <<<<<<<<<<<<<<
* jac_ret = info.callback(t[0], y_)
* else:
*/
__pyx_t_4 = (__pyx_v_info->extra_args == nullptr);
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":90
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwr_dbl_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None:
* jac_ret = info.callback(t[0], y_) # <<<<<<<<<<<<<<
* else:
* jac_ret = info.callback(t[0], y_, *info.extra_args)
*/
__pyx_t_3 = (__pyx_v_t[0]);
__pyx_t_5 = __site_call2_90_35->Target(__site_call2_90_35, __pyx_context, __pyx_v_info->callback, __pyx_t_3, ((System::Object^)__pyx_v_y_));
__pyx_t_3 = nullptr;
__pyx_v_jac_ret = __pyx_t_5;
__pyx_t_5 = nullptr;
goto __pyx_L3;
}
/*else*/ {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":92
* jac_ret = info.callback(t[0], y_)
* else:
* jac_ret = info.callback(t[0], y_, *info.extra_args) # <<<<<<<<<<<<<<
* if jac_ is not jac_ret:
* jac_ = np.PyArray_FROMANY(jac_ret, fwr_dbl_t_enum, 2, 2, np.NPY_F_CONTIGUOUS)
*/
__pyx_t_5 = (__pyx_v_t[0]);
__pyx_t_3 = __site_call2_ARGS_92_35->Target(__site_call2_ARGS_92_35, __pyx_context, __pyx_v_info->callback, __pyx_t_5, ((System::Object^)__pyx_v_y_), __pyx_v_info->extra_args);
__pyx_t_5 = nullptr;
__pyx_v_jac_ret = __pyx_t_3;
__pyx_t_3 = nullptr;
}
__pyx_L3:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":93
* else:
* jac_ret = info.callback(t[0], y_, *info.extra_args)
* if jac_ is not jac_ret: # <<<<<<<<<<<<<<
* jac_ = np.PyArray_FROMANY(jac_ret, fwr_dbl_t_enum, 2, 2, np.NPY_F_CONTIGUOUS)
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]:
*/
__pyx_t_4 = (((System::Object^)__pyx_v_jac_) != __pyx_v_jac_ret);
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":94
* jac_ret = info.callback(t[0], y_, *info.extra_args)
* if jac_ is not jac_ret:
* jac_ = np.PyArray_FROMANY(jac_ret, fwr_dbl_t_enum, 2, 2, np.NPY_F_CONTIGUOUS) # <<<<<<<<<<<<<<
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]:
* raise ValueError("Array returned from callback has illegal shape")
*/
__pyx_t_3 = (System::Object^)(long long)(NPY_DOUBLE);
__pyx_t_5 = (System::Object^)(long long)(NPY_F_CONTIGUOUS);
__pyx_t_6 = PyArray_FROMANY(__pyx_v_jac_ret, __pyx_t_3, __pyx_int_2, __pyx_int_2, __pyx_t_5);
__pyx_t_3 = nullptr;
__pyx_t_5 = nullptr;
if (__pyx_t_6 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_6) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_jac_ = ((NumpyDotNet::ndarray^)__pyx_t_6);
__pyx_t_6 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":95
* if jac_ is not jac_ret:
* jac_ = np.PyArray_FROMANY(jac_ret, fwr_dbl_t_enum, 2, 2, np.NPY_F_CONTIGUOUS)
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]: # <<<<<<<<<<<<<<
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_))
*/
__pyx_t_4 = ((__pyx_v_jac_shape[0]) != (PyArray_DIMS(__pyx_v_jac_)[0]));
if (!__pyx_t_4) {
__pyx_t_7 = ((__pyx_v_jac_shape[1]) != (PyArray_DIMS(__pyx_v_jac_)[1]));
__pyx_t_8 = __pyx_t_7;
} else {
__pyx_t_8 = __pyx_t_4;
}
if (__pyx_t_8) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":96
* jac_ = np.PyArray_FROMANY(jac_ret, fwr_dbl_t_enum, 2, 2, np.NPY_F_CONTIGUOUS)
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]:
* raise ValueError("Array returned from callback has illegal shape") # <<<<<<<<<<<<<<
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_))
* dvode_jac_cb_info = info
*/
__pyx_t_6 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_5 = __site_call1_96_32->Target(__site_call1_96_32, __pyx_context, __pyx_t_6, ((System::Object^)"Array returned from callback has illegal shape"));
__pyx_t_6 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_5, nullptr, nullptr);
__pyx_t_5 = nullptr;
goto __pyx_L5;
}
__pyx_L5:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":97
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]:
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_)) # <<<<<<<<<<<<<<
* dvode_jac_cb_info = info
* except:
*/
memcpy(__pyx_v_jac, PyArray_DATA(__pyx_v_jac_), PyArray_NBYTES(__pyx_v_jac_));
goto __pyx_L4;
}
__pyx_L4:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":98
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_))
* dvode_jac_cb_info = info # <<<<<<<<<<<<<<
* except:
* dvode_jac_cb_info = info
*/
__pyx_v_5scipy_9integrate_4vode_dvode_jac_cb_info = __pyx_v_info;
} catch (System::Exception^ __pyx_lt_1) {
System::Object^ __pyx_lt_2 = PythonOps::SetCurrentException(__pyx_context, __pyx_lt_1);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":99
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_))
* dvode_jac_cb_info = info
* except: # <<<<<<<<<<<<<<
* dvode_jac_cb_info = info
* raise sys.exc_info()
*/
/*except:*/ {
// XXX should update traceback here __Pyx_AddTraceback("scipy.integrate.vode.dvode_jac_cb_wrapper_core");
PythonOps::BuildExceptionInfo(__pyx_context, __pyx_lt_1);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":100
* dvode_jac_cb_info = info
* except:
* dvode_jac_cb_info = info # <<<<<<<<<<<<<<
* raise sys.exc_info()
*
*/
__pyx_v_5scipy_9integrate_4vode_dvode_jac_cb_info = __pyx_v_info;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":101
* except:
* dvode_jac_cb_info = info
* raise sys.exc_info() # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = PythonOps::GetGlobal(__pyx_context, "sys");
__pyx_t_6 = __site_get_exc_info_101_17->Target(__site_get_exc_info_101_17, __pyx_t_5, __pyx_context);
__pyx_t_5 = nullptr;
__pyx_t_5 = __site_call0_101_26->Target(__site_call0_101_26, __pyx_context, __pyx_t_6);
__pyx_t_6 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_5, nullptr, nullptr);
__pyx_t_5 = nullptr;
}
PythonOps::ExceptionHandled(__pyx_context);
}
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":104
*
*
* def dvode(object f, object jac, object y, fwr_dbl_t t, fwr_dbl_t tout, object rtol, object atol, fwi_integer_t itask, fwi_integer_t istate, object rwork, object iwork, fwi_integer_t mf, object f_extra_args=None, object jac_extra_args=None, bint overwrite_y=False): # <<<<<<<<<<<<<<
* """dvode(f, jac, y, t, tout, rtol, atol, itask, istate, rwork, iwork, mf[, f_extra_args, jac_extra_args]) -> (y, t, istate)
*
*/
static System::Object^ dvode(System::Object^ f, System::Object^ jac, System::Object^ y, System::Object^ t, System::Object^ tout, System::Object^ rtol, System::Object^ atol, System::Object^ itask, System::Object^ istate, System::Object^ rwork, System::Object^ iwork, System::Object^ mf, [InteropServices::Optional]System::Object^ f_extra_args, [InteropServices::Optional]System::Object^ jac_extra_args, [InteropServices::Optional]System::Object^ overwrite_y) {
System::Object^ __pyx_v_f = nullptr;
System::Object^ __pyx_v_jac = nullptr;
System::Object^ __pyx_v_y = nullptr;
fwr_dbl_t __pyx_v_t;
fwr_dbl_t __pyx_v_tout;
System::Object^ __pyx_v_rtol = nullptr;
System::Object^ __pyx_v_atol = nullptr;
fwi_integer_t __pyx_v_itask;
fwi_integer_t __pyx_v_istate;
System::Object^ __pyx_v_rwork = nullptr;
System::Object^ __pyx_v_iwork = nullptr;
fwi_integer_t __pyx_v_mf;
System::Object^ __pyx_v_f_extra_args = nullptr;
System::Object^ __pyx_v_jac_extra_args = nullptr;
int __pyx_v_overwrite_y;
fw_CallbackInfo^ __pyx_v_fw_f_cb;
fw_CallbackInfo^ __pyx_v_fw_jac_cb;
fwi_integer_t __pyx_v_neq;
fwi_integer_t __pyx_v_itol;
fwi_integer_t __pyx_v_iopt;
fwi_integer_t __pyx_v_lrw;
fwi_integer_t __pyx_v_liw;
NumpyDotNet::ndarray^ __pyx_v_y_;
NumpyDotNet::ndarray^ __pyx_v_rtol_;
NumpyDotNet::ndarray^ __pyx_v_atol_;
NumpyDotNet::ndarray^ __pyx_v_rwork_;
NumpyDotNet::ndarray^ __pyx_v_iwork_;
__pyx_t_5numpy_npy_intp __pyx_v_y_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_rtol_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_atol_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_rwork_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_iwork_shape[1];
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
long __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
long __pyx_t_6;
long __pyx_t_7;
System::Object^ __pyx_t_8 = nullptr;
System::Object^ __pyx_t_9 = nullptr;
__pyx_v_f = f;
__pyx_v_jac = jac;
__pyx_v_y = y;
__pyx_v_t = __site_cvt_cvt_fwr_dbl_t_104_0->Target(__site_cvt_cvt_fwr_dbl_t_104_0, t);
__pyx_v_tout = __site_cvt_cvt_fwr_dbl_t_104_0_1->Target(__site_cvt_cvt_fwr_dbl_t_104_0_1, tout);
__pyx_v_rtol = rtol;
__pyx_v_atol = atol;
__pyx_v_itask = __site_cvt_cvt_fwi_integer_t_104_0->Target(__site_cvt_cvt_fwi_integer_t_104_0, itask);
__pyx_v_istate = __site_cvt_cvt_fwi_integer_t_104_0_1->Target(__site_cvt_cvt_fwi_integer_t_104_0_1, istate);
__pyx_v_rwork = rwork;
__pyx_v_iwork = iwork;
__pyx_v_mf = __site_cvt_cvt_fwi_integer_t_104_0_2->Target(__site_cvt_cvt_fwi_integer_t_104_0_2, mf);
if (dynamic_cast<System::Reflection::Missing^>(f_extra_args) == nullptr) {
__pyx_v_f_extra_args = f_extra_args;
} else {
__pyx_v_f_extra_args = ((System::Object^)nullptr);
}
if (dynamic_cast<System::Reflection::Missing^>(jac_extra_args) == nullptr) {
__pyx_v_jac_extra_args = jac_extra_args;
} else {
__pyx_v_jac_extra_args = ((System::Object^)nullptr);
}
if (dynamic_cast<System::Reflection::Missing^>(overwrite_y) == nullptr) {
__pyx_v_overwrite_y = __site_cvt_cvt_int_104_0->Target(__site_cvt_cvt_int_104_0, overwrite_y);
} else {
__pyx_v_overwrite_y = ((int)0);
}
__pyx_v_fw_f_cb = nullptr;
__pyx_v_fw_jac_cb = nullptr;
__pyx_v_y_ = nullptr;
__pyx_v_rtol_ = nullptr;
__pyx_v_atol_ = nullptr;
__pyx_v_rwork_ = nullptr;
__pyx_v_iwork_ = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":137
* cdef np.ndarray y_, rtol_, atol_, rwork_, iwork_
* cdef np.npy_intp y_shape[1], rtol_shape[1], atol_shape[1], rwork_shape[1], iwork_shape[1]
* rtol_ = fw_asfortranarray(rtol, fwr_dbl_t_enum, 1, rtol_shape, False, False) # <<<<<<<<<<<<<<
* atol_ = fw_asfortranarray(atol, fwr_dbl_t_enum, 1, atol_shape, False, False)
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4))
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_rtol, NPY_DOUBLE, 1, __pyx_v_rtol_shape, 0, 0, nullptr));
__pyx_v_rtol_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":138
* cdef np.npy_intp y_shape[1], rtol_shape[1], atol_shape[1], rwork_shape[1], iwork_shape[1]
* rtol_ = fw_asfortranarray(rtol, fwr_dbl_t_enum, 1, rtol_shape, False, False)
* atol_ = fw_asfortranarray(atol, fwr_dbl_t_enum, 1, atol_shape, False, False) # <<<<<<<<<<<<<<
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4))
* iopt = 1
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_atol, NPY_DOUBLE, 1, __pyx_v_atol_shape, 0, 0, nullptr));
__pyx_v_atol_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":139
* rtol_ = fw_asfortranarray(rtol, fwr_dbl_t_enum, 1, rtol_shape, False, False)
* atol_ = fw_asfortranarray(atol, fwr_dbl_t_enum, 1, atol_shape, False, False)
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4)) # <<<<<<<<<<<<<<
* iopt = 1
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False)
*/
__pyx_t_3 = ((__pyx_v_atol_shape[0]) <= 1);
if (__pyx_t_3) {
__pyx_t_4 = ((__pyx_v_rtol_shape[0]) <= 1);
__pyx_t_5 = __pyx_t_4;
} else {
__pyx_t_5 = __pyx_t_3;
}
if (__pyx_t_5) {
__pyx_t_2 = 1;
} else {
if (((__pyx_v_rtol_shape[0]) <= 1)) {
__pyx_t_6 = 2;
} else {
if (((__pyx_v_atol_shape[0]) <= 1)) {
__pyx_t_7 = 3;
} else {
__pyx_t_7 = 4;
}
__pyx_t_6 = __pyx_t_7;
}
__pyx_t_2 = __pyx_t_6;
}
__pyx_v_itol = __pyx_t_2;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":140
* atol_ = fw_asfortranarray(atol, fwr_dbl_t_enum, 1, atol_shape, False, False)
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4))
* iopt = 1 # <<<<<<<<<<<<<<
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False)
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False)
*/
__pyx_v_iopt = 1;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":141
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4))
* iopt = 1
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False) # <<<<<<<<<<<<<<
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False)
* y_ = fw_asfortranarray(y, fwr_dbl_t_enum, 1, y_shape, not overwrite_y, False)
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_rwork, NPY_DOUBLE, 1, __pyx_v_rwork_shape, 0, 0, nullptr));
__pyx_v_rwork_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":142
* iopt = 1
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False)
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False) # <<<<<<<<<<<<<<
* y_ = fw_asfortranarray(y, fwr_dbl_t_enum, 1, y_shape, not overwrite_y, False)
* neq = y_shape[0]
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_iwork, NPY_INT, 1, __pyx_v_iwork_shape, 0, 0, nullptr));
__pyx_v_iwork_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":143
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False)
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False)
* y_ = fw_asfortranarray(y, fwr_dbl_t_enum, 1, y_shape, not overwrite_y, False) # <<<<<<<<<<<<<<
* neq = y_shape[0]
* lrw = rwork_shape[0]
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_y, NPY_DOUBLE, 1, __pyx_v_y_shape, (!__pyx_v_overwrite_y), 0, nullptr));
__pyx_v_y_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":144
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False)
* y_ = fw_asfortranarray(y, fwr_dbl_t_enum, 1, y_shape, not overwrite_y, False)
* neq = y_shape[0] # <<<<<<<<<<<<<<
* lrw = rwork_shape[0]
* liw = iwork_shape[0]
*/
__pyx_v_neq = (__pyx_v_y_shape[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":145
* y_ = fw_asfortranarray(y, fwr_dbl_t_enum, 1, y_shape, not overwrite_y, False)
* neq = y_shape[0]
* lrw = rwork_shape[0] # <<<<<<<<<<<<<<
* liw = iwork_shape[0]
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)):
*/
__pyx_v_lrw = (__pyx_v_rwork_shape[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":146
* neq = y_shape[0]
* lrw = rwork_shape[0]
* liw = iwork_shape[0] # <<<<<<<<<<<<<<
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)')
*/
__pyx_v_liw = (__pyx_v_iwork_shape[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":147
* lrw = rwork_shape[0]
* liw = iwork_shape[0]
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)')
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)):
*/
__pyx_t_5 = ((__pyx_v_rtol_shape[0]) <= 1);
if (!__pyx_t_5) {
__pyx_t_3 = ((__pyx_v_rtol_shape[0]) >= __pyx_v_neq);
__pyx_t_4 = __pyx_t_3;
} else {
__pyx_t_4 = __pyx_t_5;
}
__pyx_t_5 = (!__pyx_t_4);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":148
* liw = iwork_shape[0]
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)') # <<<<<<<<<<<<<<
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)')
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_148_24->Target(__site_call1_148_24, __pyx_context, __pyx_t_1, ((System::Object^)"Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L5;
}
__pyx_L5:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":149
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)')
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)')
* if not ((itask > 0) and (itask < 6)):
*/
__pyx_t_5 = ((__pyx_v_atol_shape[0]) <= 1);
if (!__pyx_t_5) {
__pyx_t_4 = ((__pyx_v_atol_shape[0]) >= __pyx_v_neq);
__pyx_t_3 = __pyx_t_4;
} else {
__pyx_t_3 = __pyx_t_5;
}
__pyx_t_5 = (!__pyx_t_3);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":150
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)')
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)') # <<<<<<<<<<<<<<
* if not ((itask > 0) and (itask < 6)):
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)')
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_1 = __site_call1_150_24->Target(__site_call1_150_24, __pyx_context, __pyx_t_8, ((System::Object^)"Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)"));
__pyx_t_8 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_1, nullptr, nullptr);
__pyx_t_1 = nullptr;
goto __pyx_L6;
}
__pyx_L6:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":151
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)')
* if not ((itask > 0) and (itask < 6)): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)')
* if not ((istate > 0) and (istate < 4)):
*/
__pyx_t_5 = (__pyx_v_itask > 0);
if (__pyx_t_5) {
__pyx_t_3 = (__pyx_v_itask < 6);
__pyx_t_4 = __pyx_t_3;
} else {
__pyx_t_4 = __pyx_t_5;
}
__pyx_t_5 = (!__pyx_t_4);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":152
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)')
* if not ((itask > 0) and (itask < 6)):
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)') # <<<<<<<<<<<<<<
* if not ((istate > 0) and (istate < 4)):
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)')
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_152_24->Target(__site_call1_152_24, __pyx_context, __pyx_t_1, ((System::Object^)"Condition on arguments not satisfied: (itask > 0) and (itask < 6)"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L7;
}
__pyx_L7:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":153
* if not ((itask > 0) and (itask < 6)):
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)')
* if not ((istate > 0) and (istate < 4)): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)')
* if not (rwork_shape[0] >= lrw):
*/
__pyx_t_5 = (__pyx_v_istate > 0);
if (__pyx_t_5) {
__pyx_t_4 = (__pyx_v_istate < 4);
__pyx_t_3 = __pyx_t_4;
} else {
__pyx_t_3 = __pyx_t_5;
}
__pyx_t_5 = (!__pyx_t_3);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":154
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)')
* if not ((istate > 0) and (istate < 4)):
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)') # <<<<<<<<<<<<<<
* if not (rwork_shape[0] >= lrw):
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw')
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_1 = __site_call1_154_24->Target(__site_call1_154_24, __pyx_context, __pyx_t_8, ((System::Object^)"Condition on arguments not satisfied: (istate > 0) and (istate < 4)"));
__pyx_t_8 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_1, nullptr, nullptr);
__pyx_t_1 = nullptr;
goto __pyx_L8;
}
__pyx_L8:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":155
* if not ((istate > 0) and (istate < 4)):
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)')
* if not (rwork_shape[0] >= lrw): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw')
* if not (iwork_shape[0] >= liw):
*/
__pyx_t_5 = (!((__pyx_v_rwork_shape[0]) >= __pyx_v_lrw));
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":156
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)')
* if not (rwork_shape[0] >= lrw):
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw') # <<<<<<<<<<<<<<
* if not (iwork_shape[0] >= liw):
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw')
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_156_24->Target(__site_call1_156_24, __pyx_context, __pyx_t_1, ((System::Object^)"Condition on arguments not satisfied: rwork.shape[0] >= lrw"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L9;
}
__pyx_L9:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":157
* if not (rwork_shape[0] >= lrw):
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw')
* if not (iwork_shape[0] >= liw): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw')
* if not (0 <= neq <= y_shape[0]):
*/
__pyx_t_5 = (!((__pyx_v_iwork_shape[0]) >= __pyx_v_liw));
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":158
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw')
* if not (iwork_shape[0] >= liw):
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw') # <<<<<<<<<<<<<<
* if not (0 <= neq <= y_shape[0]):
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed")
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_1 = __site_call1_158_24->Target(__site_call1_158_24, __pyx_context, __pyx_t_8, ((System::Object^)"Condition on arguments not satisfied: iwork.shape[0] >= liw"));
__pyx_t_8 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_1, nullptr, nullptr);
__pyx_t_1 = nullptr;
goto __pyx_L10;
}
__pyx_L10:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":159
* if not (iwork_shape[0] >= liw):
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw')
* if not (0 <= neq <= y_shape[0]): # <<<<<<<<<<<<<<
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed")
* if not (0 <= lrw <= rwork_shape[0]):
*/
__pyx_t_5 = (0 <= __pyx_v_neq);
if (__pyx_t_5) {
__pyx_t_5 = (__pyx_v_neq <= (__pyx_v_y_shape[0]));
}
__pyx_t_3 = (!__pyx_t_5);
if (__pyx_t_3) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":160
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw')
* if not (0 <= neq <= y_shape[0]):
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed") # <<<<<<<<<<<<<<
* if not (0 <= lrw <= rwork_shape[0]):
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed")
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_160_24->Target(__site_call1_160_24, __pyx_context, __pyx_t_1, ((System::Object^)"(0 <= neq <= y.shape[0]) not satisifed"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L11;
}
__pyx_L11:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":161
* if not (0 <= neq <= y_shape[0]):
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed")
* if not (0 <= lrw <= rwork_shape[0]): # <<<<<<<<<<<<<<
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed")
* if not (0 <= liw <= iwork_shape[0]):
*/
__pyx_t_3 = (0 <= __pyx_v_lrw);
if (__pyx_t_3) {
__pyx_t_3 = (__pyx_v_lrw <= (__pyx_v_rwork_shape[0]));
}
__pyx_t_5 = (!__pyx_t_3);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":162
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed")
* if not (0 <= lrw <= rwork_shape[0]):
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed") # <<<<<<<<<<<<<<
* if not (0 <= liw <= iwork_shape[0]):
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed")
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_1 = __site_call1_162_24->Target(__site_call1_162_24, __pyx_context, __pyx_t_8, ((System::Object^)"(0 <= lrw <= rwork.shape[0]) not satisifed"));
__pyx_t_8 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_1, nullptr, nullptr);
__pyx_t_1 = nullptr;
goto __pyx_L12;
}
__pyx_L12:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":163
* if not (0 <= lrw <= rwork_shape[0]):
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed")
* if not (0 <= liw <= iwork_shape[0]): # <<<<<<<<<<<<<<
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed")
* dvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args)
*/
__pyx_t_5 = (0 <= __pyx_v_liw);
if (__pyx_t_5) {
__pyx_t_5 = (__pyx_v_liw <= (__pyx_v_iwork_shape[0]));
}
__pyx_t_3 = (!__pyx_t_5);
if (__pyx_t_3) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":164
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed")
* if not (0 <= liw <= iwork_shape[0]):
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed") # <<<<<<<<<<<<<<
* dvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args)
* dvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args)
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_164_24->Target(__site_call1_164_24, __pyx_context, __pyx_t_1, ((System::Object^)"(0 <= liw <= iwork.shape[0]) not satisifed"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L13;
}
__pyx_L13:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":165
* if not (0 <= liw <= iwork_shape[0]):
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed")
* dvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args) # <<<<<<<<<<<<<<
* dvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args)
* try:
*/
__pyx_t_8 = __site_call2_165_47->Target(__site_call2_165_47, __pyx_context, ((System::Object^)((System::Object^)__pyx_ptype_5scipy_9integrate_4vode_fw_CallbackInfo)), __pyx_v_f, __pyx_v_f_extra_args);
__pyx_v_5scipy_9integrate_4vode_dvode_f_cb_info = ((fw_CallbackInfo^)__pyx_t_8);
__pyx_v_fw_f_cb = ((fw_CallbackInfo^)__pyx_t_8);
__pyx_t_8 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":166
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed")
* dvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args)
* dvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args) # <<<<<<<<<<<<<<
* try:
* fc.dvode(dvode_f_cb_wrapper_core, &neq, <fwr_dbl_t*>np.PyArray_DATA(y_), &t, &tout, &itol, <fwr_dbl_t*>np.PyArray_DATA(rtol_), <fwr_dbl_t*>np.PyArray_DATA(atol_), &itask, &istate, &iopt, <fwr_dbl_t*>np.PyArray_DATA(rwork_), &lrw, <fwi_integer_t*>np.PyArray_DATA(iwork_), &liw, &dvode_jac_cb_wrapper_core, &mf, NULL, NULL)
*/
__pyx_t_8 = __site_call2_166_51->Target(__site_call2_166_51, __pyx_context, ((System::Object^)((System::Object^)__pyx_ptype_5scipy_9integrate_4vode_fw_CallbackInfo)), __pyx_v_jac, __pyx_v_jac_extra_args);
__pyx_v_5scipy_9integrate_4vode_dvode_jac_cb_info = ((fw_CallbackInfo^)__pyx_t_8);
__pyx_v_fw_jac_cb = ((fw_CallbackInfo^)__pyx_t_8);
__pyx_t_8 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":167
* dvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args)
* dvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args)
* try: # <<<<<<<<<<<<<<
* fc.dvode(dvode_f_cb_wrapper_core, &neq, <fwr_dbl_t*>np.PyArray_DATA(y_), &t, &tout, &itol, <fwr_dbl_t*>np.PyArray_DATA(rtol_), <fwr_dbl_t*>np.PyArray_DATA(atol_), &itask, &istate, &iopt, <fwr_dbl_t*>np.PyArray_DATA(rwork_), &lrw, <fwi_integer_t*>np.PyArray_DATA(iwork_), &liw, &dvode_jac_cb_wrapper_core, &mf, NULL, NULL)
* finally:
*/
try {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":168
* dvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args)
* try:
* fc.dvode(dvode_f_cb_wrapper_core, &neq, <fwr_dbl_t*>np.PyArray_DATA(y_), &t, &tout, &itol, <fwr_dbl_t*>np.PyArray_DATA(rtol_), <fwr_dbl_t*>np.PyArray_DATA(atol_), &itask, &istate, &iopt, <fwr_dbl_t*>np.PyArray_DATA(rwork_), &lrw, <fwi_integer_t*>np.PyArray_DATA(iwork_), &liw, &dvode_jac_cb_wrapper_core, &mf, NULL, NULL) # <<<<<<<<<<<<<<
* finally:
* dvode_f_cb_info = None
*/
F_FUNC(dvode,DVODE)(__pyx_function_pointer_dvode_f_cb_wrapper_core, (&__pyx_v_neq), ((fwr_dbl_t *)PyArray_DATA(__pyx_v_y_)), (&__pyx_v_t), (&__pyx_v_tout), (&__pyx_v_itol), ((fwr_dbl_t *)PyArray_DATA(__pyx_v_rtol_)), ((fwr_dbl_t *)PyArray_DATA(__pyx_v_atol_)), (&__pyx_v_itask), (&__pyx_v_istate), (&__pyx_v_iopt), ((fwr_dbl_t *)PyArray_DATA(__pyx_v_rwork_)), (&__pyx_v_lrw), ((fwi_integer_t *)PyArray_DATA(__pyx_v_iwork_)), (&__pyx_v_liw), __pyx_function_pointer_dvode_jac_cb_wrapper_core, (&__pyx_v_mf), NULL, NULL);
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":170
* fc.dvode(dvode_f_cb_wrapper_core, &neq, <fwr_dbl_t*>np.PyArray_DATA(y_), &t, &tout, &itol, <fwr_dbl_t*>np.PyArray_DATA(rtol_), <fwr_dbl_t*>np.PyArray_DATA(atol_), &itask, &istate, &iopt, <fwr_dbl_t*>np.PyArray_DATA(rwork_), &lrw, <fwi_integer_t*>np.PyArray_DATA(iwork_), &liw, &dvode_jac_cb_wrapper_core, &mf, NULL, NULL)
* finally:
* dvode_f_cb_info = None # <<<<<<<<<<<<<<
* return (y_, t, istate,)
*
*/
finally {
__pyx_v_5scipy_9integrate_4vode_dvode_f_cb_info = ((fw_CallbackInfo^)nullptr);
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":171
* finally:
* dvode_f_cb_info = None
* return (y_, t, istate,) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_8 = __pyx_v_t;
__pyx_t_1 = __pyx_v_istate;
__pyx_t_9 = PythonOps::MakeTuple(gcnew array<System::Object^>{((System::Object^)__pyx_v_y_), __pyx_t_8, __pyx_t_1});
__pyx_t_8 = nullptr;
__pyx_t_1 = nullptr;
__pyx_r = __pyx_t_9;
__pyx_t_9 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":176
*
* cdef fw_CallbackInfo zvode_f_cb_info
* cdef void zvode_f_cb_wrapper_core(fwi_integer_t * n, fwr_dbl_t * t, fwc_dbl_complex_t * y, fwc_dbl_complex_t * ydot, void * rpar, void * ipar): # <<<<<<<<<<<<<<
* global zvode_f_cb_info;
* cdef fw_CallbackInfo info
*/
static void (*__pyx_function_pointer_zvode_f_cb_wrapper_core)(fwi_integer_t *, fwr_dbl_t *, __pyx_t_double_complex *, __pyx_t_double_complex *, void *, void *);
typedef void (*__pyx_fp_t_zvode_f_cb_wrapper_core)(fwi_integer_t *, fwr_dbl_t *, __pyx_t_double_complex *, __pyx_t_double_complex *, void *, void *);
static __pyx_delegate_t_5scipy_9integrate_4vode_zvode_f_cb_wrapper_core^ __pyx_delegate_val_zvode_f_cb_wrapper_core;
static void zvode_f_cb_wrapper_core(fwi_integer_t *__pyx_v_n, fwr_dbl_t *__pyx_v_t, __pyx_t_double_complex *__pyx_v_y, __pyx_t_double_complex *__pyx_v_ydot, void *__pyx_v_rpar, void *__pyx_v_ipar) {
fw_CallbackInfo^ __pyx_v_info;
NumpyDotNet::ndarray^ __pyx_v_y_;
NumpyDotNet::ndarray^ __pyx_v_ydot_;
__pyx_t_5numpy_npy_intp __pyx_v_y_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_ydot_shape[1];
System::Object^ __pyx_v_ydot_ret;
System::Object^ __pyx_t_3 = nullptr;
int __pyx_t_4;
System::Object^ __pyx_t_5 = nullptr;
System::Object^ __pyx_t_6 = nullptr;
__pyx_v_info = nullptr;
__pyx_v_y_ = nullptr;
__pyx_v_ydot_ = nullptr;
__pyx_v_ydot_ret = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":181
* cdef np.ndarray y_, ydot_
* cdef np.npy_intp y_shape[1], ydot_shape[1]
* info = zvode_f_cb_info # <<<<<<<<<<<<<<
* try:
* y_shape[0] = n[0]
*/
__pyx_v_info = __pyx_v_5scipy_9integrate_4vode_zvode_f_cb_info;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":182
* cdef np.npy_intp y_shape[1], ydot_shape[1]
* info = zvode_f_cb_info
* try: # <<<<<<<<<<<<<<
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
*/
try {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":183
* info = zvode_f_cb_info
* try:
* y_shape[0] = n[0] # <<<<<<<<<<<<<<
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* ydot_shape[0] = n[0]
*/
(__pyx_v_y_shape[0]) = (__pyx_v_n[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":184
* try:
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL) # <<<<<<<<<<<<<<
* ydot_shape[0] = n[0]
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwc_dbl_complex_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL)
*/
__pyx_t_3 = PyArray_New(NULL, 1, __pyx_v_y_shape, NPY_CDOUBLE, NULL, ((char *)__pyx_v_y), 0, NPY_FARRAY, NULL);
if (__pyx_t_3 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_3) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_y_ = ((NumpyDotNet::ndarray^)__pyx_t_3);
__pyx_t_3 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":185
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* ydot_shape[0] = n[0] # <<<<<<<<<<<<<<
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwc_dbl_complex_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None:
*/
(__pyx_v_ydot_shape[0]) = (__pyx_v_n[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":186
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* ydot_shape[0] = n[0]
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwc_dbl_complex_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL) # <<<<<<<<<<<<<<
* if info.extra_args is None:
* ydot_ret = info.callback(t[0], y_)
*/
__pyx_t_3 = PyArray_New(NULL, 1, __pyx_v_ydot_shape, NPY_CDOUBLE, NULL, ((char *)__pyx_v_ydot), 0, NPY_FARRAY, NULL);
if (__pyx_t_3 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_3) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_ydot_ = ((NumpyDotNet::ndarray^)__pyx_t_3);
__pyx_t_3 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":187
* ydot_shape[0] = n[0]
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwc_dbl_complex_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None: # <<<<<<<<<<<<<<
* ydot_ret = info.callback(t[0], y_)
* else:
*/
__pyx_t_4 = (__pyx_v_info->extra_args == nullptr);
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":188
* ydot_ = np.PyArray_New(NULL, 1, ydot_shape, fwc_dbl_complex_t_enum, NULL, <char*>ydot, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None:
* ydot_ret = info.callback(t[0], y_) # <<<<<<<<<<<<<<
* else:
* ydot_ret = info.callback(t[0], y_, *info.extra_args)
*/
__pyx_t_3 = (__pyx_v_t[0]);
__pyx_t_5 = __site_call2_188_36->Target(__site_call2_188_36, __pyx_context, __pyx_v_info->callback, __pyx_t_3, ((System::Object^)__pyx_v_y_));
__pyx_t_3 = nullptr;
__pyx_v_ydot_ret = __pyx_t_5;
__pyx_t_5 = nullptr;
goto __pyx_L3;
}
/*else*/ {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":190
* ydot_ret = info.callback(t[0], y_)
* else:
* ydot_ret = info.callback(t[0], y_, *info.extra_args) # <<<<<<<<<<<<<<
* if ydot_ is not ydot_ret:
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwc_dbl_complex_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS)
*/
__pyx_t_5 = (__pyx_v_t[0]);
__pyx_t_3 = __site_call2_ARGS_190_36->Target(__site_call2_ARGS_190_36, __pyx_context, __pyx_v_info->callback, __pyx_t_5, ((System::Object^)__pyx_v_y_), __pyx_v_info->extra_args);
__pyx_t_5 = nullptr;
__pyx_v_ydot_ret = __pyx_t_3;
__pyx_t_3 = nullptr;
}
__pyx_L3:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":191
* else:
* ydot_ret = info.callback(t[0], y_, *info.extra_args)
* if ydot_ is not ydot_ret: # <<<<<<<<<<<<<<
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwc_dbl_complex_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS)
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]:
*/
__pyx_t_4 = (((System::Object^)__pyx_v_ydot_) != __pyx_v_ydot_ret);
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":192
* ydot_ret = info.callback(t[0], y_, *info.extra_args)
* if ydot_ is not ydot_ret:
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwc_dbl_complex_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS) # <<<<<<<<<<<<<<
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]:
* raise ValueError("Array returned from callback has illegal shape")
*/
__pyx_t_3 = (System::Object^)(long long)(NPY_CDOUBLE);
__pyx_t_5 = (System::Object^)(long long)((NPY_C_CONTIGUOUS | NPY_F_CONTIGUOUS));
__pyx_t_6 = PyArray_FROMANY(__pyx_v_ydot_ret, __pyx_t_3, __pyx_int_1, __pyx_int_1, __pyx_t_5);
__pyx_t_3 = nullptr;
__pyx_t_5 = nullptr;
if (__pyx_t_6 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_6) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_ydot_ = ((NumpyDotNet::ndarray^)__pyx_t_6);
__pyx_t_6 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":193
* if ydot_ is not ydot_ret:
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwc_dbl_complex_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS)
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]: # <<<<<<<<<<<<<<
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_))
*/
__pyx_t_4 = ((__pyx_v_ydot_shape[0]) != (PyArray_DIMS(__pyx_v_ydot_)[0]));
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":194
* ydot_ = np.PyArray_FROMANY(ydot_ret, fwc_dbl_complex_t_enum, 1, 1, np.NPY_C_CONTIGUOUS|np.NPY_F_CONTIGUOUS)
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]:
* raise ValueError("Array returned from callback has illegal shape") # <<<<<<<<<<<<<<
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_))
* zvode_f_cb_info = info
*/
__pyx_t_6 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_5 = __site_call1_194_32->Target(__site_call1_194_32, __pyx_context, __pyx_t_6, ((System::Object^)"Array returned from callback has illegal shape"));
__pyx_t_6 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_5, nullptr, nullptr);
__pyx_t_5 = nullptr;
goto __pyx_L5;
}
__pyx_L5:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":195
* if ydot_shape[0] != np.PyArray_DIMS(ydot_)[0]:
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_)) # <<<<<<<<<<<<<<
* zvode_f_cb_info = info
* except:
*/
memcpy(__pyx_v_ydot, PyArray_DATA(__pyx_v_ydot_), PyArray_NBYTES(__pyx_v_ydot_));
goto __pyx_L4;
}
__pyx_L4:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":196
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_))
* zvode_f_cb_info = info # <<<<<<<<<<<<<<
* except:
* zvode_f_cb_info = info
*/
__pyx_v_5scipy_9integrate_4vode_zvode_f_cb_info = __pyx_v_info;
} catch (System::Exception^ __pyx_lt_1) {
System::Object^ __pyx_lt_2 = PythonOps::SetCurrentException(__pyx_context, __pyx_lt_1);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":197
* memcpy(ydot, np.PyArray_DATA(ydot_), np.PyArray_NBYTES(ydot_))
* zvode_f_cb_info = info
* except: # <<<<<<<<<<<<<<
* zvode_f_cb_info = info
* raise sys.exc_info()
*/
/*except:*/ {
// XXX should update traceback here __Pyx_AddTraceback("scipy.integrate.vode.zvode_f_cb_wrapper_core");
PythonOps::BuildExceptionInfo(__pyx_context, __pyx_lt_1);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":198
* zvode_f_cb_info = info
* except:
* zvode_f_cb_info = info # <<<<<<<<<<<<<<
* raise sys.exc_info()
*
*/
__pyx_v_5scipy_9integrate_4vode_zvode_f_cb_info = __pyx_v_info;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":199
* except:
* zvode_f_cb_info = info
* raise sys.exc_info() # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = PythonOps::GetGlobal(__pyx_context, "sys");
__pyx_t_6 = __site_get_exc_info_199_17->Target(__site_get_exc_info_199_17, __pyx_t_5, __pyx_context);
__pyx_t_5 = nullptr;
__pyx_t_5 = __site_call0_199_26->Target(__site_call0_199_26, __pyx_context, __pyx_t_6);
__pyx_t_6 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_5, nullptr, nullptr);
__pyx_t_5 = nullptr;
}
PythonOps::ExceptionHandled(__pyx_context);
}
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":203
*
* cdef fw_CallbackInfo zvode_jac_cb_info
* cdef void zvode_jac_cb_wrapper_core(fwi_integer_t * n, fwr_dbl_t * t, fwc_dbl_complex_t * y, fwi_integer_t * ml, fwi_integer_t * mu, fwc_dbl_complex_t * jac, fwi_integer_t * nrowpd, void * rpar, void * ipar): # <<<<<<<<<<<<<<
* global zvode_jac_cb_info;
* cdef fw_CallbackInfo info
*/
static void (*__pyx_function_pointer_zvode_jac_cb_wrapper_core)(fwi_integer_t *, fwr_dbl_t *, __pyx_t_double_complex *, fwi_integer_t *, fwi_integer_t *, __pyx_t_double_complex *, fwi_integer_t *, void *, void *);
typedef void (*__pyx_fp_t_zvode_jac_cb_wrapper_core)(fwi_integer_t *, fwr_dbl_t *, __pyx_t_double_complex *, fwi_integer_t *, fwi_integer_t *, __pyx_t_double_complex *, fwi_integer_t *, void *, void *);
static __pyx_delegate_t_5scipy_9integrate_4vode_zvode_jac_cb_wrapper_core^ __pyx_delegate_val_zvode_jac_cb_wrapper_core;
static void zvode_jac_cb_wrapper_core(fwi_integer_t *__pyx_v_n, fwr_dbl_t *__pyx_v_t, __pyx_t_double_complex *__pyx_v_y, fwi_integer_t *__pyx_v_ml, fwi_integer_t *__pyx_v_mu, __pyx_t_double_complex *__pyx_v_jac, fwi_integer_t *__pyx_v_nrowpd, void *__pyx_v_rpar, void *__pyx_v_ipar) {
fw_CallbackInfo^ __pyx_v_info;
NumpyDotNet::ndarray^ __pyx_v_y_;
NumpyDotNet::ndarray^ __pyx_v_jac_;
__pyx_t_5numpy_npy_intp __pyx_v_y_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_jac_shape[2];
System::Object^ __pyx_v_jac_ret;
System::Object^ __pyx_t_3 = nullptr;
int __pyx_t_4;
System::Object^ __pyx_t_5 = nullptr;
System::Object^ __pyx_t_6 = nullptr;
int __pyx_t_7;
int __pyx_t_8;
__pyx_v_info = nullptr;
__pyx_v_y_ = nullptr;
__pyx_v_jac_ = nullptr;
__pyx_v_jac_ret = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":208
* cdef np.ndarray y_, jac_
* cdef np.npy_intp y_shape[1], jac_shape[2]
* info = zvode_jac_cb_info # <<<<<<<<<<<<<<
* try:
* y_shape[0] = n[0]
*/
__pyx_v_info = __pyx_v_5scipy_9integrate_4vode_zvode_jac_cb_info;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":209
* cdef np.npy_intp y_shape[1], jac_shape[2]
* info = zvode_jac_cb_info
* try: # <<<<<<<<<<<<<<
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
*/
try {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":210
* info = zvode_jac_cb_info
* try:
* y_shape[0] = n[0] # <<<<<<<<<<<<<<
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0]
*/
(__pyx_v_y_shape[0]) = (__pyx_v_n[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":211
* try:
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL) # <<<<<<<<<<<<<<
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0]
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwc_dbl_complex_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL)
*/
__pyx_t_3 = PyArray_New(NULL, 1, __pyx_v_y_shape, NPY_CDOUBLE, NULL, ((char *)__pyx_v_y), 0, NPY_FARRAY, NULL);
if (__pyx_t_3 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_3) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_y_ = ((NumpyDotNet::ndarray^)__pyx_t_3);
__pyx_t_3 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":212
* y_shape[0] = n[0]
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0] # <<<<<<<<<<<<<<
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwc_dbl_complex_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None:
*/
(__pyx_v_jac_shape[0]) = (__pyx_v_nrowpd[0]);
(__pyx_v_jac_shape[1]) = (__pyx_v_n[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":213
* y_ = np.PyArray_New(NULL, 1, y_shape, fwc_dbl_complex_t_enum, NULL, <char*>y, 0, np.NPY_FARRAY, NULL)
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0]
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwc_dbl_complex_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL) # <<<<<<<<<<<<<<
* if info.extra_args is None:
* jac_ret = info.callback(t[0], y_)
*/
__pyx_t_3 = PyArray_New(NULL, 2, __pyx_v_jac_shape, NPY_CDOUBLE, NULL, ((char *)__pyx_v_jac), 0, NPY_FARRAY, NULL);
if (__pyx_t_3 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_3) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_jac_ = ((NumpyDotNet::ndarray^)__pyx_t_3);
__pyx_t_3 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":214
* jac_shape[0] = nrowpd[0]; jac_shape[1] = n[0]
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwc_dbl_complex_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None: # <<<<<<<<<<<<<<
* jac_ret = info.callback(t[0], y_)
* else:
*/
__pyx_t_4 = (__pyx_v_info->extra_args == nullptr);
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":215
* jac_ = np.PyArray_New(NULL, 2, jac_shape, fwc_dbl_complex_t_enum, NULL, <char*>jac, 0, np.NPY_FARRAY, NULL)
* if info.extra_args is None:
* jac_ret = info.callback(t[0], y_) # <<<<<<<<<<<<<<
* else:
* jac_ret = info.callback(t[0], y_, *info.extra_args)
*/
__pyx_t_3 = (__pyx_v_t[0]);
__pyx_t_5 = __site_call2_215_35->Target(__site_call2_215_35, __pyx_context, __pyx_v_info->callback, __pyx_t_3, ((System::Object^)__pyx_v_y_));
__pyx_t_3 = nullptr;
__pyx_v_jac_ret = __pyx_t_5;
__pyx_t_5 = nullptr;
goto __pyx_L3;
}
/*else*/ {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":217
* jac_ret = info.callback(t[0], y_)
* else:
* jac_ret = info.callback(t[0], y_, *info.extra_args) # <<<<<<<<<<<<<<
* if jac_ is not jac_ret:
* jac_ = np.PyArray_FROMANY(jac_ret, fwc_dbl_complex_t_enum, 2, 2, np.NPY_F_CONTIGUOUS)
*/
__pyx_t_5 = (__pyx_v_t[0]);
__pyx_t_3 = __site_call2_ARGS_217_35->Target(__site_call2_ARGS_217_35, __pyx_context, __pyx_v_info->callback, __pyx_t_5, ((System::Object^)__pyx_v_y_), __pyx_v_info->extra_args);
__pyx_t_5 = nullptr;
__pyx_v_jac_ret = __pyx_t_3;
__pyx_t_3 = nullptr;
}
__pyx_L3:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":218
* else:
* jac_ret = info.callback(t[0], y_, *info.extra_args)
* if jac_ is not jac_ret: # <<<<<<<<<<<<<<
* jac_ = np.PyArray_FROMANY(jac_ret, fwc_dbl_complex_t_enum, 2, 2, np.NPY_F_CONTIGUOUS)
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]:
*/
__pyx_t_4 = (((System::Object^)__pyx_v_jac_) != __pyx_v_jac_ret);
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":219
* jac_ret = info.callback(t[0], y_, *info.extra_args)
* if jac_ is not jac_ret:
* jac_ = np.PyArray_FROMANY(jac_ret, fwc_dbl_complex_t_enum, 2, 2, np.NPY_F_CONTIGUOUS) # <<<<<<<<<<<<<<
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]:
* raise ValueError("Array returned from callback has illegal shape")
*/
__pyx_t_3 = (System::Object^)(long long)(NPY_CDOUBLE);
__pyx_t_5 = (System::Object^)(long long)(NPY_F_CONTIGUOUS);
__pyx_t_6 = PyArray_FROMANY(__pyx_v_jac_ret, __pyx_t_3, __pyx_int_2, __pyx_int_2, __pyx_t_5);
__pyx_t_3 = nullptr;
__pyx_t_5 = nullptr;
if (__pyx_t_6 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_6) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_jac_ = ((NumpyDotNet::ndarray^)__pyx_t_6);
__pyx_t_6 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":220
* if jac_ is not jac_ret:
* jac_ = np.PyArray_FROMANY(jac_ret, fwc_dbl_complex_t_enum, 2, 2, np.NPY_F_CONTIGUOUS)
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]: # <<<<<<<<<<<<<<
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_))
*/
__pyx_t_4 = ((__pyx_v_jac_shape[0]) != (PyArray_DIMS(__pyx_v_jac_)[0]));
if (!__pyx_t_4) {
__pyx_t_7 = ((__pyx_v_jac_shape[1]) != (PyArray_DIMS(__pyx_v_jac_)[1]));
__pyx_t_8 = __pyx_t_7;
} else {
__pyx_t_8 = __pyx_t_4;
}
if (__pyx_t_8) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":221
* jac_ = np.PyArray_FROMANY(jac_ret, fwc_dbl_complex_t_enum, 2, 2, np.NPY_F_CONTIGUOUS)
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]:
* raise ValueError("Array returned from callback has illegal shape") # <<<<<<<<<<<<<<
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_))
* zvode_jac_cb_info = info
*/
__pyx_t_6 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_5 = __site_call1_221_32->Target(__site_call1_221_32, __pyx_context, __pyx_t_6, ((System::Object^)"Array returned from callback has illegal shape"));
__pyx_t_6 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_5, nullptr, nullptr);
__pyx_t_5 = nullptr;
goto __pyx_L5;
}
__pyx_L5:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":222
* if jac_shape[0] != np.PyArray_DIMS(jac_)[0] or jac_shape[1] != np.PyArray_DIMS(jac_)[1]:
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_)) # <<<<<<<<<<<<<<
* zvode_jac_cb_info = info
* except:
*/
memcpy(__pyx_v_jac, PyArray_DATA(__pyx_v_jac_), PyArray_NBYTES(__pyx_v_jac_));
goto __pyx_L4;
}
__pyx_L4:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":223
* raise ValueError("Array returned from callback has illegal shape")
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_))
* zvode_jac_cb_info = info # <<<<<<<<<<<<<<
* except:
* zvode_jac_cb_info = info
*/
__pyx_v_5scipy_9integrate_4vode_zvode_jac_cb_info = __pyx_v_info;
} catch (System::Exception^ __pyx_lt_1) {
System::Object^ __pyx_lt_2 = PythonOps::SetCurrentException(__pyx_context, __pyx_lt_1);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":224
* memcpy(jac, np.PyArray_DATA(jac_), np.PyArray_NBYTES(jac_))
* zvode_jac_cb_info = info
* except: # <<<<<<<<<<<<<<
* zvode_jac_cb_info = info
* raise sys.exc_info()
*/
/*except:*/ {
// XXX should update traceback here __Pyx_AddTraceback("scipy.integrate.vode.zvode_jac_cb_wrapper_core");
PythonOps::BuildExceptionInfo(__pyx_context, __pyx_lt_1);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":225
* zvode_jac_cb_info = info
* except:
* zvode_jac_cb_info = info # <<<<<<<<<<<<<<
* raise sys.exc_info()
*
*/
__pyx_v_5scipy_9integrate_4vode_zvode_jac_cb_info = __pyx_v_info;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":226
* except:
* zvode_jac_cb_info = info
* raise sys.exc_info() # <<<<<<<<<<<<<<
*
* def zvode(object f, object jac, object y, fwr_dbl_t t, fwr_dbl_t tout, object rtol, object atol, fwi_integer_t itask, fwi_integer_t istate, object zwork, object rwork, object iwork, fwi_integer_t mf, object f_extra_args=None, object jac_extra_args=None, bint overwrite_y=False):
*/
__pyx_t_5 = PythonOps::GetGlobal(__pyx_context, "sys");
__pyx_t_6 = __site_get_exc_info_226_17->Target(__site_get_exc_info_226_17, __pyx_t_5, __pyx_context);
__pyx_t_5 = nullptr;
__pyx_t_5 = __site_call0_226_26->Target(__site_call0_226_26, __pyx_context, __pyx_t_6);
__pyx_t_6 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_5, nullptr, nullptr);
__pyx_t_5 = nullptr;
}
PythonOps::ExceptionHandled(__pyx_context);
}
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":228
* raise sys.exc_info()
*
* def zvode(object f, object jac, object y, fwr_dbl_t t, fwr_dbl_t tout, object rtol, object atol, fwi_integer_t itask, fwi_integer_t istate, object zwork, object rwork, object iwork, fwi_integer_t mf, object f_extra_args=None, object jac_extra_args=None, bint overwrite_y=False): # <<<<<<<<<<<<<<
* """zvode(f, jac, y, t, tout, rtol, atol, itask, istate, zwork, rwork, iwork, mf[, overwrite_y]) -> (y, t, istate)
*
*/
static System::Object^ zvode(System::Object^ f, System::Object^ jac, System::Object^ y, System::Object^ t, System::Object^ tout, System::Object^ rtol, System::Object^ atol, System::Object^ itask, System::Object^ istate, System::Object^ zwork, System::Object^ rwork, System::Object^ iwork, System::Object^ mf, [InteropServices::Optional]System::Object^ f_extra_args, [InteropServices::Optional]System::Object^ jac_extra_args, [InteropServices::Optional]System::Object^ overwrite_y) {
System::Object^ __pyx_v_f = nullptr;
System::Object^ __pyx_v_jac = nullptr;
System::Object^ __pyx_v_y = nullptr;
fwr_dbl_t __pyx_v_t;
fwr_dbl_t __pyx_v_tout;
System::Object^ __pyx_v_rtol = nullptr;
System::Object^ __pyx_v_atol = nullptr;
fwi_integer_t __pyx_v_itask;
fwi_integer_t __pyx_v_istate;
System::Object^ __pyx_v_zwork = nullptr;
System::Object^ __pyx_v_rwork = nullptr;
System::Object^ __pyx_v_iwork = nullptr;
fwi_integer_t __pyx_v_mf;
System::Object^ __pyx_v_f_extra_args = nullptr;
System::Object^ __pyx_v_jac_extra_args = nullptr;
int __pyx_v_overwrite_y;
fw_CallbackInfo^ __pyx_v_fw_f_cb;
fw_CallbackInfo^ __pyx_v_fw_jac_cb;
fwi_integer_t __pyx_v_neq;
fwi_integer_t __pyx_v_itol;
fwi_integer_t __pyx_v_iopt;
fwi_integer_t __pyx_v_lzw;
fwi_integer_t __pyx_v_lrw;
fwi_integer_t __pyx_v_liw;
NumpyDotNet::ndarray^ __pyx_v_y_;
NumpyDotNet::ndarray^ __pyx_v_rtol_;
NumpyDotNet::ndarray^ __pyx_v_atol_;
NumpyDotNet::ndarray^ __pyx_v_zwork_;
NumpyDotNet::ndarray^ __pyx_v_rwork_;
NumpyDotNet::ndarray^ __pyx_v_iwork_;
__pyx_t_5numpy_npy_intp __pyx_v_y_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_rtol_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_atol_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_zwork_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_rwork_shape[1];
__pyx_t_5numpy_npy_intp __pyx_v_iwork_shape[1];
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
long __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
int __pyx_t_5;
long __pyx_t_6;
long __pyx_t_7;
System::Object^ __pyx_t_8 = nullptr;
System::Object^ __pyx_t_9 = nullptr;
__pyx_v_f = f;
__pyx_v_jac = jac;
__pyx_v_y = y;
__pyx_v_t = __site_cvt_cvt_fwr_dbl_t_228_0->Target(__site_cvt_cvt_fwr_dbl_t_228_0, t);
__pyx_v_tout = __site_cvt_cvt_fwr_dbl_t_228_0_1->Target(__site_cvt_cvt_fwr_dbl_t_228_0_1, tout);
__pyx_v_rtol = rtol;
__pyx_v_atol = atol;
__pyx_v_itask = __site_cvt_cvt_fwi_integer_t_228_0->Target(__site_cvt_cvt_fwi_integer_t_228_0, itask);
__pyx_v_istate = __site_cvt_cvt_fwi_integer_t_228_0_1->Target(__site_cvt_cvt_fwi_integer_t_228_0_1, istate);
__pyx_v_zwork = zwork;
__pyx_v_rwork = rwork;
__pyx_v_iwork = iwork;
__pyx_v_mf = __site_cvt_cvt_fwi_integer_t_228_0_2->Target(__site_cvt_cvt_fwi_integer_t_228_0_2, mf);
if (dynamic_cast<System::Reflection::Missing^>(f_extra_args) == nullptr) {
__pyx_v_f_extra_args = f_extra_args;
} else {
__pyx_v_f_extra_args = ((System::Object^)nullptr);
}
if (dynamic_cast<System::Reflection::Missing^>(jac_extra_args) == nullptr) {
__pyx_v_jac_extra_args = jac_extra_args;
} else {
__pyx_v_jac_extra_args = ((System::Object^)nullptr);
}
if (dynamic_cast<System::Reflection::Missing^>(overwrite_y) == nullptr) {
__pyx_v_overwrite_y = __site_cvt_cvt_int_228_0->Target(__site_cvt_cvt_int_228_0, overwrite_y);
} else {
__pyx_v_overwrite_y = ((int)0);
}
__pyx_v_fw_f_cb = nullptr;
__pyx_v_fw_jac_cb = nullptr;
__pyx_v_y_ = nullptr;
__pyx_v_rtol_ = nullptr;
__pyx_v_atol_ = nullptr;
__pyx_v_zwork_ = nullptr;
__pyx_v_rwork_ = nullptr;
__pyx_v_iwork_ = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":262
* cdef np.ndarray y_, rtol_, atol_, zwork_, rwork_, iwork_
* cdef np.npy_intp y_shape[1], rtol_shape[1], atol_shape[1], zwork_shape[1], rwork_shape[1], iwork_shape[1]
* rtol_ = fw_asfortranarray(rtol, fwr_dbl_t_enum, 1, rtol_shape, False, False) # <<<<<<<<<<<<<<
* atol_ = fw_asfortranarray(atol, fwr_dbl_t_enum, 1, atol_shape, False, False)
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4))
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_rtol, NPY_DOUBLE, 1, __pyx_v_rtol_shape, 0, 0, nullptr));
__pyx_v_rtol_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":263
* cdef np.npy_intp y_shape[1], rtol_shape[1], atol_shape[1], zwork_shape[1], rwork_shape[1], iwork_shape[1]
* rtol_ = fw_asfortranarray(rtol, fwr_dbl_t_enum, 1, rtol_shape, False, False)
* atol_ = fw_asfortranarray(atol, fwr_dbl_t_enum, 1, atol_shape, False, False) # <<<<<<<<<<<<<<
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4))
* iopt = 1
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_atol, NPY_DOUBLE, 1, __pyx_v_atol_shape, 0, 0, nullptr));
__pyx_v_atol_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":264
* rtol_ = fw_asfortranarray(rtol, fwr_dbl_t_enum, 1, rtol_shape, False, False)
* atol_ = fw_asfortranarray(atol, fwr_dbl_t_enum, 1, atol_shape, False, False)
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4)) # <<<<<<<<<<<<<<
* iopt = 1
* zwork_ = fw_asfortranarray(zwork, fwc_dbl_complex_t_enum, 1, zwork_shape, False, False)
*/
__pyx_t_3 = ((__pyx_v_atol_shape[0]) <= 1);
if (__pyx_t_3) {
__pyx_t_4 = ((__pyx_v_rtol_shape[0]) <= 1);
__pyx_t_5 = __pyx_t_4;
} else {
__pyx_t_5 = __pyx_t_3;
}
if (__pyx_t_5) {
__pyx_t_2 = 1;
} else {
if (((__pyx_v_rtol_shape[0]) <= 1)) {
__pyx_t_6 = 2;
} else {
if (((__pyx_v_atol_shape[0]) <= 1)) {
__pyx_t_7 = 3;
} else {
__pyx_t_7 = 4;
}
__pyx_t_6 = __pyx_t_7;
}
__pyx_t_2 = __pyx_t_6;
}
__pyx_v_itol = __pyx_t_2;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":265
* atol_ = fw_asfortranarray(atol, fwr_dbl_t_enum, 1, atol_shape, False, False)
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4))
* iopt = 1 # <<<<<<<<<<<<<<
* zwork_ = fw_asfortranarray(zwork, fwc_dbl_complex_t_enum, 1, zwork_shape, False, False)
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False)
*/
__pyx_v_iopt = 1;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":266
* itol = 1 if ((atol_shape[0] <= 1) and (rtol_shape[0] <= 1)) else (2 if (rtol_shape[0] <= 1) else (3 if (atol_shape[0] <= 1) else 4))
* iopt = 1
* zwork_ = fw_asfortranarray(zwork, fwc_dbl_complex_t_enum, 1, zwork_shape, False, False) # <<<<<<<<<<<<<<
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False)
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False)
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_zwork, NPY_CDOUBLE, 1, __pyx_v_zwork_shape, 0, 0, nullptr));
__pyx_v_zwork_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":267
* iopt = 1
* zwork_ = fw_asfortranarray(zwork, fwc_dbl_complex_t_enum, 1, zwork_shape, False, False)
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False) # <<<<<<<<<<<<<<
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False)
* y_ = fw_asfortranarray(y, fwc_dbl_complex_t_enum, 1, y_shape, not overwrite_y, False)
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_rwork, NPY_DOUBLE, 1, __pyx_v_rwork_shape, 0, 0, nullptr));
__pyx_v_rwork_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":268
* zwork_ = fw_asfortranarray(zwork, fwc_dbl_complex_t_enum, 1, zwork_shape, False, False)
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False)
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False) # <<<<<<<<<<<<<<
* y_ = fw_asfortranarray(y, fwc_dbl_complex_t_enum, 1, y_shape, not overwrite_y, False)
* neq = y_shape[0]
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_iwork, NPY_INT, 1, __pyx_v_iwork_shape, 0, 0, nullptr));
__pyx_v_iwork_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":269
* rwork_ = fw_asfortranarray(rwork, fwr_dbl_t_enum, 1, rwork_shape, False, False)
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False)
* y_ = fw_asfortranarray(y, fwc_dbl_complex_t_enum, 1, y_shape, not overwrite_y, False) # <<<<<<<<<<<<<<
* neq = y_shape[0]
* lzw = zwork_shape[0]
*/
__pyx_t_1 = ((System::Object^)fw_asfortranarray(__pyx_v_y, NPY_CDOUBLE, 1, __pyx_v_y_shape, (!__pyx_v_overwrite_y), 0, nullptr));
__pyx_v_y_ = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":270
* iwork_ = fw_asfortranarray(iwork, fwi_integer_t_enum, 1, iwork_shape, False, False)
* y_ = fw_asfortranarray(y, fwc_dbl_complex_t_enum, 1, y_shape, not overwrite_y, False)
* neq = y_shape[0] # <<<<<<<<<<<<<<
* lzw = zwork_shape[0]
* lrw = rwork_shape[0]
*/
__pyx_v_neq = (__pyx_v_y_shape[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":271
* y_ = fw_asfortranarray(y, fwc_dbl_complex_t_enum, 1, y_shape, not overwrite_y, False)
* neq = y_shape[0]
* lzw = zwork_shape[0] # <<<<<<<<<<<<<<
* lrw = rwork_shape[0]
* liw = iwork_shape[0]
*/
__pyx_v_lzw = (__pyx_v_zwork_shape[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":272
* neq = y_shape[0]
* lzw = zwork_shape[0]
* lrw = rwork_shape[0] # <<<<<<<<<<<<<<
* liw = iwork_shape[0]
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)):
*/
__pyx_v_lrw = (__pyx_v_rwork_shape[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":273
* lzw = zwork_shape[0]
* lrw = rwork_shape[0]
* liw = iwork_shape[0] # <<<<<<<<<<<<<<
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)')
*/
__pyx_v_liw = (__pyx_v_iwork_shape[0]);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":274
* lrw = rwork_shape[0]
* liw = iwork_shape[0]
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)')
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)):
*/
__pyx_t_5 = ((__pyx_v_rtol_shape[0]) <= 1);
if (!__pyx_t_5) {
__pyx_t_3 = ((__pyx_v_rtol_shape[0]) >= __pyx_v_neq);
__pyx_t_4 = __pyx_t_3;
} else {
__pyx_t_4 = __pyx_t_5;
}
__pyx_t_5 = (!__pyx_t_4);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":275
* liw = iwork_shape[0]
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)') # <<<<<<<<<<<<<<
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)')
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_275_24->Target(__site_call1_275_24, __pyx_context, __pyx_t_1, ((System::Object^)"Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L5;
}
__pyx_L5:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":276
* if not ((rtol_shape[0] <= 1) or (rtol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)')
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)')
* if not ((itask > 0) and (itask < 6)):
*/
__pyx_t_5 = ((__pyx_v_atol_shape[0]) <= 1);
if (!__pyx_t_5) {
__pyx_t_4 = ((__pyx_v_atol_shape[0]) >= __pyx_v_neq);
__pyx_t_3 = __pyx_t_4;
} else {
__pyx_t_3 = __pyx_t_5;
}
__pyx_t_5 = (!__pyx_t_3);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":277
* raise ValueError('Condition on arguments not satisfied: (rtol.shape[0] <= 1) or (rtol.shape[0] >= neq)')
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)') # <<<<<<<<<<<<<<
* if not ((itask > 0) and (itask < 6)):
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)')
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_1 = __site_call1_277_24->Target(__site_call1_277_24, __pyx_context, __pyx_t_8, ((System::Object^)"Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)"));
__pyx_t_8 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_1, nullptr, nullptr);
__pyx_t_1 = nullptr;
goto __pyx_L6;
}
__pyx_L6:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":278
* if not ((atol_shape[0] <= 1) or (atol_shape[0] >= neq)):
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)')
* if not ((itask > 0) and (itask < 6)): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)')
* if not ((istate > 0) and (istate < 4)):
*/
__pyx_t_5 = (__pyx_v_itask > 0);
if (__pyx_t_5) {
__pyx_t_3 = (__pyx_v_itask < 6);
__pyx_t_4 = __pyx_t_3;
} else {
__pyx_t_4 = __pyx_t_5;
}
__pyx_t_5 = (!__pyx_t_4);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":279
* raise ValueError('Condition on arguments not satisfied: (atol.shape[0] <= 1) or (atol.shape[0] >= neq)')
* if not ((itask > 0) and (itask < 6)):
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)') # <<<<<<<<<<<<<<
* if not ((istate > 0) and (istate < 4)):
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)')
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_279_24->Target(__site_call1_279_24, __pyx_context, __pyx_t_1, ((System::Object^)"Condition on arguments not satisfied: (itask > 0) and (itask < 6)"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L7;
}
__pyx_L7:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":280
* if not ((itask > 0) and (itask < 6)):
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)')
* if not ((istate > 0) and (istate < 4)): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)')
* if not (zwork_shape[0] >= lzw):
*/
__pyx_t_5 = (__pyx_v_istate > 0);
if (__pyx_t_5) {
__pyx_t_4 = (__pyx_v_istate < 4);
__pyx_t_3 = __pyx_t_4;
} else {
__pyx_t_3 = __pyx_t_5;
}
__pyx_t_5 = (!__pyx_t_3);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":281
* raise ValueError('Condition on arguments not satisfied: (itask > 0) and (itask < 6)')
* if not ((istate > 0) and (istate < 4)):
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)') # <<<<<<<<<<<<<<
* if not (zwork_shape[0] >= lzw):
* raise ValueError('Condition on arguments not satisfied: zwork.shape[0] >= lzw')
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_1 = __site_call1_281_24->Target(__site_call1_281_24, __pyx_context, __pyx_t_8, ((System::Object^)"Condition on arguments not satisfied: (istate > 0) and (istate < 4)"));
__pyx_t_8 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_1, nullptr, nullptr);
__pyx_t_1 = nullptr;
goto __pyx_L8;
}
__pyx_L8:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":282
* if not ((istate > 0) and (istate < 4)):
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)')
* if not (zwork_shape[0] >= lzw): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: zwork.shape[0] >= lzw')
* if not (rwork_shape[0] >= lrw):
*/
__pyx_t_5 = (!((__pyx_v_zwork_shape[0]) >= __pyx_v_lzw));
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":283
* raise ValueError('Condition on arguments not satisfied: (istate > 0) and (istate < 4)')
* if not (zwork_shape[0] >= lzw):
* raise ValueError('Condition on arguments not satisfied: zwork.shape[0] >= lzw') # <<<<<<<<<<<<<<
* if not (rwork_shape[0] >= lrw):
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw')
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_283_24->Target(__site_call1_283_24, __pyx_context, __pyx_t_1, ((System::Object^)"Condition on arguments not satisfied: zwork.shape[0] >= lzw"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L9;
}
__pyx_L9:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":284
* if not (zwork_shape[0] >= lzw):
* raise ValueError('Condition on arguments not satisfied: zwork.shape[0] >= lzw')
* if not (rwork_shape[0] >= lrw): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw')
* if not (iwork_shape[0] >= liw):
*/
__pyx_t_5 = (!((__pyx_v_rwork_shape[0]) >= __pyx_v_lrw));
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":285
* raise ValueError('Condition on arguments not satisfied: zwork.shape[0] >= lzw')
* if not (rwork_shape[0] >= lrw):
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw') # <<<<<<<<<<<<<<
* if not (iwork_shape[0] >= liw):
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw')
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_1 = __site_call1_285_24->Target(__site_call1_285_24, __pyx_context, __pyx_t_8, ((System::Object^)"Condition on arguments not satisfied: rwork.shape[0] >= lrw"));
__pyx_t_8 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_1, nullptr, nullptr);
__pyx_t_1 = nullptr;
goto __pyx_L10;
}
__pyx_L10:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":286
* if not (rwork_shape[0] >= lrw):
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw')
* if not (iwork_shape[0] >= liw): # <<<<<<<<<<<<<<
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw')
* if not (0 <= neq <= y_shape[0]):
*/
__pyx_t_5 = (!((__pyx_v_iwork_shape[0]) >= __pyx_v_liw));
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":287
* raise ValueError('Condition on arguments not satisfied: rwork.shape[0] >= lrw')
* if not (iwork_shape[0] >= liw):
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw') # <<<<<<<<<<<<<<
* if not (0 <= neq <= y_shape[0]):
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed")
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_287_24->Target(__site_call1_287_24, __pyx_context, __pyx_t_1, ((System::Object^)"Condition on arguments not satisfied: iwork.shape[0] >= liw"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L11;
}
__pyx_L11:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":288
* if not (iwork_shape[0] >= liw):
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw')
* if not (0 <= neq <= y_shape[0]): # <<<<<<<<<<<<<<
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed")
* if not (0 <= lzw <= zwork_shape[0]):
*/
__pyx_t_5 = (0 <= __pyx_v_neq);
if (__pyx_t_5) {
__pyx_t_5 = (__pyx_v_neq <= (__pyx_v_y_shape[0]));
}
__pyx_t_3 = (!__pyx_t_5);
if (__pyx_t_3) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":289
* raise ValueError('Condition on arguments not satisfied: iwork.shape[0] >= liw')
* if not (0 <= neq <= y_shape[0]):
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed") # <<<<<<<<<<<<<<
* if not (0 <= lzw <= zwork_shape[0]):
* raise ValueError("(0 <= lzw <= zwork.shape[0]) not satisifed")
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_1 = __site_call1_289_24->Target(__site_call1_289_24, __pyx_context, __pyx_t_8, ((System::Object^)"(0 <= neq <= y.shape[0]) not satisifed"));
__pyx_t_8 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_1, nullptr, nullptr);
__pyx_t_1 = nullptr;
goto __pyx_L12;
}
__pyx_L12:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":290
* if not (0 <= neq <= y_shape[0]):
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed")
* if not (0 <= lzw <= zwork_shape[0]): # <<<<<<<<<<<<<<
* raise ValueError("(0 <= lzw <= zwork.shape[0]) not satisifed")
* if not (0 <= lrw <= rwork_shape[0]):
*/
__pyx_t_3 = (0 <= __pyx_v_lzw);
if (__pyx_t_3) {
__pyx_t_3 = (__pyx_v_lzw <= (__pyx_v_zwork_shape[0]));
}
__pyx_t_5 = (!__pyx_t_3);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":291
* raise ValueError("(0 <= neq <= y.shape[0]) not satisifed")
* if not (0 <= lzw <= zwork_shape[0]):
* raise ValueError("(0 <= lzw <= zwork.shape[0]) not satisifed") # <<<<<<<<<<<<<<
* if not (0 <= lrw <= rwork_shape[0]):
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed")
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_291_24->Target(__site_call1_291_24, __pyx_context, __pyx_t_1, ((System::Object^)"(0 <= lzw <= zwork.shape[0]) not satisifed"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L13;
}
__pyx_L13:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":292
* if not (0 <= lzw <= zwork_shape[0]):
* raise ValueError("(0 <= lzw <= zwork.shape[0]) not satisifed")
* if not (0 <= lrw <= rwork_shape[0]): # <<<<<<<<<<<<<<
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed")
* if not (0 <= liw <= iwork_shape[0]):
*/
__pyx_t_5 = (0 <= __pyx_v_lrw);
if (__pyx_t_5) {
__pyx_t_5 = (__pyx_v_lrw <= (__pyx_v_rwork_shape[0]));
}
__pyx_t_3 = (!__pyx_t_5);
if (__pyx_t_3) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":293
* raise ValueError("(0 <= lzw <= zwork.shape[0]) not satisifed")
* if not (0 <= lrw <= rwork_shape[0]):
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed") # <<<<<<<<<<<<<<
* if not (0 <= liw <= iwork_shape[0]):
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed")
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_1 = __site_call1_293_24->Target(__site_call1_293_24, __pyx_context, __pyx_t_8, ((System::Object^)"(0 <= lrw <= rwork.shape[0]) not satisifed"));
__pyx_t_8 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_1, nullptr, nullptr);
__pyx_t_1 = nullptr;
goto __pyx_L14;
}
__pyx_L14:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":294
* if not (0 <= lrw <= rwork_shape[0]):
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed")
* if not (0 <= liw <= iwork_shape[0]): # <<<<<<<<<<<<<<
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed")
* zvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args)
*/
__pyx_t_3 = (0 <= __pyx_v_liw);
if (__pyx_t_3) {
__pyx_t_3 = (__pyx_v_liw <= (__pyx_v_iwork_shape[0]));
}
__pyx_t_5 = (!__pyx_t_3);
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":295
* raise ValueError("(0 <= lrw <= rwork.shape[0]) not satisifed")
* if not (0 <= liw <= iwork_shape[0]):
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed") # <<<<<<<<<<<<<<
* zvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args)
* zvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args)
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_8 = __site_call1_295_24->Target(__site_call1_295_24, __pyx_context, __pyx_t_1, ((System::Object^)"(0 <= liw <= iwork.shape[0]) not satisifed"));
__pyx_t_1 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_8, nullptr, nullptr);
__pyx_t_8 = nullptr;
goto __pyx_L15;
}
__pyx_L15:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":296
* if not (0 <= liw <= iwork_shape[0]):
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed")
* zvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args) # <<<<<<<<<<<<<<
* zvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args)
* try:
*/
__pyx_t_8 = __site_call2_296_47->Target(__site_call2_296_47, __pyx_context, ((System::Object^)((System::Object^)__pyx_ptype_5scipy_9integrate_4vode_fw_CallbackInfo)), __pyx_v_f, __pyx_v_f_extra_args);
__pyx_v_5scipy_9integrate_4vode_zvode_f_cb_info = ((fw_CallbackInfo^)__pyx_t_8);
__pyx_v_fw_f_cb = ((fw_CallbackInfo^)__pyx_t_8);
__pyx_t_8 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":297
* raise ValueError("(0 <= liw <= iwork.shape[0]) not satisifed")
* zvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args)
* zvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args) # <<<<<<<<<<<<<<
* try:
* fc.zvode(&zvode_f_cb_wrapper_core, &neq, <fwc_dbl_complex_t*>np.PyArray_DATA(y_), &t, &tout, &itol, <fwr_dbl_t*>np.PyArray_DATA(rtol_), <fwr_dbl_t*>np.PyArray_DATA(atol_), &itask, &istate, &iopt, <fwc_dbl_complex_t*>np.PyArray_DATA(zwork_), &lzw, <fwr_dbl_t*>np.PyArray_DATA(rwork_), &lrw, <fwi_integer_t*>np.PyArray_DATA(iwork_), &liw, &zvode_jac_cb_wrapper_core, &mf, NULL, NULL)
*/
__pyx_t_8 = __site_call2_297_51->Target(__site_call2_297_51, __pyx_context, ((System::Object^)((System::Object^)__pyx_ptype_5scipy_9integrate_4vode_fw_CallbackInfo)), __pyx_v_jac, __pyx_v_jac_extra_args);
__pyx_v_5scipy_9integrate_4vode_zvode_jac_cb_info = ((fw_CallbackInfo^)__pyx_t_8);
__pyx_v_fw_jac_cb = ((fw_CallbackInfo^)__pyx_t_8);
__pyx_t_8 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":298
* zvode_f_cb_info = fw_f_cb = fw_CallbackInfo(f, f_extra_args)
* zvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args)
* try: # <<<<<<<<<<<<<<
* fc.zvode(&zvode_f_cb_wrapper_core, &neq, <fwc_dbl_complex_t*>np.PyArray_DATA(y_), &t, &tout, &itol, <fwr_dbl_t*>np.PyArray_DATA(rtol_), <fwr_dbl_t*>np.PyArray_DATA(atol_), &itask, &istate, &iopt, <fwc_dbl_complex_t*>np.PyArray_DATA(zwork_), &lzw, <fwr_dbl_t*>np.PyArray_DATA(rwork_), &lrw, <fwi_integer_t*>np.PyArray_DATA(iwork_), &liw, &zvode_jac_cb_wrapper_core, &mf, NULL, NULL)
* finally:
*/
try {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":299
* zvode_jac_cb_info = fw_jac_cb = fw_CallbackInfo(jac, jac_extra_args)
* try:
* fc.zvode(&zvode_f_cb_wrapper_core, &neq, <fwc_dbl_complex_t*>np.PyArray_DATA(y_), &t, &tout, &itol, <fwr_dbl_t*>np.PyArray_DATA(rtol_), <fwr_dbl_t*>np.PyArray_DATA(atol_), &itask, &istate, &iopt, <fwc_dbl_complex_t*>np.PyArray_DATA(zwork_), &lzw, <fwr_dbl_t*>np.PyArray_DATA(rwork_), &lrw, <fwi_integer_t*>np.PyArray_DATA(iwork_), &liw, &zvode_jac_cb_wrapper_core, &mf, NULL, NULL) # <<<<<<<<<<<<<<
* finally:
* zvode_f_cb_info = None
*/
F_FUNC(zvode,ZVODE)(__pyx_function_pointer_zvode_f_cb_wrapper_core, (&__pyx_v_neq), ((__pyx_t_double_complex *)PyArray_DATA(__pyx_v_y_)), (&__pyx_v_t), (&__pyx_v_tout), (&__pyx_v_itol), ((fwr_dbl_t *)PyArray_DATA(__pyx_v_rtol_)), ((fwr_dbl_t *)PyArray_DATA(__pyx_v_atol_)), (&__pyx_v_itask), (&__pyx_v_istate), (&__pyx_v_iopt), ((__pyx_t_double_complex *)PyArray_DATA(__pyx_v_zwork_)), (&__pyx_v_lzw), ((fwr_dbl_t *)PyArray_DATA(__pyx_v_rwork_)), (&__pyx_v_lrw), ((fwi_integer_t *)PyArray_DATA(__pyx_v_iwork_)), (&__pyx_v_liw), __pyx_function_pointer_zvode_jac_cb_wrapper_core, (&__pyx_v_mf), NULL, NULL);
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":301
* fc.zvode(&zvode_f_cb_wrapper_core, &neq, <fwc_dbl_complex_t*>np.PyArray_DATA(y_), &t, &tout, &itol, <fwr_dbl_t*>np.PyArray_DATA(rtol_), <fwr_dbl_t*>np.PyArray_DATA(atol_), &itask, &istate, &iopt, <fwc_dbl_complex_t*>np.PyArray_DATA(zwork_), &lzw, <fwr_dbl_t*>np.PyArray_DATA(rwork_), &lrw, <fwi_integer_t*>np.PyArray_DATA(iwork_), &liw, &zvode_jac_cb_wrapper_core, &mf, NULL, NULL)
* finally:
* zvode_f_cb_info = None # <<<<<<<<<<<<<<
* return (y_, t, istate,)
*
*/
finally {
__pyx_v_5scipy_9integrate_4vode_zvode_f_cb_info = ((fw_CallbackInfo^)nullptr);
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":302
* finally:
* zvode_f_cb_info = None
* return (y_, t, istate,) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_8 = __pyx_v_t;
__pyx_t_1 = __pyx_v_istate;
__pyx_t_9 = PythonOps::MakeTuple(gcnew array<System::Object^>{((System::Object^)__pyx_v_y_), __pyx_t_8, __pyx_t_1});
__pyx_t_8 = nullptr;
__pyx_t_1 = nullptr;
__pyx_r = __pyx_t_9;
__pyx_t_9 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":306
*
*
* cdef np.ndarray fw_asfortranarray(object value, int typenum, int ndim, # <<<<<<<<<<<<<<
* np.npy_intp * coerced_shape,
* bint copy, bint create, int alignment=1):
*/
static NumpyDotNet::ndarray^ fw_asfortranarray(System::Object^ __pyx_v_value, int __pyx_v_typenum, int __pyx_v_ndim, __pyx_t_5numpy_npy_intp *__pyx_v_coerced_shape, int __pyx_v_copy, int __pyx_v_create, ref struct __pyx_opt_args_5scipy_9integrate_4vode_fw_asfortranarray ^__pyx_optional_args) {
int __pyx_v_alignment = ((int)1);
int __pyx_v_flags;
NumpyDotNet::ndarray^ __pyx_v_result;
__pyx_t_5numpy_npy_intp *__pyx_v_in_shape;
int __pyx_v_in_ndim;
int __pyx_v_i;
NumpyDotNet::ndarray^ __pyx_r = nullptr;
int __pyx_t_1;
System::Object^ __pyx_t_2 = nullptr;
System::Object^ __pyx_t_3 = nullptr;
int __pyx_t_4;
int __pyx_t_5;
int __pyx_t_6;
int __pyx_t_7;
System::Object^ __pyx_t_8 = nullptr;
int __pyx_t_9;
int __pyx_t_10;
int __pyx_t_11;
if (__pyx_optional_args) {
if (__pyx_optional_args->__pyx_n > 0) {
__pyx_v_alignment = __pyx_optional_args->alignment;
}
}
__pyx_v_result = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":309
* np.npy_intp * coerced_shape,
* bint copy, bint create, int alignment=1):
* cdef int flags = np.NPY_F_CONTIGUOUS | np.NPY_FORCECAST # <<<<<<<<<<<<<<
* cdef np.ndarray result
* cdef np.npy_intp * in_shape
*/
__pyx_v_flags = (NPY_F_CONTIGUOUS | NPY_FORCECAST);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":314
* cdef int in_ndim
* cdef int i
* if value is None: # <<<<<<<<<<<<<<
* if create:
* result = np.PyArray_ZEROS(ndim, coerced_shape, typenum, 1)
*/
__pyx_t_1 = (__pyx_v_value == nullptr);
if (__pyx_t_1) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":315
* cdef int i
* if value is None:
* if create: # <<<<<<<<<<<<<<
* result = np.PyArray_ZEROS(ndim, coerced_shape, typenum, 1)
* else:
*/
if (__pyx_v_create) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":316
* if value is None:
* if create:
* result = np.PyArray_ZEROS(ndim, coerced_shape, typenum, 1) # <<<<<<<<<<<<<<
* else:
* raise TypeError('Expected array but None provided')
*/
__pyx_t_2 = PyArray_ZEROS(__pyx_v_ndim, __pyx_v_coerced_shape, __pyx_v_typenum, 1);
if (__pyx_t_2 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_2) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_result = ((NumpyDotNet::ndarray^)__pyx_t_2);
__pyx_t_2 = nullptr;
goto __pyx_L4;
}
/*else*/ {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":318
* result = np.PyArray_ZEROS(ndim, coerced_shape, typenum, 1)
* else:
* raise TypeError('Expected array but None provided') # <<<<<<<<<<<<<<
* else:
* if ndim <= 1:
*/
__pyx_t_2 = PythonOps::GetGlobal(__pyx_context, "TypeError");
__pyx_t_3 = __site_call1_318_27->Target(__site_call1_318_27, __pyx_context, __pyx_t_2, ((System::Object^)"Expected array but None provided"));
__pyx_t_2 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_3, nullptr, nullptr);
__pyx_t_3 = nullptr;
}
__pyx_L4:;
goto __pyx_L3;
}
/*else*/ {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":320
* raise TypeError('Expected array but None provided')
* else:
* if ndim <= 1: # <<<<<<<<<<<<<<
* # See http://projects.scipy.org/numpy/ticket/1691 for why this is needed
* flags |= np.NPY_C_CONTIGUOUS
*/
__pyx_t_1 = (__pyx_v_ndim <= 1);
if (__pyx_t_1) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":322
* if ndim <= 1:
* # See http://projects.scipy.org/numpy/ticket/1691 for why this is needed
* flags |= np.NPY_C_CONTIGUOUS # <<<<<<<<<<<<<<
* if (not copy and alignment > 1 and np.PyArray_Check(value) and
* (<Py_ssize_t>np.PyArray_DATA(value) & (alignment - 1) != 0)):
*/
__pyx_v_flags |= NPY_C_CONTIGUOUS;
goto __pyx_L5;
}
__pyx_L5:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":323
* # See http://projects.scipy.org/numpy/ticket/1691 for why this is needed
* flags |= np.NPY_C_CONTIGUOUS
* if (not copy and alignment > 1 and np.PyArray_Check(value) and # <<<<<<<<<<<<<<
* (<Py_ssize_t>np.PyArray_DATA(value) & (alignment - 1) != 0)):
* # mis-aligned array
*/
__pyx_t_1 = (!__pyx_v_copy);
if (__pyx_t_1) {
__pyx_t_4 = (__pyx_v_alignment > 1);
if (__pyx_t_4) {
__pyx_t_3 = PyArray_Check(__pyx_v_value);
__pyx_t_5 = __site_istrue_323_59->Target(__site_istrue_323_59, __pyx_t_3);
__pyx_t_3 = nullptr;
if (__pyx_t_5) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":324
* flags |= np.NPY_C_CONTIGUOUS
* if (not copy and alignment > 1 and np.PyArray_Check(value) and
* (<Py_ssize_t>np.PyArray_DATA(value) & (alignment - 1) != 0)): # <<<<<<<<<<<<<<
* # mis-aligned array
* copy = True
*/
if (__pyx_v_value != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_v_value) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_t_6 = ((((Py_ssize_t)PyArray_DATA(((NumpyDotNet::ndarray^)__pyx_v_value))) & (__pyx_v_alignment - 1)) != 0);
__pyx_t_7 = __pyx_t_6;
} else {
__pyx_t_7 = __pyx_t_5;
}
__pyx_t_5 = __pyx_t_7;
} else {
__pyx_t_5 = __pyx_t_4;
}
__pyx_t_4 = __pyx_t_5;
} else {
__pyx_t_4 = __pyx_t_1;
}
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":326
* (<Py_ssize_t>np.PyArray_DATA(value) & (alignment - 1) != 0)):
* # mis-aligned array
* copy = True # <<<<<<<<<<<<<<
* if copy:
* flags |= np.NPY_ENSURECOPY
*/
__pyx_v_copy = 1;
goto __pyx_L6;
}
__pyx_L6:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":327
* # mis-aligned array
* copy = True
* if copy: # <<<<<<<<<<<<<<
* flags |= np.NPY_ENSURECOPY
* result = np.PyArray_FROMANY(value, typenum, 0, 0, flags)
*/
if (__pyx_v_copy) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":328
* copy = True
* if copy:
* flags |= np.NPY_ENSURECOPY # <<<<<<<<<<<<<<
* result = np.PyArray_FROMANY(value, typenum, 0, 0, flags)
* in_ndim = np.PyArray_NDIM(result)
*/
__pyx_v_flags |= NPY_ENSURECOPY;
goto __pyx_L7;
}
__pyx_L7:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":329
* if copy:
* flags |= np.NPY_ENSURECOPY
* result = np.PyArray_FROMANY(value, typenum, 0, 0, flags) # <<<<<<<<<<<<<<
* in_ndim = np.PyArray_NDIM(result)
* if in_ndim > ndim:
*/
__pyx_t_3 = __pyx_v_typenum;
__pyx_t_2 = __pyx_v_flags;
__pyx_t_8 = PyArray_FROMANY(__pyx_v_value, __pyx_t_3, __pyx_int_0, __pyx_int_0, __pyx_t_2);
__pyx_t_3 = nullptr;
__pyx_t_2 = nullptr;
if (__pyx_t_8 != nullptr && dynamic_cast<NumpyDotNet::ndarray^>(__pyx_t_8) == nullptr) {
throw PythonOps::MakeException(__pyx_context, PythonOps::GetGlobal(__pyx_context, "TypeError"), "type error", nullptr);
}
__pyx_v_result = ((NumpyDotNet::ndarray^)__pyx_t_8);
__pyx_t_8 = nullptr;
}
__pyx_L3:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":330
* flags |= np.NPY_ENSURECOPY
* result = np.PyArray_FROMANY(value, typenum, 0, 0, flags)
* in_ndim = np.PyArray_NDIM(result) # <<<<<<<<<<<<<<
* if in_ndim > ndim:
* raise ValueError("Dimension of array must be <= %d" % ndim)
*/
__pyx_t_8 = PyArray_NDIM(__pyx_v_result);
__pyx_t_9 = __site_cvt_cvt_int_330_29->Target(__site_cvt_cvt_int_330_29, __pyx_t_8);
__pyx_t_8 = nullptr;
__pyx_v_in_ndim = __pyx_t_9;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":331
* result = np.PyArray_FROMANY(value, typenum, 0, 0, flags)
* in_ndim = np.PyArray_NDIM(result)
* if in_ndim > ndim: # <<<<<<<<<<<<<<
* raise ValueError("Dimension of array must be <= %d" % ndim)
* in_shape = np.PyArray_DIMS(result)
*/
__pyx_t_4 = (__pyx_v_in_ndim > __pyx_v_ndim);
if (__pyx_t_4) {
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":332
* in_ndim = np.PyArray_NDIM(result)
* if in_ndim > ndim:
* raise ValueError("Dimension of array must be <= %d" % ndim) # <<<<<<<<<<<<<<
* in_shape = np.PyArray_DIMS(result)
* for i in range(in_ndim):
*/
__pyx_t_8 = PythonOps::GetGlobal(__pyx_context, "ValueError");
__pyx_t_2 = __pyx_v_ndim;
__pyx_t_3 = __site_op_mod_332_60->Target(__site_op_mod_332_60, ((System::Object^)"Dimension of array must be <= %d"), __pyx_t_2);
__pyx_t_2 = nullptr;
__pyx_t_2 = __site_call1_332_24->Target(__site_call1_332_24, __pyx_context, __pyx_t_8, ((System::Object^)__pyx_t_3));
__pyx_t_8 = nullptr;
__pyx_t_3 = nullptr;
throw PythonOps::MakeException(__pyx_context, __pyx_t_2, nullptr, nullptr);
__pyx_t_2 = nullptr;
goto __pyx_L8;
}
__pyx_L8:;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":333
* if in_ndim > ndim:
* raise ValueError("Dimension of array must be <= %d" % ndim)
* in_shape = np.PyArray_DIMS(result) # <<<<<<<<<<<<<<
* for i in range(in_ndim):
* coerced_shape[i] = in_shape[i]
*/
__pyx_v_in_shape = PyArray_DIMS(__pyx_v_result);
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":334
* raise ValueError("Dimension of array must be <= %d" % ndim)
* in_shape = np.PyArray_DIMS(result)
* for i in range(in_ndim): # <<<<<<<<<<<<<<
* coerced_shape[i] = in_shape[i]
* for i in range(in_ndim, ndim):
*/
__pyx_t_10 = __pyx_v_in_ndim;
for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
__pyx_v_i = __pyx_t_11;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":335
* in_shape = np.PyArray_DIMS(result)
* for i in range(in_ndim):
* coerced_shape[i] = in_shape[i] # <<<<<<<<<<<<<<
* for i in range(in_ndim, ndim):
* # Pad shape with ones on right side if necessarry
*/
(__pyx_v_coerced_shape[__pyx_v_i]) = (__pyx_v_in_shape[__pyx_v_i]);
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":336
* for i in range(in_ndim):
* coerced_shape[i] = in_shape[i]
* for i in range(in_ndim, ndim): # <<<<<<<<<<<<<<
* # Pad shape with ones on right side if necessarry
* coerced_shape[i] = 1
*/
__pyx_t_10 = __pyx_v_ndim;
for (__pyx_t_11 = __pyx_v_in_ndim; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {
__pyx_v_i = __pyx_t_11;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":338
* for i in range(in_ndim, ndim):
* # Pad shape with ones on right side if necessarry
* coerced_shape[i] = 1 # <<<<<<<<<<<<<<
* return result
*
*/
(__pyx_v_coerced_shape[__pyx_v_i]) = 1;
}
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":339
* # Pad shape with ones on right side if necessarry
* coerced_shape[i] = 1
* return result # <<<<<<<<<<<<<<
*
* # Fwrap configuration:
*/
__pyx_r = __pyx_v_result;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":290
* dtype NpyArray_FindArrayType_3args "NumpyDotNet::NpyArray::FindArrayType" (object src, dtype minitype, int max)
*
* cdef inline dtype NpyArray_FindArrayType_2args(object src, dtype minitype): # <<<<<<<<<<<<<<
* return NpyArray_FindArrayType_3args(src, minitype, NPY_MAXDIMS)
*
*/
static CYTHON_INLINE NumpyDotNet::dtype^ NpyArray_FindArrayType_2args(System::Object^ __pyx_v_src, NumpyDotNet::dtype^ __pyx_v_minitype) {
NumpyDotNet::dtype^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":291
*
* cdef inline dtype NpyArray_FindArrayType_2args(object src, dtype minitype):
* return NpyArray_FindArrayType_3args(src, minitype, NPY_MAXDIMS) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = ((System::Object^)NumpyDotNet::NpyArray::FindArrayType(__pyx_v_src, __pyx_v_minitype, NPY_MAXDIMS));
__pyx_r = ((NumpyDotNet::dtype^)__pyx_t_1);
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":310
* ctypedef void (*PyArray_CopySwapFunc)(void *, void *, int, NpyArray *)
*
* cdef inline object PyUFunc_FromFuncAndData(PyUFuncGenericFunction* func, void** data, # <<<<<<<<<<<<<<
* char* types, int ntypes, int nin, int nout,
* int identity, char* name, char* doc, int c):
*/
static CYTHON_INLINE System::Object^ PyUFunc_FromFuncAndData(__pyx_t_5numpy_PyUFuncGenericFunction *__pyx_v_func, void **__pyx_v_data, char *__pyx_v_types, int __pyx_v_ntypes, int __pyx_v_nin, int __pyx_v_nout, int __pyx_v_identity, char *__pyx_v_name, char *__pyx_v_doc, int __pyx_v_c) {
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":313
* char* types, int ntypes, int nin, int nout,
* int identity, char* name, char* doc, int c):
* return Npy_INTERFACE_ufunc(NpyUFunc_FromFuncAndDataAndSignature(func, data, types, ntypes, nin, nout, identity, name, doc, c, NULL)) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_DescrFromType(int typenum):
*/
__pyx_t_1 = Npy_INTERFACE_OBJECT(NpyUFunc_FromFuncAndDataAndSignature(__pyx_v_func, __pyx_v_data, __pyx_v_types, __pyx_v_ntypes, __pyx_v_nin, __pyx_v_nout, __pyx_v_identity, __pyx_v_name, __pyx_v_doc, __pyx_v_c, NULL));
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":315
* return Npy_INTERFACE_ufunc(NpyUFunc_FromFuncAndDataAndSignature(func, data, types, ntypes, nin, nout, identity, name, doc, c, NULL))
*
* cdef inline object PyArray_DescrFromType(int typenum): # <<<<<<<<<<<<<<
* return Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum))
*
*/
static CYTHON_INLINE System::Object^ PyArray_DescrFromType(int __pyx_v_typenum) {
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":316
*
* cdef inline object PyArray_DescrFromType(int typenum):
* return Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = ((System::Object^)Npy_INTERFACE_OBJECT(NpyArray_DescrFromType(__pyx_v_typenum)));
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":319
*
*
* cdef inline object PyArray_ZEROS(int ndim, npy_intp *shape, int typenum, int fortran): # <<<<<<<<<<<<<<
* shape_list = []
* cdef int i
*/
static CYTHON_INLINE System::Object^ PyArray_ZEROS(int __pyx_v_ndim, __pyx_t_5numpy_npy_intp *__pyx_v_shape, int __pyx_v_typenum, int __pyx_v_fortran) {
System::Object^ __pyx_v_shape_list;
int __pyx_v_i;
System::Object^ __pyx_v_numpy;
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
int __pyx_t_2;
int __pyx_t_3;
System::Object^ __pyx_t_4 = nullptr;
System::Object^ __pyx_t_5 = nullptr;
System::Object^ __pyx_t_6 = nullptr;
__pyx_v_shape_list = nullptr;
__pyx_v_numpy = nullptr;
/* "../cython/include/numpy.pxd":320
*
* cdef inline object PyArray_ZEROS(int ndim, npy_intp *shape, int typenum, int fortran):
* shape_list = [] # <<<<<<<<<<<<<<
* cdef int i
* for i in range(ndim):
*/
__pyx_t_1 = PythonOps::MakeListNoCopy(gcnew array<System::Object^>{});
__pyx_v_shape_list = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":322
* shape_list = []
* cdef int i
* for i in range(ndim): # <<<<<<<<<<<<<<
* shape_list.append(shape[i])
* import numpy
*/
__pyx_t_2 = __pyx_v_ndim;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "../cython/include/numpy.pxd":323
* cdef int i
* for i in range(ndim):
* shape_list.append(shape[i]) # <<<<<<<<<<<<<<
* import numpy
* return numpy.zeros(shape_list, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), 'F' if fortran else 'C')
*/
__pyx_t_1 = __site_get_append_323_18->Target(__site_get_append_323_18, ((System::Object^)__pyx_v_shape_list), __pyx_context);
__pyx_t_4 = (__pyx_v_shape[__pyx_v_i]);
__pyx_t_5 = __site_call1_323_25->Target(__site_call1_323_25, __pyx_context, __pyx_t_1, __pyx_t_4);
__pyx_t_1 = nullptr;
__pyx_t_4 = nullptr;
__pyx_t_5 = nullptr;
}
/* "../cython/include/numpy.pxd":324
* for i in range(ndim):
* shape_list.append(shape[i])
* import numpy # <<<<<<<<<<<<<<
* return numpy.zeros(shape_list, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), 'F' if fortran else 'C')
*
*/
__pyx_t_5 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "numpy", -1));
__pyx_v_numpy = __pyx_t_5;
__pyx_t_5 = nullptr;
/* "../cython/include/numpy.pxd":325
* shape_list.append(shape[i])
* import numpy
* return numpy.zeros(shape_list, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), 'F' if fortran else 'C') # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_EMPTY(int ndim, npy_intp *shape, int typenum, int fortran):
*/
__pyx_t_5 = __site_get_zeros_325_16->Target(__site_get_zeros_325_16, __pyx_v_numpy, __pyx_context);
__pyx_t_4 = ((System::Object^)Npy_INTERFACE_OBJECT(NpyArray_DescrFromType(__pyx_v_typenum)));
if (__pyx_v_fortran) {
__pyx_t_1 = "F";
} else {
__pyx_t_1 = "C";
}
__pyx_t_6 = __site_call3_325_22->Target(__site_call3_325_22, __pyx_context, __pyx_t_5, ((System::Object^)__pyx_v_shape_list), __pyx_t_4, ((System::Object^)__pyx_t_1));
__pyx_t_5 = nullptr;
__pyx_t_4 = nullptr;
__pyx_t_1 = nullptr;
__pyx_r = __pyx_t_6;
__pyx_t_6 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":327
* return numpy.zeros(shape_list, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), 'F' if fortran else 'C')
*
* cdef inline object PyArray_EMPTY(int ndim, npy_intp *shape, int typenum, int fortran): # <<<<<<<<<<<<<<
* shape_list = []
* cdef int i
*/
static CYTHON_INLINE System::Object^ PyArray_EMPTY(int __pyx_v_ndim, __pyx_t_5numpy_npy_intp *__pyx_v_shape, int __pyx_v_typenum, int __pyx_v_fortran) {
System::Object^ __pyx_v_shape_list;
int __pyx_v_i;
System::Object^ __pyx_v_numpy;
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
int __pyx_t_2;
int __pyx_t_3;
System::Object^ __pyx_t_4 = nullptr;
System::Object^ __pyx_t_5 = nullptr;
System::Object^ __pyx_t_6 = nullptr;
__pyx_v_shape_list = nullptr;
__pyx_v_numpy = nullptr;
/* "../cython/include/numpy.pxd":328
*
* cdef inline object PyArray_EMPTY(int ndim, npy_intp *shape, int typenum, int fortran):
* shape_list = [] # <<<<<<<<<<<<<<
* cdef int i
* for i in range(ndim):
*/
__pyx_t_1 = PythonOps::MakeListNoCopy(gcnew array<System::Object^>{});
__pyx_v_shape_list = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":330
* shape_list = []
* cdef int i
* for i in range(ndim): # <<<<<<<<<<<<<<
* shape_list.append(shape[i])
* import numpy
*/
__pyx_t_2 = __pyx_v_ndim;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "../cython/include/numpy.pxd":331
* cdef int i
* for i in range(ndim):
* shape_list.append(shape[i]) # <<<<<<<<<<<<<<
* import numpy
* return numpy.empty(shape_list, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), 'F' if fortran else 'C')
*/
__pyx_t_1 = __site_get_append_331_18->Target(__site_get_append_331_18, ((System::Object^)__pyx_v_shape_list), __pyx_context);
__pyx_t_4 = (__pyx_v_shape[__pyx_v_i]);
__pyx_t_5 = __site_call1_331_25->Target(__site_call1_331_25, __pyx_context, __pyx_t_1, __pyx_t_4);
__pyx_t_1 = nullptr;
__pyx_t_4 = nullptr;
__pyx_t_5 = nullptr;
}
/* "../cython/include/numpy.pxd":332
* for i in range(ndim):
* shape_list.append(shape[i])
* import numpy # <<<<<<<<<<<<<<
* return numpy.empty(shape_list, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), 'F' if fortran else 'C')
*
*/
__pyx_t_5 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "numpy", -1));
__pyx_v_numpy = __pyx_t_5;
__pyx_t_5 = nullptr;
/* "../cython/include/numpy.pxd":333
* shape_list.append(shape[i])
* import numpy
* return numpy.empty(shape_list, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), 'F' if fortran else 'C') # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_Empty(int nd, npy_intp *dims, dtype descr, int fortran):
*/
__pyx_t_5 = __site_get_empty_333_16->Target(__site_get_empty_333_16, __pyx_v_numpy, __pyx_context);
__pyx_t_4 = ((System::Object^)Npy_INTERFACE_OBJECT(NpyArray_DescrFromType(__pyx_v_typenum)));
if (__pyx_v_fortran) {
__pyx_t_1 = "F";
} else {
__pyx_t_1 = "C";
}
__pyx_t_6 = __site_call3_333_22->Target(__site_call3_333_22, __pyx_context, __pyx_t_5, ((System::Object^)__pyx_v_shape_list), __pyx_t_4, ((System::Object^)__pyx_t_1));
__pyx_t_5 = nullptr;
__pyx_t_4 = nullptr;
__pyx_t_1 = nullptr;
__pyx_r = __pyx_t_6;
__pyx_t_6 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":335
* return numpy.empty(shape_list, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), 'F' if fortran else 'C')
*
* cdef inline object PyArray_Empty(int nd, npy_intp *dims, dtype descr, int fortran): # <<<<<<<<<<<<<<
* shape_list = []
* cdef int i
*/
static CYTHON_INLINE System::Object^ PyArray_Empty(int __pyx_v_nd, __pyx_t_5numpy_npy_intp *__pyx_v_dims, NumpyDotNet::dtype^ __pyx_v_descr, int __pyx_v_fortran) {
System::Object^ __pyx_v_shape_list;
int __pyx_v_i;
System::Object^ __pyx_v_numpy;
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
int __pyx_t_2;
int __pyx_t_3;
System::Object^ __pyx_t_4 = nullptr;
System::Object^ __pyx_t_5 = nullptr;
__pyx_v_shape_list = nullptr;
__pyx_v_numpy = nullptr;
/* "../cython/include/numpy.pxd":336
*
* cdef inline object PyArray_Empty(int nd, npy_intp *dims, dtype descr, int fortran):
* shape_list = [] # <<<<<<<<<<<<<<
* cdef int i
* for i in range(nd):
*/
__pyx_t_1 = PythonOps::MakeListNoCopy(gcnew array<System::Object^>{});
__pyx_v_shape_list = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":338
* shape_list = []
* cdef int i
* for i in range(nd): # <<<<<<<<<<<<<<
* shape_list.append(dims[i])
* import numpy
*/
__pyx_t_2 = __pyx_v_nd;
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
/* "../cython/include/numpy.pxd":339
* cdef int i
* for i in range(nd):
* shape_list.append(dims[i]) # <<<<<<<<<<<<<<
* import numpy
* return numpy.empty(shape_list, descr, 'F' if fortran else 'C')
*/
__pyx_t_1 = __site_get_append_339_18->Target(__site_get_append_339_18, ((System::Object^)__pyx_v_shape_list), __pyx_context);
__pyx_t_4 = (__pyx_v_dims[__pyx_v_i]);
__pyx_t_5 = __site_call1_339_25->Target(__site_call1_339_25, __pyx_context, __pyx_t_1, __pyx_t_4);
__pyx_t_1 = nullptr;
__pyx_t_4 = nullptr;
__pyx_t_5 = nullptr;
}
/* "../cython/include/numpy.pxd":340
* for i in range(nd):
* shape_list.append(dims[i])
* import numpy # <<<<<<<<<<<<<<
* return numpy.empty(shape_list, descr, 'F' if fortran else 'C')
*
*/
__pyx_t_5 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "numpy", -1));
__pyx_v_numpy = __pyx_t_5;
__pyx_t_5 = nullptr;
/* "../cython/include/numpy.pxd":341
* shape_list.append(dims[i])
* import numpy
* return numpy.empty(shape_list, descr, 'F' if fortran else 'C') # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_5 = __site_get_empty_341_16->Target(__site_get_empty_341_16, __pyx_v_numpy, __pyx_context);
if (__pyx_v_fortran) {
__pyx_t_4 = "F";
} else {
__pyx_t_4 = "C";
}
__pyx_t_1 = __site_call3_341_22->Target(__site_call3_341_22, __pyx_context, __pyx_t_5, ((System::Object^)__pyx_v_shape_list), ((System::Object^)__pyx_v_descr), ((System::Object^)__pyx_t_4));
__pyx_t_5 = nullptr;
__pyx_t_4 = nullptr;
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":344
*
*
* cdef inline object PyArray_New(void *subtype, int nd, npy_intp *dims, int type_num, npy_intp *strides, void *data, int itemsize, int flags, void *obj): # <<<<<<<<<<<<<<
* assert subtype == NULL
* assert obj == NULL
*/
static CYTHON_INLINE System::Object^ PyArray_New(void *__pyx_v_subtype, int __pyx_v_nd, __pyx_t_5numpy_npy_intp *__pyx_v_dims, int __pyx_v_type_num, __pyx_t_5numpy_npy_intp *__pyx_v_strides, void *__pyx_v_data, int __pyx_v_itemsize, int __pyx_v_flags, void *__pyx_v_obj) {
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":345
*
* cdef inline object PyArray_New(void *subtype, int nd, npy_intp *dims, int type_num, npy_intp *strides, void *data, int itemsize, int flags, void *obj):
* assert subtype == NULL # <<<<<<<<<<<<<<
* assert obj == NULL
* return Npy_INTERFACE_array(NpyArray_New(subtype, nd, dims, type_num, strides, data, itemsize, flags, obj))
*/
#ifndef PYREX_WITHOUT_ASSERTIONS
if (unlikely(!(__pyx_v_subtype == NULL))) {
PythonOps::RaiseAssertionError(nullptr);
}
#endif
/* "../cython/include/numpy.pxd":346
* cdef inline object PyArray_New(void *subtype, int nd, npy_intp *dims, int type_num, npy_intp *strides, void *data, int itemsize, int flags, void *obj):
* assert subtype == NULL
* assert obj == NULL # <<<<<<<<<<<<<<
* return Npy_INTERFACE_array(NpyArray_New(subtype, nd, dims, type_num, strides, data, itemsize, flags, obj))
*
*/
#ifndef PYREX_WITHOUT_ASSERTIONS
if (unlikely(!(__pyx_v_obj == NULL))) {
PythonOps::RaiseAssertionError(nullptr);
}
#endif
/* "../cython/include/numpy.pxd":347
* assert subtype == NULL
* assert obj == NULL
* return Npy_INTERFACE_array(NpyArray_New(subtype, nd, dims, type_num, strides, data, itemsize, flags, obj)) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_SimpleNew(int nd, npy_intp *dims, int type_num):
*/
__pyx_t_1 = ((System::Object^)Npy_INTERFACE_OBJECT(NpyArray_New(__pyx_v_subtype, __pyx_v_nd, __pyx_v_dims, __pyx_v_type_num, __pyx_v_strides, __pyx_v_data, __pyx_v_itemsize, __pyx_v_flags, __pyx_v_obj)));
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":349
* return Npy_INTERFACE_array(NpyArray_New(subtype, nd, dims, type_num, strides, data, itemsize, flags, obj))
*
* cdef inline object PyArray_SimpleNew(int nd, npy_intp *dims, int type_num): # <<<<<<<<<<<<<<
* return PyArray_New(NULL, nd, dims, type_num, NULL, NULL, 0, NPY_CARRAY, NULL)
*
*/
static CYTHON_INLINE System::Object^ PyArray_SimpleNew(int __pyx_v_nd, __pyx_t_5numpy_npy_intp *__pyx_v_dims, int __pyx_v_type_num) {
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":350
*
* cdef inline object PyArray_SimpleNew(int nd, npy_intp *dims, int type_num):
* return PyArray_New(NULL, nd, dims, type_num, NULL, NULL, 0, NPY_CARRAY, NULL) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_SimpleNewFromData(int nd, npy_intp *dims, int type_num, void *data):
*/
__pyx_t_1 = PyArray_New(NULL, __pyx_v_nd, __pyx_v_dims, __pyx_v_type_num, NULL, NULL, 0, NPY_CARRAY, NULL);
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":352
* return PyArray_New(NULL, nd, dims, type_num, NULL, NULL, 0, NPY_CARRAY, NULL)
*
* cdef inline object PyArray_SimpleNewFromData(int nd, npy_intp *dims, int type_num, void *data): # <<<<<<<<<<<<<<
* return PyArray_New(NULL, nd, dims, type_num, NULL, data, 0, NPY_CARRAY, NULL)
*
*/
static CYTHON_INLINE System::Object^ PyArray_SimpleNewFromData(int __pyx_v_nd, __pyx_t_5numpy_npy_intp *__pyx_v_dims, int __pyx_v_type_num, void *__pyx_v_data) {
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":353
*
* cdef inline object PyArray_SimpleNewFromData(int nd, npy_intp *dims, int type_num, void *data):
* return PyArray_New(NULL, nd, dims, type_num, NULL, data, 0, NPY_CARRAY, NULL) # <<<<<<<<<<<<<<
*
* cdef inline bint PyArray_CHKFLAGS(ndarray n, int flags):
*/
__pyx_t_1 = PyArray_New(NULL, __pyx_v_nd, __pyx_v_dims, __pyx_v_type_num, NULL, __pyx_v_data, 0, NPY_CARRAY, NULL);
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":355
* return PyArray_New(NULL, nd, dims, type_num, NULL, data, 0, NPY_CARRAY, NULL)
*
* cdef inline bint PyArray_CHKFLAGS(ndarray n, int flags): # <<<<<<<<<<<<<<
* return NpyArray_CHKFLAGS(<NpyArray*> <npy_intp>n.Array, flags)
*
*/
static CYTHON_INLINE int PyArray_CHKFLAGS(NumpyDotNet::ndarray^ __pyx_v_n, int __pyx_v_flags) {
int __pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":356
*
* cdef inline bint PyArray_CHKFLAGS(ndarray n, int flags):
* return NpyArray_CHKFLAGS(<NpyArray*> <npy_intp>n.Array, flags) # <<<<<<<<<<<<<<
*
* cdef inline void* PyArray_DATA(ndarray n) nogil:
*/
__pyx_t_1 = __site_get_Array_356_53->Target(__site_get_Array_356_53, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_356_53->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_356_53, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_CHKFLAGS(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)), __pyx_v_flags);
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":358
* return NpyArray_CHKFLAGS(<NpyArray*> <npy_intp>n.Array, flags)
*
* cdef inline void* PyArray_DATA(ndarray n) nogil: # <<<<<<<<<<<<<<
* return NpyArray_DATA(<NpyArray*> <npy_intp>n.Array)
*
*/
static CYTHON_INLINE void *PyArray_DATA(NumpyDotNet::ndarray^ __pyx_v_n) {
void *__pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":359
*
* cdef inline void* PyArray_DATA(ndarray n) nogil:
* return NpyArray_DATA(<NpyArray*> <npy_intp>n.Array) # <<<<<<<<<<<<<<
*
* cdef inline intp_t* PyArray_DIMS(ndarray n) nogil:
*/
__pyx_t_1 = __site_get_Array_359_48->Target(__site_get_Array_359_48, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_359_48->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_359_48, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_DATA(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":361
* return NpyArray_DATA(<NpyArray*> <npy_intp>n.Array)
*
* cdef inline intp_t* PyArray_DIMS(ndarray n) nogil: # <<<<<<<<<<<<<<
* return NpyArray_DIMS(<NpyArray*> <npy_intp>n.Array)
*
*/
static CYTHON_INLINE __pyx_t_5numpy_intp_t *PyArray_DIMS(NumpyDotNet::ndarray^ __pyx_v_n) {
__pyx_t_5numpy_intp_t *__pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":362
*
* cdef inline intp_t* PyArray_DIMS(ndarray n) nogil:
* return NpyArray_DIMS(<NpyArray*> <npy_intp>n.Array) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_DESCR(ndarray n):
*/
__pyx_t_1 = __site_get_Array_362_48->Target(__site_get_Array_362_48, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_362_48->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_362_48, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_DIMS(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":364
* return NpyArray_DIMS(<NpyArray*> <npy_intp>n.Array)
*
* cdef inline object PyArray_DESCR(ndarray n): # <<<<<<<<<<<<<<
* return Npy_INTERFACE_descr(NpyArray_DESCR(<NpyArray*> <npy_intp>n.Array))
*
*/
static CYTHON_INLINE System::Object^ PyArray_DESCR(NumpyDotNet::ndarray^ __pyx_v_n) {
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":365
*
* cdef inline object PyArray_DESCR(ndarray n):
* return Npy_INTERFACE_descr(NpyArray_DESCR(<NpyArray*> <npy_intp>n.Array)) # <<<<<<<<<<<<<<
*
* cdef inline int PyArray_ITEMSIZE(ndarray n):
*/
__pyx_t_1 = __site_get_Array_365_69->Target(__site_get_Array_365_69, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_365_69->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_365_69, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_t_1 = ((System::Object^)Npy_INTERFACE_OBJECT(NpyArray_DESCR(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)))));
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":367
* return Npy_INTERFACE_descr(NpyArray_DESCR(<NpyArray*> <npy_intp>n.Array))
*
* cdef inline int PyArray_ITEMSIZE(ndarray n): # <<<<<<<<<<<<<<
* return NpyArray_ITEMSIZE(<NpyArray*> <npy_intp>n.Array)
*
*/
static CYTHON_INLINE int PyArray_ITEMSIZE(NumpyDotNet::ndarray^ __pyx_v_n) {
int __pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":368
*
* cdef inline int PyArray_ITEMSIZE(ndarray n):
* return NpyArray_ITEMSIZE(<NpyArray*> <npy_intp>n.Array) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_Return(arr):
*/
__pyx_t_1 = __site_get_Array_368_52->Target(__site_get_Array_368_52, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_368_52->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_368_52, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_ITEMSIZE(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":370
* return NpyArray_ITEMSIZE(<NpyArray*> <npy_intp>n.Array)
*
* cdef inline object PyArray_Return(arr): # <<<<<<<<<<<<<<
* if arr is None:
* return None
*/
static CYTHON_INLINE System::Object^ PyArray_Return(System::Object^ __pyx_v_arr) {
System::Object^ __pyx_v_clr;
System::Object^ __pyx_v_NumpyDotNet;
System::Object^ __pyx_r = nullptr;
int __pyx_t_1;
System::Object^ __pyx_t_2 = nullptr;
System::Object^ __pyx_t_3 = nullptr;
__pyx_v_clr = nullptr;
__pyx_v_NumpyDotNet = nullptr;
/* "../cython/include/numpy.pxd":371
*
* cdef inline object PyArray_Return(arr):
* if arr is None: # <<<<<<<<<<<<<<
* return None
* import clr
*/
__pyx_t_1 = (__pyx_v_arr == nullptr);
if (__pyx_t_1) {
/* "../cython/include/numpy.pxd":372
* cdef inline object PyArray_Return(arr):
* if arr is None:
* return None # <<<<<<<<<<<<<<
* import clr
* import NumpyDotNet.ndarray
*/
__pyx_r = nullptr;
goto __pyx_L0;
goto __pyx_L3;
}
__pyx_L3:;
/* "../cython/include/numpy.pxd":373
* if arr is None:
* return None
* import clr # <<<<<<<<<<<<<<
* import NumpyDotNet.ndarray
* return NumpyDotNet.ndarray.ArrayReturn(arr)
*/
__pyx_t_2 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "clr", -1));
__pyx_v_clr = __pyx_t_2;
__pyx_t_2 = nullptr;
/* "../cython/include/numpy.pxd":374
* return None
* import clr
* import NumpyDotNet.ndarray # <<<<<<<<<<<<<<
* return NumpyDotNet.ndarray.ArrayReturn(arr)
*
*/
__pyx_t_2 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "NumpyDotNet.ndarray", -1));
__pyx_v_NumpyDotNet = __pyx_t_2;
__pyx_t_2 = nullptr;
/* "../cython/include/numpy.pxd":375
* import clr
* import NumpyDotNet.ndarray
* return NumpyDotNet.ndarray.ArrayReturn(arr) # <<<<<<<<<<<<<<
*
* cdef inline intp_t PyArray_DIM(ndarray n, int dim):
*/
__pyx_t_2 = __site_get_ndarray_375_22->Target(__site_get_ndarray_375_22, __pyx_v_NumpyDotNet, __pyx_context);
__pyx_t_3 = __site_get_ArrayReturn_375_30->Target(__site_get_ArrayReturn_375_30, __pyx_t_2, __pyx_context);
__pyx_t_2 = nullptr;
__pyx_t_2 = __site_call1_375_42->Target(__site_call1_375_42, __pyx_context, __pyx_t_3, __pyx_v_arr);
__pyx_t_3 = nullptr;
__pyx_r = __pyx_t_2;
__pyx_t_2 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":377
* return NumpyDotNet.ndarray.ArrayReturn(arr)
*
* cdef inline intp_t PyArray_DIM(ndarray n, int dim): # <<<<<<<<<<<<<<
* return NpyArray_DIM(<NpyArray*><long long>n.Array, dim)
*
*/
static CYTHON_INLINE __pyx_t_5numpy_intp_t PyArray_DIM(NumpyDotNet::ndarray^ __pyx_v_n, int __pyx_v_dim) {
__pyx_t_5numpy_intp_t __pyx_r;
System::Object^ __pyx_t_1 = nullptr;
PY_LONG_LONG __pyx_t_2;
/* "../cython/include/numpy.pxd":378
*
* cdef inline intp_t PyArray_DIM(ndarray n, int dim):
* return NpyArray_DIM(<NpyArray*><long long>n.Array, dim) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_NDIM(ndarray obj):
*/
__pyx_t_1 = __site_get_Array_378_47->Target(__site_get_Array_378_47, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt_PY_LONG_LONG_378_47->Target(__site_cvt_cvt_PY_LONG_LONG_378_47, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_DIM(((NpyArray *)((PY_LONG_LONG)__pyx_t_2)), __pyx_v_dim);
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":380
* return NpyArray_DIM(<NpyArray*><long long>n.Array, dim)
*
* cdef inline object PyArray_NDIM(ndarray obj): # <<<<<<<<<<<<<<
* return obj.ndim
*
*/
static CYTHON_INLINE System::Object^ PyArray_NDIM(NumpyDotNet::ndarray^ __pyx_v_obj) {
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":381
*
* cdef inline object PyArray_NDIM(ndarray obj):
* return obj.ndim # <<<<<<<<<<<<<<
*
* cdef inline intp_t PyArray_SIZE(ndarray n):
*/
__pyx_t_1 = __site_get_ndim_381_14->Target(__site_get_ndim_381_14, ((System::Object^)__pyx_v_obj), __pyx_context);
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":383
* return obj.ndim
*
* cdef inline intp_t PyArray_SIZE(ndarray n): # <<<<<<<<<<<<<<
* return NpyArray_SIZE(<NpyArray*> <npy_intp>n.Array)
*
*/
static CYTHON_INLINE __pyx_t_5numpy_intp_t PyArray_SIZE(NumpyDotNet::ndarray^ __pyx_v_n) {
__pyx_t_5numpy_intp_t __pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":384
*
* cdef inline intp_t PyArray_SIZE(ndarray n):
* return NpyArray_SIZE(<NpyArray*> <npy_intp>n.Array) # <<<<<<<<<<<<<<
*
* cdef inline npy_intp* PyArray_STRIDES(ndarray n):
*/
__pyx_t_1 = __site_get_Array_384_48->Target(__site_get_Array_384_48, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_384_48->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_384_48, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_SIZE(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":386
* return NpyArray_SIZE(<NpyArray*> <npy_intp>n.Array)
*
* cdef inline npy_intp* PyArray_STRIDES(ndarray n): # <<<<<<<<<<<<<<
* return NpyArray_STRIDES(<NpyArray*> <npy_intp>n.Array)
*
*/
static CYTHON_INLINE __pyx_t_5numpy_npy_intp *PyArray_STRIDES(NumpyDotNet::ndarray^ __pyx_v_n) {
__pyx_t_5numpy_npy_intp *__pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":387
*
* cdef inline npy_intp* PyArray_STRIDES(ndarray n):
* return NpyArray_STRIDES(<NpyArray*> <npy_intp>n.Array) # <<<<<<<<<<<<<<
*
* cdef inline npy_intp PyArray_NBYTES(ndarray n):
*/
__pyx_t_1 = __site_get_Array_387_51->Target(__site_get_Array_387_51, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_387_51->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_387_51, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_STRIDES(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":389
* return NpyArray_STRIDES(<NpyArray*> <npy_intp>n.Array)
*
* cdef inline npy_intp PyArray_NBYTES(ndarray n): # <<<<<<<<<<<<<<
* return NpyArray_NBYTES(<NpyArray *><long long>n.Array)
*
*/
static CYTHON_INLINE __pyx_t_5numpy_npy_intp PyArray_NBYTES(NumpyDotNet::ndarray^ __pyx_v_n) {
__pyx_t_5numpy_npy_intp __pyx_r;
System::Object^ __pyx_t_1 = nullptr;
PY_LONG_LONG __pyx_t_2;
/* "../cython/include/numpy.pxd":390
*
* cdef inline npy_intp PyArray_NBYTES(ndarray n):
* return NpyArray_NBYTES(<NpyArray *><long long>n.Array) # <<<<<<<<<<<<<<
*
* cdef inline NpyArray *PyArray_ARRAY(ndarray n):
*/
__pyx_t_1 = __site_get_Array_390_51->Target(__site_get_Array_390_51, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt_PY_LONG_LONG_390_51->Target(__site_cvt_cvt_PY_LONG_LONG_390_51, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_NBYTES(((NpyArray *)((PY_LONG_LONG)__pyx_t_2)));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":392
* return NpyArray_NBYTES(<NpyArray *><long long>n.Array)
*
* cdef inline NpyArray *PyArray_ARRAY(ndarray n): # <<<<<<<<<<<<<<
* return <NpyArray*> <npy_intp>n.Array
*
*/
static CYTHON_INLINE NpyArray *PyArray_ARRAY(NumpyDotNet::ndarray^ __pyx_v_n) {
NpyArray *__pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":393
*
* cdef inline NpyArray *PyArray_ARRAY(ndarray n):
* return <NpyArray*> <npy_intp>n.Array # <<<<<<<<<<<<<<
*
* cdef inline int PyArray_TYPE(ndarray n):
*/
__pyx_t_1 = __site_get_Array_393_34->Target(__site_get_Array_393_34, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_393_34->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_393_34, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = ((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":395
* return <NpyArray*> <npy_intp>n.Array
*
* cdef inline int PyArray_TYPE(ndarray n): # <<<<<<<<<<<<<<
* return NpyArray_TYPE(<NpyArray*> <npy_intp>n.Array)
*
*/
static CYTHON_INLINE int PyArray_TYPE(NumpyDotNet::ndarray^ __pyx_v_n) {
int __pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":396
*
* cdef inline int PyArray_TYPE(ndarray n):
* return NpyArray_TYPE(<NpyArray*> <npy_intp>n.Array) # <<<<<<<<<<<<<<
*
* cdef inline void *PyArray_Zero(arr):
*/
__pyx_t_1 = __site_get_Array_396_48->Target(__site_get_Array_396_48, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_396_48->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_396_48, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_TYPE(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":398
* return NpyArray_TYPE(<NpyArray*> <npy_intp>n.Array)
*
* cdef inline void *PyArray_Zero(arr): # <<<<<<<<<<<<<<
* import clr
* import NumpyDotNet.NpyArray
*/
static CYTHON_INLINE void *PyArray_Zero(System::Object^ __pyx_v_arr) {
System::Object^ __pyx_v_clr;
System::Object^ __pyx_v_NumpyDotNet;
void *__pyx_r;
System::Object^ __pyx_t_1 = nullptr;
System::Object^ __pyx_t_2 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_3;
__pyx_v_clr = nullptr;
__pyx_v_NumpyDotNet = nullptr;
/* "../cython/include/numpy.pxd":399
*
* cdef inline void *PyArray_Zero(arr):
* import clr # <<<<<<<<<<<<<<
* import NumpyDotNet.NpyArray
* return <void *><npy_intp>NumpyDotNet.NpyArray.Zero(arr)
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "clr", -1));
__pyx_v_clr = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":400
* cdef inline void *PyArray_Zero(arr):
* import clr
* import NumpyDotNet.NpyArray # <<<<<<<<<<<<<<
* return <void *><npy_intp>NumpyDotNet.NpyArray.Zero(arr)
*
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "NumpyDotNet.NpyArray", -1));
__pyx_v_NumpyDotNet = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":401
* import clr
* import NumpyDotNet.NpyArray
* return <void *><npy_intp>NumpyDotNet.NpyArray.Zero(arr) # <<<<<<<<<<<<<<
*
* cdef inline object NpyArray_Return(NpyArray *arr):
*/
__pyx_t_1 = __site_get_NpyArray_401_40->Target(__site_get_NpyArray_401_40, __pyx_v_NumpyDotNet, __pyx_context);
__pyx_t_2 = __site_get_Zero_401_49->Target(__site_get_Zero_401_49, __pyx_t_1, __pyx_context);
__pyx_t_1 = nullptr;
__pyx_t_1 = __site_call1_401_54->Target(__site_call1_401_54, __pyx_context, __pyx_t_2, __pyx_v_arr);
__pyx_t_2 = nullptr;
__pyx_t_3 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_401_54->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_401_54, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = ((void *)((__pyx_t_5numpy_npy_intp)__pyx_t_3));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":403
* return <void *><npy_intp>NumpyDotNet.NpyArray.Zero(arr)
*
* cdef inline object NpyArray_Return(NpyArray *arr): # <<<<<<<<<<<<<<
* ret = Npy_INTERFACE_array(arr)
* Npy_DECREF(arr)
*/
static CYTHON_INLINE System::Object^ NpyArray_Return(NpyArray *__pyx_v_arr) {
NumpyDotNet::ndarray^ __pyx_v_ret;
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
__pyx_v_ret = nullptr;
/* "../cython/include/numpy.pxd":404
*
* cdef inline object NpyArray_Return(NpyArray *arr):
* ret = Npy_INTERFACE_array(arr) # <<<<<<<<<<<<<<
* Npy_DECREF(arr)
* return ret
*/
__pyx_t_1 = ((System::Object^)Npy_INTERFACE_OBJECT(__pyx_v_arr));
__pyx_v_ret = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":405
* cdef inline object NpyArray_Return(NpyArray *arr):
* ret = Npy_INTERFACE_array(arr)
* Npy_DECREF(arr) # <<<<<<<<<<<<<<
* return ret
*
*/
Npy_DECREF(__pyx_v_arr);
/* "../cython/include/numpy.pxd":406
* ret = Npy_INTERFACE_array(arr)
* Npy_DECREF(arr)
* return ret # <<<<<<<<<<<<<<
*
* cdef inline int PyDataType_TYPE_NUM(dtype t):
*/
__pyx_r = ((System::Object^)__pyx_v_ret);
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":408
* return ret
*
* cdef inline int PyDataType_TYPE_NUM(dtype t): # <<<<<<<<<<<<<<
* return NpyDataType_TYPE_NUM(<NpyArray_Descr *><long long>t.Dtype)
*
*/
static CYTHON_INLINE int PyDataType_TYPE_NUM(NumpyDotNet::dtype^ __pyx_v_t) {
int __pyx_r;
System::Object^ __pyx_t_1 = nullptr;
PY_LONG_LONG __pyx_t_2;
/* "../cython/include/numpy.pxd":409
*
* cdef inline int PyDataType_TYPE_NUM(dtype t):
* return NpyDataType_TYPE_NUM(<NpyArray_Descr *><long long>t.Dtype) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_FromAny(op, newtype, min_depth, max_depth, flags, context):
*/
__pyx_t_1 = __site_get_Dtype_409_62->Target(__site_get_Dtype_409_62, ((System::Object^)__pyx_v_t), __pyx_context);
__pyx_t_2 = __site_cvt_cvt_PY_LONG_LONG_409_62->Target(__site_cvt_cvt_PY_LONG_LONG_409_62, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyDataType_TYPE_NUM(((NpyArray_Descr *)((PY_LONG_LONG)__pyx_t_2)));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":411
* return NpyDataType_TYPE_NUM(<NpyArray_Descr *><long long>t.Dtype)
*
* cdef inline object PyArray_FromAny(op, newtype, min_depth, max_depth, flags, context): # <<<<<<<<<<<<<<
* import clr
* import NumpyDotNet.NpyArray
*/
static CYTHON_INLINE System::Object^ PyArray_FromAny(System::Object^ __pyx_v_op, System::Object^ __pyx_v_newtype, System::Object^ __pyx_v_min_depth, System::Object^ __pyx_v_max_depth, System::Object^ __pyx_v_flags, System::Object^ __pyx_v_context) {
System::Object^ __pyx_v_clr;
System::Object^ __pyx_v_NumpyDotNet;
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
System::Object^ __pyx_t_2 = nullptr;
__pyx_v_clr = nullptr;
__pyx_v_NumpyDotNet = nullptr;
/* "../cython/include/numpy.pxd":412
*
* cdef inline object PyArray_FromAny(op, newtype, min_depth, max_depth, flags, context):
* import clr # <<<<<<<<<<<<<<
* import NumpyDotNet.NpyArray
* return NumpyDotNet.NpyArray.FromAny(op, newtype, min_depth, max_depth, flags, context)
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "clr", -1));
__pyx_v_clr = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":413
* cdef inline object PyArray_FromAny(op, newtype, min_depth, max_depth, flags, context):
* import clr
* import NumpyDotNet.NpyArray # <<<<<<<<<<<<<<
* return NumpyDotNet.NpyArray.FromAny(op, newtype, min_depth, max_depth, flags, context)
*
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "NumpyDotNet.NpyArray", -1));
__pyx_v_NumpyDotNet = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":414
* import clr
* import NumpyDotNet.NpyArray
* return NumpyDotNet.NpyArray.FromAny(op, newtype, min_depth, max_depth, flags, context) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = __site_get_NpyArray_414_22->Target(__site_get_NpyArray_414_22, __pyx_v_NumpyDotNet, __pyx_context);
__pyx_t_2 = __site_get_FromAny_414_31->Target(__site_get_FromAny_414_31, __pyx_t_1, __pyx_context);
__pyx_t_1 = nullptr;
__pyx_t_1 = __site_call6_414_39->Target(__site_call6_414_39, __pyx_context, __pyx_t_2, __pyx_v_op, __pyx_v_newtype, __pyx_v_min_depth, __pyx_v_max_depth, __pyx_v_flags, __pyx_v_context);
__pyx_t_2 = nullptr;
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":417
*
*
* cdef inline object PyArray_CopyFromObject(op, descr, min_depth, max_depth): # <<<<<<<<<<<<<<
* return PyArray_FromAny(op, descr, min_depth, max_depth,
* NPY_ENSURECOPY | NPY_DEFAULT | NPY_ENSUREARRAY, NULL)
*/
static CYTHON_INLINE System::Object^ PyArray_CopyFromObject(System::Object^ __pyx_v_op, System::Object^ __pyx_v_descr, System::Object^ __pyx_v_min_depth, System::Object^ __pyx_v_max_depth) {
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
System::Object^ __pyx_t_2 = nullptr;
System::Object^ __pyx_t_3 = nullptr;
/* "../cython/include/numpy.pxd":419
* cdef inline object PyArray_CopyFromObject(op, descr, min_depth, max_depth):
* return PyArray_FromAny(op, descr, min_depth, max_depth,
* NPY_ENSURECOPY | NPY_DEFAULT | NPY_ENSUREARRAY, NULL) # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_1 = (System::Object^)(long long)(((NPY_ENSURECOPY | NPY_DEFAULT) | NPY_ENSUREARRAY));
__pyx_t_2 = NULL;
__pyx_t_3 = PyArray_FromAny(__pyx_v_op, __pyx_v_descr, __pyx_v_min_depth, __pyx_v_max_depth, __pyx_t_1, __pyx_t_2);
__pyx_t_1 = nullptr;
__pyx_t_2 = nullptr;
__pyx_r = __pyx_t_3;
__pyx_t_3 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":422
*
*
* cdef inline object PyArray_FROMANY(m, type, min, max, flags): # <<<<<<<<<<<<<<
* if flags & NPY_ENSURECOPY:
* flags |= NPY_DEFAULT
*/
static CYTHON_INLINE System::Object^ PyArray_FROMANY(System::Object^ __pyx_v_m, System::Object^ __pyx_v_type, System::Object^ __pyx_v_min, System::Object^ __pyx_v_max, System::Object^ __pyx_v_flags) {
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
System::Object^ __pyx_t_2 = nullptr;
int __pyx_t_3;
int __pyx_t_4;
/* "../cython/include/numpy.pxd":423
*
* cdef inline object PyArray_FROMANY(m, type, min, max, flags):
* if flags & NPY_ENSURECOPY: # <<<<<<<<<<<<<<
* flags |= NPY_DEFAULT
* return PyArray_FromAny(m, Npy_INTERFACE_descr(NpyArray_DescrFromType(type)), min, max, flags, None)
*/
__pyx_t_1 = (System::Object^)(long long)(NPY_ENSURECOPY);
__pyx_t_2 = __site_op_and_423_13->Target(__site_op_and_423_13, __pyx_v_flags, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_t_3 = __site_istrue_423_13->Target(__site_istrue_423_13, __pyx_t_2);
__pyx_t_2 = nullptr;
if (__pyx_t_3) {
/* "../cython/include/numpy.pxd":424
* cdef inline object PyArray_FROMANY(m, type, min, max, flags):
* if flags & NPY_ENSURECOPY:
* flags |= NPY_DEFAULT # <<<<<<<<<<<<<<
* return PyArray_FromAny(m, Npy_INTERFACE_descr(NpyArray_DescrFromType(type)), min, max, flags, None)
*
*/
__pyx_t_2 = (System::Object^)(long long)(NPY_DEFAULT);
__pyx_t_1 = __site_op_ior_424_14->Target(__site_op_ior_424_14, __pyx_v_flags, __pyx_t_2);
__pyx_t_2 = nullptr;
__pyx_v_flags = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L3;
}
__pyx_L3:;
/* "../cython/include/numpy.pxd":425
* if flags & NPY_ENSURECOPY:
* flags |= NPY_DEFAULT
* return PyArray_FromAny(m, Npy_INTERFACE_descr(NpyArray_DescrFromType(type)), min, max, flags, None) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_ContiguousFromObject(op, type, minDepth, maxDepth):
*/
__pyx_t_4 = __site_cvt_cvt_int_425_77->Target(__site_cvt_cvt_int_425_77, __pyx_v_type);
__pyx_t_1 = ((System::Object^)Npy_INTERFACE_OBJECT(NpyArray_DescrFromType(__pyx_t_4)));
__pyx_t_2 = PyArray_FromAny(__pyx_v_m, __pyx_t_1, __pyx_v_min, __pyx_v_max, __pyx_v_flags, nullptr);
__pyx_t_1 = nullptr;
__pyx_r = __pyx_t_2;
__pyx_t_2 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":427
* return PyArray_FromAny(m, Npy_INTERFACE_descr(NpyArray_DescrFromType(type)), min, max, flags, None)
*
* cdef inline object PyArray_ContiguousFromObject(op, type, minDepth, maxDepth): # <<<<<<<<<<<<<<
* return PyArray_FromAny(op, Npy_INTERFACE_descr(NpyArray_DescrFromType(type)), minDepth, maxDepth,
* NPY_DEFAULT | NPY_ENSUREARRAY, NULL)
*/
static CYTHON_INLINE System::Object^ PyArray_ContiguousFromObject(System::Object^ __pyx_v_op, System::Object^ __pyx_v_type, System::Object^ __pyx_v_minDepth, System::Object^ __pyx_v_maxDepth) {
System::Object^ __pyx_r = nullptr;
int __pyx_t_1;
System::Object^ __pyx_t_2 = nullptr;
System::Object^ __pyx_t_3 = nullptr;
System::Object^ __pyx_t_4 = nullptr;
System::Object^ __pyx_t_5 = nullptr;
/* "../cython/include/numpy.pxd":428
*
* cdef inline object PyArray_ContiguousFromObject(op, type, minDepth, maxDepth):
* return PyArray_FromAny(op, Npy_INTERFACE_descr(NpyArray_DescrFromType(type)), minDepth, maxDepth, # <<<<<<<<<<<<<<
* NPY_DEFAULT | NPY_ENSUREARRAY, NULL)
*
*/
__pyx_t_1 = __site_cvt_cvt_int_428_78->Target(__site_cvt_cvt_int_428_78, __pyx_v_type);
__pyx_t_2 = ((System::Object^)Npy_INTERFACE_OBJECT(NpyArray_DescrFromType(__pyx_t_1)));
/* "../cython/include/numpy.pxd":429
* cdef inline object PyArray_ContiguousFromObject(op, type, minDepth, maxDepth):
* return PyArray_FromAny(op, Npy_INTERFACE_descr(NpyArray_DescrFromType(type)), minDepth, maxDepth,
* NPY_DEFAULT | NPY_ENSUREARRAY, NULL) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_CheckFromAny(op, newtype, min_depth, max_depth, flags, context):
*/
__pyx_t_3 = (System::Object^)(long long)((NPY_DEFAULT | NPY_ENSUREARRAY));
__pyx_t_4 = NULL;
__pyx_t_5 = PyArray_FromAny(__pyx_v_op, __pyx_t_2, __pyx_v_minDepth, __pyx_v_maxDepth, __pyx_t_3, __pyx_t_4);
__pyx_t_2 = nullptr;
__pyx_t_3 = nullptr;
__pyx_t_4 = nullptr;
__pyx_r = __pyx_t_5;
__pyx_t_5 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":431
* NPY_DEFAULT | NPY_ENSUREARRAY, NULL)
*
* cdef inline object PyArray_CheckFromAny(op, newtype, min_depth, max_depth, flags, context): # <<<<<<<<<<<<<<
* import clr
* import NumpyDotNet.NpyArray
*/
static CYTHON_INLINE System::Object^ PyArray_CheckFromAny(System::Object^ __pyx_v_op, System::Object^ __pyx_v_newtype, System::Object^ __pyx_v_min_depth, System::Object^ __pyx_v_max_depth, System::Object^ __pyx_v_flags, System::Object^ __pyx_v_context) {
System::Object^ __pyx_v_clr;
System::Object^ __pyx_v_NumpyDotNet;
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
System::Object^ __pyx_t_2 = nullptr;
__pyx_v_clr = nullptr;
__pyx_v_NumpyDotNet = nullptr;
/* "../cython/include/numpy.pxd":432
*
* cdef inline object PyArray_CheckFromAny(op, newtype, min_depth, max_depth, flags, context):
* import clr # <<<<<<<<<<<<<<
* import NumpyDotNet.NpyArray
* return NumpyDotNet.NpyArray.CheckFromAny(op, newtype, min_depth, max_depth, flags, context)
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "clr", -1));
__pyx_v_clr = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":433
* cdef inline object PyArray_CheckFromAny(op, newtype, min_depth, max_depth, flags, context):
* import clr
* import NumpyDotNet.NpyArray # <<<<<<<<<<<<<<
* return NumpyDotNet.NpyArray.CheckFromAny(op, newtype, min_depth, max_depth, flags, context)
*
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "NumpyDotNet.NpyArray", -1));
__pyx_v_NumpyDotNet = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":434
* import clr
* import NumpyDotNet.NpyArray
* return NumpyDotNet.NpyArray.CheckFromAny(op, newtype, min_depth, max_depth, flags, context) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_Check(obj):
*/
__pyx_t_1 = __site_get_NpyArray_434_22->Target(__site_get_NpyArray_434_22, __pyx_v_NumpyDotNet, __pyx_context);
__pyx_t_2 = __site_get_CheckFromAny_434_31->Target(__site_get_CheckFromAny_434_31, __pyx_t_1, __pyx_context);
__pyx_t_1 = nullptr;
__pyx_t_1 = __site_call6_434_44->Target(__site_call6_434_44, __pyx_context, __pyx_t_2, __pyx_v_op, __pyx_v_newtype, __pyx_v_min_depth, __pyx_v_max_depth, __pyx_v_flags, __pyx_v_context);
__pyx_t_2 = nullptr;
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":436
* return NumpyDotNet.NpyArray.CheckFromAny(op, newtype, min_depth, max_depth, flags, context)
*
* cdef inline object PyArray_Check(obj): # <<<<<<<<<<<<<<
* import numpy as np
* return isinstance(obj, np.ndarray)
*/
static CYTHON_INLINE System::Object^ PyArray_Check(System::Object^ __pyx_v_obj) {
System::Object^ __pyx_v_np;
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
System::Object^ __pyx_t_2 = nullptr;
System::Object^ __pyx_t_3 = nullptr;
__pyx_v_np = nullptr;
/* "../cython/include/numpy.pxd":437
*
* cdef inline object PyArray_Check(obj):
* import numpy as np # <<<<<<<<<<<<<<
* return isinstance(obj, np.ndarray)
*
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "numpy", -1));
__pyx_v_np = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":438
* cdef inline object PyArray_Check(obj):
* import numpy as np
* return isinstance(obj, np.ndarray) # <<<<<<<<<<<<<<
*
* cdef inline object PyArray_Cast(arr, typenum):
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "isinstance");
__pyx_t_2 = __site_get_ndarray_438_29->Target(__site_get_ndarray_438_29, __pyx_v_np, __pyx_context);
__pyx_t_3 = __site_call2_438_21->Target(__site_call2_438_21, __pyx_context, __pyx_t_1, __pyx_v_obj, __pyx_t_2);
__pyx_t_1 = nullptr;
__pyx_t_2 = nullptr;
__pyx_r = __pyx_t_3;
__pyx_t_3 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":440
* return isinstance(obj, np.ndarray)
*
* cdef inline object PyArray_Cast(arr, typenum): # <<<<<<<<<<<<<<
* import clr
* import NumpyDotNet.NpyCoreApi
*/
static CYTHON_INLINE System::Object^ PyArray_Cast(System::Object^ __pyx_v_arr, System::Object^ __pyx_v_typenum) {
System::Object^ __pyx_v_clr;
System::Object^ __pyx_v_NumpyDotNet;
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
System::Object^ __pyx_t_2 = nullptr;
int __pyx_t_3;
System::Object^ __pyx_t_4 = nullptr;
System::Object^ __pyx_t_5 = nullptr;
__pyx_v_clr = nullptr;
__pyx_v_NumpyDotNet = nullptr;
/* "../cython/include/numpy.pxd":441
*
* cdef inline object PyArray_Cast(arr, typenum):
* import clr # <<<<<<<<<<<<<<
* import NumpyDotNet.NpyCoreApi
* return NumpyDotNet.NpyCoreApi.CastToType(arr, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), False)
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "clr", -1));
__pyx_v_clr = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":442
* cdef inline object PyArray_Cast(arr, typenum):
* import clr
* import NumpyDotNet.NpyCoreApi # <<<<<<<<<<<<<<
* return NumpyDotNet.NpyCoreApi.CastToType(arr, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), False)
*
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "NumpyDotNet.NpyCoreApi", -1));
__pyx_v_NumpyDotNet = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":443
* import clr
* import NumpyDotNet.NpyCoreApi
* return NumpyDotNet.NpyCoreApi.CastToType(arr, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), False) # <<<<<<<<<<<<<<
*
* cdef inline void import_array():
*/
__pyx_t_1 = __site_get_NpyCoreApi_443_22->Target(__site_get_NpyCoreApi_443_22, __pyx_v_NumpyDotNet, __pyx_context);
__pyx_t_2 = __site_get_CastToType_443_33->Target(__site_get_CastToType_443_33, __pyx_t_1, __pyx_context);
__pyx_t_1 = nullptr;
__pyx_t_3 = __site_cvt_cvt_int_443_100->Target(__site_cvt_cvt_int_443_100, __pyx_v_typenum);
__pyx_t_1 = ((System::Object^)Npy_INTERFACE_OBJECT(NpyArray_DescrFromType(__pyx_t_3)));
__pyx_t_4 = 0;
__pyx_t_5 = __site_call3_443_44->Target(__site_call3_443_44, __pyx_context, __pyx_t_2, __pyx_v_arr, __pyx_t_1, __pyx_t_4);
__pyx_t_2 = nullptr;
__pyx_t_1 = nullptr;
__pyx_t_4 = nullptr;
__pyx_r = __pyx_t_5;
__pyx_t_5 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":445
* return NumpyDotNet.NpyCoreApi.CastToType(arr, Npy_INTERFACE_descr(NpyArray_DescrFromType(typenum)), False)
*
* cdef inline void import_array(): # <<<<<<<<<<<<<<
* pass
*
*/
static CYTHON_INLINE void import_array(void) {
}
/* "../cython/include/numpy.pxd":448
* pass
*
* cdef inline PyNumber_Check(o): # <<<<<<<<<<<<<<
* import clr
* import NumpyDotNet.ScalarGeneric
*/
static CYTHON_INLINE System::Object^ PyNumber_Check(System::Object^ __pyx_v_o) {
System::Object^ __pyx_v_clr;
System::Object^ __pyx_v_NumpyDotNet;
System::Object^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
System::Object^ __pyx_t_2 = nullptr;
System::Object^ __pyx_t_3 = nullptr;
System::Object^ __pyx_t_4 = nullptr;
System::Object^ __pyx_t_5 = nullptr;
int __pyx_t_6;
__pyx_v_clr = nullptr;
__pyx_v_NumpyDotNet = nullptr;
/* "../cython/include/numpy.pxd":449
*
* cdef inline PyNumber_Check(o):
* import clr # <<<<<<<<<<<<<<
* import NumpyDotNet.ScalarGeneric
* return isinstance(o, (int, long, float)) or isinstance(o, NumpyDotNet.ScalarGeneric)
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "clr", -1));
__pyx_v_clr = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":450
* cdef inline PyNumber_Check(o):
* import clr
* import NumpyDotNet.ScalarGeneric # <<<<<<<<<<<<<<
* return isinstance(o, (int, long, float)) or isinstance(o, NumpyDotNet.ScalarGeneric)
*
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "NumpyDotNet.ScalarGeneric", -1));
__pyx_v_NumpyDotNet = __pyx_t_1;
__pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":451
* import clr
* import NumpyDotNet.ScalarGeneric
* return isinstance(o, (int, long, float)) or isinstance(o, NumpyDotNet.ScalarGeneric) # <<<<<<<<<<<<<<
*
* cdef inline NpyArrayIterObject *PyArray_IterNew(ndarray n):
*/
__pyx_t_1 = PythonOps::GetGlobal(__pyx_context, "isinstance");
__pyx_t_2 = PythonOps::GetGlobal(__pyx_context, "int");
__pyx_t_3 = PythonOps::GetGlobal(__pyx_context, "long");
__pyx_t_4 = PythonOps::GetGlobal(__pyx_context, "float");
__pyx_t_5 = PythonOps::MakeTuple(gcnew array<System::Object^>{((System::Object^)__pyx_t_2), ((System::Object^)__pyx_t_3), ((System::Object^)__pyx_t_4)});
__pyx_t_2 = nullptr;
__pyx_t_3 = nullptr;
__pyx_t_4 = nullptr;
__pyx_t_4 = __site_call2_451_21->Target(__site_call2_451_21, __pyx_context, __pyx_t_1, __pyx_v_o, __pyx_t_5);
__pyx_t_1 = nullptr;
__pyx_t_5 = nullptr;
__pyx_t_6 = __site_cvt_bool_451_45->Target(__site_cvt_bool_451_45, __pyx_t_4);
if (!__pyx_t_6) {
__pyx_t_4 = nullptr;
__pyx_t_5 = PythonOps::GetGlobal(__pyx_context, "isinstance");
__pyx_t_1 = __site_get_ScalarGeneric_451_73->Target(__site_get_ScalarGeneric_451_73, __pyx_v_NumpyDotNet, __pyx_context);
__pyx_t_3 = __site_call2_451_58->Target(__site_call2_451_58, __pyx_context, __pyx_t_5, __pyx_v_o, __pyx_t_1);
__pyx_t_5 = nullptr;
__pyx_t_1 = nullptr;
__pyx_t_1 = __pyx_t_3;
__pyx_t_3 = nullptr;
} else {
__pyx_t_1 = __pyx_t_4;
__pyx_t_4 = nullptr;
}
__pyx_r = __pyx_t_1;
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":453
* return isinstance(o, (int, long, float)) or isinstance(o, NumpyDotNet.ScalarGeneric)
*
* cdef inline NpyArrayIterObject *PyArray_IterNew(ndarray n): # <<<<<<<<<<<<<<
* return NpyArray_IterNew(<NpyArray*> <npy_intp>n.Array)
*
*/
static CYTHON_INLINE NpyArrayIterObject *PyArray_IterNew(NumpyDotNet::ndarray^ __pyx_v_n) {
NpyArrayIterObject *__pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":454
*
* cdef inline NpyArrayIterObject *PyArray_IterNew(ndarray n):
* return NpyArray_IterNew(<NpyArray*> <npy_intp>n.Array) # <<<<<<<<<<<<<<
*
* cdef inline NpyArrayIterObject *PyArray_IterAllButAxis(ndarray n, int *inaxis):
*/
__pyx_t_1 = __site_get_Array_454_51->Target(__site_get_Array_454_51, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_454_51->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_454_51, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_IterNew(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)));
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":456
* return NpyArray_IterNew(<NpyArray*> <npy_intp>n.Array)
*
* cdef inline NpyArrayIterObject *PyArray_IterAllButAxis(ndarray n, int *inaxis): # <<<<<<<<<<<<<<
* return NpyArray_IterAllButAxis(<NpyArray*> <npy_intp>n.Array, inaxis)
*
*/
static CYTHON_INLINE NpyArrayIterObject *PyArray_IterAllButAxis(NumpyDotNet::ndarray^ __pyx_v_n, int *__pyx_v_inaxis) {
NpyArrayIterObject *__pyx_r;
System::Object^ __pyx_t_1 = nullptr;
__pyx_t_5numpy_npy_intp __pyx_t_2;
/* "../cython/include/numpy.pxd":457
*
* cdef inline NpyArrayIterObject *PyArray_IterAllButAxis(ndarray n, int *inaxis):
* return NpyArray_IterAllButAxis(<NpyArray*> <npy_intp>n.Array, inaxis) # <<<<<<<<<<<<<<
*
* cdef inline void PyArray_ITER_NEXT(NpyArrayIterObject *obj):
*/
__pyx_t_1 = __site_get_Array_457_58->Target(__site_get_Array_457_58, ((System::Object^)__pyx_v_n), __pyx_context);
__pyx_t_2 = __site_cvt_cvt___pyx_t_5numpy_npy_intp_457_58->Target(__site_cvt_cvt___pyx_t_5numpy_npy_intp_457_58, __pyx_t_1);
__pyx_t_1 = nullptr;
__pyx_r = NpyArray_IterAllButAxis(((NpyArray *)((__pyx_t_5numpy_npy_intp)__pyx_t_2)), __pyx_v_inaxis);
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":459
* return NpyArray_IterAllButAxis(<NpyArray*> <npy_intp>n.Array, inaxis)
*
* cdef inline void PyArray_ITER_NEXT(NpyArrayIterObject *obj): # <<<<<<<<<<<<<<
* NpyArray_ITER_NEXT(obj)
*
*/
static CYTHON_INLINE void PyArray_ITER_NEXT(NpyArrayIterObject *__pyx_v_obj) {
/* "../cython/include/numpy.pxd":460
*
* cdef inline void PyArray_ITER_NEXT(NpyArrayIterObject *obj):
* NpyArray_ITER_NEXT(obj) # <<<<<<<<<<<<<<
*
* cdef inline void PyArray_ITER_RESET(NpyArrayIterObject *obj):
*/
NpyArray_ITER_NEXT(__pyx_v_obj);
}
/* "../cython/include/numpy.pxd":462
* NpyArray_ITER_NEXT(obj)
*
* cdef inline void PyArray_ITER_RESET(NpyArrayIterObject *obj): # <<<<<<<<<<<<<<
* NpyArray_ITER_RESET(obj)
*
*/
static CYTHON_INLINE void PyArray_ITER_RESET(NpyArrayIterObject *__pyx_v_obj) {
/* "../cython/include/numpy.pxd":463
*
* cdef inline void PyArray_ITER_RESET(NpyArrayIterObject *obj):
* NpyArray_ITER_RESET(obj) # <<<<<<<<<<<<<<
*
* cdef inline void * PyArray_ITER_DATA(NpyArrayIterObject *obj):
*/
NpyArray_ITER_RESET(__pyx_v_obj);
}
/* "../cython/include/numpy.pxd":465
* NpyArray_ITER_RESET(obj)
*
* cdef inline void * PyArray_ITER_DATA(NpyArrayIterObject *obj): # <<<<<<<<<<<<<<
* return NpyArray_ITER_DATA(obj)
*
*/
static CYTHON_INLINE void *PyArray_ITER_DATA(NpyArrayIterObject *__pyx_v_obj) {
void *__pyx_r;
/* "../cython/include/numpy.pxd":466
*
* cdef inline void * PyArray_ITER_DATA(NpyArrayIterObject *obj):
* return NpyArray_ITER_DATA(obj) # <<<<<<<<<<<<<<
*
* cdef inline NpyArrayNeighborhoodIterObject* PyArray_NeighborhoodIterNew(NpyArrayIterObject *obj,
*/
__pyx_r = NpyArray_ITER_DATA(__pyx_v_obj);
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":468
* return NpyArray_ITER_DATA(obj)
*
* cdef inline NpyArrayNeighborhoodIterObject* PyArray_NeighborhoodIterNew(NpyArrayIterObject *obj, # <<<<<<<<<<<<<<
* npy_intp *bounds,
* int mode,
*/
static CYTHON_INLINE NpyArrayNeighborhoodIterObject *PyArray_NeighborhoodIterNew(NpyArrayIterObject *__pyx_v_obj, __pyx_t_5numpy_npy_intp *__pyx_v_bounds, int __pyx_v_mode, void *__pyx_v_fill, npy_free_func __pyx_v_fillfree) {
NpyArrayNeighborhoodIterObject *__pyx_r;
/* "../cython/include/numpy.pxd":473
* void *fill,
* npy_free_func fillfree):
* return NpyArray_NeighborhoodIterNew(obj, bounds, mode, fill, fillfree) # <<<<<<<<<<<<<<
*
* cdef inline int PyArrayNeighborhoodIter_Reset(NpyArrayNeighborhoodIterObject* iter):
*/
__pyx_r = NpyArray_NeighborhoodIterNew(__pyx_v_obj, __pyx_v_bounds, __pyx_v_mode, __pyx_v_fill, __pyx_v_fillfree);
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":475
* return NpyArray_NeighborhoodIterNew(obj, bounds, mode, fill, fillfree)
*
* cdef inline int PyArrayNeighborhoodIter_Reset(NpyArrayNeighborhoodIterObject* iter): # <<<<<<<<<<<<<<
* return NpyArrayNeighborhoodIter_Reset(iter)
*
*/
static CYTHON_INLINE int PyArrayNeighborhoodIter_Reset(NpyArrayNeighborhoodIterObject *__pyx_v_iter) {
int __pyx_r;
/* "../cython/include/numpy.pxd":476
*
* cdef inline int PyArrayNeighborhoodIter_Reset(NpyArrayNeighborhoodIterObject* iter):
* return NpyArrayNeighborhoodIter_Reset(iter) # <<<<<<<<<<<<<<
*
* cdef inline int PyArrayNeighborhoodIter_Next(NpyArrayNeighborhoodIterObject* iter):
*/
__pyx_r = NpyArrayNeighborhoodIter_Reset(__pyx_v_iter);
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":478
* return NpyArrayNeighborhoodIter_Reset(iter)
*
* cdef inline int PyArrayNeighborhoodIter_Next(NpyArrayNeighborhoodIterObject* iter): # <<<<<<<<<<<<<<
* return NpyArrayNeighborhoodIter_Next(iter)
*
*/
static CYTHON_INLINE int PyArrayNeighborhoodIter_Next(NpyArrayNeighborhoodIterObject *__pyx_v_iter) {
int __pyx_r;
/* "../cython/include/numpy.pxd":479
*
* cdef inline int PyArrayNeighborhoodIter_Next(NpyArrayNeighborhoodIterObject* iter):
* return NpyArrayNeighborhoodIter_Next(iter) # <<<<<<<<<<<<<<
*
* cdef inline ndarray NpyIter_ARRAY(NpyArrayIterObject *iter):
*/
__pyx_r = NpyArrayNeighborhoodIter_Next(__pyx_v_iter);
goto __pyx_L0;
__pyx_r = 0;
__pyx_L0:;
return __pyx_r;
}
/* "../cython/include/numpy.pxd":481
* return NpyArrayNeighborhoodIter_Next(iter)
*
* cdef inline ndarray NpyIter_ARRAY(NpyArrayIterObject *iter): # <<<<<<<<<<<<<<
* return Npy_INTERFACE_array(iter.ao)
*/
static CYTHON_INLINE NumpyDotNet::ndarray^ NpyIter_ARRAY(NpyArrayIterObject *__pyx_v_iter) {
NumpyDotNet::ndarray^ __pyx_r = nullptr;
System::Object^ __pyx_t_1 = nullptr;
/* "../cython/include/numpy.pxd":482
*
* cdef inline ndarray NpyIter_ARRAY(NpyArrayIterObject *iter):
* return Npy_INTERFACE_array(iter.ao) # <<<<<<<<<<<<<<
*/
__pyx_t_1 = ((System::Object^)Npy_INTERFACE_OBJECT(__pyx_v_iter->ao));
__pyx_r = ((NumpyDotNet::ndarray^)__pyx_t_1);
__pyx_t_1 = nullptr;
goto __pyx_L0;
__pyx_r = nullptr;
__pyx_L0:;
return __pyx_r;
}
// XXX skipping all typeobj definitions
/* Cython code section 'pystring_table' */
/* Cython code section 'cached_builtins' */
/* Cython code section 'init_globals' */
static int __Pyx_InitGlobals(void) {
__pyx_int_0 = 0;
__pyx_int_1 = 1;
__pyx_int_2 = 2;
return 0;
}
/* Cython code section 'init_module' */
static void __Pyx_InitSites(CodeContext^ __pyx_context) {
const int PythonOperationKind_Contains = 5;
const int PythonOperationKind_GetEnumeratorForIteration = 18;
const int PythonOperationKind_FloorDivide = 23;
const int PythonOperationKind_TrueDivide = 25;
const int PythonOperationKind_InPlaceFloorDivide = 0x20000000 | 23;
const int PythonOperationKind_InPlaceTrueDivide = 0x20000000 | 25;
__site_call2_62_36 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_call2_ARGS_64_36 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(gcnew array<Argument>{Argument::Simple, Argument::Simple, Argument(ArgumentType::List)})));
__site_call1_68_32 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_get_exc_info_73_17 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "exc_info", false));
__site_call0_73_26 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(0)));
__site_call2_90_35 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_call2_ARGS_92_35 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(gcnew array<Argument>{Argument::Simple, Argument::Simple, Argument(ArgumentType::List)})));
__site_call1_96_32 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_get_exc_info_101_17 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "exc_info", false));
__site_call0_101_26 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(0)));
__site_cvt_cvt_fwr_dbl_t_104_0 = CallSite< System::Func< CallSite^, System::Object^, fwr_dbl_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwr_dbl_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_fwr_dbl_t_104_0_1 = CallSite< System::Func< CallSite^, System::Object^, fwr_dbl_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwr_dbl_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_fwi_integer_t_104_0 = CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwi_integer_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_fwi_integer_t_104_0_1 = CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwi_integer_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_fwi_integer_t_104_0_2 = CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwi_integer_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_int_104_0 = CallSite< System::Func< CallSite^, System::Object^, int >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, int::typeid, ConversionResultKind::ExplicitCast));
__site_call1_148_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_150_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_152_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_154_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_156_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_158_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_160_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_162_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_164_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call2_165_47 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_call2_166_51 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_call2_188_36 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_call2_ARGS_190_36 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(gcnew array<Argument>{Argument::Simple, Argument::Simple, Argument(ArgumentType::List)})));
__site_call1_194_32 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_get_exc_info_199_17 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "exc_info", false));
__site_call0_199_26 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(0)));
__site_call2_215_35 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_call2_ARGS_217_35 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(gcnew array<Argument>{Argument::Simple, Argument::Simple, Argument(ArgumentType::List)})));
__site_call1_221_32 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_get_exc_info_226_17 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "exc_info", false));
__site_call0_226_26 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(0)));
__site_cvt_cvt_fwr_dbl_t_228_0 = CallSite< System::Func< CallSite^, System::Object^, fwr_dbl_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwr_dbl_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_fwr_dbl_t_228_0_1 = CallSite< System::Func< CallSite^, System::Object^, fwr_dbl_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwr_dbl_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_fwi_integer_t_228_0 = CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwi_integer_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_fwi_integer_t_228_0_1 = CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwi_integer_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_fwi_integer_t_228_0_2 = CallSite< System::Func< CallSite^, System::Object^, fwi_integer_t >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, fwi_integer_t::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_int_228_0 = CallSite< System::Func< CallSite^, System::Object^, int >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, int::typeid, ConversionResultKind::ExplicitCast));
__site_call1_275_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_277_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_279_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_281_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_283_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_285_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_287_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_289_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_291_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_293_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call1_295_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_call2_296_47 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_call2_297_51 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_call1_318_27 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_istrue_323_59 = CallSite< System::Func< CallSite^, System::Object^, bool >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, bool::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_int_330_29 = CallSite< System::Func< CallSite^, System::Object^, int >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, int::typeid, ConversionResultKind::ExplicitCast));
__site_op_mod_332_60 = CallSite< System::Func< CallSite^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeBinaryOperationAction(__pyx_context, ExpressionType::Modulo));
__site_call1_332_24 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_get_append_323_18 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "append", false));
__site_call1_323_25 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_get_zeros_325_16 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "zeros", false));
__site_call3_325_22 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(3)));
__site_get_append_331_18 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "append", false));
__site_call1_331_25 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_get_empty_333_16 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "empty", false));
__site_call3_333_22 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(3)));
__site_get_append_339_18 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "append", false));
__site_call1_339_25 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_get_empty_341_16 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "empty", false));
__site_call3_341_22 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(3)));
__site_get_Array_356_53 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_356_53 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_Array_359_48 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_359_48 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_Array_362_48 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_362_48 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_Array_365_69 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_365_69 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_Array_368_52 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_368_52 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_ndarray_375_22 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "ndarray", false));
__site_get_ArrayReturn_375_30 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "ArrayReturn", false));
__site_call1_375_42 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_get_Array_378_47 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt_PY_LONG_LONG_378_47 = CallSite< System::Func< CallSite^, System::Object^, PY_LONG_LONG >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, PY_LONG_LONG::typeid, ConversionResultKind::ExplicitCast));
__site_get_ndim_381_14 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "ndim", false));
__site_get_Array_384_48 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_384_48 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_Array_387_51 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_387_51 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_Array_390_51 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt_PY_LONG_LONG_390_51 = CallSite< System::Func< CallSite^, System::Object^, PY_LONG_LONG >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, PY_LONG_LONG::typeid, ConversionResultKind::ExplicitCast));
__site_get_Array_393_34 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_393_34 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_Array_396_48 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_396_48 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_NpyArray_401_40 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "NpyArray", false));
__site_get_Zero_401_49 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Zero", false));
__site_call1_401_54 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(1)));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_401_54 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_Dtype_409_62 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Dtype", false));
__site_cvt_cvt_PY_LONG_LONG_409_62 = CallSite< System::Func< CallSite^, System::Object^, PY_LONG_LONG >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, PY_LONG_LONG::typeid, ConversionResultKind::ExplicitCast));
__site_get_NpyArray_414_22 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "NpyArray", false));
__site_get_FromAny_414_31 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "FromAny", false));
__site_call6_414_39 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(6)));
__site_op_and_423_13 = CallSite< System::Func< CallSite^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeBinaryOperationAction(__pyx_context, ExpressionType::And));
__site_istrue_423_13 = CallSite< System::Func< CallSite^, System::Object^, bool >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, bool::typeid, ConversionResultKind::ExplicitCast));
__site_op_ior_424_14 = CallSite< System::Func< CallSite^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeBinaryOperationAction(__pyx_context, ExpressionType::OrAssign));
__site_cvt_cvt_int_425_77 = CallSite< System::Func< CallSite^, System::Object^, int >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, int::typeid, ConversionResultKind::ExplicitCast));
__site_cvt_cvt_int_428_78 = CallSite< System::Func< CallSite^, System::Object^, int >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, int::typeid, ConversionResultKind::ExplicitCast));
__site_get_NpyArray_434_22 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "NpyArray", false));
__site_get_CheckFromAny_434_31 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "CheckFromAny", false));
__site_call6_434_44 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(6)));
__site_get_ndarray_438_29 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "ndarray", false));
__site_call2_438_21 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_get_NpyCoreApi_443_22 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "NpyCoreApi", false));
__site_get_CastToType_443_33 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "CastToType", false));
__site_cvt_cvt_int_443_100 = CallSite< System::Func< CallSite^, System::Object^, int >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, int::typeid, ConversionResultKind::ExplicitCast));
__site_call3_443_44 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(3)));
__site_call2_451_21 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_cvt_bool_451_45 = CallSite< System::Func< CallSite^, System::Object^, bool >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, bool::typeid, ConversionResultKind::ExplicitCast));
__site_get_ScalarGeneric_451_73 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "ScalarGeneric", false));
__site_call2_451_58 = CallSite< System::Func< CallSite^, CodeContext^, System::Object^, System::Object^, System::Object^, System::Object^ >^ >::Create(PythonOps::MakeInvokeAction(__pyx_context, CallSignature(2)));
__site_get_Array_454_51 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_454_51 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
__site_get_Array_457_58 = CallSite< System::Func< CallSite^, System::Object^, CodeContext^, System::Object^ >^ >::Create(PythonOps::MakeGetAction(__pyx_context, "Array", false));
__site_cvt_cvt___pyx_t_5numpy_npy_intp_457_58 = CallSite< System::Func< CallSite^, System::Object^, __pyx_t_5numpy_npy_intp >^ >::Create(PythonOps::MakeConversionAction(__pyx_context, __pyx_t_5numpy_npy_intp::typeid, ConversionResultKind::ExplicitCast));
}
[SpecialName]
static void PerformModuleReload(PythonContext^ context, PythonDictionary^ dict) {
dict["__builtins__"] = context->BuiltinModuleInstance;
__pyx_context = (gcnew ModuleContext(dict, context))->GlobalContext;
__Pyx_InitSites(__pyx_context);
__Pyx_InitGlobals();
/*--- Type init code ---*/
__pyx_ptype_5scipy_9integrate_4vode_fw_CallbackInfo = safe_cast<Types::PythonType^>(dict["fw_CallbackInfo"]);
/*--- Type import code ---*/
// XXX skipping type ptr assignment for NumpyDotNet::ndarray
// XXX skipping type ptr assignment for NumpyDotNet::dtype
/*--- Create function pointers ---*/
__pyx_delegate_val_dvode_f_cb_wrapper_core = gcnew __pyx_delegate_t_5scipy_9integrate_4vode_dvode_f_cb_wrapper_core(dvode_f_cb_wrapper_core);
__pyx_function_pointer_dvode_f_cb_wrapper_core = (__pyx_fp_t_dvode_f_cb_wrapper_core)(InteropServices::Marshal::GetFunctionPointerForDelegate(__pyx_delegate_val_dvode_f_cb_wrapper_core).ToPointer());
__pyx_delegate_val_dvode_jac_cb_wrapper_core = gcnew __pyx_delegate_t_5scipy_9integrate_4vode_dvode_jac_cb_wrapper_core(dvode_jac_cb_wrapper_core);
__pyx_function_pointer_dvode_jac_cb_wrapper_core = (__pyx_fp_t_dvode_jac_cb_wrapper_core)(InteropServices::Marshal::GetFunctionPointerForDelegate(__pyx_delegate_val_dvode_jac_cb_wrapper_core).ToPointer());
__pyx_delegate_val_zvode_f_cb_wrapper_core = gcnew __pyx_delegate_t_5scipy_9integrate_4vode_zvode_f_cb_wrapper_core(zvode_f_cb_wrapper_core);
__pyx_function_pointer_zvode_f_cb_wrapper_core = (__pyx_fp_t_zvode_f_cb_wrapper_core)(InteropServices::Marshal::GetFunctionPointerForDelegate(__pyx_delegate_val_zvode_f_cb_wrapper_core).ToPointer());
__pyx_delegate_val_zvode_jac_cb_wrapper_core = gcnew __pyx_delegate_t_5scipy_9integrate_4vode_zvode_jac_cb_wrapper_core(zvode_jac_cb_wrapper_core);
__pyx_function_pointer_zvode_jac_cb_wrapper_core = (__pyx_fp_t_zvode_jac_cb_wrapper_core)(InteropServices::Marshal::GetFunctionPointerForDelegate(__pyx_delegate_val_zvode_jac_cb_wrapper_core).ToPointer());
/*--- Execution code ---*/
System::Object^ __pyx_t_1 = nullptr;
PythonDictionary^ __pyx_t_2;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":19
* cimport vode_fc as fc
*
* np.import_array() # <<<<<<<<<<<<<<
* import sys
*
*/
import_array();
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":20
*
* np.import_array()
* import sys # <<<<<<<<<<<<<<
*
* cdef extern from "setjmp.h":
*/
__pyx_t_1 = LightExceptions::CheckAndThrow(PythonOps::ImportTop(__pyx_context, "sys", -1));
PythonOps::SetGlobal(__pyx_context, "sys", __pyx_t_1);
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":47
*
*
* __all__ = ['dvode', 'zvode'] # <<<<<<<<<<<<<<
*
* cdef fw_CallbackInfo dvode_f_cb_info
*/
__pyx_t_1 = PythonOps::MakeListNoCopy(gcnew array<System::Object^>{((System::Object^)"dvode"), ((System::Object^)"zvode")});
PythonOps::SetGlobal(__pyx_context, "__all__", ((System::Object^)__pyx_t_1));
__pyx_t_1 = nullptr;
/* "/cygdrive/z/dev/scipy-refactor/scipy/integrate/vode.pyx":1
* #cython: ccomplex=True # <<<<<<<<<<<<<<
*
* """The vode module was generated with Fwrap v0.2.0dev_00843a8.
*/
__pyx_t_2 = PythonOps::MakeEmptyDict();
PythonOps::SetGlobal(__pyx_context, "__test__", ((System::Object^)__pyx_t_2));
__pyx_t_2 = nullptr;
/* "../cython/include/numpy.pxd":481
* return NpyArrayNeighborhoodIter_Next(iter)
*
* cdef inline ndarray NpyIter_ARRAY(NpyArrayIterObject *iter): # <<<<<<<<<<<<<<
* return Npy_INTERFACE_array(iter.ao)
*/
}
/* Cython code section 'cleanup_globals' */
/* Cython code section 'cleanup_module' */
/* Cython code section 'main_method' */
/* Cython code section 'dotnet_globals' */
static Types::PythonType^ __pyx_ptype_5numpy_ndarray = nullptr;
static Types::PythonType^ __pyx_ptype_5numpy_dtype = nullptr;
static Types::PythonType^ __pyx_ptype_5scipy_9integrate_4vode_fw_CallbackInfo = nullptr;
static fw_CallbackInfo^ __pyx_v_5scipy_9integrate_4vode_dvode_f_cb_info = nullptr;
static fw_CallbackInfo^ __pyx_v_5scipy_9integrate_4vode_dvode_jac_cb_info = nullptr;
static fw_CallbackInfo^ __pyx_v_5scipy_9integrate_4vode_zvode_f_cb_info = nullptr;
static fw_CallbackInfo^ __pyx_v_5scipy_9integrate_4vode_zvode_jac_cb_info = nullptr;
/* Cython code section 'utility_code_def' */
/* Runtime support code */
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
return ::std::complex< float >(x, y);
}
#else
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
return x + y*(__pyx_t_float_complex)_Complex_I;
}
#endif
#else
static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {
__pyx_t_float_complex z;
z.real = x;
z.imag = y;
return z;
}
#endif
#if CYTHON_CCOMPLEX
#else
static CYTHON_INLINE int __Pyx_c_eqf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
return (a.real == b.real) && (a.imag == b.imag);
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_sumf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
__pyx_t_float_complex z;
z.real = a.real + b.real;
z.imag = a.imag + b.imag;
return z;
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_difff(__pyx_t_float_complex a, __pyx_t_float_complex b) {
__pyx_t_float_complex z;
z.real = a.real - b.real;
z.imag = a.imag - b.imag;
return z;
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_prodf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
__pyx_t_float_complex z;
z.real = a.real * b.real - a.imag * b.imag;
z.imag = a.real * b.imag + a.imag * b.real;
return z;
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_quotf(__pyx_t_float_complex a, __pyx_t_float_complex b) {
__pyx_t_float_complex z;
float denom = b.real * b.real + b.imag * b.imag;
z.real = (a.real * b.real + a.imag * b.imag) / denom;
z.imag = (a.imag * b.real - a.real * b.imag) / denom;
return z;
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_negf(__pyx_t_float_complex a) {
__pyx_t_float_complex z;
z.real = -a.real;
z.imag = -a.imag;
return z;
}
static CYTHON_INLINE int __Pyx_c_is_zerof(__pyx_t_float_complex a) {
return (a.real == 0) && (a.imag == 0);
}
static CYTHON_INLINE __pyx_t_float_complex __Pyx_c_conjf(__pyx_t_float_complex a) {
__pyx_t_float_complex z;
z.real = a.real;
z.imag = -a.imag;
return z;
}
/*
static CYTHON_INLINE float __Pyx_c_absf(__pyx_t_float_complex z) {
#if HAVE_HYPOT
return hypotf(z.real, z.imag);
#else
return sqrtf(z.real*z.real + z.imag*z.imag);
#endif
}
*/
#endif
#if CYTHON_CCOMPLEX
#ifdef __cplusplus
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
return ::std::complex< double >(x, y);
}
#else
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
return x + y*(__pyx_t_double_complex)_Complex_I;
}
#endif
#else
static CYTHON_INLINE __pyx_t_double_complex __pyx_t_double_complex_from_parts(double x, double y) {
__pyx_t_double_complex z;
z.real = x;
z.imag = y;
return z;
}
#endif
#if CYTHON_CCOMPLEX
#else
static CYTHON_INLINE int __Pyx_c_eq(__pyx_t_double_complex a, __pyx_t_double_complex b) {
return (a.real == b.real) && (a.imag == b.imag);
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_sum(__pyx_t_double_complex a, __pyx_t_double_complex b) {
__pyx_t_double_complex z;
z.real = a.real + b.real;
z.imag = a.imag + b.imag;
return z;
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_diff(__pyx_t_double_complex a, __pyx_t_double_complex b) {
__pyx_t_double_complex z;
z.real = a.real - b.real;
z.imag = a.imag - b.imag;
return z;
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_prod(__pyx_t_double_complex a, __pyx_t_double_complex b) {
__pyx_t_double_complex z;
z.real = a.real * b.real - a.imag * b.imag;
z.imag = a.real * b.imag + a.imag * b.real;
return z;
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_quot(__pyx_t_double_complex a, __pyx_t_double_complex b) {
__pyx_t_double_complex z;
double denom = b.real * b.real + b.imag * b.imag;
z.real = (a.real * b.real + a.imag * b.imag) / denom;
z.imag = (a.imag * b.real - a.real * b.imag) / denom;
return z;
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_neg(__pyx_t_double_complex a) {
__pyx_t_double_complex z;
z.real = -a.real;
z.imag = -a.imag;
return z;
}
static CYTHON_INLINE int __Pyx_c_is_zero(__pyx_t_double_complex a) {
return (a.real == 0) && (a.imag == 0);
}
static CYTHON_INLINE __pyx_t_double_complex __Pyx_c_conj(__pyx_t_double_complex a) {
__pyx_t_double_complex z;
z.real = a.real;
z.imag = -a.imag;
return z;
}
/*
static CYTHON_INLINE double __Pyx_c_abs(__pyx_t_double_complex z) {
#if HAVE_HYPOT
return hypot(z.real, z.imag);
#else
return sqrt(z.real*z.real + z.imag*z.imag);
#endif
}
*/
#endif
/* Cython code section 'end' */
};
[assembly: PythonModule("scipy__integrate__vode", module_vode::typeid)];
};
| 49.16972 | 609 | 0.682804 | jasonmccampbell |
38a853c44610e67fd150d156764179bd78e6e502 | 5,874 | cpp | C++ | UMLEditor/UMLLabelPropertyDialog.cpp | pmachapman/Tulip | 54f7bc3e8d5bb452ed8de6e6622e23d5e9be650a | [
"Unlicense"
] | null | null | null | UMLEditor/UMLLabelPropertyDialog.cpp | pmachapman/Tulip | 54f7bc3e8d5bb452ed8de6e6622e23d5e9be650a | [
"Unlicense"
] | 33 | 2018-09-14T21:58:20.000Z | 2022-01-12T21:39:22.000Z | UMLEditor/UMLLabelPropertyDialog.cpp | pmachapman/Tulip | 54f7bc3e8d5bb452ed8de6e6622e23d5e9be650a | [
"Unlicense"
] | null | null | null | /* ==========================================================================
Class : CUMLLabelPropertyDialog
Author : Johan Rosengren, Abstrakt Mekanik AB
Date : 2004-04-29
Purpose : "CUMLLabelPropertyDialog" is a dialog box wrapper derived
from "CDiagramPropertyDlg", used by "CUMLEntity"-
derived objects to edit the object title attribute.
Description : Class-Wizard created class.
Usage : In the "CUMLEntity"-derived class, add a member of
the "CUMLLabelPropertyDialog"-derived class, and call
"SetPropertyDialog" in the constructor.
The dialog template with the resource id
"IDD_UML_DIALOG_PROPERTY_LABEL" must be added to the project.
========================================================================*/
#include "stdafx.h"
#include "UMLLabelPropertyDialog.h"
#include "UMLEntityLabel.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUMLLabelPropertyDialog dialog
CUMLLabelPropertyDialog::CUMLLabelPropertyDialog(CWnd* pParent /*=NULL*/)
: CDiagramPropertyDlg(CUMLLabelPropertyDialog::IDD, pParent)
/* ============================================================
Function : CUMLLabelPropertyDialog::CUMLLabelPropertyDialog
Description : Constructor
Access : Public
Return : void
Parameters : CWnd* pParent - Dialog parent
Usage :
============================================================*/
{
//{{AFX_DATA_INIT(CUMLLabelPropertyDialog)
m_text = _T("");
//}}AFX_DATA_INIT
m_pointsize = 12;
m_bold = FALSE;
m_italic = FALSE;
m_underline = FALSE;
}
CUMLLabelPropertyDialog::~CUMLLabelPropertyDialog()
/* ============================================================
Function : CUMLLabelPropertyDialog::~CUMLLabelPropertyDialog
Description : Destructor
Access : Public
Return : void
Parameters : none
Usage :
============================================================*/
{
}
void CUMLLabelPropertyDialog::DoDataExchange(CDataExchange* pDX)
/* ============================================================
Function : CUMLLabelPropertyDialog::DoDataExchange
Description : MFC data exchange handler.
Access : Protected
Return : void
Parameters : CDataExchange* pDX - Pointer to exchange object
Usage : Called from MFC to exchange and validate
dialog data.
============================================================*/
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUMLLabelPropertyDialog)
DDX_Text(pDX, IDC_EDIT_TEXT, m_text);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUMLLabelPropertyDialog, CDialog)
//{{AFX_MSG_MAP(CUMLLabelPropertyDialog)
ON_BN_CLICKED(IDC_BUTTON_FONT, OnButtonFont)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUMLLabelPropertyDialog message handlers
void CUMLLabelPropertyDialog::OnOK()
/* ============================================================
Function : CUMLLabelPropertyDialog::OnOK
Description : Called when the Apply-key is pressed.
Access : Protected
Return : void
Parameters : none
Usage : Called from MFC. Updates the attached object
and hides the modeless dialog.
============================================================*/
{
CUMLEntityLabel* uml = static_cast<CUMLEntityLabel*>(GetEntity());
UpdateData();
uml->SetTitle(m_text);
uml->SetFont(m_font);
uml->SetBold(m_bold);
uml->SetItalic(m_italic);
uml->SetUnderline(m_underline);
uml->SetPointsize(m_pointsize);
Redraw();
ShowWindow(SW_HIDE);
GetRedrawWnd()->SetFocus();
}
void CUMLLabelPropertyDialog::OnCancel()
/* ============================================================
Function : CUMLLabelPropertyDialog::OnCancel
Description : Called when the ESC-key is pressed.
Access : Protected
Return : void
Parameters : none
Usage : Called from MFC. Overridden to close the
dialog.
============================================================*/
{
CDialog::OnCancel();
GetRedrawWnd()->SetFocus();
}
/////////////////////////////////////////////////////////////////////////////
// CUMLLabelPropertyDialog overrides
void CUMLLabelPropertyDialog::SetValues()
/* ============================================================
Function : CUMLLabelPropertyDialog::SetValues
Description : Set the values in the dialog from the
attached object.
Access : Public
Return : void
Parameters : none
Usage : Will be called by the framework and the
attached object to initialize the dialog.
The editbox is filled with the contents of
the object title attribute.
============================================================*/
{
CUMLEntityLabel* uml = static_cast<CUMLEntityLabel*>(GetEntity());
m_text = uml->GetTitle();
m_font = uml->GetFont();
m_pointsize = uml->GetPointsize();
m_bold = uml->GetBold();
m_italic = uml->GetItalic();
m_underline = uml->GetUnderline();
}
void CUMLLabelPropertyDialog::OnButtonFont()
/* ============================================================
Function : CUMLLabelPropertyDialog::OnButtonFont
Description : Handler for the dialog button Font
Access : Protected
Return : void
Parameters : none
Usage : Called from MFC.
============================================================*/
{
CFont font;
CUMLEntityLabel* uml = static_cast<CUMLEntityLabel*>(GetEntity());
font.CreatePointFont(m_pointsize * 10, uml->GetFont());
LOGFONT lf;
font.GetLogFont(&lf);
lf.lfItalic = (BYTE)m_italic;
lf.lfUnderline = (BYTE)m_underline;
if (m_bold)
lf.lfWeight = FW_BOLD;
CFontDialog dlg(&lf);
if (dlg.DoModal() == IDOK)
{
m_font = dlg.GetFaceName();
m_pointsize = dlg.GetSize() / 10;
m_bold = dlg.IsBold();
m_italic = dlg.IsItalic();
m_underline = dlg.IsUnderline();
}
}
| 25.876652 | 77 | 0.575928 | pmachapman |
38a8ad7e461ed75b069b6376bc81bb481bf24999 | 7,774 | cpp | C++ | ros/niryo_one_ros/niryo_one_driver/src/hw_driver/xl320_driver.cpp | paubrunet97/astrocytes | c21bbd2473adf68ef076356bcf578fb2ae14031f | [
"MIT"
] | 5 | 2020-11-06T18:35:57.000Z | 2021-04-30T07:16:42.000Z | ros/niryo_one_ros/niryo_one_driver/src/hw_driver/xl320_driver.cpp | paubrunet97/astrocytes | c21bbd2473adf68ef076356bcf578fb2ae14031f | [
"MIT"
] | 5 | 2020-11-05T13:39:28.000Z | 2021-12-09T04:37:30.000Z | ros/niryo_one_ros/niryo_one_driver/src/hw_driver/xl320_driver.cpp | paubrunet97/astrocytes | c21bbd2473adf68ef076356bcf578fb2ae14031f | [
"MIT"
] | 8 | 2020-09-25T10:07:15.000Z | 2022-03-11T06:26:30.000Z | /*
xl320_driver.cpp
Copyright (C) 2018 Niryo
All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "niryo_one_driver/xl320_driver.h"
XL320Driver::XL320Driver(dynamixel::PortHandler* portHandler,
dynamixel::PacketHandler* packetHandler) : DxlDriver(portHandler, packetHandler)
{
}
int XL320Driver::checkModelNumber(uint8_t id)
{
uint16_t model_number;
int ping_result = getModelNumber(id, &model_number);
if (ping_result == COMM_SUCCESS) {
if (model_number && model_number != XL320_MODEL_NUMBER) {
return PING_WRONG_MODEL_NUMBER;
}
}
return ping_result;
}
/*
* ----------------- WRITE --------------------
*/
int XL320Driver::changeId(uint8_t id, uint8_t new_id)
{
return packetHandler->write1ByteTxOnly(portHandler, id, XL320_ADDR_ID, new_id);
}
int XL320Driver::changeBaudRate(uint8_t id, uint32_t new_baudrate)
{
return packetHandler->write1ByteTxOnly(portHandler, id, XL320_ADDR_BAUDRATE, (uint8_t)new_baudrate);
}
int XL320Driver::setLed(uint8_t id, uint32_t led_value)
{
return packetHandler->write1ByteTxOnly(portHandler, id, XL320_ADDR_LED, (uint8_t)led_value);
}
int XL320Driver::setTorqueEnable(uint8_t id, uint32_t torque_enable)
{
return packetHandler->write1ByteTxOnly(portHandler, id, XL320_ADDR_TORQUE_ENABLE, (uint8_t)torque_enable);
}
int XL320Driver::setGoalPosition(uint8_t id, uint32_t position)
{
return packetHandler->write2ByteTxOnly(portHandler, id, XL320_ADDR_GOAL_POSITION, (uint16_t)position);
}
int XL320Driver::setGoalVelocity(uint8_t id, uint32_t velocity)
{
return packetHandler->write2ByteTxOnly(portHandler, id, XL320_ADDR_GOAL_SPEED, (uint16_t)velocity);
}
int XL320Driver::setGoalTorque(uint8_t id, uint32_t torque)
{
return packetHandler->write2ByteTxOnly(portHandler, id, XL320_ADDR_GOAL_TORQUE, (uint16_t)torque);
}
int XL320Driver::setReturnDelayTime(uint8_t id, uint32_t return_delay_time)
{
return packetHandler->write1ByteTxOnly(portHandler, id, XL320_ADDR_RETURN_DELAY_TIME, (uint8_t)return_delay_time);
}
int XL320Driver::setLimitTemperature(uint8_t id, uint32_t temperature)
{
return packetHandler->write1ByteTxOnly(portHandler, id, XL320_ADDR_LIMIT_TEMPERATURE, (uint8_t)temperature);
}
int XL320Driver::setMaxTorque(uint8_t id, uint32_t torque)
{
return packetHandler->write1ByteTxOnly(portHandler, id, XL320_ADDR_MAX_TORQUE, (uint8_t)torque);
}
int XL320Driver::setReturnLevel(uint8_t id, uint32_t return_level)
{
return packetHandler->write1ByteTxOnly(portHandler, id, XL320_ADDR_RETURN_LEVEL, (uint8_t)return_level);
}
int XL320Driver::setAlarmShutdown(uint8_t id, uint32_t alarm_shutdown)
{
return packetHandler->write1ByteTxOnly(portHandler, id, XL320_ADDR_ALARM_SHUTDOWN, (uint8_t)alarm_shutdown);
}
int XL320Driver::customWrite(uint8_t id, uint32_t value, uint8_t reg_address, uint8_t byte_number)
{
if (byte_number == 1) {
return packetHandler->write1ByteTxOnly(portHandler, id, reg_address, (uint8_t) value);
}
else if (byte_number == 2) {
return packetHandler->write2ByteTxOnly(portHandler, id, reg_address, (uint16_t) value);
}
else {
return -1;
}
}
/*
* ----------------- SYNC WRITE --------------------
*/
int XL320Driver::syncWritePositionGoal(std::vector<uint8_t> &id_list, std::vector<uint32_t> &position_list)
{
return syncWrite2Bytes(XL320_ADDR_GOAL_POSITION, id_list, position_list);
}
int XL320Driver::syncWriteVelocityGoal(std::vector<uint8_t> &id_list, std::vector<uint32_t> &velocity_list)
{
return syncWrite2Bytes(XL320_ADDR_GOAL_SPEED, id_list, velocity_list);
}
int XL320Driver::syncWriteTorqueGoal(std::vector<uint8_t> &id_list, std::vector<uint32_t> &torque_list)
{
return syncWrite2Bytes(XL320_ADDR_GOAL_TORQUE, id_list, torque_list);
}
int XL320Driver::syncWriteTorqueEnable(std::vector<uint8_t> &id_list, std::vector<uint32_t> &torque_enable_list)
{
return syncWrite1Byte(XL320_ADDR_TORQUE_ENABLE, id_list, torque_enable_list);
}
int XL320Driver::syncWriteLed(std::vector<uint8_t> &id_list, std::vector<uint32_t> &led_list)
{
return syncWrite1Byte(XL320_ADDR_LED, id_list, led_list);
}
/*
* ----------------- READ --------------------
*/
int XL320Driver::readPosition(uint8_t id, uint32_t *present_position)
{
return read2Bytes(XL320_ADDR_PRESENT_POSITION, id, present_position);
}
int XL320Driver::readVelocity(uint8_t id, uint32_t *present_velocity)
{
return read2Bytes(XL320_ADDR_PRESENT_SPEED, id, present_velocity);
}
int XL320Driver::readLoad(uint8_t id, uint32_t *present_load)
{
return read2Bytes(XL320_ADDR_PRESENT_LOAD, id, present_load);
}
int XL320Driver::readTemperature(uint8_t id, uint32_t *temperature)
{
return read1Byte(XL320_ADDR_PRESENT_TEMPERATURE, id, temperature);
}
int XL320Driver::readVoltage(uint8_t id, uint32_t *voltage)
{
return read1Byte(XL320_ADDR_PRESENT_VOLTAGE, id, voltage);
}
int XL320Driver::readHardwareStatus(uint8_t id, uint32_t *hardware_status)
{
return read1Byte(XL320_ADDR_HW_ERROR_STATUS, id, hardware_status);
}
int XL320Driver::readReturnDelayTime(uint8_t id, uint32_t *return_delay_time)
{
return read1Byte(XL320_ADDR_RETURN_DELAY_TIME, id, return_delay_time);
}
int XL320Driver::readLimitTemperature(uint8_t id, uint32_t *limit_temperature)
{
return read1Byte(XL320_ADDR_LIMIT_TEMPERATURE, id, limit_temperature);
}
int XL320Driver::readMaxTorque(uint8_t id, uint32_t *max_torque)
{
return read2Bytes(XL320_ADDR_MAX_TORQUE, id, max_torque);
}
int XL320Driver::readReturnLevel(uint8_t id, uint32_t *return_level)
{
return read1Byte(XL320_ADDR_RETURN_LEVEL, id, return_level);
}
int XL320Driver::readAlarmShutdown(uint8_t id, uint32_t *alarm_shutdown)
{
return read1Byte(XL320_ADDR_ALARM_SHUTDOWN, id, alarm_shutdown);
}
/*
* ----------------- SYNC READ --------------------
*/
int XL320Driver::syncReadPosition(std::vector<uint8_t> &id_list, std::vector<uint32_t> &position_list)
{
return syncRead(XL320_ADDR_PRESENT_POSITION, DXL_LEN_TWO_BYTES, id_list, position_list);
}
int XL320Driver::syncReadVelocity(std::vector<uint8_t> &id_list, std::vector<uint32_t> &velocity_list)
{
return syncRead(XL320_ADDR_PRESENT_SPEED, DXL_LEN_TWO_BYTES, id_list, velocity_list);
}
int XL320Driver::syncReadLoad(std::vector<uint8_t> &id_list, std::vector<uint32_t> &load_list)
{
return syncRead(XL320_ADDR_PRESENT_LOAD, DXL_LEN_TWO_BYTES, id_list, load_list);
}
int XL320Driver::syncReadTemperature(std::vector<uint8_t> &id_list, std::vector<uint32_t> &temperature_list)
{
return syncRead(XL320_ADDR_PRESENT_TEMPERATURE, DXL_LEN_ONE_BYTE, id_list, temperature_list);
}
int XL320Driver::syncReadVoltage(std::vector<uint8_t> &id_list, std::vector<uint32_t> &voltage_list)
{
return syncRead(XL320_ADDR_PRESENT_VOLTAGE, DXL_LEN_ONE_BYTE, id_list, voltage_list);
}
int XL320Driver::syncReadHwErrorStatus(std::vector<uint8_t> &id_list, std::vector<uint32_t> &hw_error_list)
{
return syncRead(XL320_ADDR_HW_ERROR_STATUS, DXL_LEN_ONE_BYTE, id_list, hw_error_list);
}
| 32.391667 | 118 | 0.753666 | paubrunet97 |
38ac73dd3ed36c09dc156a9ec41b9e4f5dfbbe91 | 1,220 | hpp | C++ | quick-shuffle-gpu/include/partial_hat.hpp | slaymaker1907/quick-shuffle | c26697c5899b225b2a94f9987fe3ce1a5b731f8e | [
"MIT"
] | null | null | null | quick-shuffle-gpu/include/partial_hat.hpp | slaymaker1907/quick-shuffle | c26697c5899b225b2a94f9987fe3ce1a5b731f8e | [
"MIT"
] | 1 | 2019-05-07T02:11:23.000Z | 2019-05-07T02:11:23.000Z | quick-shuffle-gpu/include/partial_hat.hpp | slaymaker1907/quick-shuffle | c26697c5899b225b2a94f9987fe3ce1a5b731f8e | [
"MIT"
] | null | null | null | #ifndef PARTIAL_HAT
#define PARTIAL_HAT
// TODO: finish this thing.
#include <cmath>
#include <assert.h>
namespace cuda_permute
{
// This class is an array of arrays which is initially statically allocated.
// The advantage is that it can be deallocated as you iterate through it with a max overhead of sqrt(size).
// write for float, then change to T.
// template <class T>
class PartialHAT {
private:
int **data_columns;
size_t column_size;
size_t total_size;
public:
// size should be > 0.
PartialHAT(size_t total_input_size) {
total_size = total_input_size;
double dbsqrt = sqrt((double)total_size); // probably good enough and faster on a GPU.
column_size = (size_t)ceil(dbsqrt);
size_t column_byte_size = column_size * sizeof(int);
size_t needed_columns = div_ceil(total_size, column_size);
// first allocate array of arrays.
data_columns = (int**)malloc(needed_columns * sizeof(int*));
assert(data_columns);
// now allocate each column.
for (int i = 0; i < needed_columns; i++) {
data_columns[i] = (int*)malloc(column_byte_size);
assert(data_columns[i]);
}
}
};
}
#endif | 28.372093 | 107 | 0.663115 | slaymaker1907 |
38ae74da347f11b80271ea334f54fc7154389660 | 8,679 | cpp | C++ | swallow/src/semantics/OperatorResolver.cpp | healerkx/swallow | c2a0c0355462d856008af04d941f9390ae220f20 | [
"BSD-3-Clause"
] | null | null | null | swallow/src/semantics/OperatorResolver.cpp | healerkx/swallow | c2a0c0355462d856008af04d941f9390ae220f20 | [
"BSD-3-Clause"
] | null | null | null | swallow/src/semantics/OperatorResolver.cpp | healerkx/swallow | c2a0c0355462d856008af04d941f9390ae220f20 | [
"BSD-3-Clause"
] | null | null | null | /* OperatorResolver.cpp --
*
* Copyright (c) 2014, Lex Chou <lex at chou dot it>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Swallow nor the names of its contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "semantics/OperatorResolver.h"
#include <cassert>
#include "ast/ast.h"
#include "common/CompilerResults.h"
#include "semantics/SymbolRegistry.h"
#include "common/Errors.h"
#include "semantics/ScopedNodes.h"
USE_SWALLOW_NS
using namespace std;
OperatorResolver::OperatorResolver(SymbolRegistry* symbolRegistry, CompilerResults* compilerResults)
:SemanticPass(symbolRegistry, compilerResults)
{
}
/*!
* Rotate the AST tree if required
*/
bool OperatorResolver::rotateRequired(const OperatorPtr& lhs, const OperatorPtr& rhs)
{
BinaryOperatorPtr left = dynamic_pointer_cast<BinaryOperator>(lhs);
BinaryOperatorPtr right = dynamic_pointer_cast<BinaryOperator>(rhs);
if(!left || !right)
return false;
OperatorInfo* leftOp = symbolRegistry->getOperator(left->getOperator(), OperatorType::InfixBinary);
OperatorInfo* rightOp = symbolRegistry->getOperator(right->getOperator(), OperatorType::InfixBinary);
if(!leftOp || !rightOp)
return false;
if(leftOp->precedence.infix == rightOp->precedence.infix)
{
//only right associativity is required because it's left associativity
return leftOp->associativity == Associativity::Right;
}
return leftOp->precedence.infix < rightOp->precedence.infix;
}
/*!
* Sort the AST tree by precedence, if the precedence is the same, sort by associativity
*/
OperatorPtr OperatorResolver::sortExpression(const OperatorPtr& op)
{
OperatorPtr root = op;
OperatorPtr c;
if(op->numChildren() != 2)
return op;
NodePtr left = op->get(0);
NodePtr right = op->get(1);
if(left && (c = std::dynamic_pointer_cast<Operator>(left)) && c->numChildren() == 2)
{
left = c = sortExpression(c);
if(rotateRequired(c, root))
{
//make c the root
NodePtr r = c->get(1);
c->set(1, root);
root->set(0, r);
root = c;
//sort new right child
NodePtr r2 = sortExpression(std::static_pointer_cast<Operator>(c->get(1)));
c->set(1, r2);
return root;
}
}
//sort old right child
c = std::dynamic_pointer_cast<Operator>(right);
if(c != NULL)
sortExpression(c);
return root;
}
void OperatorResolver::visitOperator(const OperatorDefPtr& node)
{
NodePtr parentNode = node->getParentNode();
if(!parentNode || parentNode->getNodeType() != NodeType::Program)
{
error(node, Errors::E_A_MAY_ONLY_BE_DECLARED_AT_FILE_SCOPE_1, L"operator");
abort();
return;
}
//register operator
if(node->getType() == OperatorType::InfixBinary)
{
//check precedence range
if(node->getPrecedence() < 0 || node->getPrecedence() > 255)
{
error(node, Errors::E_OPERATOR_PRECEDENCE_OUT_OF_RANGE);
abort();
}
}
bool r = symbolRegistry->registerOperator(node->getName(), node->getType(), node->getAssociativity(), node->getPrecedence(), node->isAssignment());
if(!r)
{
error(node, Errors::E_OPERATOR_REDECLARED);
abort();
}
}
void OperatorResolver::visitAssignment(const AssignmentPtr& node)
{
visitBinaryOperator(node);
}
void OperatorResolver::visitComputedProperty(const ComputedPropertyPtr& node)
{
node->setInitializer(transform<Expression>(node->getInitializer()));
if(node->getGetter())
node->getGetter()->accept(this);
if(node->getSetter())
node->getSetter()->accept(this);
if(node->getWillSet())
node->getWillSet()->accept(this);
if(node->getDidSet())
node->getDidSet()->accept(this);
}
void OperatorResolver::visitProtocol(const ProtocolDefPtr& node)
{
//ignore everything under protocol
}
void OperatorResolver::visitClosure(const ClosurePtr& node)
{
for(auto& st : *node)
{
st = transform<Statement>(st);
}
}
void OperatorResolver::visitProgram(const ProgramPtr& node)
{
ScopedProgramPtr program = static_pointer_cast<ScopedProgram>(node);
symbolRegistry->setFileScope(program->getScope());
for(auto& st : *node)
{
st = transform<Statement>(st);
}
}
void OperatorResolver::visitCodeBlock(const CodeBlockPtr& node)
{
for(auto& st : *node)
{
st = transform<Statement>(st);
}
}
void OperatorResolver::visitValueBinding(const ValueBindingPtr& node)
{
node->setInitializer(transform<Expression>(node->getInitializer()));
}
void OperatorResolver::visitStringInterpolation(const StringInterpolationPtr& node)
{
for(auto& expr : *node)
{
expr = transform<Expression>(expr);
}
}
void OperatorResolver::visitConditionalOperator(const ConditionalOperatorPtr& node)
{
node->setCondition(transform<Pattern>(node->getCondition()));
node->setTrueExpression(transform<Expression>(node->getTrueExpression()));
node->setFalseExpression(transform<Expression>(node->getFalseExpression()));
}
void OperatorResolver::visitBinaryOperator(const BinaryOperatorPtr& node)
{
node->setRHS(transform<Pattern>(node->getRHS()));
node->setLHS(transform<Pattern>(node->getLHS()));
}
void OperatorResolver::visitUnaryOperator(const UnaryOperatorPtr& node)
{
node->setOperand(transform<Expression>(node->getOperand()));
}
void OperatorResolver::visitTuple(const TuplePtr& node)
{
for(PatternPtr& p : *node)
{
p = transform<Pattern>(p);
}
}
void OperatorResolver::visitReturn(const ReturnStatementPtr& node)
{
node->setExpression(transform<Expression>(node->getExpression()));
}
void OperatorResolver::visitParenthesizedExpression(const ParenthesizedExpressionPtr& node)
{
for(auto& p : *node)
{
p.expression = transform<Expression>(p.expression);
}
}
void OperatorResolver::visitArrayLiteral(const ArrayLiteralPtr& node)
{
for(auto& p : *node)
{
p = transform<Expression>(p);
}
}
void OperatorResolver::visitDictionaryLiteral(const DictionaryLiteralPtr& node)
{
for(auto& el : *node)
{
el.first = transform<Expression>(el.first);
el.second = transform<Expression>(el.second);
}
}
void OperatorResolver::visitForcedValue(const ForcedValuePtr& node)
{
node->setExpression(transform<Expression>(node->getExpression()));
}
void OperatorResolver::visitOptionalChaining(const OptionalChainingPtr& node)
{
node->setExpression(transform<Expression>(node->getExpression()));
}
void OperatorResolver::visitIf(const IfStatementPtr& node)
{
node->setCondition(transform<Expression>(node->getCondition()));
node->getThen()->accept(this);
if(node->getElse())
node->getElse()->accept(this);
}
void OperatorResolver::visitSwitchCase(const SwitchCasePtr& node)
{
node->setControlExpression(transform<Expression>(node->getControlExpression()));
for(auto c : *node)
{
c->accept(this);
}
if(node->getDefaultCase())
node->getDefaultCase()->accept(this);
}
void OperatorResolver::visitCase(const CaseStatementPtr& node)
{
node->getCodeBlock()->accept(this);
}
| 32.144444 | 151 | 0.694089 | healerkx |
38b15af35e0065b54f6aff46387b3f8517738848 | 3,317 | cpp | C++ | lib/src/sai_redis_port.cpp | qiluo-msft/sonic-sairedis | 2059e4580d04dab68b5e15241c366fac9b3eaf30 | [
"Apache-2.0"
] | null | null | null | lib/src/sai_redis_port.cpp | qiluo-msft/sonic-sairedis | 2059e4580d04dab68b5e15241c366fac9b3eaf30 | [
"Apache-2.0"
] | null | null | null | lib/src/sai_redis_port.cpp | qiluo-msft/sonic-sairedis | 2059e4580d04dab68b5e15241c366fac9b3eaf30 | [
"Apache-2.0"
] | null | null | null | #include "sai_redis.h"
/**
* Routine Description:
* @brief Set port attribute value.
*
* Arguments:
* @param[in] port_id - port id
* @param[in] attr - attribute
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_set_port_attribute(
_In_ sai_object_id_t port_id,
_In_ const sai_attribute_t *attr)
{
std::lock_guard<std::mutex> lock(g_apimutex);
SWSS_LOG_ENTER();
return meta_sai_set_oid(
SAI_OBJECT_TYPE_PORT,
port_id,
attr,
&redis_generic_set);
}
/**
* Routine Description:
* @brief Get port attribute value.
*
* Arguments:
* @param[in] port_id - port id
* @param[in] attr_count - number of attributes
* @param[inout] attr_list - array of attributes
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_get_port_attribute(
_In_ sai_object_id_t port_id,
_In_ uint32_t attr_count,
_Inout_ sai_attribute_t *attr_list)
{
std::lock_guard<std::mutex> lock(g_apimutex);
SWSS_LOG_ENTER();
return meta_sai_get_oid(
SAI_OBJECT_TYPE_PORT,
port_id,
attr_count,
attr_list,
&redis_generic_get);
}
/**
* Routine Description:
* @brief Get port statistics counters.
*
* Arguments:
* @param[in] port_id - port id
* @param[in] counter_ids - specifies the array of counter ids
* @param[in] number_of_counters - number of counters in the array
* @param[out] counters - array of resulting counter values.
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_get_port_stats(
_In_ sai_object_id_t port_id,
_In_ const sai_port_stat_counter_t *counter_ids,
_In_ uint32_t number_of_counters,
_Out_ uint64_t* counters)
{
SWSS_LOG_ENTER();
return SAI_STATUS_NOT_IMPLEMENTED;
}
/**
* Routine Description:
* @brief Clear port statistics counters.
*
* Arguments:
* @param[in] port_id - port id
* @param[in] counter_ids - specifies the array of counter ids
* @param[in] number_of_counters - number of counters in the array
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_clear_port_stats(
_In_ sai_object_id_t port_id,
_In_ const sai_port_stat_counter_t *counter_ids,
_In_ uint32_t number_of_counters)
{
SWSS_LOG_ENTER();
return SAI_STATUS_NOT_IMPLEMENTED;
}
/**
* Routine Description:
* @brief Clear port's all statistics counters.
*
* Arguments:
* @param[in] port_id - port id
*
* Return Values:
* @return SAI_STATUS_SUCCESS on success
* Failure status code on error
*/
sai_status_t redis_clear_port_all_stats(
_In_ sai_object_id_t port_id)
{
SWSS_LOG_ENTER();
return SAI_STATUS_NOT_IMPLEMENTED;
}
/**
* @brief Port methods table retrieved with sai_api_query()
*/
const sai_port_api_t redis_port_api = {
redis_set_port_attribute,
redis_get_port_attribute,
redis_get_port_stats,
redis_clear_port_stats,
redis_clear_port_all_stats,
};
| 24.211679 | 69 | 0.669279 | qiluo-msft |
38b2d9be5f12e42bd1ad20e6df8165438fe6068b | 1,308 | hpp | C++ | Source/Gui/DictionaryPanel.hpp | alvinahmadov/Dixter | 6f98f1e84192e1e43eee409bdee6b3dac75d6443 | [
"MIT"
] | 4 | 2018-12-06T01:20:50.000Z | 2019-08-04T10:19:23.000Z | Source/Gui/DictionaryPanel.hpp | alvinahmadov/Dixter | 6f98f1e84192e1e43eee409bdee6b3dac75d6443 | [
"MIT"
] | null | null | null | Source/Gui/DictionaryPanel.hpp | alvinahmadov/Dixter | 6f98f1e84192e1e43eee409bdee6b3dac75d6443 | [
"MIT"
] | null | null | null | /**
* Copyright (C) 2015-2019
* Author Alvin Ahmadov <alvin.dev.ahmadov@gmail.com>
*
* This file is part of Dixter Project
* License-Identifier: MIT License
* See README.md for more information.
*/
#pragma once
#include "Gui/Panel.hpp"
#include "Gui/OptionBox.hpp"
class QMutex;
namespace Dixter
{
enum class EWidgetID;
template<
typename T,
typename ID
>
class TGroup;
namespace Gui
{
class TDictionaryPanel : public APanel
{
Q_OBJECT
private:
using WidgetGroup = TGroup<QWidget, EWidgetID>;
using GridGroup = TGroup<QLayout, EWidgetID>;
public:
explicit TDictionaryPanel(QWidget* parent, int width = -1, int height = -1,
const QString& name = QString());
virtual ~TDictionaryPanel() override;
void show(bool show = true);
TOptionBoxPtr
getOptionBox(EWidgetID widgetID);
QWidget* getWidget(EWidgetID id);
protected:
void init() override;
void connectEvents() override;
void setValues();
void onCopyButton(void);
void onClearButton(void);
void onLanguageChange(void);
protected slots:
void onSearch() noexcept;
private:
bool m_isLanguageSet;
GridGroup* m_grids;
WidgetGroup* m_widgets;
};
} // namespace Gui
} // namespace Dixter | 17.917808 | 78 | 0.66208 | alvinahmadov |
38b3726773f8ecbccf841798e0925e4d1a1dc220 | 519 | hpp | C++ | include/Micron/Prim.hpp | khuldraeseth/micron | e3f55c69a5546c4bba2b306775b8271880677640 | [
"Unlicense"
] | null | null | null | include/Micron/Prim.hpp | khuldraeseth/micron | e3f55c69a5546c4bba2b306775b8271880677640 | [
"Unlicense"
] | null | null | null | include/Micron/Prim.hpp | khuldraeseth/micron | e3f55c69a5546c4bba2b306775b8271880677640 | [
"Unlicense"
] | null | null | null | #pragma once
#include <functional>
#include <utility>
#include <Data/Either.hpp>
#include <Data/String.hpp>
#include <Micron/Error.hpp>
template <typename A>
struct Micron {
using Fn = std::function<std::pair<String,Either<Error,A>>(String)>;
Fn fn {};
};
auto const runMicron = [](auto ma, auto s) {
return ma.fn(s).second;
};
template <typename T> struct UnMicron {};
template <typename T> struct UnMicron<Micron<T>> { using type = T; };
template <typename T> using UnMicronT = UnMicron<T>::type;
| 19.961538 | 72 | 0.680154 | khuldraeseth |
38b50436d583b77eeeb9a231a88dfe198eee4330 | 960 | cpp | C++ | console/src/boost_1_78_0/libs/integer/test/integer_include_test.cpp | vany152/FilesHash | 39f282807b7f1abc56dac389e8259ee3bb557a8d | [
"MIT"
] | 106 | 2015-08-07T04:23:50.000Z | 2020-12-27T18:25:15.000Z | console/src/boost_1_78_0/libs/integer/test/integer_include_test.cpp | vany152/FilesHash | 39f282807b7f1abc56dac389e8259ee3bb557a8d | [
"MIT"
] | 130 | 2016-06-22T22:11:25.000Z | 2020-11-29T20:24:09.000Z | Libs/boost_1_76_0/libs/integer/test/integer_include_test.cpp | Antd23rus/S2DE | 47cc7151c2934cd8f0399a9856c1e54894571553 | [
"MIT"
] | 41 | 2015-07-08T19:18:35.000Z | 2021-01-14T16:39:56.000Z | // Copyright John Maddock 2009.
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
#include <boost/integer.hpp> // must be the only #include!
int main()
{
boost::int_fast_t<char>::fast f = 0;
(void)f;
boost::int_t<16>::fast f2 = 0;
(void)f2;
boost::int_t<32>::exact e = 0;
(void)e;
boost::int_t<12>::least l = 0;
(void)l;
boost::uint_t<16>::fast uf2 = 0;
(void)uf2;
boost::uint_t<32>::exact ue = 0;
(void)ue;
boost::uint_t<12>::least ul = 0;
(void)ul;
boost::int_max_value_t<200>::fast v1 = 0;
(void)v1;
boost::int_max_value_t<2000>::least v2 = 0;
(void)v2;
boost::int_min_value_t<-200>::fast v3 = 0;
(void)v3;
boost::int_min_value_t<-2000>::least v4 = 0;
(void)v4;
boost::uint_value_t<200>::fast v5 = 0;
(void)v5;
boost::uint_value_t<2000>::least v6 = 0;
(void)v6;
}
| 25.945946 | 69 | 0.617708 | vany152 |
38b682f70b633abba3eba5436fe16bb46d62e197 | 2,473 | cpp | C++ | buildinfo.cpp | FrostDragon/JenkinsPlugin | a3179a188ef4b5d4bd57adec5a765d485faa7ac4 | [
"MIT"
] | 2 | 2020-06-25T21:58:45.000Z | 2021-01-07T11:20:37.000Z | buildinfo.cpp | FrostDragon/JenkinsPlugin | a3179a188ef4b5d4bd57adec5a765d485faa7ac4 | [
"MIT"
] | 4 | 2016-05-25T09:35:47.000Z | 2016-06-20T00:20:32.000Z | buildinfo.cpp | FrostDragon/JenkinsPlugin | a3179a188ef4b5d4bd57adec5a765d485faa7ac4 | [
"MIT"
] | 1 | 2020-06-25T20:49:38.000Z | 2020-06-25T20:49:38.000Z | #include "buildinfo.h"
#include "jenkinspluginconstants.h"
using namespace JenkinsCI::Internal;
QString BuildInfo::url() const { return _url; }
void BuildInfo::setUrl(const QString &url) { _url = url; }
int BuildInfo::number() const { return _number; }
void BuildInfo::setNumber(int number) { _number = number; }
QDateTime BuildInfo::timestamp() const { return _timestamp; }
void BuildInfo::setTimestamp(const QDateTime ×tamp) { _timestamp = timestamp; }
void BuildInfo::setTimestamp(const qint64 timestamp)
{
_timestamp = QDateTime::fromMSecsSinceEpoch(timestamp);
}
BuildInfo::Result BuildInfo::result() const { return _result; }
QString BuildInfo::getResultIcon() const
{
switch (_result)
{
case Result::Success:
return QLatin1String(JenkinsCI::Constants::SUCCESS_ICON);
case Result::Failure:
return QLatin1String(JenkinsCI::Constants::FAIL_ICON);
case Result::Unstable:
return QLatin1String(JenkinsCI::Constants::UNSTABLE_ICON);
case Result::NotBuilt:
case Result::Aborted:
case Result::Unknown:
return QLatin1String(JenkinsCI::Constants::NOT_BUILT_ICON);
}
return QLatin1String(JenkinsCI::Constants::NOT_BUILT_ICON);
}
void BuildInfo::setResult(const Result &result) { _result = result; }
void BuildInfo::setResult(const QString &result)
{
if (result == QStringLiteral("SUCCESS"))
_result = Result::Success;
else if (result == QStringLiteral("ABORTED"))
_result = Result::Aborted;
else if (result == QStringLiteral("FAILURE"))
_result = Result::Failure;
else if (result == QStringLiteral("NOT_BUILT"))
_result = Result::NotBuilt;
else if (result == QStringLiteral("UNSTABLE"))
_result = Result::Unstable;
else
_result = Result::Unknown;
}
QString BuildInfo::displayName() const { return _displayName; }
void BuildInfo::setDisplayName(const QString &displayName) { _displayName = displayName; }
QString BuildInfo::fullDisplayName() const { return _fullDisplayName; }
void BuildInfo::setFullDisplayName(const QString &fullDisplayName)
{
_fullDisplayName = fullDisplayName;
}
QString BuildInfo::description() const { return _description; }
void BuildInfo::setDescription(const QString &description) { _description = description; }
int BuildInfo::duration() const { return _duration; }
void BuildInfo::setDuration(int duration) { _duration = duration; }
| 30.9125 | 90 | 0.708856 | FrostDragon |
38b9048b9d15c7584d4a2209bada86d74b7c2e22 | 1,834 | cpp | C++ | src/checker.cpp | ammarfaizi2/ProxyScraper | 3a303f70d283833c96b3dd6c9b52c322865b946f | [
"MIT"
] | 3 | 2018-10-14T17:27:49.000Z | 2018-10-19T22:39:54.000Z | src/checker.cpp | cppid/ProxyScraper | 3a303f70d283833c96b3dd6c9b52c322865b946f | [
"MIT"
] | null | null | null | src/checker.cpp | cppid/ProxyScraper | 3a303f70d283833c96b3dd6c9b52c322865b946f | [
"MIT"
] | 1 | 2018-10-15T07:15:52.000Z | 2018-10-15T07:15:52.000Z |
#include <sys/file.h>
#include <sys/wait.h>
#include <unistd.h>
#include "lib/TeaCurl.h"
#include "lib/TeaPCRE.h"
int check(int argc, char *argv[]) {
int worker_limit = 5;
for (int i = 0; i < 2; ++i)
{
int pid = fork();
if (pid == 0) {
char *filename = (char*)malloc(64);
sprintf(argv[0], "checkerd_run --file=uncheck_%d.tmp --worker-limit=%d", i, worker_limit);
sprintf(filename, "uncheck_%d.tmp", i);
FILE *handle = fopen(filename, "r");
flock(fileno(handle), LOCK_SH);
char *buff = (char*)malloc(8);
char *ip = (char*)malloc(64);
char *port = (char*)malloc(32);
char *country = (char*)malloc(256);
int gotIp = 0;
int workers = 0;
while (!feof(handle)) {
size_t rbt = fread(buff, 1, sizeof(char), handle);
if (rbt) {
buff[1] = '\0';
if (buff[0] != '|' && (!gotIp)) {
strcat(ip, buff);
} else if (buff[0] == '|' && (!gotIp)) {
gotIp = 1;
} else if (buff[0] == '|' && gotIp) {
while(rbt) {
rbt = fread(buff, 1, sizeof(char), handle);
buff[1] = '\0';
if (buff[0] == '\n') break;
if (buff[0] == ' ') buff[0] = '_';
strcat(country, buff);
}
int chPid = fork();
workers++;
if (chPid == 0) {
sprintf(argv[0], "checker_worker --ip=%s --port=%s", ip, port);
printf("%s:%s %s\n", ip, port, country);
sleep(10);
exit(0);
}
if (workers == worker_limit)
{
wait(NULL);
workers = 0;
}
gotIp = 0;
delete ip;
delete port;
delete country;
ip = (char*)malloc(64);
port = (char*)malloc(32);
country = (char*)malloc(256);
} else {
strcat(port, buff);
}
}
}
flock(fileno(handle), LOCK_UN);
fclose(handle);
exit(0);
}
}
wait(NULL);
return 0;
}
| 21.833333 | 93 | 0.502181 | ammarfaizi2 |
38ba50287c2408a1e00f6095ad3194f217dd4ac7 | 1,054 | cpp | C++ | Project/ModuleRNG.cpp | albertllopart/GTi-Engine-Reborn | 87d3137866488075f534e50a9480180d1f6354c0 | [
"MIT"
] | 1 | 2020-03-19T18:07:32.000Z | 2020-03-19T18:07:32.000Z | Project/ModuleRNG.cpp | albertllopart/GTi-Engine-Reborn | 87d3137866488075f534e50a9480180d1f6354c0 | [
"MIT"
] | null | null | null | Project/ModuleRNG.cpp | albertllopart/GTi-Engine-Reborn | 87d3137866488075f534e50a9480180d1f6354c0 | [
"MIT"
] | null | null | null | #include "Globals.h"
#include "Application.h"
#include "ModuleRNG.h"
#include "parson/parson.h"
#include "Glew/include/glew.h"
#include <list>
ModuleRNG::ModuleRNG(Application* app, bool start_enabled) : Module(app, start_enabled)
{
name = "Rng";
}
// Destructor
ModuleRNG::~ModuleRNG()
{}
// Called before render is available
bool ModuleRNG::Init(JSON_Object* node)
{
LOG("Loading RNG");
App->imgui->AddConsoleLog("Loading RNG");
bool ret = true;
return ret;
}
bool ModuleRNG::Start()
{
pcg32_srandom_r(&seed, NULL, (intptr_t)&seed);
return true;
}
// Called before quitting
bool ModuleRNG::CleanUp()
{
LOG("Freeing RNG");
App->imgui->AddConsoleLog("Freeing RNG");
return true;
}
update_status ModuleRNG::Update(float dt)
{
return UPDATE_CONTINUE;
}
float ModuleRNG::RandomFloat()
{
return ldexp(pcg32_random_r(&floatseed), -32);
}
uint32_t ModuleRNG::RandomInt(int min, int max)
{
uint bound = max - min + 1;
return pcg32_boundedrand_r(&intbound, bound);
}
uint32_t ModuleRNG::Random32()
{
return pcg32_random_r(&seed);
}
| 15.969697 | 87 | 0.712524 | albertllopart |
38bb918fa0cb938621c85eec58f382526a362e95 | 5,794 | cc | C++ | chrome/browser/push_messaging/push_messaging_permission_context.cc | Wzzzx/chromium-crosswalk | 768dde8efa71169f1c1113ca6ef322f1e8c9e7de | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2 | 2019-01-28T08:09:58.000Z | 2021-11-15T15:32:10.000Z | chrome/browser/push_messaging/push_messaging_permission_context.cc | maidiHaitai/haitaibrowser | a232a56bcfb177913a14210e7733e0ea83a6b18d | [
"BSD-3-Clause"
] | null | null | null | chrome/browser/push_messaging/push_messaging_permission_context.cc | maidiHaitai/haitaibrowser | a232a56bcfb177913a14210e7733e0ea83a6b18d | [
"BSD-3-Clause"
] | 6 | 2020-09-23T08:56:12.000Z | 2021-11-18T03:40:49.000Z | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/push_messaging/push_messaging_permission_context.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/permissions/permission_manager.h"
#include "chrome/browser/permissions/permission_request_id.h"
#include "chrome/browser/permissions/permission_uma_util.h"
#include "chrome/browser/profiles/profile.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/permission_type.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/origin_util.h"
PushMessagingPermissionContext::PushMessagingPermissionContext(Profile* profile)
: PermissionContextBase(profile,
content::PermissionType::PUSH_MESSAGING,
CONTENT_SETTINGS_TYPE_PUSH_MESSAGING),
profile_(profile),
weak_factory_ui_thread_(this) {}
PushMessagingPermissionContext::~PushMessagingPermissionContext() {}
ContentSetting PushMessagingPermissionContext::GetPermissionStatus(
const GURL& requesting_origin,
const GURL& embedding_origin) const {
// It's possible for this to return CONTENT_SETTING_BLOCK in cases where
// HostContentSettingsMap::GetContentSetting returns CONTENT_SETTING_ALLOW.
// TODO(johnme): This is likely to break assumptions made elsewhere, so we
// should try to remove this quirk.
#if defined(ENABLE_NOTIFICATIONS)
if (requesting_origin != embedding_origin)
return CONTENT_SETTING_BLOCK;
ContentSetting push_content_setting =
PermissionContextBase::GetPermissionStatus(requesting_origin,
embedding_origin);
blink::mojom::PermissionStatus notifications_permission =
PermissionManager::Get(profile_)->GetPermissionStatus(
content::PermissionType::NOTIFICATIONS, requesting_origin,
embedding_origin);
if (notifications_permission == blink::mojom::PermissionStatus::DENIED ||
push_content_setting == CONTENT_SETTING_BLOCK) {
return CONTENT_SETTING_BLOCK;
}
if (notifications_permission == blink::mojom::PermissionStatus::ASK)
return CONTENT_SETTING_ASK;
DCHECK(push_content_setting == CONTENT_SETTING_ALLOW ||
push_content_setting == CONTENT_SETTING_ASK);
// If the notifications permission has already been granted,
// and the push permission isn't explicitly blocked, then grant
// allow permission.
return CONTENT_SETTING_ALLOW;
#else
return CONTENT_SETTING_BLOCK;
#endif
}
// Unlike other permissions, push is decided by the following algorithm
// - You need to request it from a top level domain
// - You need to have notification permission granted.
// - You need to not have push permission explicitly blocked.
// - If those 3 things are true it is granted without prompting.
// This is done to avoid double prompting for notifications and push.
void PushMessagingPermissionContext::DecidePermission(
content::WebContents* web_contents,
const PermissionRequestID& id,
const GURL& requesting_origin,
const GURL& embedding_origin,
const BrowserPermissionCallback& callback) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
#if defined(ENABLE_NOTIFICATIONS)
if (requesting_origin != embedding_origin) {
NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
false /* persist */, CONTENT_SETTING_BLOCK);
return;
}
PermissionManager::Get(profile_)->RequestPermission(
content::PermissionType::NOTIFICATIONS, web_contents->GetMainFrame(),
requesting_origin,
base::Bind(&PushMessagingPermissionContext::DecidePushPermission,
weak_factory_ui_thread_.GetWeakPtr(), id, requesting_origin,
embedding_origin, callback));
#else
NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
false /* persist */, CONTENT_SETTING_BLOCK);
#endif
}
bool PushMessagingPermissionContext::IsRestrictedToSecureOrigins() const {
return true;
}
void PushMessagingPermissionContext::DecidePushPermission(
const PermissionRequestID& id,
const GURL& requesting_origin,
const GURL& embedding_origin,
const BrowserPermissionCallback& callback,
blink::mojom::PermissionStatus notification_status) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
ContentSetting push_content_setting =
HostContentSettingsMapFactory::GetForProfile(profile_)
->GetContentSettingAndMaybeUpdateLastUsage(
requesting_origin, embedding_origin, content_settings_type(),
std::string());
if (push_content_setting == CONTENT_SETTING_BLOCK) {
DVLOG(1) << "Push permission was explicitly blocked.";
PermissionUmaUtil::PermissionDenied(permission_type(), requesting_origin);
NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
true /* persist */, CONTENT_SETTING_BLOCK);
return;
}
if (notification_status != blink::mojom::PermissionStatus::GRANTED) {
DVLOG(1) << "Notification permission has not been granted.";
NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
false /* persist */, CONTENT_SETTING_BLOCK);
return;
}
PermissionUmaUtil::PermissionGranted(permission_type(), requesting_origin);
NotifyPermissionSet(id, requesting_origin, embedding_origin, callback,
true /* persist */, CONTENT_SETTING_ALLOW);
}
| 42.602941 | 80 | 0.749223 | Wzzzx |
38bbab352f6e8387485c5f0c5ce286419199909b | 4,460 | cpp | C++ | source/game/GLSLProgram.cpp | WarzesProject/2dgame | 7c398505bd02f9c519f2968bceb3ba87ac26a6a5 | [
"MIT"
] | null | null | null | source/game/GLSLProgram.cpp | WarzesProject/2dgame | 7c398505bd02f9c519f2968bceb3ba87ac26a6a5 | [
"MIT"
] | null | null | null | source/game/GLSLProgram.cpp | WarzesProject/2dgame | 7c398505bd02f9c519f2968bceb3ba87ac26a6a5 | [
"MIT"
] | null | null | null | #include "stdafx.h"
#include "GLSLProgram.h"
#include "IOManager.h"
//-----------------------------------------------------------------------------
void GLSLProgram::CompileShadersFromFile(std::string_view vertexShaderFilePath, std::string_view fragmentShaderFilePath)
{
std::string vertexSource;
std::string fragSource;
IOManager::ReadFileToBuffer(vertexShaderFilePath, vertexSource);
IOManager::ReadFileToBuffer(fragmentShaderFilePath, fragSource);
CompileShadersFromSource(vertexSource, fragSource);
}
//-----------------------------------------------------------------------------
void GLSLProgram::CompileShadersFromSource(std::string_view vertexSource, std::string_view fragmentSource)
{
m_programID = glCreateProgram();
m_vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
if ( m_vertexShaderID == 0 )
Throw("Vertex shader failed to be created!");
m_fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
if ( m_fragmentShaderID == 0 )
Throw("Fragment shader failed to be created!");
compileShaders(vertexSource.data(), "Vertex shader", m_vertexShaderID);
compileShaders(fragmentSource.data(), "Fragment shader", m_fragmentShaderID);
}
//-----------------------------------------------------------------------------
void GLSLProgram::LinkShaders()
{
//Attach our shaders to our program
glAttachShader(m_programID, m_vertexShaderID);
glAttachShader(m_programID, m_fragmentShaderID);
//Link our program
glLinkProgram(m_programID);
//Note the different functions here: glGetProgram* instead of glGetShader*.
GLint isLinked = 0;
glGetProgramiv(m_programID, GL_LINK_STATUS, (int *)&isLinked);
if ( isLinked == GL_FALSE )
{
GLint maxLength = 0;
glGetProgramiv(m_programID, GL_INFO_LOG_LENGTH, &maxLength);
//The maxLength includes the NULL character
std::vector<GLchar> errorLog(maxLength);
glGetProgramInfoLog(m_programID, maxLength, &maxLength, &errorLog[0]);
//We don't need the program anymore.
glDeleteProgram(m_programID);
//Don't leak shaders either.
glDeleteShader(m_vertexShaderID);
glDeleteShader(m_fragmentShaderID);
Throw(&(errorLog[0]) + std::string("\nShader failed to link!"));
}
//Always detach shaders after a successful link.
glDetachShader(m_programID, m_vertexShaderID);
glDetachShader(m_programID, m_fragmentShaderID);
glDeleteShader(m_vertexShaderID);
glDeleteShader(m_fragmentShaderID);
}
//-----------------------------------------------------------------------------
void GLSLProgram::AddAttribute(std::string_view attributeName)
{
glBindAttribLocation(m_programID, m_numAttributtes++, attributeName.data());
}
//-----------------------------------------------------------------------------
GLint GLSLProgram::GetUniformLocation(std::string_view uniformName)
{
GLint location = glGetUniformLocation(m_programID, uniformName.data());
if ( location == GL_INVALID_INDEX )
Throw("Uniform " + std::string(uniformName.data()) + " not found in shader!");
return location;
}
//-----------------------------------------------------------------------------
void GLSLProgram::Use()
{
glUseProgram(m_programID);
for ( int i = 0; i < m_numAttributtes; i++ )
glEnableVertexAttribArray(i);
}
//-----------------------------------------------------------------------------
void GLSLProgram::Unuse()
{
glUseProgram(0);
for ( int i = 0; i < m_numAttributtes; i++ )
glDisableVertexAttribArray(i);
}
//-----------------------------------------------------------------------------
void GLSLProgram::Dispose()
{
if ( m_programID )
glDeleteProgram(m_programID);
m_numAttributtes = 0;
}
//-----------------------------------------------------------------------------
void GLSLProgram::compileShaders(const char* source, std::string_view name, const GLuint &id)
{
glShaderSource(id, 1, &source, nullptr);
glCompileShader(id);
GLint isCompiled = 0;
glGetShaderiv(id, GL_COMPILE_STATUS, &isCompiled);
if ( isCompiled == GL_FALSE )
{
GLint maxLength = 0;
glGetShaderiv(id, GL_INFO_LOG_LENGTH, &maxLength);
// The maxLength includes the NULL character
std::vector<GLchar> errorLog(maxLength);
glGetShaderInfoLog(id, maxLength, &maxLength, &errorLog[0]);
// Provide the infolog in whatever manor you deem best.
// Exit with failure.
glDeleteShader(id); // Don't leak the shader.
Throw(&(errorLog[0]) + std::string("Shader ") + name.data() + " failed to compile!");
}
}
//----------------------------------------------------------------------------- | 34.573643 | 120 | 0.62287 | WarzesProject |
38bbc9c37252aee9a3cf06244c691dac181b6fcd | 53,444 | cpp | C++ | source/DSES/ExecutionControl.cpp | jiajlin/TrickHLA | ae704b97049579e997593ae6d8dd016010b8fa1e | [
"NASA-1.3"
] | null | null | null | source/DSES/ExecutionControl.cpp | jiajlin/TrickHLA | ae704b97049579e997593ae6d8dd016010b8fa1e | [
"NASA-1.3"
] | null | null | null | source/DSES/ExecutionControl.cpp | jiajlin/TrickHLA | ae704b97049579e997593ae6d8dd016010b8fa1e | [
"NASA-1.3"
] | null | null | null | /*!
@file DSES/ExecutionControl.cpp
@ingroup DSES
@brief This class provides and abstract base class as the base implementation
for managing mode transitions.
@copyright Copyright 2019 United States Government as represented by the
Administrator of the National Aeronautics and Space Administration.
No copyright is claimed in the United States under Title 17, U.S. Code.
All Other Rights Reserved.
\par<b>Responsible Organization</b>
Simulation and Graphics Branch, Mail Code ER7\n
Software, Robotics & Simulation Division\n
NASA, Johnson Space Center\n
2101 NASA Parkway, Houston, TX 77058
@tldh
@trick_link_dependency{../TrickHLA/DebugHandler.cpp}
@trick_link_dependency{../TrickHLA/SyncPntListBase.cpp}
@trick_link_dependency{../TrickHLA/SleepTimeout.cpp}
@trick_link_dependency{ExecutionControl.cpp}
@revs_title
@revs_begin
@rev_entry{Edwin Z. Crues, NASA ER7, TrickHLA, Jan 2019, --, DSES support and testing.}
@rev_entry{Edwin Z. Crues, NASA ER7, TrickHLA, June 2019, --, Version 3 rewrite.}
@revs_end
*/
// System include files.
#include <iomanip>
#include <math.h>
// Trick includes.
#include "trick/Executive.hh"
#include "trick/exec_proto.hh"
#include "trick/message_proto.h"
// HLA include files.
// TrickHLA include files.
#include "TrickHLA/DebugHandler.hh"
#include "TrickHLA/Federate.hh"
#include "TrickHLA/Int64Interval.hh"
#include "TrickHLA/Manager.hh"
#include "TrickHLA/SleepTimeout.hh"
#include "TrickHLA/StringUtilities.hh"
#include "TrickHLA/Types.hh"
#include "TrickHLA/Utilities.hh"
// DSES include files.
#include "DSES/ExecutionConfiguration.hh"
#include "DSES/ExecutionControl.hh"
// IMSim file level declarations.
namespace DSES
{
// ExecutionControl type string.
const std::string ExecutionControl::type = "DSES";
// The DSES Multiphase initialization HLA synchronization-points.
static const std::wstring SIM_CONFIG_SYNC_POINT = L"sim_config";
static const std::wstring INITIALIZE_SYNC_POINT = L"initialize";
static const std::wstring STARTUP_SYNC_POINT = L"startup";
} // namespace DSES
using namespace std;
using namespace RTI1516_NAMESPACE;
using namespace TrickHLA;
using namespace DSES;
/*!
* @job_class{initialization}
*/
ExecutionControl::ExecutionControl()
: time_padding( 5.0 ),
mode_transition_requested( false ),
pending_mtr( DSES::MTR_UNINITIALIZED ),
requested_execution_control_mode( EXECUTION_CONTROL_UNINITIALIZED ),
current_execution_control_mode( EXECUTION_CONTROL_UNINITIALIZED ),
next_mode_scenario_time( -std::numeric_limits< double >::max() ),
next_mode_cte_time( -std::numeric_limits< double >::max() ),
simulation_freeze_time( 0.0 ),
scenario_freeze_time( 0.0 ),
late_joiner( false ),
late_joiner_determined( false ),
federate( NULL )
{
return;
}
/*!
* @job_class{shutdown}
*/
ExecutionControl::~ExecutionControl()
{
clear_mode_values();
}
/*!
@details This routine will set a lot of the data in the TrickHLA::Federate that
is required for this execution control scheme. This should greatly simplify
input files and reduce input file setting errors.
@job_class{initialization}
*/
void ExecutionControl::initialize()
{
if ( DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
ostringstream msg;
msg << "DSES::ExecutionControl::initialize():" << __LINE__
<< " Initialization-Scheme:'" << get_type()
<< "'" << THLA_ENDL;
send_hs( stdout, (char *)msg.str().c_str() );
}
// Set the reference to the TrickHLA::Federate.
this->federate = &fed;
// Initialize the ExecutionControl so that it knows about the manager.
this->execution_configuration->initialize( this->get_manager() );
// There are things that must me set for the DSES initialization.
this->use_preset_master = true;
// If this is the Master federate, then it must support Time
// Management and be both Time Regulating and Time Constrained.
if ( this->is_master() ) {
federate->time_management = true;
federate->time_regulating = true;
federate->time_constrained = true;
// The software frame is set from the ExCO Least Common Time Step.
// For the Master federate the Trick simulation software frame must
// match the Least Common Time Step (LCTS).
double software_frame_time = Int64Interval::to_seconds( least_common_time_step );
exec_set_software_frame( software_frame_time );
}
// Add the Mode Transition Request synchronization points.
this->add_sync_pnt( L"mtr_run" );
this->add_sync_pnt( L"mtr_freeze" );
this->add_sync_pnt( L"mtr_shutdown" );
// Make sure we initialize the base class.
TrickHLA::ExecutionControlBase::initialize();
// Must use a preset master.
if ( !this->is_master_preset() ) {
ostringstream errmsg;
errmsg << "DSES::ExecutionControl::initialize(): WARNING:" << __LINE__
<< " Only a preset master is supported. Make sure to set"
<< " 'THLA.federate.use_preset_master = true' in your input file."
<< " Setting use_preset_master to true!"
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
this->use_preset_master = true;
}
if ( DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
if ( this->is_master() ) {
send_hs( stdout, "DSES::ExecutionControl::initialize():%d\n I AM THE PRESET MASTER%c",
__LINE__, THLA_NEWLINE );
} else {
send_hs( stdout, "DSES::ExecutionControl::initialize():%d\n I AM NOT THE PRESET MASTER%c",
__LINE__, THLA_NEWLINE );
}
}
// Call the DSES ExecutionControl pre-multi-phase initialization processes.
pre_multi_phase_init_processes();
}
/*!
@details This routine implements the DSES Join Federation Process described
in section 7.2 and figure 7-3.
@job_class{initialization}
*/
void ExecutionControl::join_federation_process()
{
// The base class implementation is good enough for now.
TrickHLA::ExecutionControlBase::join_federation_process();
}
/*!
@details This routine implements the DSES pre multi-phase initialization process.
@job_class{initialization}
*/
void ExecutionControl::pre_multi_phase_init_processes()
{
if ( DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
send_hs( stdout, "DSES::ExecutionControl::pre_multi_phase_init_processes():%d%c",
__LINE__, THLA_NEWLINE );
}
// Reset the sim-config required flag to make it required.
execution_configuration->mark_required();
// Reset the sim-config preferred-order for attributes to Receive-Order.
execution_configuration->reset_preferred_order();
// Reset the ownership flags and the attribute configuration flags for
// the simulation configuration object.
execution_configuration->reset_ownership_states();
// Setup all the Trick Ref-Attributes for the user specified objects,
// attributes, interactions and parameters.
get_manager()->setup_all_ref_attributes();
// Add the DSES multiphase initialization sync-points now that the
// Simulation-Configuration has been initialized in the call to
// the setup_all_ref_attributes() function. We do this here so
// that we can handle the RTI callbacks that use them.
this->add_multiphase_init_sync_points();
// Create the RTI Ambassador and connect.
federate->create_RTI_ambassador_and_connect();
// Destroy the federation if it was orphaned from a previous simulation
// run that did not shutdown cleanly.
federate->destroy_orphaned_federation();
// Create and then join the federation.
federate->create_and_join_federation();
// Don't forget to enable asynchronous delivery of messages.
federate->enable_async_delivery();
// Determine if this federate is the Master.
determine_federation_master();
// Setup all the RTI handles for the objects, attributes and interaction
// parameters.
get_manager()->setup_all_RTI_handles();
// Call publish_and_subscribe AFTER we've initialized the manager,
// federate, and FedAmb.
get_manager()->publish_and_subscribe();
// Reserve the RTI object instance names with the RTI, but only for
// the objects that are locally owned.
get_manager()->reserve_object_names_with_RTI();
// Waits on the reservation of the RTI object instance names for the
// locally owned objects. Calling this function will block until all
// the object instances names for the locally owned objects have been
// reserved.
get_manager()->wait_on_reservation_of_object_names();
// Creates an RTI object instance and registers it with the RTI, but
// only for the objects that are locally owned.
get_manager()->register_objects_with_RTI();
// Setup the preferred order for all object attributes and interactions.
get_manager()->setup_preferred_order_with_RTI();
// Waits on the registration of all the required RTI object instances with
// the RTI. Calling this function will block until all the required object
// instances in the Federation have been registered.
get_manager()->wait_on_registration_of_required_objects();
// Initialize the MOM interface handles.
federate->initialize_MOM_handles();
// Perform the next few steps if we are the Master federate.
if ( this->is_master() ) {
// Make sure all required federates have joined the federation.
(void)federate->wait_for_required_federates_to_join();
// Register the Multi-phase initialization sync-points.
this->register_all_sync_pnts( *federate->get_RTI_ambassador() );
}
// Wait for the "sim_config", "initialize", and "startup" sync-points
// to be registered.
this->wait_for_all_announcements( federate );
// Achieve the "sim_config" sync-point and wait for the federation
// to be synchronized on it.
federate->achieve_and_wait_for_synchronization( DSES::SIM_CONFIG_SYNC_POINT );
if ( this->is_master() ) {
// Send the "Simulation Configuration".
this->send_execution_configuration();
} else {
// Wait for the "Simulation Configuration" object attribute reflection.
this->receive_execution_configuration();
}
// Achieve the "initialize" sync-point and wait for the federation
// to be synchronized on it.
federate->achieve_and_wait_for_synchronization( DSES::INITIALIZE_SYNC_POINT );
}
/*!
@details This routine implements the DSES post multi-phase initialization process.
@job_class{initialization}
*/
void ExecutionControl::post_multi_phase_init_process()
{
// Setup HLA time management.
federate->setup_time_management();
// Achieve the "startup" sync-point and wait for the federation
// to be synchronized on it.
federate->achieve_and_wait_for_synchronization( DSES::STARTUP_SYNC_POINT );
}
/*!
* @job_class{shutdown}
*/
void ExecutionControl::shutdown()
{
return;
}
/*!
* @job_class{initialization}
*/
void ExecutionControl::setup_object_RTI_handles()
{
return;
}
/*!
* @job_class{initialization}
*/
void ExecutionControl::setup_interaction_RTI_handles()
{
return;
}
/*!
* @job_class{initialization}
*/
void ExecutionControl::add_multiphase_init_sync_points()
{
// Call the base class method to add user defined multi-phase
// initialization synchronization points.
ExecutionControlBase::add_multiphase_init_sync_points();
// Register initialization synchronization points used for startup regulation.
this->add_sync_pnt( DSES::STARTUP_SYNC_POINT );
this->add_sync_pnt( DSES::INITIALIZE_SYNC_POINT );
this->add_sync_pnt( DSES::SIM_CONFIG_SYNC_POINT );
}
void ExecutionControl::announce_sync_point(
RTI1516_NAMESPACE::RTIambassador &rti_ambassador,
wstring const & label,
RTI1516_USERDATA const & user_supplied_tag )
{
if ( this->contains( label ) ) {
// Mark init sync-point as announced.
if ( this->mark_announced( label ) ) {
if ( DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
send_hs( stdout, "DSES::ExecutionControl::announce_sync_point():%d DSES Multiphase Init Sync-Point:'%ls'%c",
__LINE__, label.c_str(), THLA_NEWLINE );
}
}
} // By default, mark an unrecognized synchronization point as achieved.
else {
if ( DebugHandler::DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
send_hs( stdout, "DSES::ExecutionControl::announce_sync_point():%d Unrecognized synchronization point:'%ls', which will be achieved.%c",
__LINE__, label.c_str(), THLA_NEWLINE );
}
// Unknown synchronization point so achieve it but don't wait for the
// federation to by synchronized on it.
this->achieve_sync_pnt( rti_ambassador, label );
}
}
/*!
* @job_class{initialization}
*/
void ExecutionControl::achieve_all_multiphase_init_sync_pnts(
RTI1516_NAMESPACE::RTIambassador &rti_ambassador )
{
// Iterate through this ExecutionControl's synchronization point list.
vector< SyncPnt * >::const_iterator i;
for ( i = sync_point_list.begin(); i != sync_point_list.end(); ++i ) {
SyncPnt *sp = ( *i );
// Achieve a synchronization point if it is not already achieved and is
// not one of the predefined ExecutionControl synchronization points.
if ( ( sp != NULL ) && sp->exists() && !sp->is_achieved()
&& ( sp->label.compare( DSES::STARTUP_SYNC_POINT ) != 0 )
&& ( sp->label.compare( DSES::INITIALIZE_SYNC_POINT ) != 0 )
&& ( sp->label.compare( DSES::SIM_CONFIG_SYNC_POINT ) != 0 ) ) {
// Achieve the synchronization point.
rti_ambassador.synchronizationPointAchieved( sp->label );
}
}
}
/*!
* @job_class{initialization}
*/
void ExecutionControl::wait_for_all_multiphase_init_sync_pnts()
{
// Iterate through this ExecutionControl's synchronization point list.
vector< SyncPnt * >::const_iterator i;
for ( i = sync_point_list.begin(); i != sync_point_list.end(); ++i ) {
SyncPnt *sp = ( *i );
// Wait for a synchronization point if it is not already achieved and is
// not one of the predefined ExecutionControl synchronization points.
if ( ( sp != NULL ) && sp->exists() && !sp->is_achieved()
&& ( sp->label.compare( DSES::STARTUP_SYNC_POINT ) != 0 )
&& ( sp->label.compare( DSES::INITIALIZE_SYNC_POINT ) != 0 )
&& ( sp->label.compare( DSES::SIM_CONFIG_SYNC_POINT ) != 0 ) ) {
SleepTimeout sleep_timer;
// Wait for the federation to synchronized on the sync-point.
while ( !sp->is_achieved() ) {
// Always check to see is a shutdown was received.
federate->check_for_shutdown_with_termination();
// Pause and release the processor for short sleep value.
(void)sleep_timer.sleep();
// Periodically check to make sure the federate is still part of
// the federation exectuion.
if ( !sp->is_achieved() && sleep_timer.timeout() ) {
sleep_timer.reset();
if ( !federate->is_execution_member() ) {
ostringstream errmsg;
errmsg << "DSES::ExecutionControl::wait_for_all_multiphase_init_sync_pnts:" << __LINE__
<< " ERROR: Unexpectedly the Federate is no longer an execution"
<< " member. This means we are either not connected to the"
<< " RTI or we are no longer joined to the federation"
<< " execution because someone forced our resignation at"
<< " the Central RTI Component (CRC) level!"
<< THLA_ENDL;
send_hs( stderr, (char *)errmsg.str().c_str() );
exec_terminate( __FILE__, (char *)errmsg.str().c_str() );
}
}
}
}
}
}
void ExecutionControl::publish()
{
return;
}
void ExecutionControl::unpublish()
{
return;
}
void ExecutionControl::subscribe()
{
return;
}
void ExecutionControl::unsubscribe()
{
return;
}
/*!
@job_class{initialization}
*/
bool ExecutionControlBase::object_instance_name_reservation_failed(
std::wstring const &obj_instance_name )
{
wstring ws_sim_config_name;
StringUtilities::to_wstring( ws_sim_config_name, execution_configuration->get_name() );
// For multiphase initialization version 1, we handle the SimConfig
// instance name reservation failure to help determine the master.
if ( obj_instance_name == ws_sim_config_name ) {
// We are NOT the Master federate since we failed to reserve the
// "SimConfig" name and only if the master was not preset.
if ( !this->is_master_preset() ) {
this->set_master( false );
}
// We failed to register the "SimConfig" name which means that another
// federate has already registered it.
execution_configuration->set_name_registered();
if ( DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
send_hs( stdout, "DSES::ExecutionControl::object_instance_name_reservation_failed():%d Name:'%ls'%c",
__LINE__, obj_instance_name.c_str(), THLA_NEWLINE );
}
// Return 'true' since we found a match.
return ( true );
}
// Return 'false' since we did not find a match.
return ( false );
}
/*!
* @job_class{initialization}
*/
void ExecutionControl::determine_federation_master()
{
if ( DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
send_hs( stdout, "DSES::ExecutionControl::determine_federation_master():%d%c",
__LINE__, THLA_NEWLINE );
}
// If we are not supposed to use a preset master, then reserve the SimConfig
// name so that we can determine the master. Also, if we are supposed to use
// a preset master and we are that master then go ahead and register the
// SimConfig name.
if ( !this->is_master_preset() || this->is_master() ) {
// Reserve "SimConfig" object instance name as a way of determining
// who the master federate is.
execution_configuration->reserve_object_name_with_RTI();
// Wait for success or failure for the "SimConfig" name reservation.
execution_configuration->wait_on_object_name_reservation();
}
// Setup the execution configuration object now that we know if we are the
// "Master" federate or not.
execution_configuration->set_master( this->is_master() );
if ( DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
if ( this->is_master() ) {
send_hs( stdout, "DSES::ExecutionControl::determine_federation_master():%d\n I AM THE MASTER%c",
__LINE__, THLA_NEWLINE );
} else {
send_hs( stdout, "DSES::ExecutionControl::determine_federation_master():%d\n I AM NOT THE MASTER%c",
__LINE__, THLA_NEWLINE );
}
}
}
bool ExecutionControl::set_pending_mtr(
MTREnum mtr_value )
{
if ( this->is_mtr_valid( mtr_value ) ) {
this->pending_mtr = mtr_value;
}
return false;
}
bool ExecutionControl::is_mtr_valid(
MTREnum mtr_value )
{
ExecutionConfiguration *ExCO = get_execution_configuration();
switch ( mtr_value ) {
case MTR_GOTO_RUN: {
return ( ( ExCO->current_execution_mode == EXECUTION_MODE_INITIALIZING ) || ( ExCO->current_execution_mode == EXECUTION_MODE_FREEZE ) );
}
case MTR_GOTO_FREEZE: {
return ( ( ExCO->current_execution_mode == EXECUTION_MODE_INITIALIZING ) || ( ExCO->current_execution_mode == EXECUTION_MODE_RUNNING ) );
}
case MTR_GOTO_SHUTDOWN: {
return ( ExCO->current_execution_mode != EXECUTION_MODE_SHUTDOWN );
}
default: {
return false;
}
}
return false;
}
void ExecutionControl::set_mode_request_from_mtr(
MTREnum mtr_value )
{
switch ( mtr_value ) {
case MTR_UNINITIALIZED:
this->pending_mtr = MTR_UNINITIALIZED;
set_next_execution_control_mode( EXECUTION_CONTROL_UNINITIALIZED );
break;
case MTR_INITIALIZING:
this->pending_mtr = MTR_INITIALIZING;
set_next_execution_control_mode( EXECUTION_CONTROL_INITIALIZING );
break;
case MTR_GOTO_RUN:
this->pending_mtr = MTR_GOTO_RUN;
set_next_execution_control_mode( EXECUTION_CONTROL_RUNNING );
break;
case MTR_GOTO_FREEZE:
this->pending_mtr = MTR_GOTO_FREEZE;
set_next_execution_control_mode( EXECUTION_CONTROL_FREEZE );
break;
case MTR_GOTO_SHUTDOWN:
this->pending_mtr = MTR_GOTO_SHUTDOWN;
set_next_execution_control_mode( EXECUTION_CONTROL_SHUTDOWN );
break;
default:
this->pending_mtr = MTR_UNINITIALIZED;
break;
}
}
void ExecutionControl::set_next_execution_control_mode(
TrickHLA::ExecutionControlEnum exec_control )
{
// Reference the DSES Execution Configuration Object (ExCO)
ExecutionConfiguration *ExCO = get_execution_configuration();
// This should only be called by the Master federate.
if ( !this->is_master() ) {
ostringstream errmsg;
errmsg << "DSES::ExecutionControl::set_next_execution_mode():" << __LINE__
<< " ERROR: This should only be called by the Master federate!" << THLA_ENDL;
send_hs( stderr, (char *)errmsg.str().c_str() );
exec_terminate( __FILE__, (char *)errmsg.str().c_str() );
return;
}
switch ( exec_control ) {
case EXECUTION_CONTROL_UNINITIALIZED:
// Set the next execution mode.
this->requested_execution_control_mode = EXECUTION_CONTROL_UNINITIALIZED;
ExCO->set_next_execution_mode( EXECUTION_MODE_UNINITIALIZED );
// Set the next mode times.
this->next_mode_scenario_time = this->get_scenario_time(); // Immediate
ExCO->set_next_mode_scenario_time( this->get_scenario_time() ); // Immediate
ExCO->set_next_mode_cte_time( this->get_cte_time() ); // Immediate
break;
case EXECUTION_CONTROL_INITIALIZING:
// Set the next execution mode.
this->requested_execution_control_mode = EXECUTION_CONTROL_INITIALIZING;
ExCO->set_next_execution_mode( EXECUTION_MODE_INITIALIZING );
// Set the next mode times.
ExCO->set_scenario_time_epoch( this->get_scenario_time() ); // Now.
this->next_mode_scenario_time = this->get_scenario_time(); // Immediate
ExCO->set_next_mode_scenario_time( this->get_scenario_time() ); // Immediate
ExCO->set_next_mode_cte_time( this->get_cte_time() ); // Immediate
break;
case EXECUTION_CONTROL_RUNNING:
// Set the next execution mode.
this->requested_execution_control_mode = EXECUTION_CONTROL_RUNNING;
ExCO->set_next_execution_mode( EXECUTION_MODE_RUNNING );
// Set the next mode times.
this->next_mode_scenario_time = this->get_scenario_time(); // Immediate
ExCO->set_next_mode_scenario_time( this->next_mode_scenario_time ); // immediate
ExCO->set_next_mode_cte_time( this->get_cte_time() );
if ( ExCO->get_next_mode_cte_time() > -std::numeric_limits< double >::max() ) {
ExCO->set_next_mode_cte_time( ExCO->get_next_mode_cte_time() + this->time_padding ); // Some time in the future.
}
break;
case EXECUTION_CONTROL_FREEZE:
// Set the next execution mode.
this->requested_execution_control_mode = EXECUTION_CONTROL_FREEZE;
ExCO->set_next_execution_mode( EXECUTION_MODE_FREEZE );
// Set the next mode times.
this->next_mode_scenario_time = this->get_scenario_time() + this->time_padding; // Some time in the future.
ExCO->set_next_mode_scenario_time( this->next_mode_scenario_time );
ExCO->set_next_mode_cte_time( this->get_cte_time() );
if ( ExCO->get_next_mode_cte_time() > -std::numeric_limits< double >::max() ) {
ExCO->set_next_mode_cte_time( ExCO->get_next_mode_cte_time() + this->time_padding ); // Some time in the future.
}
// Set the ExecutionControl freeze times.
this->scenario_freeze_time = this->next_mode_scenario_time;
this->simulation_freeze_time = this->scenario_timeline->compute_simulation_time( this->next_mode_scenario_time );
break;
case EXECUTION_CONTROL_SHUTDOWN:
// Set the next execution mode.
this->requested_execution_control_mode = EXECUTION_CONTROL_SHUTDOWN;
ExCO->set_next_execution_mode( EXECUTION_MODE_SHUTDOWN );
// Set the next mode times.
this->next_mode_scenario_time = this->get_scenario_time(); // Immediate.
ExCO->set_next_mode_scenario_time( this->next_mode_scenario_time ); // Immediate.
ExCO->set_next_mode_cte_time( this->get_cte_time() ); // Immediate
break;
default:
this->requested_execution_control_mode = EXECUTION_CONTROL_UNINITIALIZED;
if ( DebugHandler::show( DEBUG_LEVEL_1_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
ostringstream errmsg;
errmsg << "DSES::ExecutionControl::set_next_execution_mode():"
<< __LINE__ << " WARNING: Unknown execution mode value: " << exec_control
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
}
break;
}
}
bool ExecutionControl::check_mode_transition_request()
{
// Just return if false mode change has been requested.
if ( !this->is_mode_transition_requested() ) {
return false;
}
// Only the Master federate receives and processes Mode Transition Requests.
if ( !this->is_master() ) {
ostringstream errmsg;
errmsg << "DSES::ExecutionControl::check_mode_transition_request():"
<< __LINE__ << " WARNING: Received Mode Transition Request and not Master: "
<< mtr_enum_to_string( this->pending_mtr )
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
return false;
}
// First check to see if this is a valid MTR.
if ( !( is_mtr_valid( this->pending_mtr ) ) ) {
ostringstream errmsg;
errmsg << "DSES::ExecutionControl::check_mode_transition_request():"
<< __LINE__ << " WARNING: Invalid Mode Transition Request: "
<< mtr_enum_to_string( this->pending_mtr )
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
return false;
}
return true;
}
bool ExecutionControl::process_mode_transition_request()
{
// Just return is no mode change has been requested.
if ( !this->check_mode_transition_request() ) {
return false;
} else {
// Since this is a valid MTR, set the next mode from the MTR.
this->set_mode_request_from_mtr( this->pending_mtr );
}
// Reference the DSES Execution Configuration Object (ExCO)
ExecutionConfiguration *ExCO = this->get_execution_configuration();
// Print diagnostic message if appropriate.
if ( DebugHandler::show( DEBUG_LEVEL_4_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
cout << "=============================================================" << endl
<< "ExecutionControl::process_mode_transition_request()" << endl
<< "\t current_scenario_time: " << setprecision( 18 ) << this->scenario_timeline->get_time() << endl
<< "\t scenario_time_epoch: " << setprecision( 18 ) << this->scenario_timeline->get_epoch() << endl
<< "\t scenario_time_epoch(ExCO): " << setprecision( 18 ) << ExCO->scenario_time_epoch << endl
<< "\t scenario_time_sim_offset: " << setprecision( 18 ) << this->scenario_timeline->get_sim_offset() << endl
<< "\t Current HLA grant time: " << federate->get_granted_time() << endl
<< "\t Current HLA request time: " << federate->get_requested_time() << endl
<< "\t current_sim_time: " << setprecision( 18 ) << this->sim_timeline->get_time() << endl
<< "\t simulation_time_epoch: " << setprecision( 18 ) << this->sim_timeline->get_epoch() << endl;
if ( this->does_cte_timeline_exist() ) {
cout << "\t current_CTE_time: " << setprecision( 18 ) << this->cte_timeline->get_time() << endl
<< "\t CTE_time_epoch: " << setprecision( 18 ) << this->cte_timeline->get_epoch() << endl;
}
cout << "\t next_mode_scenario_time: " << setprecision( 18 ) << ExCO->next_mode_scenario_time << endl
<< "\t next_mode_cte_time: " << setprecision( 18 ) << ExCO->next_mode_cte_time << endl
<< "\t scenario_freeze_time: " << setprecision( 18 ) << this->scenario_freeze_time << endl
<< "\t simulation_freeze_time: " << setprecision( 18 ) << this->simulation_freeze_time << endl
<< "=============================================================" << endl;
}
// Check Mode Transition Request.
switch ( this->pending_mtr ) {
case MTR_GOTO_RUN:
// Clear the mode change request flag.
this->clear_mode_transition_requested();
// Transition to run can only happen from initialization or freeze.
// We don't really need to do anything if we're in initialization.
if ( this->current_execution_control_mode == EXECUTION_CONTROL_FREEZE ) {
// Tell Trick to exit freeze and go to run.
the_exec->run();
// The run transition logic will be triggered when exiting Freeze.
// This is done in the TrickHLA::Federate::exit_freeze() routine
// called when exiting Freeze.
}
return true;
break;
case MTR_GOTO_FREEZE:
// Clear the mode change request flag.
this->clear_mode_transition_requested();
// Transition to freeze can only happen from initialization or run.
// We don't really need to do anything if we're in initialization.
if ( this->current_execution_control_mode == EXECUTION_CONTROL_RUNNING ) {
// Send out the updated ExCO.
ExCO->send_init_data();
// Announce the pending freeze.
this->freeze_mode_announce();
// Tell Trick to go into freeze at the appointed time.
the_exec->freeze( this->simulation_freeze_time );
// The freeze transition logic will be done just before entering
// Freeze. This is done in the TrickHLA::Federate::freeze_init()
// routine called when entering Freeze.
}
return true;
break;
case MTR_GOTO_SHUTDOWN:
// Announce the shutdown.
this->shutdown_mode_announce();
// Tell Trick to shutdown sometime in the future.
// The DSES ExecutionControl shutdown transition will be made from
// the TrickHLA::Federate::shutdown() job.
the_exec->stop( the_exec->get_sim_time() + this->time_padding );
return true;
break;
default:
break;
}
return false;
}
/*!
* \par<b>Assumptions and Limitations:</b>
* - Called from the ExCO unpack routine.
*
* @job_class{scheduled}
*/
bool ExecutionControl::process_execution_control_updates()
{
bool mode_change = false;
ostringstream errmsg;
// Reference the DSES Execution Configuration Object (ExCO)
ExecutionConfiguration *ExCO = get_execution_configuration();
// Check if there are pending changes from the ExCO.
if ( ExCO->update_pending() ) {
// Clear the ExCO update pending flag and continue.
ExCO->clear_update_pending();
} else {
// There are no pending changes from the ExCO.
// Return that no mode changes occurred.
return false;
}
// The Master federate should never have to process ExCO updates.
if ( this->is_master() ) {
errmsg << "DSES::ExecutionControl::process_execution_control_updates():"
<< __LINE__ << " WARNING: Master receive an ExCO update: "
<< execution_control_enum_to_string( this->requested_execution_control_mode )
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
// Return that no mode changes occurred.
return false;
}
// Translate the native ExCO mode values into ExecutionModeEnum.
ExecutionModeEnum exco_cem = execution_mode_int16_to_enum( ExCO->current_execution_mode );
ExecutionModeEnum exco_nem = execution_mode_int16_to_enum( ExCO->next_execution_mode );
// Check for consistency between ExecutionControl and ExCO.
if ( exco_cem != this->current_execution_control_mode ) {
errmsg << "DSES::ExecutionControl::process_execution_control_updates():"
<< __LINE__ << " WARNING: Current execution mode mismatch between ExecutionControl ("
<< execution_control_enum_to_string( this->current_execution_control_mode )
<< ") and the ExCO current execution mode ("
<< execution_mode_enum_to_string( exco_cem )
<< ")!"
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
}
// Check for change in execution mode.
if ( exco_nem != exco_cem ) {
mode_change = true;
if ( exco_nem == EXECUTION_MODE_SHUTDOWN ) {
this->requested_execution_control_mode = EXECUTION_CONTROL_SHUTDOWN;
} else if ( exco_nem == EXECUTION_MODE_RUNNING ) {
this->requested_execution_control_mode = EXECUTION_CONTROL_RUNNING;
} else if ( exco_nem == EXECUTION_MODE_FREEZE ) {
this->requested_execution_control_mode = EXECUTION_CONTROL_FREEZE;
this->scenario_freeze_time = ExCO->next_mode_scenario_time;
this->simulation_freeze_time = this->scenario_timeline->compute_simulation_time( this->scenario_freeze_time );
} else {
errmsg << "DSES::ExecutionControl::process_execution_control_updates():"
<< __LINE__ << " WARNING: Invalid ExCO next execution mode: "
<< execution_mode_enum_to_string( exco_nem ) << "!"
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
// Return that no mode changes occurred.
return false;
}
}
// Check for CTE mode time update.
if ( ExCO->next_mode_cte_time != this->next_mode_cte_time ) {
this->next_mode_cte_time = ExCO->next_mode_cte_time;
}
// Check for mode changes.
if ( !mode_change ) {
// Return that no mode changes occurred.
return false;
}
// Process the mode change.
switch ( this->current_execution_control_mode ) {
case EXECUTION_CONTROL_UNINITIALIZED:
// Check for SHUTDOWN.
if ( this->requested_execution_control_mode == EXECUTION_CONTROL_SHUTDOWN ) {
// Mark the current execution mode as SHUTDOWN.
this->current_execution_control_mode = EXECUTION_CONTROL_SHUTDOWN;
ExCO->current_execution_mode = EXECUTION_MODE_SHUTDOWN;
// Tell the TrickHLA::Federate to shutdown.
// The DSES ExecutionControl shutdown transition will be made from
// the TrickHLA::Federate::shutdown() job.
the_exec->stop();
} else {
errmsg << "DSES::ExecutionControl::process_execution_control_updates():"
<< __LINE__ << " WARNING: Execution mode mismatch between current mode ("
<< execution_control_enum_to_string( this->current_execution_control_mode )
<< ") and the requested execution mode ("
<< execution_control_enum_to_string( this->requested_execution_control_mode )
<< ")!"
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
// Return that no mode changes occurred.
return false;
}
// Return that a mode change occurred.
return true;
break;
case EXECUTION_CONTROL_INITIALIZING:
// Check for SHUTDOWN.
if ( this->requested_execution_control_mode == EXECUTION_CONTROL_SHUTDOWN ) {
// Mark the current execution mode as SHUTDOWN.
this->current_execution_control_mode = EXECUTION_CONTROL_SHUTDOWN;
ExCO->current_execution_mode = EXECUTION_MODE_SHUTDOWN;
// Tell the TrickHLA::Federate to shutdown.
// The DSES ExecutionControl shutdown transition will be made from
// the TrickHLA::Federate::shutdown() job.
the_exec->stop();
} else if ( this->requested_execution_control_mode == EXECUTION_CONTROL_RUNNING ) {
// Tell Trick to go to in Run at startup.
the_exec->set_freeze_command( false );
// This is an early joining federate in initialization.
// So, proceed to the run mode transition.
this->run_mode_transition();
} else if ( this->requested_execution_control_mode == EXECUTION_CONTROL_FREEZE ) {
// Announce the pending freeze.
this->freeze_mode_announce();
// Tell Trick to go into freeze at startup.
//the_exec->freeze();
// Tell Trick to go into freeze at startup.
the_exec->set_freeze_command( true );
// The freeze transition logic will be done just before entering
// Freeze. This is done in the TrickHLA::Federate::freeze_init()
// routine called when entering Freeze.
} else if ( this->requested_execution_control_mode == EXECUTION_CONTROL_INITIALIZING ) {
// There's really nothing to do here.
} else {
errmsg << "DSES::ExecutionControl::process_execution_control_updates():"
<< __LINE__ << " WARNING: Execution mode mismatch between current mode ("
<< execution_control_enum_to_string( this->current_execution_control_mode )
<< ") and the requested execution mode ("
<< execution_control_enum_to_string( this->requested_execution_control_mode )
<< ")!"
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
// Return that no mode changes occurred.
return false;
}
// Return that a mode change occurred.
return true;
break;
case EXECUTION_CONTROL_RUNNING:
// Check for SHUTDOWN.
if ( this->requested_execution_control_mode == EXECUTION_CONTROL_SHUTDOWN ) {
// Print out a diagnostic warning message.
errmsg << "DSES::ExecutionControl::process_execution_control_updates():"
<< __LINE__ << " WARNING: Execution mode mismatch between current mode ("
<< execution_control_enum_to_string( this->current_execution_control_mode )
<< ") and the requested execution mode ("
<< execution_control_enum_to_string( this->requested_execution_control_mode )
<< ")!"
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
// Mark the current execution mode as SHUTDOWN.
this->current_execution_control_mode = EXECUTION_CONTROL_SHUTDOWN;
ExCO->current_execution_mode = EXECUTION_MODE_SHUTDOWN;
// Tell the TrickHLA::Federate to shutdown.
// The DSES ExecutionControl shutdown transition will be made from
// the TrickHLA::Federate::shutdown() job.
the_exec->stop();
} else if ( this->requested_execution_control_mode == EXECUTION_CONTROL_FREEZE ) {
// Print diagnostic message if appropriate.
if ( DebugHandler::show( DEBUG_LEVEL_4_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
cout << "DSES::ExecutionControl::process_execution_control_updates()" << endl
<< "\t current_scenario_time: " << setprecision( 18 ) << this->scenario_timeline->get_time() << endl
<< "\t scenario_time_epoch: " << setprecision( 18 ) << this->scenario_timeline->get_epoch() << endl
<< "\t scenario_time_epoch(ExCO): " << setprecision( 18 ) << ExCO->scenario_time_epoch << endl
<< "\t scenario_time_sim_offset: " << setprecision( 18 ) << this->scenario_timeline->get_sim_offset() << endl
<< "\t current_sim_time: " << setprecision( 18 ) << this->sim_timeline->get_time() << endl
<< "\t simulation_time_epoch: " << setprecision( 18 ) << this->sim_timeline->get_epoch() << endl;
if ( this->does_cte_timeline_exist() ) {
cout << "\t current_CTE_time: " << setprecision( 18 ) << this->cte_timeline->get_time() << endl
<< "\t CTE_time_epoch: " << setprecision( 18 ) << this->cte_timeline->get_epoch() << endl;
}
cout << "\t next_mode_scenario_time: " << setprecision( 18 ) << ExCO->next_mode_scenario_time << endl
<< "\t next_mode_cte_time: " << setprecision( 18 ) << ExCO->next_mode_cte_time << endl
<< "\t scenario_freeze_time: " << setprecision( 18 ) << this->scenario_freeze_time << endl
<< "\t simulation_freeze_time: " << setprecision( 18 ) << this->simulation_freeze_time << endl
<< "=============================================================" << endl;
}
// Announce the pending freeze.
this->freeze_mode_announce();
// Tell Trick to go into freeze at the appointed time.
the_exec->freeze( this->simulation_freeze_time );
// The freeze transition logic will be done just before entering
// Freeze. This is done in the TrickHLA::Federate::freeze_init()
// routine called when entering Freeze.
} else {
errmsg << "DSES::ExecutionControl::process_execution_control_updates():"
<< __LINE__ << " WARNING: Execution mode mismatch between current mode ("
<< execution_control_enum_to_string( this->current_execution_control_mode )
<< ") and the requested execution mode ("
<< execution_control_enum_to_string( this->requested_execution_control_mode )
<< ")!"
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
// Return that no mode changes occurred.
return false;
}
// Return that a mode change occurred.
return true;
break;
case EXECUTION_CONTROL_FREEZE:
// Check for SHUTDOWN.
if ( this->requested_execution_control_mode == EXECUTION_CONTROL_SHUTDOWN ) {
// Mark the current execution mode as SHUTDOWN.
this->current_execution_control_mode = EXECUTION_CONTROL_SHUTDOWN;
ExCO->current_execution_mode = EXECUTION_MODE_SHUTDOWN;
// Shutdown the federate now.
exec_get_exec_cpp()->stop();
} else if ( this->requested_execution_control_mode == EXECUTION_CONTROL_RUNNING ) {
// Tell Trick to exit freeze and go to run.
the_exec->run();
// The run transition logic will be done just when exiting
// Freeze. This is done in the TrickHLA::Federate::exit_freeze()
// routine called when entering Freeze.
// this->run_mode_transition();
} else {
errmsg << "DSES::ExecutionControl::process_execution_control_updates():"
<< __LINE__ << " WARNING: Execution mode mismatch between current mode ("
<< execution_control_enum_to_string( this->current_execution_control_mode )
<< ") and the requested execution mode ("
<< execution_control_enum_to_string( this->requested_execution_control_mode )
<< ")!"
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
// Return that no mode changes occurred.
return false;
}
// Return that a mode change occurred.
return true;
break;
case EXECUTION_CONTROL_SHUTDOWN:
// Once in SHUTDOWN, we cannot do anything else.
errmsg << "DSES::ExecutionControl::process_execution_control_updates():"
<< __LINE__ << " WARNING: Shutting down but received mode transition: "
<< execution_control_enum_to_string( this->requested_execution_control_mode )
<< THLA_ENDL;
send_hs( stdout, (char *)errmsg.str().c_str() );
// Return that no mode changes occurred.
return false;
break;
default:
break;
}
// Return that no mode changes occurred.
return false;
}
bool ExecutionControl::run_mode_transition()
{
RTIambassador * RTI_amb = federate->get_RTI_ambassador();
ExecutionConfiguration *ExCO = get_execution_configuration();
SyncPnt * sync_pnt = NULL;
// Register the 'mtr_run' sync-point.
if ( this->is_master() ) {
sync_pnt = this->register_sync_pnt( *RTI_amb, L"mtr_run" );
} else {
sync_pnt = this->get_sync_pnt( L"mtr_run" );
}
// Make sure that we have a valid sync-point.
if ( sync_pnt == (TrickHLA::SyncPnt *)NULL ) {
ostringstream errmsg;
errmsg << "DSES::ExecutionControl::run_mode_transition():" << __LINE__
<< " ERROR: The 'mtr_run' sync-point was not found!" << THLA_ENDL;
send_hs( stderr, (char *)errmsg.str().c_str() );
exec_terminate( __FILE__, (char *)errmsg.str().c_str() );
} else {
// Wait for 'mtr_run' sync-point announce.
sync_pnt->wait_for_announce( federate );
// Achieve the 'mtr-run' sync-point.
sync_pnt->achieve_sync_point( *RTI_amb );
// Wait for 'mtr_run' sync-point synchronization.
sync_pnt->wait_for_synchronization( federate );
// Set the current execution mode to running.
this->current_execution_control_mode = EXECUTION_CONTROL_RUNNING;
ExCO->set_current_execution_mode( EXECUTION_MODE_RUNNING );
// Check for CTE.
if ( this->does_cte_timeline_exist() ) {
double go_to_run_time;
// The Master federate updates the ExCO with the CTE got-to-run time.
if ( this->is_master() ) {
go_to_run_time = ExCO->get_next_mode_cte_time();
ExCO->send_init_data();
} // Other federates wait on the ExCO update with the CTE go-to-run time.
else {
// Wait for the ExCO update with the CTE time.
ExCO->wait_on_update();
// Process the just received ExCO update.
this->process_execution_control_updates();
// Set the CTE time to go to run.
go_to_run_time = ExCO->get_next_mode_cte_time();
}
// Wait for the CTE go-to-run time.
double diff;
while ( this->get_cte_time() < go_to_run_time ) {
// Check for shutdown.
federate->check_for_shutdown_with_termination();
diff = go_to_run_time - this->get_cte_time();
if ( fmod( diff, 1.0 ) == 0.0 ) {
if ( DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
send_hs( stdout, "DSES::ExecutionControl::run_mode_transition():%d Going to run in %G seconds.%c",
__LINE__, diff, THLA_NEWLINE );
}
}
}
// Print debug message if appropriate.
if ( DebugHandler::show( DEBUG_LEVEL_2_TRACE, DEBUG_SOURCE_EXECUTION_CONTROL ) ) {
double curr_cte_time = this->get_cte_time();
diff = curr_cte_time - go_to_run_time;
send_hs( stdout, "DSES::ExecutionControl::run_mode_transition():%d \n Going to run at CTE time %.18G seconds. \n Current CTE time %.18G seconds. \n Difference: %.9lf seconds.%c",
__LINE__, go_to_run_time, curr_cte_time, diff, THLA_NEWLINE );
}
}
}
return true;
}
void ExecutionControl::freeze_mode_announce()
{
// Register the 'mtr_freeze' sync-point.
if ( this->is_master() ) {
this->register_sync_pnt( *( federate->get_RTI_ambassador() ), L"mtr_freeze" );
}
}
bool ExecutionControl::freeze_mode_transition()
{
RTIambassador * RTI_amb = federate->get_RTI_ambassador();
ExecutionConfiguration *ExCO = get_execution_configuration();
TrickHLA::SyncPnt * sync_pnt = NULL;
// Get the 'mtr_freeze' sync-point.
sync_pnt = this->get_sync_pnt( L"mtr_freeze" );
// Make sure that we have a valid sync-point.
if ( sync_pnt == (TrickHLA::SyncPnt *)NULL ) {
ostringstream errmsg;
errmsg << "DSES::ExecutionControl::freeze_mode_transition():" << __LINE__
<< " ERROR: The 'mtr_freeze' sync-point was not found!" << THLA_ENDL;
send_hs( stderr, (char *)errmsg.str().c_str() );
exec_terminate( __FILE__, (char *)errmsg.str().c_str() );
} else {
// Wait for 'mtr_freeze' sync-point announce.
sync_pnt->wait_for_announce( federate );
// Achieve the 'mtr_freeze' sync-point.
sync_pnt->achieve_sync_point( *RTI_amb );
// Wait for 'mtr_freeze' sync-point synchronization.
sync_pnt->wait_for_synchronization( federate );
// Set the current execution mode to freeze.
this->current_execution_control_mode = EXECUTION_CONTROL_FREEZE;
ExCO->set_current_execution_mode( EXECUTION_MODE_FREEZE );
}
return false;
}
bool ExecutionControl::check_freeze_exit()
{
// Check if this is a Master federate.
if ( this->is_master() ) {
// Process and Mode Transition Requests.
process_mode_transition_request();
// Handle requests for ExCO updates.
if ( this->execution_configuration->is_attribute_update_requested() ) {
this->execution_configuration->send_requested_data();
}
// Check for Trick shutdown command.
if ( the_exec->get_exec_command() == ExitCmd ) {
// Tell the TrickHLA::Federate to shutdown.
// The DSES ExecutionControl shutdown transition will be made from
// the TrickHLA::Federate::shutdown() job.
this->federate->shutdown();
}
} else {
// Check to see if there was an ExCO update.
this->execution_configuration->receive_init_data();
// Process the ExCO update.
this->process_execution_control_updates();
// Check for shutdown.
if ( this->current_execution_control_mode == EXECUTION_CONTROL_SHUTDOWN ) {
// Tell the TrickHLA::Federate to shutdown.
// The DSES Mode Manager shutdown transition will be made from
// the TrickHLA::Federate::shutdown() job.
this->federate->shutdown();
}
}
return ( true );
}
void ExecutionControl::shutdown_mode_announce()
{
// Only the Master federate will ever announce a shutdown.
if ( !this->is_master() ) {
return;
}
// If the current execution mode is uninitialized then we haven't gotten
// far enough in the initialization process to shut anything down.
if ( this->current_execution_control_mode == EXECUTION_CONTROL_UNINITIALIZED ) {
return;
}
// Set the next execution mode to shutdown.
this->set_next_execution_control_mode( EXECUTION_CONTROL_SHUTDOWN );
// Send out the updated ExCO.
this->get_execution_configuration()->send_init_data();
// Clear the mode change request flag.
this->clear_mode_transition_requested();
}
/*!
* @job_class{shutdown}
*/
void ExecutionControl::shutdown_mode_transition()
{
// Only the Master federate has any DSES tasks for shutdown.
if ( !this->is_master() ) {
return;
}
// If the current execution mode is uninitialized then we haven't gotten
// far enough in the initialization process to shut anything down.
if ( this->current_execution_control_mode == EXECUTION_CONTROL_UNINITIALIZED ) {
return;
}
// Register the 'mtr_shutdown' sync-point.
this->register_sync_pnt( *( federate->get_RTI_ambassador() ), L"mtr_shutdown" );
}
ExecutionConfiguration *ExecutionControl::get_execution_configuration()
{
ExecutionConfiguration *ExCO;
ExCO = dynamic_cast< ExecutionConfiguration * >( this->get_execution_configuration() );
if ( ExCO == NULL ) {
ostringstream errmsg;
errmsg << "DSES::ExecutionControl::epoch_and_root_frame_discovery_process():" << __LINE__
<< " ERROR: Execution Configureation is not an DSES ExCO." << THLA_ENDL;
send_hs( stderr, (char *)errmsg.str().c_str() );
exec_terminate( __FILE__, (char *)errmsg.str().c_str() );
}
return ( this->get_execution_configuration() );
}
| 37.930447 | 193 | 0.648978 | jiajlin |
38be358d6928ad7412aa0b3f2fcfa99543558716 | 3,388 | cpp | C++ | solutions/hackerrank/hour_rank/hr26/q3/ProblemC.cpp | bluedawnstar/algorithm_library | 4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6 | [
"Unlicense"
] | 40 | 2017-11-26T05:29:18.000Z | 2020-11-13T00:29:26.000Z | solutions/hackerrank/hour_rank/hr26/q3/ProblemC.cpp | bluedawnstar/algorithm_library | 4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6 | [
"Unlicense"
] | 101 | 2019-02-09T06:06:09.000Z | 2021-12-25T16:55:37.000Z | solutions/hackerrank/hour_rank/hr26/q3/ProblemC.cpp | bluedawnstar/algorithm_library | 4c7f64ec61fc2ba059b64ad7ba20fcb5b838ced6 | [
"Unlicense"
] | 6 | 2017-01-03T14:17:58.000Z | 2021-01-22T10:37:04.000Z | #include <memory.h>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cctype>
#include <cstring>
#include <climits>
#include <cmath>
#include <vector>
#include <string>
#include <memory>
#include <numeric>
#include <limits>
#include <functional>
#include <tuple>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T>
struct DPConvexHullTrickMin {
struct Line {
T m, b; // f(x) = m * x + b
template <typename U>
inline T get(U x) const {
return m * x + b;
}
};
deque<Line> lines;
// when Xs of queries (not insert) are ascending, x[j] <= x[j + 1]
// PRECONDITION: m[k] >= m[k + 1]
void insert(T m, T b) {
Line l{ m, b };
while (lines.size() > 1 && ccw(lines[lines.size() - 2], lines[lines.size() - 1], l))
lines.pop_back();
lines.push_back(l);
}
// when Xs of queries (not insert) are descending, x[j] >= x[j + 1]
// PRECONDITION: m[k] <= m[k + 1]
void insertReverse(T m, T b) {
Line l{ m, b };
while (lines.size() > 1 && cw(lines[lines.size() - 2], lines[lines.size() - 1], l))
lines.pop_back();
lines.push_back(l);
}
template <typename U>
T query(U x) {
if (lines.empty())
return 0;
while (lines.size() > 1 && lines[0].get(x) >= lines[1].get(x))
lines.pop_front();
return lines[0].get(x);
}
private:
static T area(const Line& a, const Line& b, const Line& c) {
T ax = (b.m - a.m);
T bx = (c.b - a.b);
T ay = (c.m - a.m);
T by = (b.b - a.b);
return ax * bx - ay * by;
}
static bool ccw(const Line& a, const Line& b, const Line& c) {
return area(a, b, c) >= 0;
}
static bool cw(const Line& a, const Line& b, const Line& c) {
return area(a, b, c) <= 0;
}
};
vector<ll> A;
vector<ll> S;
vector<ll> SS;
ll dfs(int L, int R) {
if (L >= R)
return LLONG_MIN;
else if (L + 1 == R)
return 2ll * A[L] * A[R];
int mid = L + (R - L) / 2;
vector<int> idxL(mid - L + 1);
iota(idxL.begin(), idxL.end(), L);
sort(idxL.begin(), idxL.end(), [](int l, int r) {
return S[l] > S[r];
});
vector<int> idxR(R - mid);
iota(idxR.begin(), idxR.end(), mid + 2);
sort(idxR.begin(), idxR.end(), [](int l, int r) {
return S[l] < S[r];
});
DPConvexHullTrickMin<ll> cht;
for (int i : idxL)
cht.insert(2ll * S[i], -(S[i] * S[i] + SS[i]));
ll ans = 0;
for (int i : idxR) {
ans = max(ans, (S[i] * S[i] - SS[i]) - cht.query(S[i]));
}
ans = max(ans, dfs(L, mid));
ans = max(ans, dfs(mid + 1, R));
return ans;
}
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
A.resize(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
S.resize(N + 1);
SS.resize(N + 1);
for (int i = 0; i < N; i++) {
S[i + 1] = S[i] + A[i];
SS[i + 1] = SS[i] + A[i] * A[i];
}
cout << dfs(0, N - 1) / 2 << endl;
return 0;
}
| 21.443038 | 92 | 0.50059 | bluedawnstar |
38bf463491986681aa355362927a8775170e4052 | 8,211 | cc | C++ | third_party/parallel-inet/src/linklayer/ieee80211/mgmt/Ieee80211MgmtBase.cc | eniac/MimicNet | c0790679f8c220c75c33ace67e2735816aac6815 | [
"MIT"
] | 15 | 2021-08-20T08:10:01.000Z | 2022-03-24T21:24:50.000Z | third_party/parallel-inet/src/linklayer/ieee80211/mgmt/Ieee80211MgmtBase.cc | eniac/MimicNet | c0790679f8c220c75c33ace67e2735816aac6815 | [
"MIT"
] | 1 | 2022-03-30T09:03:39.000Z | 2022-03-30T09:03:39.000Z | third_party/parallel-inet/src/linklayer/ieee80211/mgmt/Ieee80211MgmtBase.cc | eniac/MimicNet | c0790679f8c220c75c33ace67e2735816aac6815 | [
"MIT"
] | 3 | 2021-08-20T08:10:34.000Z | 2021-12-02T06:15:02.000Z | //
// Copyright (C) 2006 Andras Varga
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//
#include "Ieee80211MgmtBase.h"
#include "Ieee802Ctrl_m.h"
#include "LifecycleOperation.h"
#include "NodeOperations.h"
#include "NodeStatus.h"
simsignal_t Ieee80211MgmtBase::dataQueueLenSignal = registerSignal("dataQueueLen");
static std::ostream& operator<<(std::ostream& out, cMessage *msg)
{
out << "(" << msg->getClassName() << ")" << msg->getFullName();
return out;
}
void Ieee80211MgmtBase::initialize(int stage)
{
if (stage == 0)
{
PassiveQueueBase::initialize();
dataQueue.setName("wlanDataQueue");
mgmtQueue.setName("wlanMgmtQueue");
emit(dataQueueLenSignal, dataQueue.length());
numDataFramesReceived = 0;
numMgmtFramesReceived = 0;
numMgmtFramesDropped = 0;
WATCH(numDataFramesReceived);
WATCH(numMgmtFramesReceived);
WATCH(numMgmtFramesDropped);
// configuration
frameCapacity = par("frameCapacity");
}
else if (stage == 1)
{
NodeStatus *nodeStatus = dynamic_cast<NodeStatus *>(findContainingNode(this)->getSubmodule("status"));
isOperational = (!nodeStatus) || nodeStatus->getState() == NodeStatus::UP;
// obtain our address from MAC
cModule *mac = getParentModule()->getSubmodule("mac");
if (!mac)
error("MAC module not found; it is expected to be next to this submodule and called 'mac'");
myAddress.setAddress(mac->par("address").stringValue());
}
}
void Ieee80211MgmtBase::handleMessage(cMessage *msg)
{
if (!isOperational)
throw cRuntimeError("Message '%s' received when module is OFF", msg->getName());
if (msg->isSelfMessage())
{
// process timers
EV << "Timer expired: " << msg << "\n";
handleTimer(msg);
}
else if (msg->arrivedOn("macIn"))
{
// process incoming frame
EV << "Frame arrived from MAC: " << msg << "\n";
Ieee80211DataOrMgmtFrame *frame = check_and_cast<Ieee80211DataOrMgmtFrame *>(msg);
processFrame(frame);
}
else if (msg->arrivedOn("agentIn"))
{
// process command from agent
EV << "Command arrived from agent: " << msg << "\n";
int msgkind = msg->getKind();
cObject *ctrl = msg->removeControlInfo();
delete msg;
handleCommand(msgkind, ctrl);
}
else
{
// packet from upper layers, to be sent out
cPacket *pk = PK(msg);
EV << "Packet arrived from upper layers: " << pk << "\n";
if (pk->getByteLength() > 2312)
error("message from higher layer (%s)%s is too long for 802.11b, %d bytes (fragmentation is not supported yet)",
pk->getClassName(), pk->getName(), (int)(pk->getByteLength()));
handleUpperMessage(pk);
}
}
void Ieee80211MgmtBase::sendOrEnqueue(cPacket *frame)
{
ASSERT(isOperational);
PassiveQueueBase::handleMessage(frame);
}
cMessage *Ieee80211MgmtBase::enqueue(cMessage *msg)
{
ASSERT(dynamic_cast<Ieee80211DataOrMgmtFrame *>(msg)!=NULL);
bool isDataFrame = dynamic_cast<Ieee80211DataFrame *>(msg)!=NULL;
if (!isDataFrame)
{
// management frames are inserted into mgmtQueue
mgmtQueue.insert(msg);
return NULL;
}
else if (frameCapacity && dataQueue.length() >= frameCapacity)
{
EV << "Queue full, dropping packet.\n";
return msg;
}
else
{
dataQueue.insert(msg);
emit(dataQueueLenSignal, dataQueue.length());
return NULL;
}
}
bool Ieee80211MgmtBase::isEmpty()
{
if (!mgmtQueue.empty())
return false;
return dataQueue.empty();
}
cMessage *Ieee80211MgmtBase::dequeue()
{
// management frames have priority
if (!mgmtQueue.empty())
return (cMessage *)mgmtQueue.pop();
// return a data frame if we have one
if (dataQueue.empty())
return NULL;
cMessage *pk = (cMessage *)dataQueue.pop();
// statistics
emit(dataQueueLenSignal, dataQueue.length());
return pk;
}
void Ieee80211MgmtBase::sendOut(cMessage *msg)
{
ASSERT(isOperational);
send(msg, "macOut");
}
void Ieee80211MgmtBase::dropManagementFrame(Ieee80211ManagementFrame *frame)
{
EV << "ignoring management frame: " << (cMessage *)frame << "\n";
delete frame;
numMgmtFramesDropped++;
}
void Ieee80211MgmtBase::sendUp(cMessage *msg)
{
ASSERT(isOperational);
send(msg, "upperLayerOut");
}
void Ieee80211MgmtBase::processFrame(Ieee80211DataOrMgmtFrame *frame)
{
switch (frame->getType())
{
case ST_DATA:
numDataFramesReceived++;
handleDataFrame(check_and_cast<Ieee80211DataFrame *>(frame));
break;
case ST_AUTHENTICATION:
numMgmtFramesReceived++;
handleAuthenticationFrame(check_and_cast<Ieee80211AuthenticationFrame *>(frame));
break;
case ST_DEAUTHENTICATION:
numMgmtFramesReceived++;
handleDeauthenticationFrame(check_and_cast<Ieee80211DeauthenticationFrame *>(frame));
break;
case ST_ASSOCIATIONREQUEST:
numMgmtFramesReceived++;
handleAssociationRequestFrame(check_and_cast<Ieee80211AssociationRequestFrame *>(frame));
break;
case ST_ASSOCIATIONRESPONSE:
numMgmtFramesReceived++;
handleAssociationResponseFrame(check_and_cast<Ieee80211AssociationResponseFrame *>(frame));
break;
case ST_REASSOCIATIONREQUEST:
numMgmtFramesReceived++;
handleReassociationRequestFrame(check_and_cast<Ieee80211ReassociationRequestFrame *>(frame));
break;
case ST_REASSOCIATIONRESPONSE:
numMgmtFramesReceived++;
handleReassociationResponseFrame(check_and_cast<Ieee80211ReassociationResponseFrame *>(frame));
break;
case ST_DISASSOCIATION:
numMgmtFramesReceived++;
handleDisassociationFrame(check_and_cast<Ieee80211DisassociationFrame *>(frame));
break;
case ST_BEACON:
numMgmtFramesReceived++;
handleBeaconFrame(check_and_cast<Ieee80211BeaconFrame *>(frame));
break;
case ST_PROBEREQUEST:
numMgmtFramesReceived++;
handleProbeRequestFrame(check_and_cast<Ieee80211ProbeRequestFrame *>(frame));
break;
case ST_PROBERESPONSE:
numMgmtFramesReceived++;
handleProbeResponseFrame(check_and_cast<Ieee80211ProbeResponseFrame *>(frame));
break;
default:
throw cRuntimeError("Unexpected frame type (%s)%s", frame->getClassName(), frame->getName());
}
}
bool Ieee80211MgmtBase::handleOperationStage(LifecycleOperation *operation, int stage, IDoneCallback *doneCallback)
{
Enter_Method_Silent();
if (dynamic_cast<NodeStartOperation *>(operation)) {
if (stage == NodeStartOperation::STAGE_PHYSICAL_LAYER)
start();
}
else if (dynamic_cast<NodeShutdownOperation *>(operation)) {
if (stage == NodeStartOperation::STAGE_PHYSICAL_LAYER)
stop();
}
else if (dynamic_cast<NodeCrashOperation *>(operation)) {
if (stage == NodeStartOperation::STAGE_LOCAL) // crash is immediate
stop();
}
else
throw cRuntimeError("Unsupported operation '%s'", operation->getClassName());
return true;
}
void Ieee80211MgmtBase::start()
{
isOperational = true;
}
void Ieee80211MgmtBase::stop()
{
clear();
dataQueue.clear();
emit(dataQueueLenSignal, dataQueue.length());
mgmtQueue.clear();
isOperational = false;
}
| 29.325 | 124 | 0.659603 | eniac |
38c8bc38965a627cc6e62aa970ee44cfe1233a13 | 1,554 | cpp | C++ | atcoder/abc/abc112/c.cpp | yu3mars/proconVSCodeGcc | fcf36165bb14fb6f555664355e05dd08d12e426b | [
"MIT"
] | null | null | null | atcoder/abc/abc112/c.cpp | yu3mars/proconVSCodeGcc | fcf36165bb14fb6f555664355e05dd08d12e426b | [
"MIT"
] | null | null | null | atcoder/abc/abc112/c.cpp | yu3mars/proconVSCodeGcc | fcf36165bb14fb6f555664355e05dd08d12e426b | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};
int main()
{
int n,ansx,ansy,ansh=-1;
cin>>n;
vector<int> x(n),y(n),h(n);
int xx,yy,hh;
for(int i = 0; i < n; i++)
{
cin>>x[i]>>y[i]>>h[i];
if(h[i]>0)
{
xx=x[i];
yy=y[i];
hh=h[i];
}
}
for(int tmpx = 0; tmpx < 101; tmpx++)
{
for(int tmpy = 0; tmpy < 101; tmpy++)
{
bool ok=true;
bool kakutei =false;
int tmph = hh + abs(tmpx-xx)+abs(tmpy-yy);
for(int info = 0; info < n; info++)
{
int diff= abs(tmpx-x[info])+abs(tmpy-y[info]);
if(tmph!=diff+h[info])
{
if(h[info]==0 && diff>tmph)
{
continue;
}
else
{
ok=false;
break;
}
}
}
if(ok)
{
ansx=tmpx;
ansy=tmpy;
ansh=tmph;
break;
}
}
if(ansh>0)break;
}
cout<<ansx<<" "<<ansy<<" "<<ansh<<endl;
return 0;
} | 22.2 | 62 | 0.348777 | yu3mars |
38cb167cbc035c414f1a569d9f42e3397ae5f0f3 | 1,824 | cpp | C++ | trick_source/sim_services/Executive/Executive_add_depends_on_job.cpp | gilbertguoze/trick | f0537efb0fa3cb5c0c84e36b60f055c1d1c60d21 | [
"NASA-1.3"
] | 647 | 2015-05-07T16:08:16.000Z | 2022-03-30T02:33:21.000Z | trick_source/sim_services/Executive/Executive_add_depends_on_job.cpp | gilbertguoze/trick | f0537efb0fa3cb5c0c84e36b60f055c1d1c60d21 | [
"NASA-1.3"
] | 995 | 2015-04-30T19:44:31.000Z | 2022-03-31T20:14:44.000Z | trick_source/sim_services/Executive/Executive_add_depends_on_job.cpp | gilbertguoze/trick | f0537efb0fa3cb5c0c84e36b60f055c1d1c60d21 | [
"NASA-1.3"
] | 251 | 2015-05-15T09:24:34.000Z | 2022-03-22T20:39:05.000Z |
#include <iostream>
#include <sstream>
#include "trick/Executive.hh"
#include "trick/message_proto.h"
#include "trick/message_type.h"
/**
@details
-# Find target job. Return error if target job not found.
-# Find depends job. Return error if depends job not found.
-# Return an error if both jobs are on the same thread.
-# The depend passed all checks, add the depends job to the target job dependency list
*/
int Trick::Executive::add_depends_on_job( std::string target_job_string , unsigned int t_instance ,
std::string depend_job_string , unsigned int d_instance ) {
Trick::JobData * target_job ;
Trick::JobData * depend_job ;
/* Find target job. Return error if target job not found. */
target_job = get_job(target_job_string, t_instance) ;
if ( target_job == NULL ) {
message_publish(MSG_ERROR, "add_depends_on_job: Could not find target job %s instance %d\n",
target_job_string.c_str(), t_instance) ;
return(-1) ;
}
/* Find depends job. Return error if depends job not found. */
depend_job = get_job(depend_job_string, d_instance) ;
if ( depend_job == NULL ) {
message_publish(MSG_ERROR, "add_depends_on_job: Could not find depend job %s instance %d\n",
depend_job_string.c_str(), d_instance) ;
return(-2) ;
}
/* Return an error if both jobs are on the same thread */
if( target_job->thread == depend_job->thread) {
message_publish(MSG_ERROR, "add_depends_on_job: target job %s and depend job %s on the same thread",
target_job_string.c_str() , depend_job_string.c_str()) ; ;
return(-3) ;
}
/* Passed all checks, add the depends job to the target job dependency list */
target_job->add_depend(depend_job) ;
return(0) ;
}
| 35.764706 | 108 | 0.666667 | gilbertguoze |
38ccda3f9728c41d4a8831bf3404a7f05bc3d9f1 | 628 | cpp | C++ | USACO Bronze/US Open 2016 Contest/diamond.cpp | Alecs-Li/Competitive-Programming | 39941ff8e2c8994abbae8c96a1ed0a04b10058b8 | [
"MIT"
] | 1 | 2021-07-06T02:14:03.000Z | 2021-07-06T02:14:03.000Z | USACO Bronze/US Open 2016 Contest/diamond.cpp | Alex01890-creator/competitive-programming | 39941ff8e2c8994abbae8c96a1ed0a04b10058b8 | [
"MIT"
] | null | null | null | USACO Bronze/US Open 2016 Contest/diamond.cpp | Alex01890-creator/competitive-programming | 39941ff8e2c8994abbae8c96a1ed0a04b10058b8 | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
freopen("diamond.in", "r", stdin);
freopen("diamond.out", "w", stdout);
int n, k; cin >> n >> k;
int arr[n], ans = 0, count = 0;
for(int a=0; a<n; a++){
cin >> arr[a];
}
for(int a=0; a<n; a++){
for(int b=0; b<n; b++){
if(arr[b] >= arr[a] && arr[b] <= arr[a] + k ){
count += 1;
}
}
ans = max(count, ans);
count = 0;
for(int b=0; b<n; b++){
if(arr[b] >= arr[a] - k && arr[b] <= arr[a]){
count += 1;
}
}
ans = max(count, ans);
count = 0;
}
cout << ans;
}
| 19.625 | 52 | 0.43949 | Alecs-Li |
38d051669de19e256aee72ad6f50ffa9246219ac | 13,780 | hpp | C++ | include/GMM.hpp | tim-krebs/GMM | f51872c7867d56f5cd161689ac760a31eb8bb11f | [
"MIT"
] | null | null | null | include/GMM.hpp | tim-krebs/GMM | f51872c7867d56f5cd161689ac760a31eb8bb11f | [
"MIT"
] | null | null | null | include/GMM.hpp | tim-krebs/GMM | f51872c7867d56f5cd161689ac760a31eb8bb11f | [
"MIT"
] | null | null | null | #pragma once
#include<string>
#include<vector>
#include<map>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <math.h>
#include "Kmeans.hpp"
struct Model
{
std::vector<double> weight;
std::vector<std::vector<double> > mean;
std::vector<std::vector<double> > covariance;
std::vector<std::vector<double> > invert_covariance;
std::vector<double> ExpCoeff;
};
class GMM
{
private:
/* data */
Model newModel();
void delModel(Model model);
void completeModel(Model& model);
double Likelihood(const std::vector<std::vector<double>>& melCepData, size_t frameCount, Model model, std::vector<std::vector<double>>& normProb, std::vector<double>& mixedProb);
int m_MixDim;
int m_MfccDim;
double m_Threshold;
double m_MinCov;
Model m_Model;
int number_gaussian_components;
std::map<std::string, Model> m_Models;
const double PI2 = 6.28318530717958647692;
public:
GMM();
virtual ~GMM();
int Expectation_Maximation(const std::vector<std::vector<double> > melCepData, size_t frameCount);
std::string Classify(const std::vector<std::vector<double> > &melCepData, size_t frameCount);
double Likelihood(const std::vector<std::vector<double> > &melCepData, size_t frameCount);
bool LoadModel(const std::string& filePath);
bool SaveModel(const std::string& filePath);
bool AddModel(const std::string& name);
bool AddModel(const std::string& filePath, const std::string& name);
};
/**
* @brief Construct a new GMM::GMM object
*
*/
GMM::GMM()
{
// Set the mfcc dimension
// Set the mixture dimensions
m_MixDim = 12;
m_MfccDim= 12;
// Set break statement for testing
m_Threshold = 0.005;
m_MinCov = 0.015;
// Create Models
m_Model = newModel();
}
GMM::~GMM()
{
delModel(m_Model);
std::map<std::string, Model>::const_iterator it = m_Models.begin();
while(it != m_Models.end())
{
delModel(it->second);
++it;
}
m_Models.clear();
}
/**
* @brief Train the GMM with EM-Algorithm
* E: estimation step
* M: maximation step
*
* @param melCepData (2d-vector) matrix contains the frames with features: melCepData(frames x 39)
* @param frameCount (size_t) number of frames
* @return (int) number of training iterations
*/
int GMM::Expectation_Maximation(const std::vector<std::vector<double> > melCepData, size_t frameCount)
{
int step;
int iteration = 0;
double newProb;
double recentProb = 0.0;
std::vector<double> sumProb(m_MixDim);
std::vector<double> mixedProb(frameCount);
std::vector<std::vector<double>> normProb(frameCount, std::vector<double>(m_MixDim));
std::vector<std::vector<double>> tempProb(m_MfccDim, std::vector<double>(m_MixDim));
std::vector<std::vector<double>> squareCep(frameCount, std::vector<double>(m_MfccDim));
//*** Initialization
for(int i = 0; i < m_MixDim; i++)
{
m_Model.weight[i] = 1.0 / m_MixDim;
}
step = (int)floor(frameCount / m_MixDim);
for(int j = 0; j < m_MixDim; j++)
{
for(int i = 0; i < m_MfccDim; i++)
{
m_Model.mean[i][j] = melCepData[step * (j + 1) -1][i];
}
}
for(int i = 0; i < m_MixDim; i++)
{
for(int j = 0; j < m_MfccDim; j++)
{
m_Model.covariance[i][j] = 1.0;
}
}
for(size_t i = 0; i < frameCount; i++)
{
for(int j = 0; j < m_MfccDim; j++)
{
squareCep[i][j] = melCepData[i][j] * melCepData[i][j];
}
}
// Iterative processing
// EM-Algorithm
while(true)
{
completeModel(m_Model);
newProb = Likelihood(melCepData, frameCount, m_Model, normProb, mixedProb);
// E process, a probability matrix, n*m_MixDim
for(size_t i = 0; i < frameCount; i++)
{
for(int j = 0; j < m_MixDim; j++)
{
normProb[i][j] *= m_Model.weight[j] / mixedProb[i];
}
}
// M process
for(int i = 0; i < m_MixDim; i++)
{
sumProb[i] = 0.0;
for(size_t j = 0; j < frameCount; j++)
{
sumProb[i] += normProb[j][i];
}
}
// renew mixture coefficients
for(int i = 0; i < m_MixDim; i++)
{
m_Model.weight[i] = sumProb[i] / frameCount;
}
// renew mean
for(int i = 0; i < m_MfccDim; i++)
{
for(int j = 0; j < m_MixDim; j++)
{
tempProb[i][j] = 0.0;
for(size_t k = 0; k < frameCount; k++)
tempProb[i][j] += melCepData[k][i] * normProb[k][j];
m_Model.mean[i][j] = tempProb[i][j] / sumProb[j];
}
}
// renew covariance
for(int i = 0; i < m_MixDim; i++)
{
for(int j = 0; j < m_MfccDim; j++)
{
tempProb[j][i] = 0.0;
for(size_t k = 0; k < frameCount; k++)
{
tempProb[j][i] += squareCep[k][j] * normProb[k][i];
}
tempProb[j][i] = tempProb[j][i] / sumProb[i];
}
}
// set covariance
for(int i = 0; i < m_MixDim; i++)
{
for(int j = 0; j < m_MfccDim; j++)
{
m_Model.covariance[i][j] = tempProb[j][i] - m_Model.mean[j][i] * m_Model.mean[j][i];
if(m_Model.covariance[i][j] <= m_MinCov)
{
m_Model.covariance[i][j] = m_MinCov;
}
}
}
// prepare for next iteration
recentProb = newProb;
iteration++;
if(iteration > 19) break;
}
tempProb.clear();
normProb.clear();
sumProb.clear();
mixedProb.clear();
return iteration;
}
/**
* @brief Decoder of the GMM
*
* @param melCepData (2d-vector) matrix contains the frames with features: melCepData(frames x 39)
* @param frameCount (size_t) number of frames
* @return (string) returns the recognized name
*/
std::string GMM::Classify(const std::vector<std::vector<double> >& melCepData, size_t frameCount)
{
double likelihood;
double probMax = 0;
std::string name;
bool first = true;
std::vector<double> mixedProb;
std::vector<std::vector<double> > normProb;
std::map<std::string, Model>::const_iterator it = m_Models.begin();
std::map<std::string, Model>::const_iterator itEnd = m_Models.end();
mixedProb.resize(frameCount);
normProb.resize(frameCount);
for(size_t i = 0; i < frameCount; i++)
{
normProb[i].resize(m_MixDim);
}
while(it != itEnd)
{
likelihood = Likelihood(melCepData, frameCount, it->second, normProb, mixedProb);
if((first == true) || (probMax <= likelihood))
{
probMax = likelihood;
name = it->first;
first = false;
}
++it;
}
normProb.clear();
mixedProb.clear();
return name;
}
/**
* @brief Calculates the Probability for each frame
*
* @param melCepData (2d-vector) matrix contains the frames with features: melCepData(frames x 39)
* @param frameCount (size_t) number of frames
* @return (double) returns probability
*/
double GMM::Likelihood(const std::vector<std::vector<double> >& melCepData, size_t frameCount)
{
double prob;
std::vector<double> mixedProb;
std::vector<std::vector<double> > normProb;
mixedProb.resize(frameCount);
normProb.resize(frameCount);
for(size_t i = 0; i<frameCount; i++)
{
normProb[i].resize(m_MixDim);
}
prob = Likelihood(melCepData, frameCount, m_Model, normProb, mixedProb);
normProb.clear();
mixedProb.clear();
return prob;
}
/**
* @brief GMM model saver to text files
*
* @param filePath (string) Filepath to save location
* @return true if the action was successful
*/
bool GMM::SaveModel(const std::string& filePath)
{
std::ofstream outFile(filePath);
if(!outFile.is_open())
{
return false;
}
outFile << std::fixed << std::setprecision(6);
outFile << "mixcoef:" << std::endl;
for(int i = 0; i < m_MixDim; i++)
{
outFile << m_Model.weight[i] << " ";
}
outFile << std::endl << "mean:" << std::endl;
for(int i = 0; i < m_MfccDim; i++)
{
for(int j = 0; j < m_MixDim; j++)
{
outFile << m_Model.mean[i][j] << " ";
}
outFile << std::endl;
}
outFile << "covariance:" << std::endl;
for(int i = 0; i < m_MixDim; i++)
{
for(int j = 0; j < m_MfccDim; j++)
{
outFile << m_Model.covariance[i][j] << " ";
}
outFile << std::endl;
}
outFile.close();
return true;
}
/**
* @brief Model loader from save location
*
* @param filePath (string) File path to saved location
* @return true if the action was successful
*/
bool GMM::LoadModel(const std::string& filePath)
{
std::string title;
std::ifstream inFile(filePath, std::ifstream::in);
if(!inFile.is_open())
{
return false;
}
inFile >> title;
for(int i = 0; i < m_MixDim; i++)
{
inFile >> m_Model.weight[i];
}
inFile >> title;
for(int i = 0; i < m_MfccDim; i++)
{
for(int j = 0; j < m_MixDim; j++)
{
inFile >> m_Model.mean[i][j];
}
}
inFile >> title;
for(int i=0; i<m_MixDim; i++)
{
for(int j=0; j<m_MfccDim; j++)
{
inFile >> m_Model.covariance[i][j];
}
}
inFile.close();
completeModel(m_Model);
return true;
}
/**
* @brief Create new statistical Model with initial parameters
*
* @param word (string)
* @return
*/
bool GMM::AddModel(const std::string& word)
{
// Create new Model
Model model;
model = newModel();
for(int i = 0; i < m_MixDim; i++)
{
model.weight[i] = m_Model.weight[i];
model.ExpCoeff[i] = m_Model.ExpCoeff[i];
}
for(int i = 0; i < m_MfccDim; i++)
{
for(int j = 0; j < m_MixDim; j++)
{
model.mean[i][j] = m_Model.mean[i][j];
model.covariance[j][i] = m_Model.covariance[j][i];
model.invert_covariance[j][i] = m_Model.invert_covariance[j][i];
}
}
m_Models[word] = model;
return true;
}
/**
* @brief
*
* @param filePath (string) Filepath to load location
* @param word (string)
* @return
*/
bool GMM::AddModel(const std::string& filePath, const std::string& word)
{
if(!LoadModel(filePath))
{
return false;
}
// Add Model to modelset
AddModel(word);
return true;
}
/**
* @brief Computes the Likelihoof for each frame
*
* @param melCepData (double) 2D Matrix of MFCC data
* @param frameCount (size_t) Number of frames
* @param model (struct) Struct of GMM Models
* @param normProb (double) 2D Matrix of NormalPrabability
* @param mixedProb (double) Vector of mixed Probability
* @return (double) Likelihood
*/
double GMM::Likelihood(const std::vector<std::vector<double> > &melCepData, size_t frameCount, Model model, std::vector<std::vector<double> > &normProb, std::vector<double> &mixedProb)
{
double prob = 0.0;
std::vector<double> maxMatrix(frameCount);
std::vector<std::vector<double> > expMatrix(frameCount, std::vector<double>(m_MixDim, 0));
for(size_t i = 0; i < frameCount; i++ )
{
for(int j = 0; j < m_MixDim; j++)
{
for(int k = 0; k < m_MfccDim; k++)
{
expMatrix[i][j] += (pow((melCepData[i][k] - model.mean[k][j]),2 )) * model.invert_covariance[j][k];
}
}
}
for(size_t i = 0; i < frameCount; i++)
{
auto it = max_element(expMatrix[i].begin(), expMatrix[i].end());
maxMatrix[i] = *it;
}
// calculate Probability for each frame
for(size_t i = 0; i < frameCount; i++)
{
mixedProb[i] = 0.0;
for(int j = 0; j < m_MixDim; j++)
{
expMatrix[i][j] = exp(expMatrix[i][j] - maxMatrix[i]);
normProb[i][j] = expMatrix[i][j] * model.ExpCoeff[j];
mixedProb[i] = mixedProb[i] + normProb[i][j] * model.weight[j];
}
prob += log(mixedProb[i]) + maxMatrix[i];
}
expMatrix.clear();
maxMatrix.clear();
return prob;
}
/**
* @brief Creates new Initial GMM Model
*
* @return New GMM model with initial parameters
*/
Model GMM::newModel()
{
Model model;
model.weight.resize(m_MixDim);
model.mean.resize(m_MfccDim);
for(int i = 0; i < m_MfccDim; i++)
{
model.mean[i].resize(m_MixDim);
}
// Resize matrix to m_MixDim (number of mixtures)
model.covariance.resize(m_MixDim);
model.invert_covariance.resize(m_MixDim);
for(int i = 0; i < m_MixDim; i++)
{
model.covariance[i].resize(m_MfccDim);
model.invert_covariance[i].resize(m_MfccDim);
}
model.ExpCoeff.resize(m_MixDim);
return model;
}
/**
* @brief Deletes allcreated models
*
* @param model (struct) struct of models
*/
void GMM::delModel(Model model)
{
model.weight.clear();
model.mean.clear();
model.covariance.clear();
model.invert_covariance.clear();
model.ExpCoeff.clear();
}
/**
* @brief
*
* @param model
*/
void GMM::completeModel(Model& model)
{
double x = pow(PI2, (-m_MfccDim / 2));
for(int i = 0; i < m_MixDim; i++)
{
model.ExpCoeff[i] = 1.0;
for(int j = 0; j < m_MfccDim; j++)
{
model.ExpCoeff[i] *= 1.0 / model.covariance[i][j];
}
model.ExpCoeff[i] = x * sqrt(model.ExpCoeff[i]);
}
for(int i = 0; i < m_MixDim; i++)
{
for(int j = 0; j < m_MfccDim; j++)
{
model.invert_covariance[i][j] = (-0.5) / model.covariance[i][j];
}
}
}
| 23.717728 | 184 | 0.567489 | tim-krebs |
38d16510073f892d9569760d3ca9fdf47c14f3ce | 9,123 | cpp | C++ | programs/core/abc_cli.cpp | eletesta/cirkit | 6d0939798ea25cecf92306ce796be154139b94f5 | [
"MIT"
] | null | null | null | programs/core/abc_cli.cpp | eletesta/cirkit | 6d0939798ea25cecf92306ce796be154139b94f5 | [
"MIT"
] | null | null | null | programs/core/abc_cli.cpp | eletesta/cirkit | 6d0939798ea25cecf92306ce796be154139b94f5 | [
"MIT"
] | null | null | null | /* CirKit: A circuit toolkit
* Copyright (C) 2009-2015 University of Bremen
* Copyright (C) 2015-2017 EPFL
*
* 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.
*/
/**
* This is a demonstration of the CLI API
*
* We show how to make a simple Mini ABC version based on the CLI API
*
* @author Mathias Soeken
*/
#include <boost/format.hpp>
#include <alice/command.hpp>
#include <alice/alice.hpp>
#include <base/wlc/wlc.h>
#include <aig/gia/gia.h>
namespace alice
{
/******************************************************************************
* store entry abc::Gia_Man_t* *
******************************************************************************/
/* register abc::Gia_Man_t* as store element for AIGs */
template<>
struct store_info<abc::Gia_Man_t*>
{
static constexpr const char* key = "aigs"; /* internal key, must be unique for each store */
static constexpr const char* option = "aig"; /* long flag for general commands, e.g., `store --aig` */
static constexpr const char* mnemonic = "a"; /* short flag for general commands, e.g., `store -a` */
static constexpr const char* name = "AIG"; /* singular name for option descriptions */
static constexpr const char* name_plural = "AIGs"; /* plural name for option descriptions */
};
/* I/O tag to implement `read_aiger` and `write_aiger` */
struct io_aiger_tag_t {};
/* return some short text for each AIG in `store -a` */
template<>
inline std::string store_entry_to_string<abc::Gia_Man_t*>( abc::Gia_Man_t* const& aig )
{
return boost::str( boost::format( "%s i/o = %d/%d" ) % abc::Gia_ManName( aig ) % abc::Gia_ManPiNum( aig ) % abc::Gia_ManPoNum( aig ) );
}
/* print statistics on `ps -a` */
template<>
inline void print_store_entry_statistics<abc::Gia_Man_t*>( std::ostream& os, abc::Gia_Man_t* const& aig )
{
abc::Gps_Par_t Pars;
memset( &Pars, 0, sizeof(abc::Gps_Par_t) );
abc::Gia_ManPrintStats( aig, &Pars );
}
/* enable `read_aiger` for AIGs */
template<>
inline bool store_can_read_io_type<abc::Gia_Man_t*, io_aiger_tag_t>( command& cmd )
{
return true;
}
/* implement `read_aiger` for AIGs */
template<>
inline abc::Gia_Man_t* store_read_io_type<abc::Gia_Man_t*, io_aiger_tag_t>( const std::string& filename, const command& cmd )
{
return abc::Gia_AigerRead( (char*)filename.c_str(), 0, 0, 0 );
}
/* enable `write_aiger` for AIGs */
template<>
inline bool store_can_write_io_type<abc::Gia_Man_t*, io_aiger_tag_t>( command& cmd )
{
return true;
}
/* implement `write_aiger` for AIGs */
template<>
inline void store_write_io_type<abc::Gia_Man_t*, io_aiger_tag_t>( abc::Gia_Man_t* const& aig, const std::string& filename, const command& cmd )
{
abc::Gia_AigerWrite( aig, (char*)filename.c_str(), 1, 0 );
}
/******************************************************************************
* store entry abc::Wlc_Ntk_t* *
******************************************************************************/
/* register abc::Wlc_Ntk_t* as store element for word-level networks */
template<>
struct store_info<abc::Wlc_Ntk_t*>
{
static constexpr const char* key = "wlcs"; /* internal key, must be unique for each store */
static constexpr const char* option = "wlc"; /* long flag for general commands, e.g., `store --aig` */
static constexpr const char* mnemonic = "w"; /* short flag for general commands, e.g., `store -a` */
static constexpr const char* name = "WLC"; /* singular name for option descriptions */
static constexpr const char* name_plural = "WLCs"; /* plural name for option descriptions */
};
/* I/O tag to implement `read_verilog` and `write_verilog` */
struct io_verilog_tag_t {};
/* return some short text for each WLC in `store -w` */
template<>
inline std::string store_entry_to_string<abc::Wlc_Ntk_t*>( abc::Wlc_Ntk_t* const& wlc )
{
return boost::str( boost::format( "%s i/o = %d/%d" ) % wlc->pName % abc::Wlc_NtkPiNum( wlc ) % abc::Wlc_NtkPoNum( wlc ) );
}
/* print statistics on `ps -w` */
template<>
inline void print_store_entry_statistics<abc::Wlc_Ntk_t*>( std::ostream& os, abc::Wlc_Ntk_t* const& wlc )
{
abc::Wlc_NtkPrintStats( wlc, 0, 0, 0 );
}
/* enable `read_verilog` for WLCs */
template<>
inline bool store_can_read_io_type<abc::Wlc_Ntk_t*, io_verilog_tag_t>( command& cmd )
{
return true;
}
/* implement `read_verilog` for WLCs */
template<>
inline abc::Wlc_Ntk_t* store_read_io_type<abc::Wlc_Ntk_t*, io_verilog_tag_t>( const std::string& filename, const command& cmd )
{
return abc::Wlc_ReadVer( (char*)filename.c_str(), nullptr );
}
/* enable `write_verilog` for WLCs */
template<>
inline bool store_can_write_io_type<abc::Wlc_Ntk_t*, io_verilog_tag_t>( command& cmd )
{
return true;
}
/* implement `write_verilog` for WLCs */
template<>
inline void store_write_io_type<abc::Wlc_Ntk_t*, io_verilog_tag_t>( abc::Wlc_Ntk_t* const& wlc, const std::string& filename, const command& cmd )
{
abc::Wlc_WriteVer( wlc, (char*)filename.c_str(), 0, 0 );
}
/******************************************************************************
* conversion *
******************************************************************************/
/* allow conversion from WLC to AIG with `convert --wlc_to_aig` */
template<>
inline bool store_can_convert<abc::Wlc_Ntk_t*, abc::Gia_Man_t*>()
{
return true;
}
template<>
abc::Gia_Man_t* store_convert<abc::Wlc_Ntk_t*, abc::Gia_Man_t*>( abc::Wlc_Ntk_t* const& wlc )
{
return abc::Wlc_NtkBitBlast( wlc, nullptr, -1, 2, 0, 0, 0, 0, 0, 0 );
}
/******************************************************************************
* custom commands *
******************************************************************************/
class miter_command : public command
{
public:
miter_command( const environment::ptr& env ) : command( env, "Create miter" )
{
opts.add_options()
( "id1", po::value( &id1 )->default_value( id1 ), "store id of first circuit" )
( "id2", po::value( &id2 )->default_value( id2 ), "store id of second circuit" )
( "new,n", "create new store entry" )
;
}
protected:
/* rules to check before execution:
*
* rules_t is a vector of pairs, each pair is a predicate and a string:
* predicates are checked in order, if they are false, the command is not executed and the string is
* outputted as error.
*/
rules_t validity_rules() const
{
return {
{ [this]() { return id1 != id2; }, "ids must be different" },
{ [this]() {
const auto& aigs = env->store<abc::Gia_Man_t*>();
return id1 < aigs.size() && id2 < aigs.size();
}, "ids are out of range" }
};
}
bool execute()
{
auto& aigs = env->store<abc::Gia_Man_t*>();
if ( is_set( "new" ) )
{
aigs.extend();
}
aigs.current() = abc::Gia_ManMiter( aigs[id1], aigs[id2], 0, 0, 0, 0, 0 );
return true;
}
log_opt_t log() const
{
return log_opt_t({
{"id1", id1},
{"id2", id2}
});
}
private:
unsigned id1 = 0;
unsigned id2 = 1;
};
}
/******************************************************************************
* main program *
******************************************************************************/
int main( int argc, char ** argv )
{
using namespace alice;
cli_main<abc::Gia_Man_t*, abc::Wlc_Ntk_t*> cli( "abc" );
cli.set_category( "I/O" );
ADD_READ_COMMAND( aiger, "Aiger" );
ADD_WRITE_COMMAND( aiger, "Aiger" );
ADD_READ_COMMAND( verilog, "Verilog" );
ADD_WRITE_COMMAND( verilog, "Verilog" );
cli.set_category( "Verification" );
ADD_COMMAND( miter );
return cli.run( argc, argv );
}
// Local Variables:
// c-basic-offset: 2
// eval: (c-set-offset 'substatement-open 0)
// eval: (c-set-offset 'innamespace 0)
// End:
| 33.29562 | 145 | 0.591034 | eletesta |
38d33995e5eae06285c45bde3e171a2edf327d09 | 1,196 | cpp | C++ | LeetCodeCPP/304. Range Sum Query 2D - Immutable/main.cpp | 18600130137/leetcode | fd2dc72c0b85da50269732f0fcf91326c4787d3a | [
"Apache-2.0"
] | 1 | 2019-03-29T03:33:56.000Z | 2019-03-29T03:33:56.000Z | LeetCodeCPP/304. Range Sum Query 2D - Immutable/main.cpp | 18600130137/leetcode | fd2dc72c0b85da50269732f0fcf91326c4787d3a | [
"Apache-2.0"
] | null | null | null | LeetCodeCPP/304. Range Sum Query 2D - Immutable/main.cpp | 18600130137/leetcode | fd2dc72c0b85da50269732f0fcf91326c4787d3a | [
"Apache-2.0"
] | null | null | null | //
// main.cpp
// 304. Range Sum Query 2D - Immutable
//
// Created by admin on 2019/7/12.
// Copyright © 2019年 liu. All rights reserved.
//
#include <iostream>
#include <vector>
using namespace std;
class NumMatrix {
private:
vector<vector<int>> mc; //matrixCumulative
int m=0,n=0;
int a(int i,int j){
return i>=0&&j>=0?mc[i][j]:0;
}
public:
NumMatrix(vector<vector<int>>& matrix) {
mc =matrix;
m=mc.size();
if(m==0){
return;
}
n=mc[0].size();
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
mc[i][j]+=a(i-1,j)+a(i,j-1)-a(i-1,j-1);
}
}
}
int sumRegion(int row1, int col1, int row2, int col2) {
if(m==0 || n==0){
return -1;
}
return mc[row2][col2]-a(row2,col1-1)-a(row1-1,col2)+a(row1-1,col1-1);
}
};
int main(int argc, const char * argv[]) {
vector<vector<int>> input={{3,0,1,4,2},{5,6,3,2,1},{1,2,0,1,5},{4,1,0,1,7},{1,0,3,0,5}};
NumMatrix* obj = new NumMatrix(input);
int ret=obj->sumRegion(1, 2, 2, 4);
cout<<"The ret is:"<<ret<<endl;
return 0;
}
| 22.566038 | 92 | 0.485786 | 18600130137 |
38d9b46b19f37afdf68b7db37be568fff6db41b1 | 685 | cpp | C++ | chapter21/Combat.cpp | UncleCShark/CppIn24HoursWithCmake | 7d1f30906fed2c7d144e5495ad42a3a9a59d2dce | [
"MIT"
] | null | null | null | chapter21/Combat.cpp | UncleCShark/CppIn24HoursWithCmake | 7d1f30906fed2c7d144e5495ad42a3a9a59d2dce | [
"MIT"
] | null | null | null | chapter21/Combat.cpp | UncleCShark/CppIn24HoursWithCmake | 7d1f30906fed2c7d144e5495ad42a3a9a59d2dce | [
"MIT"
] | null | null | null | #include <iostream>
int main()
{
// define character values
int strength;
double accuracy;
int dexterity;
// define constants
const double maximum = 50;
// get user input
std::cout << "\nEnter strength (1-100): ";
std::cin >> strength;
std::cout << "\nEnter accuracy (1-50): ";
std::cin >> accuracy;
std::cout << "\nEnter dexterity (1-50): ";
std::cin >> dexterity;
// calculate character combat stats
double attack = strength * (accuracy / maximum);
double damage = strength * (dexterity / maximum);
std::cout << "\nAttack rating: " << attack << "\n";
std::cout << "Damage rating: " << damage << "\n";
}
| 22.096774 | 55 | 0.579562 | UncleCShark |
38d9c8ddee49603d3cc4d513aaf65cdd972a171c | 3,039 | cpp | C++ | luogu/1442.cpp | swwind/code | 25c4c5ca2f8578ba792b44cbdf44286d39dfb7e0 | [
"WTFPL"
] | 3 | 2017-09-17T09:12:50.000Z | 2018-04-06T01:18:17.000Z | luogu/1442.cpp | swwind/code | 25c4c5ca2f8578ba792b44cbdf44286d39dfb7e0 | [
"WTFPL"
] | null | null | null | luogu/1442.cpp | swwind/code | 25c4c5ca2f8578ba792b44cbdf44286d39dfb7e0 | [
"WTFPL"
] | null | null | null | #include <bits/stdc++.h>
#define N 100020
#define ll long long
using namespace std;
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch>'9'||ch<'0')ch=='-'&&(f=0)||(ch=getchar());
while(ch<='9'&&ch>='0')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return f?x:-x;
}
struct node {
int h, l, r;
friend bool operator < (const node &a, const node &b) {
return a.h < b.h;
}
}a[N];
int tg[N<<3], vl[N<<3];
void push_down(int x) {
if (tg[x]) {
vl[x << 1] = tg[x];
vl[x<<1|1] = tg[x];
tg[x << 1] = tg[x];
tg[x<<1|1] = tg[x];
tg[x] = 0;
}
}
void update(int x, int l, int r, int L, int R, int v) {
if (l > r) return;
if (l == L && r == R) {
tg[x] = vl[x] = v;
return;
}
push_down(x);
int m = (L + R) >> 1;
if (r <= m) update(x << 1, l, r, L, m, v);
else if (l > m) update(x<<1|1, l, r, m + 1, R, v);
else update(x << 1, l, m, L, m, v), update(x<<1|1, m + 1, r, m + 1, R, v);
}
int ask(int x, int k, int L, int R) {
if (L == R)
return vl[x];
push_down(x);
int m = (L + R) >> 1;
if (k <= m) return ask(x << 1, k, L, m);
else return ask(x<<1|1, k, m + 1, R);
}
long long b[N<<1], cnt;
int gl[N], gr[N];
long long fl[N], fr[N];
int main(int argc, char const *argv[]) {
int n = read(), m = read();
int stx = read(), sty = read();
b[++cnt] = stx;
for (int i = 1; i <= n; i++) {
a[i].h = read();
if (a[i].h > sty) {
read(); read();
i --, n --;
continue;
}
b[++cnt] = a[i].l = read();
b[++cnt] = a[i].r = read();
}
sort(a + 1, a + n + 1);
sort(b + 1, b + cnt + 1);
cnt = unique(b + 1, b + cnt + 1) - b - 1;
for (int i = 1; i <= n; i++) {
a[i].l = lower_bound(b + 1, b + cnt + 1, a[i].l) - b;
a[i].r = lower_bound(b + 1, b + cnt + 1, a[i].r) - b;
gl[i] = ask(1, a[i].l, 1, cnt);
gr[i] = ask(1, a[i].r, 1, cnt);
update(1, a[i].l + 1, a[i].r - 1, 1, cnt, i);
}
stx = lower_bound(b + 1, b + cnt + 1, stx) - b;
// for (int i = 1; i <= n; i++)
// cout << gl[i] << " " << gr[i] << endl;
// cout << endl;
long long ans = 1ll << 60;
memset(fl, 63, sizeof fl);
memset(fr, 63, sizeof fr);
int st = ask(1, stx, 1, cnt);
fl[st] = sty - a[st].h + b[stx] - b[a[st].l];
fr[st] = sty - a[st].h + b[a[st].r] - b[stx];
for (int i = st; i; i--) {
if (a[i].h - a[gl[i]].h <= m) { // 如果该平台的左端点能掉下去
fl[gl[i]] = min(fl[gl[i]], fl[i] + a[i].h - a[gl[i]].h + b[a[i].l] - b[a[gl[i]].l]);
fr[gl[i]] = min(fr[gl[i]], fl[i] + a[i].h - a[gl[i]].h + b[a[gl[i]].r] - b[a[i].l]);
if (!gl[i])
ans = min(ans, fl[i] + a[i].h);
}
if (a[i].h - a[gr[i]].h <= m) { // 如果该平台的右端点能掉下去
fl[gr[i]] = min(fl[gr[i]], fr[i] + a[i].h - a[gr[i]].h + b[a[i].r] - b[a[gr[i]].l]);
fr[gr[i]] = min(fr[gr[i]], fr[i] + a[i].h - a[gr[i]].h + b[a[gr[i]].r] - b[a[i].r]);
if (!gr[i])
ans = min(ans, fr[i] + a[i].h);
}
}
// for (int i = 1; i <= st; i++)
// cout << fl[i] << " " << fr[i] << endl;
cout << ans << endl;
return 0;
}
// 15418021011393200024 | 29.504854 | 90 | 0.431392 | swwind |
38df8c5175f801ae13eb0808fe6cee826ae15fdc | 4,556 | cpp | C++ | GLManager.cpp | GuMiner/Octocad | 2858d777e5db177e1fbddf7653ba052a4fa31855 | [
"MIT"
] | null | null | null | GLManager.cpp | GuMiner/Octocad | 2858d777e5db177e1fbddf7653ba052a4fa31855 | [
"MIT"
] | null | null | null | GLManager.cpp | GuMiner/Octocad | 2858d777e5db177e1fbddf7653ba052a4fa31855 | [
"MIT"
] | null | null | null | #include "stdafx.h"
#include "GLManager.h"
#include "StringUtility.h"
GLManager *GLManager::m_pManager;
float GLManager::FOV_Y;
float GLManager::NEAR_PLANE;
float GLManager::FAR_PLANE;
// Compiles a combination vertex and fragment shader into a single shader program.
GLuint GLManager::CompileShaderProgram(const char rootName [])
{
GLuint program;
GLuint vertexShader;
GLuint fragmentShader;
std::string vsShader, fsShader;
std::stringstream vsFilenameStream, fsFilenameStream;
vsFilenameStream << "shaders/" << rootName << ".vs";
fsFilenameStream << "shaders/" << rootName << ".fs";
if (!StringUtility::LoadStringFromFile(vsFilenameStream.str().c_str(), vsShader))
{
std::cout << "Could not load " << vsShader << "!" << std::endl;
}
if (!StringUtility::LoadStringFromFile(fsFilenameStream.str().c_str(), fsShader))
{
std::cout << "Could not load fragment shader" << fsShader << "!" << std::endl;
}
const char* vss = vsShader.c_str();
const char* fss = fsShader.c_str();
char buffer[1024];
GLint len;
GLint compileStatus;
vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, &vss, NULL);
glCompileShader(vertexShader);
glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &compileStatus);
if (!compileStatus)
{
glGetShaderInfoLog(vertexShader, 1024, &len, buffer);
std::cout << std::endl << "Error: " << glewGetErrorString(glGetError()) << " " << buffer << std::endl;
}
fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragmentShader, 1, &fss, NULL);
glCompileShader(fragmentShader);
glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &compileStatus);
if (!compileStatus)
{
glGetShaderInfoLog(fragmentShader, 1024, &len, buffer);
std::cout << "Error: " << glewGetErrorString(glGetError()) << " " << buffer << std::endl;
}
// Create program
program = glCreateProgram();
glAttachShader(program, vertexShader);
glAttachShader(program, fragmentShader);
glLinkProgram(program);
glGetProgramiv(program, GL_LINK_STATUS, &compileStatus);
if (!compileStatus)
{
glGetProgramInfoLog(program, 1024, &len, buffer);
std::cout << "Error: " << glewGetErrorString(glGetError()) << " " << buffer << std::endl;
}
glDeleteShader(vertexShader);
glDeleteShader(fragmentShader);
return program;
}
bool GLManager::Initialize(float yFov, float nearPlane, float farPlane, bool fullscreen, int width, int height, std::string title)
{
m_pManager = new GLManager();
m_pManager->running = true;
m_pManager->fullscreen = fullscreen;
m_pManager->width = width;
m_pManager->height = height;
m_pManager->title = title;
FOV_Y = yFov;
NEAR_PLANE = nearPlane;
FAR_PLANE = farPlane;
return true;
}
// Generates a look-at matrix
gmtl::Matrix44f GLManager::Lookat(gmtl::Vec3f target, gmtl::Vec3f camera, gmtl::Vec3f up)
{
// Rewritten to use the standardized public-domain code for a RH matrix here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb281711(v=vs.85).aspx
gmtl::Vec3f zAxis = camera - target;
gmtl::normalize(zAxis);
gmtl::Vec3f xAxis = gmtl::makeCross(up, zAxis);
gmtl::normalize(xAxis);
gmtl::Vec3f yAxis = gmtl::makeCross(zAxis, xAxis);
gmtl::Matrix44f result;
result.set(
xAxis[0], yAxis[0], zAxis[0], 0,
xAxis[1], yAxis[1], zAxis[1], 0,
xAxis[2], yAxis[2], zAxis[2], 0,
-gmtl::dot(xAxis, camera), -gmtl::dot(yAxis, camera), -gmtl::dot(zAxis, camera), 1);
result = gmtl::transpose(result);
return result;
}
// Performs axis-angle rotation.
gmtl::Matrix44f GLManager::Rotate(float angle, gmtl::Vec3f axis)
{
gmtl::Matrix44f result;
float c = cosf(angle);
float s = sinf(angle);
float omc = 1.0f - c;
result.set((axis[0] * axis[0] * omc + c), (axis[1] * axis[0] * omc + axis[2] * s), (axis[0] * axis[2] * omc - axis[1] * s), 0.0f,
(axis[0] * axis[1] * omc - axis[2] * s), (axis[1] * axis[1] * omc + c), (axis[1] * axis[2] * omc + axis[0] * s), 0.0f,
(axis[0] * axis[2] * omc + axis[1] * s), (axis[1] * axis[2] * omc - axis[0] * s), (axis[2]* axis[2] * omc + c), 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
result = gmtl::transpose(result);
return result;
}
GLManager* GLManager::GetManager()
{
return m_pManager;
}
bool GLManager::Deinitialize()
{
delete m_pManager;
return true;
} | 32.776978 | 160 | 0.643327 | GuMiner |
38e16598309aa0325c8cdf2db1cd194f252f1ace | 1,230 | cpp | C++ | Source/SocketModule/joystick.cpp | simondlevy/SackflightHim | efcbd6b21f5f9826b00df656eb29240924a98a94 | [
"MIT"
] | 77 | 2019-01-27T05:00:40.000Z | 2022-01-30T03:28:35.000Z | Source/SocketModule/joystick.cpp | simondlevy/SackflightHim | efcbd6b21f5f9826b00df656eb29240924a98a94 | [
"MIT"
] | 124 | 2019-02-17T16:05:51.000Z | 2021-07-24T02:53:05.000Z | Source/SocketModule/joystick.cpp | simondlevy/SackflightHim | efcbd6b21f5f9826b00df656eb29240924a98a94 | [
"MIT"
] | 38 | 2019-01-31T17:25:47.000Z | 2021-12-27T23:07:30.000Z | /*
* Windows support for joysticks and other game controllers
*
* Copyright (C) 2021 Simon D. Levy
*
* MIT License
*/
#include "../MainModule/Joystick.h"
#undef TEXT
#include <shlwapi.h>
#include "joystickapi.h"
bool IJoystick::isValidJoystick(int joystick_id, uint16_t & product_id)
{
JOYCAPS joycaps = {};
if (joyGetDevCaps(joystick_id,
&joycaps, sizeof(joycaps)) == JOYERR_NOERROR) {
product_id = joycaps.wPid;
return true;
}
return false;
}
void IJoystick::readJoystick(
int joystick_id,
uint32_t & xpos,
uint32_t & ypos,
uint32_t & zpos,
uint32_t & rpos,
uint32_t & upos,
uint32_t & vpos,
uint8_t & buttons)
{
JOYINFOEX joyState;
joyState.dwSize = sizeof(joyState);
joyState.dwFlags =
JOY_RETURNALL | JOY_RETURNPOVCTS | JOY_RETURNCENTERED | JOY_USEDEADZONE;
joyGetPosEx(joystick_id, &joyState);
xpos = joyState.dwXpos;
ypos = joyState.dwYpos;
zpos = joyState.dwZpos;
rpos = joyState.dwRpos;
upos = joyState.dwUpos;
vpos = joyState.dwVpos;
buttons = (uint8_t)joyState.dwButtons;
}
| 21.964286 | 81 | 0.604878 | simondlevy |
38e369e3dc42cc79436006a020488be7cc410d16 | 386 | cpp | C++ | Source/FSD/Private/TerminatorEnemy.cpp | trumank/DRG-Mods | 2febc879f2ffe83498ac913c114d0e933427e93e | [
"MIT"
] | null | null | null | Source/FSD/Private/TerminatorEnemy.cpp | trumank/DRG-Mods | 2febc879f2ffe83498ac913c114d0e933427e93e | [
"MIT"
] | null | null | null | Source/FSD/Private/TerminatorEnemy.cpp | trumank/DRG-Mods | 2febc879f2ffe83498ac913c114d0e933427e93e | [
"MIT"
] | null | null | null | #include "TerminatorEnemy.h"
#include "HitReactionComponent.h"
void ATerminatorEnemy::All_PlayFlairAnimation_Implementation() {
}
ATerminatorEnemy::ATerminatorEnemy() {
this->FlairAnimation = NULL;
this->MinFlairAnimCooldown = 1.00f;
this->MaxFlairAnimationCooldown = 2.00f;
this->HitReactions = CreateDefaultSubobject<UHitReactionComponent>(TEXT("HitReactions"));
}
| 27.571429 | 93 | 0.772021 | trumank |
38e388a25247776082543f1004409f1775132f11 | 32,398 | cpp | C++ | Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32756G_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/Graphs/half_circle_toggle_button_inactive.cpp | ramkumarkoppu/NUCLEO-F767ZI-ESW | 85e129d71ee8eccbd0b94b5e07e75b6b91679ee8 | [
"MIT"
] | null | null | null | Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32756G_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/Graphs/half_circle_toggle_button_inactive.cpp | ramkumarkoppu/NUCLEO-F767ZI-ESW | 85e129d71ee8eccbd0b94b5e07e75b6b91679ee8 | [
"MIT"
] | null | null | null | Tools/STM32FW/STM32Cube_FW_F7_V1.16.2/Projects/STM32756G_EVAL/Demonstrations/TouchGFX/Gui/generated/images/src/Graphs/half_circle_toggle_button_inactive.cpp | ramkumarkoppu/NUCLEO-F767ZI-ESW | 85e129d71ee8eccbd0b94b5e07e75b6b91679ee8 | [
"MIT"
] | null | null | null | // Generated by imageconverter. Please, do not edit!
#include <touchgfx/hal/Config.hpp>
LOCATION_EXTFLASH_PRAGMA
KEEP extern const unsigned char _half_circle_toggle_button_inactive[] LOCATION_EXTFLASH_ATTRIBUTE = { // 55x58 RGB565 pixels.
0x9a,0xce,0x35,0xa5,0x56,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,
0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,
0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,
0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x35,0xa5,0x9a,0xce,
0x35,0xa5,0xb7,0xb5,0x18,0xbe,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,
0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,
0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,
0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0x19,0xc6,0xb7,0xb5,0x35,0xa5,
0x56,0xad,0x18,0xbe,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x18,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,
0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,
0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,
0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,
0x7a,0xce,0x18,0xc6,0x76,0xad,
0x76,0xad,0x18,0xbe,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,
0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,
0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,
0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x18,0xbe,
0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xc6,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xc6,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x5a,0xce,
0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xc6,
0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,
0x18,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x18,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,
0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xc6,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x5a,0xce,0x7a,0xce,
0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,
0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x18,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x18,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,
0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,
0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,
0x19,0xc6,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x18,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,
0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x18,0xc6,0x76,0xad,
0x76,0xad,0x18,0xbe,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,
0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xc6,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x5a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x18,0xc6,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x18,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x18,0xbe,0xd7,0xb5,0x97,0xad,0xd7,0xb5,0x5a,0xce,
0xd7,0xb5,0x97,0xad,0xd7,0xb5,0x18,0xc6,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0xf8,0xbd,0x96,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0xd7,0xbd,0x7a,0xce,0xd7,0xb5,0x76,0xad,0x76,0xad,0x76,0xad,0x96,0xad,0xf8,0xbd,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x18,0xc6,
0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x39,0xc6,0xb7,0xb5,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0xd8,0xbd,0x7a,0xce,0xd8,0xbd,0x76,0xad,
0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0xb7,0xb5,0x39,0xc6,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x39,0xc6,0x96,0xad,0x76,0xad,0x76,0xad,0x76,0xad,
0x96,0xad,0x76,0xad,0x76,0xad,0xd8,0xbd,0x7a,0xce,0xd7,0xb5,0x76,0xad,0x76,0xad,0x96,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x96,0xad,0x39,0xc6,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x18,0xbe,0x76,0xad,
0x76,0xad,
0x18,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x39,0xc6,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x96,0xad,0x76,0xad,0x76,0xad,0xd8,0xbd,0x7a,0xce,0xd8,0xb5,0x76,0xad,0x76,0xad,0x76,0xad,
0x96,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x96,0xad,0x39,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xc6,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x59,0xc6,0x96,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x96,0xad,0x76,0xad,0x76,0xad,0x76,0xad,
0x97,0xb5,0xf8,0xbd,0x7a,0xce,0xf8,0xbd,0x97,0xb5,0x76,0xad,0x76,0xad,0x77,0xad,0x96,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x97,0xad,0x5a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x19,0xc6,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,
0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0xd7,0xb5,0x76,0xad,
0x76,0xad,0x76,0xad,0x96,0xad,0x76,0xad,0x76,0xad,0xb7,0xb5,0x39,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x39,0xc6,0xb7,0xb5,0x76,0xad,0x76,0xb5,
0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0xd7,0xb5,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x18,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x39,0xc6,0x76,0xad,0x76,0xad,0x76,0xad,0x96,0xad,0x77,0xad,0x76,0xad,0xf9,0xc5,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0xf8,0xbd,0x96,0xad,0x77,0xad,0x96,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x39,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x18,0xbe,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0xb7,0xb5,0x76,0xad,0x76,0xad,0x96,0xad,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,0x76,0xb5,
0x96,0xad,0x76,0xad,0x76,0xad,0xd7,0xb5,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x5a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,
0x18,0xc6,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xc6,0x76,0xad,0x76,0xad,0x76,0xad,0x77,0xad,0x76,0xad,0xd7,0xbd,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0xd7,0xbd,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x18,0xbe,0x76,0xad,0x76,0xad,0x96,0xad,0x76,0xad,0x97,0xb5,0x5a,0xc6,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x76,0xad,0x76,0xad,0x97,0xad,
0x76,0xad,0x76,0xad,0x18,0xbe,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0xd7,0xb5,
0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0xd7,0xb5,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0xb7,0xb5,0x76,0xad,0x96,0xb5,0x76,0xad,0x76,0xad,0xd8,0xb5,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x5a,0xce,
0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x18,0xc6,0x76,0xad,
0x76,0xad,0x18,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,
0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x97,0xb5,0x76,0xad,0x96,0xad,0x76,0xad,0x76,0xad,0x19,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,
0xb7,0xb5,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x96,0xad,0x76,0xad,0x77,0xad,
0x76,0xad,0x76,0xad,0x39,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x39,0xc6,0x76,0xad,0x77,0xad,0x96,0xad,0x76,0xad,0x76,0xad,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x5a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x18,0xc6,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,
0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x18,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x19,0xc6,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,
0x5a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x18,0xbe,
0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,
0x5a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x19,0xc6,0x76,0xad,
0x76,0xad,
0x18,0xbe,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x18,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,
0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,
0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,
0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x19,0xc6,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x18,0xbe,0x76,0xad,
0x76,0xad,0x18,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xc6,0x76,0xad,
0x76,0xad,0x19,0xbe,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x5a,0xce,
0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x18,0xc6,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,
0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x18,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x19,0xbe,
0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xc6,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x18,0xc6,0x76,0xad,
0x76,0xad,0x19,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0x18,0xc6,0x7a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,
0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,
0x7a,0xce,0x19,0xbe,0x76,0xad,
0x76,0xad,0xf8,0xbd,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,
0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x5a,0xc6,0x7a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x5a,0xce,0x7a,0xc6,0x7a,0xce,
0x7a,0xce,0x5a,0xce,0x7a,0xce,0x7a,0xce,0x7a,0xc6,0x5a,0xce,0x7a,0xce,0x7a,0xce,0xf8,0xbd,0x76,0xad,
0x35,0xa5,0xb7,0xb5,0x18,0xbe,0x19,0xc6,0x19,0xbe,0x18,0xbe,
0x19,0xc6,0x19,0xbe,0x18,0xbe,0x19,0xc6,0x19,0xbe,0x18,0xbe,0x19,0xbe,0x19,0xbe,0x18,0xbe,0x19,0xbe,0x19,0xbe,0x18,0xc6,0x19,0xbe,0x19,0xbe,0x19,0xc6,0x19,0xbe,
0x19,0xbe,0x19,0xbe,0x19,0xbe,0x19,0xbe,0x19,0xbe,0x19,0xbe,0x19,0xbe,0x19,0xbe,0x19,0xc6,0x19,0xbe,0x19,0xbe,0x19,0xbe,0x19,0xc6,0x19,0xbe,0x19,0xbe,0x19,0xc6,
0x19,0xbe,0x19,0xbe,0x19,0xc6,0x19,0xbe,0x19,0xbe,0x19,0xc6,0x19,0xbe,0x19,0xbe,0x19,0xc6,0x19,0xbe,0x19,0xbe,0x19,0xc6,0x19,0xbe,0x18,0xbe,0x19,0xc6,0xb7,0xb5,
0x35,0xa5,
0x5a,0xce,0x35,0xa5,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,
0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,
0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,
0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x76,0xad,0x35,0xa5,0x59,0xce,
0x1c,0xdf,0x1c,0xe7,0x1c,0xdf,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xdf,0x1c,0xe7,
0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xdf,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,
0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xdf,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xdf,
0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xdf,0x1c,0xe7,0x1c,0xe7,0x1c,0xe7,0x1c,0xdf,0x1c,0xe7,0x1c,0xe7,0x1d,0xdf,0x1c,0xe7,0x1c,0xdf,
0x1c,0xdf,
0x1d,0xe7,0x1c,0xdf,0x1c,0xdf,0x1d,0xe7,0x1d,0xdf,0x1c,0xdf,0x1c,0xe7,0x1d,0xdf,0x1d,0xdf,0x1c,0xdf,0x1c,0xe7,0x1d,0xdf,0x1d,0xdf,0x1c,0xe7,0x1c,0xdf,0x1d,0xdf,
0x1c,0xdf,0x1d,0xe7,0x1c,0xdf,0x1d,0xdf,0x1c,0xe7,0x1c,0xdf,0x1c,0xdf,0x1d,0xe7,0x1c,0xdf,0x1d,0xdf,0x1c,0xe7,0x1d,0xdf,0x1c,0xdf,0x1c,0xdf,0x1d,0xdf,0x1c,0xdf,
0x1c,0xe7,0x1d,0xdf,0x1d,0xdf,0x1c,0xe7,0x1d,0xdf,0x1c,0xdf,0x1d,0xe7,0x1d,0xdf,0x1c,0xdf,0x1d,0xdf,0x1c,0xe7,0x1c,0xdf,0x1c,0xdf,0x1d,0xe7,0x1c,0xdf,0x1c,0xdf,
0x1d,0xe7,0x1c,0xdf,0x1d,0xdf,0x1c,0xe7,0x1d,0xdf,0x1c,0xe7
};
| 123.186312 | 160 | 0.793784 | ramkumarkoppu |
38e50fec5d804c5f4a47ca0a69557151fd881378 | 68 | hpp | C++ | include/containers/span.hpp | SakuraEngine/Sakura.Runtime | 5a397fb2b1285326c4216f522fe10e347bd566f7 | [
"MIT"
] | 29 | 2021-11-19T11:28:22.000Z | 2022-03-29T00:26:51.000Z | include/containers/span.hpp | SakuraEngine/Sakura.Runtime | 5a397fb2b1285326c4216f522fe10e347bd566f7 | [
"MIT"
] | null | null | null | include/containers/span.hpp | SakuraEngine/Sakura.Runtime | 5a397fb2b1285326c4216f522fe10e347bd566f7 | [
"MIT"
] | 1 | 2022-03-05T08:14:40.000Z | 2022-03-05T08:14:40.000Z | #pragma once
#include <gsl/span>
namespace skr
{
using gsl::span;
} | 9.714286 | 19 | 0.705882 | SakuraEngine |
38e5b5850623304281363d81c433db97cc398052 | 2,224 | cpp | C++ | test/openpower-pels/pel_rules_test.cpp | Alpana07/phosphor-logging | 1be39849bd974c2f7df7fa932edcd7f71a2c6d59 | [
"Apache-2.0"
] | 14 | 2021-11-04T07:47:37.000Z | 2022-03-21T10:10:30.000Z | test/openpower-pels/pel_rules_test.cpp | Alpana07/phosphor-logging | 1be39849bd974c2f7df7fa932edcd7f71a2c6d59 | [
"Apache-2.0"
] | 26 | 2017-02-02T08:20:10.000Z | 2021-11-16T18:28:44.000Z | test/openpower-pels/pel_rules_test.cpp | Alpana07/phosphor-logging | 1be39849bd974c2f7df7fa932edcd7f71a2c6d59 | [
"Apache-2.0"
] | 28 | 2016-07-20T16:46:54.000Z | 2022-03-16T11:20:03.000Z | #include "extensions/openpower-pels/pel_rules.hpp"
#include <gtest/gtest.h>
using namespace openpower::pels;
struct CheckParams
{
// pel_rules::check() inputs
uint16_t actionFlags;
uint8_t eventType;
uint8_t severity;
// pel_rules::check() expected outputs
uint16_t expectedActionFlags;
uint8_t expectedEventType;
};
const uint8_t sevInfo = 0x00;
const uint8_t sevRecovered = 0x10;
const uint8_t sevPredictive = 0x20;
const uint8_t sevUnrecov = 0x40;
const uint8_t sevCrit = 0x50;
const uint8_t sevDiagnostic = 0x60;
const uint8_t sevSymptom = 0x70;
const uint8_t typeNA = 0x00;
const uint8_t typeMisc = 0x01;
const uint8_t typeTracing = 0x02;
const uint8_t typeDumpNotif = 0x08;
TEST(PELRulesTest, TestCheckRules)
{
// Impossible to cover all combinations, but
// do some interesting ones.
std::vector<CheckParams> testParams{
// Informational errors w/ empty action flags
// and different event types.
{0, typeNA, sevInfo, 0x6000, typeMisc},
{0, typeMisc, sevInfo, 0x6000, typeMisc},
{0, typeTracing, sevInfo, 0x6000, typeTracing},
{0, typeDumpNotif, sevInfo, 0x2000, typeDumpNotif},
// Informational errors with wrong action flags
{0x8900, typeNA, sevInfo, 0x6000, typeMisc},
// Informational errors with extra valid action flags
{0x00C0, typeMisc, sevInfo, 0x60C0, typeMisc},
// Informational - don't report
{0x1000, typeMisc, sevInfo, 0x5000, typeMisc},
// Recovered will report as hidden
{0, typeNA, sevRecovered, 0x6000, typeNA},
// The 5 error severities will have:
// service action, report, call home
{0, typeNA, sevPredictive, 0xA800, typeNA},
{0, typeNA, sevUnrecov, 0xA800, typeNA},
{0, typeNA, sevCrit, 0xA800, typeNA},
{0, typeNA, sevDiagnostic, 0xA800, typeNA},
{0, typeNA, sevSymptom, 0xA800, typeNA}};
for (const auto& entry : testParams)
{
auto [actionFlags, type] = pel_rules::check(
entry.actionFlags, entry.eventType, entry.severity);
EXPECT_EQ(actionFlags, entry.expectedActionFlags);
EXPECT_EQ(type, entry.expectedEventType);
}
}
| 30.465753 | 64 | 0.674011 | Alpana07 |
38e7aed3d3d330732e07aaf5c614bca861a61139 | 6,000 | hpp | C++ | sparta/python/sparta_support/PythonInterpreter.hpp | knute-sifive/map | fb25626830a56ad68ab896bcd01929023ff31c48 | [
"MIT"
] | null | null | null | sparta/python/sparta_support/PythonInterpreter.hpp | knute-sifive/map | fb25626830a56ad68ab896bcd01929023ff31c48 | [
"MIT"
] | null | null | null | sparta/python/sparta_support/PythonInterpreter.hpp | knute-sifive/map | fb25626830a56ad68ab896bcd01929023ff31c48 | [
"MIT"
] | null | null | null | // <PythonInterpreter.h> -*- C++ -*-
/*!
* \file PythonInterpreter.h
* \brief Instantiates python interpreter instance
*/
#ifndef __SPARTA_PYTHONINTERPRETER_H__
#define __SPARTA_PYTHONINTERPRETER_H__
#include "sparta/sparta.hpp" // For macro definitions
#include "simdb_fwd.hpp"
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef __USE_GNU
#define __USE_GNU
#endif
#include <signal.h>
#include <string>
#include <memory>
#include <Python.h>
namespace sparta {
class RootTreeNode;
namespace app {
class Simulation;
class SimulationConfiguration;
class ReportConfiguration;
}
namespace control {
class TemporaryRunControl;
}
namespace statistics {
class StatisticsArchives;
class StatisticsStreams;
}
namespace async {
class AsynchronousTaskEval;
}
namespace python {
/*!
* \brief Stack-based GIL lock
*/
class LocalGIL {
PyGILState_STATE gstate_;
public:
LocalGIL() :
gstate_(PyGILState_Ensure())
{}
~LocalGIL() {
PyGILState_Release(gstate_);
}
};
/*!
* \brief Wraps pyhton initialization into a class
*
* \warning Python can only be initlized once per process. Multiple interpreters
* can be created. This initializeds Python and creates interpreters. Do not
* instantiate if Python is initialized already.)
*
* \note May be able to instantiate this multiple times per process as long as
* lifestpans do not overlap but this is untested and no known use exists at
* this point
*/
class PythonInterpreter {
std::unique_ptr<char[]> progname_;
std::unique_ptr<char[]> homedir_;
struct sigaction sigint_act_; //!< signal action
struct sigaction sigint_next_; //!< Next handler in chain (replaced by this class)
/*!
* \brief Run control interface currently being used
* \todo Support multiple RC interfaces
*/
control::TemporaryRunControl* run_controller_ = nullptr;
public:
/*!
* \brief Helper to statically track that one intpreter instance exists at a time
*
* Sets flag when created and clears flag when destructed. Instantiated through a member
* of interpreter so that it will always be cleanly destructed (setting flag to false)
* when the interpreter class is destroyed no matter where the owning class fails
*
* This is necessary to help ensure that one instance of this class exist at a time so that
* signal handlers can be properly mainained
*/
class SingleInstanceForce {
static PythonInterpreter* curinstance_;
public:
SingleInstanceForce(PythonInterpreter* inst) {
sparta_assert(curinstance_ == nullptr,
"Attempted to create a new Python interpreter instance while another was still alive.");
curinstance_ = inst;
}
~SingleInstanceForce() {
curinstance_ = nullptr;
}
static PythonInterpreter* getCurInstance() { return curinstance_; }
};
PythonInterpreter(const std::string& progname,
const std::string& homedir,
int argc,
char** argv);
~PythonInterpreter();
//! ========================================================================
//! Global State
//! @{
std::string getExecPrefix() const;
std::string getPythonFullPath() const;
std::string getPath() const;
std::string getVersion() const;
std::string getPlatform() const;
std::string getCompiler() const;
void publishSimulationConfiguration(app::SimulationConfiguration * sim_config);
void publishReportConfiguration(app::ReportConfiguration * report_config);
void publishStatisticsArchives(statistics::StatisticsArchives * archives);
void publishStatisticsStreams(statistics::StatisticsStreams * streams);
void publishSimulationDatabase(simdb::ObjectManager * sim_db);
void publishDatabaseController(simdb::AsyncTaskEval * db_queue);
void publishSimulator(app::Simulation * sim);
void publishTree(RootTreeNode * n);
void publishRunController(control::TemporaryRunControl* rc);
void removePublishedObject(const void * obj_this_ptr);
/*!
* \brief Temporary interactive REPL loop
* \post Updates exit code with simulation result. Should not allow Python or C++ exceptions
* to bubble out of this function except for framework errors (C++ exceptions only)
* \see getExitCode
*/
void interact();
/*!
* \brief Handle a SIGINT signal
*/
void handleSIGINT(siginfo_t * info, void * ucontext);
/*!
* \brief Exit the shell and return control from interact
*/
void asyncExit(int exit_code);
/*!
* \brief IPython hook callback handler before each prompt display
*/
void IPyPrePrompt(PyObject* embed_shell);
/*!
* \brief IPython hook callback handler once IPython shell is initialized
*/
void IPyShellInitialized();
/*!
* \brief Return the exit code set by asyncExit (0 not asyncExit not called)
*/
int getExitCode() const { return exit_code_; }
private:
SingleInstanceForce sif_;
std::unique_ptr<PyObject, void (*)(PyObject*)> ipython_inst_;
int exit_code_ = 0;
//! Mapping from void* (published object's this pointer) to the
//! Python variable name it was published to.
std::unordered_map<const void*, std::string> published_obj_names_;
};
} // namespace python
} // namespace sparta
#endif // #ifndef __SPARTA_PYTHONINTERPRETER_H__
| 28.169014 | 116 | 0.625333 | knute-sifive |
38e7c9a39b18084efa26053ed9d8f55acf0fb4d2 | 4,123 | cc | C++ | src/invadermanager.cc | CS126SP20/space-invaders | 42b3021f04b41821c6fc203c6de74352f9c2afa5 | [
"MIT"
] | null | null | null | src/invadermanager.cc | CS126SP20/space-invaders | 42b3021f04b41821c6fc203c6de74352f9c2afa5 | [
"MIT"
] | null | null | null | src/invadermanager.cc | CS126SP20/space-invaders | 42b3021f04b41821c6fc203c6de74352f9c2afa5 | [
"MIT"
] | 1 | 2021-01-09T23:47:18.000Z | 2021-01-09T23:47:18.000Z | // Copyright (c) 2020 Saurav Raghavendra. All rights reserved.
#include "spaceinvaders/invadermanager.h"
namespace spaceinvaders {
using cinder::app::getWindowHeight;
using cinder::app::getWindowWidth;
namespace {
const int kMaxInvaders = 55;
}
InvaderManager::InvaderManager()
: step_gap_(std::chrono::seconds(static_cast<long>(0.5f))),
invader_renderer_(0, 25, Invader::kWidth, 25 + Invader::kHeight,
"invader.png"),
step_timer_(true),
alive_invaders_(0) {
const int gap = 10;
for (int y = 0; y < 5; y++) {
for (int x = 0; x < 11; x++) {
float invader_x = static_cast<float>(x) * Invader::kWidth +
static_cast<float>(gap * x * 3) + Invader::kWidth;
float invader_y = static_cast<float>(y) * Invader::kHeight +
static_cast<float>(gap * y) + Invader::kHeight * 4;
invaders_.emplace_back(cinder::vec2{invader_x, invader_y});
}
}
}
void InvaderManager::TryStepInvaders() {
if (step_timer_.getSeconds() > step_gap_.count()) {
invader_renderer_.NextFrame();
bool MoveDown = false;
float step = is_moving_left ? -0.8f : 0.8f;
if (move_down_) {
step *= -1;
}
for (auto &invader : invaders_) {
if (!invader.IsAlive()) {
continue;
}
invader.Move(step, 0.0f);
if (move_down_) {
invader.Move(0, Invader::kHeight / 2.0f);
} else if (!MoveDown) {
MoveDown = TestInvaderPosition(invader);
}
}
if (move_down_) {
is_moving_left = !is_moving_left;
}
move_down_ = MoveDown;
step_timer_.start();
}
}
void InvaderManager::DrawInvaders() {
for (auto &invader : invaders_) {
if (!invader.IsAlive()) {
continue;
}
invader_renderer_.RenderEntity(invader.GetPosition());
}
}
auto InvaderManager::TryCollideWithProjectiles(
std::vector<Projectile> &projectiles) -> CollisionResult {
CollisionResult result;
std::vector<cinder::vec2> collisionPoints;
for (auto &projectile : projectiles) {
for (auto &invader : invaders_) {
if (!invader.IsAlive() || !projectile.IsActive()) {
continue;
}
if (projectile.TryCollideWith(invader)) {
alive_invaders_--;
if (alive_invaders_ == 0) {
has_all_invaders_been_added_ = false;
}
result.second.emplace_back(invader.GetPosition());
result.first += 20;
UpdateStepDelay();
}
}
}
return result;
}
auto InvaderManager::GetRandomLowestInvaderPoint(cinder::Rand &random)
-> cinder::vec2 {
if (alive_invaders_ == 0) {
return {-1, -1};
}
while (true) {
auto invader_column = random.nextInt(0, 10);
for (int y = 4; y >= 0; y--) {
int index = y * 11 + invader_column;
auto &invader = invaders_.at(index);
if (invader.IsAlive()) {
return {invader.GetPosition().x + Invader::kWidth / 2,
invader.GetPosition().y + Invader::kHeight + 5};
}
}
}
}
void InvaderManager::InitAddInvader() {
static cinder::Timer delay(true);
if (delay.getSeconds() > 0.02) {
invaders_.at(init_y_ * 11 + init_x_).MakeAlive();
alive_invaders_++;
init_x_++;
if (init_x_ == 11) {
init_x_ = 0;
init_y_--;
}
delay.start();
}
if (alive_invaders_ == kMaxInvaders) {
has_all_invaders_been_added_ = true;
init_x_ = 0;
init_y_ = 4;
UpdateStepDelay();
}
}
auto InvaderManager::AreInvadersAlive() const -> bool {
return has_all_invaders_been_added_;
}
void InvaderManager::UpdateStepDelay() {
step_gap_ = std::chrono::seconds(
static_cast<int32_t>(static_cast<float>(alive_invaders_) / 90.0f));
}
auto InvaderManager::TestInvaderPosition(const Invader &invader) -> bool {
if (invader.GetPosition().y > static_cast<float>(getWindowHeight()) - 75) {
is_game_over_ = true;
}
return (invader.GetPosition().x < 15 && is_moving_left) ||
(invader.GetPosition().x + Invader::kWidth >
static_cast<float>(getWindowWidth()) - 15 &&
!is_moving_left);
}
} // namespace spaceinvaders
| 26.6 | 77 | 0.616299 | CS126SP20 |
38ecb3f332576dd010df4bf77e050051f0e4ed92 | 225 | cpp | C++ | seeded_lda/libc/utils/Node.cpp | qinliuliuqin/Arbitrage-Strategy-Analysis | d735481a2480174366e3f90025a1f935d5ad1f8b | [
"MIT"
] | null | null | null | seeded_lda/libc/utils/Node.cpp | qinliuliuqin/Arbitrage-Strategy-Analysis | d735481a2480174366e3f90025a1f935d5ad1f8b | [
"MIT"
] | null | null | null | seeded_lda/libc/utils/Node.cpp | qinliuliuqin/Arbitrage-Strategy-Analysis | d735481a2480174366e3f90025a1f935d5ad1f8b | [
"MIT"
] | null | null | null | #include <iostream>
#ifndef NODE_H_
#define NODE_H_
template <typename T> class Node{
public:
T First;
Node<T> *Next;
public:
Node(T aFirst){
First = aFirst;
Next = NULL;
}
Node() { Next = NULL;};
};
#endif
| 10.714286 | 33 | 0.626667 | qinliuliuqin |
38f66d481e09853a71bacb11618578718dce8692 | 4,046 | cpp | C++ | example/flappy_world.cpp | linussjo/linussjo_engine | 6a5db383633ffb99a2e83666e74fe7159d7b0c53 | [
"MIT"
] | null | null | null | example/flappy_world.cpp | linussjo/linussjo_engine | 6a5db383633ffb99a2e83666e74fe7159d7b0c53 | [
"MIT"
] | 4 | 2020-02-20T20:16:21.000Z | 2020-07-06T16:36:26.000Z | example/flappy_world.cpp | linussjo/linussjo_engine | 6a5db383633ffb99a2e83666e74fe7159d7b0c53 | [
"MIT"
] | null | null | null | //
// flappy_world.cpp
// linussjo_engine
//
// Created by Linus Sjöström on 2019-09-30.
// Copyright © 2019 Linus Sjöström. All rights reserved.
//
#include "flappy_world.hpp"
flappy_world::flappy_world(const std::shared_ptr<engine::graphic::graphic_engine> &ge, unsigned int w, unsigned int h) : world(ge, w, h){}
void flappy_world::first_prepare()
{
this->right = std::make_shared<engine::graphic::shape::texture>(engine::math::point2d{0,0}, std::string(IMG_RESOURCE+"/8-bit_Andreas.png"), 3);
this->left = std::make_shared<engine::graphic::shape::texture>(engine::math::point2d{0,0}, std::string(IMG_RESOURCE+"/8-bit_AndreasLeft.png"), 3);
auto po = std::make_shared<engine::physic::physical_object>(this->right);
this->left->is_visible = false;
po->pos = engine::math::vector2d{200,350};
po->velocity.x = 0;
po->is_affected_by_gravity = true;
po->width = 36;
po->height = 50;
this->character = po;
this->character->insert_shape(this->left);
this->append_po_object(po);
}
void flappy_world::create_obstacles()
{
auto re3 = std::make_shared<engine::graphic::shape::rectangle>(engine::math::point2d{0,0}, 50,2500);
auto po3 = std::make_shared<engine::physic::physical_object>(re3);
po3->height = 50;
po3->width = 2500;
po3->pos = engine::math::vector2d{100,600};
po3->is_affected_by_gravity = false;
po3->is_static = true;
this->append_po_object(po3);
auto re4 = std::make_shared<engine::graphic::shape::rectangle>(engine::math::point2d{0,0}, 75,200);
auto po4 = std::make_shared<engine::physic::physical_object>(re4);
po4->height = 75;
po4->width = 200;
po4->pos = engine::math::vector2d{400,450};
po4->is_affected_by_gravity = false;
po4->is_static = true;
this->append_po_object(po4);
auto re5 = std::make_shared<engine::graphic::shape::rectangle>(engine::math::point2d{0,0}, 200, 50);
auto po5 = std::make_shared<engine::physic::physical_object>(re5);
po5->height = 200;
po5->width = 50;
po5->pos = engine::math::vector2d{949,300};
po5->is_affected_by_gravity = false;
po5->is_static = true;
this->append_po_object(po5);
}
void flappy_world::prepare()
{
this->character->pos = engine::math::vector2d{500,350};
this->get_graphic_engine()->prepare_draw_for_focus(this->last_pos.x - this->character->pos.x, this->last_pos.y - this->character->pos.y);
this->character->velocity = engine::math::vector2f{0,0};
this->create_obstacles();
this->last_pos = this->character->pos;
}
void flappy_world::on_iteration()
{
this->get_graphic_engine()->prepare_draw_for_focus(this->last_pos.x - this->character->pos.x, this->last_pos.y - this->character->pos.y);
}
void flappy_world::on_key_input(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS && this->character->is_grounded)
{
this->character->velocity.y = -400;
this->character->is_grounded = false;
}
if (key == GLFW_KEY_LEFT && action == GLFW_PRESS)
{
this->character->velocity.x = -300;
this->left->is_visible = true;
this->right->is_visible = false;
}
if (key == GLFW_KEY_RIGHT && action == GLFW_PRESS)
{
this->character->velocity.x = 300;
this->left->is_visible = false;
this->right->is_visible = true;
}
if (key == GLFW_KEY_UP && action == GLFW_PRESS)
{
this->character->velocity.y = -400;
}
if (key == GLFW_KEY_DOWN && action == GLFW_PRESS)
{
this->character->velocity.y = 300;
}
if ((key == GLFW_KEY_ESCAPE || key == GLFW_KEY_Q) && action == GLFW_PRESS)
{
this->continue_run = false;
}
if((key == GLFW_KEY_LEFT || key == GLFW_KEY_RIGHT) && action == GLFW_RELEASE)
{
this->character->velocity.x = 0;
}
if((key == GLFW_KEY_UP || key == GLFW_KEY_DOWN) && action == GLFW_RELEASE)
{
this->character->velocity.y = 0;
}
}
| 34 | 150 | 0.642116 | linussjo |
38f78352a606e9a9500733f7a5dee45abd5f97c7 | 5,958 | cpp | C++ | modules/tracktion_engine/playback/graph/tracktion_ModifierNode.cpp | jbloit/tracktion_engine | b3fa7d6a3a404f64ae419abdf9c801d672cffb16 | [
"MIT",
"Unlicense"
] | 734 | 2018-11-16T09:39:40.000Z | 2022-03-30T16:56:14.000Z | modules/tracktion_engine/playback/graph/tracktion_ModifierNode.cpp | jbloit/tracktion_engine | b3fa7d6a3a404f64ae419abdf9c801d672cffb16 | [
"MIT",
"Unlicense"
] | 100 | 2018-11-16T18:04:08.000Z | 2022-03-31T17:47:53.000Z | modules/tracktion_engine/playback/graph/tracktion_ModifierNode.cpp | jbloit/tracktion_engine | b3fa7d6a3a404f64ae419abdf9c801d672cffb16 | [
"MIT",
"Unlicense"
] | 123 | 2018-11-16T15:51:50.000Z | 2022-03-29T12:21:27.000Z | /*
,--. ,--. ,--. ,--.
,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2018
'-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
| | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
`---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
*/
#pragma once
namespace tracktion_engine
{
ModifierNode::ModifierNode (std::unique_ptr<Node> inputNode,
tracktion_engine::Modifier::Ptr modifierToProcess,
double sampleRateToUse, int blockSizeToUse,
const TrackMuteState* trackMuteStateToUse,
tracktion_graph::PlayHeadState& playHeadStateToUse, bool rendering)
: input (std::move (inputNode)),
modifier (std::move (modifierToProcess)),
trackMuteState (trackMuteStateToUse),
playHeadState (&playHeadStateToUse),
isRendering (rendering)
{
jassert (input != nullptr);
jassert (modifier != nullptr);
initialiseModifier (sampleRateToUse, blockSizeToUse);
}
ModifierNode::ModifierNode (std::unique_ptr<Node> inputNode,
tracktion_engine::Modifier::Ptr modifierToProcess,
double sampleRateToUse, int blockSizeToUse,
std::shared_ptr<InputProvider> contextProvider)
: input (std::move (inputNode)),
modifier (std::move (modifierToProcess)),
audioRenderContextProvider (std::move (contextProvider))
{
jassert (input != nullptr);
jassert (modifier != nullptr);
initialiseModifier (sampleRateToUse, blockSizeToUse);
}
ModifierNode::~ModifierNode()
{
if (isInitialised && ! modifier->baseClassNeedsInitialising())
modifier->baseClassDeinitialise();
}
//==============================================================================
tracktion_graph::NodeProperties ModifierNode::getNodeProperties()
{
auto props = input->getNodeProperties();
props.numberOfChannels = juce::jmax (props.numberOfChannels, modifier->getAudioInputNames().size());
props.hasAudio = props.hasAudio || modifier->getAudioInputNames().size() > 0;
props.hasMidi = props.hasMidi || modifier->getMidiInputNames().size() > 0;
props.nodeID = (size_t) modifier->itemID.getRawID();
return props;
}
void ModifierNode::prepareToPlay (const tracktion_graph::PlaybackInitialisationInfo& info)
{
juce::ignoreUnused (info);
jassert (sampleRate == info.sampleRate);
auto props = getNodeProperties();
if (props.latencyNumSamples > 0)
automationAdjustmentTime = -tracktion_graph::sampleToTime (props.latencyNumSamples, sampleRate);
}
void ModifierNode::process (ProcessContext& pc)
{
auto inputBuffers = input->getProcessedOutput();
auto& inputAudioBlock = inputBuffers.audio;
auto& outputBuffers = pc.buffers;
auto& outputAudioBlock = outputBuffers.audio;
// Copy the inputs to the outputs, then process using the
// output buffers as that will be the correct size
if (auto numInputChannelsToCopy = std::min (inputAudioBlock.getNumChannels(),
outputAudioBlock.getNumChannels()))
{
jassert (inputAudioBlock.getNumFrames() == outputAudioBlock.getNumFrames());
copy (outputAudioBlock.getFirstChannels (numInputChannelsToCopy),
inputAudioBlock.getFirstChannels (numInputChannelsToCopy));
}
// Setup audio buffers
auto outputAudioBuffer = tracktion_graph::toAudioBuffer (outputAudioBlock);
// Then MIDI buffers
midiMessageArray.copyFrom (inputBuffers.midi);
bool shouldProcess = getBoolParamValue (*modifier->enabledParam);
if (playHeadState != nullptr && playHeadState->didPlayheadJump())
midiMessageArray.isAllNotesOff = true;
if (trackMuteState != nullptr)
{
if (! trackMuteState->shouldTrackContentsBeProcessed())
{
shouldProcess = shouldProcess && trackMuteState->shouldTrackBeAudible();
if (trackMuteState->wasJustMuted())
midiMessageArray.isAllNotesOff = true;
}
}
// Process the plugin
if (shouldProcess)
modifier->baseClassApplyToBuffer (getPluginRenderContext (pc.referenceSampleRange.getStart(), outputAudioBuffer));
// Then copy the buffers to the outputs
outputBuffers.midi.copyFrom (midiMessageArray);
}
//==============================================================================
void ModifierNode::initialiseModifier (double sampleRateToUse, int blockSizeToUse)
{
sampleRate = sampleRateToUse;
modifier->baseClassInitialise (sampleRate, blockSizeToUse);
isInitialised = true;
}
PluginRenderContext ModifierNode::getPluginRenderContext (int64_t referenceSamplePosition, juce::AudioBuffer<float>& destBuffer)
{
if (audioRenderContextProvider != nullptr)
{
tracktion_engine::PluginRenderContext rc (audioRenderContextProvider->getContext());
rc.destBuffer = &destBuffer;
rc.bufferStartSample = 0;
rc.bufferNumSamples = destBuffer.getNumSamples();
rc.bufferForMidiMessages = &midiMessageArray;
rc.midiBufferOffset = 0.0;
return rc;
}
jassert (playHeadState != nullptr);
auto& playHead = playHeadState->playHead;
return { &destBuffer,
juce::AudioChannelSet::canonicalChannelSet (destBuffer.getNumChannels()),
0, destBuffer.getNumSamples(),
&midiMessageArray, 0.0,
tracktion_graph::sampleToTime (playHead.referenceSamplePositionToTimelinePosition (referenceSamplePosition), sampleRate) + automationAdjustmentTime,
playHead.isPlaying(), playHead.isUserDragging(), isRendering, false };
}
}
| 37.949045 | 161 | 0.631252 | jbloit |
38fabda2e73e66e49bb6f3093e22e2076bf78337 | 7,556 | cpp | C++ | src/UdpUserSocketImpl.cpp | geraldselvino/GNSNet | 8d3b022186a1a3163a6466169f092b22390e8cae | [
"MIT"
] | null | null | null | src/UdpUserSocketImpl.cpp | geraldselvino/GNSNet | 8d3b022186a1a3163a6466169f092b22390e8cae | [
"MIT"
] | null | null | null | src/UdpUserSocketImpl.cpp | geraldselvino/GNSNet | 8d3b022186a1a3163a6466169f092b22390e8cae | [
"MIT"
] | null | null | null | #include "UdpUserSocket.h"
#include "UdpUserSocketImpl.h"
#include "ScopeLock.h"
/**
* Definition of the Handle class(UdpUserSocket)
*/
GNSNet::UdpUserSocket::UdpUserSocket()
: pImplUdpUserSocket(gcnew UdpUserSocketImpl())
{
}
GNSNet::UdpUserSocket::~UdpUserSocket()
{
delete pImplUdpUserSocket;
}
bool GNSNet::UdpUserSocket::CreateSocket(int PortNo)
{
return pImplUdpUserSocket->CreateSocket(PortNo);
}
bool GNSNet::UdpUserSocket::CreateSocket(int PortNo, String^ const% HostName)
{
return pImplUdpUserSocket->CreateSocket(PortNo, HostName);
}
bool GNSNet::UdpUserSocket::ShutDown()
{
return pImplUdpUserSocket->ShutDown();
}
bool GNSNet::UdpUserSocket::Send(String^ const% SendData)
{
return pImplUdpUserSocket->Send(SendData);
}
bool GNSNet::UdpUserSocket::Send(String^ const% SendData, String^ const% HostName, int PortNo)
{
return pImplUdpUserSocket->Send(SendData, HostName, PortNo);
}
bool GNSNet::UdpUserSocket::Send(String^ const% SendData, int Count)
{
return pImplUdpUserSocket->Send(SendData, Count);
}
bool GNSNet::UdpUserSocket::Recv(String^% pData)
{
return pImplUdpUserSocket->Recv(pData);
}
bool GNSNet::UdpUserSocket::DiscoverClientName()
{
return pImplUdpUserSocket->DiscoverClientName();
}
bool GNSNet::UdpUserSocket::GetClientName(String^% HostName, String^% PortNo)
{
return pImplUdpUserSocket->GetClientName(HostName, PortNo);
}
int GNSNet::UdpUserSocket::LastError()
{
return pImplUdpUserSocket->LastError();
}
bool GNSNet::UdpUserSocket::IsEnableSocket()
{
return pImplUdpUserSocket->IsEnableSocket();
}
/**
* Definition of the Body class(UdpUserSocketImpl)
*/
GNSNet::UdpUserSocketImpl::UdpUserSocketImpl()
: Socket(System::Net::Sockets::AddressFamily::InterNetwork,
System::Net::Sockets::SocketType::Dgram,
System::Net::Sockets::ProtocolType::Udp),
m_DataLen(0),
m_RecvBuf(gcnew array<Byte>(UDPRECVBUF_SIZE)),
m_SockStatus(false),
m_HostName(""),
m_Port(""),
m_nLastError(0)
{
}
GNSNet::UdpUserSocketImpl::~UdpUserSocketImpl()
{
}
bool GNSNet::UdpUserSocketImpl::CreateSocket(int PortNo)
{
return CreateSocket(PortNo, "");
}
bool GNSNet::UdpUserSocketImpl::CreateSocket(int PortNo, String^ const% HostName)
{
bool ret = true;
if(HostName == ""){
m_Kind = SERVER;
}
else{
m_Kind = CLIENT;
}
try{
if(m_Kind == SERVER){
IPEndPoint^ anyEndPoint = gcnew IPEndPoint(IPAddress::Any, PortNo);
Socket::Bind(anyEndPoint);
remoteEP = dynamic_cast<EndPoint^>(anyEndPoint);
}
else{
IPEndPoint^ serverEndPoint = gcnew IPEndPoint(IPAddress::Parse(HostName), PortNo);
remoteEP = dynamic_cast<EndPoint^>(serverEndPoint);
}
m_SockStatus = true;
SetClientName(HostName, PortNo.ToString());
}
catch(SocketException^ e){
m_nLastError = e->ErrorCode;
ret = false;
}
return ret;
}
bool GNSNet::UdpUserSocketImpl::ShutDown()
{
bool ret = true;
try{
if(IsEnableSocket()){
Socket::Shutdown(SocketShutdown::Both);
m_SockStatus = false;
}
SetClientName("", "");
Socket::Close();
}
catch(SocketException^ e){
m_nLastError = e->ErrorCode;
ret = false;
}
Thread::Sleep(100);
return ret;
}
bool GNSNet::UdpUserSocketImpl::Send(String^ const% SendData)
{
bool ret = true;
if(!IsEnableSocket()){
return false;
}
try{
array<Byte>^ t_Data;
Encoding^ l_encode = Encoding::GetEncoding("utf-32");
t_Data = l_encode->GetBytes(SendData);
Socket::SendTo(t_Data, remoteEP);
}
catch(SocketException^ e){
ret = false;
m_nLastError = e->ErrorCode;
}
return ret;
}
bool GNSNet::UdpUserSocketImpl::Send(String^ const% SendData, String^ const% HostName, int PortNo)
{
bool ret = true;
if(!IsEnableSocket()){
return false;
}
try{
IPEndPoint^ toEndpoint = gcnew IPEndPoint(IPAddress::Parse(HostName), PortNo);
array<Byte>^ t_Data;
Encoding^ l_encode = Encoding::GetEncoding("utf-32");
t_Data = l_encode->GetBytes(SendData);
Socket::SendTo(t_Data, toEndpoint);
}
catch(SocketException^ e){
ret = false;
m_nLastError = e->ErrorCode;
}
return ret;
}
bool GNSNet::UdpUserSocketImpl::Send(String^ const% SendData, int Count)
{
bool ret = true;
if(!IsEnableSocket()){
return false;
}
try{
array<Byte>^ t_Data;
Encoding^ l_encode = Encoding::GetEncoding("utf-32");
t_Data = l_encode->GetBytes(SendData);
Socket::SendTo(t_Data, Count, SocketFlags::None, remoteEP);
}
catch(SocketException^ e){
ret = false;
m_nLastError = e->ErrorCode;
}
return ret;
}
bool GNSNet::UdpUserSocketImpl::Recv(String^% pData)
{
ScopeLock l_Lock(m_RecvBuf);
bool ret = true;
pData = "";
if(!IsEnableSocket()){
return false;
}
int RecvCount = m_DataLen;
while(true){
if(GetRecord(pData, m_DataLen)){
break;
}
RecvCount = UDPRECVBUF_SIZE;
try{
m_DataLen = Socket::ReceiveFrom(m_RecvBuf, RecvCount, SocketFlags::None, remoteEP);
}
catch(SocketException^ e){
m_nLastError = e->ErrorCode;
if(m_nLastError != 10040){
m_DataLen = 0;
ret = false;
break;
}
else{
m_DataLen = RecvCount;
ret = true;
}
}
catch(InvalidOperationException^){
if(!Socket::IsBound){
m_DataLen = 0;
ret = true;
}
else{
m_DataLen = 0;
ret = false;
break;
}
}
}
return ret;
}
bool GNSNet::UdpUserSocketImpl::GetRecord(String^% pRecord, int RecvCount)
{
int RecvDataLen;
bool ret = false;
RecvDataLen = RecvCount;
if(RecvDataLen > 0){
Encoding^ l_encode = Encoding::GetEncoding("utf-32");
pRecord = l_encode->GetString(m_RecvBuf, 0, RecvCount);
delete m_RecvBuf;
m_RecvBuf = gcnew array<Byte>(UDPRECVBUF_SIZE);
m_DataLen = 0;
ret = true;
}
return ret;
}
bool GNSNet::UdpUserSocketImpl::DiscoverClientName()
{
String^ HostName;
String^ PortNo;
bool ret = true;
try{
IPEndPoint^ pRemoteEndPoint = dynamic_cast<IPEndPoint^>(remoteEP);
HostName = pRemoteEndPoint->Address->ToString();
PortNo = String::Format("{0:0000}",pRemoteEndPoint->Port.ToString());
}
catch(SocketException^ e){
HostName = "";
PortNo = "";
m_nLastError = e->ErrorCode;
ret = false;
}
SetClientName(HostName, PortNo);
return ret;
}
bool GNSNet::UdpUserSocketImpl::GetClientName(String^% HostName, String^% PortNo)
{
{
ScopeLock l_Lock(m_HostName);
HostName = m_HostName;
}
{
ScopeLock l_Lock(m_Port);
PortNo = m_Port;
}
return true;
}
bool GNSNet::UdpUserSocketImpl::SetClientName(String^ const% HostName, String^ const% PortNo)
{
{
ScopeLock l_Lock(m_HostName);
m_HostName = HostName;
}
{
ScopeLock l_Lock(m_Port);
m_Port = PortNo;
}
return true;
} | 22.158358 | 98 | 0.606935 | geraldselvino |
38fbf7654002c87ba777bd68cc15190b32a4b815 | 1,183 | cpp | C++ | core/main.cpp | 7-6-6/niggahack | 1f4f42a9fd1c89126c7d865f70eaa336ab1f6135 | [
"MIT"
] | null | null | null | core/main.cpp | 7-6-6/niggahack | 1f4f42a9fd1c89126c7d865f70eaa336ab1f6135 | [
"MIT"
] | null | null | null | core/main.cpp | 7-6-6/niggahack | 1f4f42a9fd1c89126c7d865f70eaa336ab1f6135 | [
"MIT"
] | null | null | null | #include "../dependencies/common_includes.hpp"
#include "features/misc/misc.hpp"
#include "menu/config/config.hpp"
#include "features/misc/events.hpp"
#include "features/skinchanger/parser.hpp"
unsigned long __stdcall initial_thread(void* reserved) {
while (!GetModuleHandleA("serverbrowser.dll"))
Sleep(200);
try {
interfaces::initialize();
hooks::initialize();
render.setup_fonts();
utilities::material_setup();
config_system.run("nigga hack");
events.setup();
kit_parser.setup();
}
catch (const std::runtime_error & error) {
MessageBoxA(NULL, error.what(), "nigga hack", MB_OK | MB_ICONERROR);
FreeLibraryAndExitThread(reinterpret_cast<HMODULE>(reserved), 0);
return 0ul;
}
while (!GetAsyncKeyState(VK_END))
std::this_thread::sleep_for(std::chrono::milliseconds(50));
hooks::shutdown();
std::this_thread::sleep_for(std::chrono::milliseconds(100));
FreeLibraryAndExitThread(reinterpret_cast<HMODULE>(reserved), 0);
return 0ul;
}
bool __stdcall DllMain(void* instance, unsigned long reason_to_call, void* reserved) {
if (reason_to_call == DLL_PROCESS_ATTACH) {
CreateThread(0, 0, initial_thread, instance, 0, 0);
}
return true;
} | 24.142857 | 86 | 0.734573 | 7-6-6 |
38fe64d1ed97a725dc66e6dfa2a0eb14135e0b1e | 4,070 | cpp | C++ | source/util/compression/int/compressedset/LazyAndSet.cpp | izenecloud/izenelib | 9d5958100e2ce763fc75f27217adf982d7c9d902 | [
"Apache-2.0"
] | 31 | 2015-03-03T19:13:42.000Z | 2020-09-03T08:11:56.000Z | source/util/compression/int/compressedset/LazyAndSet.cpp | izenecloud/izenelib | 9d5958100e2ce763fc75f27217adf982d7c9d902 | [
"Apache-2.0"
] | 1 | 2016-12-24T00:12:11.000Z | 2016-12-24T00:12:11.000Z | source/util/compression/int/compressedset/LazyAndSet.cpp | izenecloud/izenelib | 9d5958100e2ce763fc75f27217adf982d7c9d902 | [
"Apache-2.0"
] | 8 | 2015-09-06T01:55:21.000Z | 2021-12-20T02:16:13.000Z | #include <vector>
#include <util/compression/int/compressedset/Set.h>
#include <util/compression/int/compressedset/LazyAndSet.h>
namespace izenelib
{
namespace util
{
namespace compression
{
LazyAndSet::LazyAndSet()
{
sets_ = vector<boost::shared_ptr<Set> >();
nonNullSize = 0;
setSize = 0;
init = false;
}
LazyAndSet::LazyAndSet(vector<boost::shared_ptr<Set> >& sets)
{
sets_ = sets;
nonNullSize = sets.size();
setSize = 0;
init = false;
}
inline bool LazyAndSet::find(unsigned int val) const
{
LazyAndSetIterator finder(this);
unsigned docid = finder.Advance(val);
return docid != NO_MORE_DOCS && docid == val;
}
unsigned int LazyAndSet::size() const
{
// Do the size if we haven't done it so far.
if(!init)
{
LazyAndSetIterator dcit(this);
setSize = 0;
while(dcit.nextDoc() != NO_MORE_DOCS)
setSize++;
}
init = true;
return setSize;
}
boost::shared_ptr<Set::Iterator> LazyAndSet::iterator() const
{
boost::shared_ptr<Set::Iterator> it(new LazyAndSetIterator(this));
return it;
}
LazyAndSetIterator::LazyAndSetIterator(const LazyAndSet* parent) : set(*parent)
{
lastReturn = 0;
if (set.nonNullSize < 1)
throw string("Minimum one iterator required");
for (vector<boost::shared_ptr<Set> >::const_iterator it = set.sets_.begin(); it!=set.sets_.end(); it++)
{
boost::shared_ptr<Set> set = *it;
boost::shared_ptr<Set::Iterator> dcit = set->iterator();
iterators.push_back(dcit);
}
lastReturn = (iterators.size() > 0 ? 0 : NO_MORE_DOCS);
}
unsigned int LazyAndSetIterator::docID()
{
return lastReturn;
}
unsigned int LazyAndSetIterator::nextDoc()
{
// DAAT
if (lastReturn == NO_MORE_DOCS)
return NO_MORE_DOCS;
boost::shared_ptr<Set::Iterator> dcit = iterators[0];
unsigned target = dcit->nextDoc();
// shortcut: if it reaches the end of the shortest list, do not scan other lists
if(target == NO_MORE_DOCS)
{
return (lastReturn = target);
}
int size = iterators.size();
int skip = 0;
int i = 1;
// i is ith iterator
while (i < size)
{
if (i != skip)
{
dcit = iterators[i];
unsigned int docId = dcit->Advance(target);
// once we reach the end of one of the blocks, we return NO_MORE_DOCS
if(docId == NO_MORE_DOCS)
{
return (lastReturn = docId);
}
if (docId > target) // cannot find the target in the next list
{
target = docId;
if(i != 0)
{
skip = i;
i = 0;
continue;
}
else // for the first list, it must succeed as long as the docId is not NO_MORE_DOCS
{
skip = 0;
}
}
}
i++;
}
return (lastReturn = target);
}
unsigned int LazyAndSetIterator::Advance(unsigned int target)
{
if (lastReturn == NO_MORE_DOCS)
return NO_MORE_DOCS;
boost::shared_ptr<Set::Iterator> dcit = iterators[0];
target = dcit->Advance(target);
if(target == NO_MORE_DOCS)
{
return (lastReturn = target);
}
int size = iterators.size();
int skip = 0;
int i = 1;
while (i < size)
{
if (i != skip)
{
dcit = iterators[i];
unsigned int docId = dcit->Advance(target);
if(docId == NO_MORE_DOCS)
{
return (lastReturn = docId);
}
if (docId > target)
{
target = docId;
if(i != 0)
{
skip = i;
i = 0;
continue;
}
else
{
skip = 0;
}
}
}
i++;
}
return (lastReturn = target);
}
}
}
}
| 22.865169 | 107 | 0.523587 | izenecloud |
38ff7b8dc0ecf519a013dfe3ee8a0e2b2f4b6383 | 3,521 | cpp | C++ | IfcPlusPlus/src/ifcpp/IFC4/lib/IfcParameterizedProfileDef.cpp | AlexVlk/ifcplusplus | 2f8cd5457312282b8d90b261dbf8fb66e1c84057 | [
"MIT"
] | 426 | 2015-04-12T10:00:46.000Z | 2022-03-29T11:03:02.000Z | IfcPlusPlus/src/ifcpp/IFC4/lib/IfcParameterizedProfileDef.cpp | AlexVlk/ifcplusplus | 2f8cd5457312282b8d90b261dbf8fb66e1c84057 | [
"MIT"
] | 124 | 2015-05-15T05:51:00.000Z | 2022-02-09T15:25:12.000Z | IfcPlusPlus/src/ifcpp/IFC4/lib/IfcParameterizedProfileDef.cpp | AlexVlk/ifcplusplus | 2f8cd5457312282b8d90b261dbf8fb66e1c84057 | [
"MIT"
] | 214 | 2015-05-06T07:30:37.000Z | 2022-03-26T16:14:04.000Z | /* Code generated by IfcQuery EXPRESS generator, www.ifcquery.com */
#include <sstream>
#include <limits>
#include "ifcpp/model/AttributeObject.h"
#include "ifcpp/model/BuildingException.h"
#include "ifcpp/model/BuildingGuid.h"
#include "ifcpp/reader/ReaderUtil.h"
#include "ifcpp/writer/WriterUtil.h"
#include "ifcpp/IFC4/include/IfcAxis2Placement2D.h"
#include "ifcpp/IFC4/include/IfcExternalReferenceRelationship.h"
#include "ifcpp/IFC4/include/IfcLabel.h"
#include "ifcpp/IFC4/include/IfcParameterizedProfileDef.h"
#include "ifcpp/IFC4/include/IfcProfileProperties.h"
#include "ifcpp/IFC4/include/IfcProfileTypeEnum.h"
// ENTITY IfcParameterizedProfileDef
IfcParameterizedProfileDef::IfcParameterizedProfileDef( int id ) { m_entity_id = id; }
shared_ptr<BuildingObject> IfcParameterizedProfileDef::getDeepCopy( BuildingCopyOptions& options )
{
shared_ptr<IfcParameterizedProfileDef> copy_self( new IfcParameterizedProfileDef() );
if( m_ProfileType ) { copy_self->m_ProfileType = dynamic_pointer_cast<IfcProfileTypeEnum>( m_ProfileType->getDeepCopy(options) ); }
if( m_ProfileName ) { copy_self->m_ProfileName = dynamic_pointer_cast<IfcLabel>( m_ProfileName->getDeepCopy(options) ); }
if( m_Position ) { copy_self->m_Position = dynamic_pointer_cast<IfcAxis2Placement2D>( m_Position->getDeepCopy(options) ); }
return copy_self;
}
void IfcParameterizedProfileDef::getStepLine( std::stringstream& stream ) const
{
stream << "#" << m_entity_id << "= IFCPARAMETERIZEDPROFILEDEF" << "(";
if( m_ProfileType ) { m_ProfileType->getStepParameter( stream ); } else { stream << "$"; }
stream << ",";
if( m_ProfileName ) { m_ProfileName->getStepParameter( stream ); } else { stream << "$"; }
stream << ",";
if( m_Position ) { stream << "#" << m_Position->m_entity_id; } else { stream << "$"; }
stream << ");";
}
void IfcParameterizedProfileDef::getStepParameter( std::stringstream& stream, bool /*is_select_type*/ ) const { stream << "#" << m_entity_id; }
const std::wstring IfcParameterizedProfileDef::toString() const { return L"IfcParameterizedProfileDef"; }
void IfcParameterizedProfileDef::readStepArguments( const std::vector<std::wstring>& args, const std::map<int,shared_ptr<BuildingEntity> >& map )
{
const size_t num_args = args.size();
if( num_args != 3 ){ std::stringstream err; err << "Wrong parameter count for entity IfcParameterizedProfileDef, expecting 3, having " << num_args << ". Entity ID: " << m_entity_id << std::endl; throw BuildingException( err.str().c_str() ); }
m_ProfileType = IfcProfileTypeEnum::createObjectFromSTEP( args[0], map );
m_ProfileName = IfcLabel::createObjectFromSTEP( args[1], map );
readEntityReference( args[2], m_Position, map );
}
void IfcParameterizedProfileDef::getAttributes( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes ) const
{
IfcProfileDef::getAttributes( vec_attributes );
vec_attributes.emplace_back( std::make_pair( "Position", m_Position ) );
}
void IfcParameterizedProfileDef::getAttributesInverse( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes_inverse ) const
{
IfcProfileDef::getAttributesInverse( vec_attributes_inverse );
}
void IfcParameterizedProfileDef::setInverseCounterparts( shared_ptr<BuildingEntity> ptr_self_entity )
{
IfcProfileDef::setInverseCounterparts( ptr_self_entity );
}
void IfcParameterizedProfileDef::unlinkFromInverseCounterparts()
{
IfcProfileDef::unlinkFromInverseCounterparts();
}
| 55.015625 | 244 | 0.755183 | AlexVlk |
ac014641e10e2c843aa70fa79171b5705b8df544 | 5,366 | cc | C++ | physics/neutron/models/src/NeutronNudyFissionModel.cc | Geant-RnD/geant | ffff95e23547531f3254ada2857c062a31f33e8f | [
"ECL-2.0",
"Apache-2.0"
] | 2 | 2016-10-16T14:37:42.000Z | 2018-04-05T15:49:09.000Z | physics/neutron/models/src/NeutronNudyFissionModel.cc | Geant-RnD/geant | ffff95e23547531f3254ada2857c062a31f33e8f | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | physics/neutron/models/src/NeutronNudyFissionModel.cc | Geant-RnD/geant | ffff95e23547531f3254ada2857c062a31f33e8f | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | //
#include "Geant/NeutronNudyFissionModel.h"
#include "Geant/PhysicalConstants.h"
// for Vector_t
#include "Geant/Types.h"
#include "Geant/PhysicsData.h"
#include "Geant/Isotope.h"
#include "Geant/LightTrack.h"
#include "Geant/PhysicsData.h"
#include <iostream>
#include "Geant/math_wrappers.h"
// this should be replaced by some VecMath classes
#include "base/Lorentz.h"
#include "base/Vector3D.h"
namespace geantphysics {
NeutronNudyFissionModel::NeutronNudyFissionModel(const std::string &modelname) : HadronicFinalStateModel()
{
this->SetType(HadronicModelType::kNeutronNudy);
this->SetName(modelname);
std::vector<int> projVec;
projVec.push_back(1);
projVec.push_back(3);
projVec.push_back(10);
projVec.push_back(11);
projVec.push_back(12);
projVec.push_back(13);
projVec.push_back(14);
projVec.push_back(15);
projVec.push_back(16);
projVec.push_back(17);
char *path = std::getenv("GEANT_PHYSICS_DATA");
if (!path) {
std::cerr << "****** ERROR in NeutronNudyXsec() \n"
<< " GEANT_PHYSICS_DATA is not defined! Set the GEANT_PHYSICS_DATA\n"
<< " environmental variable to the location of Geant data directory\n"
<< " It should be .root file processed from ENDF data using EndfToPointRoot\n"
<< " executable. For more details see EndfToRoot in \n"
<< " physics/neutron/nudy/EndfToRoot/README\n"
<< " root file name format is n-Z_A.root!\n"
<< std::endl;
exit(1);
}
std::string tmp = path;
filename = tmp + "/neutron/nudy/n-";
this->SetProjectileCodeVec(projVec);
}
NeutronNudyFissionModel::~NeutronNudyFissionModel() {}
void NeutronNudyFissionModel::Initialize()
{
HadronicFinalStateModel::Initialize(); //
}
int NeutronNudyFissionModel::SampleFinalState(LightTrack &track, Isotope *targetisotope, geant::TaskData *td)
{
using vecgeom::LorentzRotation;
using vecgeom::LorentzVector;
using vecgeom::Vector3D;
int numSecondaries = 0;
double Ek = track.GetKinE();
// check if kinetic energy is below fLowEnergyUsageLimit and do nothing if yes;
// check if kinetic energy is above fHighEnergyUsageLimit andd o nothing if yes
if (Ek < GetLowEnergyUsageLimit() || Ek > GetHighEnergyUsageLimit()) {
return numSecondaries;
}
/*
std::cout << "NeutronNudyFissionModel: "
<< track.GetGVcode()
<< " Ekin(MeV) = " << Ek/geant::units::MeV
<< " scattered off Z= " << targetisotope->GetZ()
<< " N= " << targetisotope->GetN()
<< std::endl;
*/
int Z = targetisotope->GetZ();
int A = targetisotope->GetN();
std::string z = std::to_string(Z);
std::string a = std::to_string(A);
std::string tmp = filename + z + "_" + a + ".root";
// int particlePDG = Particle::GetParticleByInternalCode(particleCode)->GetPDGCode();
fRENDF = tmp.c_str();
int elemId = Z * 1000 + A;
recopoint.GetData(elemId, fRENDF);
// projectile mass
double mass1 = track.GetMass();
// target mass
// double mass2 = targetisotope->GetIsoMass();
// momentum in lab frame
double plab = std::sqrt(Ek * (Ek + 2 * mass1));
double nut = recopoint.GetNuTotal(elemId, Ek / geant::units::eV);
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::default_random_engine generator(seed);
std::poisson_distribution<int> distribution(nut);
int number = distribution(generator);
while (number == 0) {
number = distribution(generator);
}
numSecondaries = number;
for (int i = 0; i != number; ++i) {
double cosLab = recopoint.GetCos4(elemId, 2, Ek / geant::units::eV);
if (cosLab == -99) {
cosLab = 2 * td->fRndm->uniform() - 1;
}
double sinLab = 0;
// problem in sampling
if (cosLab > 1.0 || cosLab < -1.0) {
std::cout << "GVNeutronNudyFission WARNING (1 - cost)= " << 1 - cosLab << " after Fission of "
<< track.GetGVcode() << " p(GeV/c)= " << plab / geant::units::GeV
<< " on an ion Z= " << targetisotope->GetZ() << " N= " << targetisotope->GetN() << std::endl;
cosLab = 1.0;
sinLab = 0.0;
// normal situation
} else {
sinLab = std::sqrt((1.0 - cosLab) * (1.0 + cosLab));
}
double phi = geant::units::kTwoPi * td->fRndm->uniform();
double sinphi, cosphi;
Math::SinCos(phi, sinphi, cosphi);
double nDirX = sinLab * cosphi;
double nDirY = sinLab * sinphi;
double nDirZ = cosLab;
// rotate in the origional particle frame : This need to be checked: Harphool
// energy of the neutron from the ENDF distributions
double energy = recopoint.GetEnergy5(elemId, 18, Ek / geant::units::eV) * geant::units::eV;
// killing primary track after fission
track.SetTrackStatus(LTrackStatus::kKill);
track.SetKinE(0.0);
auto &secondarySoA = td->fPhysicsData->InsertSecondary();
// Add neutron
// int idx = secondarySoA.InsertTrack();
secondarySoA.SetDirX(nDirX);
secondarySoA.SetDirY(nDirY);
secondarySoA.SetDirZ(nDirZ);
secondarySoA.SetKinE(energy);
secondarySoA.SetGVcode(track.GetGVcode());
secondarySoA.SetMass(track.GetMass());
secondarySoA.SetTrackIndex(track.GetTrackIndex()); // parent Track index
}
return numSecondaries;
}
} // namespace geantphysics
| 33.962025 | 109 | 0.647782 | Geant-RnD |
ac03eb4a9a1a7a7d0847a8788296833f6c931ce3 | 58 | hpp | C++ | src/boost_fusion_include_adapt_assoc_adt_named.hpp | miathedev/BoostForArduino | 919621dcd0c157094bed4df752b583ba6ea6409e | [
"BSL-1.0"
] | 10 | 2018-03-17T00:58:42.000Z | 2021-07-06T02:48:49.000Z | src/boost_fusion_include_adapt_assoc_adt_named.hpp | miathedev/BoostForArduino | 919621dcd0c157094bed4df752b583ba6ea6409e | [
"BSL-1.0"
] | 2 | 2021-03-26T15:17:35.000Z | 2021-05-20T23:55:08.000Z | src/boost_fusion_include_adapt_assoc_adt_named.hpp | miathedev/BoostForArduino | 919621dcd0c157094bed4df752b583ba6ea6409e | [
"BSL-1.0"
] | 4 | 2019-05-28T21:06:37.000Z | 2021-07-06T03:06:52.000Z | #include <boost/fusion/include/adapt_assoc_adt_named.hpp>
| 29 | 57 | 0.844828 | miathedev |
ac046d9f70569cbabb677330f09d074f1b1f2913 | 2,766 | cpp | C++ | test.cpp | hunter-packages/alltheflops-threads | f205f3f1299482cb9f55ccbecb3993eb0ffb6a38 | [
"BSD-3-Clause"
] | null | null | null | test.cpp | hunter-packages/alltheflops-threads | f205f3f1299482cb9f55ccbecb3993eb0ffb6a38 | [
"BSD-3-Clause"
] | null | null | null | test.cpp | hunter-packages/alltheflops-threads | f205f3f1299482cb9f55ccbecb3993eb0ffb6a38 | [
"BSD-3-Clause"
] | 2 | 2020-10-01T04:01:08.000Z | 2021-07-01T07:43:01.000Z |
#include "async_queue.hpp"
#include "parallel.hpp"
#include <chrono>
using namespace std::chrono;
using namespace std;
void blah(int &c, int a, int b) {
std::cout << "starting b" << std::endl;
for(int i = 0; i < b; i++)
c += a;// + b;
std::cout << "ending b" << std::endl;
}
void other(float& out, int a, int b) {
out = a * b;
}
int main(int argc, char *argv[])
{
std::cout << "test" << std::endl;
async_queue my_queue;
int c = 0;
float d = 0;
my_queue.enqueue(blah, std::ref(c), 1, 500);
my_queue.enqueue(other, std::ref(d), 1, 500);
my_queue.sync();
std::cout << c << std::endl;
my_queue.enqueue(blah, std::ref(c), 7, 5000);
my_queue.enqueue(blah, std::ref(c), 9, 5000000000);
my_queue.enqueue(blah, std::ref(c), 1, 15);
//for(int i = 0; i < 100; i++)
//std::cout << c << std::endl;
std::this_thread::sleep_for(milliseconds(1000));
std::cout << c << std::endl;
std::cout << dec;
//auto iter = make_tuple<size_t, size_t, size_t, size_t>((10 * argc + 1), (100 * argc + 1), (100 * argc + 1), (100 * argc + 1));
auto iter = dim_t{{size_t(2000000 * argc ), size_t(1000 ), size_t(1), size_t(16)}};
vector<float> out(get<0>(iter)* get<2>(iter)* get<2>(iter)* get<3>(iter));
vector<float> in(get<0>(iter)* get<2>(iter)* get<2>(iter)* get<3>(iter));
{
auto start = high_resolution_clock::now();
for(size_t i = 0; i < get<3>(iter); i++) {
for(size_t j = 0; j < get<2>(iter); j++) {
for(size_t k = 0; k < get<1>(iter); k++) {
for(size_t l = 0; l < get<0>(iter); l++) {
out[i*get<3>(iter) + j * get<2>(iter) + k *get<1>(iter) + l ] = (in[i*get<3>(iter) + j * get<2>(iter) + k *get<1>(iter) + l ] );
}
}
}
}
size_t ms = duration_cast<milliseconds>(high_resolution_clock::now() - start).count();
std::cout << "duration: " << ms << "ms"<< std::endl;
std::cout << out[24] << endl;
}
//vector<float> out1(get<0>(iter)* get<1>(iter)* get<2>(iter)* get<3>(iter));
//vector<float> in1(get<0>(iter)* get<1>(iter)* get<2>(iter)* get<3>(iter), argc);
for(int i = 0; i < 1; i ++) {
auto start = high_resolution_clock::now();
parallel_mat par(iter, [&](const dim_t &loc) {
out[get<3>(loc)*get<3>(iter) + get<2>(loc) * get<2>(iter) + get<1>(loc) *get<1>(iter) + loc[0]] =
(in[get<3>(loc)*get<3>(iter) + get<2>(loc) * get<2>(iter) + get<1>(loc) *get<1>(iter) + loc[0]]);
});
auto ms = duration_cast<milliseconds>(high_resolution_clock::now() - start).count();
std::cout << "duration: " << ms << "ms"<< std::endl;
std::cout << out[24] << endl;
}
return 0;
}
| 34.575 | 148 | 0.522054 | hunter-packages |
f19bd8ffaa302bbcfb87123bcb193e816495ceb4 | 5,765 | hpp | C++ | transmission_interface_extensions/include/transmission_interface_extensions/posveleff_joint_interface_provider.hpp | smilerobotics/ros_control_extensions | 1eee21217708dcee80aa3d91b2c6415c1f4feffa | [
"MIT"
] | null | null | null | transmission_interface_extensions/include/transmission_interface_extensions/posveleff_joint_interface_provider.hpp | smilerobotics/ros_control_extensions | 1eee21217708dcee80aa3d91b2c6415c1f4feffa | [
"MIT"
] | null | null | null | transmission_interface_extensions/include/transmission_interface_extensions/posveleff_joint_interface_provider.hpp | smilerobotics/ros_control_extensions | 1eee21217708dcee80aa3d91b2c6415c1f4feffa | [
"MIT"
] | 1 | 2021-10-14T06:37:36.000Z | 2021-10-14T06:37:36.000Z | #ifndef TRANSMISSION_INTERFACE_EXTENSIONS_POSVELEFF_JOINT_INTERFACE_PROVIDER_HPP
#define TRANSMISSION_INTERFACE_EXTENSIONS_POSVELEFF_JOINT_INTERFACE_PROVIDER_HPP
#include <string>
#include <vector>
#include <hardware_interface/robot_hw.h>
#include <hardware_interface_extensions/posveleff_command_interface.hpp>
#include <transmission_interface/transmission_info.h>
// for RequisiteProvider, JointInterfaces, RawJointDataMap, JointData
#include <transmission_interface/transmission_interface_loader.h>
#include <transmission_interface_extensions/common_namespaces.hpp>
#include <transmission_interface_extensions/posvel_joint_interface_provider.hpp>
#include <boost/foreach.hpp>
namespace transmission_interface_extensions {
class PosVelEffJointInterfaceProvider : public PosVelJointInterfaceProvider {
public:
PosVelEffJointInterfaceProvider() {}
virtual ~PosVelEffJointInterfaceProvider() {}
virtual bool updateJointInterfaces(const ti::TransmissionInfo &trans_info, hi::RobotHW *robot_hw,
ti::JointInterfaces &jnt_ifaces,
ti::RawJointDataMap &raw_jnt_data_map) {
// register state interface & handles if never
if (!JointStateInterfaceProvider::updateJointInterfaces(trans_info, robot_hw, jnt_ifaces,
raw_jnt_data_map)) {
return false;
}
// register posveleff interface if never
if (!robot_hw->get< hie::PosVelEffJointInterface >()) {
robot_hw->registerInterface(&getPosVelEffJointInterface());
}
hie::PosVelEffJointInterface &iface(*robot_hw->get< hie::PosVelEffJointInterface >());
// register posveleff handle to the posvel interface if never
BOOST_FOREACH (const ti::JointInfo &jnt_info, trans_info.joints_) {
if (!hasResource(jnt_info.name_, iface)) {
ti::RawJointData &raw_jnt_data(raw_jnt_data_map[jnt_info.name_]);
iface.registerHandle(hie::PosVelEffJointHandle(
jnt_ifaces.joint_state_interface.getHandle(jnt_info.name_), &raw_jnt_data.position_cmd,
&raw_jnt_data.velocity_cmd, &raw_jnt_data.effort_cmd));
}
}
return true;
}
protected:
virtual bool getJointCommandData(const ti::TransmissionInfo &trans_info,
const ti::RawJointDataMap &raw_jnt_data_map,
ti::JointData &jnt_cmd_data) {
// get position & velocity commands
if (!PosVelJointInterfaceProvider::getJointCommandData(trans_info, raw_jnt_data_map,
jnt_cmd_data)) {
return false;
}
// allocate destination effort command data
const std::size_t dim(trans_info.joints_.size());
jnt_cmd_data.effort.resize(dim);
// map source to destination effort command data
for (std::size_t i = 0; i < dim; ++i) {
// find source data
const ti::RawJointDataMap::const_iterator raw_jnt_data(
raw_jnt_data_map.find(trans_info.joints_[i].name_));
if (raw_jnt_data == raw_jnt_data_map.end()) {
return false;
}
// map data
jnt_cmd_data.effort[i] = const_cast< double * >(&raw_jnt_data->second.effort_cmd);
}
return true;
}
virtual bool getActuatorCommandData(const ti::TransmissionInfo &trans_info, hi::RobotHW *robot_hw,
ti::ActuatorData &act_cmd_data) {
// get position & velocity commands
if (!PosVelJointInterfaceProvider::getActuatorCommandData(trans_info, robot_hw, act_cmd_data)) {
return false;
}
// find source effort command data
std::vector< hi::ActuatorHandle > act_eff_handles;
if (!getActuatorHandles< hi::EffortActuatorInterface >(trans_info.actuators_, robot_hw,
act_eff_handles)) {
return false;
}
// allocate destination actuator command data
const std::size_t dim(trans_info.actuators_.size());
act_cmd_data.effort.resize(dim);
// map source to destination actuator command data
for (std::size_t i = 0; i < dim; ++i) {
act_cmd_data.effort[i] = const_cast< double * >(act_eff_handles[i].getCommandPtr());
}
return true;
}
virtual bool registerTransmission(ti::TransmissionLoaderData &loader_data,
ti::RequisiteProvider::TransmissionHandleData &handle_data) {
// register state, position & velocity transmissions
if (!PosVelJointInterfaceProvider::registerTransmission(loader_data, handle_data)) {
return false;
}
// quick access to the transmission manager
ti::RobotTransmissions &trans_man(*loader_data.robot_transmissions);
// register effort command transmission interface if never
if (!trans_man.get< ti::JointToActuatorEffortInterface >()) {
trans_man.registerInterface(&loader_data.transmission_interfaces.jnt_to_act_eff_cmd);
}
ti::JointToActuatorEffortInterface &iface(
*trans_man.get< ti::JointToActuatorEffortInterface >());
// register effort command transmission handle if never
if (!hasResource(handle_data.name, iface)) {
iface.registerHandle(
ti::JointToActuatorEffortHandle(handle_data.name, handle_data.transmission.get(),
handle_data.act_cmd_data, handle_data.jnt_cmd_data));
}
return true;
}
private:
// return the joint interface. it must be in the static memory space
// to allow access from outside of this plugin.
static hie::PosVelEffJointInterface &getPosVelEffJointInterface() {
static hie::PosVelEffJointInterface interface;
return interface;
}
};
} // namespace transmission_interface_extensions
#endif | 39.486301 | 100 | 0.69072 | smilerobotics |
f19d7bd952a77946ee379e6cf579f6702f5f291a | 2,304 | cc | C++ | code/Modules/LocalFS/UnitTests/FSWrapperTest.cc | FrogAC/oryol | 7254c59411e97bbb6f2363aa685718def9f13827 | [
"MIT"
] | 1,707 | 2015-01-01T14:56:08.000Z | 2022-03-28T06:44:09.000Z | code/Modules/LocalFS/UnitTests/FSWrapperTest.cc | FrogAC/oryol | 7254c59411e97bbb6f2363aa685718def9f13827 | [
"MIT"
] | 256 | 2015-01-03T14:55:53.000Z | 2020-09-09T10:43:46.000Z | code/Modules/LocalFS/UnitTests/FSWrapperTest.cc | FrogAC/oryol | 7254c59411e97bbb6f2363aa685718def9f13827 | [
"MIT"
] | 222 | 2015-01-05T00:20:54.000Z | 2022-02-06T01:41:37.000Z | //------------------------------------------------------------------------------
// FSWrapperTest.cc
//------------------------------------------------------------------------------
#include "Pre.h"
#include "UnitTest++/src/UnitTest++.h"
#include "LocalFS/private/fsWrapper.h"
#include "Core/String/StringBuilder.h"
#include <string.h>
using namespace Oryol;
using namespace _priv;
TEST(FSWrapperTest) {
String exePath = fsWrapper::getExecutableDir();
CHECK(!exePath.Empty());
String cwdPath = fsWrapper::getCwd();
CHECK(!cwdPath.Empty());
StringBuilder strBuilder;
strBuilder.Format(4096, "%s/test.txt", cwdPath.AsCStr());
const fsWrapper::handle hw = fsWrapper::openWrite(strBuilder.AsCStr());
CHECK(hw != fsWrapper::invalidHandle);
const char* str = "Hello World\n";
const int len = int(strlen(str));
int bytesWritten = fsWrapper::write(hw, str, len);
CHECK(bytesWritten == len);
fsWrapper::close(hw);
char buf[256];
Memory::Clear(buf, sizeof(buf));
const fsWrapper::handle hr = fsWrapper::openRead(strBuilder.AsCStr());
CHECK(hr != fsWrapper::invalidHandle);
int bytesRead = fsWrapper::read(hr, buf, sizeof(buf));
CHECK(bytesRead == len);
String readStr(buf, 0, len);
CHECK(readStr == "Hello World\n");
CHECK(fsWrapper::read(hr, buf, sizeof(buf)) == 0);
CHECK(fsWrapper::seek(hr, 0));
CHECK(fsWrapper::read(hr, buf, sizeof(buf)) == len);
Memory::Clear(buf, sizeof(buf));
CHECK(fsWrapper::seek(hr, 0));
CHECK(fsWrapper::read(hr, buf, 5) == 5);
readStr.Assign(buf, 0, 5);
CHECK(readStr == "Hello");
Memory::Clear(buf, sizeof(buf));
CHECK(fsWrapper::seek(hr, 6));
CHECK(fsWrapper::read(hr, buf, sizeof(buf)) == 6);
readStr.Assign(buf, 0, 6);
CHECK(readStr == "World\n");
CHECK(fsWrapper::seek(hr, 128));
CHECK(fsWrapper::read(hr, buf, sizeof(buf)) == 0);
fsWrapper::close(hr);
const fsWrapper::handle hs = fsWrapper::openRead(strBuilder.AsCStr());
int size = fsWrapper::size(hs);
CHECK(size == 12);
CHECK(fsWrapper::seek(hs, 6));
size = fsWrapper::size(hs);
CHECK(size == 12);
CHECK(fsWrapper::read(hs, buf, sizeof(buf)) == 6);
readStr.Assign(buf, 0, 6);
CHECK(readStr == "World\n");
fsWrapper::close(hs);
}
| 34.909091 | 80 | 0.594618 | FrogAC |
f1a019cae192e5df2838a6e5a19b46e41e5efa40 | 1,347 | hpp | C++ | src/pitts_tensor2_random.hpp | melven/pitts | 491f503a99a7d1161a27672955ae53ca6b5d3412 | [
"BSD-3-Clause"
] | 2 | 2021-12-31T08:28:17.000Z | 2022-01-12T14:48:49.000Z | src/pitts_tensor2_random.hpp | melven/pitts | 491f503a99a7d1161a27672955ae53ca6b5d3412 | [
"BSD-3-Clause"
] | null | null | null | src/pitts_tensor2_random.hpp | melven/pitts | 491f503a99a7d1161a27672955ae53ca6b5d3412 | [
"BSD-3-Clause"
] | null | null | null | /*! @file pitts_tensor2_random.hpp
* @brief fill simple rank-2 tensor with random values
* @author Melven Roehrig-Zoellner <Melven.Roehrig-Zoellner@DLR.de>
* @date 2019-10-10
* @copyright Deutsches Zentrum fuer Luft- und Raumfahrt e. V. (DLR), German Aerospace Center
*
**/
// include guard
#ifndef PITTS_TENSOR2_RANDOM_HPP
#define PITTS_TENSOR2_RANDOM_HPP
// includes
#include <random>
#include "pitts_tensor2.hpp"
#include "pitts_performance.hpp"
//! namespace for the library PITTS (parallel iterative tensor train solvers)
namespace PITTS
{
//! fill a rank-2 tensor with random values
//!
//! @tparam T underlying data type (double, complex, ...)
//!
template<typename T>
void randomize(Tensor2<T>& t2)
{
const auto r1 = t2.r1();
const auto r2 = t2.r2();
const auto timer = PITTS::performance::createScopedTimer<Tensor2<T>>(
{{"r1", "r2"}, {r1, r2}}, // arguments
{{r1*r2*kernel_info::NoOp<T>()}, // flops
{r1*r2*kernel_info::Store<T>()}} // data
);
std::random_device randomSeed;
std::mt19937 randomGenerator(randomSeed());
std::uniform_real_distribution<T> distribution(T(-1), T(1));
for(long long i = 0; i < r1; i++)
for(long long j = 0; j < r2; j++)
t2(i,j) = distribution(randomGenerator);
}
}
#endif // PITTS_TENSOR2_RANDOM_HPP
| 26.94 | 92 | 0.657758 | melven |
f1a35ce4be1e7e4db135a547cd5eb3a0377ec814 | 4,694 | cpp | C++ | SRC/wfc_read_xml_from_file.cpp | SammyB428/WFC | 64aee7c7953e38c8a418ba9530339e8f4faac046 | [
"BSD-2-Clause"
] | 1 | 2021-03-29T06:09:19.000Z | 2021-03-29T06:09:19.000Z | SRC/wfc_read_xml_from_file.cpp | SammyB428/WFC | 64aee7c7953e38c8a418ba9530339e8f4faac046 | [
"BSD-2-Clause"
] | null | null | null | SRC/wfc_read_xml_from_file.cpp | SammyB428/WFC | 64aee7c7953e38c8a418ba9530339e8f4faac046 | [
"BSD-2-Clause"
] | null | null | null | /*
** Author: Samuel R. Blackburn
** Internet: wfc@pobox.com
**
** Copyright, 1995-2019, Samuel R. Blackburn
**
** "You can get credit for something or get it done, but not both."
** Dr. Richard Garwin
**
** BSD License follows.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions
** are met:
**
** Redistributions of source code must retain the above copyright notice,
** this list of conditions and the following disclaimer. Redistributions
** in binary form must reproduce the above copyright notice, this list
** of conditions and the following disclaimer in the documentation and/or
** other materials provided with the distribution. Neither the name of
** the WFC nor the names of its contributors may be used to endorse or
** promote products derived from this software without specific prior
** written permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**
** $Workfile: wfc_start_screen_saver.cpp $
** $Revision: 12 $
** $Modtime: 6/26/01 10:59a $
** $Reuse Tracing Code: 1 $
*/
/* SPDX-License-Identifier: BSD-2-Clause */
#include <wfc.h>
#pragma hdrstop
#if defined( _DEBUG ) && defined( _INC_CRTDBG )
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#define new DEBUG_NEW
#endif // _DEBUG
_Check_return_ bool Win32FoundationClasses::wfc_read_xml_from_file(_In_ std::wstring_view filename, _Inout_ CExtensibleMarkupLanguageDocument& document ) noexcept
{
CMemoryFile memory_mapped_file;
if ( memory_mapped_file.Open( filename, static_cast<UINT>(CFile64::OpenFlags::modeRead) ) == true )
{
CDataParser parser;
if ( parser.Initialize(static_cast<uint8_t const *>(memory_mapped_file.GetPointer()), memory_mapped_file.Size ) == false )
{
return( false );
}
return( document.Parse( parser ) );
}
else
{
// Can't map the file for some reason....
CFile64 input_file;
if ( input_file.Open( filename, static_cast<UINT>(CFile64::OpenFlags::modeRead) ) == true )
{
return( input_file.Read( document ) );
}
}
return( true );
}
void Win32FoundationClasses::wfc_get_program_data_directory(_Out_ std::wstring& application_data_directory) noexcept
{
application_data_directory.clear();
PWSTR directory_name = nullptr;
if (SUCCEEDED(::SHGetKnownFolderPath(FOLDERID_ProgramData, 0, nullptr, &directory_name)))
{
application_data_directory.assign(directory_name);
::CoTaskMemFree(directory_name);
directory_name = nullptr;
if (application_data_directory.empty() == true)
{
// RATS! The directory is empty
return;
}
if (ends_with(application_data_directory, '\\' ) == false)
{
application_data_directory.push_back(L'\\');
}
}
else
{
application_data_directory.clear();
}
}
// End of source
/*
<HTML>
<HEAD>
<TITLE>WFC - wfc_read_xml_from_file</TITLE>
<META name="keywords" content="WFC, MFC extension library, freeware class library, Win32">
<META name="description" content="Simple C function that reads XML from a file.">
</HEAD>
<BODY>
<H1>wfc_read_xml_from_file</H1>
$Revision: 12 $<HR>
<H2>Declaration</H2>
<PRE>bool <B>wfc_read_xml_from_file</B>( LPCTSTR filename, CExtensibleMarkupLanguageDocument& xml )</PRE>
<H2>Description</H2>
This function reads the XML from the specified file.
<H2>Example</H2>
<PRE><CODE>int _tmain( int number_of_command_line_arguments, LPCTSTR command_line_arguments[] )
{
<A HREF="WfcTrace.htm">WFCTRACEINIT</A>( TEXT( "_tmain()" ) );
<B>wfc_read_xml_from_file</B>( argv[ 1 ] );
return( EXIT_SUCCESS );
}</CODE></PRE>
<HR><I>Copyright, 203, <A HREF="mailto:wfc@pobox.com">Samuel R. Blackburn</A></I><BR>
$Workfile: wfc_start_screen_saver.cpp $<BR>
$Modtime: 6/26/01 10:59a $
</BODY>
</HTML>
*/
| 30.480519 | 162 | 0.703877 | SammyB428 |
f1a8648e0f938f927e67e3c346ced40c424d252f | 1,309 | cpp | C++ | src/GUI/TexturedTabButton.cpp | tizian/Cendric2 | 5b0438c73a751bcc0d63c3af839af04ab0fb21a3 | [
"MIT"
] | 279 | 2015-05-06T19:04:07.000Z | 2022-03-21T21:33:38.000Z | src/GUI/TexturedTabButton.cpp | tizian/Cendric2 | 5b0438c73a751bcc0d63c3af839af04ab0fb21a3 | [
"MIT"
] | 222 | 2016-10-26T15:56:25.000Z | 2021-10-03T15:30:18.000Z | src/GUI/TexturedTabButton.cpp | tizian/Cendric2 | 5b0438c73a751bcc0d63c3af839af04ab0fb21a3 | [
"MIT"
] | 49 | 2015-10-01T21:23:03.000Z | 2022-03-19T20:11:31.000Z | #include "GUI/TexturedTabButton.h"
TexturedTabButton::TexturedTabButton(const sf::FloatRect& box) : TabButton(box) {}
void TexturedTabButton::render(sf::RenderTarget& renderTarget) {
renderTarget.draw(m_background);
renderTarget.draw(m_texturedLayer);
renderTarget.draw(m_border);
renderTarget.draw(m_text);
}
void TexturedTabButton::setPosition(const sf::Vector2f& position) {
TabButton::setPosition(position);
float x = getBoundingBox()->left + 0.5f * (getBoundingBox()->width - m_texturedLayer.getSize().x);
float y = getBoundingBox()->top + 0.5f * (getBoundingBox()->height - m_texturedLayer.getSize().y);
m_texturedLayer.setPosition(sf::Vector2f(x, y));
}
void TexturedTabButton::setTexture(const sf::Texture* tex, const sf::IntRect& textureRect) {
m_texturedLayer.setTexture(tex);
m_texturedLayer.setTextureRect(textureRect);
auto const bbox = getBoundingBox();
auto const height = std::min(bbox->height, static_cast<float>(textureRect.height));
auto const width = textureRect.width * (height / static_cast<float>(textureRect.height));
m_texturedLayer.setSize(sf::Vector2f(width, height));
setPosition(getPosition() - sf::Vector2f(BOUNDING_BOX_OFFSET, BORDER_OFFSET));
}
void TexturedTabButton::setTextureColor(const sf::Color& color) {
m_texturedLayer.setFillColor(color);
}
| 35.378378 | 99 | 0.766234 | tizian |
f1a8c29ed3e3496e7c8af51a2aeb3269f7dcadba | 3,653 | cpp | C++ | Code/View/VTK/MergedSeriesSliceViewer.cpp | npettiaux/orthanc-viewer | 44fcde8bcf5e589b8f229272de68f0ef98af2f02 | [
"MIT"
] | 2 | 2017-06-11T02:39:37.000Z | 2019-04-25T11:50:07.000Z | Code/View/VTK/MergedSeriesSliceViewer.cpp | icryrainix/orthanc-viewer | 44fcde8bcf5e589b8f229272de68f0ef98af2f02 | [
"MIT"
] | null | null | null | Code/View/VTK/MergedSeriesSliceViewer.cpp | icryrainix/orthanc-viewer | 44fcde8bcf5e589b8f229272de68f0ef98af2f02 | [
"MIT"
] | 5 | 2015-05-11T09:22:14.000Z | 2019-11-13T07:56:40.000Z | /**
* Copyright (c) 2013-2014 Quentin Smetz <qsmetz@gmail.com>, Sebastien
* Jodogne <s.jodogne@gmail.com>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
**/
//!
//! \file MergedSeriesSliceViewer.cpp
//! \brief The MergedSeriesSliceViewer.cpp file contains the definition of
//! non-inline methods of the MergedSeriesSliceViewer class.
//!
//! \author Quentin Smetz
//!
#include "MergedSeriesSliceViewer.h"
using namespace std;
// Constructor
MergedSeriesSliceViewer::MergedSeriesSliceViewer(SliceOrientation orientation)
: MergedSeriesViewer(), m_orientation(orientation), m_currentSlice(0)
{
renderWindow()->GetInteractor()->SetInteractorStyle(vtkSmartPointer<vtkInteractorStyleImage>::New());
vtkCamera* camera = renderer()->GetActiveCamera();
camera->ParallelProjectionOn();
switch(orientation)
{
case SAGITTAL:
camera->SetPosition(1, 0, 0);
camera->SetFocalPoint(0, 0, 0);
camera->SetViewUp(0, 0, 1);
break;
case FRONTAL:
camera->SetPosition(0, -1, 0);
camera->SetFocalPoint(0, 0, 0);
camera->SetViewUp(0, 0, 1);
break;
case TRANSVERSE:
camera->SetPosition(0, 0, -1);
camera->SetFocalPoint(0, 0, 0);
camera->SetViewUp(0, -1, 0);
break;
}
}
// Destructor
MergedSeriesSliceViewer::~MergedSeriesSliceViewer()
{}
// The 'changeCurrentSlice' slot
void MergedSeriesSliceViewer::changeCurrentSlice(double value)
{
m_currentSlice = value;
for(unsigned int i = 0 ; i < m_seriesViewers.size() ; i++)
{
SeriesSliceViewer* ssv = dynamic_cast<SeriesSliceViewer*>(m_seriesViewers.at(i));
ssv->changeCurrentSlice(value);
vtkImageActor* actor = dynamic_cast<vtkImageActor*>(ssv->getVtkProp3D());
double* display = actor->GetDisplayBounds();
double* position = actor->GetPosition();
switch(m_orientation)
{
case SAGITTAL:
actor->SetPosition(-display[0]+i, position[1], position[2]);
break;
case FRONTAL:
actor->SetPosition(position[0], -display[2]-i, position[2]);
break;
case TRANSVERSE:
actor->SetPosition(position[0], position[1], -display[4]-i);
break;
}
}
renderer()->ResetCameraClippingRange();
repaint();
}
// The 'updateTranslation' method
void MergedSeriesSliceViewer::updateTranslation(ViewConfiguration const& config)
{
changeCurrentSlice(m_currentSlice);
repaint();
}
| 32.616071 | 105 | 0.665207 | npettiaux |
f1a9e8a3c404cf290fda6598f3e53f74db2f1d39 | 1,559 | cpp | C++ | EntityComponentSystem/Core/Core/ShaderPreprocessor.cpp | Spheya/Slamanander-Engine | d0708399eacab26b243045b33b51ff30d614b7bd | [
"MIT"
] | null | null | null | EntityComponentSystem/Core/Core/ShaderPreprocessor.cpp | Spheya/Slamanander-Engine | d0708399eacab26b243045b33b51ff30d614b7bd | [
"MIT"
] | null | null | null | EntityComponentSystem/Core/Core/ShaderPreprocessor.cpp | Spheya/Slamanander-Engine | d0708399eacab26b243045b33b51ff30d614b7bd | [
"MIT"
] | null | null | null | #include "ShaderPreprocessor.hpp"
#include <unordered_map>
#include <filesystem>
#include <fstream>
#include <sstream>
#include <iostream>
namespace {
std::string processFile(std::string shaderFile, std::unordered_map<std::string, bool>& includedFiles) {
// Get the absolute path to this file
std::filesystem::path p = shaderFile;
std::string absolutePath = std::filesystem::absolute(p).u8string();
#ifdef _DEBUG
{
std::ifstream f(absolutePath);
if (!f.good()) {
std::cout << "shader file \"" << absolutePath << "\" not found!" << std::endl;
std::terminate();
}
}
#endif
// If the file is already included, do nothing
if (includedFiles[absolutePath])
return "";
// Mark the file as included
includedFiles[absolutePath] = true;
// Read all the text in the file
std::ifstream fileStream(shaderFile);
std::ostringstream processedCode;
std::string line;
while (std::getline(fileStream, line)) {
std::istringstream iss(line);
std::string statement;
iss >> statement;
if (statement == "#include") {
iss >> statement;
std::string relativeFilePath = statement.substr(1, statement.size() - 2);
processedCode << processFile(p.parent_path().u8string() + '\\' + relativeFilePath, includedFiles);
} else {
processedCode << line;
processedCode << '\n';
}
}
return processedCode.str();
}
}
std::string renderer::ShaderPreprocessor::process(std::string shaderFile) {
std::unordered_map<std::string, bool> includedFiles;
return processFile(shaderFile, includedFiles);
}
| 25.983333 | 104 | 0.681206 | Spheya |
f1ae10ec908a7170b8ce3c96f0c0fdd2e234bb84 | 285 | cpp | C++ | scgi_server.cpp | fraxer/scgi-server | 9f26eea5bb4e27c500bffddae5e91aec0f18ab52 | [
"MIT"
] | null | null | null | scgi_server.cpp | fraxer/scgi-server | 9f26eea5bb4e27c500bffddae5e91aec0f18ab52 | [
"MIT"
] | null | null | null | scgi_server.cpp | fraxer/scgi-server | 9f26eea5bb4e27c500bffddae5e91aec0f18ab52 | [
"MIT"
] | null | null | null | #include "lib/scgi.hpp"
using namespace std;
int main(int argc, char **argv) {
locale system("");
locale::global(system);
//If You started server as daemon You must to use demonize() method
if (demonize() < 1) {
return 0;
}
init((char*)"127.0.0.1", 8080);
return 0;
} | 16.764706 | 69 | 0.635088 | fraxer |
f1aef0c46f120798cd3c4429980f3dcbda7c9cab | 9,076 | cpp | C++ | Sources/Elastos/Frameworks/Droid/WebView/Chromium/src/elastos/droid/webview/chromium/native/content/common/CleanupReference.cpp | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | 7 | 2017-07-13T10:34:54.000Z | 2021-04-16T05:40:35.000Z | Sources/Elastos/Frameworks/Droid/WebView/Chromium/src/elastos/droid/webview/chromium/native/content/common/CleanupReference.cpp | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | null | null | null | Sources/Elastos/Frameworks/Droid/WebView/Chromium/src/elastos/droid/webview/chromium/native/content/common/CleanupReference.cpp | jingcao80/Elastos | d0f39852356bdaf3a1234743b86364493a0441bc | [
"Apache-2.0"
] | 9 | 2017-07-13T12:33:20.000Z | 2021-06-19T02:46:48.000Z | //=========================================================================
// Copyright (C) 2012 The Elastos Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//=========================================================================
#include <Elastos.CoreLibrary.Utility.h>
#include "elastos/droid/webkit/webview/chromium/native/content/common/ContentSwitches.h"
#include "elastos/droid/webkit/webview/chromium/native/content/common/CleanupReference.h"
#include "elastos/droid/webkit/webview/chromium/native/base/TraceEvent.h"
#include "elastos/droid/webkit/webview/chromium/native/base/ThreadUtils.h"
#include <elastos/core/AutoLock.h>
#include <elastos/core/StringUtils.h>
#include <elastos/utility/logging/Slogger.h>
#include <elastos/core/AutoLock.h>
using Elastos::Core::AutoLock;
using Elastos::Core::AutoLock;
using Elastos::Core::StringUtils;
using Elastos::Droid::Os::ILooperHelper;
using Elastos::Droid::Os::CLooperHelper;
using Elastos::Droid::Os::IMessage;
using Elastos::Droid::Os::IMessageHelper;
using Elastos::Droid::Os::CMessageHelper;
using Elastos::Droid::Webkit::Webview::Chromium::Base::TraceEvent;
using Elastos::Droid::Webkit::Webview::Chromium::Base::ThreadUtils;
using Elastos::Utility::CHashSet;
using Elastos::Utility::IHashSet;
using Elastos::Utility::EIID_IHashSet;
using Elastos::Utility::Logging::Slogger;
namespace Elastos {
namespace Droid {
namespace Webkit {
namespace Webview {
namespace Chromium {
namespace Content {
namespace Common {
//===============================================================
// CleanupReference::LazyHolder::InnerHandler
//===============================================================
//CAR_INTERFACE_IMPL(CleanupReference::LazyHolder::InnerHandler, Object, IHandler);
CleanupReference::LazyHolder::InnerHandler::InnerHandler(
/* [in] */ ILooper* looper)
: Handler(looper)
{
}
ECode CleanupReference::LazyHolder::InnerHandler::HandleMessage(
/* [in] */ IMessage* msg)
{
VALIDATE_NOT_NULL(msg);
TraceEvent::Begin();
AutoPtr<IInterface> obj;
msg->GetObj((IInterface**)&obj);
CleanupReference* ref = (CleanupReference*)(IObject::Probe(obj));
Int32 what;
msg->GetWhat(&what);
switch (what) {
case ADD_REF:
sRefs->Add((IObject*)ref);
break;
case REMOVE_REF:
ref->RunCleanupTaskInternal();
break;
default: {
String log("Bad message=");
log += StringUtils::ToString(what);
Slogger::E(TAG, log);
}
break;
}
if (DEBUG) {
Int32 size;
sRefs->GetSize(&size);
String log("will try and cleanup; max = ");
log += StringUtils::ToString(size);
Slogger::D(TAG, log);
}
{ AutoLock syncLock(sCleanupMonitor);
// Always run the cleanup loop here even when adding or removing refs, to avoid
// falling behind on rapid garbage allocation inner loops.
assert(0);
// TODO
// while ((ref = (CleanupReference) sGcQueue.poll()) != NULL) {
// ref->runCleanupTaskInternal();
// }
sCleanupMonitor.NotifyAll();
}
TraceEvent::End();
return NOERROR;
}
//===============================================================
// CleanupReference::LazyHolder
//===============================================================
AutoPtr<IHandler> CleanupReference_LazyHolder_sHandler_Init()
{
AutoPtr<IHandler> handler = new CleanupReference::LazyHolder::InnerHandler(ThreadUtils::GetUiThreadLooper());
return handler;
}
// TODO
AutoPtr<IHandler> CleanupReference::LazyHolder::sHandler;// = CleanupReference_LazyHolder_sHandler_Init();
//===============================================================
// CleanupReference::InnerThread
//===============================================================
CleanupReference::InnerThread::InnerThread(
/* [in] */ const String& threadName)
{
Thread::constructor(threadName);
}
ECode CleanupReference::InnerThread::Run()
{
while (TRUE) {
// try {
AutoPtr<CleanupReference> ref;
assert(0);
// TODO
// ref = (CleanupReference) sGcQueue->Remove();
if (DEBUG) {
Slogger::D(TAG, "removed one ref from GC queue");
}
{ AutoLock syncLock(sCleanupMonitor);
AutoPtr<IMessageHelper> helper;
CMessageHelper::AcquireSingleton((IMessageHelper**)&helper);
AutoPtr<IMessage> msg;
helper->Obtain(LazyHolder::sHandler, REMOVE_REF, (IObject*)ref, (IMessage**)&msg);
msg->SendToTarget();
// Give the UI thread chance to run cleanup before looping around and
// taking the next item from the queue, to avoid Message bombing it.
sCleanupMonitor.Wait(500);
}
// } catch (Exception e) {
// Log.e(TAG, "Queue remove exception:", e);
// }
}
return NOERROR;
}
//===============================================================
// CleanupReference
//===============================================================
Boolean CleanupReferenceStart()
{
CleanupReference::sReaperThread->SetDaemon(TRUE);
CleanupReference::sReaperThread->Start();
return TRUE;
}
static Boolean sStart = CleanupReferenceStart();
const String CleanupReference::TAG("CleanupReference");
const Boolean CleanupReference::DEBUG = FALSE; // Always check in as false!
// TODO ReferenceQueue<Object> CleanupReference::sGcQueue;
Object CleanupReference::sCleanupMonitor;
AutoPtr<IThread> CleanupReference_sReaperThread_Init()
{
AutoPtr<IThread> thread = new CleanupReference::InnerThread(CleanupReference::TAG);
return thread;
}
AutoPtr<IThread> CleanupReference::sReaperThread = CleanupReference_sReaperThread_Init();
// Add a new reference to sRefs. |msg.obj| is the CleanupReference to add.
const Int32 CleanupReference::ADD_REF;
// Remove reference from sRefs. |msg.obj| is the CleanupReference to remove.
const Int32 CleanupReference::REMOVE_REF;
/**
* Keep a strong reference to {@link CleanupReference} so that it will
* actually get enqueued.
* Only accessed on the UI thread.
*/
AutoPtr<ISet> sRefsInit()
{
AutoPtr<IHashSet> hashSet;
CHashSet::New((IHashSet**)&hashSet);
AutoPtr<ISet> set = ISet::Probe(hashSet);
return set;
}
AutoPtr<ISet> CleanupReference::sRefs = sRefsInit();
/**
* @param obj the object whose loss of reachability should trigger the
* cleanup task.
* @param cleanupTask the task to run once obj loses reachability.
*/
CleanupReference::CleanupReference(
/* [in] */ Object* obj,
/* [in] */ IRunnable* cleanupTask)
{
assert(0);
// TODO
// super(obj, sGcQueue);
if (DEBUG) {
Slogger::D(TAG, "+++ CREATED ONE REF");
}
mCleanupTask = cleanupTask;
HandleOnUiThread(ADD_REF);
}
/**
* Clear the cleanup task {@link Runnable} so that nothing will be done
* after garbage collection.
*/
void CleanupReference::CleanupNow()
{
HandleOnUiThread(REMOVE_REF);
}
void CleanupReference::HandleOnUiThread(
/* [in] */ Int32 what)
{
AutoPtr<IMessageHelper> helper;
CMessageHelper::AcquireSingleton((IMessageHelper**)&helper);
AutoPtr<IMessage> msg;
helper->Obtain(LazyHolder::sHandler, what, TO_IINTERFACE(this), (IMessage**)&msg);
AutoPtr<ILooperHelper> looperHelper;
assert(0);
CLooperHelper::AcquireSingleton((ILooperHelper**)&looperHelper);
AutoPtr<ILooper> myLooper;
looperHelper->GetMyLooper((ILooper**)&myLooper);
AutoPtr<IHandler> target;
msg->GetTarget((IHandler**)&target);
AutoPtr<ILooper> looper;
target->GetLooper((ILooper**)&looper);
if (myLooper == looper) {
target->HandleMessage(msg);
msg->Recycle();
}
else {
msg->SendToTarget();
}
}
void CleanupReference::RunCleanupTaskInternal()
{
if (DEBUG) {
Slogger::D(TAG, "runCleanupTaskInternal");
}
sRefs->Remove(TO_IINTERFACE(this));
if (mCleanupTask != NULL) {
if (DEBUG) {
Slogger::I(TAG, "--- CLEANING ONE REF");
}
mCleanupTask->Run();
mCleanupTask = NULL;
}
assert(0);
// TODO
// Clear();
}
} // namespace Common
} // namespace Content
} // namespace Chromium
} // namespace Webview
} // namespace Webkit
} // namespace Droid
} // namespace Elastos
| 31.082192 | 113 | 0.613927 | jingcao80 |
f1af6b2a4e3259748702d39b2097fccbf3800cd0 | 2,149 | cpp | C++ | Chapter_2_Data_Structures/Non-Linear_DS_with_Built-in_Libraries/kattis_stockprices.cpp | BrandonTang89/CP4_Code | 5114471f439978dd11f6f2cbf6af20ca654593da | [
"MIT"
] | 2 | 2021-12-29T04:12:59.000Z | 2022-03-30T09:32:19.000Z | Chapter_2_Data_Structures/Non-Linear_DS_with_Built-in_Libraries/kattis_stockprices.cpp | BrandonTang89/CP4_Code | 5114471f439978dd11f6f2cbf6af20ca654593da | [
"MIT"
] | null | null | null | Chapter_2_Data_Structures/Non-Linear_DS_with_Built-in_Libraries/kattis_stockprices.cpp | BrandonTang89/CP4_Code | 5114471f439978dd11f6f2cbf6af20ca654593da | [
"MIT"
] | 1 | 2022-03-01T06:12:46.000Z | 2022-03-01T06:12:46.000Z | #pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
priority_queue<pair<int,int> > bids; // price, quantity, max heap
priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>> > asks; // price, quantity, min heap
int stock_price = -1;
int num_tc, n;
string op, d;
int q, p;
int main(){
fast_cin();
cin >> num_tc;
for (int tc=0;tc<num_tc;tc++){
while (!bids.empty()) bids.pop();
while (!asks.empty()) asks.pop();
stock_price = -1;
cin >> n;
for (int i=0;i<n;i++){
cin >> op >> q >> d >> d >> p;
if (op == "buy"){
bids.push(make_pair(p, q));
}
else{
asks.push({p, q});
}
while ((!(asks.empty() || bids.empty())) && asks.top().first <= bids.top().first){
int ask_price = asks.top().first;
int bid_price = bids.top().first;
int ask_quantity = asks.top().second;
int bid_quantity = bids.top().second;
asks.pop();
bids.pop();
int q_transacted = min(ask_quantity, bid_quantity);
stock_price = ask_price;
if (q_transacted < ask_quantity){
asks.push({ask_price, ask_quantity - q_transacted});
}
if (q_transacted < bid_quantity){
bids.push({bid_price, bid_quantity - q_transacted});
}
}
if (asks.empty()){
cout << "- ";
}
else cout << asks.top().first << " ";
if (bids.empty()){
cout << "- ";
}
else cout << bids.top().first << " ";
if (stock_price == -1){
cout << "-\n";
}
else cout << stock_price << "\n";
}
}
return 0;
} | 32.074627 | 112 | 0.469521 | BrandonTang89 |
f1b38b52f39e2d93e5ace79c8efce1eab7d2f5f7 | 3,298 | cpp | C++ | menoh/mkldnn/operator/add.cpp | yuhonghong66/menoh | cdb33dfc8ba4c8dbb4c2bc70aae4f52433116402 | [
"MIT"
] | 284 | 2018-06-21T02:00:08.000Z | 2021-11-22T07:50:22.000Z | menoh/mkldnn/operator/add.cpp | yuhonghong66/menoh | cdb33dfc8ba4c8dbb4c2bc70aae4f52433116402 | [
"MIT"
] | 174 | 2018-06-21T06:01:57.000Z | 2020-12-28T06:26:55.000Z | menoh/mkldnn/operator/add.cpp | yuhonghong66/menoh | cdb33dfc8ba4c8dbb4c2bc70aae4f52433116402 | [
"MIT"
] | 33 | 2018-06-21T04:19:17.000Z | 2020-05-08T12:51:55.000Z | #include <menoh/mkldnn/operator/add.hpp>
#include <tuple>
#include <mkldnn.hpp>
#include <menoh/utility.hpp>
#include <menoh/model_core.hpp>
#include <menoh/mkldnn/operator/common.hpp>
#include <menoh/mkldnn/utility.hpp>
namespace menoh_impl {
namespace mkldnn_backend {
primitive_factory_return_type make_add_primitive(
menoh_impl::node const& node,
std::unordered_map<std::string, array> const& /*parameter_table*/,
std::unordered_map<std::string, mkldnn::memory> const&
variable_memory_table,
std::unordered_map<std::string, array> const& required_output_table,
mkldnn::engine const& engine) {
std::vector<mkldnn::primitive> net;
std::unordered_map<std::string, mkldnn::memory> output_memory_table;
std::unordered_map<std::string, array> output_table;
std::vector<mkldnn::memory> temp_memory_list;
auto const& input_a_memory =
find_value(variable_memory_table, node.input_name_list.at(0));
auto const& input_b_memory =
find_value(variable_memory_table, node.input_name_list.at(1));
auto input_a_dims = extract_dims(input_a_memory);
auto input_b_dims = extract_dims(input_b_memory);
if(input_a_dims != input_b_dims) {
throw failed_to_configure_operator(
node.op_type, node.output_name_list.at(0),
"input A and input B has different dims: broadcast is not supported yet");
}
auto const& output_name = node.output_name_list.at(0);
auto output_dims = input_a_dims;
auto add_output_md = mkldnn::memory::desc(
{output_dims}, mkldnn::memory::data_type::f32,
mkldnn::memory::format::any);
mkldnn::sum::primitive_desc add_pd(
add_output_md, std::vector<float>{1.0f, 1.0f},
{input_a_memory.get_primitive_desc(),
input_b_memory.get_primitive_desc()});
auto output_format = input_a_dims.size() == 2
? mkldnn::memory::format::nc
: mkldnn::memory::format::nchw;
std::vector<std::pair<
std::string, std::tuple<mkldnn::memory, mkldnn::memory::format>>>
variable_memory_list;
std::vector<std::pair<std::string, array>> output_name_and_arr_list;
manage_output_memory(
net, output_name, output_format, add_pd.dst_primitive_desc(),
output_memory_table, required_output_table, temp_memory_list,
engine,
[&net, &input_a_memory, &input_b_memory,
&add_pd](auto& op_output_memory) {
std::vector<mkldnn::primitive::at> inputs{
static_cast<mkldnn::primitive::at>(input_a_memory),
static_cast<mkldnn::primitive::at>(input_b_memory)};
net.push_back(mkldnn::sum(add_pd, inputs, op_output_memory));
});
return std::make_tuple(net, output_memory_table, temp_memory_list,
std::vector<array>());
}
} // namespace mkldnn_backend
} // namespace menoh_impl
| 41.225 | 92 | 0.60279 | yuhonghong66 |
f1b439a17a536e0ebfdb639369e72dc7cd36d1e0 | 3,713 | hpp | C++ | include/HoudiniEngineUnity/HEU_PreAssetEventData.hpp | RedBrumbler/BeatSaber-Quest-Codegen | 73dda50b5a3e51f10d86b766dcaa24b0c6226e25 | [
"Unlicense"
] | null | null | null | include/HoudiniEngineUnity/HEU_PreAssetEventData.hpp | RedBrumbler/BeatSaber-Quest-Codegen | 73dda50b5a3e51f10d86b766dcaa24b0c6226e25 | [
"Unlicense"
] | null | null | null | include/HoudiniEngineUnity/HEU_PreAssetEventData.hpp | RedBrumbler/BeatSaber-Quest-Codegen | 73dda50b5a3e51f10d86b766dcaa24b0c6226e25 | [
"Unlicense"
] | null | null | null | // Autogenerated from CppHeaderCreator
// Created by Sc2ad
// =========================================================================
#pragma once
// Begin includes
#include "beatsaber-hook/shared/utils/typedefs.h"
#include "beatsaber-hook/shared/utils/byref.hpp"
// Including type: HoudiniEngineUnity.HEU_AssetEventType
#include "HoudiniEngineUnity/HEU_AssetEventType.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp"
#include "beatsaber-hook/shared/utils/utils.h"
// Completed includes
// Begin forward declares
// Forward declaring namespace: HoudiniEngineUnity
namespace HoudiniEngineUnity {
// Forward declaring type: HEU_HoudiniAsset
class HEU_HoudiniAsset;
}
// Completed forward declares
// Type namespace: HoudiniEngineUnity
namespace HoudiniEngineUnity {
// Forward declaring type: HEU_PreAssetEventData
class HEU_PreAssetEventData;
}
#include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp"
NEED_NO_BOX(::HoudiniEngineUnity::HEU_PreAssetEventData);
DEFINE_IL2CPP_ARG_TYPE(::HoudiniEngineUnity::HEU_PreAssetEventData*, "HoudiniEngineUnity", "HEU_PreAssetEventData");
// Type namespace: HoudiniEngineUnity
namespace HoudiniEngineUnity {
// Size: 0x1C
#pragma pack(push, 1)
// Autogenerated type: HoudiniEngineUnity.HEU_PreAssetEventData
// [TokenAttribute] Offset: FFFFFFFF
class HEU_PreAssetEventData : public ::Il2CppObject {
public:
#ifdef USE_CODEGEN_FIELDS
public:
#else
#ifdef CODEGEN_FIELD_ACCESSIBILITY
CODEGEN_FIELD_ACCESSIBILITY:
#else
protected:
#endif
#endif
// public HoudiniEngineUnity.HEU_HoudiniAsset Asset
// Size: 0x8
// Offset: 0x10
::HoudiniEngineUnity::HEU_HoudiniAsset* Asset;
// Field size check
static_assert(sizeof(::HoudiniEngineUnity::HEU_HoudiniAsset*) == 0x8);
// public HoudiniEngineUnity.HEU_AssetEventType AssetType
// Size: 0x4
// Offset: 0x18
::HoudiniEngineUnity::HEU_AssetEventType AssetType;
// Field size check
static_assert(sizeof(::HoudiniEngineUnity::HEU_AssetEventType) == 0x4);
public:
// Get instance field reference: public HoudiniEngineUnity.HEU_HoudiniAsset Asset
::HoudiniEngineUnity::HEU_HoudiniAsset*& dyn_Asset();
// Get instance field reference: public HoudiniEngineUnity.HEU_AssetEventType AssetType
::HoudiniEngineUnity::HEU_AssetEventType& dyn_AssetType();
// public System.Void .ctor(HoudiniEngineUnity.HEU_HoudiniAsset asset, HoudiniEngineUnity.HEU_AssetEventType assetType)
// Offset: 0x1AC8144
template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary>
static HEU_PreAssetEventData* New_ctor(::HoudiniEngineUnity::HEU_HoudiniAsset* asset, ::HoudiniEngineUnity::HEU_AssetEventType assetType) {
static auto ___internal__logger = ::Logger::get().WithContext("::HoudiniEngineUnity::HEU_PreAssetEventData::.ctor");
return THROW_UNLESS((::il2cpp_utils::New<HEU_PreAssetEventData*, creationType>(asset, assetType)));
}
}; // HoudiniEngineUnity.HEU_PreAssetEventData
#pragma pack(pop)
static check_size<sizeof(HEU_PreAssetEventData), 24 + sizeof(::HoudiniEngineUnity::HEU_AssetEventType)> __HoudiniEngineUnity_HEU_PreAssetEventDataSizeCheck;
static_assert(sizeof(HEU_PreAssetEventData) == 0x1C);
}
#include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp"
// Writing MetadataGetter for method: HoudiniEngineUnity::HEU_PreAssetEventData::New_ctor
// Il2CppName: .ctor
// Cannot get method pointer of value based method overload from template for constructor!
// Try using FindMethod instead!
| 45.839506 | 158 | 0.765957 | RedBrumbler |
f1b572ef0777fade1578ef69787ee0aafe30dd0d | 1,657 | cpp | C++ | src/SDK/Prov_SDK.cpp | Telecominfraproject/wlan-cloud-ufs | e34874f68bdb7bdefb9f94a861719b7876c1c39a | [
"BSD-3-Clause"
] | 1 | 2021-08-04T02:31:29.000Z | 2021-08-04T02:31:29.000Z | src/SDK/Prov_SDK.cpp | Telecominfraproject/wlan-cloud-ufs | e34874f68bdb7bdefb9f94a861719b7876c1c39a | [
"BSD-3-Clause"
] | 1 | 2021-08-23T14:39:20.000Z | 2021-08-23T14:39:20.000Z | src/SDK/Prov_SDK.cpp | Telecominfraproject/wlan-cloud-ufs | e34874f68bdb7bdefb9f94a861719b7876c1c39a | [
"BSD-3-Clause"
] | 1 | 2022-01-03T16:17:18.000Z | 2022-01-03T16:17:18.000Z | //
// Created by stephane bourque on 2021-10-04.
//
#include "framework/MicroService.h"
namespace OpenWifi::SDK::Prov {
bool GetFirmwareOptions( const std::string & serialNumber, std::string &firmwareUpgrade,
bool &firmwareRCOnly) {
Types::StringPairVec QueryData;
QueryData.push_back(std::make_pair("firmwareOptions","true"));
OpenWifi::OpenAPIRequestGet R( OpenWifi::uSERVICE_PROVISIONING,
"/api/v1/inventory/" +serialNumber,
QueryData,
10000);
firmwareUpgrade="no";
firmwareRCOnly=false;
Poco::JSON::Object::Ptr Response;
if(R.Do(Response) == Poco::Net::HTTPResponse::HTTP_OK) {
std::cout << "Received options... " << std::endl;
std::ostringstream os;
Poco::JSON::Stringifier::stringify(Response,os);
std::cout << "Firmware option response - good - Response: " << os.str() << std::endl;
if(Response->has("firmwareUpgrade"))
firmwareUpgrade = Response->get("firmwareUpgrade").toString();
if(Response->has("firmwareRCOnly"))
firmwareRCOnly = Response->get("firmwareRCOnly").toString()=="true";
return true;
} else {
std::cout << "Failed Received options... " << std::endl;
std::ostringstream os;
Poco::JSON::Stringifier::stringify(Response,os);
std::cout << "Firmware option response - bad- Response: " << os.str() << std::endl;
}
return false;
}
} | 39.452381 | 97 | 0.548582 | Telecominfraproject |
f1baad929509c64ebb97e07d6b7589e2b13b39da | 3,000 | cpp | C++ | main/main.cpp | mrdunk/m5stack_homeautomation | 49e414039c666a595f81b66c73e2b4e7e72f3e16 | [
"MIT"
] | null | null | null | main/main.cpp | mrdunk/m5stack_homeautomation | 49e414039c666a595f81b66c73e2b4e7e72f3e16 | [
"MIT"
] | null | null | null | main/main.cpp | mrdunk/m5stack_homeautomation | 49e414039c666a595f81b66c73e2b4e7e72f3e16 | [
"MIT"
] | 1 | 2020-04-02T13:49:45.000Z | 2020-04-02T13:49:45.000Z | #include <M5Stack.h>
#include "nvs_flash.h"
#include "esp_wifi.h"
#include "esp_event_loop.h"
#include "freertos/event_groups.h"
#include "menu.h"
#include "occupancy.h"
#include "mqtt.h"
#include "temparature.h"
#include "outlet.h"
#include "googleSheet.h"
#include "config.h"
#include "getUrl.h"
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
#define BOILER_TOPIC GLOBAL_ID "/heating/state"
mrdunk::Temperature* temperature;
mrdunk::OutletKankun* outletBoiler;
mrdunk::HttpRequest* httpRequest;
// The setup routine runs once when M5Stack starts up
void setup() {
esp_log_level_set("phy_init", ESP_LOG_INFO);
// Initialize the M5Stack object
M5.begin(true, false);
// LCD display
M5.Lcd.clearDisplay();
M5.Lcd.setTextColor(WHITE);
M5.Lcd.setTextSize(4);
M5.Lcd.setCursor(10, 10);
M5.Lcd.print("Loading...\n");
setupMenu();
// Networking
wifi_init();
mqtt_app_start();
temperature = new mrdunk::Temperature("inside/downstairs/livingroom");
outletBoiler = new mrdunk::OutletKankun(BOILER_TOPIC, false);
}
// Every 20ms.
void loopTask(void *pvParameters) {
while(1) {
micros(); // update overflow
M5.update(); // Reads buttons, updates speaker.
occupancy_update();
updateMenu();
delay(20 / portTICK_PERIOD_MS);
}
}
// Every few seconds. 15 * 1000ms
void loopTask15sec(void *pvParameters) {
char currentTemp[20] = "";
while(1) {
float temp = temperature->average();
if(isnan(temp)) {
snprintf(currentTemp, 20, "Waiting for update.");
} else {
snprintf(currentTemp, 16, "%.1fC\n", temp);
}
setButton0(currentTemp, nullptr);
setButton1(outletBoiler->getState());
delay(15 * 1000 / portTICK_PERIOD_MS);
}
}
void loopTask30min(void *pvParameters) {
while(1) {
if(outletBoiler->getState()) {
googleSheet_connect(WEB_URL, "?topic=" BOILER_TOPIC "&state=1");
} else {
googleSheet_connect(WEB_URL, "?topic=" BOILER_TOPIC "&state=0");
}
delay(30 * 60 * 1000 / portTICK_PERIOD_MS);
}
}
extern "C" void app_main() {
esp_chip_info_t chip_info;
esp_chip_info(&chip_info);
printf("This is ESP32 chip with %d CPU cores, WiFi%s%s, ",
chip_info.cores,
(chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
(chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
printf("silicon revision %d, ", chip_info.revision);
printf("%dMB %s flash\n\n", spi_flash_get_chip_size() / (1024 * 1024),
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external");
//initArduino();
setup();
xTaskCreatePinnedToCore(
loopTask, "loopTask", 8192, NULL, 1, NULL, ARDUINO_RUNNING_CORE);
xTaskCreatePinnedToCore(
loopTask15sec, "loopTask15sec", 8192, NULL, 10, NULL, ARDUINO_RUNNING_CORE);
xTaskCreatePinnedToCore(
loopTask30min, "loopTask30min", 8192, NULL, 10, NULL, ARDUINO_RUNNING_CORE);
while(1) {
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
| 25.210084 | 82 | 0.684 | mrdunk |
f1bde8db188380ef2fb7b8a91dbaf194e1872e84 | 6,405 | cpp | C++ | eeprom_config.cpp | nnaumenko/room_monitor_esp8266 | 41aa2f5b8803a546a8426390147090582b4ae7be | [
"MIT"
] | 2 | 2017-11-17T07:17:17.000Z | 2021-03-15T12:38:55.000Z | eeprom_config.cpp | nnaumenko/iot_ambit | 41aa2f5b8803a546a8426390147090582b4ae7be | [
"MIT"
] | 11 | 2016-08-07T16:04:34.000Z | 2017-12-30T00:57:16.000Z | eeprom_config.cpp | nnaumenko/room_monitor_esp8266 | 41aa2f5b8803a546a8426390147090582b4ae7be | [
"MIT"
] | 1 | 2017-09-29T17:44:19.000Z | 2017-09-29T17:44:19.000Z | /*
* Copyright (C) 2016-2017 Nick Naumenko (https://github.com/nnaumenko)
* All rights reserved
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#include "diag.h"
#include "version.h"
#include "eeprom_config.h"
#include "util_data.h"
#include <EEPROM.h>
using DiagLog = diag::DiagLog<>;
EepromSavedParametersStorage eepromSavedParametersStorage;
const PROGMEM QuickStringMapItem stringMapEepromSavedParameterInternalNames[] {
{(StringMapKey)EepromSavedParameter::BLYNK_AUTH_TOKEN, "blynkauth"},
{(StringMapKey)EepromSavedParameter::WIFI_SSID, "wifissid"},
{(StringMapKey)EepromSavedParameter::WIFI_PASSWORD, "wifipass"},
{(StringMapKey)EepromSavedParameter::MG811_CALPOINT0_CAL, "adccal0cal"},
{(StringMapKey)EepromSavedParameter::MG811_CALPOINT0_RAW, "adccal0raw"},
{(StringMapKey)EepromSavedParameter::MG811_CALPOINT1_CAL, "adccal1cal"},
{(StringMapKey)EepromSavedParameter::MG811_CALPOINT1_RAW, "adccal1raw"},
{(StringMapKey)EepromSavedParameter::MG811FILTER_TYPE, "adcfilter"},
{(StringMapKey)EepromSavedParameter::MG811FILTER_LOWPASS_FREQ, "adcfiltfreq"},
{(StringMapKey)EepromSavedParameter::MG811_REJECT_CALIBRATION, "adcrejectcal"},
{(StringMapKey)EepromSavedParameter::MISC_SERIAL_OUT, "miscserout"},
{(StringMapKey)EepromSavedParameter::BLYNK_SERVER, "blynkserver"},
{(StringMapKey)EepromSavedParameter::BLYNK_SERVER_PORT, "blynkport"},
{(StringMapKey)EepromSavedParameter::STARTUP_DELAY, "stdel"},
{(StringMapKey)EepromSavedParameter::UNKNOWN, ""}
};
void saveToEEPROM (int address, const void * parameter, size_t length) {
byte * parameterBytes = (byte *) parameter;
for (size_t i = 0; i < length; i++) {
EEPROM.write(address + i, parameterBytes[i]);
}
}
void loadFromEEPROM (int address, void * parameter, size_t length) {
byte * parameterBytes = (byte *) parameter;
for (size_t i = 0; i < length; i++) {
parameterBytes[i] = EEPROM.read(address + i);
}
}
uint16_t calculateCheckSum (void) {
return (util::checksum::crc16(&eepromSavedParametersStorage, sizeof(EepromSavedParametersStorage)));
}
void saveConfig(void) {
eepromSavedParametersStorage.versionMajor = FIRMWARE_VERSION_MAJOR;
eepromSavedParametersStorage.versionMinor = FIRMWARE_VERSION_MINOR;
eepromSavedParametersStorage.checkSum = calculateCheckSum();
EEPROM.begin(sizeof(eepromSavedParametersStorage) + EEPROM_SAVED_PARAMETERS_ADDRESS);
saveToEEPROM(EEPROM_SAVED_PARAMETERS_ADDRESS,
(void *)&eepromSavedParametersStorage,
sizeof(eepromSavedParametersStorage));
EEPROM.end();
DiagLog::instance()->log(DiagLog::Severity::INFORMATIONAL, F("Config saved to EEPROM"));
}
void loadConfig(void) {
EEPROM.begin(sizeof(eepromSavedParametersStorage));
loadFromEEPROM(EEPROM_SAVED_PARAMETERS_ADDRESS,
(void *)&eepromSavedParametersStorage,
sizeof(eepromSavedParametersStorage));
EEPROM.end();
DiagLog::instance()->log(DiagLog::Severity::INFORMATIONAL, F("Config loaded from EEPROM"));
DiagLog::instance()->log(DiagLog::Severity::DEBUG,
F("Config was saved with firmware version "),
eepromSavedParametersStorage.versionMajor,
'.',
eepromSavedParametersStorage.versionMinor);
if ((eepromSavedParametersStorage.versionMajor != FIRMWARE_VERSION_MAJOR) ||
(eepromSavedParametersStorage.versionMinor != FIRMWARE_VERSION_MINOR))
DiagLog::instance()->log(DiagLog::Severity::WARNING, F("CONFIG SAVED WITH DIFFERENT FIRMWARE VERSION, PLEASE ACTIVATE CONFIG MODE AND REVIEW DATA"));
DiagLog::instance()->log(DiagLog::Severity::NOTICE, F("Checksum: "), eepromSavedParametersStorage.checkSum);
uint16_t actualCheckSum = calculateCheckSum();
if (actualCheckSum != eepromSavedParametersStorage.checkSum) {
DiagLog::instance()->log(DiagLog::Severity::WARNING, F("Actual checksum: "), actualCheckSum);
DiagLog::instance()->log(DiagLog::Severity::WARNING, F("CONFIG CHECKSUM MISMATCH, PLEASE ACTIVATE CONFIG MODE AND REVIEW DATA"));
}
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("WIFI network: "), eepromSavedParametersStorage.wifiSsid);
if (EEPROM_DEBUG_PRINT_INSECURE) {
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("WIFI password: "), eepromSavedParametersStorage.wifiPassword);
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("Auth token: "), eepromSavedParametersStorage.authToken);
}
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("MG811 cal points: "),
F("Raw="), eepromSavedParametersStorage.MG811CalPoint0Raw,
F(" Calibrated="), eepromSavedParametersStorage.MG811CalPoint0Calibrated,
F("ppm / Raw="), eepromSavedParametersStorage.MG811CalPoint1Raw,
F(" Calibrated="), eepromSavedParametersStorage.MG811CalPoint1Calibrated,
F("ppm"));
switch (eepromSavedParametersStorage.filterMG811) {
case ADCFilter::OFF:
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("MG811 filter: off"));
break;
case ADCFilter::AVERAGE:
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("MG811 filter: moving average"));
break;
case ADCFilter::LOWPASS:
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("MG811 filter: low-pass, limit frequency: "), eepromSavedParametersStorage.filterMG811LowPassFrequency, F(" x 0.01 Hz"));
break;
default:
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("MG811 filter: unknown ("), (int)eepromSavedParametersStorage.filterMG811, ')');
break;
}
if (!eepromSavedParametersStorage.rejectCalibrationMG811)
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("MG811 calibration mode: use calibration data"));
else
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("MG811 calibration mode: use uncalibrated value"));
if (!eepromSavedParametersStorage.sensorSerialOutput)
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("Sensor readings' serial output: off"));
else
DiagLog::instance()->log(DiagLog::Severity::DEBUG, F("Sensor readings' serial output: on"));
}
| 51.653226 | 181 | 0.707884 | nnaumenko |
f1bf39d84489f5ce333093288394a4c08749dafa | 431 | cc | C++ | editor/win.cc | hankhank/exys | a515784ab3c673dceb34e8b286963e48d471c48d | [
"MIT"
] | null | null | null | editor/win.cc | hankhank/exys | a515784ab3c673dceb34e8b286963e48d471c48d | [
"MIT"
] | null | null | null | editor/win.cc | hankhank/exys | a515784ab3c673dceb34e8b286963e48d471c48d | [
"MIT"
] | null | null | null | #include "gvplugin.h"
extern gvplugin_library_t gvplugin_dot_layout_LTX_library;
extern gvplugin_library_t gvplugin_neato_layout_LTX_library;
extern gvplugin_library_t gvplugin_core_LTX_library;
extern gvplugin_library_t gvplugin_quartz_LTX_library;
extern gvplugin_library_t gvplugin_visio_LTX_library;
lt_symlist_t lt_preloaded_symbols[] =
{
{ "gvplugin_dot_layout_LTX_library", &gvplugin_dot_layout_LTX_library},
{ 0, 0}
};
| 30.785714 | 72 | 0.867749 | hankhank |
f1c290db97fd84b31c4c7824da401711a52cbeab | 555 | hpp | C++ | lib/RayTracer/Rendering/Lighting/Light.hpp | ei06125/ray-tracer-challenge | 54475def8c6f82c3559871f7fce00248128bb5ba | [
"MIT"
] | null | null | null | lib/RayTracer/Rendering/Lighting/Light.hpp | ei06125/ray-tracer-challenge | 54475def8c6f82c3559871f7fce00248128bb5ba | [
"MIT"
] | null | null | null | lib/RayTracer/Rendering/Lighting/Light.hpp | ei06125/ray-tracer-challenge | 54475def8c6f82c3559871f7fce00248128bb5ba | [
"MIT"
] | null | null | null | #pragma once
#include "RayTracerPCH.hpp"
// Project Library
#include "RayTracer/Math/Tuple.hpp"
#include "RayTracer/Rendering/Color.hpp"
namespace RayTracer {
namespace Rendering {
namespace Lighting {
using namespace RayTracer::Math;
using namespace RayTracer::Rendering::Colors;
struct PointLight
{
Tuple position;
Color intensity;
};
std::ostream& operator<<(std::ostream& os, const PointLight& aLight);
bool operator==(const PointLight& lhs, const PointLight& rhs);
} // namespace Lighting
} // namespace Rendering
} // namespace RayTracer
| 19.821429 | 69 | 0.756757 | ei06125 |