hexsha stringlengths 40 40 | size int64 19 11.4M | ext stringclasses 13 values | lang stringclasses 1 value | max_stars_repo_path stringlengths 3 270 | max_stars_repo_name stringlengths 5 110 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 9 | max_stars_count float64 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 3 270 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | max_issues_repo_licenses listlengths 1 9 | max_issues_count float64 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 3 270 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | max_forks_repo_licenses listlengths 1 9 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringlengths 24 24 ⌀ | max_forks_repo_forks_event_max_datetime stringlengths 24 24 ⌀ | content stringlengths 19 11.4M | avg_line_length float64 1.93 229k | max_line_length int64 12 688k | alphanum_fraction float64 0.07 0.99 | matches listlengths 1 10 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d2db1c0c602e9b57cd9f969b22d0013c48537d29 | 3,576 | cpp | C++ | test/src/test_serializer.cpp | steinwurf/chunkie | b34a1b4641827efc22b3d477cd79ef745771fcaf | [
"BSD-3-Clause"
] | null | null | null | test/src/test_serializer.cpp | steinwurf/chunkie | b34a1b4641827efc22b3d477cd79ef745771fcaf | [
"BSD-3-Clause"
] | 3 | 2021-09-07T07:48:40.000Z | 2021-12-17T09:34:29.000Z | test/src/test_serializer.cpp | steinwurf/chunkie | b34a1b4641827efc22b3d477cd79ef745771fcaf | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2018 Steinwurf ApS
// All Rights Reserved
//
// Distributed under the "BSD License". See the accompanying LICENSE.rst file.
#include <gtest/gtest.h>
#include <chunkie/serializer.hpp>
#include <algorithm>
#include <vector>
TEST(test_serializer, basic)
{
using serializer_type = chunkie::serializer<uint32_t>;
serializer_type serializer;
EXPECT_EQ(4U, serializer_type::header_size);
EXPECT_EQ(2147483647U, serializer_type::max_object_size);
EXPECT_TRUE(serializer.object_proccessed());
std::vector<uint8_t> object = {1, 2, 3, 4};
std::vector<uint8_t> expected_buffer = {0b10000000, 0, 0, 4, 1, 2, 3, 4};
{
serializer.set_object(object.data(), object.size());
std::vector<uint8_t> buffer(serializer.max_write_buffer_size());
serializer.write_buffer(buffer.data(), buffer.size());
EXPECT_EQ(object.size() + serializer_type::header_size, buffer.size());
EXPECT_TRUE(serializer.object_proccessed());
EXPECT_EQ(expected_buffer, buffer);
}
{
serializer.set_object(object.data(), object.size());
std::vector<uint8_t> buffer(serializer.max_write_buffer_size());
serializer.write_buffer(buffer.data(), buffer.size());
EXPECT_EQ(object.size() + serializer_type::header_size, buffer.size());
EXPECT_TRUE(serializer.object_proccessed());
EXPECT_EQ(expected_buffer, buffer);
}
}
// write an object to multiple buffers
TEST(test_serializer, write_partial_objects)
{
using serializer_type = chunkie::serializer<uint32_t>;
serializer_type serializer;
std::vector<std::vector<uint8_t>> objects = {
{0, 1, 2, 3}, {4, 5, 6, 7, 8, 9},
{10, 11, 12}, {13, 14, 15, 16, 17, 18, 19, 20},
{21}, {22, 23, 24}};
std::vector<std::vector<uint8_t>> expected_buffers = {
{0b10000000, 0, 0, 4, 0},
{0b00000000, 0, 0, 3, 1, 2},
{0b00000000, 0, 0, 1, 3, 0, 0},
{0b10000000, 0, 0, 6, 4, 5, 6, 7},
{0b00000000, 0, 0, 2, 8, 9, 0, 0, 0},
{0b10000000, 0, 0, 3, 10, 11, 12, 0, 0, 0},
{0b10000000, 0, 0, 8, 13, 14, 15, 16, 17, 18, 19},
{0b00000000, 0, 0, 1, 20, 0, 0, 0, 0, 0, 0, 0},
{
0b10000000,
0,
0,
1,
21,
0,
0,
0,
0,
0,
0,
0,
0,
},
{0b10000000, 0, 0, 3, 22, 23, 24, 0, 0, 0, 0, 0, 0, 0},
};
std::vector<std::vector<uint8_t>> buffers;
// We write to buffer of growing size 5,6,7,8, ... bytes
uint32_t buffer_size = 5;
for (const auto& object : objects)
{
serializer.set_object(object.data(), object.size());
while (!serializer.object_proccessed())
{
std::vector<uint8_t> buffer(buffer_size, 0U);
buffer_size++;
auto bytes = std::min<uint32_t>(buffer.size(),
serializer.max_write_buffer_size());
serializer.write_buffer(buffer.data(), bytes);
buffers.push_back(buffer);
}
}
EXPECT_EQ(expected_buffers, buffers);
}
TEST(test_serializer, max_object_size)
{
EXPECT_EQ(127U, chunkie::serializer<uint8_t>::max_object_size);
EXPECT_EQ(32767U, chunkie::serializer<uint16_t>::max_object_size);
EXPECT_EQ(2147483647U, chunkie::serializer<uint32_t>::max_object_size);
EXPECT_EQ(9223372036854775807U,
chunkie::serializer<uint64_t>::max_object_size);
}
| 28.83871 | 80 | 0.586409 | [
"object",
"vector"
] |
d2db20bca02c0ef736c7d31e750cac03c7473ac7 | 97,454 | cpp | C++ | Extensions/ZilchShaders/Translator.cpp | RachelWilSingh/ZeroCore | e9a2f82d395e5c89fb98eceac44ce60d016dbff3 | [
"MIT"
] | 52 | 2018-09-11T17:18:35.000Z | 2022-03-13T15:28:21.000Z | Extensions/ZilchShaders/Translator.cpp | RachelWilSingh/ZeroCore | e9a2f82d395e5c89fb98eceac44ce60d016dbff3 | [
"MIT"
] | 1,409 | 2018-09-19T18:03:43.000Z | 2021-06-09T08:33:33.000Z | Extensions/ZilchShaders/Translator.cpp | RachelWilSingh/ZeroCore | e9a2f82d395e5c89fb98eceac44ce60d016dbff3 | [
"MIT"
] | 26 | 2018-09-11T17:16:32.000Z | 2021-11-22T06:21:19.000Z | ///////////////////////////////////////////////////////////////////////////////
///
/// Authors: Joshua Davis
/// Copyright 2015, DigiPen Institute of Technology
///
///////////////////////////////////////////////////////////////////////////////
#include "Precompiled.hpp"
namespace Zero
{
//-------------------------------------------------------------------ZilchShaderTranslator
ZilchShaderTranslator::ZilchShaderTranslator()
{
mErrors = nullptr;
mCurrentProject = nullptr;
mCurrentLibrary = nullptr;
mErrorTriggered = false;
mInitialized = false;
mLibraryTranslator.mTranslator = this;
}
ZilchShaderTranslator::~ZilchShaderTranslator()
{
}
void ZilchShaderTranslator::SetSettings(ZilchShaderSettingsRef& settings)
{
mSettings = settings;
}
void ZilchShaderTranslator::Setup()
{
SetupGeneric();
SetupShaderLanguage();
}
void ZilchShaderTranslator::SetupGeneric()
{
if(!mInitialized)
{
mInitialized = true;
SetupWalkerRegistration();
SetupTokenPrecedence();
}
}
void ZilchShaderTranslator::SetupWalkerRegistration()
{
mPreWalker.Register(&ZilchShaderTranslator::PreWalkClassDeclaration);
mPreWalker.Register(&ZilchShaderTranslator::PreWalkClassFunction);
mPreWalker.Register(&ZilchShaderTranslator::PreWalkClassVariables);
mWalker.RegisterNonLeafBase(&ZilchShaderTranslator::FormatCommentsAndLines);
mWalker.Register(&ZilchShaderTranslator::GenerateClassDeclaration);
mWalker.Register(&ZilchShaderTranslator::WalkClassVariables);
mWalker.Register(&ZilchShaderTranslator::WalkClassConstructor);
mWalker.Register(&ZilchShaderTranslator::WalkClassFunction);
mWalker.Register(&ZilchShaderTranslator::WalkFunctionCallNode);
mWalker.Register(&ZilchShaderTranslator::WalkLocalVariable);
mWalker.Register(&ZilchShaderTranslator::WalkStaticTypeOrCreationCallNode);
mWalker.Register(&ZilchShaderTranslator::WalkExpressionInitializerNode);
mWalker.Register(&ZilchShaderTranslator::WalkUnaryOperationNode);
mWalker.Register(&ZilchShaderTranslator::WalkBinaryOperationNode);
mWalker.Register(&ZilchShaderTranslator::WalkCastNode);
mWalker.Register(&ZilchShaderTranslator::WalkValueNode);
mWalker.Register(&ZilchShaderTranslator::WalkLocalRef);
mWalker.Register(&ZilchShaderTranslator::WalkMemberAccessNode);
mWalker.Register(&ZilchShaderTranslator::WalkIfRootNode);
mWalker.Register(&ZilchShaderTranslator::WalkIfNode);
mWalker.Register(&ZilchShaderTranslator::WalkContinueNode);
mWalker.Register(&ZilchShaderTranslator::WalkBreakNode);
mWalker.Register(&ZilchShaderTranslator::WalkReturnNode);
mWalker.Register(&ZilchShaderTranslator::WalkWhileNode);
mWalker.Register(&ZilchShaderTranslator::WalkDoWhileNode);
mWalker.Register(&ZilchShaderTranslator::WalkForNode);
mWalker.Register(&ZilchShaderTranslator::WalkForEachNode);
mWalker.Register(&ZilchShaderTranslator::WalkMultiExpressionNode);
mWalker.RegisterNonLeafBase(&ZilchShaderTranslator::FormatStatement);
mWalker.RegisterDerived<Zilch::TypeIdNode>(&ZilchShaderTranslator::WalkUnknownNode);
}
void ZilchShaderTranslator::SetupTokenPrecedence()
{
//lower number is higher precedence (precedence same as C)
mTokenPrecedence[Zilch::Grammar::Increment] = OperatorInfo(2, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::Decrement] = OperatorInfo(2, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::LogicalNot] = OperatorInfo(2, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::BitwiseNot] = OperatorInfo(2, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::As] = OperatorInfo(2, OperatorAssociativityType::RightToLeft);
//can't set the precedence of these unary operators since they use the same token as their binary counterparts
//mTokenPriorities[Zilch::Grammar::Plus] = 2;
//mTokenPriorities[Zilch::Grammar::Minus] = 2;
mTokenPrecedence[Zilch::Grammar::Multiply] = OperatorInfo(3, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::Divide] = OperatorInfo(3, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::Modulo] = OperatorInfo(3, OperatorAssociativityType::LeftToRight);
//mTokenPrecedence[Zilch::Grammar::Exponent] = 3;
mTokenPrecedence[Zilch::Grammar::Add] = OperatorInfo(4, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::Subtract] = OperatorInfo(4, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::BitshiftLeft] = OperatorInfo(5, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::BitshiftRight] = OperatorInfo(5, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::LessThan] = OperatorInfo(6, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::LessThanOrEqualTo] = OperatorInfo(6, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::GreaterThan] = OperatorInfo(6, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::GreaterThanOrEqualTo] = OperatorInfo(6, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::Equality] = OperatorInfo(7, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::Inequality] = OperatorInfo(7, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::BitwiseAnd] = OperatorInfo(8, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::BitwiseXor] = OperatorInfo(9, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::BitwiseOr] = OperatorInfo(10, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::LogicalAnd] = OperatorInfo(11, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::LogicalOr] = OperatorInfo(12, OperatorAssociativityType::LeftToRight);
mTokenPrecedence[Zilch::Grammar::Assignment] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::AssignmentAdd] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::AssignmentSubtract] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::AssignmentMultiply] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::AssignmentDivide] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::AssignmentModulo] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
//mTokenPrecedence[Zilch::Grammar::AssignmentExponent] = 14;
mTokenPrecedence[Zilch::Grammar::AssignmentLeftShift] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::AssignmentRightShift] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::AssignmentBitwiseAnd] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::AssignmentBitwiseXor] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
mTokenPrecedence[Zilch::Grammar::AssignmentBitwiseOr] = OperatorInfo(14, OperatorAssociativityType::RightToLeft);
}
void ZilchShaderTranslator::ParseNativeLibrary(ZilchShaderLibrary* shaderLibrary)
{
mLibraryTranslator.ParseNativeLibrary(this, shaderLibrary);
}
bool ZilchShaderTranslator::Translate(Zilch::SyntaxTree& syntaxTree, ZilchShaderProject* project, ZilchShaderLibraryRef& libraryRef)
{
mErrorTriggered = false;
mCurrentProject = project;
mCurrentLibrary = libraryRef;
mErrors = mCurrentProject;
SetupShaderLanguage();
// Walk the tree to generate translations of all types in this library
ZilchShaderTranslatorContext context;
// Run the pre-walk code (to avoid order issues)
mPreWalker.Walk(this, syntaxTree.Root, &context);
// This must come after pre-walking classes so that we have all required type names already populated
RegisterLibraryBoundTemplateTypes();
// Now run actual translation
mWalker.Walk(this, syntaxTree.Root, &context);
return !mErrorTriggered;
}
void ZilchShaderTranslator::BuildFinalShader(ShaderType* mainType, ShaderTypeTranslation& result, bool generatedCodeRangeMappings, bool walkDependencies)
{
// This should normally only happen when someone tries to request shader that didn't exist (ie. geometry)
if(mainType == nullptr)
return;
HashSet<ShaderType*> visitedType;
Array<ShaderType*> dependencies;
// Gather all dependencies (or just append the type if debugging)
if(walkDependencies)
BuildDependencies(mainType, visitedType, dependencies);
else
dependencies.PushBack(mainType);
ShaderCodeBuilder finalBuilder;
// Emit the version string needed to compile
finalBuilder << GetVersionString() << "\n";
// If the user wants range mappings then set the node to fill out
CodeRangeMapping* rootRange = nullptr;
if(generatedCodeRangeMappings)
rootRange = &result.mRoot;
// First output all shader inputs and outputs. These should be at the
// top as any fragment could try to use forced static built-ins.
finalBuilder << "//----- Shader Inputs/Outputs -----" << finalBuilder.EmitLineReturn();
finalBuilder << mainType->mInputAndOutputVariableDeclarations;
finalBuilder << finalBuilder.EmitLineReturn();
// Now write out all the fragment pieces in this order.
BuildStructsTranslation(finalBuilder, dependencies, rootRange);
BuildForwardDeclarationTranslation(finalBuilder, dependencies, mainType, rootRange);
BuildGlobalVarsTranslation(finalBuilder, dependencies, rootRange);
BuildFunctionCodeTranslation(finalBuilder, dependencies, mainType, rootRange);
result.mTranslation = finalBuilder.ToString();
result.mRoot.mDestPositionEnd = finalBuilder.GetSize();
}
void ZilchShaderTranslator::BuildDependencies(ShaderType* currentType, HashSet<ShaderType*>& visitedTypes, Array<ShaderType*>& dependencies)
{
// Don't double visit a type
if(visitedTypes.Contains(currentType))
return;
visitedTypes.Insert(currentType);
// Iterate over all dependencies of this class
for(size_t i = 0; i < currentType->mDependencyList.Size(); ++i)
{
ShaderType* dependencyShaderType = currentType->mDependencyList[i];
if(dependencyShaderType == nullptr)
continue;
BuildDependencies(dependencyShaderType, visitedTypes, dependencies);
}
// push this type on last so we have the most top level dependency first
dependencies.PushBack(currentType);
}
void ZilchShaderTranslator::BuildStructsTranslation(ShaderCodeBuilder& finalBuilder, Array<ShaderType*>& dependencies, CodeRangeMapping* rootRange)
{
// Start a range of all of the structs being declared
bool generateRanges = rootRange != nullptr;
ScopedRangeMapping structsRange(finalBuilder, rootRange, nullptr, generateRanges, CodeRangeDebugString("Structs"));
// Write out all structs
finalBuilder << "//----- Struct Definitions -----" << finalBuilder.EmitLineReturn();
for(size_t i = 0; i < dependencies.Size(); ++i)
{
ShaderType* type = dependencies[i];
// Check if this type hides the struct declaration
if(type->GetHideStruct())
continue;
// Map this entire class' struct
ScopedRangeMapping typeStructRange(finalBuilder, &structsRange, nullptr, &type->mSourceLocation, generateRanges,
CodeRangeDebugString("Class '%s' Struct Declaration", type->mZilchName.c_str()));
finalBuilder << "struct " << type->mShaderName << finalBuilder.EmitLineReturn();
finalBuilder.BeginScope();
// Write out all variable declarations
for(size_t i = 0; i < type->mFieldList.Size(); ++i)
{
ShaderField* field = type->mFieldList[i];
// Map each variable declaration
ScopedRangeMapping varDeclarationRange(finalBuilder, &typeStructRange, &field->mPreInitRange, nullptr, generateRanges,
CodeRangeDebugString("'%s.%s' Struct Var Declaration", type->mZilchName.c_str(), field->mZilchName.c_str()));
// Only add non-static fields into the struct definition
if(field->IsStatic() == false)
{
finalBuilder.WriteIndent();
finalBuilder << field->mShaderType << " " << field->mShaderName << ";" << finalBuilder.LineReturn;
}
}
// Close the class scope
finalBuilder.EndClassScope();
finalBuilder.WriteLine();
}
}
void ZilchShaderTranslator::BuildForwardDeclarationTranslationHelper(ShaderCodeBuilder& finalBuilder, ShaderType* shaderType, ShaderFunction* shaderFunction, ScopedRangeMapping& typeForwardDeclarationRange, bool generateRanges)
{
// Build a range for the full function's declaration (independent of the signature)
ScopedRangeMapping functionForwardDeclarationRange(finalBuilder, &typeForwardDeclarationRange, nullptr, &shaderFunction->mSourceLocation, generateRanges,
CodeRangeDebugString("'%s.%s' Forward Declaration", shaderType->mZilchName.c_str(), shaderFunction->mZilchName.c_str()));
// Write out the beginning of the function declaration
finalBuilder << shaderFunction->mShaderReturnType << " " << shaderFunction->mShaderName;
// Add a range for the signature (and all of its children) under the total function declaration
ScopedRangeMapping signatureRange(finalBuilder, &functionForwardDeclarationRange, &shaderFunction->mSignatureRange, nullptr, generateRanges,
CodeRangeDebugString("'%s.%s' signature", shaderType->mZilchName.c_str(), shaderFunction->mZilchName.c_str()));
// Now write out the function signature
finalBuilder << shaderFunction->mShaderSignature << ";" << finalBuilder.LineReturn;
}
void ZilchShaderTranslator::BuildForwardDeclarationTranslation(ShaderCodeBuilder& finalBuilder, Array<ShaderType*>& dependencies, ShaderType* mainType, CodeRangeMapping* rootRange)
{
bool generateRanges = rootRange != nullptr;
// Build a range to map all forward declarations
ScopedRangeMapping forwardDeclarationRanges(finalBuilder, rootRange, nullptr, generateRanges, CodeRangeDebugString("Forward Declarations"));
// Write out all forward declarations
finalBuilder << "//----- Forward Declarations -----" << finalBuilder.EmitLineReturn();
for(size_t i = 0; i < dependencies.Size(); ++i)
{
ShaderType* type = dependencies[i];
// If this type hides functions then skip it. This is typically on native
// types (such as Real3) that completely map to built-in types.
if(type->GetHideFunctions())
continue;
// Map all forward declarations for this type
ScopedRangeMapping typeForwardDeclarationRange(finalBuilder, &forwardDeclarationRanges, nullptr, &type->mSourceLocation, generateRanges,
CodeRangeDebugString("Class '%s' Forward Declarations", type->mZilchName.c_str()));
// Forward declare functions (do this before functions/global variables in case any variable relies on that)
for(size_t i = 0; i < type->mFunctionList.Size(); ++i)
{
ShaderFunction* function = type->mFunctionList[i];
BuildForwardDeclarationTranslationHelper(finalBuilder, type, function, typeForwardDeclarationRange, generateRanges);
}
// If this is the main type then write out any extra shader functions. This is done inside the loop of
// all dependency types instead of afterwards to deal with the code range mapping.
if(type == mainType)
{
for(size_t i = 0; i < type->mFinalShaderFunctions.Size(); ++i)
{
ShaderFunction* function = type->mFinalShaderFunctions[i];
BuildForwardDeclarationTranslationHelper(finalBuilder, type, function, typeForwardDeclarationRange, generateRanges);
}
}
finalBuilder.WriteLine();
}
}
void ZilchShaderTranslator::BuildGlobalVarsTranslationHelper(ShaderCodeBuilder& finalBuilder, ShaderField* field, ScopedRangeMapping& typeGlobalVarsRange, bool generateRanges)
{
ShaderType* owningType = field->mOwner;
// Map all global variable declarations for this type
ScopedRangeMapping varRange(finalBuilder, &typeGlobalVarsRange, nullptr, &field->mSourceLocation, generateRanges,
CodeRangeDebugString("'%s.%s' Global Var Declaration", owningType->mZilchName.c_str(), field->mZilchName.c_str()));
// If the type (only check shader types) has a forced declaration qualifier (uniform, etc...) then add that
ShaderType* fieldType = mCurrentLibrary->FindType(field->mZilchType);
if(!fieldType->mForcedDeclarationQualifiers.Empty())
finalBuilder << fieldType->mForcedDeclarationQualifiers << " ";
// Write out the field declaration
finalBuilder << field->mShaderType << " " << field->mShaderName;
// If the field has a default value then write it out
if(!field->mShaderDefaultValueString.Empty())
{
// Map the variable's default value code
ScopedRangeMapping preInitRange(finalBuilder, &varRange, &field->mPreInitRange, nullptr, generateRanges,
CodeRangeDebugString("'%s.%s' Global Var Pre-Init", owningType->mZilchName.c_str(), field->mZilchName.c_str()));
finalBuilder << " = " << field->mShaderDefaultValueString;
}
finalBuilder << ";" << finalBuilder.LineReturn;
}
void ZilchShaderTranslator::BuildGlobalVarsTranslation(ShaderCodeBuilder& finalBuilder, Array<ShaderType*>& dependencies, CodeRangeMapping* rootRange)
{
bool generate = rootRange != nullptr;
// Build a range to map all global variables
ScopedRangeMapping globalVarRanges(finalBuilder, rootRange, nullptr, generate, CodeRangeDebugString("Global Vars"));
// Store the "ordered map" of all shared fields so that we can emit them only once
HashSet<String> sharedFieldNames;
Array<ShaderField*> sharedFieldList;
// Write out all globals for all types
finalBuilder << "//----- Global Variable Declarations -----" << finalBuilder.EmitLineReturn();
for(size_t i = 0; i < dependencies.Size(); ++i)
{
ShaderType* type = dependencies[i];
// If this type hides the struct declaration then it doesn't have any members and hence global
// variables (typically statics) should also be hidden. Maybe separate into another flag later if this becomes an issue?
if(type->GetHideStruct())
continue;
// Map all global variable declarations for this type
ScopedRangeMapping typeGlobalVarsRange(finalBuilder, &globalVarRanges, nullptr, &type->mSourceLocation, generate,
CodeRangeDebugString("Class '%s' Global Vars", type->mZilchName.c_str()));
// To properly deal with basic newline formatting keep track of if this type ever
// wrote out a static variable so we don't add random newlines
bool containsStatic = false;
// Write out all static variable declarations
for(size_t i = 0; i < type->mFieldList.Size(); ++i)
{
ShaderField* field = type->mFieldList[i];
// If this field is not static then don't write it out
if(!field->IsStatic())
continue;
// If this field is actually a built-in (meaning this value will actually come
// from the built-in, not that it just shares the same name) then we should not
// write out the variable declaration because it would be written out by every
// fragment that uses it. Instead, writing this out is the responsibility of the
// main shader type in it's CopyInputOutputVariableDeclarations.
if(IsBuiltInField(field))
continue;
// If this is a shared field then it should only be emitted once
if(field->IsShared())
{
if(!sharedFieldNames.Contains(field->mShaderName))
{
sharedFieldNames.Insert(field->mShaderName);
sharedFieldList.PushBack(field);
}
continue;
}
containsStatic = true;
// Emit the variable declaration
BuildGlobalVarsTranslationHelper(finalBuilder, field, globalVarRanges, generate);
}
// Only write a newline if we wrote out static variables (to avoid random extra newlines)
if(containsStatic)
finalBuilder.WriteLine();
}
// Now write out all shared fields (should only be samplers). Note: any line number remappings will
// point to the first fragment in the composition with the field.
for(size_t i = 0; i < sharedFieldList.Size(); ++i)
{
ShaderField* shaderField = sharedFieldList[i];
BuildGlobalVarsTranslationHelper(finalBuilder, shaderField, globalVarRanges, generate);
}
}
void ZilchShaderTranslator::BuildFunctionCodeTranslationHelper(ShaderCodeBuilder& finalBuilder, ShaderType* shaderType, ShaderFunction* shaderFunction, ScopedRangeMapping& typeCodeRange, bool generateRanges)
{
// Map this entire function's declaration
ScopedRangeMapping functionDeclarationRange(finalBuilder, &typeCodeRange, nullptr, &shaderFunction->mSourceLocation, generateRanges,
CodeRangeDebugString("'%s.%s' Function Declaration", shaderType->mZilchName.c_str(), shaderFunction->mZilchName.c_str()));
// Write all comments out above the function declaration
for(size_t i = 0; i < shaderFunction->mComments.Size(); ++i)
{
String comment = shaderFunction->mComments[i];
WriteComment(finalBuilder, comment);
}
// Write out the beginning of the function declaration
finalBuilder << shaderFunction->mShaderReturnType << " " << shaderFunction->mShaderName;
// Map and write out the function's signature
{
ScopedRangeMapping signatureRange(finalBuilder, &functionDeclarationRange, &shaderFunction->mSignatureRange, nullptr, generateRanges,
CodeRangeDebugString("'%s.%s' Function Signature", shaderType->mZilchName.c_str(), shaderFunction->mZilchName.c_str()));
// Now we can write out the signature
finalBuilder << shaderFunction->mShaderSignature << finalBuilder.LineReturn;
}
// Map and write out the function's code
{
ScopedRangeMapping functionBodyRange(finalBuilder, &functionDeclarationRange, &shaderFunction->mBodyRange, nullptr, generateRanges,
CodeRangeDebugString("'%s.%s' Function Body", shaderType->mZilchName.c_str(), shaderFunction->mZilchName.c_str()));
// Now write out the function body code
finalBuilder.Write(shaderFunction->mShaderBodyCode);
}
finalBuilder.WriteLine();
}
void ZilchShaderTranslator::BuildFunctionCodeTranslation(ShaderCodeBuilder& finalBuilder, Array<ShaderType*>& dependencies, ShaderType* mainType, CodeRangeMapping* rootRange)
{
bool generate = rootRange != nullptr;
// Build a range to map all code functions declarations
ScopedRangeMapping codeRanges(finalBuilder, rootRange, nullptr, generate, CodeRangeDebugString("Global Vars"));
// Write out all class functions
for(size_t i = 0; i < dependencies.Size(); ++i)
{
ShaderType* type = dependencies[i];
if(type->GetHideFunctions())
continue;
// Map the all of the code for the current type
ScopedRangeMapping typeCodeRange(finalBuilder, &codeRanges, nullptr, &type->mSourceLocation, generate,
CodeRangeDebugString("Class '%s' Code", type->mZilchName.c_str()));
// Add a small comment for starting this class' functions
finalBuilder << "//----- " << type->mZilchName << " Functions -----" << finalBuilder.EmitLineReturn();
for(size_t i = 0; i < type->mFunctionList.Size(); ++i)
{
ShaderFunction* function = type->mFunctionList[i];
BuildFunctionCodeTranslationHelper(finalBuilder, type, function, typeCodeRange, generate);
}
// If this is the main type then write out the final shader functions
if(type == mainType)
{
// Add a small comment for starting this class' shader only functions
if(!type->mFinalShaderFunctions.Empty())
finalBuilder << "//----- " << type->mZilchName << " Final Shader Functions -----" << finalBuilder.EmitLineReturn();
for(size_t i = 0; i < type->mFinalShaderFunctions.Size(); ++i)
{
ShaderFunction* function = type->mFinalShaderFunctions[i];
BuildFunctionCodeTranslationHelper(finalBuilder, type, function, typeCodeRange, generate);
}
}
}
}
void ZilchShaderTranslator::WriteComment(ShaderCodeBuilder& builder, StringParam comment)
{
// See if there's a newline in the comment. If so this is a multi-line comment
bool isMultiLine = false;
for(StringRange range = comment.All(); !range.Empty(); range.PopFront())
{
Rune rune = range.Front();
if(rune.value == '\r' || rune.value == '\n')
{
isMultiLine = true;
break;
}
}
// If this is multi-line then emit an actual multi-line comment
if(isMultiLine)
{
builder.WriteIndentation();
builder.Write("/*");
builder.Write(comment);
builder.WriteLine("*/");
}
// Otherwise emit a single-line comment
else
{
builder.WriteIndentation();
builder.Write("//");
builder.WriteLine(comment);
}
}
void ZilchShaderTranslator::FormatCommentsAndLines(Zilch::SyntaxNode*& node, ZilchShaderTranslatorContext* context)
{
context->Flags = Zilch::WalkerFlags::ChildrenNotHandled;
//if we don't perform the generic handling then don't indent the statement
if(context->mPerformAutoFormatting == false)
return;
ShaderCodeBuilder& builder = context->GetBuilder();
// If the node is a statement then we want to do formatting of newlines
if(Zilch::StatementNode::IsNodeUsedAsStatement(node))
{
// This is basically a copy-paste from the zilch formatter, not entirely sure how it's working other than
// keeping track of the last scope to offset (so dealing with the '{}' operators) and then subtracting of comment lines.
bool scopeFound = false;
for(int i = (int)(context->FormatScopes.Size() - 1); i >= 0; --i)
{
ScopeLastNode& scope = context->FormatScopes[i];
if(scope.AssociatedScope == node->Parent)
{
scopeFound = true;
break;
}
}
ScopeLastNode* foundScope = nullptr;
if(scopeFound)
{
while(context->FormatScopes.Back().AssociatedScope != node->Parent)
{
context->FormatScopes.PopBack();
}
foundScope = &context->FormatScopes.Back();
}
else
{
foundScope = &context->FormatScopes.PushBack();
foundScope->AssociatedScope = node->Parent;
}
int lineDifference = 0;
if(foundScope->LastNode != nullptr)
lineDifference = (int)(node->Location.StartLine - foundScope->LastNode->Location.EndLine);
lineDifference -= (int)node->Comments.Size();
// Since we will always emit one line, we skip one
for(int i = 1; i < lineDifference; ++i)
builder << builder.EmitIndent() << builder.EmitLineReturn();
foundScope->LastNode = node;
}
// Add all comments for this node
for(uint i = 0; i < node->Comments.Size(); ++i)
{
String comment = node->Comments[i];
WriteComment(builder, comment);
}
// If this node is a statement (and not the root if not) then add indentation for the line
if(Zilch::StatementNode::IsNodeUsedAsStatement(node) &&
Zilch::Type::DynamicCast<Zilch::IfRootNode*>(node) == nullptr)
context->GetBuilder().WriteIndentation();
}
void ZilchShaderTranslator::FormatStatement(Zilch::StatementNode*& node, ZilchShaderTranslatorContext* context)
{
context->Flags = Zilch::WalkerFlags::ChildrenNotHandled;
//if we don't perform the generic handling then add ';'
if(context->mPerformAutoFormatting == false)
return;
// This will always run, even if other handlers will handle it
// If this node is not being used as a direct statement
// For example, an expression is a statement, but isn't always used as a statement
if(Zilch::StatementNode::IsNodeUsedAsStatement(node) == false)
return;
// As long as the statement isn't a scoped based node (if, for, while, etc)
// then we know it requires delimiting
if(Zilch::Type::DynamicCast<Zilch::ScopeNode*>(node) == nullptr &&
Zilch::Type::DynamicCast<Zilch::IfRootNode*>(node) == nullptr)
{
context->GetBuilder().WriteLine(";");
}
}
bool ZilchShaderTranslator::ValidateParamType(Zilch::AttributeParameter& attributeParam, Zilch::ConstantType::Enum expectedType, Zilch::CodeLocation& location)
{
// Make sure the parameter type is correct
if(attributeParam.Type != expectedType)
{
String msg = String::Format("Parameter '%s' must be of type %s", attributeParam.Name.c_str(), Zilch::ConstantType::Names[expectedType]);
SendTranslationError(location, msg);
return false;
}
return true;
}
bool ZilchShaderTranslator::ValidateParamType(Zilch::ValueNode* valueNode, StringParam paramName, Zilch::Grammar::Enum expectedType, StringParam expectedTypeStr, Zilch::CodeLocation& location)
{
// Make sure the parameter type is correct
if(valueNode == nullptr || valueNode->Value.TokenId != expectedType)
{
String msg = String::Format("Parameter '%s' must be of type %s", paramName.c_str(), expectedTypeStr.c_str());
SendTranslationError(location, msg);
return false;
}
return true;
}
void ZilchShaderTranslator::ParseIntrinsicAttribute(Zilch::ClassNode*& node, ShaderType* currentType)
{
NameSettings& nameSettings = mSettings->mNameSettings;
Array<String> attributesToAdd;
// Find the first Intrinsic attribute that we care about
ShaderAttributeList::NamedRange range = currentType->mAttributes.FindAttributes(nameSettings.mIntrinsicAttribute);
while(!range.Empty())
{
ShaderAttribute* shaderAttribute = range.Front();
// Find what language this attribute is for, if it's not one we care about then skip it (for now mark as an error)
Zilch::AttributeParameter* languageParam = shaderAttribute->FindFirstParameter(nameSettings.mLanguageParamName);
if(languageParam->StringValue != "glsl")
{
String msg = String::Format("Language '%s' is unsupported. Currently only 'glsl' is supported", languageParam->StringValue.c_str());
Zilch::CodeLocation* location = currentType->mAttributes.GetLocation(shaderAttribute, languageParam);
SendTranslationError(*location, msg);
break;
}
// Parse all of the parameters we care about now that we know this
// attribute is for the language we are currently translating to
for(size_t paramIndex = 0; paramIndex < shaderAttribute->mParameters.Size(); ++paramIndex)
{
Zilch::AttributeParameter& attributeParam = shaderAttribute->mParameters[paramIndex];
if(attributeParam.Name == nameSettings.mTypeNameParamName)
currentType->mShaderName = attributeParam.StringValue;
else if(attributeParam.Name == nameSettings.mStorageQualifierParamName)
currentType->mForcedDeclarationQualifiers = BuildString(currentType->mForcedDeclarationQualifiers, attributeParam.StringValue);
else if(attributeParam.Name == nameSettings.mRefTypeParamName)
currentType->mReferenceTypeQualifier = attributeParam.StringValue;
else if(attributeParam.Name == nameSettings.mPropertyTypeParamName)
currentType->mPropertyType = attributeParam.StringValue;
else if(attributeParam.Name == nameSettings.mForcedStaticParamName && attributeParam.BooleanValue == true)
attributesToAdd.PushBack(nameSettings.mForcedStaticAttribute);
else if(attributeParam.Name == nameSettings.mNonCopyableParamName && attributeParam.BooleanValue == true)
{
currentType->SetNonCopyable(attributeParam.BooleanValue);
attributesToAdd.PushBack(nameSettings.mNonCopyableAttribute);
}
}
break;
}
// Add any attributes to this type that were implied by the intrinsic attribute (such as forced static)
for(size_t i = 0; i < attributesToAdd.Size(); ++i)
currentType->mAttributes.AddAttribute(attributesToAdd[i], nullptr);
}
void ZilchShaderTranslator::ParseSharedAttribute(Zilch::MemberVariableNode*& node, ShaderAttribute* attribute, ShaderField* currentField)
{
NameSettings& nameSettings = mSettings->mNameSettings;
currentField->mIsShared = true;
String varName = currentField->mZilchName;
// If there is a parameter to override the shared name then use that name
if(attribute->mParameters.Size() == 1)
varName = attribute->mParameters[0].StringValue;
// Mangle the variable name to include the type so as to avoid naming conflicts
currentField->mShaderName = BuildString(varName, "_", currentField->mZilchType);
}
void ZilchShaderTranslator::PreWalkClassDeclaration(Zilch::ClassNode*& node, ZilchShaderTranslatorContext* context)
{
NameSettings& nameSettings = mSettings->mNameSettings;
ShaderType* currentType = FindShaderType(node->Type, node);
context->mCurrentType = currentType;
// Translate the class name (needed in advance often times for implements/extensions)
currentType->mShaderName = FixClassName(node->Type);
// By default set a type's reference qualifier to be the shared reference keyword
currentType->mReferenceTypeQualifier = nameSettings.mReferenceKeyword;
// Check for and parse the intrinsic attribute
ParseIntrinsicAttribute(node, currentType);
context->Walker->Walk(this, node->Functions, context);
context->Walker->Walk(this, node->Variables, context);
// If this is a geometry fragment then make sure that we have valid input/output streams and data types.
// If not then throw an error and replace the stored type with the unknown type to help prevent crashes.
if(currentType->mFragmentType == FragmentType::Geometry)
{
// If we never found the 'Main' function with the correct parameters
// then we won't have the input or output type so notify the user.
if(currentType->mInputType == nullptr && currentType->mOutputType == nullptr)
{
SendTranslationError(node->Location, "Geometry shaders must have a 'Main' function of signature (inputType, outputType)");
}
// Replace the input stream and input data types with dummies if needed
if(currentType->mInputType == nullptr)
currentType->mInputType = FindAndReportUnknownType(node->Type, node);
if(currentType->mInputType->mInputType == nullptr)
currentType->mInputType->mInputType = FindAndReportUnknownType(node->Type, node);
// Replace the output stream and output data types with dummies if needed
if(currentType->mOutputType == nullptr)
currentType->mOutputType = FindAndReportUnknownType(node->Type, node);
if(currentType->mOutputType->mOutputType == nullptr)
currentType->mOutputType->mOutputType = FindAndReportUnknownType(node->Type, node);
}
// Verify that if this is a fragment type that it has the main function
if(currentType->mFragmentType != FragmentType::None)
{
ShaderType::FunctionList* functions = currentType->mFunctionNameMultiMap.FindPointer("Main");
// @JoshD: This should really verify that the correct main function (Main() : Void) exists,
// but I don't have this information here right now. Refactor later!
if(functions == nullptr)
{
String msg = String::Format("Type '%s' must have a function of signature 'Main() : Void'.", currentType->mZilchName.c_str());
SendTranslationError(node->Location, msg);
}
}
}
void ZilchShaderTranslator::PreWalkClassFunction(Zilch::FunctionNode*& node, ZilchShaderTranslatorContext* context)
{
NameSettings& nameSettings = mSettings->mNameSettings;
ShaderType* currentType = context->mCurrentType;
ShaderFunction* function = currentType->FindFunction(node->DefinedFunction);
// Translate the function name
function->mShaderName = MangleName(function->mZilchName, currentType);
// If this function says to not mangle then replace the shader name with the zilch name
if(function->ContainsAttribute(nameSettings.mNoMangleAttributeName))
function->mShaderName = function->mZilchName;
// If this is an extension property then change the shader name to be mangled based upon the extension type's name
ShaderAttribute* extensionAttribute = function->mAttributes.FindFirstAttribute(nameSettings.mExtensionAttribute);
if(extensionAttribute != nullptr && extensionAttribute->mParameters.Size() == 1)
{
Zilch::AttributeParameter& param = extensionAttribute->mParameters[0];
String extendsTypeStr = param.TypeValue->ToString();
ShaderType* shaderSelfType = mCurrentLibrary->FindType(extendsTypeStr);
if(shaderSelfType != nullptr)
function->mShaderName = MangleName(function->mZilchName, shaderSelfType);
}
// If this is a geometry fragment's main function with the correct number of arguments then parse the input and output stream types
if(currentType->mFragmentType == FragmentType::Geometry && node->Name.Token == "Main" && node->Parameters.Size() == 2)
{
// Find the shader type for param 0. If it's an input type then save it and its template type
Zilch::BoundType* param0Type = (Zilch::BoundType*)node->Parameters[0]->ResultType;
ShaderType* param0ShaderType = FindShaderType(param0Type, node->Parameters[0]);
if(param0ShaderType->GetTypeData()->mType == ShaderVarType::GeometryInput)
{
currentType->mInputType = param0ShaderType;
param0ShaderType->mInputType = FindShaderType(param0Type->TemplateArguments[0].TypeValue, node->Parameters[0]);
}
// Find the shader type for param 1. If it's an output type then save it and its template type
Zilch::BoundType* param1Type = (Zilch::BoundType*)node->Parameters[1]->ResultType;
ShaderType* param1ShaderType = FindShaderType(param1Type, node->Parameters[1]);
if(param1ShaderType->GetTypeData()->mType == ShaderVarType::GeometryOutput)
{
currentType->mOutputType = param1ShaderType;
param1ShaderType->mOutputType = FindShaderType(param1Type->TemplateArguments[0].TypeValue, node->Parameters[1]);
}
}
}
void ZilchShaderTranslator::PreWalkClassVariables(Zilch::MemberVariableNode*& node, ZilchShaderTranslatorContext* context)
{
NameSettings& nameSettings = mSettings->mNameSettings;
ShaderType* currentType = context->mCurrentType;
// Check if this is actually a get/set
Zilch::GetterSetter* getterSetter = Zilch::Type::DynamicCast<Zilch::GetterSetter*>(node->CreatedProperty);
if(getterSetter)
{
if(node->Get)
PreWalkClassFunction(node->Get, context);
return;
}
ShaderField* field = currentType->FindField(node->Name.Token);
field->mShaderName = field->mZilchName;
// Find the shader type that this variable results in
ShaderType* shaderResultType = FindShaderType(node->ResultType, node);
field->mZilchType = shaderResultType->mZilchName;
field->mShaderType = shaderResultType->mShaderName;
field->mSourceLocation = node->Location;
field->mNameLocation = node->CreatedField->NameLocation;
field->mIsStatic = false;
// if this type is static or a type that is forced to be static (such as samplers)
ShaderType* resultShaderType = FindShaderType(node->ResultType, node);
bool isForcedStatic = resultShaderType->ContainsAttribute(NameSettings::mForcedStaticAttribute);
if(field->ContainsAttribute(nameSettings.mStaticAttribute) || isForcedStatic)
{
field->mIsStatic = true;
field->mShaderName = field->mZilchName;
// We have to mangle the variable's name (so that it can't conflict with anything else in global scope,
// however if this field comes from a built-in then we can't mangle the name,
// instead we need to access the global uniform's name (just the zilch name).
if(!IsBuiltInField(field))
{
field->mShaderName = MangleName(field->mZilchName, currentType);
if(node->CreatedField == nullptr)
return;
// Check if this is a shared input
ShaderAttribute* sharedInputAttribute = field->mAttributes.FindFirstAttribute(nameSettings.mSharedInputAttributeName);
if(sharedInputAttribute != nullptr)
ParseSharedAttribute(node, sharedInputAttribute, field);
}
}
// Fragment types are currently illegal as member variables. Validate and throw an error if necessary.
if(shaderResultType->mFragmentType != FragmentType::None)
{
String fragmentTypeName = FragmentType::Names[shaderResultType->mFragmentType];
String message = String::Format("Variables with the attribute '[%s]' are not allowed as member variables.", fragmentTypeName.c_str());
SendTranslationError(node->Location, message);
}
}
void ZilchShaderTranslator::GenerateClassDeclaration(Zilch::ClassNode*& node, ZilchShaderTranslatorContext* context)
{
NameSettings& nameSettings = mSettings->mNameSettings;
ShaderType* currentType = FindShaderType(node->Type, node);
ErrorIf(currentType == nullptr, "Somehow didn't find this type from the pre-walker?");
context->mCurrentType = currentType;
// If this is an intrinsic type then don't walk constructors or variables
// since the built-in type doesn't contain those
if(currentType->GetIntrinsic() == false)
{
// Walk all variables on the class
context->Walker->Walk(this, node->Variables, context);
// If this class doesn't have any members then it will be an error
// (glsl structs must have at least 1 member) so generate a dummy variable for now.
GenerateDummyMemberVariable(currentType);
// now that we have all variables we can generate the preconstructor
GeneratePreConstructor(node, context);
// Now walk all constructors, if we didn't have a default constructor then auto-generate one.
// We do this because constructors are actually functions that create the type, call the
// preconstructor, and return it, as opposed to real constructors.
context->Walker->Walk(this, node->Constructors, context);
GenerateDefaultConstructor(node, context);
}
// Finally we can walk all functions
context->Walker->Walk(this, node->Functions, context);
}
void ZilchShaderTranslator::GenerateDummyMemberVariable(ShaderType* shaderType)
{
// Find out if this class is empty (any variables that are not static)
bool isEmptyClass = true;
for(size_t i = 0; i < shaderType->mFieldList.Size(); ++i)
{
ShaderField* field = shaderType->mFieldList[i];
if(field->mIsStatic == false)
isEmptyClass = false;
}
// If the class is empty then generate an integer with the value of 0
if(isEmptyClass)
{
Zilch::Core& core = Zilch::Core::GetInstance();
String dummyName = "Dummy";
// Use find or create instead of find as this is a glsl requirement to make a dummy var
ShaderField* field = shaderType->FindOrCreateField(dummyName);
field->mShaderDefaultValueString = "0";
field->mIsStatic = false;
field->mShaderName = dummyName;
// Find the integer type so we can set that as the dummy's type
ShaderType* integerType = FindShaderType(core.IntegerType, nullptr);
field->mZilchType = integerType->mZilchName;
field->mShaderType = integerType->mShaderName;
}
}
void ZilchShaderTranslator::GeneratePreConstructor(Zilch::ClassNode*& node, ZilchShaderTranslatorContext* context)
{
NameSettings& nameSettings = mSettings->mNameSettings;
Zilch::Core& core = Zilch::Core::GetInstance();
Zilch::Function* preConstructorFn = node->PreConstructor;
ShaderType* currentType = context->mCurrentType;
ShaderFunction* function = currentType->FindFunction(preConstructorFn);
function->mShaderName = MangleName(function->mZilchName, currentType);
// Pre-constructors return void. Find the void type to know how to translate it
ShaderType* voidShaderType = FindShaderType(core.VoidType, nullptr);
function->mZilchReturnType = voidShaderType->mZilchName;
function->mShaderReturnType = voidShaderType->mShaderName;
// The pre-constructor doesn't really have any node to map to but its signature range will
// try to map to something. To get around this just set the source location back to the class node's location
function->mSignatureRange.Set(node->Location);
// Also each function needs its total range which is just the node's location (or in this case the class')
function->mSourceLocation = node->Location;
// Pre-constructors don't have an actual backing function so there's no real name location
function->mNameLocation = function->mSourceLocation;
// Declare the pre-constructor as taking the class in by reference
StringBuilder signatureBuilder;
signatureBuilder << "(" << nameSettings.mReferenceKeyword << " " << currentType->mShaderName << " " << nameSettings.mThisKeyword << ")";
function->mShaderSignature = signatureBuilder.ToString();
ScopedShaderCodeBuilder builder(context);
// Map the body of the pre-constructor
ScopedCodeRangeMapping preConstructorRange(context, &function->mBodyRange, preConstructorFn->Location, CodeRangeDebugString("PreConstructor"));
builder.BeginScope();
// Have the pre-constructor initialize all non-static variables to their default values
for(size_t i = 0; i < currentType->mFieldList.Size(); ++i)
{
ShaderField* field = currentType->mFieldList[i];
// If the field is static or it has no default value string then don't write out the pre-constructor setting of this argument
if(field->IsStatic() || field->mShaderDefaultValueString.Empty())
continue;
builder.WriteIndent();
ScopedCodeRangeMapping childRange(context, field->mPreInitRange);
builder << nameSettings.mThisKeyword << "." << field->mShaderName << " = " << field->mShaderDefaultValueString << ";" << builder.LineReturn;
}
builder.EndScope();
// Save off the function body
function->mShaderBodyCode = builder.ToString();
}
void ZilchShaderTranslator::GenerateDefaultConstructor(Zilch::ClassNode*& node, ZilchShaderTranslatorContext* context)
{
NameSettings& nameSettings = mSettings->mNameSettings;
ShaderType* currentType = context->mCurrentType;
// Find if we need to create a default constructor (determined in the type collector phase).
// This happens only if no constructor is defined, hence there is an implicit default constructor.
ShaderFunction* constructor = currentType->mFunctionOverloadMap.FindValue(ZilchShaderSettings::GetDefaultConstructorKey(), nullptr);
if(constructor != nullptr)
{
// The default constructor is special and didn't actually exist in zilch, for this create a special function
constructor->mShaderName = MangleName(constructor->mZilchName, currentType);
constructor->mZilchReturnType = currentType->mZilchName;
constructor->mShaderReturnType = currentType->mShaderName;
constructor->mShaderSignature = "()";
// Map the signature range to the class node (default constructors don't have any other logical mapping)
constructor->mSignatureRange.Set(node->Location);
// Also each function needs its total range which is just the node's location (or in this case the class')
constructor->mSourceLocation = node->Location;
// A generated constructor doesn't have an actual backing function so there's no real name location
constructor->mNameLocation = constructor->mSourceLocation;
// Create an instance of the class named 'self' and then call the pre-constructor
ScopedShaderCodeBuilder subBuilder(context);
ScopedCodeRangeMapping constructorRange(context, &constructor->mBodyRange, node->Location, CodeRangeDebugString("Constructor"));
subBuilder.BeginScope();
subBuilder << subBuilder.WriteScopedIndent() << constructor->mShaderReturnType<< " " << nameSettings.mThisKeyword << ";" << subBuilder.LineReturn;
subBuilder << subBuilder.WriteScopedIndent() << MangleName(nameSettings.mPreConstructorName, currentType) << "(" << nameSettings.mThisKeyword << ");" << subBuilder.LineReturn;
subBuilder << subBuilder.WriteScopedIndent() << "return " << nameSettings.mThisKeyword << ";" << subBuilder.LineReturn;
subBuilder.EndScope();
constructor->mShaderBodyCode = subBuilder.ToString();
}
}
void ZilchShaderTranslator::WalkClassVariables(Zilch::MemberVariableNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderType* currentType = context->mCurrentType;
// Check if this is actually a get/set
Zilch::GetterSetter* getterSetter = Zilch::Type::DynamicCast<Zilch::GetterSetter*>(node->CreatedProperty);
if(getterSetter)
{
if(node->Get)
WalkClassFunction(node->Get, context);
return;
}
ShaderField* field = currentType->FindField(node->Name.Token);
// Map the pre-init of this variable
ScopedCodeRangeMapping preInitRange(context, &field->mPreInitRange, node->Location,
CodeRangeDebugString("%s PreInit", field->mZilchName.c_str()));
// if this type is static or a type that is forced to be static (such as samplers)
ShaderType* resultShaderType = FindShaderType(node->ResultType, node);
bool isForcedStatic = resultShaderType->ContainsAttribute(NameSettings::mForcedStaticAttribute);
// if the variable has an initial value then walk the sub-tree and save the result string
if(node->InitialValue != nullptr)
{
// If this type says that it cannot be copied then that currently also means it can't have a default value assigned to it
if(resultShaderType->ContainsAttribute(NameSettings::mNonCopyableAttribute))
{
String msg = String::Format("Type '%s' cannot be assigned to.", field->mZilchType.c_str());
SendTranslationError(node->InitialValue->Location, msg);
}
ScopedShaderCodeBuilder initialValueBuilder(context);
context->Walker->Walk(this, node->InitialValue, context);
field->mShaderDefaultValueString = initialValueBuilder.ToString();
}
else
{
// @JoshD: This eventually needs to be updated to work with FixedArrays
// Otherwise we don't have a default value, however we still need to emit zilch's default value.
// We want to try to find the default constructor for the result type.
Zilch::BoundType* boundType = Zilch::Type::GetBoundType(node->ResultType);
if(boundType != nullptr && !isForcedStatic)
{
const Zilch::FunctionArray* constructors = boundType->GetOverloadedInheritedConstructors();
if(constructors != nullptr && constructors->Empty() == false)
{
// If we managed to find the default constructor then resolve the default constructor's translation
Zilch::Function* defaultConstructor = Zilch::BoundType::GetDefaultConstructor(constructors);
ScopedShaderCodeBuilder initialValueBuilder(context);
mLibraryTranslator.ResolveDefaultConstructor(this, boundType, defaultConstructor, context);
field->mShaderDefaultValueString = initialValueBuilder.ToString();
}
}
}
}
void ZilchShaderTranslator::WalkClassConstructor(Zilch::ConstructorNode*& node, ZilchShaderTranslatorContext* context)
{
// For now, only allow default constructors (could allow this later as long as we force them to also
// have a default constructor so that the compositor can create fragments)
if(node->Parameters.Size() != 0)
{
SendTranslationError(node->Location, "Can only have default constructors");
return;
}
Zilch::Core& core = Zilch::Core::GetInstance();
NameSettings& nameSettings = mSettings->mNameSettings;
ShaderType* currentType = context->mCurrentType;
// In order to have a constructed class being the same as in zilch, constructors are changed into
// functions that return a newly created class. This constructor will call the pre-constructor
// function and then perform any other logic for the constructor.
ShaderFunction* function = currentType->FindFunction(node->DefinedFunction);
function->mShaderName = MangleName(function->mZilchName, currentType);
function->mZilchReturnType = currentType->mZilchName;
function->mShaderReturnType = currentType->mShaderName;
// Also each function needs its total range which is just the node's location (or in this case the class')
function->mSourceLocation = node->Location;
function->mNameLocation = node->DefinedFunction->NameLocation;
// Build up the arguments of the constructor
ScopedShaderCodeBuilder parametersBuilder(context);
ScopedCodeRangeMapping signatureRange(context, &function->mSignatureRange, node->Location, CodeRangeDebugString("Constructor Signature"));
parametersBuilder.Write("(");
context->Walker->Walk(this, node->Parameters, context);
parametersBuilder.Write(")");
signatureRange.PopRange();
// Save the signature of the constructor
function->mShaderSignature = parametersBuilder.ToString();
ScopedShaderCodeBuilder subBuilder(context);
ScopedCodeRangeMapping constructorRange(context, &function->mBodyRange, node->Location, CodeRangeDebugString("Constructor"));
subBuilder.BeginScope();
// As the first 2 lines we need to create the class named self "ClassName self;" and then call the pre-constructor
subBuilder << subBuilder.EmitIndent() << currentType->mShaderName << " " << nameSettings.mThisKeyword << ";" << subBuilder.LineReturn;
subBuilder << subBuilder.EmitIndent() << MangleName(nameSettings.mPreConstructorName, currentType) << "(" << nameSettings.mThisKeyword << ");" << subBuilder.LineReturn;
// Now we can iterate through all of the statements of the constructor
WriteStatements(node->Statements, context);
// Finally return the struct that we created
subBuilder << subBuilder.EmitIndent() << "return " << nameSettings.mThisKeyword << ";" << subBuilder.LineReturn;
subBuilder.EndScope();
// Save the constructor's body
function->mShaderBodyCode = subBuilder.mBuilder.ToString();
}
void ZilchShaderTranslator::WalkClassFunction(Zilch::FunctionNode*& node, ZilchShaderTranslatorContext* context)
{
NameSettings& nameSettings = mSettings->mNameSettings;
Zilch::Core& core = Zilch::Core::GetInstance();
ShaderType* currentType = context->mCurrentType;
ShaderFunction* function = currentType->FindFunction(node->DefinedFunction);
ShaderType* shaderReturnType = FindShaderType(node->Type->Return, node->ReturnType);
function->mZilchReturnType = shaderReturnType->mZilchName;
function->mShaderReturnType = shaderReturnType->mShaderName;
function->mComments = node->Comments;
// Store the function's full location
function->mSourceLocation = node->Location;
function->mNameLocation = node->DefinedFunction->NameLocation;
// Unfortunately the function's location includes the statements. To get the range of just
// the signature we need to start at the function name and go until the last argument or the return type (if it exists)
int signatureStart = node->Name.Location.StartPosition;
int signatureEnd = node->Name.Location.EndPosition;
if(!node->Parameters.Empty())
signatureEnd = node->Parameters.Back()->Location.EndPosition;
if(node->ReturnType != nullptr)
signatureEnd = node->ReturnType->Location.EndPosition;
// Start a builder to make the signature
ScopedShaderCodeBuilder signatureBuilder(context);
ScopedCodeRangeMapping signatureRange(context, &function->mSignatureRange, node->Location, CodeRangeDebugString("Function Signature"));
// Override the source location for the signature
function->mSignatureRange.mSourcePositionStart = signatureStart;
function->mSignatureRange.mSourcePositionEnd = signatureEnd;
signatureBuilder.Write("(");
// Write out the regular signature
WriteFunctionSignature(node, context);
String selfType = currentType->mShaderName;
Zilch::Type* zilchSelfType = node->DefinedFunction->Owner;
// Check for the extension attribute. If we have it then alter
// the self type name (on statics) to be the class we are extending.
ShaderAttribute* extensionAttribute = function->mAttributes.FindFirstAttribute(nameSettings.mExtensionAttribute);
if(extensionAttribute != nullptr && extensionAttribute->mParameters.Size() > 0)
{
Zilch::AttributeParameter& param = extensionAttribute->mParameters[0];
String extendsTypeStr = param.TypeValue->ToString();
ShaderType* shaderSelfType = mCurrentLibrary->FindType(extendsTypeStr);
// If the function is not static then resolve the type name of the self parameter (e.g. convert Real2 to vec2)
if(shaderSelfType != nullptr && function->IsStatic() == false)
selfType = shaderSelfType->mShaderName;
}
// Add dependencies on all input types
for(size_t i = 0; i < node->Parameters.Size(); ++i)
{
Zilch::ParameterNode* parameter = node->Parameters[i];
Zilch::Type* resultType = parameter->ResultType;
ShaderType* paramShaderType = FindShaderType(resultType, parameter);
context->mCurrentType->AddDependency(paramShaderType);
}
// If the function call is not static then we have to add the self parameter
if(!function->ContainsAttribute(nameSettings.mStaticAttribute))
{
// If there were other parameters then we have to add the ',' to separate from the previous arguments
if(!node->Parameters.Empty())
signatureBuilder << ", ";
AddSelfParameter(zilchSelfType, selfType, context);
}
signatureBuilder.Write(")");
signatureRange.PopRange();
signatureBuilder.PopFromStack();
function->mShaderSignature = signatureBuilder.mBuilder.ToString();
// Write out all of statements of the function
ScopedShaderCodeBuilder functionBodyBuilder(context);
ScopedCodeRangeMapping functionBodyRange(context, &function->mBodyRange, node->Location, CodeRangeDebugString("Function %s Body", function->mZilchName.c_str()));
WriteFunctionStatements(node, context);
function->mShaderBodyCode = functionBodyBuilder.mBuilder.ToString();
if(function->ContainsAttribute(nameSettings.mMainAttribute))
{
// Only allow 1 main function per class
if(currentType->GetHasMain())
{
String msg = String::Format("Only 1 function in a class can have a function with attribute '[%s]'", nameSettings.mMainAttribute.c_str());
SendTranslationError(node->Location, msg);
}
WriteMainForClass(node, context->mCurrentType, function, context);
}
}
void ZilchShaderTranslator::WalkFunctionCallNode(Zilch::FunctionCallNode*& node, ZilchShaderTranslatorContext* context)
{
// Make sure that this function call isn't in a fragment type that is not allowed (such as Discard in a vertex shader)
CheckForAllowedFragmentIntrinsicTypes(node->LeftOperand, context);
// See if there's a library translation for this function call.
// Note: function call nodes are the "top-most" portion of a function call in the tree.
// Meaning this node contains the arguments and then the left operand will be (if it exists)
// the member or static type access. If we only need to replace a function's name (such as Math.Dot -> dot)
// then the translation should be taking place in WalkMemberAccess. This replacement is needed when the function
// and the arguments change, for instance changing Shader.Discard() -> discard and changing sampler.Sample(vec2) -> Sample(sampler, vec2).
if(mLibraryTranslator.ResolveFunctionCall(this, node, context) == true)
return;
Zilch::MemberAccessNode* memberAccessNode = Zilch::Type::DynamicCast<Zilch::MemberAccessNode*>(node->LeftOperand);
// Translate non-member access functions and static member functions as normal
if(memberAccessNode == nullptr || memberAccessNode->IsStatic == true)
{
context->Walker->Walk(this, node->LeftOperand, context);
WriteFunctionCall(node->Arguments, nullptr, nullptr, context);
return;
}
// Otherwise we know this is a function call off a member access node.
// We must change the member function call to a global function call, so we have to grab the "self" variable.
ScopedShaderCodeBuilder selfBuilder(context);
context->Walker->Walk(this, memberAccessNode->LeftOperand, context);
String selfParam = selfBuilder.ToString();
// Remove the scoped builder from the stack (so we can use the regular builder below)
selfBuilder.PopFromStack();
// To start with, try to resolve the member access if needed
// (mostly to produces errors on native type functions that haven't been translated)
// If we fail to resolve the member access then we need to write out the function call's name
if(mLibraryTranslator.ResolveMemberAccess(this, memberAccessNode, context) == false)
{
ShaderCodeBuilder& builder = context->GetBuilder();
// We need to mangle the function call's name based upon the class' type
Zilch::Type* thisType = memberAccessNode->AccessedFunction->This->ResultType;
String fnCallName = MangleName(memberAccessNode->Name, thisType, memberAccessNode);
builder << fnCallName;
}
// Write out all of the arguments (with the self param we pulled out as the last argument)
WriteFunctionCall(node->Arguments, nullptr, &selfParam, context);
}
void ZilchShaderTranslator::WalkLocalVariable(Zilch::LocalVariableNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
// Resolve the variable's type to the actual translation type
Zilch::Type* resultType = node->CreatedVariable->ResultType;
ShaderType* variableShaderType = FindShaderType(resultType, node);
// Geometry outputs are special and can't always be declared as a new variable.
// Leave this up to the current language to define how this is translated.
if(variableShaderType->GetTypeData()->mType == ShaderVarType::GeometryOutput)
{
WriteGeometryOutputVariableDeclaration(node, variableShaderType, context);
return;
}
// Write out "Type name"
builder.Write(variableShaderType->mShaderName);
builder.WriteSpace();
String variableName = ApplyVariableReplacement(node->Name.Token);
builder.Write(variableName);
// If the variable had an initial value then write it out
if(node->InitialValue != nullptr)
{
// Build up a string that is the default value
ScopedShaderCodeBuilder defaultValueBuilder(context);
context->Walker->Walk(this, node->InitialValue, context);
defaultValueBuilder.PopFromStack();
String defaultValue = defaultValueBuilder.ToString();
// If we didn't get an actual default value (such as an array's default constructor) then don't write out a default value
if(!defaultValue.Empty())
{
builder.Write(" = ");
builder.Write(defaultValue);
}
}
}
void ZilchShaderTranslator::WalkStaticTypeOrCreationCallNode(Zilch::StaticTypeNode*& node, ZilchShaderTranslatorContext* context)
{
// This node is for new Type() or local Type() or even just Type().
// This walker needs to write out the final type of the thing we're creating. Sometimes this will be replacing the type
// (if it was from another library) and other times it will be "constructing" the class so we replace that with a "constructor" function call.
ShaderCodeBuilder& builder = context->GetBuilder();
Zilch::Type* zilchCreatedType = node->ReferencedType;
// If the created type is in the fragment library then we need to mangle it's name (but not replace types)
if(IsInOwningLibrary(zilchCreatedType))
{
// Mark the type we're constructing as a type we're dependent on
// (so we can make sure to include it when composing the final file)
ShaderType* createdShaderType = FindShaderType(zilchCreatedType, node);
context->mCurrentType->AddDependency(createdShaderType);
// Since this type is from their library, call the "constructor" function instead of the type's constructor
builder << MangleName(mSettings->mNameSettings.mConstructorName, zilchCreatedType, node);
}
else
{
// Otherwise this type is not in their library so just resolve it's name
ShaderType* createdShaderType = FindShaderType(zilchCreatedType, node);
builder.Write(createdShaderType->mShaderName);
}
}
void ZilchShaderTranslator::WalkExpressionInitializerNode(Zilch::ExpressionInitializerNode*& node, ZilchShaderTranslatorContext* context)
{
// If we have a registered initializer node resolver then don't perform the regular walker
if(mLibraryTranslator.ResolveInitializerNode(this, node->ResultType, node, context))
return;
// Otherwise just walk the left operand and all the initializer statements
// @JoshD: This probably won't work correctly right now. Test initializer lists of non-array types later!
//context->Walker->Walk(this, node->LeftOperand, context);
//context->Walker->Walk(this, node->InitializerStatements, context);
SendTranslationError(node->Location, "Initializer expressions currently are not supported on non-array types.");
}
void ZilchShaderTranslator::WalkUnaryOperationNode(Zilch::UnaryOperatorNode*& node, ZilchShaderTranslatorContext* context)
{
// Later update this to allow the replacement of certain operators per type (such as ~ on Integers)
// @JoshD-Update
// Want to pass types by Zilch ref but have to not output this character in translation
if (node->Operator->TokenId == Zilch::Grammar::AddressOf)
{
context->Walker->Walk(this, node->Operand, context);
return;
}
// Write out the token and then the operand
ShaderCodeBuilder& builder = context->GetBuilder();
builder.Write(node->Operator->Token);
context->Walker->Walk(this, node->Operand, context);
}
void ZilchShaderTranslator::WalkBinaryOperationNode(Zilch::BinaryOperatorNode*& node, ZilchShaderTranslatorContext* context)
{
bool needsGrouping = false;
// If the parent node is a unary op then we need to add parenthesis
Zilch::UnaryOperatorNode* parentUnaryOp = Zilch::Type::DynamicCast<Zilch::UnaryOperatorNode*>(node->Parent);
if(parentUnaryOp != nullptr)
needsGrouping = true;
Zilch::MemberAccessNode* parentMemberAccess = Zilch::Type::DynamicCast<Zilch::MemberAccessNode*>(node->Parent);
if(parentMemberAccess != nullptr)
needsGrouping = true;
// Otherwise, if the parent is a binary op then we need to check if we need parenthesis
Zilch::BinaryOperatorNode* parentBinaryOp = Zilch::Type::DynamicCast<Zilch::BinaryOperatorNode*>(node->Parent);
if(parentBinaryOp != nullptr)
{
OperatorInfo defaultPrecedence(999, OperatorAssociativityType::LeftToRight);
OperatorInfo parentPrecedence = mTokenPrecedence.FindValue(parentBinaryOp->Operator->TokenId, defaultPrecedence);
OperatorInfo nodePrecedence = mTokenPrecedence.FindValue(node->Operator->TokenId, defaultPrecedence);
// If our parent has a lower precedence than us then that means this parent would attach to whatever is closest to it.
// Instead parent needs to attach to the result of this node so we need to add parenthesis.
if(parentPrecedence.mPrecedence < nodePrecedence.mPrecedence)
needsGrouping = true;
// If the parent has the same precedence then we might still need parenthesis. This is based upon the associativity of the operator.
// If an operator is left-to-right then the tree will naturally be left-heavy. If this node is on the right of our parent then that
// means grouping should be applied to us. One example of this is "a / (b / c) will produce "b / c" on the right of the parent
// '/' instead of the left hence we need parenthesis. The same holds true for right-to-left operators.
else if(parentPrecedence.mPrecedence == nodePrecedence.mPrecedence)
{
if(parentPrecedence.mAssociativityType == OperatorAssociativityType::LeftToRight && parentBinaryOp->RightOperand == node)
needsGrouping = true;
else if(parentPrecedence.mAssociativityType == OperatorAssociativityType::RightToLeft && parentBinaryOp->LeftOperand == node)
needsGrouping = true;
}
}
ShaderCodeBuilder& builder = context->GetBuilder();
if(needsGrouping)
builder << "(";
// See if there's a replacement for the binary op (such as < in glsl 1.2).
// This may turn into another op, or even a function call, but either way we still
// want to apply grouping based upon the parent operator's precedence.
if(mLibraryTranslator.ResolveBinaryOp(this, node, context) == false)
{
context->Walker->Walk(this, node->LeftOperand, context);
// Write out the operator (with a space in-between)
builder << builder.EmitSpace() << node->Operator->Token << builder.EmitSpace();
context->Walker->Walk(this, node->RightOperand, context);
}
if(needsGrouping)
builder << ")";
}
void ZilchShaderTranslator::WalkCastNode(Zilch::TypeCastNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
// Do C++ style casting float(0), ignore implicit casting for now
ShaderType* castType = FindShaderType(node->ResultType, node);
builder.Write(castType->mShaderName);
builder.Write("(");
context->Walker->Walk(this, node->Operand, context);
builder.Write(")");
}
void ZilchShaderTranslator::WalkValueNode(Zilch::ValueNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
// Write out the value type (replace it if needed)
String value = ApplyValueReplacement(node->Value.Token);
builder.Write(value);
// If the value type is a float then append a f to the end (0.0->0.0f)
Zilch::Core& core = Zilch::Core::GetInstance();
if(node->ResultType == core.RealType)
builder.Write("f");
}
void ZilchShaderTranslator::WalkLocalRef(Zilch::LocalVariableReferenceNode*& node, ZilchShaderTranslatorContext* context)
{
// Build a scoped range to capture the range of this local ref (mostly for debugging ranges...)
ScopedCodeRangeMapping subRange(context, node->Location, CodeRangeDebugString("LocalRef"));
// Replace the local variable if needed (such as turn "this" into "self")
String localVar = ApplyVariableReplacement(node->Value.Token);
context->GetBuilder().Write(localVar);
}
void ZilchShaderTranslator::WalkGetterSetter(Zilch::MemberAccessNode*& node, Zilch::GetterSetter* getSet, ZilchShaderTranslatorContext* context)
{
// Iousage can be a mixture or r and l
if(node->IoUsage == Zilch::IoMode::ReadRValue)
{
Zilch::Function* zilchGetter = node->AccessedGetterSetter->Get;
ShaderFunction* shaderFunction = nullptr;
// Find the shader function from the member's type
ShaderType* accessedShaderType = FindShaderType(node->LeftOperand->ResultType, node, false);
if(accessedShaderType != nullptr)
shaderFunction = accessedShaderType->FindFunction(zilchGetter);
// If we couldn't find the function then try finding an extension function
if(shaderFunction == nullptr)
shaderFunction = mCurrentLibrary->FindExtension(zilchGetter);
// If we managed to get the shader function then translate it
if(shaderFunction != nullptr)
{
// Mark the function we referenced as a dependency
context->mCurrentType->AddDependency(shaderFunction->mOwner);
context->GetBuilder() << shaderFunction->mShaderName << "(";
// If the function is not static then pass the left operand (the self type)
if(!shaderFunction->ContainsAttribute(mSettings->mNameSettings.mStaticAttribute))
context->Walker->Walk(this, node->LeftOperand, context);
context->GetBuilder() << ")";
return;
}
String accessedTypeName = node->LeftOperand->ResultType->ToString();
String msg = String::Format("Getter '%s.%s' can't be translated", accessedTypeName.c_str(), zilchGetter->Name.c_str());
SendTranslationError(node->Location, msg);
}
}
void ZilchShaderTranslator::WalkMemberAccessNode(Zilch::MemberAccessNode*& node, ZilchShaderTranslatorContext* context)
{
// See if there's a library translation for this member access. Note that at this point we are below a
// function call if this was one. We can only change the member access itself, that is we can change
// "obj.Name" but not any function calls. If we wanted to do this then we should've added a resolver for a function call node.
if(mLibraryTranslator.ResolveMemberAccess(this, node, context))
return;
// If this member access node is actually a getter/setter then walk it (generate function calls) instead of the member access
if(node->AccessedGetterSetter != nullptr)
{
WalkGetterSetter(node, node->AccessedGetterSetter, context);
return;
}
ShaderCodeBuilder& builder = context->GetBuilder();
// If this is a static member access or a forced static type then just ignore the object.Member
// and transform this into the mangled global name, something like Object_Member.
String resultType = node->ResultType->ToString();
bool isForcedStatic = false;
// The "result type" could be a delegate which we can't get a type to (e.g. static extension function).
// In this case it's safe to translate without validating if it's forced static
ShaderType* resultShaderType = FindShaderType(node->ResultType, node, false);
if(resultShaderType != nullptr)
isForcedStatic = resultShaderType->ContainsAttribute(NameSettings::mForcedStaticAttribute);
if(node->IsStatic || isForcedStatic)
{
String mangledMemberName = MangleName(node->Name, node->LeftOperand->ResultType, node);
// We don't actually know if this member access node is on a field of a type
// we already know about. If it is then we should use whatever the pre-established
// shader name is for the field (especially when it comes to built-in samplers),
// otherwise just use the regular mangled name.
ShaderType* memberShaderType = FindShaderType(node->LeftOperand->ResultType, node, false);
if(memberShaderType != nullptr)
{
ShaderField* field = memberShaderType->mFieldMap.FindValue(node->Name, nullptr);
if(node->AccessedField != nullptr && field != nullptr)
mangledMemberName = field->mShaderName;
}
builder << mangledMemberName;
// We want to make a dependency on the type we are accessing, but this could be a function call or a member access.
// For now just make a dependency on both the node's result and the left op's result. If one is invalid it will likely be a delegate type.
ShaderType* resultShaderType = FindShaderType(node->ResultType, node, false);
if(resultShaderType != nullptr)
context->mCurrentType->AddDependency(resultShaderType);
ShaderType* leftOpResultShaderType = FindShaderType(node->LeftOperand->ResultType, node, false);
if(leftOpResultShaderType != nullptr)
context->mCurrentType->AddDependency(leftOpResultShaderType);
}
else
{
// Otherwise this is a regular member access, so first walk the left operand
context->Walker->Walk(this, node->LeftOperand, context);
// Grab the string representing the operator
String token = Zilch::Grammar::GetKeywordOrSymbol(node->Operator);
// To prevent future kinds of member access tokens from being implemented (such as ~>)
// and breaking, only allow the regular member access '.' for now.
if(node->Operator != Zilch::Grammar::Access)
{
String msg = String::Format("Operator '%s' is invalid for use in translation", token.c_str());
SendTranslationError(node->Location, msg);
}
// Then just append the access of the variable (no mangling needed here)
builder << token << node->Name;
}
}
void ZilchShaderTranslator::WalkMultiExpressionNode(Zilch::MultiExpressionNode*& node, ZilchShaderTranslatorContext* context)
{
String msg = "This expression is too complex to be translated. Please simplify the expression. "
"The most common examples are compound operators such as 'array[i] += value' which should change to 'array[i] = array[i] + value'.";
SendTranslationError(node->Location, msg);
}
void ZilchShaderTranslator::WalkIfRootNode(Zilch::IfRootNode*& node, ZilchShaderTranslatorContext* context)
{
// Walk all of the parts of the if statement
Zilch::NodeList<Zilch::IfNode>::range range = node->IfParts.All();
for(; !range.Empty(); range.PopFront())
{
Zilch::IfNode* node = range.Front();
context->Walker->Walk(this, node, context);
}
}
void ZilchShaderTranslator::WalkIfNode(Zilch::IfNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
// Write out the correct part and conditions for each kind of if node (such as "if" vs. "if else" vs. "else")
if(node->IsFirstPart)
{
builder.Write("if(");
context->Walker->Walk(this, node->Condition, context);
builder.WriteLine(")");
}
else if(node->Condition != nullptr)
{
builder.Write("else if(");
context->Walker->Walk(this, node->Condition, context);
builder.WriteLine(")");
}
else
{
builder.WriteLine("else");
}
// Write all all of the statements in the node
builder.BeginScope();
WriteStatements(node->Statements, context);
builder.EndScope();
}
void ZilchShaderTranslator::WalkBreakNode(Zilch::BreakNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
builder.Write("break");
}
void ZilchShaderTranslator::WalkContinueNode(Zilch::ContinueNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
builder.Write("continue");
}
void ZilchShaderTranslator::WalkReturnNode(Zilch::ReturnNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
builder.Write("return");
// If there's a return value then write it out
if(node->ReturnValue != nullptr)
{
builder.WriteSpace();
context->Walker->Walk(this, node->ReturnValue, context);
}
}
void ZilchShaderTranslator::WalkWhileNode(Zilch::WhileNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
builder.Write("while(");
context->Walker->Walk(this, node->Condition, context);
builder.WriteLine(")");
builder.BeginScope();
WriteStatements(node->Statements, context);
builder.EndScope();
}
void ZilchShaderTranslator::WalkDoWhileNode(Zilch::DoWhileNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
builder.WriteLine("do");
builder.BeginScope();
WriteStatements(node->Statements, context);
builder.EndScope();
builder.WriteIndentation();
builder.Write("while(");
context->Walker->Walk(this, node->Condition, context);
builder.Write(")");
builder.WriteLine(";");
}
void ZilchShaderTranslator::WalkForNode(Zilch::ForNode*& node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
builder.Write("for(");
// The first portion of a for loop can either be creating a new variable or just setting a variable to a value
if(node->Initialization)
context->Walker->Walk(this, node->Initialization, context);
else if(node->ValueVariable)
{
// The generic handler would treat the variable as a statement which we don't want,
// set the state on the context to temporarily ignore the generic handling
bool oldState = context->mPerformAutoFormatting;
context->mPerformAutoFormatting = false;
context->Walker->Walk(this, node->ValueVariable, context);
context->mPerformAutoFormatting = oldState;
}
builder.Write("; ");
// Write the condition
if(node->Condition != nullptr)
context->Walker->Walk(this, node->Condition, context);
builder.Write("; ");
// Write the iteration
if(node->Iterator != nullptr)
context->Walker->Walk(this, node->Iterator, context);
builder.WriteLine(")");
builder.BeginScope();
WriteStatements(node->Statements, context);
builder.EndScope();
}
void ZilchShaderTranslator::WalkForEachNode(Zilch::ForEachNode*& node, ZilchShaderTranslatorContext* context)
{
// Don't allow for each loops
SendTranslationError(node->Location, "foreach statements are not allowed in shader translation");
}
void ZilchShaderTranslator::WalkUnknownNode(Zilch::SyntaxNode*& node, ZilchShaderTranslatorContext* context)
{
SendTranslationError(node->Location, String::Format("Node type '%s' is not allowed in translation", node->ToString().c_str()));
}
void ZilchShaderTranslator::WriteStatements(Zilch::NodeList<Zilch::StatementNode>& statements, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
for(size_t i = 0; i < statements.Size(); ++i)
{
Zilch::StatementNode* statement = statements[i];
// For each statement keep track of the line number mappings
ScopedCodeRangeMapping statementRange(context, statement->Location, CodeRangeDebugString("Statement"));
context->Walker->Walk(this, statement, context);
}
}
void ZilchShaderTranslator::WriteFunctionStatements(Zilch::GenericFunctionNode* node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
builder.BeginScope();
WriteStatements(node->Statements, context);
builder.EndScope();
}
void ZilchShaderTranslator::WriteFunctionSignature(Zilch::GenericFunctionNode* node, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
//add all of the parameters
for(uint i = 0; i < node->Parameters.Size(); ++i)
{
Zilch::ParameterNode* parameter = node->Parameters[i];
Zilch::Type* resultType = parameter->CreatedVariable->ResultType;
ShaderType* resultShaderType = FindShaderType(resultType, node);
// Check if this is a reference type, if so we need to properly translate the in/inout/out keywords
bool isRefType = Zilch::Type::IsHandleType(resultType);
// If this is a reference type then add the appropriate qualifier (from the shader type if it has one)
if(isRefType)
{
if(!resultShaderType->mReferenceTypeQualifier.Empty())
builder << resultShaderType->mReferenceTypeQualifier << " ";
else
builder << mSettings->mNameSettings.mReferenceKeyword << " ";
}
// Otherwise, check and see if we're trying to pass to a function a non-copyable type. If so report an error
else if(resultShaderType->IsNonCopyable())
{
String msg = String::Format("Type '%s' is non-copyable. It can only be passed to a function using the 'ref' keyword.", resultShaderType->mZilchName.c_str());
SendTranslationError(parameter->Location, msg);
}
builder.Write(resultShaderType->mShaderName);
builder.WriteSpace();
String parameterName = ApplyVariableReplacement(parameter->Name.Token);
builder.Write(parameterName);
if(i != node->Parameters.Size() - 1)
builder.Write(", ");
}
}
void ZilchShaderTranslator::WriteFunctionCall(StringParam functionName, Zilch::NodeList<Zilch::ExpressionNode>& arguments, String* firstParam, String* lastParam, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
builder << functionName;
WriteFunctionCall(arguments, firstParam, lastParam, context);
}
void ZilchShaderTranslator::WriteFunctionCall(Zilch::NodeList<Zilch::ExpressionNode>& arguments, String* firstParam, String* lastParam, ZilchShaderTranslatorContext* context)
{
ShaderCodeBuilder& builder = context->GetBuilder();
builder << "(";
if(firstParam != nullptr && !firstParam->Empty())
{
builder << *firstParam;
if(arguments.Size() != 0)
builder << ", ";
}
for(size_t i = 0; i < arguments.Size(); ++i)
{
context->Walker->Walk(this, arguments[i], context);
if(i != arguments.Size() - 1)
builder << ", ";
}
if(lastParam != nullptr && !lastParam->Empty())
{
if(arguments.Size() != 0)
builder << ", ";
builder << *lastParam;
}
builder << ")";
}
void ZilchShaderTranslator::AddSelfParameter(Zilch::Type* zilchSelfType, ZilchShaderTranslatorContext* context)
{
AddSelfParameter(zilchSelfType, context->mCurrentType->mShaderName, context);
}
void ZilchShaderTranslator::AddSelfParameter(Zilch::Type* zilchSelfType, StringParam selfType, ZilchShaderTranslatorContext* context)
{
ShaderType* shaderSelfType = FindShaderType(zilchSelfType, nullptr);
context->GetBuilder() << shaderSelfType->mReferenceTypeQualifier << " " << selfType << " " << mSettings->mNameSettings.mThisKeyword;
}
String ZilchShaderTranslator::ApplyValueReplacement(StringParam value)
{
return value;
}
String ZilchShaderTranslator::ApplyVariableReplacement(StringParam varName)
{
// Currently only replace the 'this' keyword with 'self'
if(varName == Zilch::ThisKeyword)
return mSettings->mNameSettings.mThisKeyword;
// Otherwise, pre-pend the variable with a unique key to prevent clashing with
// built-in function names (so we get '_dot' instead of the math library function 'dot')
return BuildString("_", varName);
}
String ZilchShaderTranslator::MangleName(StringParam name, Zilch::Type* classType, Zilch::SyntaxNode* locationNode)
{
ShaderType* shaderType = FindShaderType(classType, locationNode);
// If we have a shader type then get the correct mangled name from it (it stores the correct shader type name)
if(shaderType != nullptr)
return MangleName(name, shaderType);
// If we didn't find the type then fix the class' name if necessary
// (I don't think this should ever happen anymore as this is only really templates)
String mangledClassName = FixClassName(classType);
return GenerateMangledName(mangledClassName, name);
}
String ZilchShaderTranslator::MangleName(StringParam name, ShaderType* type)
{
return GenerateMangledName(type->mShaderName, name);
}
String ZilchShaderTranslator::FixClassName(Zilch::Type* type)
{
// Get the bound type (converts indirection types to bound types)
StringRange className = type->ToString();
Zilch::BoundType* boundType = Zilch::BoundType::GetBoundType(type);
if(boundType != nullptr)
className = boundType->ToString();
// If the type is not template then just return the normal class name
if(IsTemplateType(boundType) == false)
return className;
// Otherwise strip out invalid symbols.
// Also pre-pend it with "template_" both for readability and to prevent name conflicts.
StringBuilder builder;
builder.Append("template_");
while(!className.Empty())
{
Rune r = className.Front();
className.PopFront();
// Convert some symbols into underscores (such as the template brackets)
if(r == '[' || r == ']' || r == ',')
builder.Append("_");
// And just strip out some other symbols (otherwise it gets really cumbersome to read)
else if(r == ' ')
continue;
else
builder.Append(r);
}
return builder.ToString();
}
String ZilchShaderTranslator::GenerateDefaultConstructorString(Zilch::Type* type, ZilchShaderTranslatorContext* context)
{
// If this is not a user defined type then call the default constructor for this type.
// This could be a more elaborate string depending on the type, such as Real4(1, 1, 1, 1).
if(!IsInOwningLibrary(type))
{
Zilch::BoundType* boundType = Zilch::BoundType::GetBoundType(type);
const Zilch::FunctionArray* constructors = boundType->GetOverloadedInheritedConstructors();
Zilch::Function* defaultConstructor = Zilch::BoundType::GetDefaultConstructor(constructors);
if(constructors != nullptr && constructors->Empty() == false)
{
// If we managed to find the default constructor then resolve the default constructor's translation
Zilch::Function* defaultConstructor = Zilch::BoundType::GetDefaultConstructor(constructors);
ScopedShaderCodeBuilder initialValueBuilder(context);
mLibraryTranslator.ResolveDefaultConstructor(this, boundType, defaultConstructor, context);
return initialValueBuilder.ToString();
}
}
// Otherwise, this is a user defined type so just call the constructor function.
return BuildString(MangleName(mSettings->mNameSettings.mConstructorName, type, nullptr), "()");
}
bool ZilchShaderTranslator::IsTemplateType(Zilch::BoundType* type)
{
// Currently there's no way (from a Type*) to know if a type is a template.
// So instead I'm just seeing (for now) if the type has the '[' character.
String className = type->ToString();
return className.Contains("[");
}
void ZilchShaderTranslator::RegisterLibraryBoundTemplateTypes()
{
// Iterate over all bound types in this library and if any are
// a template then try to register them with the library translator
Zilch::BoundTypeMap::range boundTypes = mCurrentLibrary->mZilchLibrary->BoundTypes.All();
for(; !boundTypes.Empty(); boundTypes.PopFront())
{
Zilch::BoundType* boundType = boundTypes.Front().second;
if(!boundType->TemplateBaseName.Empty())
{
String resultTypeName;
(mLibraryTranslator.mTemplateTypeResolver)(this, boundType, nullptr, resultTypeName);
}
}
}
void ZilchShaderTranslator::CheckForAllowedFragmentIntrinsicTypes(Zilch::ExpressionNode* node, ZilchShaderTranslatorContext* context)
{
if(node == nullptr)
return;
Zilch::MemberAccessNode* memberAccessNode = Zilch::Type::DynamicCast<Zilch::MemberAccessNode*>(node);
if(memberAccessNode == nullptr)
return;
bool isVertexAllowed = false;
bool isGeometryAllowed = false;
bool isPixelAllowed = false;
// Keep track of the access type string for error messages
String accessType;
if(memberAccessNode != nullptr)
{
Zilch::Function* function = memberAccessNode->AccessedFunction;
Zilch::Array<Zilch::Attribute>* attributes = nullptr;
// Get the attribute array from whatever the accessed type was
if(function != nullptr)
{
attributes = &function->Attributes;
accessType = "Function";
}
Zilch::Field* field = memberAccessNode->AccessedField;
if(field != nullptr)
{
attributes = &field->Attributes;
accessType = "Field";
}
Zilch::Property* property = memberAccessNode->AccessedProperty;
if(property != nullptr)
{
attributes = &property->Attributes;
accessType = "Property";
}
Zilch::GetterSetter* getterSetter = memberAccessNode->AccessedGetterSetter;
if(getterSetter != nullptr)
{
attributes = &getterSetter->Attributes;
accessType = "GetSet";
}
// Check for all of the allowed attributes
isVertexAllowed = ContainsAttribute(*attributes, NameSettings::mVertexIntrinsicAttributeName);
isGeometryAllowed = ContainsAttribute(*attributes, NameSettings::mGeometryIntrinsicAttributeName);
isPixelAllowed = ContainsAttribute(*attributes, NameSettings::mPixelIntrinsicAttributeName);
}
// If this didn't contain any of the attributes to limit fragment types
// then there are no restrictions and there is no error
if(isVertexAllowed == false && isGeometryAllowed == false && isPixelAllowed == false)
return;
// This is an error if the current fragment type isn't allowed or this isn't in a fragment type
FragmentType::Enum fragmentType = context->mCurrentType->mFragmentType;
bool isError = (fragmentType == FragmentType::None);
isError |= (fragmentType == FragmentType::Vertex && isVertexAllowed == false);
isError |= (fragmentType == FragmentType::Geometry && isGeometryAllowed == false);
isError |= (fragmentType == FragmentType::Pixel && isPixelAllowed == false);
// Report the error
if(isError)
{
// Build up a string of the allowed fragment types
Array<String> allowedFragmentTypes;
if(isVertexAllowed)
allowedFragmentTypes.PushBack("Vertex");
if(isGeometryAllowed)
allowedFragmentTypes.PushBack("Geometry");
if(isPixelAllowed)
allowedFragmentTypes.PushBack("Pixel");
String allowedTypesStr = JoinStrings(allowedFragmentTypes, " or ");
String msg = String::Format("%s '%s' is only allowed in %s fragments.", accessType.c_str(), memberAccessNode->Name.c_str(), allowedTypesStr.c_str());
SendTranslationError(node->Location, msg);
}
}
bool ZilchShaderTranslator::ContainsAttribute(Array<Zilch::Attribute>& attributes, StringParam attributeToSearch)
{
for(uint i = 0; i < attributes.Size(); ++i)
{
Zilch::Attribute& attribute = attributes[i];
if(attribute.Name == attributeToSearch)
return true;
}
return false;
}
bool ZilchShaderTranslator::IsInOwningLibrary(Zilch::Library* library)
{
// Check and see if this library is the same as the source library (that we are passed in from the compositor)
if(mLibraryTranslator.IsUserLibrary(library))
return true;
return false;
}
bool ZilchShaderTranslator::IsInOwningLibrary(Zilch::Type* type)
{
Zilch::Library* owningLibrary = type->GetOwningLibrary();
return IsInOwningLibrary(owningLibrary);
}
ShaderType* ZilchShaderTranslator::FindShaderType(Zilch::Type* type, Zilch::SyntaxNode* syntaxNode, bool reportErrors)
{
Zilch::BoundType* boundType = Zilch::BoundType::GetBoundType(type);
// If we found the bound type successfully then try to find the shader type
if(boundType != nullptr)
{
// If this is a template type then there is a chance we haven't yet created this specific
// template's translation (such as an array of real3 vs real). There is also a chance that
// a different library owns the bound type that is needed here and that the template is an
// intrinsic type (FixedArray). In this case we won't have the pre-existing shader type
// (because there isn't one) but we still need to translate functions. This should eventually
// be removed and these shader types should either be created somehow or the translation
// resolution functions need to stick around in all dependent libraries.
if(IsTemplateType(boundType))
{
String resultTypeName;
(mLibraryTranslator.mTemplateTypeResolver)(this, type, syntaxNode, resultTypeName);
}
// Try and find a shader type to return from the corresponding bound type
ShaderType* resultShaderType = mCurrentLibrary->FindType(boundType);
if(resultShaderType != nullptr)
return resultShaderType;
}
ShaderType* resultType = nullptr;
// Otherwise we couldn't produce a shader type so return a fake type (to prevent crashes) and report an error
if(reportErrors)
resultType = FindAndReportUnknownType(type, syntaxNode);
return resultType;
}
ShaderType* ZilchShaderTranslator::FindAndReportUnknownType(Zilch::Type* type, Zilch::SyntaxNode* syntaxNode)
{
ErrorIf(syntaxNode == nullptr, "Shader error at unknown location.");
String msg = String::Format("Type '%s' is not a valid type for use in a shader", type->ToString().c_str());
if(syntaxNode != nullptr)
SendTranslationError(syntaxNode->Location, msg);
return mCurrentLibrary->FindType("[Unknown]");
}
bool ZilchShaderTranslator::IsBuiltInField(ShaderField* field)
{
ShaderType* fieldShaderType = field->GetShaderType();
ShaderFieldKey fieldKey(field);
// A field is only considered to come from a built-in if it matches a declared built-in and
// it is either declared as an input or a forced static. A forced static (such as a sampler)
// auto becomes a built-in because they must be an input, otherwise they make no sense right now.
// Otherwise we could have an variable like 'Time' that could either be [Static] or contain no
// attribute in which case it is not considered as coming from a built-in.
bool isBuiltIn = mSettings->mShaderDefinitionSettings.mBuiltIns.ContainsKey(fieldKey);
bool isInput = field->ContainsAttribute(mSettings->mNameSettings.mInputAttributeName);
bool isForcedStatic = fieldShaderType->ContainsAttribute(mSettings->mNameSettings.mForcedStaticAttribute);
if(isBuiltIn && (isInput || isForcedStatic))
return true;
return false;
}
void ZilchShaderTranslator::SendTranslationError(Zilch::CodeLocation& codeLocation, StringParam message)
{
SendTranslationError(codeLocation, message, message);
}
void ZilchShaderTranslator::SendTranslationError(Zilch::CodeLocation& codeLocation, StringParam shortMsg, StringParam fullMsg)
{
mErrorTriggered = true;
if(mErrors != nullptr)
mErrors->SendTranslationError(codeLocation, shortMsg, fullMsg);
}
}//namespace Zero
| 46.121155 | 228 | 0.724927 | [
"geometry",
"object",
"transform"
] |
d2dbe82d893c76adac063cf72ecb07aea9279c34 | 40,721 | cpp | C++ | parrlibgl/ui/imui.cpp | AlessandroParrotta/parrlibgl | 2d0a27a16bb17be8d4554bfcdc4f5e2a4946db96 | [
"MIT"
] | null | null | null | parrlibgl/ui/imui.cpp | AlessandroParrotta/parrlibgl | 2d0a27a16bb17be8d4554bfcdc4f5e2a4946db96 | [
"MIT"
] | null | null | null | parrlibgl/ui/imui.cpp | AlessandroParrotta/parrlibgl | 2d0a27a16bb17be8d4554bfcdc4f5e2a4946db96 | [
"MIT"
] | null | null | null | #include "imui.h"
#include "../sprite.h"
namespace prb {
namespace imui {
const std::string glbid = "imui";
statec state;
statec oldstate = state;
//prefss prefs;
unsigned int gid = 0;
unsigned int activegid = 0;
template<typename T>
struct stack {
std::vector<T> st;
void push(T const& t) { st.push_back(t); }
void pop() { st.pop_back(); }
T popr() { T cp = st.back(); st.pop_back(); return cp; }
T& back() { return st.back(); }
T& top() { return back(); }
T back() const { return st.back(); }
T top() const { return back(); }
int size() const { return st.size(); }
};
stack<statec> ststack;
//std::string miqid = ""; //mouse in quad identifier
mat3 space = 1.f;
void setSpace(mat3 const& sp) { space = sp; }
mat3 getSpace() { return space; }
//the line of thought regarding containers is that the ui elements inside the same container
//should never overlap (unless those are drop down menus), however containers can overlap
//so i only check for containers
//std::vector<aabb2> containers; //right-click quads for mouseInQuad
//int currentContainer = 0;
//void pushContainer(aabb2 const& bb) {
// containers.push_back(bb);
// currentContainer++;
//}
std::unordered_map<std::string, aabb2> containers;
std::unordered_map<std::string, int> posContainers;
std::unordered_map<std::string, bool> pingContainers;
stack<std::string> curContainer;
int curposcontainer = 0;
void beginContainer(std::string const& id, aabb2 const& bb) {
pingContainers[id] = true;
containers[id] = bb;
curContainer.push(id);
curposcontainer++;
posContainers[id] = curposcontainer;
}
void endContainer() {
curContainer.pop();
}
//dropmenu vals
bool dropmenu = false;
std::string dropid = "";
aabb2 dropbb = 0.f;
aabb2 dropbodybb = 0.f;
bool dropjustopened = false; //to delay check 1 frame
std::vector<std::wstring> dropopts; //how many options does the current opened dropmenu have
int dropsel = -1;
mat3 dropspace = 1.f;
mat3 utildropmat = 1.f;
statec dropstate;
//**(fast)dropdown container bodies are always on top of every other ui element
bool dropmenubeganopened = false;
mat3 tospace() { return (util::getTopMatrix() * space).inverted() * util::getAspectOrtho(); }
mat3 fromspace() { return util::getAspectOrtho().inverted() * util::getTopMatrix() * space; }
//projects the mouse from orthoNDC space to imui space
vec2 mouseproj() {
return (util::getTopMatrix() * space).inverted() * util::getAspectOrtho() * input::getMousePos();
}
bool mouseInQuad(aabb2 const& bb) {
return input::mouseInQuad(util::getAspectOrtho().inverted() * util::getTopMatrix() * space * bb);
}
//which container the mouse is in
std::string mouseInContainer() {
int maxpos = 0;
std::string contname = "";
for (auto& c : containers) {
if (posContainers[c.first] > maxpos && mouseInQuad(c.second)) {
maxpos = posContainers[c.first]; contname = c.first;
}
}
return contname;
}
bool manuallayout = false; //when the user sets the pos and size manually even when a layout != NOLAYOUT is active
void setLayout(int la) { state.layout = la; }
int getLayout() { return state.layout; }
void saveState() {
ststack.push(state);
}
void restoreState() {
state = ststack.popr();
}
void setmanuallayout() {
saveState();
state.manualLayoutOverride = true;
state.layout = NOLAYOUT;
}
//sets layout to manual and pushes state to stack
void setmanuallayout(vec2 const& pos, vec2 const& size) {
setmanuallayout();
state.pos = pos; state.size = size;
}
void setPos(vec2 const& pos) { state.pos = pos; state.nextPos = pos; }
void setSize(vec2 const& size) { state.size = size; state.nextSize = size; }
void move(vec2 const& delta) { state.pos += delta; state.nextPos = state.pos; }
void setOffset(vec2 const& offset) { state.offset = offset; }
void updatestatelayout() {
if (state.layout == NOLAYOUT) return;
state.nextSize = state.size;
state.pos = state.nextPos;
switch (state.layout) {
case HORIZONTAL:
state.nextPos = state.pos + state.offset.xo();
break;
case VERTICAL:
state.nextPos = state.pos + state.offset.oy();
break;
case INCREMENTAL:
state.nextPos = state.pos + state.offset;
break;
case CONTAINER:
break;
}
if (state.indropmenu) {
//rescale the current drop menu bb to then save it
if (state.currentDropMenuBB == 0.f) {
state.currentDropMenuBB = aabb2{ -state.size, state.size }/2.f + state.pos;
}
else {
state.currentDropMenuBB.rescale(state.pos - state.size/2.f);
state.currentDropMenuBB.rescale(state.pos + state.size/2.f);
}
}
//savelayout();
}
void layoutSkip() {
updatestatelayout();
}
void useAtlas(std::string const& name) { state.atlas = name; }
void setTxr(std::vector<std::string> const& fonts, int const& fontSize) { glb::txr("imui", fonts, fontSize); }
void setTxr(std::string const& font, int const& fontSize) { setTxr(std::vector<std::string>{ font }, fontSize); }
TextRenderer& getTxr() { return glb::txr(glbid); }
void setTextColor(vec4 color) { getTxr().color(color); }
void setTextOutlineColor(vec4 color) { getTxr().outlineColor(color); }
vec4 getTextColor() { return getTxr().color(); }
vec4 getTextOutlineColor() { return getTxr().outlineColor(); }
Sprite& getSprite() { return glb::sprite(state.atlas); }
void drawsprite(mat3 const& transform) {
if (imui::state.atlas.compare("") == 0) return;
getSprite().draw(space * transform);
}
void drawsprite(std::string const& animation, mat3 const& transform) {
if (imui::state.atlas.compare("") == 0) return;
Sprite& at = getSprite();
Sprite::AnimationPlayer ap = { at, animation };
at.draw(ap, space * transform);
}
void drawsprite(std::string const& state, aabb2 const& bb, mat3 const& transform) {
if (imui::state.atlas.compare("") == 0) return;
getSprite().draw(state, bb, space * transform);
}
void drawspritetiledstate(std::string const& state, vec2 const& size, mat3 const& transform) {
if (imui::state.atlas.compare("") == 0) return;
getSprite().drawTiled(state, size, space * transform);
}
void drawspritetiledstate(std::string const& state, aabb2 const& bb, mat3 const& transform) {
if (imui::state.atlas.compare("") == 0) return;
getSprite().drawTiled(state, bb, space * transform);
}
aabb2 gettiledareascreenspace(std::string const& atlas, vec2 const& size) {
if (state.atlas.compare("") == 0) return { -size, size };
return getSprite().getTiledAreaScreenSpace(atlas, size);
}
void drawstr(std::wstring const& str, std::wstring const& modstr, vec2 const& off, aabb2 const& bb, mat3 const& tr) {
glb::txr(glbid).drawWStringpx(str, modstr, off, space * bb, tr);
}
void drawstr(std::wstring const& str, vec2 const& off, aabb2 const& bb, mat3 const& tr) {
glb::txr(glbid).drawWStringpx(str, off, space * bb, tr);
}
void drawstr(std::wstring const& str, vec2 const& off, mat3 const& tr) {
glb::txr(glbid).drawWStringpx(str, off, tr);
}
TextRenderer::bwstring strbbw(std::wstring const& str, vec2 const& off, aabb2 const& bb, mat3 const& tr){
return glb::txr(glbid).getWStringBoundedpx(str, space * bb, off, L"", tr);
}
TextRenderer::bwstring strbbw(std::wstring const& str, aabb2 const& bb, vec2 const& off, std::wstring const& modstr, mat3 const& tr) {
return glb::txr(glbid).getWStringBoundedpx(str, space * bb, off, modstr, tr);
}
aabb2 strbb(std::wstring const& str, vec2 const& off, aabb2 const& bb, mat3 const& tr) {
return strbbw(str, off, bb, tr).bound;
}
bool button(std::wstring const& text) {
updatestatelayout();
aabb2 bb = aabb2{ -state.size, state.size }/2.f + state.pos;
bool miq = mouseInContainer() == curContainer.top() && mouseInQuad(bb);
//Sprite& at = glb::getSprite(atlas);
//Sprite::AnimationPlayer ap = { at, miq ? (input::getMouse(0) ? "button-click" : "button-hover") : "button-passive" };
//aabb2 ta = (space * at.getTiledAreaScreenSpace(ap, state.size)) + bb.center();
//at.drawTiled(ap, state.size, space * pmat3::translate(state.pos));
std::string state = miq ? input::getMouse(0) ? "button-click" : "button-hover" : "button-passive";
aabb2 ta = gettiledareascreenspace(state, imui::state.size);
drawspritetiledstate(state, bb, 1.f);
//debug::drawQuad(util::getTopMatrixAspectInv() * space * bb);
//glb::getTxr("imui").drawWStringpx(text, 0.f, bb, pmat3::translate(space*pos));
drawstr(text, 0.f, bb, pmat3::translate(space * (ta.center() + imui::state.pos)));
return miq && input::getMouseUp(0);
}
bool button(std::wstring const& text, vec2 const& pos, vec2 const& size) { setmanuallayout(pos, size); bool res = button(text); restoreState(); return res; }
struct gmenu { bool invoked = false; bool open = false; };
std::unordered_map<std::string, gmenu> gmenus;
bool groupMenu(Sprite const& s, mat3 const& tr) { return false; }
bool groupMenu(std::string const& name, mat3 const& tr){ return false; }
//
//----------------------------------TEXTFIELD-----------------------------------------------
//
struct textfieldo {
std::wstring* text; //full text string
std::wstring vistext = L""; //visible text on screen (based on the textfield's bounding box)
int off = 0; //offset from beginning of text
int sel = 0; //current selected character
int selmax = 0; //second selection for multiple character selection (always greater than sel)
int shadowSel = 0; //shadow selection when hovering mouse over characters
int selstartpoint = -1; //control variable for when you hold the mouse to select multiple characters
int selvis = 0; //up to which character is the string visible on screen
bool active = false;
float txtimer = 0.f; //timer for text-like polling when holding control keys
bool txfirst = false;
bool modified = false; //whether this textfield's text has been modified (inserted or removed characters)
float clickTimer = 0.f;
bool enableClickTimer = false;
int clickTimes = 0;
};
std::unordered_map<std::string, textfieldo> txfs;
void apptext(textfieldo const& tf, std::wstring const& str, int off) {
tf.text->insert(off, str);
}
void remtext(textfieldo const& tf, int o1, int o2) {
if (o1 > o2 || o1 < 0 || o1 > tf.text->length() || o2 < 0 || o2 > tf.text->length()) return;
*tf.text = tf.text->erase(o1, o2 - o1);
}
//replace text
void txreptext(textfieldo& tf, int o1, int o2, std::wstring const& str) {
remtext(tf, o1, o2);
apptext(tf, str, o1);
}
std::wstring substr(std::wstring const& text, int o1, int o2) {
return text.substr(outl::clamp(o1, 0, text.length()), outl::clamp(o2 - o1, 0, text.length()));
}
std::wstring substr(textfieldo const& tf, int o1, int o2) {
return tf.text->substr(o1, o2 - o1);
}
bool txcontrol(textfieldo& tx, float const& speed) {
return tx.txtimer == 0.f || tx.txtimer > speed;
}
void movetfoff(textfieldo& tf, int const& delta) {
tf.sel += delta;
tf.sel = outl::clamp(tf.sel, 0, tf.text->length());
}
void movetfoff(textfieldo& tf, int& val, int const& delta) {
val += delta;
val = outl::clamp(val, 0, tf.text->length());
}
void tfsetsel(textfieldo& tf, int sel) { tf.sel = sel; }
void tfsetoff(textfieldo& tf, int selmax) { tf.selmax = selmax; }
void tfdrawcursor(textfieldo& tf, aabb2 const& subb, vec4 const& col) {
util::setColor(col);
vec2 tsz = vec2(subb.sizey() / 16.f, subb.size().y);
vec2 tof = subb[3] - (tsz / 2.f).xo();
util::drawQuad(tof, tsz);
}
void tfdrawcursor(textfieldo& tf, int sel, vec4 const& col, vec2 const& off, aabb2 const& ta, mat3 const& tr) {
aabb2 stbb = strbb(tf.vistext, off, ta, tr);
aabb2 subb = strbb(substr(tf, tf.off, sel), off, ta, tr);
subb.minyr(stbb.miny());
subb.maxyr(stbb.maxy());
tfdrawcursor(tf, subb, col);
}
void tfdrawcursor(textfieldo& tf, int sel, vec4 const& col, aabb2 const& stbb, vec2 const& off, aabb2 const& ta, mat3 const& tr) {
aabb2 subb = strbb(substr(tf, tf.off, sel), off, ta, tr);
subb.minyr(stbb.miny());
subb.maxyr(stbb.maxy());
tfdrawcursor(tf, subb, col);
}
int tfgetsel(textfieldo& tf, vec2 const& v, aabb2 const& stbb, vec2 const& off, aabb2 const& ta, mat3 const& tr) {
aabb2 stbbspace = space.inverted() * stbb; //stbb converted in imui::space
aabb2 mbb = aabb2(ta.fmin(), vec2(v.x, ta.maxy()));
TextRenderer::bwstring shadowbb = strbbw(tf.vistext, mbb, off, L"", tr);
//debug::drawQuad(util::getAspectOrtho().inverted() * util::getTopMatrix() * stbb);
//debug::drawQuad(util::getAspectOrtho().inverted() * util::getTopMatrix() * space * stbbspace, vc4::blue);
//debug::drawQuad(util::getAspectOrtho().inverted() * util::getTopMatrix() * space * mbb, vc4::green);
//debug::drawQuad(util::getAspectOrtho().inverted() * util::getTopMatrix() * space * shadowbb.bound, vc4::white);
//debug::rtlog << "stbb" << stbb << "\n";
//debug::rtlog << "stbbspace" << stbbspace << "\n";
//debug::rtlog << "mbb" << mbb << "\n";
//debug::rtlog << "shadowbb" << shadowbb.bound << "\n";
return shadowbb.str.length();
}
int tfgetsel(textfieldo& tf, vec2 const& v, vec2 const& off, aabb2 const& ta, mat3 const& tr) {
aabb2 stbb = strbb(tf.vistext, off, ta, tr);
return tfgetsel(tf, v, stbb, off, ta, tr);
}
void tfdrawcursor(textfieldo& tf, vec2 const& v, vec4 const& col, vec2 const& off, aabb2 const& ta, mat3 const& tr) {
aabb2 stbb = strbb(tf.vistext, off, ta, tr);
int shadowSel = tfgetsel(tf, v, stbb, off, ta, tr);
tfdrawcursor(tf, shadowSel, col, stbb, off, ta, tr);
}
void tfadjustsels(textfieldo& tf) {
if (tf.sel > tf.selmax) { int t = tf.sel; tf.sel = tf.selmax; tf.selmax = t; }
tf.sel = outl::clamp(tf.sel, 0, tf.text->length());
tf.selmax = outl::clamp(tf.selmax, 0, tf.text->length());
tf.selvis = outl::clamp(tf.selvis, 0, tf.text->length());
tf.off = outl::clamp(tf.off, 0, tf.text->length());
}
void tfmoveoff(textfieldo& tf, int delta, vec2 const& off, aabb2 const& ta, mat3 const& tr) {
tf.off += delta;
tfadjustsels(tf);
tf.selvis = tf.off + strbbw(tf.text->substr(tf.off, tf.text->length() - tf.off), off, ta, tr).str.length();
tfadjustsels(tf);
}
int textField(std::string const& identifier, std::wstring const& hintText, std::wstring* text) {
if (!text) return 0;
if (txfs.find(identifier) == txfs.end()) { txfs[identifier]; txfs[identifier].sel = text->length(); }
updatestatelayout();
aabb2 bb = aabb2{ -state.size, state.size } / 2.f + state.pos;
bool miq = mouseInContainer() == curContainer.top() && mouseInQuad(bb);
textfieldo& tf = txfs[identifier];
tf.text = text;
std::string tstate = tf.active ? "textfield-click" : (miq ? "textfield-hover" : "textfield-passive");
//Sprite& at = glb::getSprite(atlas);
//Sprite::AnimationPlayer ap = { at, tf.active ? "textfield-click" : (miq ? "textfield-hover" : "textfield-passive") };
//at.drawTiled(ap, state.size/2.f, space * pmat3::translate(state.pos));
//aabb2 ta = at.getTiledAreaScreenSpace(ap, state.size/2.f) + bb.center();
drawspritetiledstate(tstate, state.size/2.f, pmat3::translate(state.pos));
aabb2 ta = gettiledareascreenspace(tstate, state.size / 2.f) + bb.center();
ta = ta.scaled(.9f);
vec2 off = vec2(1.f, 0.f);
tf.off = outl::clamp(tf.off, 0, tf.text->length());
tf.vistext = tf.off == 0 ? *tf.text : tf.text->substr(tf.off, tf.text->length() - tf.off);
mat3 tr = pmat3::translate(space*(ta.center() - ta.size().xo()/2.f));
if (tf.text->length() == 0 && hintText.length() > 0) { vec4 cl = getTxr().color(); getTxr().color(cl.a(.6f)); drawstr(hintText, state.modstr, off, ta, tr); getTxr().color(cl); }
else drawstr(tf.vistext, state.modstr, off, ta, tr);
int res = 0;
if (!tf.active && miq && input::getMouseDown(0)) { tf.active = true; res = 2; tf.sel = tf.text->length(); }
else if (tf.active && !miq && input::getMouseDown(0)) { tf.active = false; res = 3; } //when you click await it simulates an 'enter' keypress
tf.shadowSel = tf.text->length();
if ((miq || tf.selstartpoint > -1) && !tf.enableClickTimer) {
vec2 mproj = mouseproj(); //mouse projected in imui space
aabb2 stbb = strbb(tf.vistext, off, ta, tr);
tf.shadowSel = tf.off + tfgetsel(tf, mproj.maxed(ta.fmin()), stbb, off, ta, tr);
tfdrawcursor(tf, tf.shadowSel, vc4::black.a(.5f), stbb, off, ta, tr);
if (input::getMouseDown(0)) tf.sel = tf.selstartpoint = tf.selmax = tf.shadowSel;
if (input::getMouse(0)) {
if (tf.shadowSel > tf.selstartpoint) { tf.sel = tf.selstartpoint; tf.selmax = tf.shadowSel; }
else { tf.sel = tf.shadowSel; tf.selmax = tf.selstartpoint; }
}
if (input::getMouseUp(0)) tf.selstartpoint = -1;
if (mproj.x > ta.fmax().x && tf.selvis < tf.text->length()) tfmoveoff(tf, 1, off, ta, tr);
if (mproj.x < ta.fmin().x) tfmoveoff(tf, -1, off, ta, tr);
}
if (tf.active) {
//click timer management
if (tf.enableClickTimer && input::getMouseDelta() != 0.f) tf.enableClickTimer = false;
if (tf.enableClickTimer) {
tf.clickTimer += tick::deltaTime;
if (input::clickDown()) {
tf.clickTimes++;
tfadjustsels(tf);
switch (tf.clickTimes) {
case 1:
while (tf.selmax < tf.text->length() && (*tf.text)[tf.selmax] != L' ') tf.selmax++;
while (tf.sel > 0 && (*tf.text)[(std::max)(tf.sel,0)-1] != L' ') tf.sel--;
break;
case 2:
tf.selmax = tf.text->length();
tf.sel = 0;
break;
}
}
if (tf.clickTimer > .5f) tf.enableClickTimer = false;
}
else if (input::clickDown() && input::getMouseDelta() == 0.f) {
tf.enableClickTimer = true;
tf.clickTimer = 0.f;
tf.clickTimes = 0;
}
std::wstring oldtext = *tf.text;
//debug::rtlog << tf.sel << " -> " << tf.selmax << " " << tf.shadowSel << "\n";
TextRenderer::bwstring bwstr = strbbw(tf.vistext, off, ta, tr);
aabb2 stbb = bwstr.bound;
tfdrawcursor(tf, tf.sel, vc4::black, stbb, off, ta, tr);
if (tf.sel != tf.selmax) {
//draw a cyan quad to highlight the selected area
aabb2 minbb = strbb(substr(tf.vistext, 0, tf.sel - tf.off), off, ta, tr);
aabb2 maxbb = strbb(substr(tf.vistext, 0, tf.selmax - tf.off), off, ta, tr);
aabb2 selbb = stbb.minx(minbb.maxx()).maxx(maxbb.maxx());
util::setColor(vc4::cyan.a(.5f));
util::drawQuad(selbb);
tfdrawcursor(tf, tf.selmax, vc4::black, stbb, off, ta, tr);
}
tf.selvis = tf.off + bwstr.str.length(); //max character visible on screen
//debug::rtlog << "selvis " << tf.selvis << " (" << bwstr.str << ")\n";
int oldsel = tf.sel;
unsigned int txt = input::pollTextKey();
//if (txt > 0) { apptext(tf, std::wstring({ (wchar_t)txt }), tf.sel); tf.sel++; }
if (txt > 0) {
txreptext(tf, tf.sel, tf.selmax, std::wstring({ (wchar_t)txt })); tf.sel++; tf.selmax = tf.sel;
tfadjustsels(tf);
}
float speed = .1f * (tf.txfirst ? .5f : 4.f); //text control speed
if (input::getKey(GLFW_KEY_BACKSPACE) && txcontrol(tf, speed)) {
if (input::getKey(GLFW_KEY_LEFT_CONTROL)) {
tf.selmax = tf.sel;
tf.selmax = outl::clamp(tf.selmax, 0, tf.text->length() - 1);
while (tf.selmax > 0 && (*tf.text)[tf.selmax] == L' ') movetfoff(tf, tf.selmax, -1); //skip spaces
while (tf.selmax > 0 && (*tf.text)[tf.selmax] != L' ') movetfoff(tf, tf.selmax, -1); //skip word
tfadjustsels(tf);
remtext(tf, tf.sel, tf.selmax);
}
else {
tfadjustsels(tf);
if (tf.sel != tf.selmax) { txreptext(tf, tf.sel, tf.selmax, L""); tf.selmax = tf.sel; }
else { remtext(tf, tf.sel - 1, tf.sel); tf.sel--; }
//remtext(tf, tf.sel - 1, tf.sel);
//tf.sel--;
}
}
if (input::getKey(GLFW_KEY_DELETE) && txcontrol(tf, speed)) {
if (input::getKey(GLFW_KEY_LEFT_CONTROL)) {
tf.selmax = tf.sel;
tf.selmax = outl::clamp(tf.selmax, 0, tf.text->length() - 1);
while (tf.selmax < tf.text->length() && (*tf.text)[tf.selmax] == L' ') movetfoff(tf, tf.selmax, 1); //skip spaces
while (tf.selmax < tf.text->length() && (*tf.text)[tf.selmax] != L' ') movetfoff(tf, tf.selmax, 1);
tfadjustsels(tf);
remtext(tf, tf.sel, tf.selmax);
}
else {
tfadjustsels(tf);
if (tf.sel != tf.selmax) { txreptext(tf, tf.sel, tf.selmax, L""); tf.selmax = tf.sel; }
else { remtext(tf, tf.sel, tf.sel+1); }
}
}
if (input::getKey(GLFW_KEY_LEFT) && txcontrol(tf, speed)) {
if (input::getKey(GLFW_KEY_LEFT_CONTROL)) {
tf.sel = outl::clamp(tf.sel, 0, tf.text->length() - 1);
while (tf.sel > 0 && (*tf.text)[tf.sel] == L' ') movetfoff(tf, -1); //skip spaces
while (tf.sel > 0 && (*tf.text)[tf.sel] != L' ') movetfoff(tf, -1); //skip word
}
else tf.sel--;
}
if (input::getKey(GLFW_KEY_RIGHT) && txcontrol(tf, speed)) {
if (input::getKey(GLFW_KEY_LEFT_CONTROL)) {
tf.sel = outl::clamp(tf.sel, 0, tf.text->length() - 1);
while (tf.sel < tf.text->length() && (*tf.text)[tf.sel] == L' ') movetfoff(tf, 1); //skip spaces
while (tf.sel < tf.text->length() && (*tf.text)[tf.sel] != L' ') movetfoff(tf, 1); //skip word
}
else tf.sel++;
}
if (input::getKey(GLFW_KEY_LEFT_CONTROL) && txcontrol(tf, speed)) {
if (input::getKey(GLFW_KEY_V)) {
std::wstring clip = input::getFromClipboardw();
//apptext(tf, clip, tf.sel);
tfadjustsels(tf);
txreptext(tf, tf.sel, tf.selmax, clip);
tf.sel = tf.selmax = tf.sel + clip.length();
}
}
if (input::getKey(GLFW_KEY_LEFT_CONTROL)) {
if (input::getKeyDown(GLFW_KEY_C)) {
if (tf.sel != tf.selmax) {
tfadjustsels(tf); //in case tf.selmax < tf.sel
std::wstring cp = tf.text->substr(tf.sel, tf.selmax - tf.sel);
input::copyToClipboard(cp);
}
}
}
if (input::getKey(GLFW_KEY_BACKSPACE) ||
input::getKey(GLFW_KEY_LEFT) ||
input::getKey(GLFW_KEY_RIGHT) ||
(input::getKey(GLFW_KEY_LEFT_CONTROL) && input::getKey(GLFW_KEY_V)) ||
input::getKey(GLFW_KEY_DELETE)
) tf.txtimer += tick::deltaTime;
else { tf.txtimer = 0.f; tf.txfirst = false; }
if (tf.txtimer > speed) { tf.txtimer = 0.f; tf.txfirst = true; }
if (input::getKeyDown(GLFW_KEY_X)) tfmoveoff(tf, 1, off, ta, tr);
if (input::getKeyDown(GLFW_KEY_Z)) tfmoveoff(tf, -1, off, ta, tr);
tf.sel = outl::clamp(tf.sel, 0, tf.text->length());
if (oldsel != tf.sel && tf.selmax == oldsel) tf.selmax = tf.sel; //anchor selmax to sel if you're not already selecting more than 1 char
bool textmodified = oldtext.compare(*tf.text) != 0;
//debug::rtlog << tf.off << "\n";
//these loops are for trying to keep tf.sel inside the textfield on screen
int oldselvis = tf.selvis;
if (textmodified) {
tfmoveoff(tf, 0, off, ta, tr);
}
if (tf.sel == tf.selmax) {
//try not making tf.sel go too much to the right (offscreen)
while (tf.sel > tf.selvis && tf.selvis < tf.text->length()) tfmoveoff(tf, 1, off, ta, tr);
//try not making tf.sel go too much to the left (offscreen)
while (tf.off > 0 && tf.sel < tf.off) tfmoveoff(tf, -1, off, ta, tr);
}
if (txt > 0 || textmodified) return 4;
if (input::getKeyDown(GLFW_KEY_ENTER)) return 3;
return 1;
}
return res;
}
int textField(std::string const& identifier, std::wstring const& hintText, std::wstring const& modstr, vec2 const& pos, vec2 const& size, std::wstring* text) { setmanuallayout(pos, size); state.modstr = modstr; int res = textField(identifier, hintText, text); restoreState(); return res; }
template<typename T>
struct textfieldsnumst {
T old = static_cast<T>(0);
std::wstring text;
};
template<typename T>
std::unordered_map<std::string, textfieldsnumst<T>> txfsnt;
template<typename T>
int textFieldt(std::string const& identifier, T* val) { //textfield for numbers/objects
if (txfsnt<T>.find(identifier) == txfsnt<T>.end()) { textfieldsnumst<T> tf; tf.text = stru::towstr<T>(*val); txfsnt<T>[identifier] = tf; }
textfieldsnumst<T>& tf = txfsnt<T>[identifier];
state.modstr = L"";
int res = textField(identifier, std::is_same<T, int>::value ? L"integer" : L"decimal", &tf.text);
if (res == 3 || res == 4) {
T t = stru::tot<T>(tf.text);
if (tf.text.compare(L"") == 0) t = static_cast<T>(0);
*val = t;
}
if (res == 3) {
T t = stru::tot<T>(tf.text);
if (tf.text.compare(L"") == 0) t = static_cast<T>(0);
tf.text = stru::towstr<T>(t);
}
if (res == 0 && *val != tf.old) { tf.text = stru::towstr<T>(*val); }
tf.old = *val;
return res;
}
template<typename T>
int textFieldt(std::string const& identifier, vec2 const& pos, vec2 const& size, T* val) { setmanuallayout(pos, size); int res = textFieldt<T>(identifier, val); restoreState(); return res; }
int textFieldi(std::string const& identifier, int* val) { return textFieldt<int>(identifier, val); }
int textFieldi(std::string const& identifier, vec2 const& pos, vec2 const& size, int* val) { return textFieldt<int>(identifier, pos, size, val); }
int textFieldd(std::string const& identifier, double* val) { return textFieldt<double>(identifier, val); }
int textFieldd(std::string const& identifier, vec2 const& pos, vec2 const& size, double* val) { return textFieldt<double>(identifier, pos, size, val); }
int textFieldf(std::string const& identifier, float* val) { return textFieldt<float>(identifier, val); }
int textFieldf(std::string const& identifier, vec2 const& pos, vec2 const& size, float* val) { return textFieldt<float>(identifier, pos, size, val); }
void label(std::wstring const& text) {
updatestatelayout();
if(state.bound != 0.f) drawstr(text, state.stroffset, state.bound, pmat3::translate(space * state.pos));
else drawstr(text, state.stroffset, pmat3::translate(space * state.pos));
}
void label(std::wstring const& text, vec2 const& pos) { state.pos = pos; label(text); }
void labelBound(std::wstring const& text, aabb2 const& bound, vec2 const& offset) {
updatestatelayout();
aabb2 bb = aabb2{ state.size*bound.fmin(), state.size*bound.fmax() } / 2.f + state.pos;
drawstr(text, offset, bb, pmat3::translate(space * (state.pos - bb.size()*offset)));
}
void labelBound(std::wstring const& text, aabb2 const& bound) { labelBound(text, bound, 0.f); }
void labelBound(std::wstring const& text, vec2 const& offset) { labelBound(text, { -1.f, 1.f }, offset); }
void labelBound(std::wstring const& text) { labelBound(text, { -1.f, 1.f }, 0.f); }
struct slidero {
bool holding = false; //if the slider is being held by the user
vec2 startholdoff = 0.f; //offset from handle center when user starts holding
};
std::unordered_map<std::string, slidero> sliders;
template<typename T>
int slidert(std::string const& identifier, T* val, T minval, T maxval, bool textfield) {
if (val == nullptr) return 0;
updatestatelayout();
slidero& sl = sliders[identifier];
aabb2 bb = aabb2(-state.size, state.size) / 2.f + state.pos;
float sepval = textfield ? .6f : 1.f; //separation between slider and textfield (percentage of sizeX/2)
vec2 handleSize = { bb.size().y / 2.f, bb.size().y };
aabb2 barbb = bb.centered().movedIn({ handleSize.x/2.f, 0.f });
barbb = (barbb * vec2(1.f,.5f)).maxx(barbb.maxx()*sepval) + imui::state.pos;
drawspritetiledstate("slider-body", barbb, 1.f);
float vperc = (static_cast<float>(*val) - static_cast<float>(minval)) / (static_cast<float>(maxval) - static_cast<float>(minval));
vperc = outl::clamp(vperc, 0.f, 1.f);
float handlex = -barbb.size().x/2.f + barbb.size().x * vperc;
aabb2 handlebb = aabb2(-handleSize, handleSize)/2.f + barbb.center() + vec2x(handlex);
bool miq = mouseInContainer() == curContainer.top() && mouseInQuad(handlebb);
std::string state = "";
if (sl.holding || (miq && input::getMouse(0))) state = "slider-click";
else if(miq) state = "slider-hover";
else state = "slider-passive";
drawspritetiledstate(state, handlebb, 1.f);
//float slsizey = ssize.y * 2.f;
//vec2 slsize = vec2(slsizey * .375f, slsizey);
//aabb2 slbb = aabb2{ -slsize, slsize };
//aabb2 slbbp = (slbb + vec2(slx, 0.f) + state.pos);
//std::string astate = (miq || sl.holding) ? (input::getMouse(0) || sl.holding) ? "slider-click" : "slider-hover" : "slider-passive";
//drawspritetiledstate(astate, vec2(slsizey*.375f, slsizey), pmat3::translate(state.pos+vec2(slx,.0f)));
int res = 0;
bool oldslholding = sl.holding;
if (miq && input::getMouseDown(0)) { sl.holding = true; res = 1; sl.startholdoff = handlebb.center()-mouseproj(); }
else if (input::getMouseUp(0)) { sl.holding = false; res = 2; }
if (sl.holding) {
vec2 minpos = barbb[0];
vec2 maxpos = barbb[3];
vec2 nppos = mouseproj()+sl.startholdoff;
float nperc = (nppos.x - minpos.x) / (maxpos.x - minpos.x);
nperc = outl::clamp(nperc, 0.f, 1.f);
*val = static_cast<T>((float)minval + ((float)maxval - (float)minval) * nperc);
if (oldslholding == sl.holding) res = 3;
}
if (textfield) {
saveState();
imui::state.atlas = "";
aabb2 tfbb = bb.centered();
tfbb = tfbb.minx(tfbb.maxx()* sepval) + imui::state.pos;
textFieldt<T>(identifier + "-txf", tfbb.center(), tfbb.size(), val);
restoreState();
}
}
template<typename T>
int slidert(std::string const& identifier, vec2 const& pos, vec2 const& size, T* val, T minval, T maxval, bool textfield) { setmanuallayout(pos, size); int res = slidert<T>(identifier, val, minval, maxval, textfield); restoreState(); return res; }
int slideri(std::string const& identifier, int* val, int minval, int maxval, bool textfield) { return slidert<int>(identifier, val, minval, maxval, textfield); }
int slideri(std::string const& identifier, vec2 const& pos, vec2 const& size, int* val, int minval, int maxval, bool textfield) { return slidert<int>(identifier, pos, size, val, minval, maxval, textfield); }
int sliderd(std::string const& identifier, double* val, double minval, double maxval, bool textfield) { return slidert<double>(identifier, val, minval, maxval, textfield); }
int sliderd(std::string const& identifier, vec2 const& pos, vec2 const& size, double* val, double minval, double maxval, bool textfield) { return slidert<double>(identifier, pos, size, val, minval, maxval, textfield); }
int sliderf(std::string const& identifier, float* val, float minval, float maxval, bool textfield) { return slidert<float>(identifier, val, minval, maxval, textfield); }
int sliderf(std::string const& identifier, vec2 const& pos, vec2 const& size, float* val, float minval, float maxval, bool textfield) { return slidert<float>(identifier, pos, size, val, minval, maxval, textfield); }
int dropMenu(std::string const& identifier, std::wstring const& text, std::vector<std::wstring> const& opts) {
//if (cbxs.find(identifier) == cbxs.end()) { cbxs[identifier] = { -1 }; }
updatestatelayout();
//dropmenuo& cb = cbxs[identifier];
//std::wstring sel = text;//L"Select...";
//if (cb.selected > -1) sel = opts[cb.selected];
aabb2 bb = aabb2(-state.size, state.size) / 2.f +state.pos; //bb of the entire combo box
//aabb2 selbb = bb.maxx(bb.scaled(.6f).maxx()); //bb of 'text' area
aabb2 selbb = bb.maxx(bb.maxx()-.1f* space.inverted().scalingv().x); //bb of 'text' area
aabb2 arrowbb = bb.minx(bb.maxx()-.1f * space.inverted().scalingv().x); //bb of arrow to drop menu
bool miq = mouseInContainer() == curContainer.top() && mouseInQuad(bb);
std::string state = miq ? input::getMouse(0) ? "dropmenu-click" : "dropmenu-hover" : "dropmenu-passive";
drawspritetiledstate(state, bb, 1.f);
drawstr(text, 0.f, selbb, pmat3::translate(space * selbb.center()));
drawsprite("dropmenu-arrow", aabb2(-1.f, 1.f).fitted(arrowbb), 1.f);
if (miq && input::click()) {
dropmenu = !dropmenu;
if (dropmenu) {
dropjustopened = true;
dropid = identifier;
dropbb = bb;
dropopts = opts;
}
}
else if (!miq && input::click() && dropmenu && dropid.compare(identifier) == 0 && !mouseInQuad(dropbodybb)) dropmenu = false;
if (dropmenu && dropid.compare(identifier) == 0) {
dropspace = space;
utildropmat = util::getTopMatrix();
dropstate = imui::state;
}
if (dropsel != -1 && dropmenu && dropid.compare(identifier) == 0) {
int res = dropsel;
dropsel = -1;
//cb.selected = res;
dropmenu = false;
return res;
}
return -1;
}
int dropMenu(std::string const& identifier, std::wstring const& text, vec2 const& pos, vec2 const& size, std::vector<std::wstring> const& opts) { setmanuallayout(pos, size); int res = dropMenu(identifier, text, opts); restoreState(); return res; }
struct comboboxo {
int selected = -1;
};
std::unordered_map<std::string, comboboxo> cbxs;
int comboBox(std::string const& identifier, std::wstring const& hintText, std::vector<std::wstring> const& opts, int const& defaultOpt) {
if (cbxs.find(identifier) == cbxs.end()) { cbxs[identifier] = { -1 }; }
updatestatelayout();
comboboxo& cb = cbxs[identifier];
if (defaultOpt > -1 && cb.selected == -1) cb.selected = defaultOpt;
std::wstring tsel = cb.selected > -1 ? opts[cb.selected] : hintText;
int res = dropMenu(identifier + "-dp", tsel, state.pos, state.size, opts);
if (res != -1) cbxs[identifier].selected = res;
return res;
}
int comboBox(std::string const& identifier, std::wstring const& hintText, vec2 const& pos, vec2 const& size, std::vector<std::wstring> const& opts, int const& defaultOpt) { setmanuallayout(pos, size); int res = comboBox(identifier, hintText, opts); restoreState(); return res; }
int checkBox(std::string const& identifier, bool* val) {
if (!val) return 0;
updatestatelayout();
aabb2 bb = aabb2(-state.size, state.size)/2.f + state.pos;
bool miq = mouseInContainer() == curContainer.top() && mouseInQuad(bb);
std::string state = miq ? input::getMouse(0) ? "checkbox-click" : "checkbox-hover" : "checkbox-passive";
drawspritetiledstate(state, bb, 1.f);
//debug::rtlog << state << "\n";
int res = 0;
if (miq && input::click()) { *val = !*val; res = 1; }
if(*val) drawsprite("checkbox-check", aabb2(-1.f,1.f).fitted(bb), 1.f);
return res;
}
int checkBox(std::string const& identifier, vec2 const& pos, vec2 const& size, bool* val) { setmanuallayout(); int res = checkBox(identifier, val); restoreState(); return res; }
struct dropMenuBoundingBoxStructure {
dropMenuBoundingBoxStructure* parent = nullptr;
aabb2 bb;
std::vector<dropMenuBoundingBoxStructure*> childs;
};
bool mouseInChildrenDropMenus(dropMenuBoundingBoxStructure const& dmbs) {
for (int i = 0; i < dmbs.childs.size(); i++) {
if (!dmbs.childs[i]) continue;
//debug::rtlog << "checking child " << i << "\n";
if (mouseInQuad(dmbs.childs[i]->bb) || mouseInChildrenDropMenus(*dmbs.childs[i])) return true;
}
return false;
}
struct begdropmeno {
bool opened = false;
dropMenuBoundingBoxStructure dmbs;
};
std::unordered_map<std::string, begdropmeno> begdps;
bool beginDropMenu(std::string const& identifier, std::wstring const& text) {
if (begdps.find(identifier) == begdps.end()) { begdps[identifier]; }
updatestatelayout();
begdropmeno& bdm = begdps[identifier];
aabb2 bb = aabb2(-state.size, state.size) / 2.f + state.pos; //bb of the entire combo box
//aabb2 selbb = bb.maxx(bb.scaled(.6f).maxx()); //bb of 'text' area
aabb2 selbb = bb.maxx(bb.maxx()-.1f * space.inverted().scalingv().x); //bb of 'text' area
aabb2 arrowbb = bb.minx(bb.maxx()-.1f * space.inverted().scalingv().x); //bb of arrow to drop menu
bool miq = (mouseInContainer() == curContainer.top() || state.indropmenu) && mouseInQuad(bb);
std::string tstate = miq ? input::getMouse(0) ? "dropmenu-click" : "dropmenu-hover" : "dropmenu-passive";
drawspritetiledstate(tstate, bb, 1.f);
drawstr(text, 0.f, selbb, pmat3::translate(space * selbb.center()));
drawsprite("dropmenu-arrow", aabb2(-1.f, 1.f).fitted(arrowbb), 1.f);
//debug::drawQuad(util::getTopMatrixAspectInv() * space * bb);
//debug::drawQuad(util::getTopMatrixAspectInv() * space * selbb);
//debug::drawQuad(util::getTopMatrixAspectInv() * space * arrowbb);
//if (button(text, state.pos, state.size)) {
// bdm.opened = !bdm.opened;
// if (bdm.opened) { curbegdp = identifier; dropbeganopened = true; }
//}
if (miq && input::getMouseUp(0)) {
bdm.opened = !bdm.opened;
}
if (!miq && input::getMouseUp(0) &&
!mouseInQuad(bdm.dmbs.bb) &&
!mouseInChildrenDropMenus(bdm.dmbs)) { bdm.opened = false; }
if (bdm.dmbs.childs.size() > 0) bdm.dmbs.childs.clear();
if (bdm.opened) {
bool alreadydrop = state.indropmenu;
saveState();
state.currentDropMenuBB = vec2(0.f);
if (state.indropmenu && state.dropmenuid.compare("") != 0) { //root drop menu
bdm.dmbs.parent = &begdps[state.dropmenuid].dmbs;
}
state.indropmenu = true;
state.dropmenuid = identifier;
if (alreadydrop) { setPos(state.pos + state.size.xo()); state.offset = state.size.ny(); }
else { setPos(state.pos - state.size.oy()); state.offset = state.size.ny(); }
state.layout = VERTICAL;
beginContainer(identifier + "-dm", bdm.dmbs.bb);
}
return bdm.opened;
}
bool beginDropMenu(std::string const& identifier, std::wstring const& text, vec2 const& pos, vec2 const& size) { setmanuallayout(pos, size); bool res = beginDropMenu(identifier, text); if(!res) restoreState(); return res; }
void endDropMenu() {
endContainer();
//before restoring, i save the bounding box of the current drop menu and store it in the
//children of its super drop menu
if (!state.indropmenu || state.dropmenuid.compare("") == 0) { std::cout << "called enddropmenu before beginDropMenu!\n"; return; }
begdropmeno& bdm = begdps[state.dropmenuid];
bdm.dmbs.bb = state.currentDropMenuBB;
if (bdm.dmbs.parent) {
bdm.dmbs.parent->childs.push_back(&bdm.dmbs);
}
restoreState();
if (state.manualLayoutOverride) restoreState();
}
void reset() {
if (ststack.size() > 0) { std::cout << "warning: degenerate imui stack at end of frame!\n"; ststack.st.clear(); }
//if(containers.size() > 0) containers.clear();
if (dropmenu) { //there can only be one dropmenu activated at one time
saveState();
state = dropstate;
util::pushMatrix();
util::resetMatrix();
util::multMatrix(utildropmat);
mat3 oldsp = space;
space = dropspace;
beginContainer("__parr__top__", dropbodybb);
aabb2 projScreen = tospace() * util::getResbbNDCAspect();
dropbodybb = aabb2(dropbb.fmin() - vec2y(dropbb.size().y * dropopts.size()), dropbb[3]);
dropbodybb = dropbodybb.forcedIn(projScreen);
vec2 startpos = dropbodybb.edgeCenter(1) - vec2y(dropbb.size().y / 2.f);
drawspritetiledstate("dropmenu-passive", dropbodybb, 1.f);
int wrapi = 0;
for (int i = 0; i < dropopts.size(); i++) {
vec2 pos = startpos - vec2y(dropbb.sizey() * i);
if (pos.y-dropbb.sizey()/2.f < projScreen.miny()) {
if (wrapi == 0) { wrapi = i; }
pos = vec2(pos.x + dropbb.sizex(), projScreen[1].y-dropbb.sizey()/2.f) - vec2y(dropbb.sizey() * (i - wrapi));
dropbodybb.rescale(pos + dropbb.size()/2.f);
//std::cout << wrapi << " " << pos << "\n";
}
if (button(dropopts[i], pos, dropbb.size())) {
if(!dropjustopened) dropsel = i;
}
}
endContainer();
if (dropjustopened) dropjustopened = false;
space = oldsp;
util::popMatrix();
restoreState();
}
//remove every container that was not called in this frame
bool rem = true;
while (rem) {
rem = false;
for (auto& c : pingContainers) if (!c.second) { containers.erase(c.first); posContainers.erase(c.first); pingContainers.erase(c.first); rem = true; break; }
}
for (auto& c : pingContainers) {
c.second = false;
}
curposcontainer = 0;
state.pos = 0.f; state.size = 0.f;
state.nextPos = 0.f; state.nextSize = 0.f;
gid = 0;
}
void init() {
ststack.st.reserve(10);
curContainer.push("");
}
}
}
| 38.967464 | 291 | 0.636527 | [
"vector",
"transform"
] |
d2e11ed2f60919ef813ff2569ef1b7cbd9345808 | 1,354 | cc | C++ | src/bot.cc | L0laapk3/RLBotCPP | 0d56546fd818324e232b77375eba1861e8e8956f | [
"MIT"
] | 4 | 2019-06-08T21:25:14.000Z | 2019-09-06T17:20:22.000Z | RLBotCPP/src/bot.cc | steinraf/badbotcpp | 6b517bd0c9ce1f1b717dbfdd790e627434259219 | [
"MIT"
] | 2 | 2019-06-18T19:24:32.000Z | 2021-12-08T06:38:37.000Z | RLBotCPP/src/bot.cc | steinraf/badbotcpp | 6b517bd0c9ce1f1b717dbfdd790e627434259219 | [
"MIT"
] | 13 | 2019-05-04T19:08:25.000Z | 2022-02-07T20:13:09.000Z | #include "rlbot/bot.h"
#include <vector>
#include "rlbot/interface.h"
#include "rlbot/rlbot_generated.h"
namespace rlbot {
Bot::Bot(int _index, int _team, std::string _name) {
index = _index;
team = _team;
name = _name;
}
BallPrediction Bot::GetBallPrediction() {
ByteBuffer buffer = Interface::GetBallPrediction();
BallPrediction ballprediction(buffer);
Interface::Free(buffer.ptr);
return ballprediction;
}
FieldInfo Bot::GetFieldInfo() {
ByteBuffer buffer = Interface::UpdateFieldInfoFlatbuffer();
FieldInfo fieldinfo(buffer);
Interface::Free(buffer.ptr);
return fieldinfo;
}
MatchInfo Bot::GetMatchInfo() {
ByteBuffer buffer = Interface::GetMatchSettings();
MatchInfo matchinfo(buffer);
Interface::Free(buffer.ptr);
return matchinfo;
}
void Bot::SendQuickChat(rlbot::flat::QuickChatSelection message,
bool teamOnly) {
Interface::SendQuickChat(message, index, teamOnly);
}
QuickChatMessages Bot::ReceiveQuickChat() {
ByteBuffer buffer =
Interface::ReceiveQuickChat(index, team, lastMessageIndex);
QuickChatMessages quickchat = QuickChatMessages(buffer);
Interface::Free(buffer.ptr);
int count = quickchat->messages()->size();
if (count > 0) {
lastMessageIndex = quickchat->messages()->Get(count - 1)->messageIndex();
}
return quickchat;
}
} // namespace rlbot
| 24.178571 | 77 | 0.718612 | [
"vector"
] |
d2e1d08c3e9c17bf5630041c008b6a2f57867f91 | 9,607 | cpp | C++ | src/cozmo_description/cozmo.cpp | JHLee0513/libcozmo | f3a90a39ec1b1c4ead691328fd43459d67a3a44a | [
"BSD-3-Clause"
] | 8 | 2017-01-11T15:49:34.000Z | 2019-04-24T21:49:05.000Z | src/cozmo_description/cozmo.cpp | JHLee0513/libcozmo | f3a90a39ec1b1c4ead691328fd43459d67a3a44a | [
"BSD-3-Clause"
] | 6 | 2019-07-19T01:43:45.000Z | 2020-03-10T07:28:30.000Z | src/cozmo_description/cozmo.cpp | JHLee0513/libcozmo | f3a90a39ec1b1c4ead691328fd43459d67a3a44a | [
"BSD-3-Clause"
] | 4 | 2019-07-01T20:04:44.000Z | 2020-02-14T10:12:35.000Z | #include "cozmo_description/cozmo.hpp"
#include "Eigen/Dense"
#include <cmath>
#include <chrono>
#include <thread>
#include "aikido/trajectory/Trajectory.hpp"
#include "aikido/trajectory/Interpolated.hpp"
#include "aikido/statespace/Interpolator.hpp"
#include "aikido/statespace/GeodesicInterpolator.hpp"
#include "aikido/statespace/SE2.hpp"
namespace libcozmo{
using BoxShape = dart::dynamics::BoxShape;
using MeshShape = dart::dynamics::MeshShape;
using FreeJoint = dart::dynamics::FreeJoint;
using RevoluteJoint = dart::dynamics::RevoluteJoint;
using VisualAspect = dart::dynamics::VisualAspect;
using Skeleton = dart::dynamics::Skeleton;
using WeldJointConstraint = dart::constraint::WeldJointConstraint;
using InverseKinematicsPtr = dart::dynamics::InverseKinematicsPtr;
using Interpolator = aikido::statespace::Interpolator;
using GeodesicInterpolator = aikido::statespace::GeodesicInterpolator;
using Interpolated = aikido::trajectory::Interpolated;
using aikido::statespace::SE2;
Cozmo::Cozmo(const std::string& mesh_dir){
createCozmo(mesh_dir);
}
void Cozmo::createIKModule()
{
ik = dart::dynamics::InverseKinematics::create(ghost_strut);
ik->useChain();
}
void Cozmo::setForkliftPosition(double pos)
{
lower_forklift_strut_right->getParentJoint()->setPosition(0, pos);
upper_forklift_strut_right->getParentJoint()->setPosition(0, pos + 0.08);
lower_forklift_strut_left->getParentJoint()->setPosition(0, pos);
upper_forklift_strut_left->getParentJoint()->setPosition(0, pos + 0.08);
Eigen::Isometry3d goal_pose;
goal_pose = lower_forklift_strut_right->getTransform(base);
// Solve IK
ik->getTarget()->setTransform(goal_pose, base);
Eigen::VectorXd ik_solution;
if (ik->solveAndApply(ik_solution, true)) {
std::cout << "IK solution found!\n";
} else {
std::cout << "No IK solution found.\n" << std::endl;
}
}
BodyNodePtr Cozmo::makeRootBody(const SkeletonPtr& cozmo,
const std::string& mesh_name,
const std::string& mesh_dir)
{
FreeJoint::Properties properties;
BodyNodePtr bn = cozmo->createJointAndBodyNodePair<FreeJoint>(
nullptr,
properties,
dart::dynamics::BodyNode::AspectProperties(mesh_name)).second;
std::shared_ptr<MeshShape> base(new MeshShape(Eigen::Vector3d(1., 1., 1.),
MeshShape::loadMesh(mesh_dir + "/cozmo_base.STL")));
auto shapeNode = bn->createShapeNodeWith<VisualAspect>(std::static_pointer_cast<dart::dynamics::Shape>(base));
Eigen::Isometry3d tf = Eigen::Isometry3d::Identity();
Eigen::Matrix3d R = Eigen::Matrix3d::Identity();
R = Eigen::AngleAxisd(-M_PI/2, Eigen::Vector3d::UnitX());
tf.linear() = R;
bn->getParentJoint()->setTransformFromChildBodyNode(tf);
shapeNode->getVisualAspect()->setRGB(Eigen::Vector3d(190/255., 190/255., 190/255.));
return bn;
}
BodyNodePtr Cozmo::addBody(const SkeletonPtr& cozmo,
BodyNodePtr parent,
const std::string& mesh_name,
const std::string& mesh_dir,
Eigen::Vector3d transformFromParent,
Eigen::Vector3d transformFromChild)
{
RevoluteJoint::Properties properties;
properties.mName = mesh_name;
auto joint_bn = cozmo->createJointAndBodyNodePair<RevoluteJoint>(parent,
properties,
dart::dynamics::BodyNode::AspectProperties(mesh_name));
auto bn = joint_bn.second;
auto joint = joint_bn.first;
// Assumes that all mesh file names are at most 20 characters
// Pulls the file name out of the longer body node name and creates file path
const std::string& filepath = mesh_dir + "/" + mesh_name.substr(0,20) + ".STL";
std::shared_ptr<MeshShape> child(new MeshShape(Eigen::Vector3d(1., 1., 1.),
MeshShape::loadMesh(filepath)));
auto shapeNode = bn->createShapeNodeWith<VisualAspect>(std::static_pointer_cast<dart::dynamics::Shape>(child));
Eigen::Isometry3d tf = Eigen::Isometry3d::Identity();
Eigen::Matrix3d R = Eigen::Matrix3d::Identity();
shapeNode->getVisualAspect()->setRGB(Eigen::Vector3d(190/255., 190/255., 190/255.));
tf.translation() = transformFromParent;
joint->setTransformFromParentBodyNode(tf);
tf.translation() = transformFromChild;
joint->setTransformFromChildBodyNode(tf);
return bn;
}
SkeletonPtr Cozmo::createCozmo(const std::string& mesh_dir)
{
cozmo = Skeleton::create("cozmo");
base = makeRootBody(cozmo, "body", mesh_dir);
head = addBody(cozmo,
base,
"head",
mesh_dir,
Eigen::Vector3d(0.03, 0.0615, 0.0385),
Eigen::Vector3d(0.022, 0.02, 0.0));
upper_forklift_strut_left = addBody(cozmo,
base,
"upper_forklift_strut_left",
mesh_dir,
Eigen::Vector3d(-0.0045, 0.058, 0.0805),
Eigen::Vector3d(0.003, 0.021, 0.0));
upper_forklift_strut_right = addBody(cozmo,
base,
"upper_forklift_strut_right",
mesh_dir,
Eigen::Vector3d(-0.0045, 0.058, 0.0315),
Eigen::Vector3d(0.003, 0.021, 0.0));
lower_forklift_strut_left = addBody(cozmo,
base,
"lower_forklift_strut_left",
mesh_dir,
Eigen::Vector3d(-0.0025, 0.044, 0.0805),
Eigen::Vector3d(0.006, 0.015, 0.0));
lower_forklift_strut_right = addBody(cozmo,
base,
"lower_forklift_strut_right",
mesh_dir,
Eigen::Vector3d(-0.0025, 0.044, 0.0315),
Eigen::Vector3d(0.006, 0.015, 0.0));
forklift = addBody(cozmo,
upper_forklift_strut_right,
"forklift",
mesh_dir,
Eigen::Vector3d(0.066, 0.001, 0.0032),
Eigen::Vector3d(0.0028, 0.025, 0.0));
// We solve IK in the setForkliftPosition to make this strut exactly
// match lower_forklift_strut_right in order to compensate for the
// inability to model closed chains
ghost_strut = addBody(cozmo,
forklift,
"lower_forklift_strut_ghost",
mesh_dir,
Eigen::Vector3d(0.003, 0.01, 0.0),
Eigen::Vector3d(0.0691, 0.0032, 0.0032));
createIKModule();
setForkliftPosition(0.0);
return cozmo;
}
void Cozmo::executeTrajectory(
std::chrono::milliseconds period,
TrajectoryPtr traj)
{
using std::chrono::system_clock;
using std::chrono::duration;
using std::chrono::duration_cast;
system_clock::time_point startTime = system_clock::now();
bool trajInExecution = true;
while (trajInExecution) {
auto space = traj->getStateSpace();
if (space == NULL) { std::cout << "State space is NULL" << std::endl; }
auto scopedState = space->createState();
system_clock::time_point const now = system_clock::now();
double t = duration_cast<duration<double> >(now - startTime).count();
traj->evaluate(t, scopedState);
std::unique_lock<std::mutex> skeleton_lock(cozmo->getMutex());
auto state = static_cast<SE2::State*>(scopedState.getState());
Eigen::Isometry2d trans = state->getIsometry();
Eigen::Isometry3d trans_3d = Eigen::Isometry3d::Identity();
trans_3d.translation() << trans.translation()[0], trans.translation()[1], 0.;
trans_3d.linear().block<2,2>(0,0) = trans.linear();
base->getParentJoint()->setPositions(
dart::dynamics::FreeJoint::convertToPositions(trans_3d));
skeleton_lock.unlock();
bool const is_done = (t >= traj->getEndTime());
if (is_done) trajInExecution = false;
std::this_thread::sleep_until(now + period);
}
}
void Cozmo::setState(const double& x, const double& y, const Eigen::Quaterniond& orientation) {
Eigen::Isometry3d state = Eigen::Isometry3d::Identity();
state.linear() = orientation.normalized().toRotationMatrix();
state.translation() << x, y, 0.;
base->getParentJoint()->setPositions(
dart::dynamics::FreeJoint::convertToPositions(state));
}
SE2::State Cozmo::createState(const double x, const double y, const double th)
{
SE2::State s;
Eigen::Isometry2d t = Eigen::Isometry2d::Identity();
const Eigen::Rotation2D<double> rot(th);
t.linear() = rot.toRotationMatrix();
Eigen::Vector2d trans;
trans << x, y;
t.translation() = trans;
s.setIsometry(t);
return s;
}
std::shared_ptr<Interpolated> Cozmo::createInterpolatedTraj(
std::vector<Waypoint> waypoints)
{
std::shared_ptr<SE2> statespace = std::make_shared<SE2>();
std::shared_ptr<Interpolator> interpolator =
std::make_shared<GeodesicInterpolator>(statespace);
const int num_waypoints = waypoints.size();
Waypoint *w = new Waypoint;
SE2::State s;
std::shared_ptr<Interpolated> traj;
traj = std::make_shared<Interpolated>(statespace, interpolator);
for (int i=0; i < num_waypoints; i++) {
w = &waypoints.at(i);
s = createState(w->x, w->y, w->th);
traj->addWaypoint(w->t, &s);
}
return traj;
}
Eigen::Vector3d Cozmo::getState(
const std::shared_ptr<Interpolated> path, const double& time) {
auto space = path->getStateSpace();
auto scopedState = space->createState();
path->evaluate(time, scopedState);
const auto state =
static_cast<aikido::statespace::SE2::State*>(scopedState.getState());
const auto transform = state->getIsometry();
Eigen::Rotation2Dd rotation = Eigen::Rotation2Dd::Identity();
rotation.fromRotationMatrix(transform.rotation());
const auto translation = transform.translation();
return Eigen::Vector3d(translation.x(), translation.y(), rotation.angle());
}
} // namespace libcozmo
| 33.590909 | 115 | 0.673259 | [
"mesh",
"shape",
"vector",
"model",
"transform"
] |
5e41fadf2cded07818742bbb32dd067cded77511 | 1,944 | cpp | C++ | Codeforces/1436/C.cpp | noobie7/Codes | 4d8265f4b7042bd7e8c0e0402d417c7e160ae6d4 | [
"MIT"
] | 2 | 2021-09-14T15:57:24.000Z | 2022-03-18T14:11:04.000Z | Codeforces/1436/C.cpp | noobie7/Codes | 4d8265f4b7042bd7e8c0e0402d417c7e160ae6d4 | [
"MIT"
] | null | null | null | Codeforces/1436/C.cpp | noobie7/Codes | 4d8265f4b7042bd7e8c0e0402d417c7e160ae6d4 | [
"MIT"
] | null | null | null | /*
"An anomaly, I'm Muhammad Ali
Cause I know one day I'm gonna be the"
- Greatest, Eminem
*/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size()) cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" "; cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
vector<ll> fac;
vector<ll> ifac;
ll binmodulo(ll x, ll y){
x%=mod;
if(!x) return 0;
ll res = 1;
while(y){
if(y&1){
res = res*x%mod;
}
y/=2;
x = x*x%mod;
}
return res;
}
void precompute(int n){
fac.resize(n+1,1);
ifac.resize(n+1);
for(int i =2; i <=n; i++){
fac[i] = i*fac[i-1]%mod;
}
ifac[n] = binmodulo(fac[n], mod-2);
for(int i = n-1; i>=0; i--){
ifac[i] = (i+1)*ifac[i+1]%mod;
}
}
ll ncr(ll n, ll r){
return fac[n]*ifac[n-r]%mod*ifac[r]%mod;
}
int main(){
Shazam;
precompute(1005);
int n; cin>>n;
int x; cin>>x;
int p; cin>>p;
int l = 0;
int r = n;
int gr = 0, ls = 0;
while( r > l ){
int mid = (l + r)/2;
if(mid <= p) {if(mid != p) ls++; l = mid + 1;}
else {gr++; r = mid;}
}
ll lavail = x - 1;
ll ravail = n - x;
ll ans = 1;
if( lavail < ls || ravail < gr){cout<<0<<endl; return 0;}
ans = ans * ncr(lavail, ls) % mod;
ans = ans * ncr(ravail, gr) % mod;
ans = ans * fac[n-(ls + gr + 1)] % mod;
ans = ans * fac[ls] % mod;
ans = ans * fac[gr] % mod;
cout<<ans<<endl;
return 0;
} | 22.604651 | 81 | 0.503601 | [
"vector"
] |
5e42b6bd20d6f319801194c403cf2e9571ae81d7 | 5,163 | cpp | C++ | modules/vectorfieldvisualization/processors/3d/streamlines.cpp | victorca25/inviwo | 34b6675f6b791a08e358d24aea4f75d5baadc6da | [
"BSD-2-Clause"
] | null | null | null | modules/vectorfieldvisualization/processors/3d/streamlines.cpp | victorca25/inviwo | 34b6675f6b791a08e358d24aea4f75d5baadc6da | [
"BSD-2-Clause"
] | null | null | null | modules/vectorfieldvisualization/processors/3d/streamlines.cpp | victorca25/inviwo | 34b6675f6b791a08e358d24aea4f75d5baadc6da | [
"BSD-2-Clause"
] | null | null | null | #include "streamlines.h"
#include <inviwo/core/datastructures/buffer/buffer.h>
#include <inviwo/core/datastructures/buffer/bufferramprecision.h>
#include <inviwo/core/datastructures/geometry/basicmesh.h>
#include <inviwo/core/datastructures/image/layerram.h>
#include <inviwo/core/datastructures/volume/volumeram.h>
#include <modules/opengl/image/layergl.h>
#include <bitset>
#include <inviwo/core/util/imagesampler.h>
#include <modules/vectorfieldvisualization/algorithms/integrallineoperations.h>
namespace inviwo {
const ProcessorInfo StreamLines::processorInfo_{
"org.inviwo.StreamLines", // Class identifier
"Stream Lines", // Display name
"Vector Field Visualization", // Category
CodeState::Experimental, // Code state
Tags::CPU, // Tags
};
const ProcessorInfo StreamLines::getProcessorInfo() const { return processorInfo_; }
StreamLines::StreamLines()
: Processor()
, sampler_("sampler")
, seedPoints_("seedpoints")
, volume_("vectorvolume")
, linesStripsMesh_("linesStripsMesh_")
, lines_("lines")
, streamLineProperties_("streamLineProperties", "Stream Line Properties")
, tf_("transferFunction", "Transfer Function")
, velocityScale_("velocityScale_", "Velocity Scale (inverse)", 1, 0, 10)
, maxVelocity_("minMaxVelocity", "Velocity Range", "0", InvalidationLevel::Valid)
, useOpenMP_("useOpenMP","Use OpenMP",true)
{
addPort(sampler_);
addPort(seedPoints_);
addPort(volume_);
addPort(lines_);
addPort(linesStripsMesh_);
maxVelocity_.setReadOnly(true);
addProperty(streamLineProperties_);
addProperty(useOpenMP_);
addProperty(tf_);
addProperty(velocityScale_);
addProperty(maxVelocity_);
tf_.get().clearPoints();
tf_.get().addPoint(vec2(0, 1), vec4(0, 0, 1, 1));
tf_.get().addPoint(vec2(0.5, 1), vec4(1, 1, 0, 1));
tf_.get().addPoint(vec2(1, 1), vec4(1, 0, 0, 1));
setAllPropertiesCurrentStateAsDefault();
}
StreamLines::~StreamLines() {}
void StreamLines::process() {
auto sampler = [&]() -> std::shared_ptr<const SpatialSampler<3, 3, double> > {
if (sampler_.isConnected()) return sampler_.getData();
else return std::make_shared<VolumeDoubleSampler<3>>(volume_.getData());
}();
auto mesh = std::make_shared<BasicMesh>();
mesh->setModelMatrix(sampler->getModelMatrix());
mesh->setWorldMatrix(sampler->getWorldMatrix());
auto m = streamLineProperties_.getSeedPointTransformationMatrix(
sampler->getCoordinateTransformer());
float maxVelocity = 0;
StreamLineTracer tracer(sampler, streamLineProperties_);
auto lines = std::make_shared<IntegralLineSet>(sampler->getModelMatrix());
std::vector<BasicMesh::Vertex> vertices;
if (useOpenMP_) {
size_t startID = 0;
for (const auto &seeds : seedPoints_) {
#pragma omp parallel for
for (long long j = 0; j < static_cast<long long>(seeds->size()); j++) {
auto p = seeds->at(j);
vec4 P = m * vec4(p, 1.0f);
auto line = tracer.traceFrom(vec3(P));
auto size = line.getPositions().size();
if (size > 1) {
#pragma omp critical
lines->push_back(line, startID + j);
};
}
startID += seeds->size();
}
}
else {
size_t startID = 0;
for (const auto &seeds : seedPoints_) {
for(const auto &p : *seeds.get()){
vec4 P = m * vec4(p, 1.0f);
auto line = tracer.traceFrom(vec3(P));
auto size = line.getPositions().size();
if (size > 1) {
lines->push_back(line, startID);
}
startID++;
}
}
}
for (auto &line : *lines) {
auto position = line.getPositions().begin();
auto velocity = line.getMetaData("velocity").begin();
auto size = line.getPositions().size();
if (size <= 1) continue;
auto indexBuffer =
mesh->addIndexBuffer(DrawType::Lines, ConnectivityType::StripAdjacency);
indexBuffer->add(0);
for (size_t i = 0; i < size; i++) {
vec3 pos(*position);
vec3 v(*velocity);
float l = glm::length(vec3(*velocity));
float d = glm::clamp(l / velocityScale_.get(), 0.0f, 1.0f);
maxVelocity = std::max(maxVelocity, l);
auto c = vec4(tf_.get().sample(d));
indexBuffer->add(static_cast<std::uint32_t>(vertices.size()));
vertices.push_back({pos, glm::normalize(v), pos, c});
position++;
velocity++;
}
indexBuffer->add(static_cast<std::uint32_t>(vertices.size() - 1));
}
//}
mesh->addVertices(vertices);
maxVelocity_.set(toString(maxVelocity));
linesStripsMesh_.setData(mesh);
util::curvature(*lines);
util::tortuosity(*lines);
lines_.setData(lines);
}
} // namespace
| 29.843931 | 88 | 0.596359 | [
"mesh",
"geometry",
"vector"
] |
5e47e23405558292e843c40253e5fbcb0b71ea18 | 6,970 | hpp | C++ | include/visualization/Layout.hpp | Enrico7741/ControllerVisualization | 8a0dc16e776440edad8db050cfe953c63bacdd0b | [
"MIT"
] | null | null | null | include/visualization/Layout.hpp | Enrico7741/ControllerVisualization | 8a0dc16e776440edad8db050cfe953c63bacdd0b | [
"MIT"
] | null | null | null | include/visualization/Layout.hpp | Enrico7741/ControllerVisualization | 8a0dc16e776440edad8db050cfe953c63bacdd0b | [
"MIT"
] | null | null | null | //--------------------------------------------------------------------------------------------------
// Cross-Platform Controller Input Visualization
// Copyright (C) 2021 Enrico Schörnick
// Licensed under the MIT License
//--------------------------------------------------------------------------------------------------
#ifndef VISUALIZATION_LAYOUT_HPP
#define VISUALIZATION_LAYOUT_HPP
#include <vector>
#include <utility>
#include <cstdint>
/**
* Namespace for global constants concerning the layout.
* Constants defined here shall be used throughout all layout relevant code.
*/
namespace Layout
{
struct Color
{
uint8_t r;
uint8_t g;
uint8_t b;
};
namespace Colors
{
const Color text{0, 0, 0};
const Color boxDark{5, 10, 15};
const Color boxBright{60, 80, 90};
const Color background{25, 35, 45};
const Color breakpoint{150, 0, 0};
const Color outlineCode{255, 0, 0};
const Color displayBackground{40, 40, 40};
const Color displayForeground{170, 255, 170};
}
namespace Box
{
const int margin{11}; // Space between each box
const int padding{5}; // Padding between boundary and content
const int outlineThickness{4}; // Thickness of box outline
}
namespace Char
{
const int width{10};
const int height{14};
const int margin{4}; // Space between chars
const int bmpStart{0}; // Start of first char in bitmap
const int bmpMargin{2}; // Space between two chars in bitmap
const int asciiOffset{33}; // Ascii value of first char in bitmap
const int lineHeight{height + 5}; // Y-distance between start of two lines
}
namespace Button
{
const int width{32};
const int height{36};
const int bmpMargin{1}; // Space between two buttons in bitmap
}
namespace MainWindow
{
const int width{1870};
const int firstRowHeight{488}; // Heigth of sections in first row of the window
const int secondRowHeight{317}; // Heigth of sections in second row of the window
const int height{680};
}
namespace DisplayBox
{
const int xPos{Box::margin};
const int yPos{Box::margin};
const int width{968};
const int height{MainWindow::firstRowHeight};
const int scale{15};
const int displayX{xPos + Box::outlineThickness}; // X-position of display in box
const int displayY{yPos + Box::outlineThickness}; // Y-position of display in box
}
namespace InfoBox
{
const int xPos{Box::margin};
const int yPos{2 * Box::margin + DisplayBox::height};
const int width{350};
const int height{MainWindow::secondRowHeight};
}
namespace InputBox
{
const int xPos{2 * Box::margin + InfoBox::width};
const int yPos{2 * Box::margin + DisplayBox::height};
const int width{236};
const int height{MainWindow::secondRowHeight};
const int stepSizeX = 52; // Distance between button columns in x
const int firstCol = xPos + Box::padding + 20; // Start of first button column in x
const int secondCol = firstCol + stepSizeX;
const int thirdCol = secondCol + stepSizeX;
const int fourthCol = thirdCol + stepSizeX;
const int stepSizeY = 69; // Distance between button rows in y
const int firstRow = yPos + Box::padding + 33; // Start of first button row in y
const int secondRow = firstRow + stepSizeY;
const int thirdRow = secondRow + stepSizeY;
const int fourthRow = thirdRow + stepSizeY;
const std::vector<std::pair<int, int>> buttonPos{
{Layout::InputBox::firstCol, Layout::InputBox::firstRow}, // 1
{Layout::InputBox::secondCol, Layout::InputBox::firstRow}, // 2
{Layout::InputBox::thirdCol, Layout::InputBox::firstRow}, // 3
{Layout::InputBox::fourthCol, Layout::InputBox::firstRow}, // 4
{Layout::InputBox::firstCol, Layout::InputBox::secondRow}, // Q
{Layout::InputBox::secondCol, Layout::InputBox::secondRow}, // W
{Layout::InputBox::thirdCol, Layout::InputBox::secondRow}, // E
{Layout::InputBox::fourthCol, Layout::InputBox::secondRow}, // R
{Layout::InputBox::firstCol, Layout::InputBox::thirdRow}, // A
{Layout::InputBox::secondCol, Layout::InputBox::thirdRow}, // S
{Layout::InputBox::thirdCol, Layout::InputBox::thirdRow}, // D
{Layout::InputBox::fourthCol, Layout::InputBox::thirdRow}, // F
{Layout::InputBox::firstCol, Layout::InputBox::fourthRow}, // Z
{Layout::InputBox::secondCol, Layout::InputBox::fourthRow}, // X
{Layout::InputBox::thirdCol, Layout::InputBox::fourthRow}, // C
{Layout::InputBox::fourthCol, Layout::InputBox::fourthRow}}; // V
}
namespace BreakpointBox
{
const int xPos{3 * Box::margin + InfoBox::width + InputBox::width};
const int yPos{2 * Box::margin + DisplayBox::height};
const int width{125};
const int height{MainWindow::secondRowHeight};
}
namespace StackBox
{
const int xPos{4 * Box::margin + InfoBox::width + InputBox::width + BreakpointBox::width};
const int yPos{2 * Box::margin + DisplayBox::height};
const int width{224};
const int height{MainWindow::secondRowHeight};
// Outline for current stack level. Complicated...
const int outlineX{xPos + Box::outlineThickness + 3};
const int outlineY{yPos + height - Box::outlineThickness - Box::padding - Char::height - 2};
const int outlineWidth{width - 2 * (Box::outlineThickness + 3)};
const int outlineHeight{Char::height + 4};
}
namespace RegisterBox
{
const int xPos{2 * Box::margin + DisplayBox::width};
const int yPos{2 * Box::margin + DisplayBox::height};
const int width{350};
const int height{MainWindow::secondRowHeight};
const int colWidth{197}; // Distance in x to second column
}
namespace CodeBox
{
const int xPos{2 * Box::margin + DisplayBox::width};
const int yPos{Box::margin};
const int width{350};
const int height{MainWindow::firstRowHeight};
// Outline for current instruction. Also complicated...
const int outlineX{xPos + Box::outlineThickness + 3};
const int outlineY{yPos + Box::outlineThickness + 3};
const int outlineWidth{width - 2 * (Box::outlineThickness + 3)};
const int outlineHeight{Char::height + 4};
// Breakpoint background width
const int bpLineWidth{width - 2 * (Box::outlineThickness + Box::padding)};
}
}
#endif | 38.508287 | 100 | 0.594692 | [
"vector"
] |
5e4b03c370f9cf65599352da38425d9b794c101e | 7,273 | cc | C++ | src/core2/fifo_test.cc | LeeOHzzZ/lmac-ila | ed457b2107456ecbf6fc65ab09798241507a2ddd | [
"MIT"
] | null | null | null | src/core2/fifo_test.cc | LeeOHzzZ/lmac-ila | ed457b2107456ecbf6fc65ab09798241507a2ddd | [
"MIT"
] | null | null | null | src/core2/fifo_test.cc | LeeOHzzZ/lmac-ila | ed457b2107456ecbf6fc65ab09798241507a2ddd | [
"MIT"
] | null | null | null | // ============================================================================
// Instruction-Level Abstraction of LeWiz Communications Ethernet MAC
//
// This Instruction-Level Abstraction (ILA) description is derived based on the
// LeWiz Communications Ethernet MAC (LMAC), which is licensed under GNU LGPL.
// Check "LICENSE" which comes with this distribution for more information.
// ============================================================================
//
// File Name: file_test.cc
// This file implement the model of a two clk driven fifo module, of which two clock
// frequencies are of integer multiples.
#include <lmac/core2/lmac_core_top.h>
#include <lmac/core2/configs.h>
#include <lmac/utils.h>
#include <iostream>
#include <ilang/util/log.h>
#define rd_trigger 0
namespace ilang {
void LmacCore2::SetupFIFOTEST(Ila& m) {
ILA_INFO << "before adding child for fifo test";
AddChild_FIFO_TEST(m);
}
void LmacCore2::AddChild_FIFO_TEST(Ila& m) {
auto child = m.NewChild("FIFO_TEST");
child.SetValid(m.input(TX_WE) == TX_WE_V_VALID);
child.SetFetch(BvConst(0x1, 1));
// counter for the clock
NewState(child, "counter", 2);
// fifo read enable signal
NewState(child, "RE", 1);
// fifo empty signal
NewState(child, "fifo_empty", 1);
// common states used
auto data_in = m.input(TX_DATA);
auto wused = Extract(m.state(TXFIFO_WUSED_QWD), 4, 0);
auto fifo_full = m.state(TXFIFO_FULL);
auto fifo_empty = child.state("fifo_empty");
auto fifo = m.state(TXFIFO_BUFF);
auto wr_ptr = m.state(TXFIFO_BUFF_WR_PTR);
auto rd_ptr = m.state(TXFIFO_BUFF_RD_PTR);
auto fifo_out = m.state(TXFIFO_RD_OUTPUT);
auto counter = child.state("counter");
ILA_INFO << "before fifo_test 1st instr";
// three instructions
{// Write enable but not read enable
auto instr = child.NewInstr("Write_only");
//decode
auto we = (m.input(TX_WE) == TX_WE_V_VALID);
auto fifo_non_full = (fifo_full != TXFIFO_FULL_V_FULL);
auto rne = (child.state("RE") == 0);
instr.SetDecode(we & fifo_non_full & rne);
// update
auto wr_run = (counter == 0) | (counter == 2);
auto wr_entry = Ite((wr_ptr == TXFIFO_BUFF_DEPTH), BvConst(0x0, TXFIFO_BUFF_WR_PTR_BWID),
wr_ptr);
auto fifo_full_new = Ite(Uge(wused, TXFIFO_BUFF_DEPTH - 1), BvConst(1,1), BvConst(0,1));
auto fifo_full_old = Ite(Uge(wused, TXFIFO_BUFF_DEPTH), BvConst(1,1), BvConst(0,1));
auto fifo_empty_old = Ite(wused == 0, BvConst(1,1), BvConst(0,1));
instr.SetUpdate(fifo, Ite( wr_run, Store(fifo, wr_entry, data_in), fifo));
instr.SetUpdate(wr_ptr, Ite( wr_run,
Ite((Uge(wr_ptr, TXFIFO_BUFF_DEPTH)),
BvConst(0x1, TXFIFO_BUFF_WR_PTR_BWID), wr_ptr+1),
wr_ptr));
instr.SetUpdate(wused, Ite(wr_run, wused+1, wused));
instr.SetUpdate(fifo_full, Ite(wr_run, fifo_full_new, fifo_full_old));
instr.SetUpdate(fifo_empty, Ite(wr_run, BvConst(0x0, 1), fifo_empty_old));
}
ILA_INFO << "before fifo_test 2nd instr";
{// Write disable and Read enable
auto instr = child.NewInstr("Read_only");
auto wne = (m.input(TX_WE) == 0);
auto fifo_not_empty = (fifo_empty == 0);
auto re = (child.state("RE") == 1);
auto full_temp = Ite((wused == TXFIFO_BUFF_DEPTH), BvConst(1, 1), BvConst(0,1));
auto empty_temp = Ite((wused == 0), BvConst(1,1), BvConst(0,1));
instr.SetDecode(wne & fifo_not_empty & re);
//updates
auto rd_run = (counter == 2);
auto data_out = Ite(rd_run, Load(fifo, Ite(rd_ptr == TXFIFO_BUFF_DEPTH,
BvConst(0x0, TXFIFO_BUFF_RD_PTR_BWID), rd_ptr)),
fifo_out);
instr.SetUpdate(fifo_out, data_out);
instr.SetUpdate(rd_ptr, Ite(rd_run, Ite((rd_ptr == TXFIFO_BUFF_DEPTH),
BvConst(0x1, TXFIFO_BUFF_RD_PTR_BWID), rd_ptr+1),
rd_ptr));
instr.SetUpdate(wused, Ite(rd_run, wused-1, wused));
instr.SetUpdate(fifo_full, Ite(rd_run, BvConst(0x0, 1), full_temp));
instr.SetUpdate(fifo_empty, Ite(rd_run, Ite(wused == 1, BvConst(0x1,1), BvConst(0x0,1)),
empty_temp));
}
ILA_INFO << "before fifo_test 3rd instr";
{// Write and read both enable and triggered
// when counter != trigger, act like write-only
// when counter == trigger, both effects
auto instr = child.NewInstr("Write-Read");
// decode
auto we = (m.input(TX_WE) == TX_WE_V_VALID);
auto re = (child.state("RE") == 1);
auto fifo_not_full = (fifo_full != TXFIFO_FULL_V_FULL);
auto fifo_not_empty = (fifo_empty == 0);
instr.SetDecode(we & re & fifo_not_empty & fifo_not_full);
auto full_temp = Ite((wused == TXFIFO_BUFF_DEPTH), BvConst(1, 1), BvConst(0,1));
auto empty_temp = Ite((wused == 0), BvConst(1,1), BvConst(0,1));
auto both_run = (counter == 2);
auto wr_run = (counter == 0) | (counter == 2);
auto data_out = Ite(both_run, Load(fifo, Ite(rd_ptr == TXFIFO_BUFF_DEPTH,
BvConst(0x0, TXFIFO_BUFF_RD_PTR_BWID), rd_ptr)),
fifo_out);
ILA_INFO << "TEST";
// state updates
auto wr_entry = Ite((wr_ptr == TXFIFO_BUFF_DEPTH), BvConst(0x0, TXFIFO_BUFF_WR_PTR_BWID),
wr_ptr);
auto rd_entry = Ite((rd_ptr == TXFIFO_BUFF_DEPTH), BvConst(0x0, TXFIFO_BUFF_RD_PTR_BWID),
rd_ptr);
auto fifo_full_old = Ite(Uge(wused, TXFIFO_BUFF_DEPTH), BvConst(1,1), BvConst(0,1));
auto fifo_empty_old = Ite(wused == 0, BvConst(1,1), BvConst(0,1));
instr.SetUpdate(fifo, Ite(wr_run, Store(fifo, wr_entry, data_in), fifo));
instr.SetUpdate(fifo_out, data_out);
instr.SetUpdate(wr_ptr,Ite( wr_run, Ite((Uge(wr_ptr, TXFIFO_BUFF_DEPTH)),
BvConst(0x1, TXFIFO_BUFF_WR_PTR_BWID), wr_ptr+1),
wr_ptr));
instr.SetUpdate(rd_ptr, Ite(both_run, Ite((rd_ptr == TXFIFO_BUFF_DEPTH),
BvConst(0x1, TXFIFO_BUFF_RD_PTR_BWID), rd_ptr+1),
rd_ptr));
instr.SetUpdate(wused, Ite(both_run, wused, Ite(wr_run, wused+1, wused)));
instr.SetUpdate(fifo_full, Ite(both_run, full_temp,
Ite(wr_run,
Ite((Uge(wused, TXFIFO_BUFF_DEPTH - 1)), BvConst(1, 1), BvConst(0, 1)),
fifo_full_old)));
instr.SetUpdate(fifo_empty, Ite(both_run,
empty_temp,
Ite(wr_run, BvConst(0, 1), fifo_empty_old)));
}
}
}
| 43.035503 | 145 | 0.558229 | [
"model"
] |
5e4be6e2714f923a7850f01b3ff97597cdab84f7 | 1,470 | cpp | C++ | ProjectEndGame/cScaleRelativeToOverTime.cpp | BobEh/AI-Formations | 3af8de3586ca8721e2be62466acb1d4f4a88d42b | [
"MIT"
] | 1 | 2020-03-14T18:51:09.000Z | 2020-03-14T18:51:09.000Z | ProjectEndGame/cScaleRelativeToOverTime.cpp | BobEh/AI-Formations | 3af8de3586ca8721e2be62466acb1d4f4a88d42b | [
"MIT"
] | null | null | null | ProjectEndGame/cScaleRelativeToOverTime.cpp | BobEh/AI-Formations | 3af8de3586ca8721e2be62466acb1d4f4a88d42b | [
"MIT"
] | null | null | null | #include "cScaleRelativeToOverTime.h"
void cScaleRelativeToOverTime::Init(std::vector<sPair> vecDetails)
{
// Scales the object over time
// Pass:
// - Ending Scale
// - Number of seconds this will take
// Initial scale is set on the 1st Update()
this->m_endScale = vecDetails[0].numData.x;
this->m_TimeToChange = vecDetails[1].numData.x;
return;
}
void cScaleRelativeToOverTime::SetGameObject(cGameObject* pGO)
{
this->m_pTheGO = pGO;
return;
}
void cScaleRelativeToOverTime::Update(double deltaTime)
{
if ( ! this->m_UpdateHasBeeCalled )
{
this->m_startScale = this->m_pTheGO->scale;
this->m_ChangeSpeed = ( this->m_endScale - this->m_startScale ) / this->m_TimeToChange;
this->m_UpdateHasBeeCalled = true;
}
this->m_pTheGO->scale += (this->m_ChangeSpeed * (float)deltaTime);
this->m_ElapsedTime += deltaTime;
return;
}
bool cScaleRelativeToOverTime::IsDone(void)
{
// See if we've reached the scale we want
// (Note: you might want to compare this with a multiple of FLT_EPSION)
//if ( fabs(this->m_endScale - this->m_pTheGO->scale) < FLT_EPSILON * 10.0f )
//if ( fabs(this->m_endScale - this->m_pTheGO->scale) < 0.1f )
//{
// return true;
//}
if ( this->m_ElapsedTime >= (double)this->m_TimeToChange )
{
return true;
}
return false;
}
void cScaleRelativeToOverTime::AddCommandSerial(iCommand* pCommand)
{
return;
}
void cScaleRelativeToOverTime::AddCommandsParallel(std::vector<iCommand*> vec_pCommands)
{
return;
} | 22.96875 | 89 | 0.717007 | [
"object",
"vector"
] |
5e4eb185f6f8cbdcf80018f3f58928d9b562a70e | 1,394 | hh | C++ | src/include/view.hh | ppwwyyxx/Ray-Tracing-Engine | af3ec164d6b5e5b592a54a75282432d610423ffb | [
"MIT"
] | 101 | 2015-01-01T09:24:45.000Z | 2022-01-22T12:00:24.000Z | src/include/view.hh | ppwwyyxx/Ray-Tracing-Engine | af3ec164d6b5e5b592a54a75282432d610423ffb | [
"MIT"
] | 1 | 2018-11-23T03:53:47.000Z | 2018-11-23T05:31:52.000Z | src/include/view.hh | ppwwyyxx/Ray-Tracing-Engine | af3ec164d6b5e5b592a54a75282432d610423ffb | [
"MIT"
] | 32 | 2015-01-05T15:35:33.000Z | 2021-12-08T08:17:17.000Z | // File: view.hh
// Author: Yuxin Wu <ppwwyyxxc@gmail.com>
#pragma once
#include <memory>
#include "geometry/geometry.hh"
#include "render/space.hh"
class View {
private:
const Geometry geo;
inline void normalize_dir_vector()
{ dir_w.normalize(); dir_h.normalize(); }
inline void restore_dir_vector() {
// we should have: |dir_w| * geo.w == size
// as well as: |dir_w| == |dir_h|
dir_w = dir_w.get_normalized() * (size / geo.w);
dir_h = dir_h.get_normalized() * (size / geo.w);
}
const Space& sp;
public:
Vec view_point;
Vec mid;
real_t size; // length the img cover in the scene
Vec dir_w, dir_h;
Vec origin_norm; // the initial view
bool use_dof = false;
bool use_bended_screen = false;
View(const Space& _sp, const Vec& _view_point,
const Vec& _mid, real_t w, const Geometry& _geo);
void zoom(real_t ratio); // r > 1: zoom in
void twist(int angle); // -180 ~ 180
void rotate(int angle); // -180 ~ 180
void orbit(int angle); // -180 ~ 180
void shift(real_t dist, bool horiz);
void move_screen(real_t dist);
Color render(int i, int j) const; // i row j column
Color render_bended(int i, int j) const;
Color render_antialias(const Vec& dest, int sample) const; // render with n^2 sample at each pixel
Color render_dof(const Vec& dest) const;
const Geometry& get_geo() const
{ return geo; }
};
| 21.446154 | 100 | 0.659971 | [
"geometry",
"render"
] |
5e4fadfe5590df79a46d94a53a23b3d230d89dca | 2,247 | cc | C++ | codejam/2016/quailifiers/C.cc | metaflow/contests | 5e9ffcb72c3e7da54b5e0818b1afa59f5778ffa2 | [
"MIT"
] | 1 | 2019-05-12T23:41:00.000Z | 2019-05-12T23:41:00.000Z | codejam/2016/quailifiers/C.cc | metaflow/contests | 5e9ffcb72c3e7da54b5e0818b1afa59f5778ffa2 | [
"MIT"
] | null | null | null | codejam/2016/quailifiers/C.cc | metaflow/contests | 5e9ffcb72c3e7da54b5e0818b1afa59f5778ffa2 | [
"MIT"
] | null | null | null | #include<bits/stdc++.h>
using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
const int INF = numeric_limits<int>::max();
const double EPS = 1e-10;
const l e5 = 100000, e6 = 1000000, e7 = 10000000, e9 = 1000000000;
struct Result {
l value;
vl divisors;
};
vl primes;
const l MAX_PRIME = 1000000;
vl sieve_primes() {
bitset<MAX_PRIME + 1> b;
vl primes;
primes.emplace_back(2);
for (l i = 3; i <= MAX_PRIME; i += 2) {
if (b[i]) continue;
primes.emplace_back(i);
for (l j = i * i; j <= MAX_PRIME; j += i) b.set(j);
}
return primes;
}
vl factorize_to_primes(l n) {
vl factors;
auto p = primes.begin();
while (p != primes.end() && (*p) * (*p) <= n) {
while (n % *p == 0) {
factors.emplace_back(*p);
n /= *p;
}
p++;
}
if (n != 1) factors.emplace_back(n);
return factors;
}
l get_devisor(l x) {
auto factors = factorize_to_primes(x);
assert(factors.size());
if (factors[0] != x) return factors[0];
return 0;
}
l as_base(l n, l base) {
l m = 1;
l x = 0;
while (n) {
if (n & 1) x += m;
n >>= 1;
m *= base;
}
return x;
}
Result get_result(l x) {
Result r;
r.value = x;
for (l base = 2; base < 11; base++) {
l y = as_base(x, base);
l divisor = get_devisor(y);
if (!divisor) break;
r.divisors.emplace_back(divisor);
}
return r;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
primes = sieve_primes();
l tcc; cin >> tcc; // ignore
l n, j; cin >> n >> j;
l m = 1 + (1L << (n - 1));
cout << m << endl;
vector<Result> results;
for (l i = 0; results.size() < j && i < 1000; i++) {
l x = m + (i << 1);
auto r = get_result(x);
if (r.divisors.size() == 9) {
results.emplace_back(r);
}
}
cout << "Case #1:" << endl;
for (auto r : results) {
cout << as_base(r.value, 10);
for (auto d : r.divisors) cout << " " << d;
cout << endl;
}
}
| 22.247525 | 71 | 0.561193 | [
"vector"
] |
5e5b0ec8924f2df37a717f0beee99c76ee4eb854 | 52,660 | cpp | C++ | code/calculation/vortex.cpp | FreeCX/diploma | 3ebbbe1e9deae462a952b2f8c20a727039baf11b | [
"BSD-3-Clause"
] | null | null | null | code/calculation/vortex.cpp | FreeCX/diploma | 3ebbbe1e9deae462a952b2f8c20a727039baf11b | [
"BSD-3-Clause"
] | null | null | null | code/calculation/vortex.cpp | FreeCX/diploma | 3ebbbe1e9deae462a952b2f8c20a727039baf11b | [
"BSD-3-Clause"
] | null | null | null | #include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iostream>
#include <math.h>
#include <omp.h>
#include <sstream>
#include <stdint.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include "cppad/cppad.hpp"
#include "HLBFGS/HLBFGS.h"
#include "include/alglib/src/optimization.h"
// using OPENMP for parallel computation in HLBFGS
#define USE_OPENMP 1
using namespace alglib;
using namespace std;
using CppAD::AD;
double alpha1 = -1;
double alpha2 = -0.0069;
double ax = 0.025;
double ay = 0.025;
double beta1 = 1;
double beta2 = 0.0278;
double deltap = 0.000001;
double e = 0.7;
double epsilon = 0.001;
double etta = 0.0111;
double f1abs = 0;
double f1imag = 0;
double f1real = 0;
double f2abs = 0;
double f2imag = 0;
double f2real = 0;
double ksi1 = 1 / sqrt( 2 * abs( alpha1 ) );
double ksi2 = 1 / sqrt( 2 * abs( alpha2 ) );
double rax = 1 / ax;
double ray = 1 / ay;
double rdeltap = 1 / deltap;
double theta1, theta2, r1, r2;
double u10 = sqrt( abs( alpha1 / beta1 ) );
double u20 = sqrt( abs( alpha2 / beta2 ) );
int d = 1;
int iv1, jv1, iv2, jv2;
int Nx = 1200;
int Ny = 800;
std::complex<double> f1 = 0, f2 = 0;
std::complex<double> I( 0.0, 1.0 ), z1 = 0, z2 = 0;
vector< AD<double> > Y;
vector< AD<double> > X;
CppAD::ADFun<double> fun;
double **Axv, **Axy, **W, **T, **H2;
double **dAx, **dAy;
double **df1re, **df2re, **df1im, **df2im;
double *grad, *vars;
std::complex<double> *f1v, *f2v;
real_1d_array x;
uint32_t nextTime, predTime;
struct u_type {
char type[16];
char utype;
};
typedef struct u_type u_type_t;
struct p_block {
char name[32];
short utype;
int *ivalue;
float *fvalue;
double *dvalue;
};
typedef struct p_block p_block_t;
enum {
E_FAILED = -1,
E_SUCCESS = 0,
T_INT = 0,
T_FLOAT,
T_DOUBLE
};
u_type_t t[4] = {
{ "int", T_INT },
{ "float", T_FLOAT },
{ "double", T_DOUBLE },
{ 0 }
};
// parsing configuration file
int config_parser( const char *filename, int count, p_block_t *a )
{
char *p, utype, line[1024];
FILE *f;
int i;
f = fopen( filename, "r" );
if ( f == NULL ) {
return E_FAILED;
}
while ( !feof( f ) ) {
fgets( line, 1024, f );
p = strtok( line, " " );
for ( i = 0; t[i].type != NULL; i++ ) {
if ( strcmp( t[i].type, p ) == 0 ) {
utype = t[i].utype;
break;
}
}
p = strtok( NULL, " " );
if ( p == NULL ) {
break;
}
for ( i = 0; a[i].name != NULL; i++ ) {
if ( strcmp( a[i].name, p ) == 0 ) {
break;
}
}
if ( i > count ) {
continue;
}
a[i].utype = (char) utype;
p = strtok( NULL, "=" );
switch ( a[i].utype ) {
case T_INT:
*a[i].ivalue = strtol( p, (char **) NULL, 10 );
break;
case T_FLOAT:
*a[i].fvalue = strtof( p, (char **) NULL );
break;
case T_DOUBLE:
*a[i].dvalue = strtod( p, (char **) NULL );
break;
}
}
fclose( f );
return E_SUCCESS;
}
// get and print local time
void get_time( void )
{
struct tm *ti;
time_t raw;
char buffer[64];
time( &raw );
ti = localtime( &raw );
strftime( buffer, 64, "%d/%m/%y %H:%M:%S", ti );
puts( buffer );
}
// get cpu ticks
uint32_t get_ticks( void )
{
struct timeval tv;
gettimeofday( &tv, 0 );
return ( tv.tv_sec * 1000 + tv.tv_usec / 1000 );
}
// calculating potential energy associated with the node i,j coord
inline double CalculateW( int i, int j, double *vars )
{
double f1real = vars[( Ny + 1 ) * i + j];
double f1imag = vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )];
double f2real = vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )];
double f2imag = vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )];
double Theta1 = atan2( f1imag, f1real );
double Theta2 = atan2( f2imag, f2real );
double f1abs = f1real * f1real + f1imag * f1imag;
double f2abs = f2real * f2real + f2imag * f2imag;
double W = 0.5 * ( ( 2 * alpha1 + beta1 * f1abs ) * f1abs + ( 2 * alpha2 +
beta2 * f2abs ) * f2abs ) - etta * sqrt( f1abs * f2abs ) *
cos( Theta2 - Theta1 );
return W;
}
// calculating kinetic energy associated with the node i,j coord
inline double CalculateT( int i, int j, double *vars )
{
double f1xre;
double f2xre;
double f1yre;
double f2yre;
double f1xim;
double f2xim;
double f1yim;
double f2yim;
if ( i < Nx && j < Ny && i > 0 && j > 0 ) {
f1xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j] -
vars[( Ny + 1 ) * ( i - 1 ) + j] ) / 2 * rax;
f1xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * rax;
f2xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f2xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f1yre = ( vars[( Ny + 1 ) * i + j + 1] -
vars[( Ny + 1 ) * i + j - 1] ) / 2 * ray;
f1yim = ( vars[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * ray;
f2yre = ( vars[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * ray;
f2yim = ( vars[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * ray;
} else if ( i == 0 && j == 0 ) {
f1xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j] -
vars[( Ny + 1 ) * i + j] ) * rax;
f1xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( vars[( Ny + 1 ) * i + j + 1] -
vars[( Ny + 1 ) * i + j] ) * ray;
f1yim = ( vars[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( vars[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( vars[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i == 0 && j > 0 && j < Ny ) {
f1xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j] -
vars[( Ny + 1 ) * i + j] ) * rax;
f1xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( vars[( Ny + 1 ) * i + j + 1] -
vars[( Ny + 1 ) * i + j - 1] ) / 2 * ray;
f1yim = ( vars[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) / 2 * ray;
f2yre = ( vars[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * ray;
f2yim = ( vars[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * ray;
} else if ( i == 0 && j == Ny ) {
f1xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j] -
vars[( Ny + 1 ) * i + j] ) * rax;
f1xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( vars[( Ny + 1 ) * i + j] -
vars[( Ny + 1 ) * i + j - 1] ) * ray;
f1yim = ( vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i > 0 && i < Nx && j == 0 ) {
f1xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j] -
vars[( Ny + 1 ) * ( i - 1 ) + j] ) / 2 * rax;
f1xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * rax;
f2xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f2xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f1yre = ( vars[( Ny + 1 ) * i + j + 1] -
vars[( Ny + 1 ) * i + j] ) * ray;
f1yim = ( vars[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( vars[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( vars[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i > 0 && i < Nx && j == Ny ) {
f1xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j] -
vars[( Ny + 1 ) * ( i - 1 ) + j] ) / 2 * rax;
f1xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * rax;
f2xre = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f2xim = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - vars[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f1yre = ( vars[( Ny + 1 ) * i + j] -
vars[( Ny + 1 ) * i + j - 1] ) * ray;
f1yim = ( vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i == Nx && j == 0 ) {
f1xre = ( vars[( Ny + 1 ) * i + j] -
vars[( Ny + 1 ) * ( i - 1 ) + j] ) * rax;
f1xim = ( vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( vars[( Ny + 1 ) * i + j + 1] -
vars[( Ny + 1 ) * i + j] ) * ray;
f1yim = ( vars[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( vars[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( vars[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i == Nx && j > 0 && j < Ny ) {
f1xre = ( vars[( Ny + 1 ) * i + j] -
vars[( Ny + 1 ) * ( i - 1 ) + j] ) * rax;
f1xim = ( vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( vars[( Ny + 1 ) * i + j + 1] -
vars[( Ny + 1 ) * i + j - 1] ) / 2 * ray;
f1yim = ( vars[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) / 2 * ray;
f2yre = ( vars[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * ray;
f2yim = ( vars[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * ray;
} else if ( i == Nx && j == Ny ) {
f1xre = ( vars[( Ny + 1 ) * i + j] -
vars[( Ny + 1 ) * ( i - 1 ) + j] ) * rax;
f1xim = ( vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( vars[( Ny + 1 ) * i + j] -
vars[( Ny + 1 ) * i + j - 1] ) * ray;
f1yim = ( vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
vars[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
}
double Axf1re = vars[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] *
vars[( Ny + 1 ) * i + j];
double Axf1im = vars[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] *
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )];
double Axf2re = vars[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] *
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )];
double Axf2im = vars[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] *
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )];
double Ayf1re = vars[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] *
vars[( Ny + 1 ) * i + j];
double Ayf1im = vars[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] *
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )];
double Ayf2re = vars[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] *
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )];
double Ayf2im = vars[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] *
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )];
double T1x = ( f1xre - e * Axf1im ) * ( f1xre - e * Axf1im ) +
( f1xim + e * Axf1re ) * ( f1xim + e * Axf1re );
double T1y = ( f1yre - e * Ayf1im ) * ( f1yre - e * Ayf1im ) +
( f1yim + e * Ayf1re ) * ( f1yim + e * Ayf1re );
double T2x = ( f2xre - e * Axf2im ) * ( f2xre - e * Axf2im ) +
( f2xim + e * Axf2re ) * ( f2xim + e * Axf2re );
double T2y = ( f2yre - e * Ayf2im ) * ( f2yre - e * Ayf2im ) +
( f2yim + e * Ayf2re ) * ( f2yim + e * Ayf2re );
double T = 0.5 * ( ( T1x + T1y ) + ( T2x + T2y ) );
return T;
}
// calculating magnetic field associated with the node i,j coord
inline double CalculateH2( int i, int j, double *vars )
{
double Ay_up = ( vars[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] +
vars[( Ny + 1 ) * i + j + 1 + 5 * ( Nx + 1 ) * ( Ny + 1 )] ) / 2;
double Ay_down = ( vars[( Ny + 1 ) * ( i + 1 ) + j + 5 * ( Nx + 1 ) *
( Ny + 1 )] + vars[( Ny + 1 ) * ( i + 1 ) + j + 1 + 5 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2;
double Ax_right = ( vars[( Ny + 1 ) * i + j + 1 + 4 * ( Nx + 1 ) *
( Ny + 1 )] + vars[( Ny + 1 ) * ( i + 1 ) + j + 1 + 4 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2;
double Ax_left = ( vars[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] +
vars[( Ny + 1 ) * ( i + 1 ) + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] ) / 2;
double H = ( - Ay_up * ay + Ax_left * ax + Ay_down * ay - Ax_right * ax )
* rax * ray;
return 0.5 * H * H;
}
// calculating energy associated with the node i,j and your neighbor
inline double CalculateNeihbourF( int i, int j, double * x )
{
double F = 0.0;
for ( int ii = i - 1; ii <= i + 1; ii++ ) {
for ( int jj = j - 1; jj <= j + 1; jj++ ) {
if ( ( ii >= 0 ) && ( ii < Nx + 1 ) && ( jj >= 0 ) &&
( jj < Ny + 1 ) ) {
F += CalculateW( ii, jj, x ) + CalculateT( ii, jj, x );
}
}
}
if ( i < Nx && j < Ny && i > 0 && j > 0 ) {
F += CalculateH2( i - 1, j - 1, x ) + CalculateH2( i, j - 1, x ) +
CalculateH2( i - 1, j + 0, x ) + CalculateH2( i, j + 0, x );
} else if ( i == 0 && j == 0 ) {
F += CalculateH2( i, j, x );
} else if ( i == 0 && j > 0 && j < Ny ) {
F += CalculateH2( i, j - 1, x ) + CalculateH2( i, j, x );
} else if ( i == 0 && j == Ny ) {
F += CalculateH2( i, j - 1, x );
} else if ( i > 0 && i < Nx && j == 0 ) {
F += CalculateH2( i - 1, j, x ) + CalculateH2( i, j, x );
} else if ( i > 0 && i < Nx && j == Ny ) {
F += CalculateH2( i - 1, j - 1, x ) + CalculateH2( i, j - 1, x );
} else if ( i == Nx && j == 0 ) {
F += CalculateH2( i - 1, j, x );
} else if ( i == Nx && j > 0 && j < Ny ) {
F += CalculateH2( i - 1, j - 1, x ) + CalculateH2( i - 1, j, x );
} else if ( i == Nx && j == Ny ) {
F += CalculateH2( i - 1, j - 1, x );
}
return ax * ay * F;
}
void CalculateGradient( double *vars, double *grad )
{
double F1, F2;
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
// f1real
vars[( Ny + 1 ) * i + j] += deltap;
F1 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j] -= 2 * deltap;
F2 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j] += deltap;
grad[( Ny + 1 ) * i + j] = 0.5 * ( F1 - F2 ) * rdeltap;
// f1imag
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] += deltap;
F1 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -= 2 * deltap;
F2 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] += deltap;
grad[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] = 0.5 *
( F1 - F2 ) * rdeltap;
// f2real
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] += deltap;
F1 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -=
2 * deltap;
F2 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] += deltap;
grad[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] = 0.5 *
( F1 - F2 ) * rdeltap;
// f2imag
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] += deltap;
F1 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -=
2 * deltap;
F2 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] += deltap;
grad[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] = 0.5 *
( F1 - F2 ) * rdeltap;
// Ax
vars[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] += deltap;
F1 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] -=
2 * deltap;
F2 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] += deltap;
grad[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] = 0.5 *
( F1 - F2 ) * rdeltap;
// Ay
vars[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] += deltap;
F1 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] -=
2 * deltap;
F2 = CalculateNeihbourF( i, j, vars );
vars[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] += deltap;
grad[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] = 0.5 *
( F1 - F2 ) * rdeltap;
}
}
}
// fill table of energy node and square integration method
inline double FillEnergyTableSquare( double * x )
{
double F = 0.0;
double W0 = 0.0;
double T0 = 0.0;
double H20 = 0.0;
for ( int i = 0; i < Nx + 1; i ++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
W[i][j] = CalculateW( i, j, x );
T[i][j] = CalculateT( i, j, x );
F += T[i][j] + W[i][j];
}
}
for ( int i = 0; i < Nx; i++ ) {
for ( int j = 0; j < Ny; j++ ) {
H2[i][j] = CalculateH2( i, j, x );
F += H2[i][j];
}
}
return ax * ay * F;
}
// fill table of energy node and trapezoid integration method
inline double FillEnergyTableTrapz( double *x )
{
double F1 = 0.0;
double F2 = 0.0;
double W0 = 0.0;
double T0 = 0.0;
double H20 = 0.0;
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
W[i][j] = CalculateW( i, j, x );
T[i][j] = CalculateT( i, j, x );
}
}
F1 += T[0][0] + W[0][0];
F1 += T[Nx][Ny] + W[Nx][Ny];
F1 += T[0][Ny] + W[0][Ny];
F1 += T[Nx][0] + W[Nx][0];
for ( int i = 1; i < Nx; i++ ) {
F1 += 2 * ( T[i][0] + W[i][0] );
F1 += 2 * ( T[i][Ny] + W[i][Ny] );
}
for ( int j = 1; j < Ny; j++ ) {
F1 += 2 * ( T[0][j] + W[0][j] );
F1 += 2 * ( T[Nx][j] + W[Nx][j] );
}
for ( int i = 1; i < Nx; i++ ) {
for ( int j = 1; j < Ny; j++ ) {
F1 += 4 * ( T[i][j] + W[i][j] );
}
}
for ( int i = 0; i < Nx; i++ ) {
for ( int j = 0; j < Ny; j++ ) {
H2[i][j] = CalculateH2( i, j, x );
}
}
F2 += H2[0][0];
F2 += H2[Nx - 1][Ny - 1];
F2 += H2[0][Ny - 1];
F2 += H2[Nx - 1][0];
for ( int i = 1; i < Nx - 1; i++ ) {
F2 += 2 * H2[i][0];
F2 += 2 * H2[i][Ny - 1];
}
for ( int j = 1; j < Ny - 1; j++ ) {
F2 += 2 * H2[0][j];
F2 += 2 * H2[Nx - 1][j];
}
for ( int i = 1; i < Nx - 1; i++ ) {
for ( int j = 1; j < Ny - 1; j++ ) {
F2 += 4 * H2[i][j];
}
}
return 0.25 * ax * ay * ( F1 + F2 );
}
// calculating potential energy associated with the node i,j coord
template <class Type>
inline Type CalculateWPT( int i, int j, vector<Type> &varsp )
{
Type f1real = varsp[( Ny + 1 ) * i + j];
Type f1imag = varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )];
Type f2real = varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )];
Type f2imag = varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )];
Type Theta1 = CppAD::atan2( f1imag + 1e-30, f1real + 1e-30 );
Type Theta2 = CppAD::atan2( f2imag + 1e-30, f2real + 1e-30 );
Type f1abs = f1real * f1real + f1imag * f1imag + 1e-30;
Type f2abs = f2real * f2real + f2imag * f2imag + 1e-30;
Type W = 0;
W = 0.5 * ( ( 2 * alpha1 + beta1 * f1abs ) * f1abs +
( 2 * alpha2 + beta2 * f2abs ) * f2abs ) -
etta * sqrt( f1abs * f2abs ) * ( CppAD::cos( Theta2 - Theta1 ) );
return W;
}
// analytic calculating kinetic energy associated with the node i,j coord
template <class Type>
inline Type CalculateTPT( int i, int j, vector<Type> &varsp )
{
Type f1xre;
Type f2xre;
Type f1yre;
Type f2yre;
Type f1xim;
Type f2xim;
Type f1yim;
Type f2yim;
if ( i < Nx && j < Ny && i > 0 && j > 0 ) {
f1xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j] -
varsp[( Ny + 1 ) * ( i - 1 ) + j] ) / 2 * rax;
f1xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f2xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f2xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f1yre = ( varsp[( Ny + 1 ) * i + j + 1] -
varsp[( Ny + 1 ) * i + j - 1] ) / 2 * ray;
f1yim = ( varsp[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * ray;
f2yre = ( varsp[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * ray;
f2yim = ( varsp[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * ray;
} else if ( i == 0 && j == 0 ) {
f1xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j] -
varsp[( Ny + 1 ) * i + j] ) * rax;
f1xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( varsp[( Ny + 1 ) * i + j + 1] -
varsp[( Ny + 1 ) * i + j] ) * ray;
f1yim = ( varsp[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( varsp[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( varsp[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i == 0 && j > 0 && j < Ny ) {
f1xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j] -
varsp[( Ny + 1 ) * i + j] ) * rax;
f1xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( varsp[( Ny + 1 ) * i + j + 1] -
varsp[( Ny + 1 ) * i + j - 1] ) / 2 * ray;
f1yim = ( varsp[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) / 2 * ray;
f2yre = ( varsp[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * ray;
f2yim = ( varsp[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * ray;
} else if ( i == 0 && j == Ny ) {
f1xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j] -
varsp[( Ny + 1 ) * i + j] ) * rax;
f1xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( varsp[( Ny + 1 ) * i + j] -
varsp[( Ny + 1 ) * i + j - 1] ) * ray;
f1yim = ( varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i > 0 && i < Nx && j == 0 ) {
f1xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j] -
varsp[( Ny + 1 ) * ( i - 1 ) + j] ) / 2 * rax;
f1xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * rax;
f2xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f2xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f1yre = ( varsp[( Ny + 1 ) * i + j + 1] -
varsp[( Ny + 1 ) * i + j] ) * ray;
f1yim = ( varsp[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( varsp[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( varsp[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i > 0 && i < Nx && j == Ny ) {
f1xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j] -
varsp[( Ny + 1 ) * ( i - 1 ) + j] ) / 2 * rax;
f1xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] )
/ 2 * rax;
f2xre = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f2xim = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] - varsp[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * rax;
f1yre = ( varsp[( Ny + 1 ) * i + j] -
varsp[( Ny + 1 ) * i + j - 1] ) * ray;
f1yim = ( varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i == Nx && j == 0 ) {
f1xre = ( varsp[( Ny + 1 ) * i + j] -
varsp[( Ny + 1 ) * ( i - 1 ) + j] ) * rax;
f1xim = ( varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( varsp[( Ny + 1 ) * i + j + 1] -
varsp[( Ny + 1 ) * i + j] ) * ray;
f1yim = ( varsp[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( varsp[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( varsp[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
} else if ( i == Nx && j > 0 && j < Ny ) {
f1xre = ( varsp[( Ny + 1 ) * i + j] -
varsp[( Ny + 1 ) * ( i - 1 ) + j] ) * rax;
f1xim = ( varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( varsp[( Ny + 1 ) * i + j + 1] -
varsp[( Ny + 1 ) * i + j - 1] ) / 2 * ray;
f1yim = ( varsp[( Ny + 1 ) * i + j + 1 + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) / 2 * ray;
f2yre = ( varsp[( Ny + 1 ) * i + j + 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * ray;
f2yim = ( varsp[( Ny + 1 ) * i + j + 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2 * ray;
} else if ( i == Nx && j == Ny ) {
f1xre = ( varsp[( Ny + 1 ) * i + j] -
varsp[( Ny + 1 ) * ( i - 1 ) + j] ) * rax;
f1xim = ( varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + ( Nx + 1 ) * ( Ny + 1 )] ) * rax;
f2xre = ( varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f2xim = ( varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * ( i - 1 ) + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] ) * rax;
f1yre = ( varsp[( Ny + 1 ) * i + j] -
varsp[( Ny + 1 ) * i + j - 1] ) * ray;
f1yim = ( varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yre = ( varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 2 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
f2yim = ( varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] -
varsp[( Ny + 1 ) * i + j - 1 + 3 * ( Nx + 1 ) * ( Ny + 1 )] ) * ray;
}
Type Axf1re = varsp[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] *
varsp[( Ny + 1 ) * i + j];
Type Axf1im = varsp[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] *
varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )];
Type Axf2re = varsp[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] *
varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )];
Type Axf2im = varsp[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] *
varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )];
Type Ayf1re = varsp[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] *
varsp[( Ny + 1 ) * i + j];
Type Ayf1im = varsp[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] *
varsp[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )];
Type Ayf2re = varsp[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] *
varsp[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )];
Type Ayf2im = varsp[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] *
varsp[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )];
Type T1x = ( f1xre - e * Axf1im ) * ( f1xre - e * Axf1im ) +
( f1xim + e * Axf1re ) * ( f1xim + e * Axf1re );
Type T1y = ( f1yre - e * Ayf1im ) * ( f1yre - e * Ayf1im ) +
( f1yim + e * Ayf1re ) * ( f1yim + e * Ayf1re );
Type T2x = ( f2xre - e * Axf2im ) * ( f2xre - e * Axf2im ) +
( f2xim + e * Axf2re ) * ( f2xim + e * Axf2re );
Type T2y = ( f2yre - e * Ayf2im ) * ( f2yre - e * Ayf2im ) +
( f2yim + e * Ayf2re ) * ( f2yim + e * Ayf2re );
Type T = 0.5 * ( ( T1x + T1y ) + ( T2x + T2y ) );
return T;
}
// analytic calculation energy of magnetic field associated with node i,j coord
template <class Type>
inline Type CalculateH2PT( int i, int j, vector<Type> &varsp )
{
Type H;
Type Ay_up = ( varsp[( Ny + 1 ) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] +
varsp[( Ny + 1 ) * i + j + 1 + 5 * ( Nx + 1 ) * ( Ny + 1 )] ) / 2;
Type Ay_down = ( varsp[( Ny + 1 ) * ( i + 1 ) + j + 5 * ( Nx + 1 ) *
( Ny + 1 )] + varsp[( Ny + 1 ) * ( i + 1 ) + j + 1 + 5 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2;
Type Ax_right = ( varsp[( Ny + 1 ) * i + j + 1 + 4 * ( Nx + 1 ) *
( Ny + 1 )] + varsp[( Ny + 1 ) * ( i + 1 ) + j + 1 + 4 * ( Nx + 1 ) *
( Ny + 1 )] ) / 2;
Type Ax_left = ( varsp[( Ny + 1 ) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] +
varsp[( Ny + 1 ) * ( i + 1 ) + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] ) / 2;
H = ( - Ay_up * ay + Ax_left * ax + Ay_down * ay - Ax_right * ax ) *
rax * ray;
return 0.5 * H * H;
}
// analytic integration by the square method
template <class Type> inline Type EnergySquareT( vector<Type> &varsp )
{
Type F = 0.0;
Type W0 = 0.0;
Type T0 = 0.0;
Type H20 = 0.0;
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
F += CalculateWPT( i, j, varsp ) + CalculateTPT( i, j, varsp );
}
}
for ( int i = 0; i < Nx; i++ ) {
for ( int j = 0; j < Ny; j++ ) {
F += CalculateH2PT( i, j, varsp );
}
}
return ax * ay * F;
}
// analytic integration by the trapezoid method
template <class Type> inline Type EnergyTrapzT( vector<Type> &varsp )
{
Type F1 = 0.0;
Type F2 = 0.0;
Type W0 = 0.0;
Type T0 = 0.0;
Type H20 = 0.0;
F1 += CalculateWP( 0, 0, varsp ) + CalculateTP( 0, 0, varsp );
F1 += CalculateWP( Nx, Ny, varsp ) + CalculateTP( Nx, Ny, varsp );
F1 += CalculateWP( 0, Ny, varsp ) + CalculateTP( 0, Ny, varsp );
F1 += CalculateWP( Nx, 0, varsp ) + CalculateTP( Nx, 0, varsp );
for ( int i = 1; i < Nx; i++ ) {
F1 += 2 * ( CalculateWP( i, 0, varsp ) +
CalculateTP( i, 0, varsp ) );
F1 += 2 * ( CalculateWP( i, Ny, varsp ) +
CalculateTP( i, Ny, varsp ) );
}
for ( int j = 1; j < Ny; j++ ) {
F1 += 2 * ( CalculateWP( 0, j, varsp ) + CalculateTP( 0, j, varsp ) );
F1 += 2 * ( CalculateWP( Nx, j, varsp ) + CalculateTP( Nx, j, varsp ) );
}
for ( int i = 1; i < Nx; i++ ) {
for ( int j = 1; j < Ny; j++ ) {
F1 += 4 * ( CalculateWP( i, j, varsp ) +
CalculateTP( i, j, varsp ) );
}
}
F2 += CalculateH2P( 0, 0, varsp );
F2 += CalculateH2P( Nx - 1, Ny - 1, varsp );
F2 += CalculateH2P( 0, Ny - 1, varsp );
F2 += CalculateH2P( Nx - 1, 0, varsp );
for ( int i = 1; i < Nx - 1; i++ ) {
F2 += 2 * CalculateH2P( i, 0, varsp );
F2 += 2 * CalculateH2P( i, Ny - 1, varsp );
}
for ( int j = 1; j < Ny - 1; j++ ) {
F2 += 2 * CalculateH2P( 0, j, varsp );
F2 += 2 * CalculateH2P( Nx - 1, j, varsp );
}
for ( int i = 1; i < Nx - 1; i++ ) {
for ( int j = 1; j < Ny - 1; j++ ) {
F2 += 4 * CalculateH2P( i, j, varsp );
}
}
return 0.25 * ax * ay * ( F1 + F2 );
}
// block of minimization algorithm LBFGS from HLBFGS
void evalfunc( int n, double *x, double *prev_x, double *f, double *g )
{
double ff = FillEnergyTableSquare( x );
*f = ff;
vector<double> g1( n );
vector<double> xx( n );
for ( int i = 0; i < n; i++ ) {
xx[i] = x[i];
}
g1 = fun.Jacobian( xx );
for ( int i = 0; i < n; i++ ) {
g[i] = g1[i];
}
g1.clear();
}
// print information about new iteration
void newiteration( int iter, int call_iter, double *x, double *f, double *g,
double *gnorm )
{
nextTime = get_ticks();
printf( "[%u][%d]: %.8f %.8f %.8f\n", nextTime - predTime, call_iter,
*g, *f, *gnorm );
predTime = nextTime;
}
// main block of programm
int main( int argc, char *argv[] )
{
p_block_t block[] = {
{ "alpha1", T_DOUBLE, 0, 0, &alpha1 },
{ "alpha2", T_DOUBLE, 0, 0, &alpha2 },
{ "ax", T_DOUBLE, 0, 0, &ax },
{ "ay", T_DOUBLE, 0, 0, &ay },
{ "beta1", T_DOUBLE, 0, 0, &beta1 },
{ "beta2", T_DOUBLE, 0, 0, &beta2 },
{ "d", T_INT, &d },
{ "deltap", T_DOUBLE, 0, 0, &deltap },
{ "e", T_DOUBLE, 0, 0, &e },
{ "epsilon", T_DOUBLE, 0, 0, &epsilon },
{ "etta", T_DOUBLE, 0, 0, &etta },
{ "Nx", T_INT, &Nx },
{ "Ny", T_INT, &Ny },
{ NULL }
};
int k_file = 0, n = 0;
vector<string> names;
string word;
ifstream file;
if ( argc > 2 ) {
file.open( argv[1] );
if ( !file.is_open() ) {
printf( "[error]: can't open %s file!\n", argv[1] );
exit( EXIT_FAILURE );
}
while ( file >> word ) {
cout << word << endl;
names.push_back( word );
}
file.close();
} else {
printf( "usage: %s <file-list>\n", argv[0] );
exit( EXIT_FAILURE );
}
printf( ">> Start working [names = %lu]\n", names.size() );
while ( names.size() > (size_t) k_file ) {
printf( ">> Start Job#%02d [ %s ]\n", k_file, names[k_file].c_str() );
printf( ">> Time start: " );
get_time();
config_parser( names[k_file].c_str(), 13, block );
rax = 1 / ax;
ray = 1 / ay;
iv1 = Nx / 2 - d;
jv1 = Ny / 2;
iv2 = Nx / 2 + d;
jv2 = Ny / 2;
// allocation memory for array
n = 6 * ( Nx + 1 ) * ( Ny + 1 );
X.resize( n );
x.setlength( n );
df1re = new double *[Nx + 1];
df2re = new double *[Nx + 1];
df1im = new double *[Nx + 1];
df2im = new double *[Nx + 1];
W = new double *[Nx + 1];
T = new double *[Nx + 1];
vars = new double [n];
grad = new double [n];
H2 = new double *[Nx +1];
dAx = new double *[Nx + 1];
dAy = new double *[Nx + 1];
for ( int i = 0; i < Nx + 1; i++ ) {
df1re[i] = new double [Ny + 1];
df2re[i] = new double [Ny + 1];
df1im[i] = new double [Ny + 1];
df2im[i] = new double [Ny + 1];
W[i] = new double [Ny + 1];
T[i] = new double [Ny + 1];
dAx[i] = new double [Ny + 1];
dAy[i] = new double [Ny + 1];
H2[i] = new double [Ny + 1];
}
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
z1 = ( Nx / 2 - i - d ) * ax + I * ay * (double)( Ny / 2 - j );
z2 = ( Nx / 2 - i + d ) * ax + I * ay * (double)( Ny / 2 - j );
theta1 = arg( z1 );
theta2 = arg( z2 );
r1 = abs( z1 );
r2 = abs( z2 );
// initial configuration of the order parameter
if ( z1 == 0.0 || z2 == 0.0 ) {
vars[( Ny + 1 ) * i + j] = 0.0;
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] = 0.0;
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) *
( Ny + 1 )] = 0.0;
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) *
( Ny + 1 )] = 0.0;
} else {
f1 = u10 * sqrt( 0.5 + 0.5 *
tanh( 4.0 / ksi1 * ( r1 - ksi1 ) ) ) *
exp( I * theta1 ) * sqrt( 0.5 + 0.5 *
tanh( 4.0 / ksi1 * ( r2 - ksi1 ) ) ) *
exp( I * theta2 );
f2 = u20 * sqrt( 0.5 + 0.5 *
tanh( 4.0 / ksi2 * ( r2 - ksi2 ) ) ) *
exp( I * theta2 ) * sqrt( 0.5 + 0.5 *
tanh( 4.0 / ksi2 * ( r1 - ksi2 ) ) ) *
exp( I * theta1 );
vars[( Ny + 1 ) * i + j] = f1.real();
vars[( Ny + 1 ) * i + j + ( Nx + 1 ) * ( Ny + 1 )] =
f1.imag();
vars[( Ny + 1 ) * i + j + 2 * ( Nx + 1 ) * ( Ny + 1 )] =
f2.real();
vars[( Ny + 1 ) * i + j + 3 * ( Nx + 1 ) * ( Ny + 1 )] =
f2.imag();
}
// initial configuration of Ax
vars[(Ny + 1) * i + j + 4 * ( Nx + 1 ) * ( Ny + 1 )] =
1.0 / e / ( r1 + r2 ) * sin( theta1 + theta2 );
// initial configuration of Ay
vars[(Ny + 1) * i + j + 5 * ( Nx + 1 ) * ( Ny + 1 )] =
-1.0 / e / (r1 + r2) * cos( theta1 + theta2 );
}
}
// design function for automatic differentiation
for ( int i = 0; i < n; i++ ) {
X[i] = 1.0;
}
CppAD::Independent( X );
size_t m = 1;
Y.resize( m );
Y[0] = EnergySquareT( X );
fun = CppAD::ADFun<double>( X, Y );
// end design function for automatic differentiation
printf( ">> Start energy is %+.8f\n", FillEnergyTableSquare( vars ) );
double parameter[20];
parameter[6] = 0.01;
int info[20];
// initialize HLBFGS method
INIT_HLBFGS( parameter, info );
info[4] = 4000;
info[6] = 0;
info[7] = 0;
info[10] = 0;
info[11] = 1;
nextTime = get_ticks();
HLBFGS( n, 5, vars, evalfunc, 0, HLBFGS_UPDATE_Hessian, newiteration,
parameter, info );
// save results
char buffer[32];
sprintf( buffer, "job#%02d_%s", k_file, names[k_file].c_str() );
// put results in 'job#%02d_%s' format directory
#ifdef WIN32
mkdir( buffer );
#else
mkdir( buffer, S_IRWXU | S_IRGRP | S_IROTH );
#endif
chdir( buffer );
FILE *f;
// write result to file
f = fopen( "dataF1r.dat", "w" );
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
fprintf( f, "%+.16f ", vars[(Ny+1) * i+j] );
}
fprintf( f, "\n" );
}
fclose( f );
f = fopen( "dataF1c.dat", "w" );
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
fprintf( f, "%+.16f ", vars[(Ny+1) * i+j+(Nx+1) * (Ny+1)] );
}
fprintf( f, "\n" );
}
fclose( f );
f = fopen( "dataF2r.dat", "w" );
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++) {
fprintf( f, "%+.16f ", vars[(Ny+1) * i+j+2 * (Nx+1) * (Ny+1)] );
}
fprintf( f, "\n" );
}
fclose( f );
f = fopen( "dataF2c.dat", "w" );
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++) {
fprintf( f, "%+.16f ", vars[(Ny+1) * i+j+3 * (Nx+1) * (Ny+1)] );
}
fprintf( f, "\n" );
}
fclose( f );
f = fopen( "dataAx.dat", "w" );
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++) {
fprintf( f, "%+.16f ", vars[(Ny+1) * i+j+4 * (Nx+1) * (Ny+1)] );
}
fprintf( f, "\n" );
}
fclose( f );
f = fopen( "dataAy.dat", "w" );
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
fprintf( f, "%+.16f ", vars[(Ny+1) * i+j+5 * (Nx+1) * (Ny+1)] );
}
fprintf( f, "\n" );
}
fclose( f );
f = fopen( "dataB.dat", "w" );
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
fprintf( f, "%+.16f ", sqrt( 2 * H2[i][j] ) );
}
fprintf( f, "\n" );
}
fclose( f );
f = fopen( "dataW.dat", "w" );
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
fprintf( f, "%+.16f ", W[i][j] );
}
fprintf( f, "\n" );
}
fclose( f );
f = fopen( "dataT.dat", "w" );
for ( int i = 0; i < Nx + 1; i++ ) {
for ( int j = 0; j < Ny + 1; j++ ) {
fprintf( f, "%+.16f ", T[i][j] );
}
fprintf( f, "\n" );
}
fclose( f );
chdir( ".." );
k_file++;
// free allocating memory
for ( int i = 0; i < Nx + 1; i++ ) {
free( df1re[i] );
free( df2re[i] );
free( df1im[i] );
free( df2im[i] );
free( W[i] );
free( T[i] );
free( dAx[i] );
free( dAy[i] );
free( H2[i] );
}
free( vars );
free( grad );
free( df1re );
free( df2re );
free( df1im );
free( df2im );
free( W );
free( T );
free( H2 );
free( dAx );
free( dAy );
printf( ">> Time end: " );
get_time();
}
return EXIT_SUCCESS;
} | 42.027135 | 80 | 0.339651 | [
"vector"
] |
5e5bc9fb74d1fe7af207d47e5f1994c598cfcf9f | 15,910 | cpp | C++ | src/matUtils/merge.cpp | abschneider/usher | 2ebfe7013d69097427cce59585a3ee2edd98773b | [
"MIT"
] | 67 | 2020-09-18T23:10:37.000Z | 2022-02-02T17:58:19.000Z | src/matUtils/merge.cpp | abschneider/usher | 2ebfe7013d69097427cce59585a3ee2edd98773b | [
"MIT"
] | 132 | 2020-09-21T03:11:29.000Z | 2022-03-31T23:19:14.000Z | src/matUtils/merge.cpp | abschneider/usher | 2ebfe7013d69097427cce59585a3ee2edd98773b | [
"MIT"
] | 22 | 2020-09-18T20:28:21.000Z | 2022-03-24T12:17:33.000Z | #include "merge.hpp"
po::variables_map parse_merge_command(po::parsed_options parsed) {
uint32_t num_cores = tbb::task_scheduler_init::default_num_threads();
std::string num_threads_message = "Number of threads to use when possible [DEFAULT uses all available cores, " + std::to_string(num_cores) + " detected on this machine]";
po::variables_map vm;
po::options_description merge_desc("merge options");
merge_desc.add_options()("input-mat-1", po::value<std::string>()->required(),
"Input mutation-annotated tree file [REQUIRED]. If only this argument is set, print the count of samples and nodes in the tree.")
("input-mat-2", po::value<std::string>()->required(),
"Input mutation-annotated tree file [REQUIRED]. If only this argument is set, print the count of samples and nodes in the tree.")
("output-mat,o", po::value<std::string>()->required(),
"Write output files to the target directory. Default is current directory.")
("max-depth,d", po::value<uint32_t>()->default_value(20),
"Max depth to consider in the subtree rooted at the consistent node.")
("threads,T", po::value<uint32_t>()->default_value(num_cores), num_threads_message.c_str());
std::vector<std::string> opts = po::collect_unrecognized(parsed.options, po::include_positional);
opts.erase(opts.begin());
// Run the parser, with try/catch for help
try {
po::store(po::command_line_parser(opts)
.options(merge_desc)
.run(),
vm);
po::notify(vm);
} catch (std::exception &e) {
std::cerr << merge_desc << std::endl;
// Return with error code 1 unless the user specifies help
if (vm.count("help"))
exit(0);
else
exit(1);
}
return vm;
}
std::string get_first_leaf(MAT::Node* n) {
auto ret = n;
while (ret->children.size() > 0) {
ret = ret->children[0];
}
return ret->identifier;
}
/**
* Checks for consistency between both MAT files to ensure that they are able to merge
**/
bool consistent(MAT::Tree A, MAT::Tree B, concurMap& consistNodes) {
//vectors of all leaves in both input trees
std::vector<std::string> A_leaves = A.get_leaves_ids();
std::vector<std::string> B_leaves = B.get_leaves_ids();
tbb::parallel_sort(A_leaves.begin(), A_leaves.end());
tbb::parallel_sort(B_leaves.begin(), B_leaves.end());
//creates a vector of common_leaves between two input trees
std::vector<std::string> common_leaves;
set_intersection(B_leaves.begin(), B_leaves.end(), A_leaves.begin(), A_leaves.end(), std::back_inserter(common_leaves));
tbb::parallel_sort(common_leaves.begin(), common_leaves.end());
fprintf(stderr, "%zu common leaves.\n", common_leaves.size());
if (common_leaves.size() == 0) {
return true;
}
//creates two subtrees using the common_leaves
std::vector<std::string> A_to_remove, B_to_remove;
auto Asub = get_tree_copy(A);
std::set_difference(A_leaves.begin(), A_leaves.end(), common_leaves.begin(), common_leaves.end(), std::back_inserter(A_to_remove));
for (auto l : A_to_remove) {
Asub.remove_node(l, false);
}
Asub.remove_single_child_nodes();
auto Adfs = Asub.depth_first_expansion();
bool ret = true;
static tbb::affinity_partitioner ap;
/**
* Parallel loop that parses through the depth first expansion of
* both subtrees and compares each node's mutations
**/
tbb::mutex m;
tbb::parallel_for(
tbb::blocked_range<size_t>(0, Adfs.size()),
[&](tbb::blocked_range<size_t> r) {
for (size_t k = r.begin(); k < r.end(); ++k) {
auto n = Adfs[k];
if (n->children.size() > 1) {
auto c1 = n->children[0];
auto c2 = n->children[1];
auto l1 = get_first_leaf(c1);
auto l2 = get_first_leaf(c2);
auto lca1 = MAT::LCA(A, l1, l2);
auto lca2 = MAT::LCA(B, l1, l2);
if ((lca1 != NULL) && (lca2!= NULL)) {
consistNodes.emplace(std::pair<std::string, std::string> (lca2->identifier, lca1->identifier));
} else {
fprintf(stderr, "NULL found!\n");
}
}
if (n->children.size() == 0) {
consistNodes.emplace(std::pair<std::string, std::string> (n->identifier, n->identifier));
}
}
},
ap);
if (consistNodes.size() != Adfs.size()) {
fprintf (stderr, "WARNING: MATs not completely consistent!\n");
}
fprintf (stderr, "%zu of %zu nodes consistent.\n", consistNodes.size(), Adfs.size());
return ret;
}
void merge_main(po::parsed_options parsed) {
timer.Start();
//Takes user input and loads the specified MAT files
po::variables_map vm = parse_merge_command(parsed);
std::string mat1_filename = vm["input-mat-1"].as<std::string>();
std::string mat2_filename = vm["input-mat-2"].as<std::string>();
std::string output_filename = vm["output-mat"].as<std::string>();
uint32_t num_threads = vm["threads"].as<uint32_t>();
uint32_t max_levels = vm["max-depth"].as<uint32_t>();
fprintf(stderr, "Initializing %u worker threads.\n\n", num_threads);
tbb::task_scheduler_init init(num_threads);
fprintf(stderr, "Loading first input MAT. Existing clade annotations will be cleared\n");
MAT::Tree mat1 = MAT::load_mutation_annotated_tree(mat1_filename);
for (auto n: mat1.depth_first_expansion()) {
n->clear_annotations();
}
fprintf(stderr, "Completed in %ld msec \n\n", timer.Stop());
timer.Start();
fprintf(stderr, "Loading second input MAT. Existing clade annotations will be cleared\n");
MAT::Tree mat2 = MAT::load_mutation_annotated_tree(mat2_filename);
for (auto n: mat2.depth_first_expansion()) {
n->clear_annotations();
}
fprintf(stderr, "Completed in %ld msec \n\n", timer.Stop());
timer.Start();
fprintf(stderr, "Checking MAT consistency.\n");
MAT::Tree baseMat;
MAT::Tree otherMat;
concurMap consistNodes;
//uncondenses nodes of both MAT files
if (mat1.condensed_nodes.size() > 0) {
mat1.uncondense_leaves();
}
if (mat2.condensed_nodes.size() > 0) {
mat2.uncondense_leaves();
}
//Assigns largest MAT to baseMat and smaller one to otherMat
if (mat1.get_num_leaves() > mat2.get_num_leaves()) {
baseMat = mat1;
otherMat = mat2;
} else {
baseMat = mat2;
otherMat = mat1;
}
//Checks for consistency in mutation paths between the two trees
consistent(baseMat, otherMat, consistNodes);
fprintf(stderr, "Completed in %ld msec \n\n", timer.Stop());
timer.Start();
fprintf(stderr, "Finding new samples to merge\n");
//Makes a copy of the baseMat files to add the samples to later
MAT::Tree finalMat = get_tree_copy(baseMat);
std::vector<std::string> samples;
auto otherLeaves = otherMat.get_leaves_ids();
auto baseLeaves = baseMat.get_leaves_ids();
tbb::parallel_sort(otherLeaves.begin(), otherLeaves.end());
tbb::parallel_sort(baseLeaves.begin(), baseLeaves.end());
//creates vector of new samples to be added
std::set_difference(otherLeaves.begin(), otherLeaves.end(), baseLeaves.begin(), baseLeaves.end(), std::back_inserter(samples));
fprintf(stderr, "Completed in %ld msec \n\n", timer.Stop());
timer.Start();
static tbb::affinity_partitioner ap;
fprintf(stderr, "Merging %lu new samples\n", samples.size());
tbb::mutex m;
size_t num_mutex = 8*num_threads;
std::vector<tbb::mutex> m_vec(num_mutex);
std::map<std::string, size_t> node_to_first_sample;
//parallel loop that concurrently parses through all the new samples
int i = 0;
for (size_t k = 0; k < samples.size(); k++) {
std::string x = samples[k];
auto ancestors = otherMat.rsearch(x, true);
std::string curr = finalMat.root->identifier;
/**
* Parses through the the ancestors of each sample on otherMat and finds
* Closest consistent node on baseMat
**/
for (auto anc: ancestors) {
if (consistNodes.find(anc->identifier) != consistNodes.end()) {
curr = consistNodes[anc->identifier];
break;
}
}
MAT::Node s(x, -1);
s.mutations.clear();
for (int y = ancestors.size()-1; y >= 0; y--) {
for (auto m: ancestors[y]->mutations) {
s.add_mutation(m);
}
}
std::sort(s.mutations.begin(), s.mutations.end());
//Roots bfs at closest consistent node identified in previous loop
//Restricts tree search to a smaller subtree
auto bfs = finalMat.breadth_first_expansion(curr);
std::vector<std::vector<MAT::Mutation> > node_excess_mutations(bfs.size());
std::vector<std::vector<MAT::Mutation> > node_imputed_mutations(bfs.size());
size_t best_node_num_leaves = 0;
int best_set_difference = s.mutations.size() + bfs[0]->mutations.size() + 1;
size_t best_j = 0;
size_t num_best = 1;
bool best_node_has_unique = false;
MAT::Node *best_node = bfs[0];
std::vector<bool> node_has_unique(bfs.size(), false);
std::vector<size_t> best_j_vec;
best_j_vec.emplace_back(0);
tbb::parallel_for(
tbb::blocked_range<size_t>(0, bfs.size()),
[&](tbb::blocked_range<size_t> r) {
for (size_t k = r.begin(); k < r.end(); k++) {
if (bfs[k]->level - bfs[0]->level > max_levels) {
continue;
}
mapper2_input inp;
inp.T = &finalMat;
inp.node = bfs[k];
inp.missing_sample_mutations = &s.mutations;
inp.excess_mutations = &node_excess_mutations[k];
inp.imputed_mutations = &node_imputed_mutations[k];
inp.best_node_num_leaves = &best_node_num_leaves;
inp.best_set_difference = &best_set_difference;
inp.best_node = &best_node;
inp.best_j = &best_j;
inp.num_best = &num_best;
inp.j = k;
inp.has_unique = &best_node_has_unique;
inp.best_j_vec = &best_j_vec;
inp.node_has_unique = &(node_has_unique);
mapper2_body(inp, false);
}
}, ap);
if (finalMat.get_node(x) == NULL) {
// Is placement as sibling
if (best_node->is_leaf() || best_node_has_unique) {
m.lock();
std::string nid = finalMat.new_internal_node_id();
finalMat.create_node(nid, best_node->parent->identifier);
finalMat.create_node(x, nid);
finalMat.move_node(best_node->identifier, nid);
m.unlock();
// common_mut stores mutations common to the
// best node branch and the sample, l1_mut
// stores mutations unique to best node branch
// and l2_mut stores mutations unique to the
// sample not in best node branch
std::vector<MAT::Mutation> common_mut, l1_mut, l2_mut;
std::vector<MAT::Mutation> curr_l1_mut;
// Compute current best node branch mutations
for (auto m1 : best_node->mutations) {
MAT::Mutation m = m1.copy();
curr_l1_mut.emplace_back(m);
}
// Clear mutations on the best node branch which
// will be later replaced by l1_mut
best_node->clear_mutations();
// Compute l1_mut
for (auto m1 : curr_l1_mut) {
bool found = false;
for (auto m2 : node_excess_mutations[best_j]) {
if (m1.is_masked()) {
break;
}
if (m1.position == m2.position) {
if (m1.mut_nuc == m2.mut_nuc) {
found = true;
break;
}
}
}
if (!found) {
MAT::Mutation m = m1.copy();
l1_mut.emplace_back(m);
}
}
// Compute l2_mut
for (auto m1 : node_excess_mutations[best_j]) {
bool found = false;
for (auto m2 : curr_l1_mut) {
if (m1.is_masked()) {
break;
}
if (m1.position == m2.position) {
if (m1.mut_nuc == m2.mut_nuc) {
found = true;
MAT::Mutation m = m1.copy();
common_mut.emplace_back(m);
break;
}
}
}
if (!found) {
MAT::Mutation m = m1.copy();
l2_mut.emplace_back(m);
}
}
// Add mutations to new node using common_mut
for (auto m : common_mut) {
finalMat.get_node(nid)->add_mutation(m);
}
// Add mutations to best node using l1_mut
for (auto m : l1_mut) {
finalMat.get_node(best_node->identifier)->add_mutation(m);
}
// Add new sample mutations using l2_mut
for (auto m : l2_mut) {
finalMat.get_node(x)->add_mutation(m);
}
}
// Else placement as child
else {
m.lock();
finalMat.create_node(x, best_node->identifier);
MAT::Node *node = finalMat.get_node(x);
m.unlock();
std::vector<MAT::Mutation> node_mut;
std::vector<MAT::Mutation> curr_l1_mut;
for (auto m1 : best_node->mutations) {
MAT::Mutation m = m1.copy();
curr_l1_mut.emplace_back(m);
}
for (auto m1 : node_excess_mutations[best_j]) {
bool found = false;
for (auto m2 : curr_l1_mut) {
if (m1.is_masked()) {
break;
}
if (m1.position == m2.position) {
if (m1.mut_nuc == m2.mut_nuc) {
found = true;
break;
}
}
}
if (!found) {
MAT::Mutation m = m1.copy();
node_mut.emplace_back(m);
}
}
for (auto m : node_mut) {
node->add_mutation(m);
}
}
}
fprintf(stderr, "\rAdded %d of %zu samples", ++i, samples.size());
}
fprintf(stderr, "\n");
fprintf(stderr, "Completed in %ld msec \n\n", timer.Stop());
//Save final MAT file
timer.Start();
fprintf(stderr, "Condensing and saving final MAT\n");
finalMat.condense_leaves();
MAT::save_mutation_annotated_tree(finalMat, output_filename);
fprintf(stderr, "Completed in %ld msec \n\n", timer.Stop());
}
| 38.245192 | 174 | 0.540163 | [
"vector"
] |
5e5d93d0f7d45347605c1c6222597bcf0999e3f1 | 1,416 | cpp | C++ | game/city/infiltrationscreen.cpp | AndO3131/OpenApoc | 9dea1895e273a1da5a7d8eda173255f6b364e626 | [
"MIT"
] | null | null | null | game/city/infiltrationscreen.cpp | AndO3131/OpenApoc | 9dea1895e273a1da5a7d8eda173255f6b364e626 | [
"MIT"
] | null | null | null | game/city/infiltrationscreen.cpp | AndO3131/OpenApoc | 9dea1895e273a1da5a7d8eda173255f6b364e626 | [
"MIT"
] | null | null | null |
#include "game/city/infiltrationscreen.h"
#include "framework/framework.h"
namespace OpenApoc
{
InfiltrationScreen::InfiltrationScreen(Framework &fw)
: Stage(fw), menuform(fw.gamecore->GetForm("FORM_INFILTRATION_SCREEN"))
{
}
InfiltrationScreen::~InfiltrationScreen() {}
void InfiltrationScreen::Begin() {}
void InfiltrationScreen::Pause() {}
void InfiltrationScreen::Resume() {}
void InfiltrationScreen::Finish() {}
void InfiltrationScreen::EventOccurred(Event *e)
{
menuform->EventOccured(e);
fw.gamecore->MouseCursor->EventOccured(e);
if (e->Type == EVENT_KEY_DOWN)
{
if (e->Data.Keyboard.KeyCode == ALLEGRO_KEY_ESCAPE)
{
stageCmd.cmd = StageCmd::Command::POP;
return;
}
}
if (e->Type == EVENT_FORM_INTERACTION && e->Data.Forms.EventFlag == FormEventType::ButtonClick)
{
if (e->Data.Forms.RaisedBy->Name == "BUTTON_QUIT")
{
stageCmd.cmd = StageCmd::Command::POP;
return;
}
}
}
void InfiltrationScreen::Update(StageCmd *const cmd)
{
menuform->Update();
*cmd = this->stageCmd;
// Reset the command to default
this->stageCmd = StageCmd();
}
void InfiltrationScreen::Render()
{
fw.Stage_GetPrevious(this->shared_from_this())->Render();
fw.renderer->drawFilledRect({0, 0}, fw.Display_GetSize(), Colour{0, 0, 0, 128});
menuform->Render();
fw.gamecore->MouseCursor->Render();
}
bool InfiltrationScreen::IsTransition() { return false; }
}; // namespace OpenApoc
| 21.454545 | 96 | 0.711864 | [
"render"
] |
5e5dd5672ed5f69d39c9658923e05bea8d8b16c4 | 12,940 | cpp | C++ | copasi/UI/CQCompartmentDM.cpp | SzVarga/COPASI | 00451b1a67eeec8272c73791ca861da754a7c4c4 | [
"Artistic-2.0"
] | null | null | null | copasi/UI/CQCompartmentDM.cpp | SzVarga/COPASI | 00451b1a67eeec8272c73791ca861da754a7c4c4 | [
"Artistic-2.0"
] | null | null | null | copasi/UI/CQCompartmentDM.cpp | SzVarga/COPASI | 00451b1a67eeec8272c73791ca861da754a7c4c4 | [
"Artistic-2.0"
] | null | null | null | // Copyright (C) 2019 - 2020 by Pedro Mendes, Rector and Visitors of the
// University of Virginia, University of Heidelberg, and University
// of Connecticut School of Medicine.
// All rights reserved.
// Copyright (C) 2017 - 2018 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and University of
// of Connecticut School of Medicine.
// All rights reserved.
// Copyright (C) 2010 - 2016 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., University of Heidelberg, and The University
// of Manchester.
// All rights reserved.
// Copyright (C) 2009 by Pedro Mendes, Virginia Tech Intellectual
// Properties, Inc., EML Research, gGmbH, University of Heidelberg,
// and The University of Manchester.
// All rights reserved.
#include <QtCore/QString>
#include "CQCompartmentDM.h"
#include "CQMessageBox.h"
#include "qtUtilities.h"
#include "copasi/model/CReaction.h"
#include "copasi/model/CMetab.h"
#include "copasi/model/CReactionInterface.h"
#include "copasi/model/CEvent.h"
#include "copasi/UI/CQCopasiApplication.h"
#include "copasi/copasi.h"
#include "copasi/CopasiDataModel/CDataModel.h"
#include "copasi/core/CRootContainer.h"
#include "copasi/model/CCompartment.h"
#include "copasi/model/CModel.h"
#include "copasi/function/CExpression.h"
#include "copasi/undo/CUndoData.h"
CQCompartmentDM::CQCompartmentDM(QObject *parent)
: CQBaseDataModel(parent, NULL)
, mpCompartments(NULL)
{
mTypes.push_back(FROM_UTF8(CModelEntity::StatusName[CModelEntity::Status::FIXED]));
mTypes.push_back(FROM_UTF8(CModelEntity::StatusName[CModelEntity::Status::ASSIGNMENT]));
mTypes.push_back(FROM_UTF8(CModelEntity::StatusName[CModelEntity::Status::ODE]));
mUnits.append("?");
mUnits.append("?");
mUnits.append("?");
mUnits.append("?");
}
const QStringList& CQCompartmentDM::getTypes()
{
return mTypes;
}
size_t CQCompartmentDM::size() const
{
if (mpCompartments != NULL)
return mpCompartments->size();
return 0;
}
int CQCompartmentDM::rowCount(const QModelIndex& C_UNUSED(parent)) const
{
return mFetched + 1;
}
int CQCompartmentDM::columnCount(const QModelIndex&) const
{
return TOTAL_COLS_COMPARTMENTS;
}
Qt::ItemFlags CQCompartmentDM::flags(const QModelIndex &index) const
{
if (!index.isValid())
return Qt::ItemIsEnabled;
if (index.column() == COL_NAME_COMPARTMENTS || index.column() == COL_TYPE_COMPARTMENTS)
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
else if (index.column() == COL_IVOLUME)
{
if (this->index(index.row(), COL_TYPE_COMPARTMENTS).data() == QString(FROM_UTF8(CModelEntity::StatusName[CModelEntity::Status::ASSIGNMENT])))
return QAbstractItemModel::flags(index) & ~Qt::ItemIsEnabled;
else
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsEnabled;
}
else
return QAbstractItemModel::flags(index);
}
QVariant CQCompartmentDM::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= rowCount())
return QVariant();
if (index.column() > 0 && role == Qt::ForegroundRole && !(flags(index) & Qt::ItemIsEditable))
return QColor(Qt::darkGray);
if (role == Qt::DisplayRole || role == Qt::EditRole)
{
if (isDefaultRow(index) || index.row() >= (int) mpCompartments->size())
{
switch (index.column())
{
case COL_ROW_NUMBER:
return QVariant(QString(""));
case COL_NAME_COMPARTMENTS:
return QVariant(QString("New Compartment"));
case COL_TYPE_COMPARTMENTS:
return QVariant(QString(FROM_UTF8(CModelEntity::StatusName[CModelEntity::Status::FIXED])));
case COL_IVOLUME:
return QVariant(convertToQString(1.0));
default:
return QVariant(QString(""));
}
}
else
{
CCompartment & Compartment = mpCompartments->operator[](index.row());
const CExpression * pExpression = NULL;
switch (index.column())
{
case COL_ROW_NUMBER:
return QVariant(index.row() + 1);
case COL_NAME_COMPARTMENTS:
return QVariant(QString(FROM_UTF8(Compartment.getObjectName())));
case COL_TYPE_COMPARTMENTS:
return QVariant(QString(FROM_UTF8(CModelEntity::StatusName[Compartment.getStatus()])));
case COL_UNIT_COMPARTMENTS:
return QVariant(mUnits[Compartment.getDimensionality()]);
case COL_IVOLUME:
if (role == Qt::EditRole)
return QVariant(convertToQString(Compartment.getInitialValue()));
else
return QVariant(Compartment.getInitialValue());
case COL_VOLUME:
return QVariant(Compartment.getValue());
case COL_RATE_COMPARTMENTS:
return QVariant(Compartment.getRate());
case COL_IEXPRESSION_COMPARTMENTS:
{
pExpression = Compartment.getInitialExpressionPtr();
if (pExpression != NULL)
return QVariant(QString(FROM_UTF8(pExpression->getDisplayString())));
else
return QVariant();
}
case COL_EXPRESSION_COMPARTMENTS:
{
pExpression = Compartment.getExpressionPtr();
if (pExpression != NULL)
return QVariant(QString(FROM_UTF8(pExpression->getDisplayString())));
else
return QVariant();
}
case COL_NEXPRESSION_COMPARTMENTS:
{
pExpression = Compartment.getNoiseExpressionPtr();
if (Compartment.hasNoise() && pExpression != NULL)
return QVariant(QString(FROM_UTF8(pExpression->getDisplayString())));
else
return QVariant();
}
}
}
}
return QVariant();
}
QVariant CQCompartmentDM::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (role != Qt::DisplayRole)
return QVariant();
std::string tmp = CUnit::prettyPrint("1/(" + mpDataModel->getModel()->getTimeUnit() + ")");
QString ValueUnit = "[Unit]";
QString RateUnit = (tmp != "?") ? "[Unit" + FROM_UTF8(tmp.substr(1)) + "]" : "[?]";
if (orientation == Qt::Horizontal)
{
switch (section)
{
case COL_ROW_NUMBER:
return QVariant(QString("#"));
case COL_NAME_COMPARTMENTS:
return QVariant(QString("Name"));
case COL_TYPE_COMPARTMENTS:
return QVariant(QString(" Type "));
case COL_UNIT_COMPARTMENTS:
return QVariant("Unit");
case COL_IVOLUME:
return QVariant("Initial Size\n" + ValueUnit);
case COL_VOLUME:
return QVariant("Size\n" + ValueUnit);
case COL_RATE_COMPARTMENTS:
return QVariant("Rate\n" + RateUnit);
case COL_IEXPRESSION_COMPARTMENTS:
return QVariant("Initial Expression\n" + ValueUnit);
case COL_EXPRESSION_COMPARTMENTS:
if (ValueUnit == RateUnit)
return QVariant("Expression\n" + ValueUnit);
else
return QVariant("Expression\n" + ValueUnit + " or " + RateUnit);
case COL_NEXPRESSION_COMPARTMENTS:
return QVariant("Noise Expression");
default:
return QVariant();
}
}
else //Vertical header
return QString("%1").arg(section + 1);
}
bool CQCompartmentDM::setData(const QModelIndex &index,
const QVariant &value,
int role)
{
QVariant data = index.data();
if (data == value)
return false;
if (isDefaultRow(index) && data != value)
{
insertNewRows(rowCount(), 1, index.column(), value);
}
else if (role == Qt::EditRole)
{
CCompartment & Compartment = mpCompartments->operator[](index.row());
CData OldData = Compartment.toData();
switch (index.column())
{
case COL_NAME_COMPARTMENTS:
if (mpCompartments->getIndex(TO_UTF8(value.toString())) == C_INVALID_INDEX)
{
Compartment.setObjectName(TO_UTF8(value.toString()));
}
break;
case COL_TYPE_COMPARTMENTS:
Compartment.setStatus(CModelEntity::StatusName.toEnum(TO_UTF8(value.toString())));
break;
case COL_IVOLUME:
Compartment.setInitialValue(value.toDouble());
break;
}
CUndoData UndoData;
Compartment.createUndoData(UndoData, CUndoData::Type::CHANGE, OldData, (CCore::Framework) mFramework);
if (!UndoData.empty())
{
ListViews::addUndoMetaData(this, UndoData);
emit signalNotifyChanges(mpDataModel->recordData(UndoData));
}
}
return true;
}
// virtual
void CQCompartmentDM::resetCacheProtected()
{
mpCompartments = dynamic_cast< CDataVectorNS < CCompartment > * >(&mpDataModel->getModel()->getCompartments());
assert(mpCompartments != NULL);
CModel * pModel = mpDataModel->getModel();
assert(pModel != NULL);
mUnits[0] = "1";
mUnits[1] = FROM_UTF8(CUnit::prettyPrint(pModel->getLengthUnit()));
mUnits[2] = FROM_UTF8(CUnit::prettyPrint(pModel->getAreaUnit()));
mUnits[3] = FROM_UTF8(CUnit::prettyPrint(pModel->getVolumeUnit()));
}
bool CQCompartmentDM::insertRows(int position, int rows, const QModelIndex & parent)
{
insertNewRows(position, rows);
return true;
}
bool CQCompartmentDM::removeRows(int position, int rows, const QModelIndex & parent)
{
if (rows <= 0)
return true;
beginRemoveRows(parent, position, position + rows - 1);
std::vector< const CCompartment * > ToBeDeleted;
ToBeDeleted.resize(rows);
std::vector< const CCompartment * >::iterator it = ToBeDeleted.begin();
std::vector< const CCompartment * >::iterator end = ToBeDeleted.end();
CDataVector< CCompartment >::const_iterator itRow = mpCompartments->begin() + position;
for (; it != end; ++it, ++itRow)
{
*it = &*itRow;
}
for (it = ToBeDeleted.begin(); it != end; ++it)
{
CUndoData UndoData;
(*it)->createUndoData(UndoData, CUndoData::Type::REMOVE);
ListViews::addUndoMetaData(this, UndoData);
--mFetched;
emit signalNotifyChanges(mpDataModel->applyData(UndoData));
}
endRemoveRows();
return true;
}
bool CQCompartmentDM::removeRows(QModelIndexList rows, const QModelIndex& index)
{
if (rows.isEmpty())
return false;
// Build the list of pointers to items to be deleted
// before actually deleting any item.
QList <CCompartment *> Compartments;
QModelIndexList::const_iterator i;
for (i = rows.begin(); i != rows.end(); ++i)
if (!isDefaultRow(*i) &&
&mpCompartments->operator[](i->row()) != NULL)
{
Compartments.append(&mpCompartments->operator[](i->row()));
}
QList< CCompartment * >::const_iterator j;
for (j = Compartments.begin(); j != Compartments.end(); ++j)
{
CCompartment * pCompartment = *j;
QMessageBox::StandardButton choice =
CQMessageBox::confirmDelete(ListViews::ancestor(this), "compartment",
FROM_UTF8(pCompartment->getObjectName()),
pCompartment);
if (choice == QMessageBox::Ok)
{
removeRows(mpCompartments->getIndex(pCompartment->getObjectName()), 1);
}
}
return true;
}
void CQCompartmentDM::insertNewRows(int position, int rows, int column, const QVariant & value)
{
beginInsertRows(QModelIndex(), position, position + rows - 1);
for (int row = 0; row < rows; ++row)
{
QString name = createNewName(column == COL_NAME_COMPARTMENTS ? value.toString() : "compartment", COL_NAME_COMPARTMENTS);
CCompartment * pComp = mpDataModel->getModel()->createCompartment(TO_UTF8(name));
if (pComp == NULL)
continue;
++mFetched;
if (column == COL_TYPE_COMPARTMENTS)
{
pComp->setStatus(CModelEntity::StatusName.toEnum(TO_UTF8(value.toString())));
}
if (column == COL_IVOLUME)
{
pComp->setInitialValue(value.toDouble());
}
CUndoData UndoData(CUndoData::Type::INSERT, pComp);
ListViews::addUndoMetaData(this, UndoData);
emit signalNotifyChanges(mpDataModel->recordData(UndoData));
}
endInsertRows();
}
bool CQCompartmentDM::clear()
{
QModelIndexList rows;
for (int i = 0; i < (int) mpCompartments->size(); i++)
{
rows.append(index(i, 0));
}
return removeRows(rows);
}
| 29.078652 | 147 | 0.622025 | [
"vector",
"model"
] |
5e5fb7f5a3164d61bee7904c0b440b3c66f32056 | 5,174 | hpp | C++ | include/carve/polyhedron_decl.hpp | pcamarillor/Exploratory3D | 10705d201376b98bdf8f19fca398a3bf341807c9 | [
"MIT"
] | null | null | null | include/carve/polyhedron_decl.hpp | pcamarillor/Exploratory3D | 10705d201376b98bdf8f19fca398a3bf341807c9 | [
"MIT"
] | null | null | null | include/carve/polyhedron_decl.hpp | pcamarillor/Exploratory3D | 10705d201376b98bdf8f19fca398a3bf341807c9 | [
"MIT"
] | null | null | null | // Begin License:
// Copyright (C) 2006-2008 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of the GNU General Public
// License version 2.0 as published by the Free Software Foundation
// and appearing in the file LICENSE.GPL2 included in the packaging of
// this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#pragma once
#include <carve/carve.hpp>
#include <carve/geom3d.hpp>
#include <carve/polyhedron_base.hpp>
#include <carve/octree_decl.hpp>
#include <carve/collection_types.hpp>
#include <assert.h>
#include <list>
namespace carve {
namespace poly {
class EdgeConnectivityInfo;
struct Polyhedron : public Geometry<3> {
private:
Polyhedron(); // not implemented
Polyhedron &operator=(const Polyhedron &); // not implemented
// *** initialization
bool initSpatialIndex();
void initVertexConnectivity();
bool initEdgeConnectivity(const EdgeConnectivityInfo &);
void buildEdgeFaceMap(EdgeConnectivityInfo &);
void setFaceAndVertexOwner();
bool initConnectivity();
bool markManifolds();
bool calcManifoldEmbedding();
bool init();
void faceRecalc();
void commonFaceInit(bool _recalc);
public:
typedef std::unordered_map<const vertex_t *, const vertex_t *, hash_vertex_ptr> VVMap;
static void collectFaceVertices(std::vector<face_t > &faces,
std::vector<vertex_t > &vertices,
carve::csg::VVMap &vmap);
static void collectFaceVertices(std::vector<face_t > &faces,
std::vector<vertex_t > &vertices);
std::vector<bool> manifold_is_closed;
std::vector<bool> manifold_is_negative;
carve::geom3d::AABB aabb;
carve::csg::Octree octree;
// *** construction of Polyhedron objects
Polyhedron(const Polyhedron &);
// copy a single manifold
Polyhedron(const Polyhedron &, int m_id);
// copy a subset of manifolds
Polyhedron(const Polyhedron &, const std::vector<bool> &selected_manifolds);
Polyhedron(std::vector<face_t > &_faces,
std::vector<vertex_t > &_vertices,
bool _recalc = false);
Polyhedron(std::vector<face_t > &_faces,
bool _recalc = false);
Polyhedron(std::list<face_t > &_faces,
bool _recalc = false);
Polyhedron(const std::vector<carve::geom3d::Vector> &vertices,
int n_faces,
const std::vector<int> &face_indices);
~Polyhedron();
// *** containment queries
void testVertexAgainstClosedManifolds(const carve::geom3d::Vector &v,
std::map<int, PointClass> &result,
bool ignore_orentation) const;
PointClass containsVertex(const carve::geom3d::Vector &v,
const face_t **hit_face = NULL,
bool even_odd = false,
int manifold_id = -1) const;
// *** locality queries
void findEdgesNear(const carve::geom::aabb<3> &aabb, std::vector<const edge_t *> &edges) const;
void findEdgesNear(const carve::geom3d::LineSegment &l, std::vector<const edge_t *> &edges) const;
void findEdgesNear(const carve::geom3d::Vector &v, std::vector<const edge_t *> &edges) const;
void findEdgesNear(const face_t &face, std::vector<const edge_t *> &edges) const;
void findEdgesNear(const edge_t &edge, std::vector<const edge_t *> &edges) const;
void findFacesNear(const carve::geom::aabb<3> &aabb, std::vector<const face_t *> &faces) const;
void findFacesNear(const carve::geom3d::LineSegment &l, std::vector<const face_t *> &faces) const;
void findFacesNear(const edge_t &edge, std::vector<const face_t *> &faces) const;
// *** manifold queries
inline bool vertexOnManifold(const vertex_t *v, int m_id) const;
inline bool edgeOnManifold(const edge_t *e, int m_id) const;
template<typename T>
int vertexManifolds(const vertex_t *v, T result) const;
template<typename T>
int edgeManifolds(const edge_t *e, T result) const;
size_t manifoldCount() const;
bool hasOpenManifolds() const;
// *** transformation
// flip face directions
void invertAll();
void invert(const std::vector<bool> &selected_manifolds);
void invert(int m_id);
void invert();
// matrix transform of vertices
void transform(const carve::math::Matrix &xform);
// arbitrary function transform of vertices
template<typename T>
void transform(const T &xform);
void print(std::ostream &) const;
void canonicalize();
};
std::ostream &operator<<(std::ostream &, const Polyhedron &);
}
}
| 29.067416 | 104 | 0.628334 | [
"geometry",
"vector",
"transform"
] |
5e61c5c6bd05b7d65240f8f890e359d8d6b86bf8 | 11,082 | cpp | C++ | test/uri_test.cpp | Olipro/foxy | 280975d1289beed476d4748fc77441b39c9a0ec7 | [
"BSL-1.0"
] | 74 | 2017-10-28T12:46:15.000Z | 2021-08-19T12:04:39.000Z | test/uri_test.cpp | Olipro/foxy | 280975d1289beed476d4748fc77441b39c9a0ec7 | [
"BSL-1.0"
] | 7 | 2018-01-21T21:18:01.000Z | 2020-12-22T20:24:45.000Z | test/uri_test.cpp | Olipro/foxy | 280975d1289beed476d4748fc77441b39c9a0ec7 | [
"BSL-1.0"
] | 8 | 2019-04-01T21:18:05.000Z | 2021-08-11T17:30:43.000Z | //
// Copyright (c) 2018-2019 Christian Mazakas (christian dot mazakas at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/LeonineKing1199/foxy
//
#include <foxy/uri.hpp>
#include <boost/utility/string_view.hpp>
#include <vector>
#include <algorithm>
#include <catch2/catch.hpp>
namespace x3 = boost::spirit::x3;
TEST_CASE("uri_test")
{
SECTION("should parse the sub-delims")
{
auto const delims =
std::vector<boost::string_view>{"!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="};
auto const matched_all_sub_delims =
std::all_of(delims.begin(), delims.end(), [](auto const delim) -> bool {
auto begin = delim.begin();
auto const end = delim.end();
return x3::parse(begin, end, foxy::uri::sub_delims);
});
CHECK(matched_all_sub_delims);
auto view = boost::string_view("rawr");
auto begin = view.begin();
auto const end = view.end();
auto const non_match = !x3::parse(begin, end, foxy::uri::sub_delims);
CHECK(non_match);
}
SECTION("should parse the gen-delims")
{
auto const delims = std::vector<boost::string_view>{":", "/", "?", "#", "[", "]", "@"};
auto const matched_all_gen_delims =
std::all_of(delims.begin(), delims.end(), [](auto const delim) -> bool {
auto begin = delim.begin();
auto const end = delim.end();
return x3::parse(begin, end, foxy::uri::gen_delims);
});
CHECK(matched_all_gen_delims);
auto view = boost::string_view("rawr");
auto begin = view.begin();
auto const end = view.end();
auto const non_match = !x3::parse(begin, end, foxy::uri::gen_delims);
CHECK(non_match);
}
SECTION("should parse the reserved")
{
auto const delims = std::vector<boost::string_view>{
":", "/", "?", "#", "[", "]", "@", "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="};
auto const matched_all_reserved =
std::all_of(delims.begin(), delims.end(), [](auto const delim) -> bool {
auto begin = delim.begin();
auto const end = delim.end();
return x3::parse(begin, end, foxy::uri::reserved);
});
CHECK(matched_all_reserved);
{
auto view = boost::string_view("rawr");
auto begin = view.begin();
auto const end = view.end();
auto const non_match = !x3::parse(begin, end, foxy::uri::reserved);
CHECK(non_match);
}
{
auto view = boost::string_view("~~~~Leonine.King1199__---");
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, +foxy::uri::unreserved);
CHECK(match);
CHECK(begin == end);
}
}
SECTION("should support percent encoded parsing")
{
auto view = boost::string_view("%5B");
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::pct_encoded);
CHECK(match);
CHECK(begin == end);
}
SECTION("should support the pchar")
{
// unreserved + ":@" portion of pchar
//
{
auto view = boost::string_view("~~:~~Le@on@ine.King1199__--:-");
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, +foxy::uri::pchar);
CHECK(match);
CHECK(begin == end);
}
// pct_encoded portion of pchar
//
{
auto view = boost::string_view("%5B");
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::pchar);
CHECK(match);
CHECK(begin == end);
}
// sub_delims portion of pchar
//
{
auto const delims =
std::vector<boost::string_view>{"!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="};
auto const matched_all_sub_delims =
std::all_of(delims.begin(), delims.end(), [](auto const delim) -> bool {
auto begin = delim.begin();
auto const end = delim.end();
return x3::parse(begin, end, foxy::uri::pchar);
});
CHECK(matched_all_sub_delims);
}
}
SECTION("should support query/fragment parsing")
{
{
auto view = boost::string_view("/lol?asdfasdfasdf");
auto begin = view.begin();
auto const end = view.end();
auto const match1 = x3::parse(begin, end, foxy::uri::query);
begin = view.begin();
auto const match2 = x3::parse(begin, end, foxy::uri::fragment);
CHECK((match1 && match2));
}
}
SECTION("should support decimal octet parsing")
{
auto const valid_inputs = std::vector<boost::string_view>{
"0", "1", "9", "10", "99", "100", "199", "200", "249", "250", "255"};
auto const all_match =
std::all_of(valid_inputs.begin(), valid_inputs.end(), [](auto const view) -> bool {
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::dec_octet);
auto const full_match = match && (begin == end);
return full_match;
});
CHECK(all_match);
auto const invalid_inputs =
std::vector<boost::string_view>{"lolol", "-1", "256", "010", "01", "267", "1337"};
auto const none_match =
std::all_of(invalid_inputs.begin(), invalid_inputs.end(), [](auto const view) -> bool {
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::dec_octet);
if (match) { return begin != end; }
return !match;
});
CHECK(none_match);
}
SECTION("should support IPv4 address parsing")
{
auto const valid_inputs =
std::vector<boost::string_view>{"127.0.0.1", "255.255.255.255", "0.0.0.0", "192.68.0.27"};
auto const all_match =
std::all_of(valid_inputs.begin(), valid_inputs.end(), [](auto const view) -> bool {
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::ip_v4_address);
auto const full_match = match && (begin == end);
return full_match;
});
CHECK(all_match);
auto const invalid_inputs = std::vector<boost::string_view>{
"127.0.0.01", "255.255.255.255.255", "a.b.c.d", "192.68.334340.2227", "127.0.1"};
auto const none_match =
std::all_of(invalid_inputs.begin(), invalid_inputs.end(), [](auto const view) -> bool {
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::ip_v4_address);
if (match) { return begin != end; }
return !match;
});
CHECK(none_match);
}
SECTION("should support IPv6 address parsing")
{
auto const valid_inputs =
std::vector<boost::string_view>{"3ffe:1900:4545:3:200:f8ff:fe21:67cf",
"fe80:0:0:0:200:f8ff:fe21:67cf",
"2001:0db8:0a0b:12f0:0000:0000:0000:0001",
"2001:db8:3333:4444:5555:6666:7777:8888",
"2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF",
"::",
"2001:db8::",
"::1234:5678",
"2001:db8::1234:5678",
"2001:0db8:0001:0000:0000:0ab9:C0A8:0102",
"2001:db8:1::ab9:C0A8:102",
"684D:1111:222:3333:4444:5555:6:77",
"0:0:0:0:0:0:0:0"};
auto const all_match =
std::all_of(valid_inputs.begin(), valid_inputs.end(), [](auto const view) -> bool {
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::ip_v6_address);
auto const full_match = match && (begin == end);
return full_match;
});
CHECK(all_match);
auto const invalid_inputs = std::vector<boost::string_view>{};
auto const none_match =
std::all_of(invalid_inputs.begin(), invalid_inputs.end(), [](auto const view) -> bool {
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::ip_v6_address);
if (match) { return begin != end; }
return !match;
});
CHECK(none_match);
}
SECTION("should support URI parsing")
{
auto const valid_inputs =
std::vector<boost::string_view>{"https://www.google.com",
"http://example.com/",
"http://goo%20%20goo%7C%7C.com/",
"http://a.com/",
"http://192.168.0.1/",
"http://xn--6qqa088eba/",
"foobar://www.example.com:80/",
"http://example.com/foo%09%C2%91%93",
"http://example.com/%7Ffp3%3Eju%3Dduvgw%3Dd",
"http://www.example.com/?%02hello%7F%20bye",
"http://www.example.com/?q=%26%2355296%3B%26%2355296%3B",
"http://www.example.com/?foo=bar",
"http://www.example.com/#hello",
"http://www.example.com/#%23asdf",
"http:",
"asdf:jkl;",
"foof://:;@[::]/@;:??:;@/~@;://#//:;@~/@;:\?\?//:foof",
"http://ay%40lmao:password@[fe80::]/p@th?q=@lol"};
auto const all_match =
std::all_of(valid_inputs.begin(), valid_inputs.end(), [](auto const view) -> bool {
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::uri);
auto const full_match = match && (begin == end);
return full_match;
});
CHECK(all_match);
auto const invalid_inputs =
std::vector<boost::string_view>{"http://192.168.0.1%20hello/", "http://[google.com]/"};
auto const none_match =
std::all_of(invalid_inputs.begin(), invalid_inputs.end(), [](auto const view) -> bool {
auto begin = view.begin();
auto const end = view.end();
auto const match = x3::parse(begin, end, foxy::uri::uri);
if (match) { return begin != end; }
return !match;
});
CHECK(none_match);
}
}
| 31.753582 | 100 | 0.511189 | [
"vector"
] |
5e661ba4cf05480ab0aa965c447b63576f533397 | 7,698 | cpp | C++ | cpp/open3d/t/geometry/LineSet.cpp | mfkiwl/Open3D | 6aa17206f273df77c54f11b6efc97aef125d5517 | [
"MIT"
] | null | null | null | cpp/open3d/t/geometry/LineSet.cpp | mfkiwl/Open3D | 6aa17206f273df77c54f11b6efc97aef125d5517 | [
"MIT"
] | 3 | 2021-10-07T01:47:59.000Z | 2022-03-19T02:44:45.000Z | cpp/open3d/t/geometry/LineSet.cpp | mfkiwl/Open3D | 6aa17206f273df77c54f11b6efc97aef125d5517 | [
"MIT"
] | null | null | null | // ----------------------------------------------------------------------------
// - Open3D: www.open3d.org -
// ----------------------------------------------------------------------------
// The MIT License (MIT)
//
// Copyright (c) 2018-2021 www.open3d.org
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
// ----------------------------------------------------------------------------
#include "open3d/t/geometry/LineSet.h"
#include <string>
#include "open3d/core/EigenConverter.h"
#include "open3d/core/ShapeUtil.h"
#include "open3d/core/Tensor.h"
#include "open3d/core/TensorCheck.h"
#include "open3d/core/linalg/Matmul.h"
#include "open3d/t/geometry/TensorMap.h"
#include "open3d/t/geometry/kernel/Transform.h"
namespace open3d {
namespace t {
namespace geometry {
LineSet::LineSet(const core::Device &device)
: Geometry(Geometry::GeometryType::LineSet, 3),
device_(device),
point_attr_(TensorMap("positions")),
line_attr_(TensorMap("indices")) {}
LineSet::LineSet(const core::Tensor &point_positions,
const core::Tensor &line_indices)
: LineSet([&]() {
core::AssertTensorDevice(line_indices, point_positions.GetDevice());
return point_positions.GetDevice();
}()) {
SetPointPositions(point_positions);
SetLineIndices(line_indices);
}
LineSet LineSet::To(const core::Device &device, bool copy) const {
if (!copy && GetDevice() == device) {
return *this;
}
LineSet lineset(device);
for (const auto &kv : line_attr_) {
lineset.SetLineAttr(kv.first, kv.second.To(device, /*copy=*/true));
}
for (const auto &kv : point_attr_) {
lineset.SetPointAttr(kv.first, kv.second.To(device, /*copy=*/true));
}
return lineset;
}
std::string LineSet::ToString() const {
std::string str = fmt::format("LineSet on {}\n", GetDevice().ToString());
if (point_attr_.size() == 0) {
str += "[0 points ()] Attributes: None.";
} else {
str += fmt::format(
"[{} points ({})] Attributes:", GetPointPositions().GetShape(0),
GetPointPositions().GetDtype().ToString());
}
if (point_attr_.size() == 1) {
str += " None.";
} else {
for (const auto &keyval : point_attr_) {
if (keyval.first == "positions") continue;
str += fmt::format(" {} (dtype = {}, shape = {}),", keyval.first,
keyval.second.GetDtype().ToString(),
keyval.second.GetShape().ToString());
}
str[str.size() - 1] = '.';
}
if (line_attr_.size() == 0) {
str += "\n[0 lines ()] Attributes: None.";
} else {
str += fmt::format(
"\n[{} lines ({})] Attributes:", GetLineIndices().GetShape(0),
GetLineIndices().GetDtype().ToString());
}
if (line_attr_.size() == 1) {
str += " None.";
} else {
for (const auto &keyval : line_attr_) {
if (keyval.first == "indices") continue;
str += fmt::format(" {} (dtype = {}, shape = {}),", keyval.first,
keyval.second.GetDtype().ToString(),
keyval.second.GetShape().ToString());
}
str[str.size() - 1] = '.';
}
return str;
}
LineSet &LineSet::Transform(const core::Tensor &transformation) {
core::AssertTensorShape(transformation, {4, 4});
kernel::transform::TransformPoints(transformation, GetPointPositions());
return *this;
}
LineSet &LineSet::Translate(const core::Tensor &translation, bool relative) {
core::AssertTensorShape(translation, {3});
core::AssertTensorDevice(translation, device_);
core::Tensor transform = translation;
if (!relative) {
transform -= GetCenter();
}
GetPointPositions() += transform;
return *this;
}
LineSet &LineSet::Scale(double scale, const core::Tensor ¢er) {
core::AssertTensorShape(center, {3});
core::AssertTensorDevice(center, device_);
core::Tensor point_positions = GetPointPositions();
point_positions.Sub_(center).Mul_(scale).Add_(center);
return *this;
}
LineSet &LineSet::Rotate(const core::Tensor &R, const core::Tensor ¢er) {
core::AssertTensorShape(R, {3, 3});
core::AssertTensorShape(center, {3});
kernel::transform::RotatePoints(R, GetPointPositions(), center);
return *this;
}
geometry::LineSet LineSet::FromLegacy(
const open3d::geometry::LineSet &lineset_legacy,
core::Dtype float_dtype,
core::Dtype int_dtype,
const core::Device &device) {
if (float_dtype != core::Float32 && float_dtype != core::Float64) {
utility::LogError("float_dtype must be Float32 or Float64, but got {}.",
float_dtype.ToString());
}
if (int_dtype != core::Int32 && int_dtype != core::Int64) {
utility::LogError("int_dtype must be Int32 or Int64, but got {}.",
int_dtype.ToString());
}
LineSet lineset(device);
if (lineset_legacy.HasPoints()) {
lineset.SetPointPositions(
core::eigen_converter::EigenVector3dVectorToTensor(
lineset_legacy.points_, float_dtype, device));
} else {
utility::LogWarning("Creating from empty legacy LineSet.");
}
if (lineset_legacy.HasLines()) {
lineset.SetLineIndices(
core::eigen_converter::EigenVector2iVectorToTensor(
lineset_legacy.lines_, int_dtype, device));
} else {
utility::LogWarning("Creating from legacy LineSet with no lines.");
}
if (lineset_legacy.HasColors()) {
lineset.SetLineColors(
core::eigen_converter::EigenVector3dVectorToTensor(
lineset_legacy.colors_, float_dtype, device));
}
return lineset;
}
open3d::geometry::LineSet LineSet::ToLegacy() const {
open3d::geometry::LineSet lineset_legacy;
if (HasPointPositions()) {
lineset_legacy.points_ =
core::eigen_converter::TensorToEigenVector3dVector(
GetPointPositions());
}
if (HasLineIndices()) {
lineset_legacy.lines_ =
core::eigen_converter::TensorToEigenVector2iVector(
GetLineIndices());
}
if (HasLineColors()) {
lineset_legacy.colors_ =
core::eigen_converter::TensorToEigenVector3dVector(
GetLineColors());
}
return lineset_legacy;
}
} // namespace geometry
} // namespace t
} // namespace open3d
| 37.009615 | 80 | 0.598987 | [
"geometry",
"shape",
"transform"
] |
5e69e549caf7af6d4795df59fb98a907005f92ca | 2,171 | cpp | C++ | src/ImageSaver.cpp | rezaali/Cinder-ImageSaver | 9ef0d1f9b485b87b8f397318643b946b14a88307 | [
"MIT"
] | null | null | null | src/ImageSaver.cpp | rezaali/Cinder-ImageSaver | 9ef0d1f9b485b87b8f397318643b946b14a88307 | [
"MIT"
] | null | null | null | src/ImageSaver.cpp | rezaali/Cinder-ImageSaver | 9ef0d1f9b485b87b8f397318643b946b14a88307 | [
"MIT"
] | null | null | null | #include "ImageSaver.h"
#include "cinder/Camera.h"
#include "cinder/app/App.h"
#include "Paths.h"
#include "Tiler.h"
using namespace reza::paths;
using namespace reza::tiler;
using namespace ci;
using namespace std;
namespace reza {
namespace img {
ImageSaver::ImageSaver(
const ci::app::WindowRef &window,
const std::function<void()> &drawFn,
const std::function<void( glm::vec2, glm::vec2, glm::vec2, glm::vec2 )> &drawBgFn,
const std::function<void( glm::vec2, glm::vec2, glm::vec2, glm::vec2 )> &drawPostFn )
: mWindowRef( window ), mDrawFn( drawFn ), mDrawBgFn( drawBgFn ), mDrawPostFn( drawPostFn )
{
}
ImageSaver::~ImageSaver()
{
}
void ImageSaver::update()
{
if( mSaveImage ) {
ivec2 windowSize = mWindowRef->getSize();
ivec2 outputSize = windowSize * mSizeMultiplier;
auto render = Tiler::create( outputSize, windowSize, mWindowRef, mAlpha );
render->setMatrices( mCam );
if( mDrawBgFn ) {
render->setDrawBgFn( [this]( const vec2 &ul, const vec2 &ur, const vec2 &lr, const vec2 &ll ) {
mDrawBgFn( ul, ur, lr, ll );
} );
}
if( mDrawFn ) {
render->setDrawFn( [this]() {
mDrawFn();
} );
}
if( mDrawPostFn ) {
render->setDrawPostFn( [this]( const vec2 &ul, const vec2 &ur, const vec2 &lr, const vec2 &ll ) {
mDrawPostFn( ul, ur, lr, ll );
} );
}
if( createDirectory( mSaveImagePath ) ) {
fs::path high = mSaveImagePath;
high += fs::path( mSaveImageName + "." + mSaveImageExtension );
writeImage( high, render->getSurface(), ImageTarget::Options().quality( 1.0 ) );
}
mSaveImage = false;
}
}
void ImageSaver::save( const CameraPersp &cam, const fs::path &path, const string &filename, const string &extension, bool alpha )
{
mSaveImage = true;
mCam = cam;
mSaveImagePath = path;
mSaveImageName = filename;
mSaveImageExtension = extension;
mAlpha = alpha;
}
void ImageSaver::save( const fs::path &path, const string &filename, const string &extension, bool alpha )
{
mSaveImage = true;
mCam = CameraPersp();
mSaveImagePath = path;
mSaveImageName = filename;
mSaveImageExtension = extension;
mAlpha = alpha;
}
} // namespace img
} // namespace reza
| 24.670455 | 130 | 0.669277 | [
"render"
] |
5e6a36be6de1e958f42af2039e16ff627d9e52d9 | 340 | cpp | C++ | Reference/Strings/Distinct Substring Count.cpp | searleser97/Algorithms | af791541d416c29867213d705375cbb3361f486c | [
"Apache-2.0"
] | 7 | 2019-06-06T17:54:20.000Z | 2021-03-24T02:31:55.000Z | Reference/Strings/Distinct Substring Count.cpp | searleser97/Algorithms | af791541d416c29867213d705375cbb3361f486c | [
"Apache-2.0"
] | null | null | null | Reference/Strings/Distinct Substring Count.cpp | searleser97/Algorithms | af791541d416c29867213d705375cbb3361f486c | [
"Apache-2.0"
] | 1 | 2021-03-24T02:31:57.000Z | 2021-03-24T02:31:57.000Z | // 13
#include "../Data Structures/Strings/Suffix Automaton.cpp"
// O(N)
int distinctSubstrCount(const string& s) {
SuffixAutomaton sa(s);
vector<int> dp(sa.size);
function<int(int)> dfs = [&](int u) {
if (dp[u]) return dp[u];
for (auto& v : sa.next[u]) dp[u] += dfs(v.second);
return ++dp[u];
};
return dfs(0) - 1;
} | 24.285714 | 58 | 0.594118 | [
"vector"
] |
5e70e6b641eb1732174bea669fdeb3135d964f53 | 19,881 | cc | C++ | example/laser_key_test.cc | ibyte2011/LaserDB | 326fa477c4cbee36f46706ecb3b4a48d3bdab057 | [
"Apache-2.0"
] | 26 | 2021-01-07T09:32:37.000Z | 2022-02-17T04:00:03.000Z | example/laser_key_test.cc | imotai/LaserDB | 16f02fe001751b26e4221f54f9d3e2ca8c1a0607 | [
"Apache-2.0"
] | 1 | 2021-09-01T09:16:53.000Z | 2021-12-04T02:25:15.000Z | example/laser_key_test.cc | imotai/LaserDB | 16f02fe001751b26e4221f54f9d3e2ca8c1a0607 | [
"Apache-2.0"
] | 10 | 2021-01-21T06:26:46.000Z | 2022-02-08T02:41:23.000Z | #include <fstream>
#include "folly/init/Init.h"
#include "folly/Random.h"
#include "common/service_router/http.h"
#include "common/laser/status.h"
#include "client/laser_client.h"
#include "common/metrics/metrics.h"
DEFINE_string(host, "127.0.0.1", "current service host address");
DEFINE_string(local_host, "127.0.0.1", "current service host address");
DEFINE_int32(port, 0, "current service port");
DEFINE_string(service_name, "laser_client", "Current geo client service name");
DEFINE_string(target_service_name, "laser_dev", "Search laser service name");
DEFINE_string(database_name, "test", "Test laser database name");
DEFINE_string(table_names, "test_raw_string", "Test laser table names");
DEFINE_string(command, "get", "Test laser command");
DEFINE_int32(numbers, 10000, "Send laser server numbers.");
DEFINE_int32(batch_number, 10, "Send laser batch multi request numbers.");
DEFINE_int32(num_clients, 16, "Number of clients to use. (Default: 1 per core)");
DEFINE_bool(print, false, "Print result to stdout");
DEFINE_int32(value_size, 128, "Value size");
DEFINE_int32(rpc_request_timeout, 10, "each request recv timeout");
DEFINE_int32(diff_range, 256, "Address diff range");
DEFINE_string(load_balance_method, "random",
"request load balance method `random/roundrobin/localfirst/configurable_weight`");
DEFINE_string(client_request_read_mode, "mixed_read", "request read mode `leader_read/mixed_read");
DEFINE_int32(max_conn_per_server, 0, "Max connection pre server.");
DEFINE_int32(thrift_compression_method, 0, "thrift compression method");
DEFINE_int32(max_key_id, 10, "Max key id");
DEFINE_int32(max_key_bucket, 32, "Max key create bucket");
DEFINE_int32(hash_field_size, 10, "hash value field size");
DEFINE_int32(zadd_data_num, 10, "zadd add 10 data to db");
DEFINE_int32(zrangebyscore_data_num, 5, "zrangebyscore show 5 data here");
DEFINE_int32(zremrangebyscore_data_num, 8, "zremrangebyscore remove 8 data here");
constexpr static char KEY_BUCKET_AND_ID_SPLIT[] = "|";
constexpr char LASER_CLIENT_MODULE_NAME[] = "laser_client";
constexpr char LASER_CLIENT_TABLE_CALL[] = "table_call";
constexpr double LASER_CLIENT_CALL_METRIC_CALL_BUCKET_SIZE = 1.0;
constexpr double LASER_CLIENT_CALL_METRIC_CALL_MIN = 0.0;
constexpr double LASER_CLIENT_CALL_METRIC_CALL_MAX = 1000.0;
class LaserCall {
public:
LaserCall(const std::string& target_service_name, const std::string& database_name, const std::string& table_names)
: target_service_name_(target_service_name), database_name_(database_name), table_names_(table_names) {}
~LaserCall() = default;
void init() {
client_ = std::make_shared<laser::LaserClient>(target_service_name_);
client_->init();
client_options_ = getClientOption();
}
const laser::ClientOption getClientOption() {
laser::ClientOption option;
option.setReceiveTimeoutMs(FLAGS_rpc_request_timeout);
option.setMaxConnPerServer(FLAGS_max_conn_per_server);
option.setThriftCompressionMethod(FLAGS_thrift_compression_method);
auto method = service_router::stringToLoadBalanceMethod(FLAGS_load_balance_method);
service_router::LoadBalanceMethod load_method = service_router::LoadBalanceMethod::RANDOM;
if (!method) {
FB_LOG_EVERY_MS(ERROR, 1000) << "Specified load balance method is invalid, default is random";
} else {
load_method = *method;
}
option.setLoadBalance(load_method);
auto read_mode = laser::ClientRequestReadMode::MIXED_READ;
auto read_mode_optional = laser::stringToClientRequestReadMode(FLAGS_client_request_read_mode);
if (read_mode_optional) {
read_mode = *read_mode_optional;
}
option.setReadMode(read_mode);
service_router::BalanceLocalFirstConfig local_first;
local_first.setLocalIp(FLAGS_local_host);
local_first.setDiffRange(FLAGS_diff_range);
option.setLocalFirstConfig(local_first);
return option;
}
void run(bool is_print, uint32_t numbers, uint32_t thread_nums) {
std::vector<std::string> tables;
folly::split(',', table_names_, tables);
if (tables.empty()) {
LOG(INFO) << "Stress test table is empty.";
return;
}
for (auto& table_name : tables) {
std::unordered_map<std::string, std::string> tags = {{"table_name", table_name}};
timers_[table_name] = metrics::Metrics::getInstance()->buildTimers(
LASER_CLIENT_MODULE_NAME, LASER_CLIENT_TABLE_CALL, LASER_CLIENT_CALL_METRIC_CALL_BUCKET_SIZE,
LASER_CLIENT_CALL_METRIC_CALL_MIN, LASER_CLIENT_CALL_METRIC_CALL_MAX, tags);
}
while (is_running_) {
for (auto& table_name : tables) {
std::vector<std::unique_ptr<std::thread>> threads;
for (int i = 0; i < thread_nums; ++i) {
threads.push_back(std::make_unique<std::thread>([this, is_print, table_name, numbers]() {
for (uint32_t i = 0; i < numbers; i++) {
call(table_name, is_print);
}
}));
}
for (auto& thr : threads) {
thr->join();
}
}
}
}
void stop() { is_running_ = false; }
private:
std::string target_service_name_;
std::string database_name_;
std::string table_names_;
std::shared_ptr<laser::LaserClient> client_;
std::atomic<bool> is_running_{true};
laser::ClientOption client_options_;
std::atomic<uint32_t> current_bucket_id_{0};
std::atomic<uint32_t> key_id_{0};
std::unordered_map<std::string, std::shared_ptr<metrics::Timers>> timers_;
void call(const std::string& table_name, bool is_print) {
metrics::Timer timer(timers_[table_name].get());
if (FLAGS_command == "mget") {
std::vector<laser::LaserKey> keys;
getLaserKeys(&keys, table_name);
mget(keys, table_name, is_print);
} else if (FLAGS_command == "mgetDetail") {
std::vector<laser::LaserKey> keys;
getLaserKeys(&keys, table_name);
mgetDetail(keys, table_name, is_print);
} else if (FLAGS_command == "mdel") {
std::vector<laser::LaserKey> keys;
getLaserKeys(&keys, table_name);
mdel(keys, table_name, is_print);
} else if (FLAGS_command == "setget") {
setget(table_name, is_print);
} else if (FLAGS_command == "exist") {
exist(table_name, is_print);
} else if (FLAGS_command == "msetget") {
msetget(table_name, is_print);
} else if (FLAGS_command == "mset") {
mset(table_name, is_print);
} else if (FLAGS_command == "msetDetailget") {
msetDetailget(table_name, is_print);
} else if (FLAGS_command == "hmsetget") {
hmset(table_name, is_print, true);
} else if (FLAGS_command == "hmset") {
hmset(table_name, is_print, false);
} else if (FLAGS_command == "hgetall") {
laser::LaserKey key;
getLaserKey(&key, table_name);
hgetall(key, is_print);
} else if (FLAGS_command == "zadd") {
zadd(table_name, is_print);
} else if (FLAGS_command == "zrangebyscore") {
zrangebyscore(table_name, is_print);
} else if (FLAGS_command == "zremrangebyscore") {
zremrangebyscore(table_name, is_print);
} else if (FLAGS_command == "set") {
set(table_name, is_print);
} else {
laser::LaserKey key;
getLaserKey(&key, table_name);
get(key, table_name, is_print);
}
}
void get(const laser::LaserKey& key, const std::string& table_name, bool is_print) {
std::string data;
auto ret = client_->getSync(client_options_, &data, key);
if (!is_print) {
return;
}
if (ret != laser::Status::OK) {
LOG(INFO) << "Call get api fail," << ret;
} else {
LOG(INFO) << "pk:" << key.get_primary_keys()[0] << " vlaue:" << data;
}
}
void setget(const std::string& table_name, bool is_print) {
laser::LaserKV kv;
getLaserKV(&kv, table_name);
auto ret = client_->setSync(client_options_, kv);
if (is_print && ret != laser::Status::OK) {
LOG(INFO) << "Call setget api fail," << ret;
}
const laser::LaserKey key = kv.get_key();
get(kv.get_key(), table_name, is_print);
}
void set(const std::string& table_name, bool is_print) {
laser::LaserKV kv;
getLaserKV(&kv, table_name);
auto ret = client_->setSync(client_options_, kv);
if (is_print && ret != laser::Status::OK) {
LOG(INFO) << "Call set api fail," << ret;
}
}
void exist(const std::string& table_name, bool is_print) {
laser::LaserKV kv;
getLaserKV(&kv, table_name);
const laser::LaserKey key = kv.get_key();
bool data;
auto ret = client_->existSync(client_options_, &data, key);
if (!is_print) {
return;
}
if (ret != laser::Status::OK) {
LOG(INFO) << "Call exist api fail," << ret;
} else {
LOG(INFO) << "Exist command pk is:" << key.get_primary_keys()[0] << " exist:" << data;
}
}
void msetget(const std::string& table_name, bool is_print) {
std::vector<laser::LaserKV> kvs;
getLaserKVs(&kvs, table_name);
std::vector<int64_t> result;
auto ret = client_->mset(client_options_, &result, kvs);
if (is_print && ret != laser::Status::OK) {
LOG(INFO) << "Call msetget api fail," << ret;
}
std::vector<laser::LaserKey> keys;
for (auto& kv : kvs) {
keys.push_back(kv.get_key());
}
mget(keys, table_name, is_print);
}
void mset(const std::string& table_name, bool is_print) {
std::vector<laser::LaserKV> kvs;
getLaserKVs(&kvs, table_name);
std::vector<int64_t> result;
auto ret = client_->mset(client_options_, &result, kvs);
if (is_print && ret != laser::Status::OK) {
LOG(INFO) << "Call msetget api fail," << ret;
}
}
void msetDetailget(const std::string& table_name, bool is_print) {
std::vector<laser::LaserKV> kvs;
getLaserKVs(&kvs, table_name);
std::vector<laser::LaserValue> result;
auto ret = client_->msetDetail(client_options_, &result, kvs);
if (is_print && ret != laser::Status::OK) {
LOG(INFO) << "Call msetDetailget api fail," << ret;
}
std::vector<laser::LaserKey> keys;
for (auto& kv : kvs) {
keys.push_back(kv.get_key());
}
std::vector<laser::LaserValue> values;
ret = client_->mgetDetail(client_options_, &values, keys);
if (is_print && ret != laser::Status::OK) {
LOG(INFO) << "Call mgetDetail api return not ok." << ret;
}
}
void mget(const std::vector<laser::LaserKey>& keys, const std::string& table_name, bool is_print) {
std::vector<laser::LaserValue> values;
auto ret = client_->mget(client_options_, &values, keys);
if (!is_print) {
return;
}
if (ret != laser::Status::OK) {
LOG(INFO) << "Call get api fail," << ret;
return;
}
LOG(INFO) << "Start print result:";
for (uint32_t i = 0; i < values.size(); i++) {
auto& value = values[i];
auto value_type = value.getType();
auto& pk = keys[i].get_primary_keys();
if (laser::LaserValue::Type::string_value == value_type) {
LOG(INFO) << "key:" << pk[0] << "value:" << value.get_string_value();
} else if (laser::LaserValue::Type::null_value == value_type) {
LOG(INFO) << "key:" << pk[0] << "value: is null";
} else {
LOG(INFO) << "value: is invalid";
}
}
}
void setData(const std::string& table_name, bool is_print) {
std::vector<laser::LaserKV> kvs;
getLaserKVs(&kvs, table_name);
for (auto& kv : kvs) {
auto ret = client_->setSync(client_options_, kv);
if (is_print) {
if (ret != laser::Status::OK) {
LOG(INFO) << "Call set api fail," << ret;
}
}
}
}
void mgetDetail(const std::vector<laser::LaserKey>& keys, const std::string& table_name, bool is_print) {
std::vector<laser::LaserValue> values;
// 调用set插入数据,再通过mgetDetail获取返回信息
setData(table_name, is_print);
// 通过mgetDetail获取返回信息
auto ret = client_->mgetDetail(client_options_, &values, keys);
if (!is_print) {
return;
}
if (ret != laser::Status::OK) {
LOG(INFO) << "Call mgetDetail api return not ok." << ret;
}
LOG(INFO) << "Start print result:";
for (uint32_t i = 0; i < values.size(); i++) {
auto& pk = keys[i].get_primary_keys();
LOG(ERROR) << "key:" << pk[0] << ", res:" << values[i].get_entry_value().get_status();
LOG(ERROR) << "key:" << pk[0] << ", value:" << values[i].get_entry_value().get_string_value();
}
}
void mdel(const std::vector<laser::LaserKey>& keys, const std::string& table_name, bool is_print) {
std::vector<laser::LaserValue> values;
// 调用set插入数据,再通过mdel删除数据
setData(table_name, is_print);
// 通过mdel删除key
auto ret = client_->mdel(client_options_, &values, keys);
if (!is_print) {
return;
}
if (ret != laser::Status::OK) {
LOG(INFO) << "Call mdel api return not ok." << ret;
}
LOG(INFO) << "Start print result:";
for (uint32_t i = 0; i < values.size(); i++) {
auto& pk = keys[i].get_primary_keys();
LOG(ERROR) << "mdel : key:" << pk[0] << ", res:" << values[i].get_entry_value().get_status();
}
}
void hmset(const std::string& table_name, bool is_print, bool isget = false) {
laser::LaserKey laser_key;
getLaserKey(&laser_key, table_name);
auto pks = laser_key.get_primary_keys();
if (pks.empty()) {
LOG(INFO) << "laser key: is invalid";
return;
}
laser::LaserValue values;
std::map<std::string, std::string> values_map;
for (uint32_t i = 0; i < FLAGS_hash_field_size; i++) {
values_map[folly::to<std::string>(pks[0], i)] = pks[0];
}
values.set_map_value(values_map);
auto ret = client_->hmsetSync(client_options_, laser_key, values);
if (is_print && ret != laser::Status::OK) {
LOG(INFO) << "Call hmset api fail," << ret;
return;
}
if (!isget) {
return;
}
hgetall(laser_key, is_print);
}
void hgetall(const laser::LaserKey& laser_key, bool is_print) {
std::map<std::string, std::string> data;
auto ret = client_->hgetallSync(client_options_, &data, laser_key);
if (!is_print) {
return;
}
if (ret != laser::Status::OK) {
LOG(INFO) << "Call get api fail," << ret;
return;
}
LOG(INFO) << "Start print result:";
auto& pks = laser_key.get_primary_keys();
for (auto& value : data) {
LOG(INFO) << "key:" << pks[0] << " field:" << value.first << " value:" << value.second;
}
}
void getLaserKeys(std::vector<laser::LaserKey>* keys, const std::string& table_name) {
for (int i = 0; i < FLAGS_batch_number; i++) {
laser::LaserKey laser_key;
getLaserKey(&laser_key, table_name);
keys->push_back(std::move(laser_key));
}
}
void getLaserKey(laser::LaserKey* laser_key, const std::string& table_name) {
uint32_t key_id = key_id_.fetch_add(1);
if (key_id_ > FLAGS_max_key_id) {
key_id_.store(0);
}
uint32_t bucket_id = current_bucket_id_.fetch_add(1);
if (current_bucket_id_ > FLAGS_max_key_bucket) {
current_bucket_id_.store(0);
}
std::string pk = folly::to<std::string>(getKey(bucket_id, key_id));
std::vector<std::string> pks({pk});
laser_key->set_database_name(database_name_);
laser_key->set_table_name(table_name);
laser_key->set_primary_keys(pks);
}
void getLaserKVs(std::vector<laser::LaserKV>* kvs, const std::string& table_name) {
for (int i = 0; i < FLAGS_batch_number; i++) {
laser::LaserKV kv;
getLaserKV(&kv, table_name);
kvs->push_back(std::move(kv));
}
}
void getLaserKV(laser::LaserKV* kv, const std::string& table_name) {
laser::LaserKey key;
getLaserKey(&key, table_name);
laser::LaserValue value;
std::string value_str = paddingValue(key.get_primary_keys()[0]);
size_t repeat_step = std::ceil(std::log2(FLAGS_value_size) - std::log2(value_str.size()));
for (int i = 0; i < repeat_step; i++) {
value_str += value_str;
}
value.set_string_value(value_str);
kv->set_key(key);
kv->set_value(value);
}
std::string paddingValue(const std::string& value) {
std::string result = value;
size_t new_len = std::pow(2, std::ceil(std::log2(value.size())));
for (size_t i = 0; i < (new_len - value.size()); i++) {
result.append(1, '0');
}
return result;
}
int64_t getKey(size_t bucket_id, size_t key_id) {
int64_t key = CityHash64WithSeed(KEY_BUCKET_AND_ID_SPLIT, 1, bucket_id);
std::string key_id_str = folly::to<std::string>(key_id);
key = CityHash64WithSeed(key_id_str.c_str(), key_id_str.size(), key);
return key;
}
void getMemberScores(std::unordered_map<std::string, double>* member_scores) {
for (uint32_t i = 0; i < FLAGS_zadd_data_num; i++) {
std::string str_tmp;
str_tmp = "member_" + std::to_string(i);
(*member_scores)[str_tmp] = i;
}
}
bool zaddData(const laser::LaserKey& laser_key, bool is_print) {
std::unordered_map<std::string, double> map_member_scores;
getMemberScores(&map_member_scores);
uint32_t res;
auto ret = client_->zaddSync(client_options_, &res, laser_key, map_member_scores);
if ((ret != laser::Status::OK) && (is_print)) {
LOG(INFO) << "Call zadd api fail," << ret;
return false;
}
return true;
}
void zadd(const std::string& table_name, bool is_print) {
laser::LaserKey laser_key;
getLaserKey(&laser_key, table_name);
uint32_t res;
std::unordered_map<std::string, double> member_scores;
getMemberScores(&member_scores);
auto ret = client_->zaddSync(client_options_, &res, laser_key, member_scores);
if (is_print && ret != laser::Status::OK) {
LOG(INFO) << "Call zadd api fail," << ret;
return;
}
}
void zrangebyscore(const std::string& table_name, bool is_print) {
laser::LaserKey laser_key;
getLaserKey(&laser_key, table_name);
// 先调用zaddSync插入数据,再通过zrangebyscore获取返回值
auto is_sucess = zaddData(laser_key, is_print);
if (!is_sucess) {
return;
}
int64_t num_min = 1;
int64_t num_max = FLAGS_zrangebyscore_data_num;
std::vector<laser::LaserFloatScoreMember> member_scores;
auto ret = client_->zrangebyscoreSync(client_options_, &member_scores, laser_key, num_min, num_max);
if (is_print && ret != laser::Status::OK) {
LOG(INFO) << "Call zrangebyscoreSync api fail." << ret;
return;
} else {
for (auto member_score : member_scores) {
LOG(INFO) << "member : " << member_score.getMember();
LOG(INFO) << "score : " << member_score.getScore();
}
}
}
void zremrangebyscore(const std::string& table_name, bool is_print) {
laser::LaserKey laser_key;
getLaserKey(&laser_key, table_name);
// 先调用zaddSync插入数据,再通过zremrangebyscore删除
auto is_sucess = zaddData(laser_key, is_print);
if (!is_sucess) {
return;
}
int64_t num_min = 1;
int64_t num_max = FLAGS_zremrangebyscore_data_num;
uint32_t number = 0;
auto ret2 = client_->zremrangebyscoreSync(client_options_, &number, laser_key, num_min, num_max);
if (is_print && ret2 != laser::Status::OK) {
LOG(INFO) << "Call zremrangebyscoreSync api fail." << ret2;
return;
} else {
LOG(INFO) << "number : " << number;
}
}
};
int main(int argc, char* argv[]) {
FLAGS_logtostderr = true;
folly::Init init(&argc, &argv);
SCOPE_EXIT {
service_router::unregisterAll();
service_framework::http::stop();
service_router::stop_connection_pool();
};
LaserCall laser_call(FLAGS_target_service_name, FLAGS_database_name, FLAGS_table_names);
laser_call.init();
std::thread http_server_thread(
[]() { service_router::httpServiceServer(FLAGS_service_name, FLAGS_host, FLAGS_port); });
laser_call.run(FLAGS_print, FLAGS_numbers, FLAGS_num_clients);
http_server_thread.join();
return 0;
}
| 34.515625 | 117 | 0.652885 | [
"vector"
] |
5e760ad804976e4ce8ebd73279887834a03287a6 | 1,371 | hpp | C++ | flower_equals_win/FlowerApplication.hpp | Garoli/flower-equals-win-game | c6965b9dfa38de124e3e8991a0d92509a54365df | [
"Unlicense",
"MIT"
] | null | null | null | flower_equals_win/FlowerApplication.hpp | Garoli/flower-equals-win-game | c6965b9dfa38de124e3e8991a0d92509a54365df | [
"Unlicense",
"MIT"
] | null | null | null | flower_equals_win/FlowerApplication.hpp | Garoli/flower-equals-win-game | c6965b9dfa38de124e3e8991a0d92509a54365df | [
"Unlicense",
"MIT"
] | null | null | null | #ifndef __PA1_APPLICATION_H__
#define __PA1_APPLICATION_H__
#include <memory>
#include "Application.hpp"
#include "CellView.h"
#include "glApi.hpp"
#include "logic/Game.h"
// forward declarations
struct GLFWwindow;
/// A concrete implementation of Application for PA1
class FlowerApplication : public Application {
public:
/**
* @brief Constructor
* @param windowWidth initial width of the application
* @param windowHeight initial height of the application
* @param part should be 1 or 2 to select the corresponding tutorial part
*/
FlowerApplication(int windowWidth, int windowHeight);
void setCallbacks() override;
static void usage(std::string & shortDescritpion, std::string & synopsis, std::string & description);
private:
void renderFrame() override;
void update() override;
static void resize(GLFWwindow * window, int framebufferWidth, int framebufferHeight);
CellView * getNeighbourView(int, int);
void findChanges();
CellView *getCellView(Cell*);
void moveUpdate(Direction const d);
private:
Buffer m_vbo;
VAO m_vao;
Program m_program;
Program m_program_bee;
CellView backgroundView;
CellView * beeView;
CellView winView;
glm::vec2 beeOrigin{};
std::vector<CellView *> dataView;
bool key_pressed;
int button_pressed;
Game game;
glm::vec2 m_offset;
};
#endif // !defined(__PA1_APPLICATION_H__)
| 26.882353 | 103 | 0.749088 | [
"vector"
] |
5e7706b39bf44e7fe26fdaacde8129d96a2fc49d | 4,419 | cpp | C++ | scf/src/v20180416/model/ListAliasesRequest.cpp | suluner/tencentcloud-sdk-cpp | a56c73cc3f488c4d1e10755704107bb15c5e000d | [
"Apache-2.0"
] | 43 | 2019-08-14T08:14:12.000Z | 2022-03-30T12:35:09.000Z | scf/src/v20180416/model/ListAliasesRequest.cpp | suluner/tencentcloud-sdk-cpp | a56c73cc3f488c4d1e10755704107bb15c5e000d | [
"Apache-2.0"
] | 12 | 2019-07-15T10:44:59.000Z | 2021-11-02T12:35:00.000Z | scf/src/v20180416/model/ListAliasesRequest.cpp | suluner/tencentcloud-sdk-cpp | a56c73cc3f488c4d1e10755704107bb15c5e000d | [
"Apache-2.0"
] | 28 | 2019-07-12T09:06:22.000Z | 2022-03-30T08:04:18.000Z | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* 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 <tencentcloud/scf/v20180416/model/ListAliasesRequest.h>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
using namespace TencentCloud::Scf::V20180416::Model;
using namespace std;
ListAliasesRequest::ListAliasesRequest() :
m_functionNameHasBeenSet(false),
m_namespaceHasBeenSet(false),
m_functionVersionHasBeenSet(false),
m_offsetHasBeenSet(false),
m_limitHasBeenSet(false)
{
}
string ListAliasesRequest::ToJsonString() const
{
rapidjson::Document d;
d.SetObject();
rapidjson::Document::AllocatorType& allocator = d.GetAllocator();
if (m_functionNameHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "FunctionName";
iKey.SetString(key.c_str(), allocator);
d.AddMember(iKey, rapidjson::Value(m_functionName.c_str(), allocator).Move(), allocator);
}
if (m_namespaceHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Namespace";
iKey.SetString(key.c_str(), allocator);
d.AddMember(iKey, rapidjson::Value(m_namespace.c_str(), allocator).Move(), allocator);
}
if (m_functionVersionHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "FunctionVersion";
iKey.SetString(key.c_str(), allocator);
d.AddMember(iKey, rapidjson::Value(m_functionVersion.c_str(), allocator).Move(), allocator);
}
if (m_offsetHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Offset";
iKey.SetString(key.c_str(), allocator);
d.AddMember(iKey, rapidjson::Value(m_offset.c_str(), allocator).Move(), allocator);
}
if (m_limitHasBeenSet)
{
rapidjson::Value iKey(rapidjson::kStringType);
string key = "Limit";
iKey.SetString(key.c_str(), allocator);
d.AddMember(iKey, rapidjson::Value(m_limit.c_str(), allocator).Move(), allocator);
}
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
d.Accept(writer);
return buffer.GetString();
}
string ListAliasesRequest::GetFunctionName() const
{
return m_functionName;
}
void ListAliasesRequest::SetFunctionName(const string& _functionName)
{
m_functionName = _functionName;
m_functionNameHasBeenSet = true;
}
bool ListAliasesRequest::FunctionNameHasBeenSet() const
{
return m_functionNameHasBeenSet;
}
string ListAliasesRequest::GetNamespace() const
{
return m_namespace;
}
void ListAliasesRequest::SetNamespace(const string& _namespace)
{
m_namespace = _namespace;
m_namespaceHasBeenSet = true;
}
bool ListAliasesRequest::NamespaceHasBeenSet() const
{
return m_namespaceHasBeenSet;
}
string ListAliasesRequest::GetFunctionVersion() const
{
return m_functionVersion;
}
void ListAliasesRequest::SetFunctionVersion(const string& _functionVersion)
{
m_functionVersion = _functionVersion;
m_functionVersionHasBeenSet = true;
}
bool ListAliasesRequest::FunctionVersionHasBeenSet() const
{
return m_functionVersionHasBeenSet;
}
string ListAliasesRequest::GetOffset() const
{
return m_offset;
}
void ListAliasesRequest::SetOffset(const string& _offset)
{
m_offset = _offset;
m_offsetHasBeenSet = true;
}
bool ListAliasesRequest::OffsetHasBeenSet() const
{
return m_offsetHasBeenSet;
}
string ListAliasesRequest::GetLimit() const
{
return m_limit;
}
void ListAliasesRequest::SetLimit(const string& _limit)
{
m_limit = _limit;
m_limitHasBeenSet = true;
}
bool ListAliasesRequest::LimitHasBeenSet() const
{
return m_limitHasBeenSet;
}
| 25.994118 | 100 | 0.722109 | [
"model"
] |
5e80eaa8b64f36e9894efc35cb253466d0ea1212 | 8,621 | cpp | C++ | test/matslise2d/quartic.cpp | twist-numerical/matslise2d | 71533b53d4e95e286bf948a69ef280333e461ccf | [
"MIT"
] | null | null | null | test/matslise2d/quartic.cpp | twist-numerical/matslise2d | 71533b53d4e95e286bf948a69ef280333e461ccf | [
"MIT"
] | null | null | null | test/matslise2d/quartic.cpp | twist-numerical/matslise2d | 71533b53d4e95e286bf948a69ef280333e461ccf | [
"MIT"
] | null | null | null | #include <cmath>
#include <vector>
#include <tuple>
#include "../catch.hpp"
#include "../../matslise2d/matslise2d.h"
#include "checkOrthonormality.h"
using namespace matslise;
using namespace std;
using namespace Eigen;
template<typename Scalar>
void testQuartic(
const Scalar &a, const Scalar &c, const Scalar &alpha, const vector<Scalar> &eigenvalues, int sectorCount = 23,
const Scalar &tolerance = static_cast<Scalar>(1e-8), const Scalar &error = static_cast<Scalar>(1e-8)) {
typename Matslise2D<Scalar>::Config config;
config.tolerance = tolerance;
config.xSymmetric = true;
config.ySectorBuilder = sector_builder::uniform<Matslise2D<Scalar>>(sectorCount);
Matslise2DHalf<Scalar> p(
[a, c](const Scalar &x, const Scalar &y) -> Scalar {
return x * x + y * y + c * (x * x * x * x + 2 * a * x * x * y * y + y * y * y * y);
},
{-alpha, alpha, -alpha, alpha}, config);
for (const Scalar &E : eigenvalues) {
CHECK(Approx(E).margin(error) == p.eigenvalue(E+100*error).first);
CHECK(Approx(E).margin(error) == p.eigenvalue(E-100*error).first);
}
}
TEST_CASE("Eigenfunctions quartic: c=-3", "[matslise2d][eigenvalues][quartic]") {
testQuartic<double>(
-1, 1e-3, 7.5,
{2.0009985054698104735, 4.0029925416713028329, 6.0029940290428079650, 6.0069702421328217062,
6.0089687360251750823, 8.0056893858679641592, 8.0162095893107613409, 10.006398993925805298,
10.008948049206928896, 10.014940522380068574});
testQuartic<double>(
0, 1e-3, 7.5,
{2.0014973853463713991, 4.0044884408419148160, 6.0074794963374582330, 6.0104605654612931866,
8.0134516209568366035, 8.0194012847307019984, 10.019423745576214974, 10.022392340226245415,
10.031298258747896515, 12.028364464845623786});
testQuartic<double>(
1, 1e-3, 7.5,
{2.0019955220947085337, 4.0059806337201560486, 6.0119494490457070830, 6.0139360981896530736,
8.0198961283737167314, 8.0238606392924854844, 10.029814877549869265, 10.035748547202912722,
10.037726447540990997, 12.041699947383956422});
}
TEST_CASE("Eigenfunctions quartic: c=0", "[matslise2d][eigenvalues][quartic]") {
testQuartic<double>(
-1, 1, 6,
{2.5616265756400316393, 5.3968039831941313950, 7.5491560629022652232, 8.4359873223484674428,
9.6175877647334193257, 10.366020696842355027, 12.818706298776658594, 12.886584502841939840,
13.406949149052421685, 15.336126803517827432}, 41, 1e-8, 1e-6);
testQuartic<double>(
0, 1, 5,
{2.7847032830605837113, 6.0411643457423693920, 9.2976254084241550728, 10.047401599289601544,
13.303862661971387225, 14.549155539580166935, 17.310099915518619376, 17.805616602261952616,
19.449909077833544750, 21.811853855809184767}, 31, 1e-8);
testQuartic<double>(
1, 1, 5,
{2.9520500919628742871, 6.4629059998638721377, 10.390627295503782127, 10.882435576819807244,
14.658513813565503097, 15.482771577251666477, 19.217523495888984907, 20.293829707535892571,
20.661082690597886009, 24.033166193470850317}, 31, 1e-8);
}
TEST_CASE("Eigenfunctions quartic: c=3", "[matslise2d][eigenvalues][quartic]") {
// unsolvable
/* testQuartic<double>(-1, 1e3, 2.8,
{17.686909350775717644, 37.965440109662577256, 48.868379100596636584, 56.219242763197933124,
65.547004077171159352, 76.242494474221982538, 79.726698208795028150, 79.927690262545928550,
88.286001081585014158, 98.836631846113076108}); */
testQuartic<double>(
0, 1e3, 1.5,
{21.279577422656092127, 48.726622170710310149, 76.173666918764528170, 85.321192911492859325,
112.76823765954707735, 127.24298764862115750, 149.36280840032962652, 154.69003239667537552,
173.44216290830327624, 191.28460313745792470});
testQuartic<double>(
1, 1e3, 1.5,
{23.513389183129853963, 54.054855795519439394, 89.433434033749367277, 95.437449804059634223,
128.61961618091473035, 138.28303842944239989, 170.99777828093744127, 183.30633810778597643,
187.54903714202645897, 216.15194758663360719});
}
#ifdef MATSLISE2D_QUADMATH
#include <boost/multiprecision/float128.hpp>
using boost::multiprecision::float128;
TEST_CASE("Eigenfunctions quartic: c=-3 (float128)", "[matslise2d][eigenvalues][quartic][float128][slow]") {
#pragma omp parallel
#pragma omp single
{
#pragma omp task
testQuartic<float128>(
-1, 1e-3, 7.5,
{2.0009985054698104735q, 4.0029925416713028329q, 6.0029940290428079650q, 6.0069702421328217062q,
6.0089687360251750823q, 8.0056893858679641592q, 8.0162095893107613409q, 10.006398993925805298q,
10.008948049206928896q, 10.014940522380068574q},
15, 0.0001q, 1e-20q);
#pragma omp task
testQuartic<float128>(
0, 1e-3, 7.5,
{2.0014973853463713991q, 4.0044884408419148160q, 6.0074794963374582330q, 6.0104605654612931866q,
8.0134516209568366035q, 8.0194012847307019984q, 10.019423745576214974q, 10.022392340226245415q,
10.031298258747896515q, 12.028364464845623786q},
15, 0.0001q, 1e-20q);
#pragma omp task
testQuartic<float128>(
1, 1e-3, 7.5,
{2.0019955220947085337q, 4.0059806337201560486q, 6.0119494490457070830q, 6.0139360981896530736q,
8.0198961283737167314q, 8.0238606392924854844q, 10.029814877549869265q, 10.035748547202912722q,
10.037726447540990997q, 12.041699947383956422q},
15, 0.0001q, 1e-20q);
#pragma omp taskwait
}
}
TEST_CASE("Eigenfunctions quartic: c=0 (float128)", "[matslise2d][eigenvalues][quartic][float128][slow]") {
#pragma omp parallel
#pragma omp single
{
#pragma omp task
testQuartic<float128>(
-1, 1, 6,
{2.5616265756400316393q, 5.3968039831941313950q, 7.5491560629022652232q, 8.4359873223484674428q,
9.6175877647334193257q, 10.366020696842355027q, 12.818706298776658594q, 12.886584502841939840q,
13.406949149052421685q, 15.336126803517827432q},
25, 1e-6q, 1e-20q);
#pragma omp task
testQuartic<float128>(
0, 1, 5,
{2.7847032830605837113q, 6.0411643457423693920q, 9.2976254084241550728q, 10.047401599289601544q,
13.303862661971387225q, 14.549155539580166935q, 17.310099915518619376q, 17.805616602261952616q,
19.449909077833544750q, 21.811853855809184767q},
25, 1e-6q, 1e-20q);
#pragma omp task
testQuartic<float128>(
1, 1, 5,
{2.9520500919628742871q, 6.4629059998638721377q, 10.390627295503782127q, 10.882435576819807244q,
14.658513813565503097q, 15.482771577251666477q, 19.217523495888984907q, 20.293829707535892571q,
20.661082690597886009q, 24.033166193470850317q},
25, 1e-6q, 1e-20q);
#pragma omp taskwait
}
}
TEST_CASE("Eigenfunctions quartic: c=3 (float128)", "[matslise2d][eigenvalues][quartic][float128][slow]") {
// unsolvable
/* testQuartic<double>(-1, 1e3, 2.8,
{17.686909350775717644, 37.965440109662577256, 48.868379100596636584, 56.219242763197933124,
65.547004077171159352, 76.242494474221982538, 79.726698208795028150, 79.927690262545928550,
88.286001081585014158, 98.836631846113076108}); */
#pragma omp parallel
#pragma omp single
{
#pragma omp task
testQuartic<float128>(
0, 1e3q, 1.5,
{21.279577422656092127q, 48.726622170710310149q, 76.173666918764528170q, 85.321192911492859325q,
112.76823765954707735q, 127.24298764862115750q, 149.36280840032962652q, 154.69003239667537552q,
173.44216290830327624q, 191.28460313745792470q},
25, 1e-6q, 1e-20q);
#pragma omp task
testQuartic<float128>(
1, 1e3q, 1.5,
{23.513389183129853963q, 54.054855795519439394q, 89.433434033749367277q, 95.437449804059634223q,
128.61961618091473035q, 138.28303842944239989q, 170.99777828093744127q, 183.30633810778597643q,
187.54903714202645897q, 216.15194758663360719q},
25, 1e-6q, 1e-20q);
#pragma omp taskwait
}
}
#endif | 47.10929 | 119 | 0.664772 | [
"vector"
] |
5e88c9fd1065ab6b7582fda789d862179d381fe3 | 20,610 | cpp | C++ | src/plugins/azoth/plugins/murm/entrybase.cpp | devel29a/leechcraft | faf5e856010fb785e4bbf3ce7b5c6a5c49f3239a | [
"BSL-1.0"
] | null | null | null | src/plugins/azoth/plugins/murm/entrybase.cpp | devel29a/leechcraft | faf5e856010fb785e4bbf3ce7b5c6a5c49f3239a | [
"BSL-1.0"
] | null | null | null | src/plugins/azoth/plugins/murm/entrybase.cpp | devel29a/leechcraft | faf5e856010fb785e4bbf3ce7b5c6a5c49f3239a | [
"BSL-1.0"
] | null | null | null | /**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2006-2014 Georg Rudoy
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
#include "entrybase.h"
#include <boost/variant.hpp>
#include <boost/optional.hpp>
#include <QIcon>
#include <QXmlStreamWriter>
#include <util/util.h>
#include <util/sll/urloperator.h>
#include <util/sll/qtutil.h>
#include <util/sys/extensionsdata.h>
#include <interfaces/core/iiconthememanager.h>
#include <interfaces/azoth/azothutil.h>
#include <interfaces/azoth/iproxyobject.h>
#include "vkaccount.h"
#include "vkmessage.h"
#include "vkconnection.h"
#include "xmlsettingsmanager.h"
namespace LeechCraft
{
namespace Azoth
{
namespace Murm
{
EntryBase::EntryBase (VkAccount *acc)
: QObject (acc)
, Account_ (acc)
{
}
void EntryBase::Store (VkMessage *msg)
{
Messages_ << msg;
emit gotMessage (msg);
}
QObject* EntryBase::GetQObject ()
{
return this;
}
IAccount* EntryBase::GetParentAccount () const
{
return Account_;
}
IMessage* EntryBase::CreateMessage (IMessage::Type type, const QString&, const QString& body)
{
auto msg = new VkMessage (true, IMessage::Direction::Out, type, this);
msg->SetBody (body);
return msg;
}
QList<IMessage*> EntryBase::GetAllMessages () const
{
QList<IMessage*> result;
for (auto obj : Messages_)
result << obj;
return result;
}
void EntryBase::PurgeMessages (const QDateTime& before)
{
AzothUtil::StandardPurgeMessages (Messages_, before);
}
void EntryBase::MarkMsgsRead ()
{
Account_->GetParentProtocol ()->GetAzothProxy ()->MarkMessagesAsRead (this);
if (!HasUnread_)
return;
QList<qulonglong> ids;
for (auto msg : Messages_)
if (!msg->IsRead ())
{
ids << msg->GetID ();
msg->SetRead ();
}
HasUnread_ = false;
if (!ids.isEmpty ())
Account_->GetConnection ()->MarkAsRead (ids);
}
namespace
{
const QString AudioDivStyle = "border-color: #CDCCCC; "
"margin-top: 2px; margin-bottom: 0px; "
"border-width: 1px; border-style: solid; border-radius: 5px; "
"padding-left: 5px; padding-right: 5px; padding-top: 2px; padding-bottom: 2px;";
const QString RepostDivStyle = "border-color: #ABAAAA; "
"margin-top: 2px; margin-bottom: 0px; margin-left: 1em; margin-right: 0em; "
"border-width: 1px; border-style: solid; border-radius: 5px; "
"padding-left: 5px; padding-right: 5px; padding-top: 2px; padding-bottom: 2px;";
struct SimpleImageInfo
{
const QString Url_;
const QString Alt_ = {};
const boost::optional<QSize> Size_ = {};
SimpleImageInfo (const QString& url)
: Url_ { url }
{
}
SimpleImageInfo (const QString& url, const QString& alt, const QSize& size)
: Url_ { url }
, Alt_ { alt }
, Size_ { size }
{
}
};
struct LinkImageInfo
{
const QString FullUrl_;
const QString ThumbUrl_;
const QString Alt_;
const boost::optional<QSize> FullSize_;
const boost::optional<QSize> ThumbSize_;
};
using ImageInfo = boost::variant<SimpleImageInfo, LinkImageInfo>;
void WriteImgDims (QXmlStreamWriter& w, const boost::optional<QSize>& size)
{
if (!size)
return;
w.writeAttribute ("width", QString::number (size->width ()));
w.writeAttribute ("height", QString::number (size->height ()));
}
QString GetImageTemplate (const ImageInfo& imageInfo)
{
struct EmbedVisitor : boost::static_visitor<QString>
{
QString operator() (const SimpleImageInfo& info) const
{
QString result;
QXmlStreamWriter w { &result };
w.writeStartElement ("img");
w.writeAttribute ("src", info.Url_);
w.writeAttribute ("alt", info.Alt_);
w.writeAttribute ("title", info.Alt_);
WriteImgDims (w, info.Size_);
w.writeEndElement ();
return result;
}
QString operator() (const LinkImageInfo& info) const
{
QString result;
const auto& alt = (info.Alt_.isEmpty () && info.FullSize_) ?
QString::number (info.FullSize_->width ()) +
QString::fromUtf8 ("×") +
QString::number (info.FullSize_->height ()) :
info.Alt_;
QXmlStreamWriter w { &result };
w.writeStartElement ("a");
w.writeAttribute ("href", info.FullUrl_);
w.writeAttribute ("target", "_blank");
w.writeStartElement ("img");
w.writeAttribute ("src", info.ThumbUrl_);
w.writeAttribute ("alt", alt);
w.writeAttribute ("title", alt);
WriteImgDims (w, info.ThumbSize_);
w.writeEndElement ();
w.writeEndElement ();
return result;
}
};
struct LinkVisitor : boost::static_visitor<QString>
{
QString operator() (const SimpleImageInfo& info) const
{
QString result;
QXmlStreamWriter w { &result };
w.writeStartElement ("a");
w.writeAttribute ("href", info.Url_);
if (!info.Alt_.isEmpty ())
w.writeCharacters (info.Alt_);
else if (info.Size_)
w.writeCharacters (QObject::tr ("Image, %1 by %2 pixels.")
.arg (info.Size_->width ())
.arg (info.Size_->height ()));
else
w.writeCharacters (QObject::tr ("Image"));
w.writeEndElement ();
return result;
}
QString operator() (const LinkImageInfo& info) const
{
QString result;
const auto& alt = (info.Alt_.isEmpty () && info.FullSize_) ?
QObject::tr ("Image, %1 by %2 pixels.")
.arg (info.FullSize_->width ())
.arg (info.FullSize_->height ()) :
info.Alt_;
QXmlStreamWriter w { &result };
w.writeStartElement ("a");
w.writeAttribute ("href", info.FullUrl_);
w.writeAttribute ("target", "_blank");
w.writeCharacters (alt);
w.writeEndElement ();
return result;
}
};
const auto& showOpt = XmlSettingsManager::Instance ()
.property ("ShowImagesInChat").toString ();
if (showOpt == "Embedded")
return boost::apply_visitor (EmbedVisitor {}, imageInfo);
else if (showOpt == "Links")
return boost::apply_visitor (LinkVisitor {}, imageInfo);
qWarning () << Q_FUNC_INFO
<< "unknown show option type"
<< showOpt;
return {};
}
QString Gift2Replacement (const GiftInfo& info)
{
return GetImageTemplate (SimpleImageInfo { info.Thumb_.toEncoded () });
}
QString Photo2Replacement (const PhotoInfo& info)
{
return GetImageTemplate (LinkImageInfo
{
info.Full_,
info.Thumbnail_,
{},
info.FullSize_,
info.ThumbnailSize_
});
}
QString Icon2Img (const QIcon& icon, const QString& name)
{
return GetImageTemplate (SimpleImageInfo
{
LeechCraft::Util::GetAsBase64Src (icon.pixmap (16, 16).toImage ()),
name,
{ 16, 16 }
});
}
QString Audio2Replacement (const AudioInfo& info, const ICoreProxy_ptr& proxy)
{
auto durStr = LeechCraft::Util::MakeTimeFromLong (info.Duration_);
if (durStr.startsWith ("00:"))
durStr = durStr.mid (3);
QUrl azothUrl;
azothUrl.setScheme ("azoth");
azothUrl.setHost ("sendentities");
Util::UrlOperator { azothUrl }
("count", "1")
("entityVar0", info.URL_.toEncoded ())
("entityType0", "url")
("addCount0", "1");
auto enqueueUrl = azothUrl;
Util::UrlOperator { enqueueUrl }
("flags0", "OnlyHandle")
("add0key0", "Action")
("add0value0", "AudioEnqueue");
auto playUrl = azothUrl;
Util::UrlOperator { playUrl }
("flags0", "OnlyHandle")
("add0key0", "Action")
("add0value0", "AudioEnqueuePlay");
auto downloadUrl = azothUrl;
Util::UrlOperator { downloadUrl }
("flags0", "OnlyDownload");
QString result;
auto addImage = [&proxy, &result] (const QString& icon, const QString& name)
{
result += Icon2Img (proxy->GetIconThemeManager ()->GetIcon (icon), name);
};
result += "<div style='" + AudioDivStyle + "'>";
result += "<a href='";
result += QString::fromUtf8 (enqueueUrl.toEncoded ());
result += "'>";
addImage ("list-add", EntryBase::tr ("Enqueue"));
result += "</a> <a href='";
result += QString::fromUtf8 (playUrl.toEncoded ());
result += "'>";
addImage ("media-playback-start", EntryBase::tr ("Play"));
result += "</a> <a href='";
result += QString::fromUtf8 (downloadUrl.toEncoded ());
result += "'>";
addImage ("download", EntryBase::tr ("Download"));
result += "</a> ";
result += info.Artist_ + QString::fromUtf8 (" — ") + info.Title_;
result += " <span style='float:right'>" + durStr + "</span>";
result += "</div>";
return result;
}
QString Video2Replacement (const VideoInfo& info, const ICoreProxy_ptr&)
{
QString result = "<div>";
result += QString ("<a href='http://vk.com/video%1_%2' target='_blank'>")
.arg (info.OwnerID_)
.arg (info.ID_);
result += QString ("<img src='%1' width='320' height='240' alt='' /><br />")
.arg (info.Image_.toEncoded ().constData ());
result += "<strong>" + info.Title_ + "</strong> ";
if (!info.Desc_.isEmpty ())
result += "(" + info.Desc_ + ") ";
result += "[" + LeechCraft::Util::MakeTimeFromLong (info.Duration_) + "] <br />";
result += "</a></div>";
return result;
}
QString Document2Replacement (const DocumentInfo& info, const ICoreProxy_ptr&)
{
QString result = "<div>";
const auto& icon = Util::ExtensionsData::Instance ().GetExtIcon (info.Extension_);
result += Icon2Img (icon, info.Extension_);
result += QString::fromUtf8 ("<a href='%1'>%2</a> — ")
.arg (info.Url_.toEncoded ().constData ())
.arg (info.Title_);
result += EntryBase::tr ("%1 document, size: %2")
.arg (info.Extension_.toUpper ())
.arg (Util::MakePrettySize (info.Size_));
result += "</div>";
return result;
}
QString PagePreview2Replacement (const PagePreview& info)
{
QString result = "<div>";
result += EntryBase::tr ("Page:") + QString (" <a href='%1'>%2</a>")
.arg (info.Url_.toEncoded ().constData ())
.arg (info.Title_);
result += "</div>";
return result;
}
QString StickerId2Replacement (const QString& stickerId)
{
const auto stickerSize = XmlSettingsManager::Instance ().property ("StickersSize").toInt ();
return GetImageTemplate (SimpleImageInfo
{
QString { "https://vk.com/images/stickers/%1/%2.png" }
.arg (stickerId)
.arg (stickerSize),
{},
{ stickerSize, stickerSize }
});
}
struct ContentsInfo
{
QString Contents_;
bool HasAdditionalInfo_;
QStringList FwdIds_;
};
QString ProcessMessageBody (QString body)
{
QRegExp rx { "\\[([a-z]+[0-9]+)\\|(.*)\\]", Qt::CaseInsensitive, QRegExp::RegExp2 };
rx.setMinimal (true);
body.replace (rx, "<a href='https://vk.com/\\1'>\\2</a>");
return body;
}
ContentsInfo ToMessageContents (const MessageInfo& info)
{
auto newContents = ProcessMessageBody (info.Text_);
struct AttachInfo
{
QString Type_;
QString ID_;
};
QMap<int, AttachInfo> attaches;
const QString attachMarker ("attach");
const QString typeMarker ("_type");
for (const auto& pair : Util::Stlize (info.Params_))
{
auto key = pair.first;
if (!key.startsWith (attachMarker))
continue;
key = key.mid (attachMarker.size ());
const bool isType = key.endsWith (typeMarker);
if (isType)
key.chop (typeMarker.size ());
bool ok = false;
const auto num = key.toInt (&ok);
if (!ok)
continue;
auto& attach = attaches [num];
if (isType)
attach.Type_ = pair.second.toString ();
else
attach.ID_ = pair.second.toString ();
}
QStringList photoIds, wallIds, audioIds, videoIds, docIds, pageIds;
for (const auto& info : attaches)
if (info.Type_ == "photo")
photoIds << info.ID_;
else if (info.Type_ == "wall")
wallIds << info.ID_;
else if (info.Type_ == "audio")
audioIds << info.ID_;
else if (info.Type_ == "video")
videoIds << info.ID_;
else if (info.Type_ == "doc")
docIds << info.ID_;
else if (info.Type_ == "page")
pageIds << info.ID_;
else if (info.Type_ == "sticker")
newContents += "<br/>" + StickerId2Replacement (info.ID_);
const auto hasAdditional = !photoIds.isEmpty () ||
!wallIds.isEmpty () ||
!audioIds.isEmpty () ||
!videoIds.isEmpty () ||
!docIds.isEmpty () ||
!pageIds.isEmpty ();
for (const auto& id : photoIds)
newContents += "<div id='photostub_" + id + "'></div>";
for (const auto& id : wallIds)
newContents += "<div id='wallstub_" + id + "'></div>";
for (const auto& id : audioIds)
newContents += "<div id='audiostub_" + id + "'></div>";
for (const auto& id : videoIds)
newContents += "<div id='videostub_" + id + "'></div>";
for (const auto& id : docIds)
newContents += "<div id='docstub_" + id + "'></div>";
for (const auto& id : pageIds)
newContents += "<div id='pagestub_" + id + "'></div>";
const auto& fwdIds = info.Params_.value ("fwd")
.toString ().split (',', QString::SkipEmptyParts);
for (const auto& id : fwdIds)
newContents += "<div id='fwdstub_" + id + "'></div>";
return { newContents, hasAdditional, fwdIds };
}
enum class FullInfoMode
{
Normal,
Forward,
Repost
};
QString FullInfo2Replacement (const FullMessageInfo& info, const ICoreProxy_ptr& proxy, FullInfoMode mode)
{
QString replacement;
if (mode == FullInfoMode::Forward)
{
replacement += "<div>";
replacement += EntryBase::tr ("Forwarded message from %1")
.arg (info.PostDate_.toString ());
replacement += "</div>";
}
replacement += ProcessMessageBody (info.Text_);
for (const auto& gift : info.Gifts_)
replacement += "<br/>" + Gift2Replacement (gift);
for (const auto& sticker : info.Stickers_)
replacement += "<br/>" + StickerId2Replacement (sticker.Id_);
for (const auto& photo : info.Photos_)
replacement += "<br/>" + Photo2Replacement (photo);
for (const auto& video : info.Videos_)
replacement += "<br/>" + Video2Replacement (video, proxy);
for (const auto& page : info.PagesPreviews_)
replacement += "<br/>" + PagePreview2Replacement (page);
if (!info.Audios_.empty ())
{
replacement += "<div>";
for (const auto& audio : info.Audios_)
replacement += Audio2Replacement (audio, proxy);
replacement += "</div>";
}
if (!info.Documents_.isEmpty ())
{
replacement += "<div>";
for (const auto& doc : info.Documents_)
replacement += Document2Replacement (doc, proxy);
replacement += "</div>";
}
for (const auto& repost : info.ContainedReposts_)
{
replacement += "<div style='" + RepostDivStyle + "'>";
replacement += FullInfo2Replacement (repost, proxy, FullInfoMode::Repost);
replacement += "</div>";
}
for (const auto& fwd : info.ForwardedMessages_)
{
replacement += "<div style='" + RepostDivStyle + "'>";
replacement += FullInfo2Replacement (fwd, proxy, FullInfoMode::Forward);
replacement += "</div>";
}
if (mode == FullInfoMode::Repost)
{
replacement += "<div style='text-align:right'>";
replacement += EntryBase::tr ("Posted on: %1")
.arg (info.PostDate_.toString ());
if (info.Likes_ || info.Reposts_)
{
replacement += "<br/>";
replacement += EntryBase::tr ("%n like(s)", 0, info.Likes_);
replacement += "; ";
replacement += EntryBase::tr ("%n repost(s)", 0, info.Reposts_);
}
replacement += "</div>";
}
return replacement;
}
template<typename T, typename R>
void AppendReplacements (QList<QPair<QString, QString>>& replacements,
const QString& name, const QList<T>& items, const R& func)
{
for (const auto& item : items)
{
const auto& id = QString ("%1_%2_%3")
.arg (name)
.arg (item.OwnerID_)
.arg (item.ID_);
replacements.append ({ id, func (item) });
}
}
}
void EntryBase::HandleAttaches (VkMessage *msg, const MessageInfo& info, const FullMessageInfo& full)
{
if (full.ID_)
{
const auto& body = FullInfo2Replacement (full, Account_->GetCoreProxy (), FullInfoMode::Normal);
msg->SetBody (body);
return;
}
const auto& contentsInfo = ToMessageContents (info);
msg->SetBody (contentsInfo.Contents_);
QPointer<VkMessage> safeMsg (msg);
for (const auto& idStr : contentsInfo.FwdIds_)
{
std::size_t endIdx = 0;
const auto id = std::stoull (idStr.section ('_', 1, 1).toStdString (), &endIdx);
if (!endIdx)
{
qWarning () << Q_FUNC_INFO
<< "unable to parse message ID"
<< idStr;
continue;
}
Account_->GetConnection ()->GetMessageInfo (id,
[this, safeMsg, idStr] (const FullMessageInfo& msgInfo)
{
if (!safeMsg)
return;
auto body = safeMsg->GetBody ();
const auto& id = "fwdstub_" + idStr;
auto repl = "<div style='" + RepostDivStyle + "'>";
repl += FullInfo2Replacement (msgInfo,
Account_->GetCoreProxy (), FullInfoMode::Forward);
repl += "</div>";
PerformReplacements ({ { id, repl } }, body);
safeMsg->SetBody (body);
});
}
if (!contentsInfo.HasAdditionalInfo_)
return;
Account_->GetConnection ()->GetMessageInfo (msg->GetID (),
[safeMsg] (const FullMessageInfo& msgInfo)
{
if (!safeMsg)
return;
const auto safeThis = qobject_cast<EntryBase*> (safeMsg->ParentCLEntry ());
safeThis->HandleFullMessageInfo (msgInfo, safeMsg);
});
}
void EntryBase::HandleFullMessageInfo (const FullMessageInfo& msgInfo, VkMessage *msg)
{
const auto& proxy = Account_->GetCoreProxy ();
QList<QPair<QString, QString>> replacements;
AppendReplacements (replacements, "photostub", msgInfo.Photos_, &Photo2Replacement);
AppendReplacements (replacements, "pagestub", msgInfo.PagesPreviews_, &PagePreview2Replacement);
AppendReplacements (replacements, "audiostub", msgInfo.Audios_,
[proxy] (const AudioInfo& info) { return Audio2Replacement (info, proxy); });
AppendReplacements (replacements, "videostub", msgInfo.Videos_,
[proxy] (const VideoInfo& info) { return Video2Replacement (info, proxy); });
AppendReplacements (replacements, "docstub", msgInfo.Documents_,
[proxy] (const DocumentInfo& info) { return Document2Replacement (info, proxy); });
AppendReplacements (replacements, "wallstub", msgInfo.ContainedReposts_,
[proxy] (const FullMessageInfo& info) { return FullInfo2Replacement (info, proxy, FullInfoMode::Repost); });
auto body = msg->GetBody ();
PerformReplacements (replacements, body);
msg->SetBody (body);
}
void EntryBase::PerformReplacements (QList<QPair<QString, QString>> replacements, QString& body)
{
QString js;
for (auto& pair : replacements)
{
body.replace ("<div id='" + pair.first + "'></div>",
"<div>" + pair.second + "</div>");
pair.second.replace ('\n', "<br/>");
pair.second.replace ('\\', "\\\\");
pair.second.replace ('"', "\\\"");
js += QString ("try { document.getElementById('%1').innerHTML = \"%2\"; } catch (e) { console.log(e); };")
.arg (pair.first)
.arg (pair.second);
}
emit performJS (js);
}
}
}
}
| 28.825175 | 112 | 0.630956 | [
"object",
"solid"
] |
5e8e268d6e3986fd33d81588381df47cf1a82eaa | 610 | hpp | C++ | Assignment7/Intersection.hpp | Antares0982/GAMES101 | d45cf6ad14fb633e64ecc5ef10e8637d27472f00 | [
"MIT"
] | 1 | 2021-12-19T08:33:48.000Z | 2021-12-19T08:33:48.000Z | Assignment7/Intersection.hpp | Antares0982/GAMES101 | d45cf6ad14fb633e64ecc5ef10e8637d27472f00 | [
"MIT"
] | null | null | null | Assignment7/Intersection.hpp | Antares0982/GAMES101 | d45cf6ad14fb633e64ecc5ef10e8637d27472f00 | [
"MIT"
] | null | null | null | //
// Created by LEI XU on 5/16/19.
//
#ifndef RAYTRACING_INTERSECTION_H
#define RAYTRACING_INTERSECTION_H
#include "Material.hpp"
#include "Vector.hpp"
class Object;
class Sphere;
struct Intersection {
Intersection() {
happened = false;
coords = Vector3f();
normal = Vector3f();
distance = std::numeric_limits<double>::max();
obj = nullptr;
m = nullptr;
}
bool happened;
Vector3f coords;
Vector3f tcoords;
Vector3f normal;
Vector3f emit;
double distance;
Object *obj;
Material *m;
};
#endif //RAYTRACING_INTERSECTION_H
| 19.677419 | 54 | 0.640984 | [
"object",
"vector"
] |
5e8f976b0c82f0cc76da1505e6ef5106a713eedb | 808 | cpp | C++ | cpp/offer63_max_profit.cpp | CharleyZhao123/sweat_and_harvest | a898fb0e7923b60c8ff04f023c380d87a26e5f5f | [
"MIT"
] | null | null | null | cpp/offer63_max_profit.cpp | CharleyZhao123/sweat_and_harvest | a898fb0e7923b60c8ff04f023c380d87a26e5f5f | [
"MIT"
] | null | null | null | cpp/offer63_max_profit.cpp | CharleyZhao123/sweat_and_harvest | a898fb0e7923b60c8ff04f023c380d87a26e5f5f | [
"MIT"
] | null | null | null | #include <iostream>
#include <vector>
using namespace std;
class Solution
{
public:
// dp[i] = max{dp[i-1], (prices[i] - before_min_price)}
// 两种选择: 今天i卖, 今天i不卖, 那个利润多选哪个
// 今天卖: prices[i] - before_min_price
// 今天不卖: dp[i-1]
int maxProfit(vector<int> &prices)
{
int nums = prices.size();
if (nums <= 1)
return 0;
int max_profit = 0;
int min_price = prices[0];
int now_profit = 0;
for (int i=1; i<nums; i++)
{
now_profit = prices[i] - min_price;
if (now_profit > max_profit)
max_profit = now_profit;
if (prices[i] < min_price)
min_price = prices[i];
}
return max_profit;
}
};
int main()
{
return 0;
} | 21.263158 | 59 | 0.498762 | [
"vector"
] |
5e94a388fb671284005357ec845f06889329a79a | 1,243 | cpp | C++ | 0378_Kth Smallest Element in a Sorted Matrix.cpp | RickTseng/Cpp_LeetCode | 6a710b8abc268eba767bc17d91d046b90a7e34a9 | [
"MIT"
] | 1 | 2021-09-13T00:58:59.000Z | 2021-09-13T00:58:59.000Z | 0378_Kth Smallest Element in a Sorted Matrix.cpp | RickTseng/Cpp_LeetCode | 6a710b8abc268eba767bc17d91d046b90a7e34a9 | [
"MIT"
] | null | null | null | 0378_Kth Smallest Element in a Sorted Matrix.cpp | RickTseng/Cpp_LeetCode | 6a710b8abc268eba767bc17d91d046b90a7e34a9 | [
"MIT"
] | null | null | null | #include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<queue>
using namespace std;
class Solution {
public:
int kthSmallest(vector<vector<int>>& matrix, int k) {
vector<int> db;
for(int r = 0;r<matrix.size();r++){
for(int c = 0;c<matrix[r].size();c++){
db.push_back(matrix[r][c]);
}
}
sort(db.begin(),db.end());
return db[k-1];
}
};
int main(){
vector<vector<int>> matrix = {{1,5,9},{10,11,13},{12,13,15}};
vector<vector<int>> matrix1 = {{1,2},{1,3}};
Solution sol;
int ans = sol.kthSmallest(matrix1,2);
}
/*
Input: matrix = {{1,5,9},{10,11,13},{12,13,15}}, k = 8
Output: 13
Explanation: The elements in the matrix are {1,5,9,10,11,12,13,13,15}, and the 8th smallest number is 13
Constraints:
n == matrix.length == matrix[i].length
1 <= n <= 300
-10^9 <= matrix[i][j] <= 10^9
All the rows and columns of matrix are guaranteed to be sorted in non-decreasing order.
1 <= k <= n2
Runtime: 32 ms, faster than 71.24% of C++ online submissions for Kth Smallest Element in a Sorted Matrix.
Memory Usage: 14.5 MB, less than 30.02% of C++ online submissions for Kth Smallest Element in a Sorted Matrix.
*/ | 28.906977 | 110 | 0.606597 | [
"vector"
] |
5e9693306be86fdb642da791dcf22af3c2c8d13d | 3,882 | hpp | C++ | src/unity/lib/annotation/annotation_base.hpp | ZeroInfinite/turicreate | dd210c2563930881abd51fd69cb73007955b33fd | [
"BSD-3-Clause"
] | null | null | null | src/unity/lib/annotation/annotation_base.hpp | ZeroInfinite/turicreate | dd210c2563930881abd51fd69cb73007955b33fd | [
"BSD-3-Clause"
] | 2 | 2022-01-13T04:03:55.000Z | 2022-03-12T01:02:31.000Z | src/unity/lib/annotation/annotation_base.hpp | ZeroInfinite/turicreate | dd210c2563930881abd51fd69cb73007955b33fd | [
"BSD-3-Clause"
] | null | null | null | #ifndef TURI_ANNOTATIONS_ANNOTATION_BASE_HPP
#define TURI_ANNOTATIONS_ANNOTATION_BASE_HPP
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <export.hpp>
#include <flexible_type/flexible_type.hpp>
#include <unity/lib/extensions/ml_model.hpp>
#include <unity/lib/unity_sarray.hpp>
#include <unity/lib/unity_sframe.hpp>
#include "build/format/cpp/annotate.pb.h"
#include "build/format/cpp/data.pb.h"
#include "build/format/cpp/message.pb.h"
#include "build/format/cpp/meta.pb.h"
namespace annotate_spec = TuriCreate::Annotation::Specification;
namespace turi {
namespace annotate {
/**
*
* Fallback
*
* If the user forgets to assign a return variable in their Python script this
* global will hold the last annotated sframe
*/
struct EXPORT annotation_global : public ml_model_base {
std::shared_ptr<unity_sframe> annotation_sframe;
std::shared_ptr<unity_sframe> get_value() { return annotation_sframe; }
BEGIN_CLASS_MEMBER_REGISTRATION("annotation_global")
REGISTER_GETTER("annotation_sframe", annotation_global::get_value)
END_CLASS_MEMBER_REGISTRATION
};
/**
* Every annotation backend extends from this class. This forces the annotation
* api to remain consistent across all implementations. The reason the virtual
* methods exist rather than a switch statement in the annotate method is to
* expose this functionality to the capi so that other developers have the
* ability to tie their own annotations UI's to use this api.
*/
class EXPORT AnnotationBase : public ml_model_base {
public:
AnnotationBase(){};
AnnotationBase(const std::shared_ptr<unity_sframe> &data,
const std::vector<std::string> &data_columns,
const std::string &annotation_column);
virtual ~AnnotationBase(){};
void annotate(const std::string &path_to_client);
size_t size();
std::shared_ptr<unity_sframe> returnAnnotations(bool drop_null = false);
std::shared_ptr<annotation_global> get_annotation_registry();
virtual annotate_spec::MetaData metaData() = 0;
virtual annotate_spec::Data getItems(size_t start, size_t end) = 0;
virtual annotate_spec::Annotations getAnnotations(size_t start,
size_t end) = 0;
virtual bool
setAnnotations(const annotate_spec::Annotations &annotations) = 0;
BEGIN_BASE_CLASS_MEMBER_REGISTRATION()
IMPORT_BASE_CLASS_REGISTRATION(ml_model_base);
REGISTER_NAMED_CLASS_MEMBER_FUNCTION("annotate", AnnotationBase::annotate,
"path_to_client");
REGISTER_NAMED_CLASS_MEMBER_FUNCTION("returnAnnotations",
AnnotationBase::returnAnnotations,
"drop_null");
register_defaults("returnAnnotations", {{"drop_null", false}});
REGISTER_NAMED_CLASS_MEMBER_FUNCTION("get_annotation_registry",
AnnotationBase::get_annotation_registry);
// TODO: Potentially plumb `::google::protobuf::MessageLite` to variant
// type.
END_CLASS_MEMBER_REGISTRATION
protected:
std::shared_ptr<unity_sframe> m_data;
const std::vector<std::string> m_data_columns;
std::string m_annotation_column;
void _addAnnotationColumn();
void _addIndexColumn();
void _checkDataSet();
void _reshapeIndicies(size_t &start, size_t &end);
private:
/* A little trick to overload the `__serialize_proto` function at compile time
* so I don't have to define that for every Annotation::Specification type.
*
* Using the SFINAE method: https://en.cppreference.com/w/cpp/language/sfinae
*/
template <typename T, typename = typename std::enable_if<std::is_base_of<
::google::protobuf::MessageLite, T>::value>::type>
std::string __serialize_proto(T message);
};
} // namespace annotate
} // namespace turi
#endif
| 31.306452 | 80 | 0.718959 | [
"vector"
] |
5e9d22244b7bf7687a651f54f06ebfa01f655cc8 | 2,072 | cpp | C++ | sigscan.cpp | tcpie/hook_any_x64 | bc48e80e82a37b37f1498835276a7d20fd56bf82 | [
"MIT",
"Zlib",
"BSD-3-Clause"
] | 19 | 2021-07-17T05:37:10.000Z | 2021-07-29T07:54:14.000Z | sigscan.cpp | c3358/hook_any_x64 | bc48e80e82a37b37f1498835276a7d20fd56bf82 | [
"MIT",
"Zlib",
"BSD-3-Clause"
] | null | null | null | sigscan.cpp | c3358/hook_any_x64 | bc48e80e82a37b37f1498835276a7d20fd56bf82 | [
"MIT",
"Zlib",
"BSD-3-Clause"
] | 6 | 2021-07-17T05:37:11.000Z | 2021-07-28T12:51:41.000Z | #include "sigscan.h"
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <windows.h>
#include <winbase.h>
#include <winnt.h>
#include <Psapi.h>
#include <winternl.h>
#include <stdint.h>
#include <iostream>
uint64_t search_start = 0;
DWORD search_size = 0;
void init_sigscan()
{
HANDLE currProcess = GetCurrentProcess();
MODULEINFO modInfo = { NULL, };
GetModuleInformation(currProcess, GetModuleHandleA("GTA5.exe"), &modInfo, sizeof(modInfo));
DWORD dummyDword = NULL;
search_start = (uint64_t)modInfo.lpBaseOfDll;
search_size = modInfo.SizeOfImage;
}
void* sigscan(const std::string& pattern)
{
std::istringstream iss(pattern);
std::vector<std::string> tokens{ std::istream_iterator<std::string>{iss},
std::istream_iterator<std::string>{} };
std::vector<uint8_t> vals;
std::vector<char> mask;
for (auto str : tokens)
{
if (str == "??") {
vals.push_back(1);
mask.push_back('?');
continue;
}
uint8_t val = std::stoul(str, nullptr, 16);
vals.push_back(val);
mask.push_back('x');
}
// NULL terminate our mask
mask.push_back('\0');
return sigscan(vals.data(), mask.data());
}
void* sigscan(const unsigned char* pattern, const char* mask)
{
if (search_start == 0 || search_size == 0) {
init_sigscan();
}
unsigned int patternLength = strlen(mask);
for (uint64_t i = 0; i < search_size - patternLength; i++)
{
bool found = true;
for (uint64_t j = 0; j < patternLength; j++)
{
if (mask[j] != '?' && pattern[j] != *(uint8_t*)(search_start + i + j))
{
found = false;
break;
}
}
if (found)
{
return (char*)(search_start + i);
}
}
return nullptr;
} | 23.280899 | 96 | 0.548263 | [
"vector"
] |
5ea593d505b224de704b81b1e0d9a3ebd4c9cfb2 | 3,071 | cpp | C++ | src/cr_chart.cpp | carmeloevoli/D2XSECS | 8c12bce59bce2f51555bd15f0824f9a8c056bd7e | [
"MIT"
] | 2 | 2018-05-24T14:57:56.000Z | 2018-12-13T13:35:20.000Z | src/cr_chart.cpp | cosmicrays/D2XSECS | 8c12bce59bce2f51555bd15f0824f9a8c056bd7e | [
"MIT"
] | null | null | null | src/cr_chart.cpp | cosmicrays/D2XSECS | 8c12bce59bce2f51555bd15f0824f9a8c056bd7e | [
"MIT"
] | 1 | 2021-07-03T01:15:29.000Z | 2021-07-03T01:15:29.000Z | // Copyright (c) 2017 Carmelo Evoli - MIT License
#include "XS4GCR/cr_chart.h"
#include <algorithm>
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "XS4GCR/cgs.h"
namespace XS4GCR {
void DefaultCosmicRayChart::print() {
std::cout << "# using Default cosmic-ray chart" << std::endl;
}
void DefaultCosmicRayChart::init() { read_table(); }
DefaultCosmicRayChart::DefaultCosmicRayChart() { assert(Utils::file_exist(m_chart_filename)); }
void DefaultCosmicRayChart::read_table() {
std::string line;
if (Utils::file_exist(m_chart_filename)) {
std::ifstream in(m_chart_filename);
while (std::getline(in, line))
if (line.length() > 0 && line[0] != '#') {
add_isotope(line);
}
}
std::cout << " - read CR chart with " << m_chart.size() << " isotopes.\n";
}
void DefaultCosmicRayChart::add_isotope(const std::string& line) {
std::istringstream ss(line);
int A;
int Z;
std::string name;
std::string mode;
double tau;
ss >> Z >> A >> name >> mode >> tau;
tau *= cgs::kyr;
Decay_mode decay_mode;
if (mode == "STABLE") {
decay_mode = STABLE;
} else if (mode == "BETA-") {
decay_mode = BETA_MINUS;
} else if (mode == "BETA+") {
decay_mode = BETA_PLUS;
} else if (mode == "BETA-FED") {
decay_mode = BETA_MINUS_FED;
} else if (mode == "BETA+FED") {
decay_mode = BETA_PLUS_FED;
} else {
std::cerr << "Error: mode " << mode << "not found!";
exit(1);
}
auto pid = PID(Z, A);
decay_params params{tau, decay_mode};
auto ret = m_chart.insert(std::make_pair(pid, params));
if (ret.second == false) {
std::cout << "Warning: element " << pid << " already existed!\n";
}
}
std::shared_ptr<CosmicRayChart> DefaultCosmicRayChart::clone() {
return std::make_shared<DefaultCosmicRayChart>(*this);
}
double CosmicRayChart::get_halftime(PID particle) const {
auto it = m_chart.find(particle);
if (it != m_chart.end()) {
return it->second.tau_half;
} else {
std::cout << "Particle " << particle << " not found.\n";
return -1;
}
}
std::string CosmicRayChart::get_mode(PID particle) const {
auto it = m_chart.find(particle);
if (it != m_chart.end()) {
auto mode = it->second.mode;
if (mode == BETA_MINUS) {
return "B-";
} else if (mode == BETA_MINUS_FED) {
return "B-FED";
} else if (mode == BETA_PLUS) {
return "B+";
} else if (mode == BETA_PLUS_FED) {
return "B+FED";
} else {
return "STABLE";
}
} else {
std::cout << "Particle " << particle << " not found.\n";
return "none";
}
}
std::vector<PID> CosmicRayChart::get_particle_list() const {
std::vector<PID> list;
for (auto p : m_chart) list.push_back(p.first);
std::sort(list.begin(), list.end());
return list;
}
} // namespace XS4GCR
| 27.666667 | 95 | 0.578639 | [
"vector"
] |
5eb21be54147e463f9625f04fc341ea1e744209e | 44,769 | cpp | C++ | alib/src/a_expr.cpp | AndrewSav/csvfix | 1cb44ecdc04af5162947a8f9a24047029745e188 | [
"MIT"
] | 4 | 2022-01-25T15:54:29.000Z | 2022-03-18T21:32:16.000Z | alib/src/a_expr.cpp | AndrewSav/csvfix | 1cb44ecdc04af5162947a8f9a24047029745e188 | [
"MIT"
] | null | null | null | alib/src/a_expr.cpp | AndrewSav/csvfix | 1cb44ecdc04af5162947a8f9a24047029745e188 | [
"MIT"
] | 5 | 2021-12-14T05:42:52.000Z | 2022-03-11T04:23:47.000Z | //----------------------------------------------------------------------------
// a_expr.cpp
//
// simple expression eveluation
//
// Copyright (C) 2009 Neil Butterworth
//----------------------------------------------------------------------------
#include "a_base.h"
#include "a_str.h"
#include "a_expr.h"
#include "a_collect.h"
#include "a_rand.h"
#include "a_date.h"
#include "a_time.h"
#include "a_regex.h"
#include <stack>
#include <iostream>
#include <cmath>
#include <cstring>
#include <ctime>
#include <sstream>
#include <iomanip>
using std::string;
using std::vector;
using std::deque;
//----------------------------------------------------------------------------
namespace ALib {
//----------------------------------------------------------------------------
// Hack for user seeding of rng
//----------------------------------------------------------------------------
bool Expression :: mUseRNGSeed = false;
int Expression :: mRNGSeed = 0;
void Expression :: SetRNGSeed( int n ) {
mUseRNGSeed = true;
mRNGSeed = n;
}
int Expression :: GetRNGSeed() {
if ( mUseRNGSeed ) {
return mRNGSeed;
}
else {
return std::time(0);
}
}
//----------------------------------------------------------------------------
// Separator used between expressions
//----------------------------------------------------------------------------
const char * EXPR_SEP = ";";
//----------------------------------------------------------------------------
// Names of operators that cannot be used directly by user
//----------------------------------------------------------------------------
const char * UMINUS_STR = "UM"; // unary minus
const char * RDVAR_STR = "RV"; // read variable op
const char * FNCALL_STR = "FC"; // call function op
//----------------------------------------------------------------------------
// Characters used to denote special tokens
//----------------------------------------------------------------------------
const char CHAR_DQUOTE = '"'; // strings are delimeted by these
const char CHAR_SQUOTE = '\''; // or these
const char CHAR_VAR = '$'; // variables are preceded by these
const char CHAR_ESC = '\\'; // escappe next char
//----------------------------------------------------------------------------
// The tokeniser takes a string containing an expression and chops it up
// into tokens. Used by the expression compiler.
//----------------------------------------------------------------------------
class ExprTokeniser {
public:
ExprTokeniser( const std::string & expr );
ExprToken Get();
void DumpOn( std::ostream & os ) const;
private:
bool ReadWS();
char Next();
char Peek() const;
ExprToken ReadNum();
ExprToken ReadStr();
ExprToken ReadVar();
ExprToken ReadOp();
ExprToken ReadFunc();
ExprToken Error( const string & msg ) const;
bool mCanBeUnaryMinus;
std::string mExprs;
char mCurrent;
unsigned int mPos, mCol, mLine;
};
//----------------------------------------------------------------------------
// Compiler taks a string containing one or more expressions and produces
// an intermediate reverse poliish form that can be handled easily by
// the ectual expression evaluator
// TODO (neilb#1#): maybe change to use exceptions rather than string returns
//----------------------------------------------------------------------------
class ExprCompiler {
public:
ExprCompiler();
~ExprCompiler();
std::string Compile( const std::string & expr,
Expression::RPNRep & rep );
static void DumpRP( std::ostream & os, const Expression::RPNRep & rp );
private:
void PopSubExpr( Expression::RPNRep & rep );
void PopHigherPrec( const ExprToken & tok, Expression::RPNRep & rep );
std::stack <ExprToken> mStack;
std::stack <std::string> mFuncStack;
};
//----------------------------------------------------------------------------
// Singleton dictionary used to map funcrtion names to actual functions
//----------------------------------------------------------------------------
Dictionary <Expression::AddFunc> Expression::mFuncs;
//----------------------------------------------------------------------------
// helper macrro to add function to dictionary
//----------------------------------------------------------------------------
#define ADD_FUNC( name, fn, np ) \
static Expression::AddFunc reg_##fn##_( name, fn, np )
//----------------------------------------------------------------------------
// static method that does the real addi to dictionary
//----------------------------------------------------------------------------
void Expression :: AddFunction( const string & name, const AddFunc & f ) {
mFuncs.Add( name, f );
}
//----------------------------------------------------------------------------
// helper to get double version of function param - params are strings
//----------------------------------------------------------------------------
static double GetDParam( const deque <string> & params, int i ) {
string s = params.at( i );
if ( ! IsNumber( s ) ) {
ATHROW( "Invalid number: " << s );
}
return ToReal( s );
}
//----------------------------------------------------------------------------
// The following are the functions we currently support
//----------------------------------------------------------------------------
// if first param is true, return second param else return third
static string FuncIf( const deque <string> & params, Expression * ) {
if ( Expression::ToBool( params[0] ) ) {
return params[1];
}
else {
return params[2];
}
}
// Invert truth of param . We don't currently support '!' operator.
static string FuncNot( const deque <string> & params, Expression * ) {
if ( Expression::ToBool( params[0] ) ) {
return "0";
}
else {
return "1";
}
}
// Transform double param into an integer
static string FuncInt( const deque <string> & params, Expression * ) {
double n = GetDParam( params, 0 );
return Str( (int)n );
}
// Get absolute value of param
static string FuncAbs( const deque <string> & params, Expression * ) {
double n = GetDParam( params, 0 );
return Str( std::fabs( n ) );
}
// Get sign of param
static string FuncSign( const deque <string> & params, Expression * ) {
double n = GetDParam( params, 0 );
if ( n == 0 ) {
return "0";
}
else if ( n > 0 ) {
return "1";
}
else {
return "-1";
}
}
// Trim leading & trailing whitespace from param
static string FuncTrim( const deque <string> & params, Expression * ) {
return Str( Trim( params[0] ) );
}
// Return string converted to uppercase
static string FuncUpper( const deque <string> & params, Expression * ) {
return Str( Upper( params[0] ) );
}
// Return string converted to lowercase
static string FuncLower( const deque <string> & params, Expression * ) {
return Str( Lower( params[0] ) );
}
// Return length of param treaded as string
static string FuncLen( const deque <string> & params, Expression * ) {
return Str( params[0].size() );
}
// Return substring of first param specified by start and length
static string FuncSubstr( const deque <string> & params, Expression * ) {
int pos = int( GetDParam( params, 1 ) ) - 1;
if ( pos < 0 ) {
ATHROW( "Invalid position in substr()" );
}
int len = int( GetDParam( params, 2 ) );
if ( len < 0 ) {
ATHROW( "Invalid length in substr()" );
}
return params[0].substr( pos, len );
}
// Get position of second param in first. Returns zero on fail else
// one-based index of start of second param in first.
static string FuncPos( const deque <string> & params, Expression * ) {
string haystack = params[0];
string needle = params[1];
STRPOS pos = haystack.find( needle );
return Str( pos == STRNPOS ? 0 : pos + 1 );
}
// Is param a number (real or integer)
static string FuncIsNum( const deque <string> & params, Expression * ) {
return IsNumber( params[0] ) ? "1" : "0";
}
// Normalise param into boolean 1 (true) or 0 (false)
static string FuncBool( const deque <string> & params, Expression * ) {
if ( Expression::ToBool( params[0] ) ) {
return "1";
}
else {
return "0";
}
}
// Does param consist of only whitespace characters
static string FuncIsEmpty( const deque <string> & params, Expression * ) {
return params[0].find_first_not_of( " \t" ) == STRNPOS ? "1" : "0";
}
// return random number
static string FuncRandom( const deque <string> & params, Expression * ) {
static RandGen rg( Expression::GetRNGSeed() );
return Str( rg.NextReal() );
}
// get current date in ISO format
static string FuncToday( const deque <string> & params, Expression * ) {
Date d = Date::Today();
return d.Str();
}
// get current time in hh:mm:ss format
static string FuncNow( const deque <string> & params, Expression * ) {
Time t = Time::Now();
return t.Str();
}
// compare params as strings ignoring case
static string FuncStrEq( const deque <string> & params, Expression * ) {
return Str( Equal( params[0], params[1]) );
}
// see if regex matches string
static string FuncMatch( const deque <string> & params, Expression * ) {
RegEx re( params[1] );
RegEx::Pos pos = re.FindIn( params[0] );
return pos.Found() ? "1" : "0";
}
// get environment variable, or empty string
static string FuncGetenv( const deque <string> & params, Expression * ) {
const char * val = std::getenv( params[0].c_str() );
return val == NULL ? "" : val;
}
// min and max
static string FuncMin( const deque <string> & params, Expression * ) {
if ( IsNumber( params[0] ) && IsNumber( params[1] )) {
double n1 = GetDParam( params, 0 );
double n2 = GetDParam( params, 1 );
return n1 < n2 ? params[0] : params[1];
}
else {
return params[0] < params[1] ? params[0] : params[1];
}
}
static string FuncMax( const deque <string> & params, Expression * ) {
if ( IsNumber( params[0] ) && IsNumber( params[1] )) {
double n1 = GetDParam( params, 0 );
double n2 = GetDParam( params, 1 );
return n1 > n2 ? params[0] : params[1];
}
else {
return params[0] > params[1] ? params[0] : params[1];
}
}
// date validation and element access
static string FuncIsDate( const deque <string> & params, Expression * ) {
try {
Date d( params[0] );
}
catch( ... ) {
return "0";
}
return "1";
}
static string FuncDay( const deque <string> & params, Expression * ) {
try {
Date d( params[0] );
return Str( d.Day() );
}
catch( ... ) {
return "";
}
}
static string FuncMonth( const deque <string> & params, Expression * ) {
try {
Date d( params[0] );
return Str( d.Month() );
}
catch( ... ) {
return "";
}
}
static string FuncYear( const deque <string> & params, Expression * ) {
try {
Date d( params[0] );
return Str( d.Year() );
}
catch( ... ) {
return "";
}
}
// get 1-based index of first param in comma-list
static string FuncIndex( const deque <string> & params, Expression * ) {
CommaList cl( params[1] );
int idx = cl.Index( params[0] );
return Str( idx + 1 );
}
// pick 1-based value from comma list
static string FuncPick( const deque <string> & params, Expression * ) {
if ( ! IsInteger( params[0] )) {
ATHROW( "First parameter of pick() must be integer" );
}
int n = ToInteger( params[0] );
CommaList cl( params[1] );
if ( n < 1 || n > (int) cl.Size() ) {
return "";
}
else {
return cl.At( n - 1 );
}
}
// get field from current record - index is 1-based
static string FuncField( const deque <string> & params, Expression * e ) {
if ( ! IsInteger( params[0] )) {
ATHROW( "Parameter of field() must be integer" );
}
int i = ToInteger( params[0] ) - 1;
if ( i < 0 || i >= (int) e->PosParamCount() ) {
return "";
}
else {
return e->PosParam( i );
}
}
// check if number is an integer
static string FuncIsInt( const deque <string> & params, Expression * e ) {
return IsInteger( params[0] ) ? "1" : "0";
}
// try to match regex agains all positional parameters
// returns 1-based index of matching parameter, or 0 on no match
static string FuncFind( const deque <string> & params, Expression * e ) {
RegEx re( params[0] );
for ( unsigned int i = 0; i < e->PosParamCount(); i++ ) {
RegEx::Pos pos = re.FindIn( e->PosParam( i ) );
if ( pos.Found() ) {
return Str( i + 1 );
}
}
return "0";
}
// round number n to d decimal places
static string FuncRound( const deque <string> & params, Expression * e ) {
if ( ! IsInteger( params[1] )) {
ATHROW( "Second parameter of round() must be integer" );
}
double n = IsNumber( params[0] ) ? ToReal( params[0] ) : 0.0 ;
int d = ToInteger( params[1] );
if ( d < 0 ) {
ATHROW( "Second parameter of round() must be non-negative" );
}
std::ostringstream os;
os << std::fixed << std::setprecision( d ) << n;
return os.str();
}
//----------------------------------------------------------------------------
// Add all the functions to the function dictionary
//----------------------------------------------------------------------------
ADD_FUNC( "abs", FuncAbs, 1 );
ADD_FUNC( "bool", FuncBool, 1 );
ADD_FUNC( "day", FuncDay, 1 );
ADD_FUNC( "env", FuncGetenv, 1 );
ADD_FUNC( "field", FuncField, 1 );
ADD_FUNC( "find", FuncFind, 1 );
ADD_FUNC( "if", FuncIf, 3 );
ADD_FUNC( "index", FuncIndex, 2 );
ADD_FUNC( "int", FuncInt, 1 );
ADD_FUNC( "isdate", FuncIsDate, 1 );
ADD_FUNC( "isempty", FuncIsEmpty, 1 );
ADD_FUNC( "isint", FuncIsInt, 1 );
ADD_FUNC( "isnum", FuncIsNum, 1 );
ADD_FUNC( "month", FuncMonth, 1 );
ADD_FUNC( "not", FuncNot, 1 );
ADD_FUNC( "pos", FuncPos, 2 );
ADD_FUNC( "random", FuncRandom, 0 );
ADD_FUNC( "sign", FuncSign, 1 );
ADD_FUNC( "substr", FuncSubstr, 3 );
ADD_FUNC( "trim", FuncTrim, 1 );
ADD_FUNC( "today", FuncToday, 0 );
ADD_FUNC( "now", FuncNow, 0 );
ADD_FUNC( "upper", FuncUpper, 1 );
ADD_FUNC( "lower", FuncLower, 1 );
ADD_FUNC( "len", FuncLen, 1 );
ADD_FUNC( "streq", FuncStrEq, 2 );
ADD_FUNC( "match", FuncMatch, 2 );
ADD_FUNC( "max", FuncMax, 2 );
ADD_FUNC( "min", FuncMin, 2 );
ADD_FUNC( "pick", FuncPick, 2 );
ADD_FUNC( "year", FuncYear, 1 );
ADD_FUNC( "round", FuncRound, 2 );
//----------------------------------------------------------------------------
// Operator names and associated precedence
//----------------------------------------------------------------------------
struct OpEntry {
const char * mOp; // name
unsigned int mPrec; // precedence - high number == high precedence
};
OpEntry Ops[] = {
{"*", 10}, {"/",10}, {"%",10},
{"+",8}, {"-",8},
{"==", 6}, {"<>", 6}, {"!=", 6}, {"<=", 6}, {">=",6}, {"<", 6}, {">",6},
{".", 4 },
{"&&", 3 }, { "||", 3 },
{",", 2 },
{FNCALL_STR, 1 }, {"(",2}, {")",2}, // must be low
{EXPR_SEP, 0 }, // must be lowest prec
{NULL, 0} // must be null terminated
};
//----------------------------------------------------------------------------
// Dump token in readable form. Only used for debug.
//----------------------------------------------------------------------------
void ExprToken :: DumpOn( std::ostream & os ) const {
switch( mType ) {
case etNone: os << "NONE"; break;
case etOp: os << "OP "; break;
case etNum: os << "NUM "; break;
case etStr: os << "STR "; break;
case etVar: os << "VAR "; break;
case etFunc: os << "FUNC"; break;
case etError: os << "ERR "; break;
case etDone: os << "DONE" ; break;
default: ATHROW( "Bad token type " << mType );
}
os << " [" << mValue << "]" ;
}
//----------------------------------------------------------------------------
// is operator expression separator?
//----------------------------------------------------------------------------
bool ExprToken :: IsSep() const {
return Type() == etOp && Value() == EXPR_SEP;
}
//----------------------------------------------------------------------------
// create temp separator object for comparisons
// TODO (neilb#1#): should probably be function
//----------------------------------------------------------------------------
ExprToken ExprToken :: MakeSep() {
return ExprToken( etOp, EXPR_SEP, 0 );
}
//----------------------------------------------------------------------------
// Tokens are equal if have same type and same string rep
//----------------------------------------------------------------------------
bool ExprToken :: operator == ( const ExprToken & et ) const {
return mType == et.mType && mValue == et.mValue;
}
//----------------------------------------------------------------------------
// Create tokeniser from string to tokenise
//----------------------------------------------------------------------------
ExprTokeniser :: ExprTokeniser( const std::string & e )
: mCanBeUnaryMinus( true ), mExprs( e ), mPos( 0 ) {
Next();
}
//----------------------------------------------------------------------------
// Helper to create error token
//----------------------------------------------------------------------------
ExprToken ExprTokeniser :: Error( const string & msg ) const {
return ExprToken( ExprToken::etError, msg );
}
//----------------------------------------------------------------------------
// get next token, returning special etDone token when no more inut
//----------------------------------------------------------------------------
ExprToken ExprTokeniser :: Get() {
while( mCurrent ) {
if ( isspace( mCurrent ) ) {
ReadWS();
continue;
}
else if ( isdigit( mCurrent )
|| (mCurrent == '.' && isdigit( Peek()))) {
return ReadNum();
}
else if ( mCurrent == CHAR_VAR ) {
return ReadVar();
}
else if ( mCurrent == CHAR_DQUOTE || mCurrent == CHAR_SQUOTE ) {
return ReadStr();
}
else if ( isalpha( mCurrent ) ) {
return ReadFunc();
}
else {
return ReadOp();
}
}
return ExprToken( ExprToken::etDone, "" );
}
//----------------------------------------------------------------------------
// step to next character in tokeniser input, setting current value
//----------------------------------------------------------------------------
char ExprTokeniser :: Next() {
if ( mPos >= mExprs.size() ) {
return mCurrent = 0;
}
mCurrent = mExprs[ mPos++ ];
if ( mCurrent == '\n' ) {
mLine++;
mCol = 0;
}
else {
mCol++;
}
return mCurrent;
}
//----------------------------------------------------------------------------
// One character lookahead into tokeniser input
//----------------------------------------------------------------------------
char ExprTokeniser :: Peek() const {
return mPos >= mExprs.size() ? 0 : mExprs[ mPos ];
}
//----------------------------------------------------------------------------
// Skip over non-significant whitespace, returning true if there is more
// input after the skipped spaces.
//----------------------------------------------------------------------------
bool ExprTokeniser :: ReadWS() {
while( mCurrent ) {
if ( isspace( mCurrent ) ) {
Next();
}
else {
return true;
}
}
return false;
}
//----------------------------------------------------------------------------
// translate char which was escaped by backslash
//----------------------------------------------------------------------------
static char EscChr( char c ) {
switch( c ) {
case 'n': return '\n';
case 'r': return '\r';
case 't': return '\t';
default: return c;
}
}
//----------------------------------------------------------------------------
// Read string token. Must be called with current character being the first
// char in string, which must be a quote. Return string without quotes.
//----------------------------------------------------------------------------
ExprToken ExprTokeniser :: ReadStr() {
string s;
char quote = mCurrent;
while(1) {
Next();
if ( mCurrent == CHAR_ESC ) {
Next();
if ( mCurrent == 0 ) {
return Error( "Invalid escape" );
}
s += EscChr( mCurrent );
}
else if ( mCurrent == quote ) {
Next();
break;
}
else if ( mCurrent == 0 ) {
return Error( "Unterminated string" );
}
s += mCurrent;
}
mCanBeUnaryMinus = false;
return ExprToken( ExprToken::etStr, s );
}
//----------------------------------------------------------------------------
// Read function name, which must begin with and contain only alpha characters
// and end in an open paren with no spaces between the name and the paren.
// Returns name without paren.
//----------------------------------------------------------------------------
ExprToken ExprTokeniser :: ReadFunc() {
string s;
while( isalpha( mCurrent ) ) {
s += mCurrent;
Next();
}
mCanBeUnaryMinus = true;
if ( mCurrent == '(' ) {
Next();
return ExprToken( ExprToken::etFunc, s );
}
else {
return ExprToken( ExprToken::etStr, s );
}
}
//----------------------------------------------------------------------------
// Variables must begin with '$', though this is not cheked here
// Rest of name can be alphanum or underscore. Returns name without '$'
//----------------------------------------------------------------------------
ExprToken ExprTokeniser :: ReadVar() {
string name;
bool isfunc = false;
Next(); // skip $ sign already checked
while(1) {
name += mCurrent;
Next();
if ( mCurrent == '_' || isalnum( mCurrent ) ) {
// ok - do nothing
}
else {
break;
}
}
if ( name.size() == 0 ) {
return Error( "Unnamed variable" );
}
mCanBeUnaryMinus = false;
return ExprToken( isfunc ? ExprToken::etFunc : ExprToken::etVar, name);
}
//----------------------------------------------------------------------------
// Read operator - all ops are 1 or 2 characters long
//----------------------------------------------------------------------------
ExprToken ExprTokeniser :: ReadOp() {
unsigned int i = 0;
if ( mCurrent == '-' && mCanBeUnaryMinus ) {
Next();
return ExprToken( ExprToken::etOp, UMINUS_STR, 20 );
}
while( const char * p = Ops[i].mOp ) {
int pl = std::strlen(p);
if ( pl == 1 && mCurrent == p[0] ) {
Next();
mCanBeUnaryMinus = * p == ')' ? false : true;
return ExprToken( ExprToken::etOp, p, Ops[i].mPrec );
}
else if ( pl == 2 && mCurrent == p[0] && Peek() == p[1] ) {
Next();
Next();
mCanBeUnaryMinus = true;
return ExprToken( ExprToken::etOp, p, Ops[i].mPrec );
}
i++;
}
return Error( "Invalid operator " );
}
//----------------------------------------------------------------------------
// Read number. Numbers are always treated as reals.
//----------------------------------------------------------------------------
ExprToken ExprTokeniser :: ReadNum() {
string num;
bool havepoint = false;
while(1) {
if ( mCurrent == '.' ) {
if ( ! havepoint ) {
havepoint = true;
if ( ! isdigit( Peek() ) ) {
return Error( "Invalid number - expected digit" );
}
}
else {
return Error( "Invalid number - unexpected decimal point" );
}
}
else if ( isdigit( mCurrent ) ) {
// OK - do nothing
}
else if ( mCurrent == 0 || isspace( mCurrent )
|| ! isalpha( mCurrent ) ) {
if ( StrLast( num ) == '.' ) {
return Error( "Invalid number - no digits following point" );
}
break;
}
else {
return Error( "Invalid number" );
}
num += mCurrent;
Next();
}
mCanBeUnaryMinus = false;
return ExprToken( ExprToken::etNum, num );
}
//----------------------------------------------------------------------------
// Compiler takes tokens and turns them into a Reverse Polish form that
// is easy to execute. Uses a stack to handle operator precedence and
// sub-expressions.
//----------------------------------------------------------------------------
ExprCompiler :: ExprCompiler() {
}
ExprCompiler :: ~ExprCompiler() {
}
//----------------------------------------------------------------------------
// Sub expression is an expression in parens or a functiopn param list
// here we pop everything down to opening paren of function and add them to
// the Reverse Polish representation
//----------------------------------------------------------------------------
void ExprCompiler :: PopSubExpr( Expression::RPNRep & rep) {
while( mStack.size() ) {
ExprToken st = mStack.top();
mStack.pop();
//st.DumpOn( std::cout );
if ( st.Type() == ExprToken::etOp && st.Value() == "(" ) {
return;
}
else if ( st.Type() == ExprToken::etOp && st.Value() == FNCALL_STR ) {
if ( mFuncStack.empty() ) {
ATHROW( "Bad function call nesting" );
}
string fn = mFuncStack.top();
mFuncStack.pop();
rep.push_back( ExprToken( ExprToken::etStr, fn ) );
rep.push_back( st );
return;
}
else {
rep.push_back( st );
}
}
ATHROW( "Bad expression nesting or function call syntax" );
}
//----------------------------------------------------------------------------
// Handles precedence by popping everything of greater or equal prec
// and adding it to the RPN rep.
//----------------------------------------------------------------------------
void ExprCompiler :: PopHigherPrec( const ExprToken & tok,
Expression::RPNRep & rep) {
while( mStack.size() ) {
ExprToken st = mStack.top();
if ( st.Precedence() >= tok.Precedence() ) {
rep.push_back( st );
mStack.pop();
}
else {
break;
}
}
if ( tok == ExprToken::MakeSep() ) {
rep.push_back( tok );
Clear( mStack );
// std::cout << "------\n";
}
else if ( tok.Value() != "," ) {
mStack.push( tok );
}
}
//----------------------------------------------------------------------------
// compile an expression into RPN, returning error message or
// the empty string if everthing was OK
//----------------------------------------------------------------------------
string ExprCompiler :: Compile( const string & expr,
Expression::RPNRep & rep ) {
Clear( mStack );
Clear( mFuncStack );
ExprTokeniser et( expr );
while(1) {
ExprToken tok = et.Get();
//tok.DumpOn( std::cout );
//std::cout << "\n";
if ( tok.Type() == ExprToken::etDone ) {
break;
}
else if ( tok.Type() == ExprToken::etError ) {
return "Compilation error - " + tok.Value() ;
}
else if ( tok.Type() == ExprToken::etNum
|| tok.Type() == ExprToken::etStr ) {
rep.push_back( tok );
}
else if ( tok.Type() == ExprToken::etOp ) {
if ( tok.Value() == ")" ) {
PopSubExpr( rep );
}
else if ( tok.Value() == UMINUS_STR || tok.Value() == "(" ) {
mStack.push( tok );
}
else {
PopHigherPrec( tok, rep );
}
}
else if ( tok.Type() == ExprToken::etFunc ) {
mFuncStack.push( tok.Value() );
ExprToken tmp( ExprToken::etOp, FNCALL_STR, 1 );
mStack.push( tmp );
}
else if ( tok.Type() == ExprToken::etVar ) {
rep.push_back( tok );
ExprToken tmp( ExprToken::etOp, RDVAR_STR, 100 );
mStack.push( tmp );
}
else {
throw "Not supported yet";
}
}
// add expr separator if user didn't bother to
if ( rep.size() == 0 || ! (Last( rep ) == ExprToken::MakeSep()) ) {
rep.push_back( ExprToken( ExprToken::etOp, EXPR_SEP, 0 ) );
}
return "";
}
//----------------------------------------------------------------------------
// Dump RPN representation for debug
//----------------------------------------------------------------------------
void ExprCompiler :: DumpRP( std::ostream & os, const Expression::RPNRep & rp ) {
for ( unsigned int i = 0; i < rp.size(); i++ ) {
os << "[";
rp[i].DumpOn( os );
os << "]";
}
os << "\n";
}
//----------------------------------------------------------------------------
// Expression uses compiler to compile string rep of expression into Reverse
// Polish form and then executes it. Alternatively, these stages can be
// performed separately.
//----------------------------------------------------------------------------
Expression :: Expression() {
}
Expression :: ~Expression() {
}
//----------------------------------------------------------------------------
// evaluate supplied expression, returning result as string
//----------------------------------------------------------------------------
string Expression :: Evaluate( const std::string & expr ) {
string emsg = Compile( expr );
if ( emsg != "" ) {
ATHROW( emsg );
}
return Evaluate();
}
//----------------------------------------------------------------------------
// Evaluate pre-compiled expression
//----------------------------------------------------------------------------
string Expression :: Evaluate( ) {
if ( mRPN.empty() ) {
ATHROW( "No compiled expression" );
}
string result;
unsigned int i = 0;
//ExprCompiler::DumpRP( std::cout, mRPN );
while( EvalSingleExpr( i, result ) ) {
}
return result;
}
//----------------------------------------------------------------------------
// compile to RP form, but don't evaluate expression
//----------------------------------------------------------------------------
string Expression :: Compile( const std::string & expr ) {
string s = Trim( expr );
if ( StrLast( s ) != EXPR_SEP[0] ) {
s += EXPR_SEP;
}
mRPN.clear();
ExprCompiler ec;
string emsg = ec.Compile( s, mRPN );
return emsg;
}
//----------------------------------------------------------------------------
// See if expression has compiled contents
//----------------------------------------------------------------------------
bool Expression :: IsCompiled() const {
return mRPN.size() != 0;
}
//----------------------------------------------------------------------------
// Call named function, returning result of call.
// If anything goes wrong with popping the stack it almost certainly means
// the user didn't provide enough parameters.
//----------------------------------------------------------------------------
string Expression :: CallFunction( const string & name ) {
const AddFunc * af = mFuncs.GetPtr( name );
if ( af == 0 ) {
ATHROW( "Unknown function: " << name );
}
std::deque <string> params;
try {
for ( unsigned int i = 0; i < af->mParamCount; i++ ) {
params.push_front( PopStr() );
}
}
catch( ... ) {
ATHROW( "Function " << name << "() given the wrong number of parameters."
<< " It takes "<< af->mParamCount << "." );
}
return af->mFunc( params, this );
}
//----------------------------------------------------------------------------
// Get positional parameter values
//----------------------------------------------------------------------------
unsigned int Expression :: PosParamCount() const {
return mPosParams.size();
}
string Expression :: PosParam( unsigned int i ) const {
return mPosParams.at( i );
}
//----------------------------------------------------------------------------
// add a positional parameter that can be accessed as $1, $2 etc.
//----------------------------------------------------------------------------
void Expression :: AddPosParam( const string & s ) {
mPosParams.push_back( s );
}
//----------------------------------------------------------------------------
// clear all positional parameters
//----------------------------------------------------------------------------
void Expression :: ClearPosParams() {
mPosParams.clear();
}
//----------------------------------------------------------------------------
// evaluate a single expression terminated by expression separator
//----------------------------------------------------------------------------
bool Expression :: EvalSingleExpr( unsigned int & ei, string & result ) {
// do not remove this - we need to preserve previous result
if ( ei >= mRPN.size() ) {
return false;
}
result = "";
Clear( mStack );
while( ei < mRPN.size() ) {
ExprToken tok = mRPN.at( ei++ );
if ( tok == ExprToken::MakeSep() ) {
if ( mStack.size() != 1 ) {
ATHROW( "Invalid expression" );
// ATHROW( "Invalid expression in EvalSingleExpr stack "
// << ei << " " << mStack.size() );
}
result = mStack.top();
return true;
}
else if ( tok.Type() == ExprToken::etNum
|| tok.Type() == ExprToken::etStr ) {
mStack.push( tok.Value() );
}
else if ( tok.Type() == ExprToken::etOp ) {
ExecOp( tok );
}
else if ( tok.Type() == ExprToken::etVar ) {
mStack.push( tok.Value() );
}
else {
tok.DumpOn( std::cerr );
ATHROW( "Not implemented in EvalSingleExpr" );
}
}
return false;
}
//----------------------------------------------------------------------------
// helper to pop string from stack or report error
//----------------------------------------------------------------------------
string Expression :: PopStr() {
if ( mStack.size() == 0 ) {
ATHROW( "Invalid expression" );
}
string s = mStack.top();
mStack.pop();
return s;
}
//----------------------------------------------------------------------------
// helper to pop number from stack
//----------------------------------------------------------------------------
double Expression :: PopNum() {
string s = PopStr();
if ( ! IsNumber( s ) ) {
ATHROW( "Invalid numeric value " << s );
}
return ToReal( s );
}
//----------------------------------------------------------------------------
// push boolean rep to stack
//----------------------------------------------------------------------------
void Expression :: PushBool( bool b ) {
mStack.push( b ? "1" : "0" );
}
//----------------------------------------------------------------------------
// handle comparison operators
//----------------------------------------------------------------------------
void Expression :: DoCompare( const string & op ) {
string rhs = PopStr();
string lhs = PopStr();
if ( IsNumber( rhs ) && IsNumber( lhs ) ) {
double dr = ToReal( rhs );
double dl = ToReal( lhs );
if ( op == "==" ) {
PushBool( dl == dr );
}
else if ( op == "<>" || op == "!=" ) { // we allow either
PushBool( dl != dr );
}
else if ( op == "<" ) {
PushBool( dl < dr );
}
else if ( op == ">" ) {
PushBool( dl > dr );
}
else if ( op == ">=" ) {
PushBool( dl >= dr );
}
else if ( op == "<=" ) {
PushBool( dl <= dr );
}
}
else {
if ( op == "==" ) {
PushBool( lhs == rhs );
}
else if ( op == "<>" || op == "!=" ) {
PushBool( lhs != rhs );
}
else if ( op == "<" ) {
PushBool( lhs < rhs );
}
else if ( op == ">" ) {
PushBool( lhs > rhs );
}
else if ( op == ">=" ) {
PushBool( lhs >= rhs );
}
else if ( op == "<=" ) {
PushBool( lhs <= rhs );
}
}
}
//----------------------------------------------------------------------------
// convert string to bool - 0 or empty is false, anything else is true
//----------------------------------------------------------------------------
bool Expression :: ToBool( const std::string & s ) {
if ( IsNumber(s ) ) {
double d = ToReal( s );
return d != 0.0;
}
else {
return s != "";
}
}
//----------------------------------------------------------------------------
// Handle the && and || operators. Currently we don't do short-circuited
// evaluation, but we certainly ought to.
//----------------------------------------------------------------------------
void Expression :: DoAndOr( const std::string & op ) {
string rhs = PopStr();
string lhs = PopStr();
bool ok = ToBool( lhs );
if ( ok ) {
if ( op == "&&" ) {
PushBool( ToBool( rhs ) );
}
else {
PushBool( ok );
}
}
else {
if ( op == "||" ) {
PushBool( ToBool( rhs ) );
}
else {
PushBool( ok );
}
}
}
//----------------------------------------------------------------------------
// get value of variable. if the variable name is an integer it is a
// positional parameter otherwise it is a nmaed variable.
//----------------------------------------------------------------------------
string Expression :: GetVar( const string & var ) const {
if ( IsInteger( var ) ) {
int n = ToInteger( var ) - 1;
if ( n < 0 ) {
ATHROW( "Invalid positional parameter " << n );
}
if ( n >= (int) mPosParams.size() ) {
return "";
}
else {
return mPosParams[n];
}
}
else {
const string * val = mVars.GetPtr( var );
if ( val == 0 ) {
ATHROW( "Unknown variable: " << var );
}
return * val;
}
}
//----------------------------------------------------------------------------
// clear all named variables
//----------------------------------------------------------------------------
void Expression :: ClearVars() {
mVars.Clear();
}
//----------------------------------------------------------------------------
// add named variable, overwriting any exist ing value of same name
//----------------------------------------------------------------------------
void Expression :: AddVar( const string & name, const string & val ) {
mVars.Replace( name, val );
}
//----------------------------------------------------------------------------
// Given a token containing an operator, execute it, pushing result to stack
//----------------------------------------------------------------------------
void Expression :: ExecOp( const ExprToken & tok ) {
string op = tok.Value();
if ( op == "." ) {
string s = PopStr();
mStack.push( PopStr() + s );
}
else if ( op == "+" ) {
mStack.push( Str( PopNum() + PopNum() ) );
}
else if ( op == "-" ) {
double n = PopNum();
mStack.push( Str( PopNum() - n ) );
}
else if ( op == "*" ) {
mStack.push( Str( PopNum() * PopNum() ) );
}
else if ( op == "/" ) {
double n = PopNum();
if ( n == 0 ) {
ATHROW( "Divide by zero" );
}
mStack.push( Str( PopNum() / n ) );
}
else if ( op == "%" ) {
double rhs = PopNum();
double lhs = PopNum();
if ( lhs < 0 || rhs < 0 ) {
ATHROW( "Invalid operands for % operator" );
}
int n = int(lhs) % int(rhs);
mStack.push( Str( n ) );
}
else if ( op == "*" ) {
mStack.push( Str( PopNum() * PopNum() ) );
}
else if ( In( op, IgnoreCase, "==", "<>", "!=", "<", ">", "<=", ">=", NULL ) ) {
DoCompare( op );
}
else if ( op == "&&" || op == "||" ) {
DoAndOr( op );
}
else if ( op == UMINUS_STR ) {
double d = - PopNum();
mStack.push( Str( d ) );
}
else if ( op == RDVAR_STR ) {
string s = PopStr();
mStack.push( GetVar( s ) );
}
else if ( op == FNCALL_STR ) {
string fun = PopStr();
mStack.push( CallFunction( fun ) );
}
else {
ATHROW( "Unknown operator: " << op );
}
}
//----------------------------------------------------------------------------
} // namespace
//----------------------------------------------------------------------------
// Testing
//----------------------------------------------------------------------------
#ifdef ALIB_TEST
#include "a_myth.h"
using namespace ALib;
using namespace std;
DEFSUITE( "a_expr" );
DEFTEST( TokeniserTest1 ) {
string e = "1 + 2";
ExprTokeniser t( e );
ExprToken tok = t.Get();
FAILNE( tok.Value(), "1" );
tok = t.Get();
FAILNE( tok.Value(), "+" );
tok = t.Get();
FAILNE( tok.Value(), "2" );
tok = t.Get();
FAILNE( tok.Type(), ExprToken::etDone );
}
DEFTEST( CompilerTest ) {
string expr = " 1 + 2 * 6;";
ExprCompiler cp;
Expression::RPNRep rp;
string r = cp.Compile( expr, rp );
// ExprCompiler::DumpRP( cout, rp );
FAILNE( r, "" );
FAILNE( rp.size(), 6 );
expr = "-2;";
rp.clear();
r = cp.Compile( expr, rp );
FAILNE( r, "" );
FAILNE( rp.size(), 3 );
//ExprCompiler::DumpRP( cout, rp );
expr = "$1 + 2;";
rp.clear();
r = cp.Compile( expr, rp );
//ExprCompiler::DumpRP( cout, rp );
FAILNE( r, "" );
FAILNE( rp.size(), 5 );
expr = "(1 + 2) *3;";
rp.clear();
r = cp.Compile( expr, rp );
//ExprCompiler::DumpRP( cout, rp );
FAILNE( r, "" );
FAILNE( rp.size(), 6 );
expr = "1 == 2;";
rp.clear();
r = cp.Compile( expr, rp );
//ExprCompiler::DumpRP( cout, rp );
FAILNE( r, "" );
FAILNE( rp.size(), 4 );
expr = "5 + inc(3);" ;
rp.clear();
r = cp.Compile( expr, rp );
//ExprCompiler::DumpRP( cout, rp );
}
DEFTEST( PosParamTest ) {
Expression e;
e.AddPosParam( "foo" );
e.AddPosParam( "bar" );
FAILNE( e.PosParamCount(), 2 );
FAILNE( e.PosParam(0), "foo" );
FAILNE( e.PosParam(1), "bar" );
// these use pos params
string s = e.Evaluate( "find('bar')" );
FAILNE( s, "2" );
s = e.Evaluate( "find('zod')" );
FAILNE( s, "0" );
}
DEFTEST( ExpressionTest ) {
Expression e;
string s = e.Evaluate( "1 + 2;" );
FAILNE( s, "3" );
s = e.Evaluate( "2 * 5;" );
FAILNE( s, "10" );
s = e.Evaluate( "10 / 2" );
FAILNE( s, "5" );
s = e.Evaluate( "1;2;" );
FAILNE( s, "2" );
s = e.Evaluate( "3-1" );
FAILNE( s, "2" );
}
DEFTEST( NumTest ) {
Expression e;
string s = e.Evaluate( "isint('42');" );
FAILNE( s, "1" );
s = e.Evaluate( "isint('42.0');" );
FAILNE( s, "0" );
}
DEFTEST( UnaryMinusTest ) {
Expression e;
string s = e.Evaluate( "-2;" );
FAILNE( s, "-2" );
s = e.Evaluate( "1--2;" );
FAILNE( s, "3" );
}
DEFTEST( VarTest ) {
Expression e;
e.AddPosParam( "3" );
string s = e.Evaluate( "$1;" );
FAILNE( s, "3" );
s = e.Evaluate( "$1+2;" );
FAILNE( s, "5" );
e.AddVar( "beast", "666" );
s = e.Evaluate( "$beast;" );
FAILNE( s, "666" );
s = e.Evaluate( "field(1)" );
FAILNE( s, "3" );
}
DEFTEST( ParenTest ) {
Expression e;
string s = e.Evaluate( "(1 + 2) * 3" );
FAILNE( s, "9" );
}
DEFTEST( BoolTest ) {
Expression e;
string s = e.Evaluate( "1 == 2;" );
FAILNE( s, "0" );
s = e.Evaluate( "1 <> 2;" );
FAILNE( s, "1" );
s = e.Evaluate( "1 != 2;" );
FAILNE( s, "1" );
s = e.Evaluate( "1 && 2;" );
FAILNE( s, "1" );
s = e.Evaluate( "1 && 0;" );
FAILNE( s, "0" );
s = e.Evaluate( "1 || 0;" );
FAILNE( s, "1" );
s = e.Evaluate( "1 < 2" );
FAILNE( s, "1" );
s = e.Evaluate( "2 > 1" );
FAILNE( s, "1" );
s = e.Evaluate( "1 <= 2" );
FAILNE( s, "1" );
s = e.Evaluate( "2 >= 1" );
FAILNE( s, "1" );
}
DEFTEST( IsEmptyTest ) {
Expression e;
string s = e.Evaluate( "isempty('')" );
FAILNE( s, "1" );
s = e.Evaluate( "isempty('foo')" );
FAILNE( s, "0" );
s = e.Evaluate( "isempty(' \t')" );
FAILNE( s, "1" );
}
DEFTEST( RegExTest ) {
Expression e;
string s = e.Evaluate( "match('','^$' )" );
FAILNE( s, "1" );
s = e.Evaluate( "match('foo','^$')" );
FAILNE( s, "0" );
s = e.Evaluate( "match('foo','foo')" );
FAILNE( s, "1" );
s = e.Evaluate( "match('foo','f.*')" );
FAILNE( s, "1" );
}
struct ExprTest {
const char * expr;
const char * result;
};
static ExprTest ETests[] = {
{"\"\"","" },
{"\"xxx\"","xxx" },
{"0", "0"},
{"1", "1"},
{"1 + 2 * 3", "7" },
{"(1 + 2) * 3", "9" },
{"9 % 2", "1" },
{"1 + 3 * ((2 * 10 + 5) / 5)", "16" },
{"not(1)", "0"},
{"if( 1, 'foo', 'bar')", "foo"},
{"if( 0, 'foo', 'bar')", "bar"},
{"int(123.456)", "123"},
{"substr('1234567890', 2, 3)", "234"},
{"sign(-42)", "-1"},
{"abs(-42)", "42"},
{"trim(' foo ')", "foo"},
{"pos('foobar','ob')", "3"},
{"foo . bar", "foobar"},
{"lower('FOO')", "foo" },
{"upper('foo')", "FOO" },
{"len('foo')", "3" },
{"streq('foo','FOO')", "1" },
{"streq('foox','FOO')", "0" },
{"min('3','6')", "3" },
{"max('3','6')", "6" },
{"day('1980-10-7')", "7" },
{"month('1980-10-7')", "10" },
{"year('1980-10-7')", "1980" },
{"isdate('1980-10-7')", "1" },
{"isdate('1980-13-7')", "0" },
{"index('two', 'one,two,three' )", "2" },
{"pick('2', 'one,two,three' )", "two" },
{NULL,NULL}
};
DEFTEST( AllExprs ) {
int i = 0;
while( ETests[i].expr ) {
Expression e;
string s = e.Evaluate( ETests[i].expr );
string si = Str(i);
FAILNEM( s, ETests[i].result, (si + string(": ") + ETests[i].expr ));
i++;
}
}
#endif
// end
| 28.068339 | 82 | 0.45364 | [
"object",
"vector",
"transform"
] |
5eb38bc438523051ac4eebd8bd1f2a5bb41031c0 | 5,144 | cpp | C++ | tests/Dynamic/AttackReleaseHysteresisFilter.cpp | AudioTK/AudioTK | dba42eea68534501efe74692b74edf4792cca231 | [
"BSD-3-Clause"
] | 23 | 2021-02-04T10:47:46.000Z | 2022-03-25T03:45:00.000Z | tests/Dynamic/AttackReleaseHysteresisFilter.cpp | AudioTK/AudioTK | dba42eea68534501efe74692b74edf4792cca231 | [
"BSD-3-Clause"
] | 2 | 2021-02-01T15:45:06.000Z | 2021-09-13T19:39:05.000Z | tests/Dynamic/AttackReleaseHysteresisFilter.cpp | AudioTK/AudioTK | dba42eea68534501efe74692b74edf4792cca231 | [
"BSD-3-Clause"
] | 2 | 2021-04-12T03:28:12.000Z | 2021-12-17T00:47:11.000Z | /**
* \ file AttackReleaseHysteresisFilter.cpp
*/
#include <ATK/Dynamic/AttackReleaseHysteresisFilter.h>
#include <ATK/Core/InPointerFilter.h>
#include <ATK/Core/OutPointerFilter.h>
#include <ATK/Core/Utilities.h>
#include <gtest/gtest.h>
#include <boost/math/constants/constants.hpp>
constexpr gsl::index PROCESSSIZE = 1024*64;
TEST(AttackReleaseHysteresis, attack_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
filter.set_attack(0.5);
ASSERT_EQ(filter.get_attack(), 0.5);
}
TEST(AttackReleaseHysteresis, attack_range_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
ASSERT_THROW(filter.set_attack(-0.000001), ATK::RuntimeError);
}
TEST(AttackReleaseHysteresis, attack_range2_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
ASSERT_THROW(filter.set_attack(1.000001), ATK::RuntimeError);
}
TEST(AttackReleaseHysteresis, release_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
filter.set_release(0.5);
ASSERT_EQ(filter.get_release(), 0.5);
}
TEST(AttackReleaseHysteresis, release_range_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
ASSERT_THROW(filter.set_release(-0.000001), ATK::RuntimeError);
}
TEST(AttackReleaseHysteresis, release_range2_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
ASSERT_THROW(filter.set_release(1.000001), ATK::RuntimeError);
}
TEST(AttackReleaseHysteresis, attack_hysteresis_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
filter.set_release_hysteresis(0.1);
filter.set_attack_hysteresis(0.5);
ASSERT_EQ(filter.get_attack_hysteresis(), 0.5);
}
TEST(AttackReleaseHysteresis, attack_hysteresis_db_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
filter.set_release_hysteresis(0.001);
filter.set_attack_hysteresis_db(-20);
ASSERT_NEAR(filter.get_attack_hysteresis(), 0.1, 0.1);
}
TEST(AttackReleaseHysteresis, attack_hysteresis_range_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
filter.set_release_hysteresis(.5);
ASSERT_THROW(filter.set_attack_hysteresis(.5 - 0.000001), ATK::RuntimeError);
}
TEST(AttackReleaseHysteresis, attack_hysteresis_range2_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
ASSERT_THROW(filter.set_attack_hysteresis(1.000001), ATK::RuntimeError);
}
TEST(AttackReleaseHysteresis, hysteresis_release_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
filter.set_release_hysteresis(0.5);
ASSERT_EQ(filter.get_release_hysteresis(), 0.5);
}
TEST(AttackReleaseHysteresis, release_hysteresis_db_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
filter.set_release_hysteresis_db(-20);
ASSERT_NEAR(filter.get_release_hysteresis(), 0.1, 0.1);
}
TEST(AttackReleaseHysteresis, release_hysteresis_range_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
ASSERT_THROW(filter.set_release_hysteresis(-0.000001), ATK::RuntimeError);
}
TEST(AttackReleaseHysteresis, release_hysteresis_range2_test)
{
ATK::AttackReleaseHysteresisFilter<double> filter;
ASSERT_THROW(filter.set_release_hysteresis(1.000001), ATK::RuntimeError);
}
TEST(AttackReleaseHysteresisFilter, triangle_test)
{
std::vector<double> data(PROCESSSIZE);
for(gsl::index i = 0; i < PROCESSSIZE/2; ++i)
{
data[i] = i / 48000;
}
for(gsl::index i = 0; i < PROCESSSIZE/2; ++i)
{
data[PROCESSSIZE/2 + i] = (PROCESSSIZE/2 - i) / 48000;
}
ATK::InPointerFilter<double> generator(data.data(), 1, PROCESSSIZE, false);
generator.set_output_sampling_rate(48000);
std::vector<double> outdata(PROCESSSIZE);
ATK::AttackReleaseHysteresisFilter<double> filter(1);
filter.set_attack(std::exp(-1./(48000 * 1e-3)));
filter.set_release(std::exp(-1./(48000 * 100e-3)));
filter.set_input_sampling_rate(48000);
filter.set_input_port(0, &generator, 0);
ATK::OutPointerFilter<double> output(outdata.data(), 1, PROCESSSIZE, false);
output.set_input_sampling_rate(48000);
output.set_input_port(0, &filter, 0);
output.process(PROCESSSIZE);
for(gsl::index i = 0; i < PROCESSSIZE/2; ++i)
{
ASSERT_GE(data[i], outdata[i]);
}
for(gsl::index i = 0; i < PROCESSSIZE/2; ++i)
{
ASSERT_GE(outdata[PROCESSSIZE / 2 + i], outdata[PROCESSSIZE / 2 + i - 1]);
}
}
#define CUSTOMPROCESSSIZE 7
TEST(AttackReleaseHysteresisFilter, release_custom_test)
{
double data[] = {0., 1., .5, .4, .3, .2, .1};
double target[] = {0., 1., 1., .46, .46, .226, .1126};
ATK::InPointerFilter<double> generator(data, 1, CUSTOMPROCESSSIZE, false);
generator.set_output_sampling_rate(48000);
std::array<double, CUSTOMPROCESSSIZE> outdata;
ATK::AttackReleaseHysteresisFilter<double> filter(1);
filter.set_attack(0);
filter.set_release(.1);
filter.set_release_hysteresis(.5);
filter.set_input_sampling_rate(48000);
filter.set_input_port(0, &generator, 0);
ATK::OutPointerFilter<double> output(outdata.data(), 1, CUSTOMPROCESSSIZE, false);
output.set_input_sampling_rate(48000);
output.set_input_port(0, &filter, 0);
output.process(CUSTOMPROCESSSIZE);
for(gsl::index i = 0; i < CUSTOMPROCESSSIZE; ++i)
{
ASSERT_NEAR(target[i], outdata[i], .001);
}
}
| 28.73743 | 84 | 0.75311 | [
"vector"
] |
5eb4557d320dbcf45ac92f80e15e129b9c40e8da | 2,115 | cc | C++ | test.cc | dremon/cjsonpp | 71d876f2d311269f8b848021145e83b07a7aecfb | [
"MIT"
] | 1 | 2020-10-28T08:24:26.000Z | 2020-10-28T08:24:26.000Z | test.cc | ancwrd1/cjsonpp | 71d876f2d311269f8b848021145e83b07a7aecfb | [
"MIT"
] | null | null | null | test.cc | ancwrd1/cjsonpp | 71d876f2d311269f8b848021145e83b07a7aecfb | [
"MIT"
] | null | null | null | #include <assert.h>
#include <iostream>
#include <list>
#include "cjsonpp.h"
cjsonpp::JSONObject create_arr()
{
cjsonpp::JSONObject obj;
cjsonpp::JSONObject arr = cjsonpp::arrayObject();
arr.add("foo");
arr.add("bar");
obj.set("arr", arr);
return obj.get<cjsonpp::JSONObject>("arr");
}
int main()
{
using namespace cjsonpp;
try {
JSONObject o;
#ifdef WITH_CPP11
std::vector<int> v = {1, 2, 3, 4};
JSONObject vo = {1, 2, 3, 4};
#else
std::vector<int> v;
v.push_back(1); v.push_back(2); v.push_back(3); v.push_back(4);
JSONObject vo = cjsonpp::arrayObject();
vo.add(1); vo.add(2); vo.add(3); vo.add(4);
#endif
o.set("num", 1234);
o.set("str1", "1234");
o.set("str2", "vvv");
o.set("v", v);
o.set("vo", vo);
assert(o.has("num"));
assert(o.has(std::string("str2")));
std::cout << o.get<std::string>("str1") << '\n';
std::cout << parse(o.print()) << '\n';
#ifdef WITH_CPP11
std::vector<JSONObject> jv = o.get("v").asArray();
std::vector<int> iv = o.get("vo").asArray<int>();
#else
std::vector<JSONObject> jv = o.get<JSONObject>("v").asArray<JSONObject, std::vector>();
std::vector<int> iv = o.get<JSONObject>("vo").asArray<int, std::vector>();
#endif
for (size_t i = 0; i < jv.size(); i++)
std::cout << jv[i].as<int>() << iv[i];
std::cout << '\n';
JSONObject obj;
obj.set("intval", 1234);
obj.set("arrval", v);
obj.set("doubleval", 100.1);
obj.set("nullval", cjsonpp::nullObject());
std::cout << obj << '\n';
std::list<int> arr2 = obj.get<JSONObject>("arrval").asArray<int, std::list>();
JSONObject arr = cjsonpp::arrayObject();
arr.add("s1");
arr.add("s2");
JSONObject obj2;
obj2.set("arrval", arr);
std::cout << obj2 << std::endl;
const cjsonpp::JSONObject arr3 = create_arr();
const std::string json = arr3.print();
std::cout << json << std::endl;
} catch (const JSONError& e) {
std::cout << e.what() << '\n';
return -1;
}
const char* garbageJSON = "This is not valid JSON.";
try {
JSONObject obj = parse(garbageJSON);
return -1;
} catch (const JSONError&) {
// no-op
}
return 0;
}
| 23.241758 | 89 | 0.596217 | [
"vector"
] |
5eb83290d18b259f27506313984eed8833ce4e66 | 2,477 | cpp | C++ | core/src/wrapper/DataTransfer.cpp | NeatNerdPrime/milvus | 98de0f87e99cd1ff86d8e63b91c76589b195abe1 | [
"Apache-2.0"
] | 1 | 2020-05-31T00:34:00.000Z | 2020-05-31T00:34:00.000Z | core/src/wrapper/DataTransfer.cpp | NeatNerdPrime/milvus | 98de0f87e99cd1ff86d8e63b91c76589b195abe1 | [
"Apache-2.0"
] | 1 | 2019-11-22T07:07:47.000Z | 2019-11-22T07:07:47.000Z | core/src/wrapper/DataTransfer.cpp | flydragon2018/milvus | fa1effdb91d9fd9710ff5a9ae519bd538e79b0b0 | [
"Apache-2.0"
] | 1 | 2021-05-23T15:04:01.000Z | 2021-05-23T15:04:01.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.
#include "wrapper/DataTransfer.h"
#include <memory>
#include <utility>
#include <vector>
namespace milvus {
namespace engine {
knowhere::DatasetPtr
GenDatasetWithIds(const int64_t& nb, const int64_t& dim, const float* xb, const int64_t* ids) {
std::vector<int64_t> shape{nb, dim};
auto tensor = knowhere::ConstructFloatTensor((uint8_t*)xb, nb * dim * sizeof(float), shape);
std::vector<knowhere::TensorPtr> tensors{tensor};
std::vector<knowhere::FieldPtr> tensor_fields{knowhere::ConstructFloatField("data")};
auto tensor_schema = std::make_shared<knowhere::Schema>(tensor_fields);
auto id_array = knowhere::ConstructInt64Array((uint8_t*)ids, nb * sizeof(int64_t));
std::vector<knowhere::ArrayPtr> arrays{id_array};
std::vector<knowhere::FieldPtr> array_fields{knowhere::ConstructInt64Field("id")};
auto array_schema = std::make_shared<knowhere::Schema>(tensor_fields);
auto dataset =
std::make_shared<knowhere::Dataset>(std::move(arrays), array_schema, std::move(tensors), tensor_schema);
return dataset;
}
knowhere::DatasetPtr
GenDataset(const int64_t& nb, const int64_t& dim, const float* xb) {
std::vector<int64_t> shape{nb, dim};
auto tensor = knowhere::ConstructFloatTensor((uint8_t*)xb, nb * dim * sizeof(float), shape);
std::vector<knowhere::TensorPtr> tensors{tensor};
std::vector<knowhere::FieldPtr> tensor_fields{knowhere::ConstructFloatField("data")};
auto tensor_schema = std::make_shared<knowhere::Schema>(tensor_fields);
auto dataset = std::make_shared<knowhere::Dataset>(std::move(tensors), tensor_schema);
return dataset;
}
} // namespace engine
} // namespace milvus
| 41.983051 | 112 | 0.736778 | [
"shape",
"vector"
] |
5ebb7cdd6ce40a2235a67d0106cf7980dc3e370b | 9,129 | cpp | C++ | Tests/solver_test002/main.cpp | INM-RAS/INMOST | 2846aa63c1fc11c406cb2d558646237223183201 | [
"BSD-3-Clause"
] | 25 | 2016-03-14T19:34:00.000Z | 2022-03-17T13:34:59.000Z | Tests/solver_test002/main.cpp | INMOST-DEV/INMOST | c2209a6378b0d2ecc2f3ec9a12e0217cca011ca8 | [
"BSD-3-Clause"
] | 22 | 2015-01-17T18:43:16.000Z | 2021-03-26T08:09:43.000Z | Tests/solver_test002/main.cpp | INM-RAS/INMOST | 2846aa63c1fc11c406cb2d558646237223183201 | [
"BSD-3-Clause"
] | 13 | 2015-04-22T16:04:21.000Z | 2021-03-31T10:51:48.000Z | #include "inmost.h"
#include <string>
#include <iostream>
using namespace INMOST;
/***********************************************************************
(*) 5402 3D Poisson equation solver
(*) Test solvers on 3D Poisson equation.
This test is located in Tests/solver_test002
(*) Brief
Test solvers and tune parameters for on-the-fly generated matrices for 3D
Poisson equation.
(*) Description
This test will run solvers in both serial and parallel modes with NP
processes for a model problem of 3D Poisson equation.
The coefficient matrix and vectors for a parallel run will be generated
directly at the target processor, so no external reordering is required
to be installed.
The artificial right-hand side rhs=(1,1,...,1) is used.
The specific solver is defined by a user.
User may also provide options file to alter default solver options.
Main purpose of this test is to assess robustness of internal or external
solvers during development.
Another purpose is to check the behaviour of the liner solver for large
and extremely large test problems without taking into account the disk
memory requirements.
(*) Arguments
Usage: ./solver_test002 <solver_type> N<for NxNxN problem> [solver_options.xml]
* First parameter is the Solver type:
inner_ilu2, inner Solver based on BiCGStab(L) solver with second
order IIU factorization as preconditioner;
inner_ddpqiluc, inner Solver based on BiCGStab(L) solver with second order Crout-ILU with inversed-based condition estimation and unsymmetric reordering for diagonal dominance as preconditioner;
inner_mptiluc, inner Solver based on BiCGStab(L) solver with second order Crout-ILU with inversed-based condition estimation and maximum product transversal reordering as preconditioner;
inner_mptilu2, inner Solver based on BiCGStab(L) solver with second order ILU and maximum product transversal reordering as preconditione;
trilinos_aztec, external Solver AztecOO from Trilinos package;
currentty without preconditioner;
trilinos_belos, external Solver Belos from Trilinos package, currently without preconditioner;
trilinos_ml, external Solver AztecOO with ML preconditioner;
trilinos_ifpack, external Solver AztecOO with Ifpack preconditioner;
petsc, external Solver PETSc;
ani, external Solver from ANI3D based on ILU2 (sequential Fortran version);
fcbiilu2, external FCBIILU2 Solver (BIILU2 parallel F2C version);
k3biilu2, internal K3BIILU2 Solver (BIILU2 parallel version).
* Second parameter is the dimension N of the 3D Poisson problem for NxNxN
mesh.
* Third optional parameter is the file with solver parameters, see
examples/MatSolve/database.xml as example.
(*) Running test
You can run the test directly from the command line.
For example, you can specify the 100x100x100 test case and solve it by the
internal ILU2 based solver with the default parameters on 4 processors:
$ cd tests/solver_test002
$ mpirun -np 4 ./solver_test002 inner_ilu2 100
(*) Source
* Source code is adopted from examples/MatSolve
***********************************************************************/
#if defined(USE_MPI)
#define BARRIER MPI_Barrier(MPI_COMM_WORLD);
#else
#define BARRIER
#endif
void Poisson3D(int n1, int n2, int n3, Sparse::Matrix & mat); // Generate 3D Poisson matrix
int main(int argc, char ** argv)
{
int rank,procs;
if( argc < 3 )
{
std::cout << "Usage: " << argv[0] << " S<method name> N<for NxNxN problem> [solver_options.txt]" << std::endl;
return -1;
}
std::string type = std::string(argv[1]);
int n = atoi(argv[2]);
Solver::Initialize(&argc,&argv,argc > 3 ? argv[3] : NULL); // Initialize the linear solver in accordance with args
{
#if defined(USE_MPI)
MPI_Comm_rank(MPI_COMM_WORLD,&rank); // Get the rank of the current process
MPI_Comm_size(MPI_COMM_WORLD,&procs); // Get the total number of processors used
#else
rank = 0;
procs = 1;
#endif
if( rank == 0 )
std::cout << "Testing " << type << std::endl;
//std::cout << rank << "/" << procs << " " << argv[0] << std::endl;
Sparse::Matrix mat("A"); // Declare the matrix of the linear system to be solved
Sparse::Vector b("rhs"); // Declare the right-hand side vector
Sparse::Vector x("sol"); // Declare the solution vector
int n1=n, n2=n, n3=n;
if( !rank ) std::cout << "Poisson equation: " << n1 << " x " << n2 << " x " << n3 << std::endl;
BARRIER
double tt = Timer(), t = Timer();
Poisson3D(n1,n2,n3,mat);
BARRIER
if( !rank ) std::cout << "Generate matrix: " << Timer() - t << std::endl;
//mat.Save("test.mtx");
// Set local RHS to 1 if it was not specified
INMOST_DATA_ENUM_TYPE mbeg,mend,k;
mat.GetInterval(mbeg,mend);
b.SetInterval(mbeg,mend);
for( k = mbeg; k < mend; ++k ) b[k] = 1.0;
bool success = false;
int iters;
double resid, realresid = 0;
std::string reason;
{
Solver s(type); // Declare the linear solver by specified type
s.SetParameter("gmres_substeps", "3");
s.SetParameter("reorder_nonzeros", "0");
s.SetParameter("rescale_iterations", "8");
s.SetParameter("adapt_ddpq_tolerance", "0");
s.SetParameter("verbosity", "0");
s.SetParameter("drop_tolerance", "0.05");
s.SetParameter("reuse_tolerance", "0.0025");
s.SetParameter("pivot_condition", "5");
s.SetParameter("ddpq_tolerance", "0.7");
//mat.Save("A.mtx");
//b.Save("b.mtx");
t = Timer();
s.SetMatrix(mat); // Compute the preconditioner for the original matrix
BARRIER
if( !rank ) std::cout << "preconditioner: " << Timer() - t << std::endl;
t = Timer();
success = s.Solve(b,x); // Solve the linear system with the previously computted preconditioner
//x.Save("x.mtx");
BARRIER
if( !rank ) std::cout << "solver: " << Timer() - t << std::endl;
iters = s.Iterations(); // Get the number of iterations performed
resid = s.Residual(); // Get the final residual achieved
reason = s.ReturnReason();
//x.Save("output.rhs");
}
tt = Timer() - tt;
{ // Compute the true residual
double aresid = 0, bresid = 0;
Sparse::Vector test;
t = Timer();
Solver::OrderInfo info;
info.PrepareMatrix(mat,0);
info.PrepareVector(x);
info.Update(x);
mat.MatVec(1.0,x,0.0,test); // Multiply the original matrix by a vector
{
INMOST_DATA_ENUM_TYPE mbeg,mend,k;
info.GetLocalRegion(info.GetRank(),mbeg,mend);
for( k = mbeg; k < mend; ++k )
{
aresid += (test[k]-b[k])*(test[k]-b[k]);
bresid += b[k]*b[k];
}
}
double temp[2] = {aresid,bresid}, recv[2] = {aresid,bresid};
#if defined(USE_MPI)
MPI_Reduce(temp,recv,2,MPI_DOUBLE,MPI_SUM,0,MPI_COMM_WORLD);
if( info.GetRank() == 0 ) std::cout << "||Ax-b|| " << sqrt(recv[0]) << " ||b|| " << sqrt(recv[1]) << " ||Ax-b||/||b|| " << sqrt(recv[0]/recv[1]) << std::endl;
#endif
realresid = sqrt(recv[0]/recv[1]);
//realresid = sqrt(realresid);
info.RestoreVector(x);
if( !rank ) std::cout << "norms: " << Timer() - t << std::endl;
}
{
if( rank == 0 )
{
std::cout << procs << " processors";
if( success )
{
std::cout << " solved in " << tt << " secs";
std::cout << " with " << iters << " iterations to " << resid << " norm";
}
else std::cout << " failed to solve";
std::cout << " matrix \"" << argv[2] << "\"";
if( argc > 3 ) std::cout << " vector \"" << argv[3] << "\"";
std::cout << " true residual ||Ax-b||/||b|| " << realresid;
std::cout << std::endl;
std::cout << "reason: " << reason << std::endl;
}
}
}
Solver::Finalize(); // Finalize solver and close MPI activity
return 0;
}
// Generate 3D Poisson matrix
void Poisson3D(int n1, int n2, int n3, Sparse::Matrix & A)
{
int myid=0, nproc=1;
#if defined(USE_MPI)
MPI_Comm_size (MPI_COMM_WORLD, &nproc);
MPI_Comm_rank (MPI_COMM_WORLD, &myid);
#endif
int n = n1 * n2 * n3;
unsigned idmax, idmin, block = n / nproc;
idmin = myid * block;
idmax = idmin + block;
if (myid == nproc-1) idmax = n;
A.SetInterval(idmin,idmax);
static const unsigned ndiag = 7;
int id[ndiag] = { 0, 0,-1, 0, 1, 0, 0 }; // ! ! -1 ! !
int jd[ndiag] = { 0,-1, 0, 0, 0, 1, 0 }; // ! -1 ! -1 6 -1 ! -1 !
int kd[ndiag] = { -1, 0, 0, 0, 0, 0, 1 }; // ! ! -1 ! !
int ad[ndiag] = { -1,-1,-1, 6,-1,-1,-1 };
for (int k=0; k<n3; k++) {
for (int j=0; j<n2; j++) {
for (int i=0; i<n1; i++) {
unsigned iii = i + j*n1 + k*n1*n2;
if (iii >= idmin && iii < idmax) {
for (unsigned d=0; d<ndiag; d++) {
int ii = i + id[d];
int jj = j + jd[d];
int kk = k + kd[d];
if (ii >= 0 && ii < n1 &&
jj >= 0 && jj < n2 &&
kk >= 0 && kk < n3) {
int jjj = ii + jj*n1 + kk*n1*n2;
A[iii][jjj] = ad[d];
}
}
}
}
}
}
}
| 34.977011 | 202 | 0.608719 | [
"mesh",
"vector",
"model",
"3d"
] |
5ebfb2734a9942818625e700578f03a1e25d3684 | 3,993 | hpp | C++ | external/cfmesh/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorFUN/meshSurfaceEdgeExtractorFUN.hpp | MrAwesomeRocks/caelus-cml | 55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7 | [
"mpich2"
] | null | null | null | external/cfmesh/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorFUN/meshSurfaceEdgeExtractorFUN.hpp | MrAwesomeRocks/caelus-cml | 55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7 | [
"mpich2"
] | null | null | null | external/cfmesh/meshLibrary/utilities/surfaceTools/meshSurfaceEdgeExtractorFUN/meshSurfaceEdgeExtractorFUN.hpp | MrAwesomeRocks/caelus-cml | 55b6dc5ba47d0e95c07412d9446ac72ac11d7fd7 | [
"mpich2"
] | null | null | null | /*---------------------------------------------------------------------------*\
Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
This file is part of cfMesh.
cfMesh 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.
cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
Class
meshSurfaceEdgeExtractorFUN
Description
Stores boundary faces into patches and captures edges and corners
by inserting fundamental mesh sheets
Author: Franjo Juretic (franjo.juretic@c-fields.com)
SourceFiles
meshSurfaceEdgeExtractorFUN.cpp
\*---------------------------------------------------------------------------*/
#ifndef meshSurfaceEdgeExtractorFUN_HPP
#define meshSurfaceEdgeExtractorFUN_HPP
#include "polyMeshGenModifier.hpp"
#include "boolList.hpp"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace CML
{
// Forward declarations
class meshOctree;
class meshSurfaceEngine;
/*---------------------------------------------------------------------------*\
Class meshSurfaceEdgeExtractorFUN Declaration
\*---------------------------------------------------------------------------*/
class meshSurfaceEdgeExtractorFUN
{
// Private data
//- mesh
polyMeshGen& mesh_;
//- octree
const meshOctree& meshOctree_;
//- mesh surface pointer
meshSurfaceEngine* surfaceEnginePtr_;
//- shall the procedure generate an initial wrapper sheet
const bool createWrapperSheet_;
// Private member functions
//- return reference to surface engine
meshSurfaceEngine& surfaceEngine();
//- clear mesh suirface engine
void clearOut();
//- distribute boundary faces into patches
void distributeBoundaryFaces();
//- check whether all corners in the surface mesh are present
//- in the volume mesh
void reviseCorners();
//- check whether all edges in the surface mesh are present
//- in the volume mesh
void reviseEdges();
//- find corner vertices and correct patches
void findCornersAndCorrectPatches();
//- create fundamental sheets
void createBasicFundamentalSheets();
//- smooth the surface
void smoothMeshSurface();
//- modify fundamental sheets
void improveQualityOfFundamentalSheets();
//- re-map points after edges have been extracted
void remapBoundaryPoints();
//- Disallow default construct
meshSurfaceEdgeExtractorFUN();
//- Disallow default bitwise copy construct
meshSurfaceEdgeExtractorFUN(const meshSurfaceEdgeExtractorFUN&);
//- Disallow default bitwise assignment
void operator=(const meshSurfaceEdgeExtractorFUN&);
public:
// Constructors
//- Construct from mesh data
meshSurfaceEdgeExtractorFUN
(
polyMeshGen& mesh,
const meshOctree& octree,
const bool createWrapperSheet = true
);
// Destructor
~meshSurfaceEdgeExtractorFUN();
// Member Functions
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace CML
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
| 28.521429 | 79 | 0.559479 | [
"mesh"
] |
5ec6f1958470d5efbe9b84add9dd4dbd20fdd714 | 18,325 | cpp | C++ | test/rocprim/test_hc_device_segmented_scan.cpp | arsenm/rocPRIM | 02d6006a7951c53ecfd245200d58809d3eee0b48 | [
"MIT"
] | null | null | null | test/rocprim/test_hc_device_segmented_scan.cpp | arsenm/rocPRIM | 02d6006a7951c53ecfd245200d58809d3eee0b48 | [
"MIT"
] | null | null | null | test/rocprim/test_hc_device_segmented_scan.cpp | arsenm/rocPRIM | 02d6006a7951c53ecfd245200d58809d3eee0b48 | [
"MIT"
] | null | null | null | // MIT License
//
// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <algorithm>
#include <functional>
#include <iostream>
#include <random>
#include <type_traits>
#include <vector>
#include <utility>
// Google Test
#include <gtest/gtest.h>
// HC API
#include <hcc/hc.hpp>
// rocPRIM API
#include <rocprim/rocprim.hpp>
#include "test_utils.hpp"
template<
class Input,
class Output,
class ScanOp = ::rocprim::plus<Input>,
int Init = 0, // as only integral types supported, int is used here even for floating point inputs
unsigned int MinSegmentLength = 0,
unsigned int MaxSegmentLength = 1000
>
struct params
{
using input_type = Input;
using output_type = Output;
using scan_op_type = ScanOp;
static constexpr int init = Init;
static constexpr unsigned int min_segment_length = MinSegmentLength;
static constexpr unsigned int max_segment_length = MaxSegmentLength;
};
template<class Params>
class RocprimDeviceSegmentedScan : public ::testing::Test {
public:
using params = Params;
};
using custom_short2 = test_utils::custom_test_type<short>;
using custom_int2 = test_utils::custom_test_type<int>;
using custom_double2 = test_utils::custom_test_type<double>;
typedef ::testing::Types<
params<unsigned char, unsigned int, rocprim::plus<unsigned int>>,
params<int, int, rocprim::plus<int>, -100, 0, 10000>,
params<custom_double2, custom_double2, rocprim::minimum<custom_double2>, 1000, 0, 10000>,
params<custom_int2, custom_short2, rocprim::maximum<custom_int2>, 10, 1000, 10000>,
params<float, double, rocprim::maximum<double>, 50, 2, 10>,
params<float, float, rocprim::plus<float>, 123, 100, 200>
> Params;
TYPED_TEST_CASE(RocprimDeviceSegmentedScan, Params);
std::vector<size_t> get_sizes()
{
std::vector<size_t> sizes = {
1024, 2048, 4096, 1792,
1, 10, 53, 211, 500,
2345, 11001, 34567,
(1 << 17) - 1220
};
const std::vector<size_t> random_sizes = test_utils::get_random_data<size_t>(2, 1, 1000000);
sizes.insert(sizes.end(), random_sizes.begin(), random_sizes.end());
return sizes;
}
TYPED_TEST(RocprimDeviceSegmentedScan, InclusiveScan)
{
using input_type = typename TestFixture::params::input_type;
using output_type = typename TestFixture::params::output_type;
using scan_op_type = typename TestFixture::params::scan_op_type;
using result_type = output_type;
using offset_type = unsigned int;
const bool debug_synchronous = false;
scan_op_type scan_op;
std::random_device rd;
std::default_random_engine gen(rd());
std::uniform_int_distribution<size_t> segment_length_dis(
TestFixture::params::min_segment_length,
TestFixture::params::max_segment_length
);
hc::accelerator acc;
hc::accelerator_view acc_view = acc.create_view();
const std::vector<size_t> sizes = get_sizes();
for(size_t size : sizes)
{
SCOPED_TRACE(testing::Message() << "with size = " << size);
// Generate data and calculate expected results
std::vector<output_type> values_expected(size);
std::vector<input_type> values_input = test_utils::get_random_data<input_type>(size, 0, 100);
std::vector<offset_type> offsets;
unsigned int segments_count = 0;
size_t offset = 0;
while(offset < size)
{
const size_t segment_length = segment_length_dis(gen);
offsets.push_back(offset);
const size_t end = std::min(size, offset + segment_length);
result_type aggregate = values_input[offset];
values_expected[offset] = aggregate;
for(size_t i = offset + 1; i < end; i++)
{
aggregate = scan_op(aggregate, static_cast<result_type>(values_input[i]));
values_expected[i] = aggregate;
}
segments_count++;
offset += segment_length;
}
offsets.push_back(size);
hc::array<input_type> d_values_input(hc::extent<1>(size), values_input.begin(), acc_view);
hc::array<offset_type> d_offsets(hc::extent<1>(segments_count + 1), offsets.begin(), acc_view);
hc::array<output_type> d_values_output(hc::extent<1>(size), acc_view);
size_t temporary_storage_bytes;
rocprim::segmented_inclusive_scan(
nullptr, temporary_storage_bytes,
d_values_input.accelerator_pointer(), d_values_output.accelerator_pointer(),
segments_count,
d_offsets.accelerator_pointer(), d_offsets.accelerator_pointer() + 1,
scan_op,
acc_view, debug_synchronous
);
ASSERT_GT(temporary_storage_bytes, 0);
hc::array<char> d_temporary_storage(temporary_storage_bytes, acc_view);
rocprim::segmented_inclusive_scan(
d_temporary_storage.accelerator_pointer(), temporary_storage_bytes,
d_values_input.accelerator_pointer(), d_values_output.accelerator_pointer(),
segments_count,
d_offsets.accelerator_pointer(), d_offsets.accelerator_pointer() + 1,
scan_op,
acc_view, debug_synchronous
);
acc_view.wait();
std::vector<output_type> values_output = d_values_output;
ASSERT_NO_FATAL_FAILURE(test_utils::assert_near(values_output, values_expected, 0.01f));
}
}
TYPED_TEST(RocprimDeviceSegmentedScan, ExclusiveScan)
{
using input_type = typename TestFixture::params::input_type;
using output_type = typename TestFixture::params::output_type;
using scan_op_type = typename TestFixture::params::scan_op_type;
using result_type = output_type;
using offset_type = unsigned int;
const input_type init = TestFixture::params::init;
const bool debug_synchronous = false;
scan_op_type scan_op;
std::random_device rd;
std::default_random_engine gen(rd());
std::uniform_int_distribution<size_t> segment_length_dis(
TestFixture::params::min_segment_length,
TestFixture::params::max_segment_length
);
hc::accelerator acc;
hc::accelerator_view acc_view = acc.create_view();
const std::vector<size_t> sizes = get_sizes();
for(size_t size : sizes)
{
SCOPED_TRACE(testing::Message() << "with size = " << size);
// Generate data and calculate expected results
std::vector<output_type> values_expected(size);
std::vector<input_type> values_input = test_utils::get_random_data<input_type>(size, 0, 100);
std::vector<offset_type> offsets;
unsigned int segments_count = 0;
size_t offset = 0;
while(offset < size)
{
const size_t segment_length = segment_length_dis(gen);
offsets.push_back(offset);
const size_t end = std::min(size, offset + segment_length);
result_type aggregate = init;
values_expected[offset] = aggregate;
for(size_t i = offset + 1; i < end; i++)
{
aggregate = scan_op(aggregate, static_cast<result_type>(values_input[i-1]));
values_expected[i] = aggregate;
}
segments_count++;
offset += segment_length;
}
offsets.push_back(size);
hc::array<input_type> d_values_input(hc::extent<1>(size), values_input.begin(), acc_view);
hc::array<offset_type> d_offsets(hc::extent<1>(segments_count + 1), offsets.begin(), acc_view);
hc::array<output_type> d_values_output(hc::extent<1>(size), acc_view);
size_t temporary_storage_bytes;
rocprim::segmented_exclusive_scan(
nullptr, temporary_storage_bytes,
d_values_input.accelerator_pointer(), d_values_output.accelerator_pointer(),
segments_count,
d_offsets.accelerator_pointer(), d_offsets.accelerator_pointer() + 1,
init, scan_op,
acc_view, debug_synchronous
);
ASSERT_GT(temporary_storage_bytes, 0);
hc::array<char> d_temporary_storage(temporary_storage_bytes, acc_view);
rocprim::segmented_exclusive_scan(
d_temporary_storage.accelerator_pointer(), temporary_storage_bytes,
d_values_input.accelerator_pointer(), d_values_output.accelerator_pointer(),
segments_count,
d_offsets.accelerator_pointer(), d_offsets.accelerator_pointer() + 1,
init, scan_op,
acc_view, debug_synchronous
);
acc_view.wait();
std::vector<output_type> values_output = d_values_output;
ASSERT_NO_FATAL_FAILURE(test_utils::assert_near(values_output, values_expected, 0.01f));
}
}
TYPED_TEST(RocprimDeviceSegmentedScan, InclusiveScanUsingHeadFlags)
{
using input_type = typename TestFixture::params::input_type;
using flag_type = unsigned int;
using output_type = typename TestFixture::params::output_type;
using scan_op_type = typename TestFixture::params::scan_op_type;
const bool debug_synchronous = false;
hc::accelerator acc;
hc::accelerator_view acc_view = acc.create_view();
const std::vector<size_t> sizes = get_sizes();
for(auto size : sizes)
{
SCOPED_TRACE(testing::Message() << "with size = " << size);
// Generate data
std::vector<input_type> input = test_utils::get_random_data<input_type>(size, 1, 1);
std::vector<flag_type> flags = test_utils::get_random_data<flag_type>(size, 0, 10);
flags[0] = 1U;
std::transform(
flags.begin(), flags.end(), flags.begin(),
[](flag_type a){ if(a==1U) return 1U; return 0U; }
);
hc::array<input_type> d_input(hc::extent<1>(size), input.begin(), acc_view);
hc::array<flag_type> d_flags(hc::extent<1>(size), flags.begin(), acc_view);
hc::array<output_type> d_output(size, acc_view);
acc_view.wait();
// scan function
scan_op_type scan_op;
// Calculate expected results on host
std::vector<output_type> expected(input.size());
test_utils::host_inclusive_scan(
rocprim::make_zip_iterator(
rocprim::make_tuple(input.begin(), flags.begin())
),
rocprim::make_zip_iterator(
rocprim::make_tuple(input.end(), flags.end())
),
rocprim::make_zip_iterator(
rocprim::make_tuple(expected.begin(), rocprim::make_discard_iterator())
),
[scan_op](const rocprim::tuple<output_type, flag_type>& t1,
const rocprim::tuple<output_type, flag_type>& t2)
-> rocprim::tuple<output_type, flag_type>
{
if(!rocprim::get<1>(t2))
{
return rocprim::make_tuple(
scan_op(rocprim::get<0>(t1), rocprim::get<0>(t2)),
rocprim::get<1>(t1) + rocprim::get<1>(t2)
);
}
return t2;
}
);
// temp storage
size_t temp_storage_size_bytes;
// Get size of d_temp_storage
rocprim::segmented_inclusive_scan(
nullptr,
temp_storage_size_bytes,
d_input.accelerator_pointer(),
d_output.accelerator_pointer(),
d_flags.accelerator_pointer(),
input.size(),
scan_op,
acc_view,
debug_synchronous
);
acc_view.wait();
// temp_storage_size_bytes must be >0
ASSERT_GT(temp_storage_size_bytes, 0);
// allocate temporary storage
hc::array<char> d_temp_storage(temp_storage_size_bytes, acc_view);
acc_view.wait();
// Run
rocprim::segmented_inclusive_scan(
d_temp_storage.accelerator_pointer(),
temp_storage_size_bytes,
d_input.accelerator_pointer(),
d_output.accelerator_pointer(),
d_flags.accelerator_pointer(),
input.size(),
scan_op,
acc_view,
debug_synchronous
);
acc_view.wait();
// Check if output values are as expected
std::vector<output_type> output = d_output;
ASSERT_NO_FATAL_FAILURE(test_utils::assert_near(output, expected, 0.01f));
}
}
TYPED_TEST(RocprimDeviceSegmentedScan, ExclusiveScanUsingHeadFlags)
{
using input_type = typename TestFixture::params::input_type;
using flag_type = unsigned int;
using output_type = typename TestFixture::params::output_type;
using scan_op_type = typename TestFixture::params::scan_op_type;
const input_type init = TestFixture::params::init;
const bool debug_synchronous = false;
hc::accelerator acc;
hc::accelerator_view acc_view = acc.create_view();
const std::vector<size_t> sizes = get_sizes();
for(auto size : sizes)
{
SCOPED_TRACE(testing::Message() << "with size = " << size);
// Generate data
std::vector<input_type> input = test_utils::get_random_data<input_type>(size, 1, 1);
std::vector<flag_type> flags = test_utils::get_random_data<flag_type>(size, 0, 10);
flags[0] = 1U;
std::transform(
flags.begin(), flags.end(), flags.begin(),
[](flag_type a){ if(a==1U) return 1U; return 0U; }
);
hc::array<input_type> d_input(hc::extent<1>(size), input.begin(), acc_view);
hc::array<flag_type> d_flags(hc::extent<1>(size), flags.begin(), acc_view);
hc::array<output_type> d_output(size, acc_view);
acc_view.wait();
// scan function
scan_op_type scan_op;
// Calculate expected results on host
std::vector<output_type> expected(input.size());
// Modify input to perform exclusive operation on initial input.
// This shifts input one to the right and initializes segments with init.
expected[0] = init;
std::transform(
rocprim::make_zip_iterator(
rocprim::make_tuple(input.begin(), flags.begin()+1)
),
rocprim::make_zip_iterator(
rocprim::make_tuple(input.end() - 1, flags.end())
),
rocprim::make_zip_iterator(
rocprim::make_tuple(expected.begin() + 1, rocprim::make_discard_iterator())
),
[init](const rocprim::tuple<input_type, flag_type>& t)
-> rocprim::tuple<input_type, flag_type>
{
if(rocprim::get<1>(t))
{
return rocprim::make_tuple(
init,
rocprim::get<1>(t)
);
}
return t;
}
);
// Now we can run inclusive scan and get segmented exclusive results
test_utils::host_inclusive_scan(
rocprim::make_zip_iterator(
rocprim::make_tuple(expected.begin(), flags.begin())
),
rocprim::make_zip_iterator(
rocprim::make_tuple(expected.end(), flags.end())
),
rocprim::make_zip_iterator(
rocprim::make_tuple(expected.begin(), rocprim::make_discard_iterator())
),
[scan_op](const rocprim::tuple<output_type, flag_type>& t1,
const rocprim::tuple<output_type, flag_type>& t2)
-> rocprim::tuple<output_type, flag_type>
{
if(!rocprim::get<1>(t2))
{
return rocprim::make_tuple(
scan_op(rocprim::get<0>(t1), rocprim::get<0>(t2)),
rocprim::get<1>(t1) + rocprim::get<1>(t2)
);
}
return t2;
}
);
// temp storage
size_t temp_storage_size_bytes;
// Get size of d_temp_storage
rocprim::segmented_exclusive_scan(
nullptr,
temp_storage_size_bytes,
d_input.accelerator_pointer(),
d_output.accelerator_pointer(),
d_flags.accelerator_pointer(),
init,
input.size(),
scan_op,
acc_view,
debug_synchronous
);
acc_view.wait();
// temp_storage_size_bytes must be >0
ASSERT_GT(temp_storage_size_bytes, 0);
// allocate temporary storage
hc::array<char> d_temp_storage(temp_storage_size_bytes, acc_view);
acc_view.wait();
// Run
rocprim::segmented_exclusive_scan(
d_temp_storage.accelerator_pointer(),
temp_storage_size_bytes,
d_input.accelerator_pointer(),
d_output.accelerator_pointer(),
d_flags.accelerator_pointer(),
init,
input.size(),
scan_op,
acc_view,
debug_synchronous
);
acc_view.wait();
// Check if output values are as expected
std::vector<output_type> output = d_output;
ASSERT_NO_FATAL_FAILURE(test_utils::assert_near(output, expected, 0.01f));
}
}
| 36.797189 | 103 | 0.625757 | [
"vector",
"transform"
] |
5ec7d848f4fc93387ae771314f6a3c860ae14c8b | 13,918 | cpp | C++ | src/engine/entity/src/scripting/script_renderer.cpp | pinguin999/halley | 895e5ae482787eb09185928625e1ee9be3845fbc | [
"Apache-2.0"
] | null | null | null | src/engine/entity/src/scripting/script_renderer.cpp | pinguin999/halley | 895e5ae482787eb09185928625e1ee9be3845fbc | [
"Apache-2.0"
] | null | null | null | src/engine/entity/src/scripting/script_renderer.cpp | pinguin999/halley | 895e5ae482787eb09185928625e1ee9be3845fbc | [
"Apache-2.0"
] | null | null | null | #include "scripting/script_renderer.h"
#include "world.h"
#include "halley/core/graphics/painter.h"
#include "halley/maths/bezier.h"
#include "halley/support/logger.h"
#include "scripting/script_graph.h"
#include "scripting/script_node_type.h"
using namespace Halley;
#ifndef DONT_INCLUDE_HALLEY_HPP
#define DONT_INCLUDE_HALLEY_HPP
#endif
#include "components/transform_2d_component.h"
ScriptRenderer::ScriptRenderer(Resources& resources, World& world, const ScriptNodeTypeCollection& nodeTypeCollection, float nativeZoom)
: resources(resources)
, world(world)
, nodeTypeCollection(nodeTypeCollection)
, nativeZoom(nativeZoom)
{
nodeBg = Sprite().setImage(resources, "halley_ui/ui_float_solid_window.png").setPivot(Vector2f(0.5f, 0.5f));
variableBg = Sprite().setImage(resources, "halley_ui/script_variable.png").setPivot(Vector2f(0.5f, 0.5f));
pinSprite = Sprite().setImage(resources, "halley_ui/ui_render_graph_node_pin.png").setPivot(Vector2f(0.5f, 0.5f));
labelText
.setFont(resources.get<Font>("Ubuntu Bold"))
.setSize(14)
.setColour(Colour(1, 1, 1))
.setOutlineColour(Colour(0, 0, 0))
.setOutline(1)
.setAlignment(0.5f);
}
void ScriptRenderer::setGraph(const ScriptGraph* graph)
{
this->graph = graph;
}
void ScriptRenderer::setState(ScriptState* scriptState)
{
state = scriptState;
}
void ScriptRenderer::draw(Painter& painter, Vector2f basePos, float curZoom)
{
if (!graph) {
return;
}
const float effectiveZoom = std::max(nativeZoom, curZoom);
for (size_t i = 0; i < graph->getNodes().size(); ++i) {
drawNodeOutputs(painter, basePos, i, *graph, effectiveZoom);
}
if (currentPath) {
drawConnection(painter, currentPath.value(), curZoom, false);
}
for (uint32_t i = 0; i < static_cast<uint32_t>(graph->getNodes().size()); ++i) {
const auto& node = graph->getNodes()[i];
const bool highlightThis = highlightNode && highlightNode->nodeId == i;
const auto pinType = highlightThis ? highlightNode->element : std::optional<ScriptNodePinType>();
const auto pinId = highlightThis ? highlightNode->elementId : 0;
NodeDrawMode drawMode;
if (state) {
// Rendering in-game, with execution state
const auto nodeIntrospection = state->getNodeIntrospection(i);
if (nodeIntrospection.state == ScriptState::NodeIntrospectionState::Active) {
drawMode.type = NodeDrawModeType::Active;
drawMode.time = nodeIntrospection.time;
} else if (nodeIntrospection.state == ScriptState::NodeIntrospectionState::Visited) {
drawMode.type = NodeDrawModeType::Visited;
drawMode.time = nodeIntrospection.time;
}
drawMode.activationTime = nodeIntrospection.activationTime;
} else {
// Rendering in editor
if (highlightThis && highlightNode->element.type == ScriptNodeElementType::Node) {
drawMode.type = NodeDrawModeType::Highlight;
}
}
drawNode(painter, basePos, node, effectiveZoom, drawMode, pinType, pinId);
}
}
void ScriptRenderer::drawNodeOutputs(Painter& painter, Vector2f basePos, size_t nodeIdx, const ScriptGraph& graph, float curZoom)
{
const ScriptGraphNode& node = graph.getNodes().at(nodeIdx);
const auto* nodeType = nodeTypeCollection.tryGetNodeType(node.getType());
if (!nodeType) {
return;
}
const bool nodeHighlighted = highlightNode && highlightNode->nodeId == nodeIdx;
for (size_t i = 0; i < node.getPins().size(); ++i) {
const auto& srcPinType = nodeType->getPin(node, i);
const auto& pin = node.getPins()[i];
for (const auto& pinConnection: pin.connections) {
std::optional<Vector2f> dstPos;
ScriptNodePinType dstPinType;
bool highlighted = nodeHighlighted;
if (pinConnection.dstNode && srcPinType.direction == ScriptNodePinDirection::Output) {
const size_t dstIdx = pinConnection.dstPin;
const auto& dstNode = graph.getNodes().at(pinConnection.dstNode.value());
const auto* dstNodeType = nodeTypeCollection.tryGetNodeType(dstNode.getType());
if (!dstNodeType) {
continue;
}
dstPos = getNodeElementArea(*dstNodeType, basePos, dstNode, dstIdx, curZoom).getCentre();
dstPinType = dstNodeType->getPin(node, dstIdx);
if (highlightNode && highlightNode->nodeId == pinConnection.dstNode.value()) {
highlighted = true;
}
} else if (pinConnection.entity.isValid()) {
auto entity = world.tryGetEntity(pinConnection.entity);
if (entity.isValid()) {
auto* transform = entity.tryGetComponent<Transform2DComponent>();
if (transform) {
dstPos = transform->getGlobalPosition();
dstPinType = ScriptNodePinType{ ScriptNodeElementType::TargetPin, ScriptNodePinDirection::Output };
}
}
}
if (dstPos) {
const Vector2f srcPos = getNodeElementArea(*nodeType, basePos, node, i, curZoom).getCentre();
drawConnection(painter, ConnectionPath{ srcPos, dstPos.value(), srcPinType, dstPinType }, curZoom, highlighted);
}
}
}
}
BezierCubic ScriptRenderer::makeBezier(const ConnectionPath& path) const
{
auto getSideNormal = [] (ScriptPinSide side) -> Vector2f
{
switch (side) {
case ScriptPinSide::Left:
return Vector2f(-1, 0);
case ScriptPinSide::Right:
return Vector2f(1, 0);
case ScriptPinSide::Top:
return Vector2f(0, -1);
case ScriptPinSide::Bottom:
return Vector2f(0, 1);
}
return Vector2f();
};
const Vector2f fromDir = getSideNormal(path.fromType.getSide());
const Vector2f toDir = getSideNormal(path.toType.getSide());
const auto delta = path.to - path.from;
const float dist = std::max(std::max(std::abs(delta.x), std::abs(delta.y)), 20.0f) / 2;
return BezierCubic(path.from, path.from + dist * fromDir, path.to + dist * toDir, path.to);
}
void ScriptRenderer::drawConnection(Painter& painter, const ConnectionPath& path, float curZoom, bool highlight) const
{
const auto bezier = makeBezier(path);
const auto baseCol = getPinColour(path.fromType);
const auto col = highlight ? baseCol.inverseMultiplyLuma(0.25f) : baseCol;
painter.drawLine(bezier + Vector2f(1.0f, 2.0f) / curZoom, 3.0f / curZoom, Colour4f(0, 0, 0, 0.3f));
painter.drawLine(bezier, 3.0f / curZoom, col);
}
void ScriptRenderer::drawNode(Painter& painter, Vector2f basePos, const ScriptGraphNode& node, float curZoom, NodeDrawMode drawMode, std::optional<ScriptNodePinType> highlightElement, uint8_t highlightElementId)
{
const Vector2f border = Vector2f(18, 18);
const Vector2f nodeSize = getNodeSize(curZoom);
const auto pos = ((basePos + node.getPosition()) * curZoom).round() / curZoom;
const auto* nodeType = nodeTypeCollection.tryGetNodeType(node.getType());
if (!nodeType) {
return;
}
{
const auto baseCol = getNodeColour(*nodeType);
Colour4f col = baseCol;
Colour4f iconCol = Colour4f(1, 1, 1);
switch (drawMode.type) {
case NodeDrawModeType::Highlight:
col = col.inverseMultiplyLuma(0.5f);
break;
case NodeDrawModeType::Active:
{
const float phase = drawMode.time * 2.0f * pif();
col = col.inverseMultiplyLuma(sinRange(phase, 0.3f, 1.0f));
break;
}
case NodeDrawModeType::Visited:
col = col.multiplyLuma(0.3f);
iconCol = Colour4f(0.5f, 0.5f, 0.5f);
break;
}
if (drawMode.activationTime > 0.0f) {
const float t = drawMode.activationTime;
col = lerp(col, Colour4f(1, 1, 1), t * t);
}
// Node body
const bool variable = nodeType->getClassification() == ScriptNodeClassification::Variable;
if (variable) {
variableBg.clone()
.setColour(col)
.setPosition(pos)
.setScale(1.0f / curZoom)
.draw(painter);
} else {
nodeBg.clone()
.setColour(col)
.setPosition(pos)
.scaleTo(nodeSize + border)
.setSize(nodeBg.getSize() / curZoom)
.setSliceScale(1.0f / curZoom)
.draw(painter);
}
const auto label = nodeType->getLabel(node);
const float iconExtraOffset = nodeType->getClassification() == ScriptNodeClassification::Variable ? -2.0f : 0.0f;
const Vector2f iconOffset = label.isEmpty() ? Vector2f() : Vector2f(0, (-8.0f + iconExtraOffset) / curZoom).round();
// Icon
getIcon(*nodeType, node).clone()
.setPosition(pos + iconOffset)
.setScale(1.0f / curZoom)
.setColour(iconCol)
.draw(painter);
// Label
if (!label.isEmpty()) {
labelText.clone()
.setPosition(pos + Vector2f(0, (8.0f + iconExtraOffset) / curZoom).round())
.setText(label)
.setSize(14 / curZoom)
.setOutline(8.0f / curZoom)
.setOutlineColour(col.multiplyLuma(0.75f))
.draw(painter);
}
}
// Draw pins
const auto& pins = nodeType->getPinConfiguration(node);
for (size_t i = 0; i < pins.size(); ++i) {
const auto& pinType = pins[i];
const auto circle = getNodeElementArea(*nodeType, basePos, node, i, curZoom);
const auto baseCol = getPinColour(pinType);
const auto col = highlightElement == pinType && highlightElementId == i ? baseCol.inverseMultiplyLuma(0.3f) : baseCol;
pinSprite.clone()
.setPosition(circle.getCentre())
.setColour(col)
.setScale(1.0f / curZoom)
.draw(painter);
}
}
Vector2f ScriptRenderer::getNodeSize(float curZoom) const
{
return Vector2f(60, 60);
}
Circle ScriptRenderer::getNodeElementArea(const IScriptNodeType& nodeType, Vector2f basePos, const ScriptGraphNode& node, size_t pinN, float curZoom) const
{
const Vector2f nodeSize = getNodeSize(curZoom);
const auto getOffset = [&] (size_t idx, size_t n)
{
const float spacing = nodeSize.x / (n + 1);
return (static_cast<float>(idx) - (n - 1) * 0.5f) * spacing;
};
const auto& pin = nodeType.getPin(node, pinN);
const auto pinSide = pin.getSide();
size_t pinsOnSide = 0;
size_t idxOnSide = 0;
const auto& pins = nodeType.getPinConfiguration(node);
for (size_t i = 0; i < pins.size(); ++i) {
const auto& pinType = pins[i];
if (i == pinN) {
idxOnSide = pinsOnSide;
}
if (pinType.getSide() == pinSide) {
++pinsOnSide;
}
}
const auto sideOffset = getOffset(idxOnSide, pinsOnSide);
Vector2f offset;
switch (pinSide) {
case ScriptPinSide::Left:
offset = Vector2f(-nodeSize.x * 0.5f, sideOffset);
break;
case ScriptPinSide::Right:
offset = Vector2f(nodeSize.x * 0.5f, sideOffset);
break;
case ScriptPinSide::Top:
offset = Vector2f(sideOffset, -nodeSize.y * 0.5f);
break;
case ScriptPinSide::Bottom:
offset = Vector2f(sideOffset, nodeSize.y * 0.5f);
break;
default:
break;
}
const Vector2f pos = basePos + node.getPosition();
const Vector2f centre = pos + offset / curZoom;
const float radius = 4.0f / curZoom;
return Circle(centre, radius);
}
Colour4f ScriptRenderer::getNodeColour(const IScriptNodeType& nodeType)
{
switch (nodeType.getClassification()) {
case ScriptNodeClassification::Terminator:
return Colour4f(0.97f, 0.35f, 0.35f);
case ScriptNodeClassification::Action:
return Colour4f(0.07f, 0.84f, 0.09f);
case ScriptNodeClassification::Variable:
return Colour4f(0.91f, 0.71f, 0.0f);
case ScriptNodeClassification::FlowControl:
return Colour4f(0.35f, 0.35f, 0.97f);
}
return Colour4f(0.2f, 0.2f, 0.2f);
}
Colour4f ScriptRenderer::getPinColour(ScriptNodePinType pinType) const
{
switch (pinType.type) {
case ScriptNodeElementType::FlowPin:
return Colour4f(0.75f, 0.75f, 0.99f);
case ScriptNodeElementType::ReadDataPin:
return Colour4f(0.91f, 0.55f, 0.2f);
case ScriptNodeElementType::WriteDataPin:
return Colour4f(0.91f, 0.2f, 0.2f);
case ScriptNodeElementType::TargetPin:
return Colour4f(0.35f, 1, 0.35f);
}
return Colour4f();
}
const Sprite& ScriptRenderer::getIcon(const IScriptNodeType& nodeType, const ScriptGraphNode& node)
{
const auto& iconName = nodeType.getIconName(node);
const auto iter = icons.find(iconName);
if (iter != icons.end()) {
return iter->second;
}
icons[iconName] = Sprite().setImage(resources, iconName).setPivot(Vector2f(0.5f, 0.5f));
return icons[iconName];
}
std::optional<ScriptRenderer::NodeUnderMouseInfo> ScriptRenderer::getNodeUnderMouse(Vector2f basePos, float curZoom, std::optional<Vector2f> mousePos, bool pinPriority) const
{
if (!graph || !mousePos) {
return {};
}
const float effectiveZoom = std::max(nativeZoom, curZoom);
const auto nodeSize = getNodeSize(effectiveZoom);
const Rect4f area = Rect4f(-nodeSize / 2, nodeSize / 2) / effectiveZoom;
float bestDistance = std::numeric_limits<float>::max();
std::optional<NodeUnderMouseInfo> bestResult;
for (size_t i = 0; i < graph->getNodes().size(); ++i) {
const auto& node = graph->getNodes()[i];
const auto pos = basePos + node.getPosition();
const auto nodeBounds = Circle(pos, area.getSize().length() / 2);
if (!nodeBounds.contains(mousePos.value())) {
continue;
}
const auto* nodeType = nodeTypeCollection.tryGetNodeType(node.getType());
if (!nodeType) {
continue;
}
const auto curRect = area + pos;
// Check each pin handle
bool foundPin = false;
const auto& pins = nodeType->getPinConfiguration(node);
for (size_t j = 0; j < pins.size(); ++j) {
const auto& pinType = pins[j];
const auto circle = getNodeElementArea(*nodeType, basePos, node, j, curZoom).expand((pinPriority ? 12.0f : 4.0f) / curZoom);
if (circle.contains(mousePos.value())) {
foundPin = true;
const float distance = (mousePos.value() - circle.getCentre()).length();
if (distance < bestDistance) {
bestDistance = distance;
bestResult = NodeUnderMouseInfo{ static_cast<uint32_t>(i), pinType, static_cast<uint8_t>(j), curRect, circle.getCentre() };
}
}
}
// Check main body
if (!foundPin && curRect.contains(mousePos.value())) {
const float distance = (mousePos.value() - curRect.getCenter()).length();
if (distance < bestDistance) {
bestDistance = distance;
bestResult = NodeUnderMouseInfo{ static_cast<uint32_t>(i), ScriptNodePinType{ScriptNodeElementType::Node}, 0, curRect, Vector2f() };
}
}
}
return bestResult;
}
void ScriptRenderer::setHighlight(std::optional<NodeUnderMouseInfo> node)
{
highlightNode = node;
}
void ScriptRenderer::setCurrentPath(std::optional<ConnectionPath> path)
{
currentPath = path;
}
| 32.143187 | 211 | 0.708148 | [
"transform"
] |
5ecd360350ced632474eadd0afba056ae36b2e9f | 921 | cpp | C++ | Dataset/Leetcode/test/102/372.cpp | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/test/102/372.cpp | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | Dataset/Leetcode/test/102/372.cpp | kkcookies99/UAST | fff81885aa07901786141a71e5600a08d7cb4868 | [
"MIT"
] | null | null | null | class Solution {
public:
vector<vector<int>> XXX(TreeNode* root) {
vector<vector<int> > ans;
if (!root) return ans;
queue<pair<TreeNode*,int> > que;
que.push(pair(root,0));
while(!que.empty())
{
int level = que.front().second;
vector<int> temp;
while ( level == que.front().second )
{
temp.push_back(que.front().first->val);
if ( que.front().first->left!=NULL) que.push(pair(que.front().first->left, level+1));
if ( que.front().first->right!=NULL) que.push(pair(que.front().first->right, level+1));
que.pop();
}
ans.push_back(temp);
}
return ans;
}
};
undefined
for (i = 0; i < document.getElementsByTagName("code").length; i++) { console.log(document.getElementsByTagName("code")[i].innerText); }
| 31.758621 | 139 | 0.515744 | [
"vector"
] |
5ecf1c887d991b0cded4b2ab9f436c0e30e89764 | 5,633 | cc | C++ | src/matrix/sparse-matrix-test.cc | jxzhanggg/kaldi-trunk | 03fbab26e5714a990e1b6dee9475d4a282a42ccc | [
"Apache-2.0"
] | 319 | 2016-10-24T23:08:04.000Z | 2022-03-08T02:36:51.000Z | src/matrix/sparse-matrix-test.cc | jxzhanggg/kaldi-trunk | 03fbab26e5714a990e1b6dee9475d4a282a42ccc | [
"Apache-2.0"
] | 18 | 2017-01-12T12:08:07.000Z | 2020-06-18T07:37:20.000Z | src/matrix/sparse-matrix-test.cc | jxzhanggg/kaldi-trunk | 03fbab26e5714a990e1b6dee9475d4a282a42ccc | [
"Apache-2.0"
] | 87 | 2016-10-25T04:39:48.000Z | 2021-12-24T07:47:31.000Z | // matrix/sparse-matrix-test.cc
// Copyright 2015 Guoguo Chen
// See ../../COPYING for clarification regarding multiple 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
//
// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
// WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
// MERCHANTABLITY OR NON-INFRINGEMENT.
// See the Apache 2 License for the specific language governing permissions and
// limitations under the License.
#include "matrix/matrix-lib.h"
#include "util/stl-utils.h"
namespace kaldi {
template <typename Real>
void UnitTestSparseVectorSum() {
for (int32 i = 0; i < 10; i++) {
MatrixIndexT dim = 10 + Rand() % 40;
SparseVector<Real> svec(dim);
svec.SetRandn(0.8);
Vector<Real> vec(dim);
vec.SetRandn();
svec.CopyElementsToVec(&vec);
Real sum1 = svec.Sum();
Real sum2 = vec.Sum();
AssertEqual(sum1, sum2, 0.00001);
}
}
template <typename Real>
void UnitTestSparseVectorAddToVec() {
for (int32 i = 0; i < 10; i++) {
MatrixIndexT dim = 10 + Rand() % 40;
SparseVector<Real> svec(dim);
svec.SetRandn(0.8);
Vector<Real> vec(dim);
vec.SetRandn();
svec.CopyElementsToVec(&vec);
Vector<Real> other_vec1(dim);
other_vec1.SetRandn();
Vector<Real> other_vec2 = other_vec1;
svec.AddToVec(0.7, &other_vec1);
other_vec2.AddVec(0.7, vec);
AssertEqual(other_vec1, other_vec2, 0.00001);
}
}
template <typename Real>
void UnitTestSparseVectorMax() {
for (int32 i = 0; i < 10; i++) {
MatrixIndexT dim = 10 + Rand() % 40;
if (RandInt(0, 3) == 0)
dim = RandInt(1, 5);
SparseVector<Real> svec(dim);
if (RandInt(0, 3) != 0)
svec.SetRandn(0.8);
Vector<Real> vec(dim);
vec.SetRandn();
svec.CopyElementsToVec(&vec);
int32 index1, index2;
Real max1, max2;
max1 = svec.Max(&index1);
max2 = vec.Max(&index2);
AssertEqual(max1, max2, 0.00001);
AssertEqual(index1, index2, 0.00001);
}
}
template <typename Real>
void UnitTestSparseVectorVecSvec() {
for (int32 i = 0; i < 10; i++) {
MatrixIndexT dim = 10 + Rand() % 40;
SparseVector<Real> svec(dim);
svec.SetRandn(0.8);
Vector<Real> vec(dim);
vec.SetRandn();
svec.CopyElementsToVec(&vec);
Vector<Real> other_vec(dim);
other_vec.SetRandn();
Real product1 = VecSvec(other_vec, svec);
Real product2 = VecVec(other_vec, vec);
KALDI_ASSERT(fabs(product1 - product2) < 1.0e-04);
}
}
template <typename Real>
void UnitTestSparseMatrixSum() {
for (int32 i = 0; i < 10; i++) {
MatrixIndexT row = 10 + Rand() % 40;
MatrixIndexT col = 10 + Rand() % 50;
SparseMatrix<Real> smat(row, col);
smat.SetRandn(0.8);
Matrix<Real> mat(row, col);
mat.SetRandn();
smat.CopyToMat(&mat);
Real sum1 = smat.Sum();
Real sum2 = mat.Sum();
AssertEqual(sum1, sum2, 0.00001);
}
}
template <typename Real>
void UnitTestSparseMatrixFrobeniusNorm() {
for (int32 i = 0; i < 10; i++) {
MatrixIndexT row = 10 + Rand() % 40;
MatrixIndexT col = 10 + Rand() % 50;
SparseMatrix<Real> smat(row, col);
smat.SetRandn(0.8);
Matrix<Real> mat(row, col);
mat.SetRandn();
smat.CopyToMat(&mat);
Real norm1 = smat.FrobeniusNorm();
Real norm2 = mat.FrobeniusNorm();
AssertEqual(norm1, norm2, 0.00001);
}
}
template <typename Real>
void UnitTestSparseMatrixAddToMat() {
for (int32 i = 0; i < 10; i++) {
MatrixIndexT row = 10 + Rand() % 40;
MatrixIndexT col = 10 + Rand() % 50;
SparseMatrix<Real> smat(row, col);
smat.SetRandn(0.8);
Matrix<Real> mat(row, col);
mat.SetRandn();
smat.CopyToMat(&mat);
Matrix<Real> other_mat1(row, col);
other_mat1.SetRandn();
Matrix<Real> other_mat2 = other_mat1;
smat.AddToMat(0.7, &other_mat1);
other_mat2.AddMat(0.7, mat);
AssertEqual(other_mat1, other_mat2, 0.00001);
}
}
template <typename Real>
void UnitTestSparseMatrixTraceMatSmat() {
for (int32 i = 0; i < 10; i++) {
MatrixIndexT row = 10 + Rand() % 40;
MatrixIndexT col = 10 + Rand() % 50;
Matrix<Real> mat1(row, col);
Matrix<Real> mat2(col, row);
Matrix<Real> mat3(row, col);
mat1.SetRandn();
mat2.SetRandn();
mat3.SetRandn();
SparseMatrix<Real> smat1(row, col);
SparseMatrix<Real> smat2(col, row);
smat1.SetRandn(0.8);
smat2.SetRandn(0.8);
smat1.CopyToMat(&mat1);
smat2.CopyToMat(&mat2);
Real trace1 = TraceMatMat(mat3, mat1, kTrans);
Real trace2 = TraceMatSmat(mat3, smat1, kTrans);
AssertEqual(trace1, trace2, 0.00001);
trace1 = TraceMatMat(mat3, mat2, kNoTrans);
trace2 = TraceMatSmat(mat3, smat2, kNoTrans);
AssertEqual(trace1, trace2, 0.00001);
}
}
template <typename Real>
void SparseMatrixUnitTest() {
// SparseVector
UnitTestSparseVectorSum<Real>();
UnitTestSparseVectorAddToVec<Real>();
UnitTestSparseVectorMax<Real>();
UnitTestSparseVectorVecSvec<Real>();
// SparseMatrix
UnitTestSparseMatrixSum<Real>();
UnitTestSparseMatrixFrobeniusNorm<Real>();
UnitTestSparseMatrixAddToMat<Real>();
UnitTestSparseMatrixTraceMatSmat<Real>();
}
} // namespace kaldi
int main() {
kaldi::SetVerboseLevel(5);
kaldi::SparseMatrixUnitTest<float>();
kaldi::SparseMatrixUnitTest<double>();
KALDI_LOG << "Tests succeeded.";
return 0;
}
| 24.598253 | 79 | 0.652583 | [
"vector"
] |
5edac55fa716ca0e684aa22bfb30c5614262823f | 3,564 | hpp | C++ | source/include/coffee/persistence/Storage.hpp | ciscoruiz/wepa | e6d922157543c91b6804f11073424a0a9c6e8f51 | [
"MIT"
] | 2 | 2018-02-03T06:56:29.000Z | 2021-04-20T10:28:32.000Z | source/include/coffee/persistence/Storage.hpp | ciscoruiz/wepa | e6d922157543c91b6804f11073424a0a9c6e8f51 | [
"MIT"
] | 8 | 2018-02-18T21:00:07.000Z | 2018-02-20T15:31:24.000Z | source/include/coffee/persistence/Storage.hpp | ciscoruiz/wepa | e6d922157543c91b6804f11073424a0a9c6e8f51 | [
"MIT"
] | 1 | 2018-02-09T07:09:26.000Z | 2018-02-09T07:09:26.000Z | // MIT License
//
// Copyright (c) 2018 Francisco Ruiz (francisco.ruiz.rayo@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.
//
#ifndef __coffee_persistence_Storage_hpp
#define __coffee_persistence_Storage_hpp
#include <memory>
#include <coffee/basis/NamedObject.hpp>
#include <coffee/basis/pattern/lru/Cache.hpp>
#include <coffee/persistence/PrimaryKey.hpp>
#include <coffee/persistence/Accessor.hpp>
#include <coffee/dbms/DatabaseException.hpp>
namespace coffee {
namespace xml {
class Node;
}
namespace dbms {
class Connection;
class GuardConnection;
}
namespace persistence {
class Repository;
class Object;
class Loader;
class Recorder;
class Eraser;
class Creator;
class Storage : public basis::NamedObject {
public:
private:
typedef basis::pattern::lru::Cache<
Accessor::ThePrimaryKey,
Accessor::TheObject,
persistence::PrimaryKey::HashSharedPointer,
persistence::PrimaryKey::EqualSharedPointer> Cache;
static const int UpperLimitForMaxCacheSize = 4 * 1024;
static const int LowerLimitForMaxCacheSize = 16;
public:
static const int DefaultMaxCacheSize = 128;
Storage(const std::string& name, const int maxCacheSize);
~Storage();
unsigned int getHitCounter() const noexcept { return m_hitCounter; }
unsigned int getFaultCounter() const noexcept { return m_faultCounter; }
Accessor::TheObject load(Accessor::TheConnection& connection, Loader& loader)
throw(basis::RuntimeException, dbms::DatabaseException);
void save(Accessor::TheConnection& connection, Recorder& recorder)
throw(basis::RuntimeException, dbms::DatabaseException);
void erase(Accessor::TheConnection& connection, Eraser& eraser)
throw(basis::RuntimeException, dbms::DatabaseException);
void save(dbms::GuardConnection& connection, Recorder& recorder)
throw(basis::RuntimeException, dbms::DatabaseException);
void erase(dbms::GuardConnection& connection, Eraser& eraser)
throw(basis::RuntimeException, dbms::DatabaseException);
operator basis::StreamString() const noexcept { return asString(); }
basis::StreamString asString() const noexcept;
std::shared_ptr<xml::Node> asXML(std::shared_ptr<xml::Node>& parent) const throw(basis::RuntimeException);
Storage() = delete;
Storage(const Storage&) = delete;
private:
Cache m_cache;
mutable unsigned int m_hitCounter;
mutable unsigned int m_faultCounter;
};
} /* namespace persistence */
} /* namespace coffee */
#endif
| 32.697248 | 109 | 0.745791 | [
"object"
] |
5ede5c1f34521f0c4962b6829edc694bbf89ee75 | 10,729 | cpp | C++ | src/render/imgui_renderer.cpp | jaihysc/Jactorio | d40cb9249f3b04f08a21c9d112533e540c1a6c7b | [
"MIT"
] | 25 | 2020-04-02T15:54:23.000Z | 2022-03-20T21:03:28.000Z | src/render/imgui_renderer.cpp | jaihysc/Jactorio | d40cb9249f3b04f08a21c9d112533e540c1a6c7b | [
"MIT"
] | 3 | 2020-10-02T01:44:25.000Z | 2022-02-23T13:22:23.000Z | src/render/imgui_renderer.cpp | jaihysc/Jactorio | d40cb9249f3b04f08a21c9d112533e540c1a6c7b | [
"MIT"
] | 1 | 2021-03-27T20:38:04.000Z | 2021-03-27T20:38:04.000Z | // This file is subject to the terms and conditions defined in 'LICENSE' in the source code package
#include "render/imgui_renderer.h"
#include <cstdint> // intptr_t
#include "core/convert.h"
#include "render/opengl/error.h"
#include "render/renderer_common.h"
using namespace jactorio;
render::ImGuiRenderer::ImGuiRenderer(RendererCommon& common) : common_(&common) {}
void render::ImGuiRenderer::Init() {
// Setup back-end capabilities flags
ImGuiIO& io = ImGui::GetIO();
io.BackendRendererName = "Jactorio impl_opengl3";
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field,
// allowing for large meshes.
shader_.Init({{"data/core/shaders/im_vs.vert", GL_VERTEX_SHADER}, //
{"data/core/shaders/im_fs.frag", GL_FRAGMENT_SHADER}});
attribLocationTex_ = shader_.GetUniformLocation("u_texture");
attribLocationProjMtx_ = shader_.GetUniformLocation("u_proj_mtx");
attribLocationVtxPos_ = SafeCast<GLuint>(shader_.GetAttribLocation("Position"));
attribLocationVtxUV_ = SafeCast<GLuint>(shader_.GetAttribLocation("UV"));
attribLocationVtxColor_ = SafeCast<GLuint>(shader_.GetAttribLocation("Color"));
buffer.GlInit();
vertexArray_.Init();
// Setup attributes for ImDrawVert
vertexArray_.Bind();
buffer.GlBind();
DEBUG_OPENGL_CALL(glEnableVertexAttribArray(attribLocationVtxPos_));
DEBUG_OPENGL_CALL(glEnableVertexAttribArray(attribLocationVtxUV_));
DEBUG_OPENGL_CALL(glEnableVertexAttribArray(attribLocationVtxColor_));
DEBUG_OPENGL_CALL(glVertexAttribPointer(attribLocationVtxPos_, //
2,
GL_FLOAT,
GL_FALSE,
sizeof(ImDrawVert),
reinterpret_cast<GLvoid*>(IM_OFFSETOF(ImDrawVert, pos))));
DEBUG_OPENGL_CALL(glVertexAttribPointer(attribLocationVtxUV_, //
2,
GL_FLOAT,
GL_FALSE,
sizeof(ImDrawVert),
reinterpret_cast<GLvoid*>(IM_OFFSETOF(ImDrawVert, uv))));
DEBUG_OPENGL_CALL(glVertexAttribPointer(attribLocationVtxColor_,
4,
GL_UNSIGNED_BYTE,
GL_TRUE,
sizeof(ImDrawVert),
reinterpret_cast<GLvoid*>(IM_OFFSETOF(ImDrawVert, col))));
VertexArray::Unbind();
}
void render::ImGuiRenderer::Terminate() {
DestroyFontsTexture();
}
void render::ImGuiRenderer::Bind() const noexcept {
shader_.Bind();
vertexArray_.Bind();
buffer.GlBind();
}
void render::ImGuiRenderer::RenderWorld(const unsigned tex_id) const noexcept {
// On Linux, if a draw call is made with no indices, it covers up the world rendered underneath
// blanking the screen
if (buffer.IdxCount() > 0) {
DEBUG_OPENGL_CALL(
glUniformMatrix4fv(attribLocationProjMtx_, 1, GL_FALSE, &common_->mvpManager.GetMvpMatrix()[0][0]));
// Data for drawing is already prepared by mapping buffers
DEBUG_OPENGL_CALL(glBindTexture(GL_TEXTURE_2D, tex_id));
DEBUG_OPENGL_CALL(
glDrawElements(GL_TRIANGLES, //
SafeCast<GLsizei>(buffer.IdxCount()), // Count is indices in index array, NOT triangle number
sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
nullptr));
}
buffer.GlHandleBufferResize(); // May need to resize while gui is not open
}
void render::ImGuiRenderer::RenderGui(ImDrawData* draw_data) const {
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer
// coordinates)
const auto fb_width = LossyCast<int>(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
const auto fb_height = LossyCast<int>(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
if (fb_width <= 0 || fb_height <= 0)
return;
SetupRenderState(draw_data);
// Will project scissor/clipping rectangles into framebuffer space
const ImVec2 clip_off = draw_data->DisplayPos; // (0,0) unless using multi-viewports
const ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
// Render command lists
for (int n = 0; n < draw_data->CmdListsCount; n++) {
const ImDrawList* cmd_list = draw_data->CmdLists[n];
// Check for capacity
if (SafeCast<uint32_t>(cmd_list->VtxBuffer.Size) > buffer.VtxCapacity()) {
buffer.ReserveVtx(cmd_list->VtxBuffer.Size);
}
if (SafeCast<uint32_t>(cmd_list->IdxBuffer.Size) > buffer.IdxCapacity()) {
buffer.ReserveIdx(cmd_list->IdxBuffer.Size);
}
buffer.GlHandleBufferResize();
// Upload vertex/index buffers
buffer.GlWriteBegin();
for (auto& vtx : cmd_list->VtxBuffer) {
buffer.UncheckedPushVtx(vtx);
}
for (auto& idx : cmd_list->IdxBuffer) {
buffer.UncheckedPushIdx(idx);
}
buffer.GlWriteEnd();
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) {
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback != nullptr) {
// User callback, registered via ImDrawList::AddCallback()
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer
// to reset render state.)
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
SetupRenderState(draw_data);
else
pcmd->UserCallback(cmd_list, pcmd);
}
else {
// Project scissor/clipping rectangles into framebuffer space
ImVec4 clip_rect;
clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f) {
// Apply scissor/clipping rectangle
DEBUG_OPENGL_CALL(glScissor(LossyCast<int>(clip_rect.x),
LossyCast<int>(fb_height - clip_rect.w),
LossyCast<int>(clip_rect.z - clip_rect.x),
LossyCast<int>(clip_rect.w - clip_rect.y)));
// Bind texture, Draw
DEBUG_OPENGL_CALL(
glBindTexture(GL_TEXTURE_2D, SafeCast<GLuint>(reinterpret_cast<intptr_t>(pcmd->TextureId))));
DEBUG_OPENGL_CALL(glDrawElementsBaseVertex(
GL_TRIANGLES,
SafeCast<GLsizei>(pcmd->ElemCount),
sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
reinterpret_cast<void*>(SafeCast<intptr_t>(pcmd->IdxOffset * sizeof(ImDrawIdx))),
SafeCast<GLint>(pcmd->VtxOffset)));
}
}
}
}
// Scissor must be disabled PRIOR to gl clear or it does not clear the entire screen
DEBUG_OPENGL_CALL(glDisable(GL_SCISSOR_TEST));
}
bool render::ImGuiRenderer::InitFontsTexture() {
// Build texture atlas
ImGuiIO& io = ImGui::GetIO();
unsigned char* pixels;
int width, height;
io.Fonts->GetTexDataAsRGBA32(
&pixels, &width, &height); // Load as RGBA 32-bit (75% of the memory is wasted, but default font is so small)
// because it is more likely to be compatible with user's existing shaders. If your
// ImTextureId represent a higher-level concept than just a GL texture id, consider
// calling GetTexDataAsAlpha8() instead to save on GPU memory.
// Upload texture to graphics system
DEBUG_OPENGL_CALL(glGenTextures(1, &fontTexture_));
DEBUG_OPENGL_CALL(glBindTexture(GL_TEXTURE_2D, fontTexture_));
DEBUG_OPENGL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
DEBUG_OPENGL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
#ifdef GL_UNPACK_ROW_LENGTH
DEBUG_OPENGL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0));
#endif
DEBUG_OPENGL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels));
// Store our identifier
io.Fonts->TexID = reinterpret_cast<ImTextureID>(SafeCast<intptr_t>(fontTexture_));
return true;
}
void render::ImGuiRenderer::DestroyFontsTexture() {
if (fontTexture_ != 0u) {
ImGuiIO& io = ImGui::GetIO();
DEBUG_OPENGL_CALL(glDeleteTextures(1, &fontTexture_));
io.Fonts->TexID = 0;
fontTexture_ = 0;
}
}
void render::ImGuiRenderer::SetupRenderState(ImDrawData* draw_data) const {
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
DEBUG_OPENGL_CALL(glEnable(GL_SCISSOR_TEST));
// Setup viewport, orthographic projection matrix
// Our visible imgui space lies from draw_data->DisplayPos (top left) to
// draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
const auto l = draw_data->DisplayPos.x;
const auto r = draw_data->DisplayPos.x + draw_data->DisplaySize.x;
const auto t = draw_data->DisplayPos.y;
const auto b = draw_data->DisplayPos.y + draw_data->DisplaySize.y;
const float ortho_projection[4][4] = {
{2.0f / (r - l), 0.0f, 0.0f, 0.0f},
{0.0f, 2.0f / (t - b), 0.0f, 0.0f},
{0.0f, 0.0f, -1.0f, 0.0f},
{(r + l) / (l - r), (t + b) / (b - t), 0.0f, 1.0f},
};
DEBUG_OPENGL_CALL(glUniform1i(attribLocationTex_, 0));
DEBUG_OPENGL_CALL(glUniformMatrix4fv(attribLocationProjMtx_, 1, GL_FALSE, &ortho_projection[0][0]));
}
| 46.851528 | 120 | 0.606207 | [
"render"
] |
5eed276d4053bf98b416a358eeb92fd0cc1d2604 | 11,084 | cpp | C++ | ixbots/ixbots/IXCobraToSentryBot.cpp | spauldingmedical/IXWebSocket | 3e09bb16cf0cad1fffaab8115f9bae54a137b485 | [
"BSD-3-Clause"
] | null | null | null | ixbots/ixbots/IXCobraToSentryBot.cpp | spauldingmedical/IXWebSocket | 3e09bb16cf0cad1fffaab8115f9bae54a137b485 | [
"BSD-3-Clause"
] | null | null | null | ixbots/ixbots/IXCobraToSentryBot.cpp | spauldingmedical/IXWebSocket | 3e09bb16cf0cad1fffaab8115f9bae54a137b485 | [
"BSD-3-Clause"
] | null | null | null | /*
* IXCobraToSentryBot.cpp
* Author: Benjamin Sergeant
* Copyright (c) 2019 Machine Zone, Inc. All rights reserved.
*/
#include "IXCobraToSentryBot.h"
#include "IXQueueManager.h"
#include <chrono>
#include <ixcobra/IXCobraConnection.h>
#include <spdlog/spdlog.h>
#include <sstream>
#include <thread>
#include <vector>
namespace ix
{
int cobra_to_sentry_bot(const CobraConfig& config,
const std::string& channel,
const std::string& filter,
const std::string& position,
SentryClient& sentryClient,
bool verbose,
bool strict,
size_t maxQueueSize,
bool enableHeartbeat,
int runtime)
{
ix::CobraConnection conn;
conn.configure(config);
conn.connect();
Json::FastWriter jsonWriter;
std::atomic<uint64_t> sentCount(0);
std::atomic<uint64_t> receivedCount(0);
std::atomic<bool> errorSending(false);
std::atomic<bool> stop(false);
std::atomic<bool> throttled(false);
std::atomic<bool> fatalCobraError(false);
QueueManager queueManager(maxQueueSize);
auto timer = [&sentCount, &receivedCount, &stop] {
while (!stop)
{
spdlog::info("messages received {} sent {}", receivedCount, sentCount);
auto duration = std::chrono::seconds(1);
std::this_thread::sleep_for(duration);
}
spdlog::info("timer thread done");
};
std::thread t1(timer);
auto heartbeat = [&sentCount, &receivedCount, &stop, &enableHeartbeat] {
std::string state("na");
if (!enableHeartbeat) return;
while (!stop)
{
std::stringstream ss;
ss << "messages received " << receivedCount;
ss << "messages sent " << sentCount;
std::string currentState = ss.str();
if (currentState == state)
{
spdlog::error("no messages received or sent for 1 minute, exiting");
exit(1);
}
state = currentState;
auto duration = std::chrono::minutes(1);
std::this_thread::sleep_for(duration);
}
spdlog::info("heartbeat thread done");
};
std::thread t2(heartbeat);
auto sentrySender =
[&queueManager, verbose, &errorSending, &sentCount, &stop, &throttled, &sentryClient] {
while (true)
{
Json::Value msg = queueManager.pop();
if (stop) break;
if (msg.isNull()) continue;
auto ret = sentryClient.send(msg, verbose);
HttpResponsePtr response = ret.first;
if (!response)
{
spdlog::warn("Null HTTP Response");
continue;
}
if (verbose)
{
for (auto it : response->headers)
{
spdlog::info("{}: {}", it.first, it.second);
}
spdlog::info("Upload size: {}", response->uploadSize);
spdlog::info("Download size: {}", response->downloadSize);
spdlog::info("Status: {}", response->statusCode);
if (response->errorCode != HttpErrorCode::Ok)
{
spdlog::info("error message: {}", response->errorMsg);
}
if (response->headers["Content-Type"] != "application/octet-stream")
{
spdlog::info("payload: {}", response->payload);
}
}
if (response->statusCode != 200)
{
spdlog::error("Error sending data to sentry: {}", response->statusCode);
spdlog::error("Body: {}", ret.second);
spdlog::error("Response: {}", response->payload);
errorSending = true;
// Error 429 Too Many Requests
if (response->statusCode == 429)
{
auto retryAfter = response->headers["Retry-After"];
std::stringstream ss;
ss << retryAfter;
int seconds;
ss >> seconds;
if (!ss.eof() || ss.fail())
{
seconds = 30;
spdlog::warn("Error parsing Retry-After header. "
"Using {} for the sleep duration",
seconds);
}
spdlog::warn("Error 429 - Too Many Requests. ws will sleep "
"and retry after {} seconds",
retryAfter);
throttled = true;
auto duration = std::chrono::seconds(seconds);
std::this_thread::sleep_for(duration);
throttled = false;
}
}
else
{
++sentCount;
}
if (stop) break;
}
spdlog::info("sentrySender thread done");
};
std::thread t3(sentrySender);
conn.setEventCallback([&conn,
&channel,
&filter,
&position,
&jsonWriter,
verbose,
&throttled,
&receivedCount,
&fatalCobraError,
&queueManager](ix::CobraConnectionEventType eventType,
const std::string& errMsg,
const ix::WebSocketHttpHeaders& headers,
const std::string& subscriptionId,
CobraConnection::MsgId msgId) {
if (eventType == ix::CobraConnection_EventType_Open)
{
spdlog::info("Subscriber connected");
for (auto it : headers)
{
spdlog::info("{}: {}", it.first, it.second);
}
}
if (eventType == ix::CobraConnection_EventType_Closed)
{
spdlog::info("Subscriber closed");
}
else if (eventType == ix::CobraConnection_EventType_Authenticated)
{
spdlog::info("Subscriber authenticated");
conn.subscribe(channel,
filter,
position,
[&jsonWriter, verbose, &throttled, &receivedCount, &queueManager](
const Json::Value& msg, const std::string& position) {
if (verbose)
{
spdlog::info("Subscriber received message {} -> {}", position, jsonWriter.write(msg));
}
// If we cannot send to sentry fast enough, drop the message
if (throttled)
{
return;
}
++receivedCount;
queueManager.add(msg);
});
}
else if (eventType == ix::CobraConnection_EventType_Subscribed)
{
spdlog::info("Subscriber: subscribed to channel {}", subscriptionId);
}
else if (eventType == ix::CobraConnection_EventType_UnSubscribed)
{
spdlog::info("Subscriber: unsubscribed from channel {}", subscriptionId);
}
else if (eventType == ix::CobraConnection_EventType_Error)
{
spdlog::error("Subscriber: error {}", errMsg);
}
else if (eventType == ix::CobraConnection_EventType_Published)
{
spdlog::error("Published message hacked: {}", msgId);
}
else if (eventType == ix::CobraConnection_EventType_Pong)
{
spdlog::info("Received websocket pong");
}
else if (eventType == ix::CobraConnection_EventType_Handshake_Error)
{
spdlog::error("Subscriber: Handshake error: {}", errMsg);
fatalCobraError = true;
}
else if (eventType == ix::CobraConnection_EventType_Authentication_Error)
{
spdlog::error("Subscriber: Authentication error: {}", errMsg);
fatalCobraError = true;
}
else if (eventType == ix::CobraConnection_EventType_Subscription_Error)
{
spdlog::error("Subscriber: Subscription error: {}", errMsg);
fatalCobraError = true;
}
});
// Run forever
if (runtime == -1)
{
while (true)
{
auto duration = std::chrono::seconds(1);
std::this_thread::sleep_for(duration);
if (strict && errorSending) break;
if (fatalCobraError) break;
}
}
// Run for a duration, used by unittesting now
else
{
for (int i = 0 ; i < runtime; ++i)
{
auto duration = std::chrono::seconds(1);
std::this_thread::sleep_for(duration);
if (strict && errorSending) break;
if (fatalCobraError) break;
}
}
//
// Cleanup.
// join all the bg threads and stop them.
//
conn.disconnect();
stop = true;
// progress thread
t1.join();
// heartbeat thread
if (t2.joinable()) t2.join();
// sentry sender thread
t3.join();
return ((strict && errorSending) || fatalCobraError) ? -1 : (int) sentCount;
}
} // namespace ix
| 36.222222 | 125 | 0.42214 | [
"vector"
] |
5eefae61841fb0762bbd5f746c96fee7dcd4d7b9 | 1,537 | cpp | C++ | solutions/LeetCode/C++/846.cpp | timxor/leetcode-journal | 5f1cb6bcc44a5bc33d88fb5cdb4126dfc6f4232a | [
"MIT"
] | 854 | 2018-11-09T08:06:16.000Z | 2022-03-31T06:05:53.000Z | solutions/LeetCode/C++/846.cpp | timxor/leetcode-journal | 5f1cb6bcc44a5bc33d88fb5cdb4126dfc6f4232a | [
"MIT"
] | 29 | 2019-06-02T05:02:25.000Z | 2021-11-15T04:09:37.000Z | solutions/LeetCode/C++/846.cpp | timxor/leetcode-journal | 5f1cb6bcc44a5bc33d88fb5cdb4126dfc6f4232a | [
"MIT"
] | 347 | 2018-12-23T01:57:37.000Z | 2022-03-12T14:51:21.000Z | __________________________________________________________________________________________________
sample 40 ms submission
class Solution {
public:
bool isNStraightHand(vector<int>& hand, int W) {
if(W==1) return true;
if(hand.size()%W) return false;
vector<int> cs(W,0);
for(auto &&i:hand) {
cs[i%W]++;
}
int M=hand.size()/W;
for(auto &&i:cs) {
if(i!=M) return false;
}
return true;
}
};
__________________________________________________________________________________________________
sample 10408 kb submission
class Solution {
public:
bool isNStraightHand(vector<int>& hand, int W) {
std::sort(hand.begin(), hand.end());
while(hand.size() !=0)
{
int prev=-1;
for(int i=0; i<W; i++)
{
if(i==0)
{
prev = hand.back();
hand.pop_back();
continue;
}
auto it = std::find(hand.begin(), hand.end(), prev-1);
if(it == hand.end())
{
return false;
}
else
{
hand.erase(it);
prev = prev-1;
}
}
}
return true;
}
};
__________________________________________________________________________________________________
| 26.964912 | 98 | 0.482759 | [
"vector"
] |
d672b6e06b43a0d20c4589a08b5234d1cddff2f1 | 2,611 | hpp | C++ | include/stackcpp/objects/tag.hpp | Rakete1111/stackcpp | ac47632332a5a2ecf01043d00c5568147a59eff8 | [
"BSL-1.0"
] | 4 | 2017-07-26T17:00:34.000Z | 2021-08-04T06:41:32.000Z | include/stackcpp/objects/tag.hpp | Rakete1111/stackcpp | ac47632332a5a2ecf01043d00c5568147a59eff8 | [
"BSL-1.0"
] | 1 | 2017-08-09T15:57:54.000Z | 2017-12-08T17:33:49.000Z | include/stackcpp/objects/tag.hpp | Rakete1111/stackcpp | ac47632332a5a2ecf01043d00c5568147a59eff8 | [
"BSL-1.0"
] | 1 | 2019-03-30T19:32:29.000Z | 2019-03-30T19:32:29.000Z | // Boost Software License - Version 1.0 - August 17th, 2003
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#ifndef STACKCPP_TAG_H
#define STACKCPP_TAG_H
#include "stackcpp/misc/types.hpp"
#include <rapidjson/document.h>
#include <string>
#include <vector>
namespace stackcpp {
inline namespace objects { struct tag; }
tag parse_tag(const rapidjson::Value&);
inline namespace objects {
struct tag final {
integer_t count() const noexcept { return count_; }
bool has_synonyms() const noexcept { return has_synonyms_; }
bool moderator_only() const noexcept { return moderator_only_; }
bool required() const noexcept { return required_; }
date_t last_active() const noexcept { return last_active_; }
std::string name() const noexcept { return name_; }
std::vector<std::string> synonyms() const noexcept { return synonyms_; }
unique_id user_id() const noexcept { return user_id_; }
private:
friend tag stackcpp::parse_tag(const rapidjson::Value&);
// See [dcl.fct.def.default]/4 and [dcl.init.aggr]/1 for rational.
tag() noexcept {}
integer_t count_{};
bool has_synonyms_{};
bool moderator_only_{};
bool required_{};
date_t last_active_;
std::string name_;
std::vector<std::string> synonyms_;
unique_id user_id_;
};
}
}
#endif
| 34.813333 | 78 | 0.738797 | [
"object",
"vector"
] |
d67a872afcccefe66ccbe008fb9d9720ff9854e8 | 782 | cpp | C++ | leetcode/archives_am/973.k-closest-points-to-origin.cpp | saurabhraj042/dsaPrep | 0973a03bc565a2850003c7e48d99b97ff83b1d01 | [
"MIT"
] | 23 | 2021-10-30T04:11:52.000Z | 2021-11-27T09:16:18.000Z | leetcode/archives_am/973.k-closest-points-to-origin.cpp | saurabhraj042/dsaPrep | 0973a03bc565a2850003c7e48d99b97ff83b1d01 | [
"MIT"
] | null | null | null | leetcode/archives_am/973.k-closest-points-to-origin.cpp | saurabhraj042/dsaPrep | 0973a03bc565a2850003c7e48d99b97ff83b1d01 | [
"MIT"
] | 4 | 2021-10-30T03:26:05.000Z | 2021-11-14T12:15:04.000Z | // https://leetcode.com/problems/k-closest-points-to-origin/
class Solution {
public:
vector<vector<int>> kClosest(vector<vector<int>>& points, int k) {
vector<vector<int>> ans;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
for(int i = 0; i < points.size(); i++){
auto pt = points[i];
long long int x_sq = pt[0] * pt[0];
long long int y_sq = pt[1] * pt[1];
int dis_og = (x_sq + y_sq);
pq.push({dis_og, i});
}
while(k-- && !pq.empty()){
auto pt = pq.top();
pq.pop();
ans.push_back(points[pt.second]);
}
return ans;
}
}; | 28.962963 | 91 | 0.459079 | [
"vector"
] |
d684214a45a50db43109fbc0fc79331a6c8df0b1 | 10,321 | cpp | C++ | 3rdParty/boost/1.71.0/libs/geometry/test/cs_undefined/setops.cpp | rajeev02101987/arangodb | 817e6c04cb82777d266f3b444494140676da98e2 | [
"Apache-2.0"
] | 12,278 | 2015-01-29T17:11:33.000Z | 2022-03-31T21:12:00.000Z | 3rdParty/boost/1.71.0/libs/geometry/test/cs_undefined/setops.cpp | rajeev02101987/arangodb | 817e6c04cb82777d266f3b444494140676da98e2 | [
"Apache-2.0"
] | 9,469 | 2015-01-30T05:33:07.000Z | 2022-03-31T16:17:21.000Z | 3rdParty/boost/1.71.0/libs/geometry/test/cs_undefined/setops.cpp | rajeev02101987/arangodb | 817e6c04cb82777d266f3b444494140676da98e2 | [
"Apache-2.0"
] | 892 | 2015-01-29T16:26:19.000Z | 2022-03-20T07:44:30.000Z | // Boost.Geometry
// Copyright (c) 2019, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#include "common.hpp"
#include <boost/geometry/algorithms/difference.hpp>
#include <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/algorithms/sym_difference.hpp>
#include <boost/geometry/algorithms/union.hpp>
template <typename G1, typename G2, typename G3, typename S>
inline void set_idsu(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::intersection(g1, g2, g3, s);
bg::difference(g1, g2, g3, s);
bg::sym_difference(g1, g2, g3, s);
bg::union_(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3, typename S>
inline void set_ids(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::intersection(g1, g2, g3, s);
bg::difference(g1, g2, g3, s);
bg::sym_difference(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3, typename S>
inline void set_id(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::intersection(g1, g2, g3, s);
bg::difference(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3, typename S>
inline void set_i(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::intersection(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3, typename S>
inline void set_d(G1 const& g1, G2 const& g2, G3 & g3, S const& s)
{
bg::difference(g1, g2, g3, s);
}
template <typename G1, typename G2, typename G3>
inline void set_idsu_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_idsu(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_idsu(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_idsu_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_idsu(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_idsu(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_idsu(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_idsu_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_idsu(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_idsu(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_idsu(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
template <typename G1, typename G2, typename G3>
inline void set_ids_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_ids(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_ids(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_ids_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_ids(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_ids(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_ids(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_ids_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_ids(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_ids(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_ids(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
template <typename G1, typename G2, typename G3>
inline void set_id_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_id(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_id(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_id_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_id(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_id(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_id(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_id_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_id(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_id(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_id(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
template <typename G1, typename G2, typename G3>
inline void set_i_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_i(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_i(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_i_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_i(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_i(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_i(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_i_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_i(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_i(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_i(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
template <typename G1, typename G2, typename G3>
inline void set_d_pp(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_d(g1, g2, g3, bg::strategy::within::cartesian_point_point());
::set_d(g1, g2, g3, bg::strategy::within::spherical_point_point());
}
template <typename G1, typename G2, typename G3>
inline void set_d_ps(G1 const& g1, G2 const& g2, G3 & g3)
{
typedef typename bg::point_type<G1>::type point_type;
::set_d(g1, g2, g3, bg::strategy::within::cartesian_winding<point_type>());
::set_d(g1, g2, g3, bg::strategy::within::spherical_winding<point_type>());
::set_d(g1, g2, g3, bg::strategy::within::geographic_winding<point_type>());
}
template <typename G1, typename G2, typename G3>
inline void set_d_ss(G1 const& g1, G2 const& g2, G3 & g3)
{
::set_d(g1, g2, g3, bg::strategy::intersection::cartesian_segments<>());
::set_d(g1, g2, g3, bg::strategy::intersection::spherical_segments<>());
::set_d(g1, g2, g3, bg::strategy::intersection::geographic_segments<>());
}
int test_main(int, char*[])
{
geom g;
// P/P->P
::set_idsu_pp(g.pt, g.pt, g.mpt);
::set_idsu_pp(g.pt, g.mpt, g.mpt);
::set_idsu_pp(g.mpt, g.mpt, g.mpt);
// P/L->P
::set_id_ps(g.pt, g.s, g.mpt);
::set_id_ps(g.pt, g.ls, g.mpt);
::set_id_ps(g.pt, g.mls, g.mpt);
::set_id_ps(g.mpt, g.s, g.mpt);
::set_id_ps(g.mpt, g.ls, g.mpt);
::set_id_ps(g.mpt, g.mls, g.mpt);
// P/A->P
// no intersection nor difference
//::set_id_ps(g.pt, g.r, g.mpt);
//::set_id_ps(g.pt, g.po, g.mpt);
//::set_id_ps(g.pt, g.mpo, g.mpt);
//::set_id_ps(g.mpt, g.r, g.mpt);
//::set_id_ps(g.mpt, g.po, g.mpt);
//::set_id_ps(g.mpt, g.mpo, g.mpt);
// L/L->P
::set_ids_ss(g.s, g.s, g.mpt);
//::set_i_ss(g.s, g.ls, g.mpt); // no intersection nor difference
//::set_i_ss(g.s, g.mls, g.mpt); // no intersection nor difference
//::set_i_ss(g.ls, g.s, g.mpt); // no intersection nor difference
::set_ids_ss(g.ls, g.ls, g.mpt);
::set_i_ss(g.ls, g.mls, g.mpt); // no difference nor sym_difference
//::set_i_ss(g.mls, g.s, g.mpt); // no intersection nor difference
::set_i_ss(g.mls, g.ls, g.mpt); // no difference nor sym_difference
::set_ids_ss(g.mls, g.mls, g.mpt);
// L/L->L
//::set_ids_ss(g.s, g.s, g.mls); // union not implemented, missing specialization
//::set_idsu_ss(g.s, g.ls, g.mls); // missing specialization
//::set_idsu_ss(g.s, g.mls, g.mls); // missing specialization
//::set_idsu_ss(g.ls, g.s, g.mls); // missing specialization
::set_idsu_ss(g.ls, g.ls, g.mls);
::set_idsu_ss(g.ls, g.mls, g.mls);
//::set_idsu_ss(g.mls, g.s, g.mls); // missing specialization
::set_idsu_ss(g.mls, g.ls, g.mls);
::set_idsu_ss(g.mls, g.mls, g.mls);
// S/B->L ?
// L/B->L ?
// L/A->P
//::set_ids_ss(g.s, g.r, g.mpt); // no intersection
//::set_ids_ss(g.s, g.po, g.mpt); // no intersection
//::set_ids_ss(g.s, g.mpo, g.mpt); // no intersection
::set_ids_ss(g.ls, g.r, g.mpt);
::set_ids_ss(g.ls, g.po, g.mpt);
::set_ids_ss(g.ls, g.mpo, g.mpt);
::set_ids_ss(g.mls, g.r, g.mpt);
::set_ids_ss(g.mls, g.po, g.mpt);
::set_ids_ss(g.mls, g.mpo, g.mpt);
// L/A->L
//::set_id_ss(g.s, g.r, g.mls); // no intersection
//::set_id_ss(g.s, g.po, g.mls); // no intersection
//::set_id_ss(g.s, g.mpo, g.mls); // no intersection
::set_id_ss(g.ls, g.r, g.mls);
::set_id_ss(g.ls, g.po, g.mls);
::set_id_ss(g.ls, g.mpo, g.mls);
::set_id_ss(g.mls, g.r, g.mls);
::set_id_ss(g.mls, g.po, g.mls);
::set_id_ss(g.mls, g.mpo, g.mls);
// A/A->P
::set_i_ss(g.r, g.r, g.mpt);
::set_i_ss(g.r, g.po, g.mpt);
::set_i_ss(g.r, g.mpo, g.mpt);
::set_i_ss(g.po, g.r, g.mpt);
::set_i_ss(g.po, g.po, g.mpt);
::set_i_ss(g.po, g.mpo, g.mpt);
::set_i_ss(g.mpo, g.r, g.mpt);
::set_i_ss(g.mpo, g.po, g.mpt);
::set_i_ss(g.mpo, g.mpo, g.mpt);
// A/A->L
::set_i_ss(g.r, g.r, g.mls);
::set_i_ss(g.r, g.po, g.mls);
::set_i_ss(g.r, g.mpo, g.mls);
::set_i_ss(g.po, g.r, g.mls);
::set_i_ss(g.po, g.po, g.mls);
::set_i_ss(g.po, g.mpo, g.mls);
::set_i_ss(g.mpo, g.r, g.mls);
::set_i_ss(g.mpo, g.po, g.mls);
::set_i_ss(g.mpo, g.mpo, g.mls);
// A/A->A
::set_idsu_ss(g.r, g.r, g.mpo);
::set_idsu_ss(g.r, g.po, g.mpo);
::set_idsu_ss(g.r, g.mpo, g.mpo);
::set_idsu_ss(g.po, g.r, g.mpo);
::set_idsu_ss(g.po, g.po, g.mpo);
::set_idsu_ss(g.po, g.mpo, g.mpo);
::set_idsu_ss(g.mpo, g.r, g.mpo);
::set_idsu_ss(g.mpo, g.po, g.mpo);
::set_idsu_ss(g.mpo, g.mpo, g.mpo);
return 0;
}
| 36.599291 | 85 | 0.635404 | [
"geometry"
] |
d68c137598fb392ec120382aa967f936c91ca060 | 6,461 | cpp | C++ | source/ai/rl/TD.cpp | SummitChen/opennero | 1bb1ba083cf2576e09bb7cfeac013d6940a47afe | [
"BSD-3-Clause"
] | 215 | 2015-08-26T19:41:28.000Z | 2022-01-19T13:23:17.000Z | source/ai/rl/TD.cpp | SummitChen/opennero | 1bb1ba083cf2576e09bb7cfeac013d6940a47afe | [
"BSD-3-Clause"
] | 6 | 2015-11-03T19:40:24.000Z | 2019-10-15T11:19:32.000Z | source/ai/rl/TD.cpp | SummitChen/opennero | 1bb1ba083cf2576e09bb7cfeac013d6940a47afe | [
"BSD-3-Clause"
] | 56 | 2015-08-26T19:42:05.000Z | 2022-02-26T16:45:41.000Z | #include <cfloat>
#include <vector>
#include <algorithm>
#include <iostream>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/export.hpp>
#include "core/Common.h"
#include "math/Random.h"
#include "Approximator.h"
#include "ai/AI.h"
#include "TD.h"
namespace OpenNero
{
/// called right before the agent is born
bool TDBrain::initialize(const AgentInitInfo& init)
{
mInfo = init;
this->fitness = mInfo.reward.getInstance();
int bins = action_bins;
if (num_tiles > 0)
{
AssertMsg(action_bins == 0, "action_bins must be 0 for num_tiles > 0");
AssertMsg(state_bins == 0, "state_bins must be 0 for num_tiles > 0");
mApproximator.reset(
new TilesApproximator(mInfo, num_tiles, num_weights));
bins = 7; // XXX force bins > 0 to discretize action_list below
}
else
{
AssertMsg(action_bins > 0, "action_bins > 0 for num_tiles == 0");
AssertMsg(state_bins > 0, "action_bins > 0 for num_tiles == 0");
mApproximator.reset(
new TableApproximator(mInfo, action_bins, state_bins));
}
// Similar to FeatureVectorInfo::enumerate (from AI.cpp).
//
// We want to enumerate all possible actions in a discrete way, so that
// we can store them in a policy table somehow. So, for each action
// dimension, if it's discrete we just enumerate the integral values for
// that dimension, and if it's continuous, we split it into "bins"
// different values.
//
// An example: Suppose some action dimension is continuous and spans the
// closed interval [-1, 1]. Additionally suppose we want to split
// continuous action dimensions into 5 bins. We'd like to preserve the
// actual range of action values, but only store the 5 discrete values
// that equally partition this space, i.e., {-1, -.5, 0, .5, 1}. So we
// traverse the action dimension from -1 to 1 (inclusive), adding
// (hi - lo) / (bins - 1) == (1 - -1) / 4 == 0.5 each time.
const FeatureVectorInfo& info = init.actions;
action_list.clear();
action_list.push_back(info.getInstance());
for (size_t i = 0; i < info.size(); ++i)
{
const double lo = info.getMin(i), hi = info.getMax(i);
const double inc = info.isDiscrete(i) ? 1.0f : (hi - lo) / (bins - 1);
std::vector< Actions > new_action_list;
std::vector< Actions >::const_iterator iter;
for (iter = action_list.begin(); iter != action_list.end(); ++iter)
{
for (double a = lo; a <= hi; a += inc)
{
FeatureVector v = *iter;
v[i] = a;
new_action_list.push_back(v);
}
}
action_list = new_action_list;
}
return true;
}
/// called for agent to take its first step
Actions TDBrain::start(const TimeType& time, const Observations& new_state)
{
epsilon_greedy(new_state);
action = new_action;
state = new_state;
return action;
}
/// act based on time, sensor arrays, and last reward
Actions TDBrain::act(const TimeType& time, const Observations& new_state, const Reward& reward)
{
AssertMsg(reward.size() == 1, "multi-objective rewards not supported");
// select new action and estimate its value
double new_Q = epsilon_greedy(new_state);
double old_Q = mApproximator->predict(state, action);
// Q(s_t, a_t) <- Q(s_t, a_t) + \alpha [r_{t+1} + \gamma Q(s_{t+1}, a_{t+1}) - Q(s_t, a_t)
mApproximator->update(state, action, old_Q + mAlpha * (reward[0] + mGamma * new_Q - old_Q));
action = new_action;
state = new_state;
return action;
}
/// called to tell agent about its last reward
bool TDBrain::end(const TimeType& time, const Reward& reward)
{
AssertMsg(reward.size() == 1, "multi-objective rewards not supported");
// Q(s_t, a_t) <- Q(s_t, a_t) + \alpha [r_{t+1} - Q(s_t, a_t)]
// LOG_F_DEBUG("ai", "TD FINAL UPDATE s1: " << state << ", a1: " << action << ", r: " << reward);
double old_Q = mApproximator->predict(state, action);
mApproximator->update(state, action, old_Q + mAlpha * (reward[0] - old_Q));
return true;
}
/// select action according to the epsilon-greedy policy
double TDBrain::epsilon_greedy(const Observations& new_state)
{
// with chance epsilon, select random action
if (RANDOM.randF() < mEpsilon)
{
new_action = mInfo.actions.getRandom();
double value = predict(new_state);
return value;
}
// enumerate all possible actions (actions must be discrete!)
new_action = mInfo.actions.getInstance();
// select the greedy action in random order
std::random_shuffle(action_list.begin(), action_list.end());
double max_value = -DBL_MAX;
std::vector< Actions >::const_iterator iter;
for (iter = action_list.begin(); iter != action_list.end(); ++iter)
{
double value = mApproximator->predict(new_state, *iter);
if (value > max_value)
{
max_value = value;
new_action = *iter;
}
}
// Assuming if you choose max value, you will want to update with that as your prediction
return max_value;
}
/// called right before the agent dies
bool TDBrain::destroy()
{
return true;
}
/// serialize this brain to a text string
std::string TDBrain::to_string() const
{
std::ostringstream oss;
boost::archive::text_oarchive oa(oss);
oa << *this;
return oss.str();
}
/// deserialize this brain from a text string
void TDBrain::from_string(const std::string& s)
{
try {
std::istringstream iss(s);
boost::archive::text_iarchive ia(iss);
ia >> *this;
} catch (boost::archive::archive_exception const& e) {
LOG_F_ERROR("ai.rl", "unable to load agent because of error, " << e.what());
}
}
}
BOOST_CLASS_EXPORT(OpenNero::TDBrain)
| 36.92 | 105 | 0.583811 | [
"vector"
] |
d68d8f5da712dd5a31e7ab71df0b7f471ba1a759 | 1,069 | cpp | C++ | src/FalconEngine/Graphics/Renderer/Scene/Light.cpp | LiuYiZhou95/FalconEngine | b798f20e9dbd01334a4e4cdbbd9a5bec74966418 | [
"MIT"
] | 6 | 2017-04-17T12:34:57.000Z | 2019-10-19T23:29:59.000Z | src/FalconEngine/Graphics/Renderer/Scene/Light.cpp | Lywx/FalconEngine | c4d1fed789218d1994908b8dbbcd6c01961f9ef2 | [
"MIT"
] | null | null | null | src/FalconEngine/Graphics/Renderer/Scene/Light.cpp | Lywx/FalconEngine | c4d1fed789218d1994908b8dbbcd6c01961f9ef2 | [
"MIT"
] | 2 | 2019-12-30T08:28:04.000Z | 2020-08-05T09:58:53.000Z | #include <FalconEngine/Graphics/Renderer/Scene/Light.h>
namespace FalconEngine
{
FALCON_ENGINE_RTTI_IMPLEMENT(Light, Object);
/************************************************************************/
/* Constructors and Destructor */
/************************************************************************/
Light::Light(LightType lightType) :
mAmbient(ColorPalette::Transparent),
mDiffuse(ColorPalette::Transparent),
mSpecular(ColorPalette::Transparent),
mDirection(Vector3f::Zero),
mConstant(1),
mLinear(0),
mQuadratic(0),
mPosition(Vector3f::Zero),
mInnerAngle(0),
mOuterAngle(0),
mCosAngle(0),
mSinAngle(0),
mExponent(0),
mLightType(lightType)
{
}
Light::~Light()
{
}
/************************************************************************/
/* Constructors and Destructor */
/************************************************************************/
LightType
Light::GetLightType() const
{
return mLightType;
}
}
| 24.860465 | 74 | 0.449018 | [
"object"
] |
d68e7c91e3a039fc13573c6a28933ae719221026 | 43,071 | cxx | C++ | osprey/kgccfe/tree_symtab.cxx | sharugupta/OpenUH | daddd76858a53035f5d713f648d13373c22506e8 | [
"BSD-2-Clause"
] | null | null | null | osprey/kgccfe/tree_symtab.cxx | sharugupta/OpenUH | daddd76858a53035f5d713f648d13373c22506e8 | [
"BSD-2-Clause"
] | null | null | null | osprey/kgccfe/tree_symtab.cxx | sharugupta/OpenUH | daddd76858a53035f5d713f648d13373c22506e8 | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (C) 2006. QLogic Corporation. All Rights Reserved.
*/
/*
Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved.
File modified June 20, 2003 by PathScale, Inc. to update Open64 C/C++
front-ends to GNU 3.2.2 release.
*/
/*
Copyright (C) 2002 Tensilica, Inc. All Rights Reserved.
Revised to support Tensilica processors and to improve overall performance
*/
/*
Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it would be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Further, this software is distributed without any warranty that it is
free of the rightful claim of any third person regarding infringement
or the like. Any license provided herein, whether implied or
otherwise, applies only to this software file. Patent licenses, if
any, provided herein do not apply to combinations of this program with
other software, or any other product whatsoever.
You should have received a copy of the GNU General Public License along
with this program; if not, write the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston MA 02111-1307, USA.
Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
Mountain View, CA 94043, or:
http://www.sgi.com
For further information regarding this notice, see:
http://oss.sgi.com/projects/GenInfo/NoticeExplan
*/
/* translate gnu decl trees to symtab references */
#if defined(BUILD_OS_DARWIN)
#include <limits.h>
#else /* defined(BUILD_OS_DARWIN) */
#include <values.h>
#endif /* defined(BUILD_OS_DARWIN) */
#include "defs.h"
#include "errors.h"
#include "gnu_config.h"
#ifdef KEY
// To get HW_WIDE_INT ifor flags.h */
#include "gnu/hwint.h"
#endif /* KEY */
#include "gnu/flags.h"
extern "C" {
#include "gnu/system.h"
#include "gnu/tree.h"
#include "gnu/toplev.h"
}
#if defined(TARG_IA32) || defined(TARG_X8664)
// the definition in gnu/config/i386/i386.h causes problem
// with the enumeration in common/com/ia32/config_targ.h
#undef TARGET_PENTIUM
#endif /* TARG_IA32 */
#if defined(TARG_PPC32)
// the definition in gnu/config/ppc32/rs6000.h causes problem
// with the enumeration in common/com/ppc32/config_targ.h
#undef TARGET_POWERPC
#endif /* TARG_PPC32 */
#ifdef KEY
#ifdef TARG_MIPS
// ABI_N32 is defined in config/MIPS/mips.h and conflicts with
// common/com/MIPS/config_targ.h
#undef ABI_N32
#endif /* TARG_MIPS */
#endif /* KEY */
#include "symtab.h"
#include "strtab.h"
#include "tree_symtab.h"
#include "wn.h"
#include "wfe_expr.h"
#include "wfe_misc.h"
#include "wfe_dst.h"
#include "ir_reader.h"
#include <cmplrs/rcodes.h>
#ifdef KEY
#include "erfe.h"
#endif
#include "config_asm.h"
extern FILE *tree_dump_file; // For debugging only
extern INT pstatic_as_global;
static char*
Get_Name (tree node)
{
static UINT anon_num = 0;
static char buf[256];
if (node != NULL) {
if (TREE_CODE (node) == IDENTIFIER_NODE)
return IDENTIFIER_POINTER (node);
else if (TREE_CODE (node) == TYPE_DECL)
// If type has a typedef-name, the TYPE_NAME is a TYPE_DECL.
return IDENTIFIER_POINTER (DECL_NAME (node));
else if (DECL_NAME (node)) {
// e.g. var_decl or function_decl
return IDENTIFIER_POINTER (DECL_NAME (node));
}
}
// null node or null decl_name,
// e.g. from compiler temporaries
++anon_num;
sprintf(buf, "%sanonymous%s%d", Label_Name_Separator, Label_Name_Separator, anon_num);
return buf;
}
#ifdef TARG_SL
/* this function only return signed mtype and the function MTYPE_complement will do
* conversion from signed type to unsigned type if current type is unsigned type */
TYPE_ID
Get_Mtype_For_Integer_Type(tree type_tree, INT64 tsize)
{
TYPE_ID mtype;
switch(tsize) {
case 1:
mtype = MTYPE_I1;
break;
case 2:
mtype = MTYPE_I2;
break;
case 4:
mtype = MTYPE_I4;
break;
case 8:
DevWarn("8 byte types being used");
mtype = MTYPE_I8;
break;
}
return mtype;
}
#endif
#ifdef KEY
extern void WFE_add_pragma_to_enclosing_regions (WN_PRAGMA_ID, ST *);
// Called from the parser to find out if a local variable declared within
// a structured block in OMP context should be shared among threads
BOOL
Is_shared_mp_var (tree decl_node)
{
ST * st = DECL_ST (decl_node);
if (st && ST_sclass (st) == SCLASS_AUTO)
return TRUE;
return FALSE;
}
#endif // KEY
// idx is non-zero only for RECORD and UNION, when there is forward declaration
extern TY_IDX
Create_TY_For_Tree (tree type_tree, TY_IDX idx)
{
if (TREE_CODE(type_tree) == ERROR_MARK)
exit (RC_USER_ERROR);
TY_IDX orig_idx = idx;
if(TREE_CODE_CLASS(TREE_CODE(type_tree)) != 't') {
DevWarn("Bad tree class passed to Create_TY_For_Tree %c",
TREE_CODE_CLASS(TREE_CODE(type_tree)));
return idx;
}
#ifdef KEY
UINT align = TYPE_ALIGN(type_tree) / BITSPERBYTE;
#endif
// for typedefs get the information from the base type
if (TYPE_NAME(type_tree) &&
idx == 0 &&
(TREE_CODE(type_tree) == RECORD_TYPE ||
TREE_CODE(type_tree) == UNION_TYPE) &&
TREE_CODE(TYPE_NAME(type_tree)) == TYPE_DECL &&
TYPE_MAIN_VARIANT(type_tree) != type_tree) {
idx = Get_TY (TYPE_MAIN_VARIANT(type_tree));
#ifdef TARG_NVISA
if (TREE_CODE(type_tree) == RECORD_TYPE) {
char *name = Get_Name(TYPE_NAME(type_tree));
if (strcmp(name, "char1") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "uchar1") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "char2") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "uchar2") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "char3") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "uchar3") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "char4") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "uchar4") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "short1") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "ushort1") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "short2") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "ushort2") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "short3") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "ushort3") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "short4") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "ushort4") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "int1") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "uint1") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "int2") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "uint2") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "int3") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "uint3") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "int4") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "uint4") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "long1") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "ulong1") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "long2") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "ulong2") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "long3") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "ulong3") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "long4") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "ulong4") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "float1") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "float2") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "float3") == 0)
Set_TY_can_be_vector(idx);
else if (strcmp(name, "float4") == 0)
Set_TY_can_be_vector(idx);
}
#endif
if (TYPE_READONLY(type_tree))
Set_TY_is_const (idx);
if (TYPE_VOLATILE(type_tree))
Set_TY_is_volatile (idx);
#ifdef KEY
if (TYPE_RESTRICT(type_tree))
Set_TY_is_restrict (idx);
Set_TY_align (idx, align); // bug 10533
#endif
TYPE_TY_IDX(type_tree) = idx;
if(Debug_Level >= 2) {
struct mongoose_gcc_DST_IDX dst =
Create_DST_type_For_Tree(type_tree,idx,orig_idx);
TYPE_DST_IDX(type_tree) = dst;
}
return idx;
}
TYPE_ID mtype;
INT64 tsize;
BOOL variable_size = FALSE;
tree type_size = TYPE_SIZE(type_tree);
#ifndef KEY
UINT align = TYPE_ALIGN(type_tree) / BITSPERBYTE;
#endif
if (TREE_CODE(type_tree) == VOID_TYPE)
tsize = 0;
else
if (type_size == NULL) {
#ifndef KEY
// incomplete structs have 0 size
FmtAssert(TREE_CODE(type_tree) == ARRAY_TYPE
|| TREE_CODE(type_tree) == UNION_TYPE
|| TREE_CODE(type_tree) == RECORD_TYPE,
("Create_TY_For_Tree: type_size NULL for non ARRAY/RECORD"));
#endif
tsize = 0;
}
else {
if (TREE_CODE(type_size) != INTEGER_CST) {
if (TREE_CODE(type_tree) == ARRAY_TYPE)
DevWarn ("Encountered VLA at line %d", lineno);
else
#ifndef KEY
Fail_FmtAssertion ("VLA at line %d not currently implemented", lineno);
#else
// Bug 943
{
#ifdef PSC_TO_OPEN64
printf("opencc: variable-length structure not yet implemented\n");
#endif
exit(2);
}
#endif
variable_size = TRUE;
tsize = 0;
}
else
#ifdef KEY // bug 3045
tsize = (Get_Integer_Value(type_size) + BITSPERBYTE - 1)
/ BITSPERBYTE;
#else
tsize = Get_Integer_Value(type_size) / BITSPERBYTE;
#endif
}
switch (TREE_CODE(type_tree)) {
case VOID_TYPE:
idx = MTYPE_To_TY (MTYPE_V); // use predefined type
break;
case BOOLEAN_TYPE:
case INTEGER_TYPE:
switch (tsize) {
case 1:
#ifdef TARG_SL
mtype = Get_Mtype_For_Integer_Type(type_tree, tsize);
#else
mtype = MTYPE_I1;
#endif
break;
case 2:
#ifdef TARG_SL
mtype = Get_Mtype_For_Integer_Type(type_tree, tsize);
#else
mtype = MTYPE_I2;
#endif
break;
case 4:
#ifdef TARG_SL
mtype = Get_Mtype_For_Integer_Type(type_tree, tsize);
#else
mtype = MTYPE_I4;
#endif
break;
case 8:
#ifdef TARG_SL
mtype = Get_Mtype_For_Integer_Type(type_tree, tsize);
#else
mtype = MTYPE_I8;
#endif
break;
#if !defined(TARG_X8664) && !defined(TARG_IA64) && !defined(TARG_MIPS) && !defined(TARG_LOONGSON)
#ifdef _LP64
case 16: mtype = MTYPE_I8; break;
#endif /* _LP64 */
#else
// needed for compiling variable length array
// as in gcc.c-torture/execute/920929-1.c
// we need to fix the rest of the compiler
// with _LP64 but seems to work fine without.
case 16: mtype = MTYPE_I8; break;
#endif /* KEY */
default: FmtAssert(FALSE, ("Get_TY unexpected size"));
}
if (TREE_UNSIGNED(type_tree)) {
mtype = MTYPE_complement(mtype);
}
#ifdef KEY
if (lookup_attribute ("may_alias", TYPE_ATTRIBUTES (type_tree)))
{
// bug 9975: Handle may_alias attribute, we need to create
// a new type to which we can attach the flag.
TY &ty = New_TY (idx);
TY_Init (ty, tsize, KIND_SCALAR, mtype,
Save_Str(Get_Name(TYPE_NAME(type_tree))) );
Set_TY_no_ansi_alias (ty);
#if defined(TARG_SL)
// for -m32, it is not the predefined type, alignment shoule be set.
// Corresponding to following code about bug#2932.
if (!TARGET_64BIT)
Set_TY_align (idx, align);
#endif
} else
#endif
#ifdef TARG_NVISA
// In C/C++, char is a separate type from signed char
// or unsigned char. WHIRL doesn't distinguish this
// because what we emit needs a sign property,
// but whirl2c needs to be able to distinguish.
// So override the TY_is_character flag (which was previously
// only used for Fortran) to say that this is a plain char.
// Gnu creates a "char_type_node" for this purpose.
if (tsize == 1 && type_tree == char_type_node) {
// create a new type with this flag
TY &ty = New_TY (idx);
TY_Init (ty, tsize, KIND_SCALAR, mtype,
Save_Str(Get_Name(TYPE_NAME(type_tree))) );
Set_TY_is_character(ty);
} else
#endif
idx = MTYPE_To_TY (mtype); // use predefined type
#if defined(TARG_X8664) || defined(TARG_SL)
/* At least for -m32, the alignment is not the same as the data
type's natural size. (bug#2932)
*/
if( TARGET_64BIT )
#endif // TARG_X8664
Set_TY_align (idx, align);
break;
case CHAR_TYPE:
mtype = (TREE_UNSIGNED(type_tree) ? MTYPE_U1 : MTYPE_I1);
idx = MTYPE_To_TY (mtype); // use predefined type
break;
case ENUMERAL_TYPE:
mtype = (TREE_UNSIGNED(type_tree) ? MTYPE_U4 : MTYPE_I4);
#ifdef KEY
/* bug#500 */
if( tsize == 8 ){
mtype = (TREE_UNSIGNED(type_tree) ? MTYPE_U8 : MTYPE_I8);
}
#endif
idx = MTYPE_To_TY (mtype); // use predefined type
break;
case REAL_TYPE:
switch (tsize) {
case 4: mtype = MTYPE_F4; break;
case 8: mtype = MTYPE_F8; break;
#if defined(TARG_IA64)
case 12:
case 16: mtype = MTYPE_F10; break;
#elif defined(TARG_MIPS) || defined(TARG_IA32) || defined(TARG_X8664) || defined(TARG_NVISA) || defined(TARG_LOONGSON)
case 12:
case 16: mtype = MTYPE_FQ; break;
#else
case 16: mtype = MTYPE_F16; break;
#endif /* TARG_MIPS */
default: FmtAssert(FALSE, ("Get_TY unexpected REAL_TYPE size %d", tsize));
}
idx = MTYPE_To_TY (mtype); // use predefined type
break;
case COMPLEX_TYPE:
switch (tsize) {
#ifdef KEY
case 2:
case 4: ErrMsg (EC_Unsupported_Type, "Complex integer");
#endif
case 8: mtype = MTYPE_C4; break;
case 16: mtype = MTYPE_C8; break;
#if defined(TARG_MIPS) || defined(TARG_IA32) || defined(TARG_X8664) || defined(TARG_LOONGSON)
case 32: mtype = MTYPE_CQ; break;
#endif /* TARG_MIPS */
#ifdef TARG_IA64
#ifdef PATHSCALE_MERGE
case 32: mtype = MTYPE_C10; break;
#endif
case 24: mtype = MTYPE_C10; break;
#endif /* TARG_IA64 */
#if defined(TARG_IA32) || defined(TARG_X8664)
case 24: mtype = MTYPE_CQ; break;
#endif /* TARG_IA32 */
default: FmtAssert(FALSE, ("Get_TY unexpected size"));
}
idx = MTYPE_To_TY (mtype); // use predefined type
break;
case REFERENCE_TYPE:
case POINTER_TYPE:
idx = Make_Pointer_Type (Get_TY (TREE_TYPE(type_tree)));
Set_TY_align (idx, align);
break;
case ARRAY_TYPE:
{ // new scope for local vars
TY &ty = New_TY (idx);
TY_Init (ty, tsize, KIND_ARRAY, MTYPE_M,
Save_Str(Get_Name(TYPE_NAME(type_tree))) );
Set_TY_etype (ty, Get_TY (TREE_TYPE(type_tree)));
Set_TY_align (idx, TY_align(TY_etype(ty)));
if (TYPE_NAME(type_tree) == NULL)
Set_TY_anonymous(ty);
// assumes 1 dimension
// nested arrays are treated as arrays of arrays
ARB_HANDLE arb = New_ARB ();
ARB_Init (arb, 0, 0, 0);
Set_TY_arb (ty, arb);
Set_ARB_first_dimen (arb);
Set_ARB_last_dimen (arb);
Set_ARB_dimension (arb, 1);
#ifdef KEY
// Bug 660
// Due to the way we handle extern variables, we may end up
// with a type whose base type is undefined upto this point.
// For example, extern struct bar_t bar[];
// (don't know size of struct bar_t)
if (!TYPE_SIZE(TREE_TYPE(type_tree)))
break;
#endif
if (TREE_CODE(TYPE_SIZE(TREE_TYPE(type_tree))) == INTEGER_CST) {
Set_ARB_const_stride (arb);
Set_ARB_stride_val (arb,
Get_Integer_Value (TYPE_SIZE_UNIT(TREE_TYPE(type_tree))));
}
else {
WN *swn;
swn = WFE_Expand_Expr (TYPE_SIZE_UNIT(TREE_TYPE(type_tree)));
if (WN_opcode (swn) == OPC_U4I4CVT ||
WN_opcode (swn) == OPC_U8I8CVT) {
swn = WN_kid0 (swn);
}
#ifdef KEY
// In the event that swn operator is not
// OPR_LDID, save expr node swn
// and use LDID of that stored address as swn.
// Copied from Wfe_Save_Expr in wfe_expr.cxx
if (WN_operator (swn) != OPR_LDID) {
TYPE_ID mtype = WN_rtype(swn);
TY_IDX ty_idx = MTYPE_To_TY(mtype);
ST *st;
st = Gen_Temp_Symbol (ty_idx, "__save_expr");
#ifdef KEY
WFE_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL,
st);
#endif
WFE_Set_ST_Addr_Saved (swn);
swn = WN_Stid (mtype, 0, st, ty_idx, swn);
WFE_Stmt_Append (swn, Get_Srcpos());
swn = WN_Ldid (mtype, 0, st, ty_idx);
}
#endif /* KEY */
FmtAssert (WN_operator (swn) == OPR_LDID,
("stride operator for VLA not LDID"));
ST *st = WN_st (swn);
TY_IDX ty_idx = ST_type (st);
WN *wn = WN_CreateXpragma (WN_PRAGMA_COPYIN_BOUND,
(ST_IDX) NULL, 1);
WN_kid0 (wn) = WN_Ldid (TY_mtype (ty_idx), 0, st, ty_idx);
WFE_Stmt_Append (wn, Get_Srcpos());
Clear_ARB_const_stride (arb);
Set_ARB_stride_var (arb, (ST_IDX) ST_st_idx (st));
}
Set_ARB_const_lbnd (arb);
Set_ARB_lbnd_val (arb, 0);
if (type_size) {
#ifdef KEY
// For Zero-length arrays, TYPE_MAX_VALUE tree is NULL
if (!TYPE_MAX_VALUE (TYPE_DOMAIN (type_tree))) {
Set_ARB_const_ubnd (arb);
Set_ARB_ubnd_val (arb, 0xffffffff);
} else
#endif /* KEY */
if (TREE_CODE(TYPE_MAX_VALUE (TYPE_DOMAIN (type_tree))) ==
INTEGER_CST) {
Set_ARB_const_ubnd (arb);
Set_ARB_ubnd_val (arb, Get_Integer_Value (
TYPE_MAX_VALUE (TYPE_DOMAIN (type_tree)) ));
}
#ifdef KEY
// bug 4086: see comments "throw away any variable
// type sizes ..." in finish_decl().
else if (!TYPE_DEFER_EXPANSION (type_tree))
#else
else
#endif
{
WN *uwn = WFE_Expand_Expr (TYPE_MAX_VALUE (TYPE_DOMAIN (type_tree)) );
if (WN_opcode (uwn) == OPC_U4I4CVT ||
WN_opcode (uwn) == OPC_U8I8CVT) {
uwn = WN_kid0 (uwn);
}
#ifdef KEY
// In the event that uwn operator is not
// OPR_LDID, save expr node uwn
// and use LDID of that stored address as uwn.
// Copied from Wfe_Save_Expr in wfe_expr.cxx
if (WN_operator (uwn) != OPR_LDID) {
TYPE_ID mtype = WN_rtype(uwn);
TY_IDX ty_idx = MTYPE_To_TY(mtype);
ST *st;
st = Gen_Temp_Symbol (ty_idx, "__save_expr");
#ifdef KEY
WFE_add_pragma_to_enclosing_regions (WN_PRAGMA_LOCAL,
st);
#endif
WFE_Set_ST_Addr_Saved (uwn);
uwn = WN_Stid (mtype, 0, st, ty_idx, uwn);
WFE_Stmt_Append (uwn, Get_Srcpos());
uwn = WN_Ldid (mtype, 0, st, ty_idx);
}
#endif /* KEY */
FmtAssert (WN_operator (uwn) == OPR_LDID,
("bounds operator for VLA not LDID"));
ST *st = WN_st (uwn);
TY_IDX ty_idx = ST_type (st);
WN *wn = WN_CreateXpragma (WN_PRAGMA_COPYIN_BOUND,
(ST_IDX) NULL, 1);
WN_kid0 (wn) = WN_Ldid (TY_mtype (ty_idx), 0, st, ty_idx);
WFE_Stmt_Append (wn, Get_Srcpos());
Clear_ARB_const_ubnd (arb);
Set_ARB_ubnd_var (arb, ST_st_idx (st));
}
#ifdef KEY
else
{
Clear_ARB_const_ubnd (arb);
Set_ARB_ubnd_val (arb, 0);
}
#endif
}
else {
Clear_ARB_const_ubnd (arb);
Set_ARB_ubnd_val (arb, 0);
}
if (variable_size
#ifdef KEY
// bug 4086
&& !TYPE_DEFER_EXPANSION (type_tree)
#endif
) {
WN *swn, *wn;
swn = WFE_Expand_Expr (TYPE_SIZE_UNIT(type_tree));
if (TY_size(TY_etype(ty))) {
if (WN_opcode (swn) == OPC_U4I4CVT ||
WN_opcode (swn) == OPC_U8I8CVT) {
swn = WN_kid0 (swn);
}
#ifdef KEY
// In the event that swn operator is not
// OPR_LDID, save expr node swn
// and use LDID of that stored address as swn.
// Copied from Wfe_Save_Expr in wfe_expr.cxx
if (WN_operator (swn) != OPR_LDID) {
TYPE_ID mtype = WN_rtype(swn);
TY_IDX ty_idx = MTYPE_To_TY(mtype);
ST *st;
st = Gen_Temp_Symbol (ty_idx, "__save_expr");
#ifdef KEY
WFE_add_pragma_to_enclosing_regions
(WN_PRAGMA_LOCAL, st);
#endif
WFE_Set_ST_Addr_Saved (swn);
swn = WN_Stid (mtype, 0, st, ty_idx, swn);
WFE_Stmt_Append (swn, Get_Srcpos());
swn = WN_Ldid (mtype, 0, st, ty_idx);
}
#endif /* KEY */
FmtAssert (WN_operator (swn) == OPR_LDID,
("size operator for VLA not LDID"));
ST *st = WN_st (swn);
TY_IDX ty_idx = ST_type (st);
TYPE_ID mtype = TY_mtype (ty_idx);
wn = WN_Stid (mtype, 0, st, ty_idx, swn);
WFE_Stmt_Append (wn, Get_Srcpos());
}
}
} // end array scope
break;
case RECORD_TYPE:
case UNION_TYPE:
{ // new scope for local vars
TY &ty = (idx == TY_IDX_ZERO) ? New_TY(idx) : Ty_Table[idx];
// For typedef A B, tree A and tree B link to the same TY C
// When parsing A, C's name is set to A
// When parsing B, C's name is set to B
// It makes C's name be random in different object files so that TY merge will fail
// So the name of this TY must be fixed to the main variant name.
if (TYPE_MAIN_VARIANT(type_tree) != type_tree)
TY_Init(ty, tsize, KIND_STRUCT, MTYPE_M,
Save_Str(Get_Name(TYPE_NAME(TYPE_MAIN_VARIANT(type_tree)))));
else
TY_Init (ty, tsize, KIND_STRUCT, MTYPE_M,
Save_Str(Get_Name(TYPE_NAME(type_tree))) );
if (TYPE_NAME(type_tree) == NULL)
Set_TY_anonymous(ty);
if (TREE_CODE(type_tree) == UNION_TYPE) {
Set_TY_is_union(idx);
}
if (align == 0) align = 1; // in case incomplete type
Set_TY_align (idx, align);
// set idx now in case recurse thru fields
TYPE_TY_IDX(type_tree) = idx;
// to handle nested structs and avoid entering flds
// into wrong struct, make two passes over the fields.
// first create the list of flds for the current struct,
// but don't follow the nested types. Then go back thru
// the fields and set the fld_type, recursing down into
// nested structs.
Set_TY_fld (ty, FLD_HANDLE());
FLD_IDX first_field_idx = Fld_Table.Size ();
tree field;
FLD_HANDLE fld;
for (field = TREE_PURPOSE(type_tree);
field;
field = TREE_CHAIN(field) )
{
if (TREE_CODE(field) == TYPE_DECL) {
DevWarn ("got TYPE_DECL in field list");
continue;
}
if (TREE_CODE(field) == CONST_DECL) {
DevWarn ("got CONST_DECL in field list");
continue;
}
fld = New_FLD ();
FLD_Init (fld, Save_Str(Get_Name(DECL_NAME(field))),
0, // type
Get_Integer_Value(DECL_FIELD_OFFSET(field)) +
Get_Integer_Value(DECL_FIELD_BIT_OFFSET(field))
/ BITSPERBYTE );
if (DECL_NAME(field) == NULL)
Set_FLD_is_anonymous(fld);
#ifdef OLDCODE
if ( ! DECL_BIT_FIELD(field)
&& Get_Integer_Value(DECL_SIZE(field)) > 0
&& Get_Integer_Value(DECL_SIZE(field))
!= (TY_size(Get_TY(TREE_TYPE(field)))
* BITSPERBYTE) )
{
// for some reason gnu doesn't set bit field
// when have bit-field of standard size
// (e.g. int f: 16;). But we need it set
// so we know how to pack it, because
// otherwise the field type is wrong.
DevWarn("field size %d doesn't match type size %d",
Get_Integer_Value(DECL_SIZE(field)),
TY_size(Get_TY(TREE_TYPE(field)))
* BITSPERBYTE );
DECL_BIT_FIELD(field) = 1;
}
if (DECL_BIT_FIELD(field)) {
Set_FLD_is_bit_field (fld);
// bofst is remaining bits from byte offset
Set_FLD_bofst (fld,
// Get_Integer_Value(DECL_FIELD_OFFSET(field)) +
Get_Integer_Value(
DECL_FIELD_BIT_OFFSET(field))
% BITSPERBYTE );
Set_FLD_bsize (fld, Get_Integer_Value(DECL_SIZE(field)));
}
#endif /* OLDCODE */
}
FLD_IDX last_field_idx = Fld_Table.Size () - 1;
if (last_field_idx >= first_field_idx) {
Set_TY_fld (ty, FLD_HANDLE (first_field_idx));
Set_FLD_last_field (FLD_HANDLE (last_field_idx));
}
// now set the fld types.
fld = TY_fld(ty);
for (field = TREE_PURPOSE(type_tree);
field;
field = TREE_CHAIN(field))
{
#ifdef KEY
const int FLD_BIT_FIELD_SIZE = 64;
#endif
if (TREE_CODE(field) == TYPE_DECL)
continue;
if (TREE_CODE(field) == CONST_DECL)
continue;
if ( ! DECL_BIT_FIELD(field)
#ifdef KEY
&& DECL_SIZE(field)
// We don't handle bit-fields > 64 bits. For an INT field of 128 bits, we
// make it 64 bits. But then don't set it as FLD_IS_BIT_FIELD.
&& Get_Integer_Value(DECL_SIZE(field)) <=
FLD_BIT_FIELD_SIZE
#endif /* KEY */
&& Get_Integer_Value(DECL_SIZE(field)) > 0
&& Get_Integer_Value(DECL_SIZE(field))
!= (TY_size(Get_TY(TREE_TYPE(field)))
* BITSPERBYTE) )
{
// for some reason gnu doesn't set bit field
// when have bit-field of standard size
// (e.g. int f: 16;). But we need it set
// so we know how to pack it, because
// otherwise the field type is wrong.
DevWarn("field size %lld doesn't match type size %lld",
Get_Integer_Value(DECL_SIZE(field)),
TY_size(Get_TY(TREE_TYPE(field)))
* BITSPERBYTE );
DECL_BIT_FIELD(field) = 1;
}
if (DECL_BIT_FIELD(field)) {
Set_FLD_is_bit_field (fld);
// bofst is remaining bits from byte offset
Set_FLD_bofst (fld,
// Get_Integer_Value(DECL_FIELD_OFFSET(field)) +
Get_Integer_Value(
DECL_FIELD_BIT_OFFSET(field))
% BITSPERBYTE );
Set_FLD_bsize (fld, Get_Integer_Value(DECL_SIZE(field)));
}
TY_IDX fty_idx = Get_TY(TREE_TYPE(field));
if ((TY_align (fty_idx) > align) || (TY_is_packed (fty_idx)))
Set_TY_is_packed (ty);
Set_FLD_type(fld, fty_idx);
fld = FLD_next(fld);
}
} // end record scope
break;
case METHOD_TYPE:
DevWarn ("Encountered METHOD_TYPE at line %d", lineno);
case FUNCTION_TYPE:
{ // new scope for local vars
tree arg;
INT32 num_args;
TY &ty = New_TY (idx);
TY_Init (ty, 0, KIND_FUNCTION, MTYPE_UNKNOWN, 0);
Set_TY_align (idx, 1);
TY_IDX ret_ty_idx;
TY_IDX arg_ty_idx;
TYLIST tylist_idx;
// allocate TYs for return as well as parameters
// this is needed to avoid mixing TYLISTs if one
// of the parameters is a pointer to a function
ret_ty_idx = Get_TY(TREE_TYPE(type_tree));
for (arg = TYPE_ARG_TYPES(type_tree);
arg;
arg = TREE_CHAIN(arg))
arg_ty_idx = Get_TY(TREE_VALUE(arg));
// if return type is pointer to a zero length struct
// convert it to void
if (!WFE_Keep_Zero_Length_Structs &&
TY_mtype (ret_ty_idx) == MTYPE_M &&
TY_size (ret_ty_idx) == 0) {
// zero length struct being returned
DevWarn ("function returning zero length struct at line %d", lineno);
ret_ty_idx = Be_Type_Tbl (MTYPE_V);
}
Set_TYLIST_type (New_TYLIST (tylist_idx), ret_ty_idx);
Set_TY_tylist (ty, tylist_idx);
for (num_args = 0, arg = TYPE_ARG_TYPES(type_tree);
arg;
num_args++, arg = TREE_CHAIN(arg))
{
arg_ty_idx = Get_TY(TREE_VALUE(arg));
if (!WFE_Keep_Zero_Length_Structs &&
TY_mtype (arg_ty_idx) == MTYPE_M &&
TY_size (arg_ty_idx) == 0) {
// zero length struct passed as parameter
DevWarn ("zero length struct encountered in function prototype at line %d", lineno);
}
else
Set_TYLIST_type (New_TYLIST (tylist_idx), arg_ty_idx);
}
if (num_args)
{
Set_TY_has_prototype(idx);
if (arg_ty_idx != Be_Type_Tbl(MTYPE_V))
{
Set_TYLIST_type (New_TYLIST (tylist_idx), 0);
Set_TY_is_varargs(idx);
}
else
Set_TYLIST_type (Tylist_Table [tylist_idx], 0);
}
else
Set_TYLIST_type (New_TYLIST (tylist_idx), 0);
} // end FUNCTION_TYPE scope
break;
#ifdef TARG_X8664
// x86 gcc vector types
case VECTOR_TYPE:
{
switch (GET_MODE_SIZE (TYPE_MODE (type_tree)))
{
case 8:
switch (GET_MODE_UNIT_SIZE (TYPE_MODE (type_tree)))
{
case 1:
idx = MTYPE_To_TY (MTYPE_M8I1);
break;
case 2:
idx = MTYPE_To_TY (MTYPE_M8I2);
break;
case 4:
if (TREE_CODE (TREE_TYPE (type_tree)) == INTEGER_TYPE)
idx = MTYPE_To_TY (MTYPE_M8I4);
else
idx = MTYPE_To_TY (MTYPE_M8F4);
break;
default: Fail_FmtAssertion ("Get_TY: NYI");
}
break;
case 16:
switch (GET_MODE_UNIT_SIZE (TYPE_MODE (type_tree)))
{
case 1:
idx = MTYPE_To_TY (MTYPE_V16I1);
break;
case 2:
idx = MTYPE_To_TY (MTYPE_V16I2);
break;
case 4:
if (TREE_CODE (TREE_TYPE (type_tree)) == INTEGER_TYPE)
idx = MTYPE_To_TY (MTYPE_V16I4);
else
idx = MTYPE_To_TY (MTYPE_V16F4);
break;
case 8:
if (TREE_CODE (TREE_TYPE (type_tree)) == INTEGER_TYPE)
idx = MTYPE_To_TY (MTYPE_V16I8);
else
idx = MTYPE_To_TY (MTYPE_V16F8);
break;
default: Fail_FmtAssertion ("Get_TY: NYI");
}
break;
default:
Fail_FmtAssertion ("Get_TY: Unexpected vector type");
}
}
break;
#endif // TARG_X8664
default:
FmtAssert(FALSE, ("Get_TY unexpected tree_type"));
}
if (TYPE_READONLY(type_tree))
Set_TY_is_const (idx);
if (TYPE_VOLATILE(type_tree))
Set_TY_is_volatile (idx);
#ifdef KEY
if (TYPE_RESTRICT(type_tree))
Set_TY_is_restrict (idx);
#endif
TYPE_TY_IDX(type_tree) = idx;
if(Debug_Level >= 2) {
struct mongoose_gcc_DST_IDX dst =
Create_DST_type_For_Tree(type_tree,idx,orig_idx);
TYPE_DST_IDX(type_tree) = dst;
}
return idx;
}
#ifdef KEY
void
Create_DST_For_Tree (tree decl_node, ST* st)
{
struct mongoose_gcc_DST_IDX dst =
Create_DST_decl_For_Tree(decl_node,st);
DECL_DST_IDX(decl_node) = dst;
return;
}
#endif
ST*
Create_ST_For_Tree (tree decl_node)
{
TY_IDX ty_idx;
ST* st;
char *name;
ST_SCLASS sclass;
ST_EXPORT eclass;
SYMTAB_IDX level;
if (TREE_CODE(decl_node) == ERROR_MARK)
exit (RC_USER_ERROR);
#ifdef PATHSCALE_MERGE
//begin - fix for bug OSP 204
if (TREE_CODE (decl_node) == VAR_DECL &&
(TREE_STATIC(decl_node) || DECL_EXTERNAL(decl_node) || TREE_PUBLIC(decl_node) ) &&
DECL_ASSEMBLER_NAME(decl_node) ) {
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME(decl_node));
if (*name == '*' ) name++;
}
else if (DECL_NAME (decl_node)) {
#ifdef TARG_NVISA
if (TREE_CODE(decl_node) == PARM_DECL) {
static char buf[256];
// have to mangle parameter names since referred to by name;
// need to mangle such that params in different functions are unique.
sprintf(buf, "__cudaparm_%s_%s",
ST_name(Get_Current_PU_ST()),
IDENTIFIER_POINTER (DECL_NAME (decl_node)));
name = buf;
}
else
#endif
name = IDENTIFIER_POINTER (DECL_NAME (decl_node));
}
//end - fix for bug OSP 204
#endif
else {
DevWarn ("no name for DECL_NODE");
name = "__unknown__";
}
switch (TREE_CODE(decl_node)) {
case FUNCTION_DECL:
{
TY_IDX func_ty_idx = Get_TY(TREE_TYPE(decl_node));
if (DECL_WIDEN_RETVAL (decl_node)) {
/*
extern tree long_long_integer_type_node;
extern tree long_long_unsigned_type_node;
*/
tree type_tree = TREE_TYPE(decl_node);
tree ret_type_tree = TREE_TYPE (type_tree);
TY_IDX ret_ty_idx = Get_TY(ret_type_tree);
if (MTYPE_signed (TY_mtype (ret_ty_idx)))
TREE_TYPE (type_tree) = long_long_integer_type_node;
else
TREE_TYPE (type_tree) = long_long_unsigned_type_node;
TY_IDX old_func_ty_idx = func_ty_idx;
func_ty_idx = Create_TY_For_Tree (type_tree, TY_IDX_ZERO);
TREE_TYPE (type_tree) = ret_type_tree;
TYPE_TY_IDX(type_tree) = old_func_ty_idx;
}
sclass = SCLASS_EXTERN;
eclass = TREE_PUBLIC(decl_node) ? EXPORT_PREEMPTIBLE : EXPORT_LOCAL;
level = GLOBAL_SYMTAB+1;
PU_IDX pu_idx;
PU& pu = New_PU (pu_idx);
PU_Init (pu, func_ty_idx, level);
st = New_ST (GLOBAL_SYMTAB);
if (DECL_CDECL(decl_node))
Set_PU_is_cdecl(pu_idx);
#ifdef KEY // Fix bug # 34
// gcc sometimes adds a '*' and itself handles it this way while outputing
char * check_for_star = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (
decl_node));
if (*check_for_star == '*')
check_for_star++;
ST_Init (st, Save_Str (check_for_star),
CLASS_FUNC, sclass, eclass, TY_IDX (pu_idx));
#else
ST_Init (st,
Save_Str ( IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl_node))),
CLASS_FUNC, sclass, eclass, TY_IDX (pu_idx));
#endif // KEY
/*
if (TREE_CODE(TREE_TYPE(decl_node)) == METHOD_TYPE)
fprintf (stderr, "Create_ST_For_Tree: METHOD_TYPE\n");
*/
}
break;
case PARM_DECL:
case VAR_DECL:
{
if (TREE_CODE(decl_node) == PARM_DECL) {
sclass = SCLASS_FORMAL;
eclass = EXPORT_LOCAL;
level = CURRENT_SYMTAB;
}
else {
if (DECL_CONTEXT (decl_node) == 0) {
if (TREE_PUBLIC (decl_node)) {
if (DECL_INITIAL(decl_node))
sclass = SCLASS_DGLOBAL;
else if (TREE_STATIC(decl_node)) {
if (flag_no_common || DECL_SECTION_NAME(decl_node) ||
DECL_THREAD_LOCAL(decl_node) )
sclass = SCLASS_UGLOBAL;
else
sclass = SCLASS_COMMON;
}
else
sclass = SCLASS_EXTERN;
#ifdef TARG_IA64
// bug fix for OSP_89 && OSP_173 && OSP_169
extern BOOL Use_Call_Shared_Link,Gp_Rel_Aggresive_Opt;
if (!flag_pic) {
if (Use_Call_Shared_Link && Gp_Rel_Aggresive_Opt &&
sclass != SCLASS_EXTERN && sclass != SCLASS_COMMON)
eclass = EXPORT_PROTECTED;
else
eclass = EXPORT_PREEMPTIBLE;
}
else
eclass = EXPORT_PREEMPTIBLE;
}
#else
eclass = EXPORT_PREEMPTIBLE;
}
#endif
else {
sclass = SCLASS_FSTATIC;
eclass = EXPORT_LOCAL;
#ifdef TARG_NVISA
if (TREE_CODE(TREE_TYPE(decl_node)) == ARRAY_TYPE
&& TYPE_SIZE(TREE_TYPE(decl_node)) == NULL)
{
// HACK WARNING:
// cudafe is generating these as fake pointers,
// which it later allocates all to the same memory;
// because they are static wopt thinks they are already
// allocated and don't alias, but they do,
// so change them to be common preemptible
// (ideally cudafe should probably do this itself).
DevWarn("static array of unknown size, change to common");
sclass = SCLASS_COMMON;
eclass = EXPORT_PREEMPTIBLE;
}
#endif
}
level = GLOBAL_SYMTAB;
}
else {
if (DECL_EXTERNAL(decl_node)) {
sclass = SCLASS_EXTERN;
level = GLOBAL_SYMTAB;
eclass = EXPORT_PREEMPTIBLE;
}
else {
if (TREE_STATIC (decl_node)) {
sclass = SCLASS_PSTATIC;
if (pstatic_as_global
#ifdef KEY
// bugs 2647, 2681
// Promote it if we are sure the function containing this var has been
// inlined.
|| DECL_PROMOTE_STATIC (decl_node)
#endif
)
level = GLOBAL_SYMTAB;
else
level = CURRENT_SYMTAB;
}
else {
sclass = SCLASS_AUTO;
level = decl_node->decl.symtab_idx ?
decl_node->decl.symtab_idx : CURRENT_SYMTAB;
}
eclass = EXPORT_LOCAL;
}
}
}
st = New_ST (level);
ty_idx = Get_TY (TREE_TYPE(decl_node));
if (TY_kind (ty_idx) == KIND_ARRAY &&
TREE_STATIC (decl_node) &&
DECL_INITIAL (decl_node) == FALSE &&
TY_size (ty_idx) == 0) {
Set_TY_size (ty_idx, TY_size (Get_TY (TREE_TYPE (TREE_TYPE (decl_node)))));
}
#ifndef KEY
// bug 3735: the compiler cannot arbitrarily change the alignment of
// individual structures
if (TY_mtype (ty_idx) == MTYPE_M &&
Aggregate_Alignment > 0 &&
Aggregate_Alignment > TY_align (ty_idx))
Set_TY_align (ty_idx, Aggregate_Alignment);
#endif // !KEY
// qualifiers are set on decl nodes
if (TREE_READONLY(decl_node))
Set_TY_is_const (ty_idx);
if (TREE_THIS_VOLATILE(decl_node))
Set_TY_is_volatile (ty_idx);
#ifdef KEY
// Handle aligned attribute (bug 7331)
if (DECL_USER_ALIGN (decl_node))
Set_TY_align (ty_idx, DECL_ALIGN_UNIT (decl_node));
// NOTE: we do not update the ty_idx value in the TYPE_TREE. So
// if any of the above properties are set, the next time we get into
// Get_ST, the ty_idx in the TYPE_TREE != ty_idx in st. The solution
// is either to update TYPE_TREE now, or compare the ty_idx_index
// in Get_ST (instead of ty_idx). Currently we do the latter.
#endif // KEY
ST_Init (st, Save_Str(name), CLASS_VAR, sclass, eclass, ty_idx);
if (TREE_CODE(decl_node) == PARM_DECL) {
Set_ST_is_value_parm(st);
}
if (TREE_CODE(decl_node) == VAR_DECL && TREE_READONLY(decl_node)
// const_var doesn't apply to stack variables.
// we are really doing this mainly for external const
// (if initialized then just replaced with initial value).
&& ST_sclass(st) != SCLASS_AUTO)
{
Set_ST_is_const_var(st);
}
if (TREE_CODE(decl_node) == VAR_DECL && DECL_THREAD_LOCAL(decl_node)) {
Set_ST_is_thread_local (st);
}
}
break;
default:
{
Fail_FmtAssertion ("Create_ST_For_Tree: unexpected tree type");
}
break;
}
DECL_ST(decl_node) = st;
if ((DECL_WEAK (decl_node)) && (TREE_CODE (decl_node) != PARM_DECL)) {
Set_ST_is_weak_symbol (st);
/*
if (TREE_CODE (decl_node) == FUNCTION_DECL)
Set_ST_sclass (st, SCLASS_TEXT);
*/
}
#ifdef TARG_NVISA
if (DECL_GLOBAL(decl_node)) {
Set_ST_in_global_mem (st);
}
if (DECL_LOCAL(decl_node)) {
Set_ST_in_local_mem (st);
}
if (DECL_SHARED(decl_node)) {
Set_ST_in_shared_mem (st);
if (ST_sclass(st) == SCLASS_FORMAL)
Set_ST_is_const_var(st); /* param space is readonly */
}
if (DECL_CONSTANT(decl_node)) {
Set_ST_in_constant_mem (st);
Set_ST_is_const_var(st);
}
if (DECL_TEXTURE(decl_node)) {
Set_ST_in_texture_mem (st);
}
if (DECL_THREAD_LIMIT (decl_node) != 0 &&
DECL_BLOCK_LIMIT (decl_node) != 0 ) {
Set_PU_thread_limit (Pu_Table [ST_pu(st)], DECL_THREAD_LIMIT (decl_node));
Set_PU_block_limit (Pu_Table [ST_pu(st)], DECL_BLOCK_LIMIT (decl_node));
}
#endif /* TARG_NVISA */
if (DECL_SECTION_NAME (decl_node)) {
if (TREE_CODE (decl_node) == FUNCTION_DECL)
level = GLOBAL_SYMTAB;
ST_ATTR_IDX st_attr_idx;
ST_ATTR& st_attr = New_ST_ATTR (level, st_attr_idx);
ST_ATTR_Init (st_attr, ST_st_idx (st), ST_ATTR_SECTION_NAME,
Save_Str (TREE_STRING_POINTER (DECL_SECTION_NAME (decl_node))));
Set_ST_has_named_section (st);
}
if (DECL_SYSCALL_LINKAGE (decl_node)) {
Set_PU_has_syscall_linkage (Pu_Table [ST_pu(st)]);
}
#if defined(TARG_SL)
if(DECL_SL_MODEL_NAME(decl_node)) {
if(TREE_CODE(decl_node) == VAR_DECL &&
TREE_CODE(DECL_SL_MODEL_NAME(decl_node)) == STRING_CST)
{
if(!strcmp(TREE_STRING_POINTER(DECL_SL_MODEL_NAME(decl_node)), "small"))
Set_ST_gprel(st);
else if(!strcmp(TREE_STRING_POINTER(DECL_SL_MODEL_NAME(decl_node)), "large"))
Set_ST_not_gprel(st);
else
Fail_FmtAssertion("incorrect model type for sl data model");
}
}
#endif
if(Debug_Level >= 2) {
#ifdef KEY
// Bug 559
if (ST_sclass(st) != SCLASS_EXTERN) {
DST_INFO_IDX dst_idx ;
struct mongoose_gcc_DST_IDX tdst
= DECL_DST_IDX(decl_node);
cp_to_dst_from_tree(&dst_idx,&tdst);
// Bug 6679 - when the variables inside the second definition of an
// "extern inline" function (with an attribute) are encountered, there
// will already be an entry in the DST table. In that event, update the
// ST (offset) field in the DST entry. The ST offset may change because
// now we are expanding the function body.
// Just deleting the DECL_DST_IDX entry in WFE_Null_ST_References
// will not help because the DST entry was already appended to the
// DST tree.
if(ST_class(st) == CLASS_VAR && !DST_IS_NULL(dst_idx)) {
DST_INFO *info_ptr = DST_INFO_IDX_TO_PTR(dst_idx);
DST_ATTR_IDX attr_idx = DST_INFO_attributes(info_ptr);
DST_VARIABLE *attr = DST_ATTR_IDX_TO_PTR(attr_idx, DST_VARIABLE);
DST_ASSOC_INFO_st_idx(DST_VARIABLE_def_st(attr)) = ST_st_idx(st);
} else {
struct mongoose_gcc_DST_IDX dst =
Create_DST_decl_For_Tree(decl_node,st);
DECL_DST_IDX(decl_node) = dst;
}
}
#else
struct mongoose_gcc_DST_IDX dst =
Create_DST_decl_For_Tree(decl_node,st);
DECL_DST_IDX(decl_node) = dst;
#endif
}
/* NOTES:
* Following code is temporarily used since mtype isn't
* ready for now. After mtype handling has been finished we will
* use new normal method to handle section assignment. */
/* Description:
* Set ST Flags for variant internal buffer type
* VBUF is only to be file scope variable and gp-relative
* SBUF need to decide if SBUF is explicitly declared. If
* declared the flag Set_ST_in_sbuf need to be set to indicate
* the variable will be processed by CP2. */
#ifdef TARG_SL
const char* section_name;
int has_assigned_section = 0;
if(DECL_VBUF(decl_node)) // || DECL_SBUF(decl_node))
{
if(DECL_V1BUF(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
&& !POINTER_TYPE_P(TREE_TYPE(decl_node)))
{
Set_ST_in_v1buf(st);
Set_ST_gprel(st);
}
else if(DECL_V2BUF(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
&& !POINTER_TYPE_P(TREE_TYPE(decl_node)))
{
Set_ST_in_v2buf(st);
Set_ST_gprel(st);
TY_IDX st_ty_idx=ST_type(st);
Set_TY_size (st_ty_idx, TY_size(st_ty_idx)*2);
}
else if(DECL_V4BUF(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
&& !POINTER_TYPE_P(TREE_TYPE(decl_node)))
{
Set_ST_in_v4buf(st);
Set_ST_gprel(st);
TY_IDX st_ty_idx=ST_type(st);
Set_TY_size (st_ty_idx, TY_size(st_ty_idx)*4);
}
}
else if(DECL_SBUF(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
&& !POINTER_TYPE_P(TREE_TYPE(decl_node))) {
if(TREE_CODE(TREE_TYPE(decl_node)) == ARRAY_TYPE)
{
tree element_type = TREE_TYPE(decl_node);
while(TREE_CODE(element_type) == ARRAY_TYPE)
element_type = TREE_TYPE(element_type);
if(!POINTER_TYPE_P(element_type))
{
Set_ST_in_sbuf(st);
Set_ST_gprel(st);
}
}
else
{
Set_ST_in_sbuf(st);
Set_ST_gprel(st);
}
}
else if(DECL_SDRAM(decl_node) && TREE_CODE(decl_node) != FUNCTION_DECL
&& !POINTER_TYPE_P(TREE_TYPE(decl_node))) {
Set_ST_in_sdram(st);
}
#endif // TARG_SL
return st;
}
| 30.633713 | 118 | 0.649509 | [
"object",
"vector",
"model"
] |
d69666ac2ab96444cabc27b2413b572d15bcc749 | 22,740 | cc | C++ | master/kismet-2018-08-BETA1/kismet-2018-08-BETA1/legacy_code/legacy_client/kis_client_phy80211.cc | AlexRogalskiy/DevArtifacts | 931aabb8cbf27656151c54856eb2ea7d1153203a | [
"MIT"
] | 4 | 2018-09-07T15:35:24.000Z | 2019-03-27T09:48:12.000Z | master/kismet-2018-08-BETA1/kismet-2018-08-BETA1/legacy_code/legacy_client/kis_client_phy80211.cc | AlexRogalskiy/DevArtifacts | 931aabb8cbf27656151c54856eb2ea7d1153203a | [
"MIT"
] | 371 | 2020-03-04T21:51:56.000Z | 2022-03-31T20:59:11.000Z | master/kismet-2018-08-BETA1/kismet-2018-08-BETA1/legacy_code/legacy_client/kis_client_phy80211.cc | AlexRogalskiy/DevArtifacts | 931aabb8cbf27656151c54856eb2ea7d1153203a | [
"MIT"
] | 3 | 2019-06-18T19:57:17.000Z | 2020-11-06T03:55:08.000Z | /*
This file is part of Kismet
Kismet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Kismet 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 Kismet; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "globalregistry.h"
#include "devicetracker.h"
#include "kis_client_devicetracker.h"
#include "kis_client_phy80211.h"
#include "kis_panel_device.h"
void CPD11_DOT11SSID(CLIPROTO_CB_PARMS) {
((Client_Phy80211 *) auxptr)->Proto_DOT11SSID(globalreg, proto_string,
proto_parsed, srccli,
auxptr);
}
void CPD11_DOT11DEVICE(CLIPROTO_CB_PARMS) {
((Client_Phy80211 *) auxptr)->Proto_DOT11DEVICE(globalreg, proto_string,
proto_parsed, srccli,
auxptr);
}
void CPD11_DOT11CLIENT(CLIPROTO_CB_PARMS) {
((Client_Phy80211 *) auxptr)->Proto_DOT11CLIENT(globalreg, proto_string,
proto_parsed, srccli,
auxptr);
}
string CPD11_Dot11Column_Cb(KDL_COLUMN_PARMS) {
return ((Client_Phy80211 *) aux)->Dot11Column(device, columnid, header);
}
Client_Phy80211::Client_Phy80211(GlobalRegistry *in_globalreg,
Client_Devicetracker *in_tracker,
int in_phyid) : Client_Phy_Handler(in_globalreg,
in_tracker, in_phyid) {
phyname = "IEEE802.11";
const char *CPD11_ssid_fields[] = {
"bssidmac", "checksum", "type", "ssid", "beaconinfo",
"cryptset", "cloaked", "firsttime", "lasttime",
"beaconrate", "beacons", "channel", "dot11d",
NULL
};
const char *CPD11_dot11device_fields[] = {
"mac", "typeset", "txcrypt", "rxcrypt", "decrypted",
"disconnects", "cdpdev", "cdpport",
"fragments", "retries", "lastssid",
"lastssidcsum", "txdatasize", "rxdatasize",
"lastbssid", "dhcphost", "dhcpvendor",
"eapid",
NULL
};
const char *CPD11_dot11client_fields[] = {
"mac", "bssidmac", "firsttime", "lasttime",
"decrypted", "txcrypt", "rxcrypt",
"lastssid", "lastssidcsum", "cdpdev",
"cdpport", "dhcphost", "dhcpvendor",
"txdatasize", "rxdatasize", "manuf",
"eapid",
NULL
};
devcomp_ref_common = devicetracker->RegisterDeviceComponent("COMMON");
devcomp_ref_dot11 = devicetracker->RegisterDeviceComponent("DOT11_DEVICE");
proto_dot11ssid_fields_num = TokenNullJoin(&proto_dot11ssid_fields,
CPD11_ssid_fields);
proto_dot11device_fields_num = TokenNullJoin(&proto_dot11device_fields,
CPD11_dot11device_fields);
proto_dot11client_fields_num = TokenNullJoin(&proto_dot11client_fields,
CPD11_dot11client_fields);
}
void Client_Phy80211::NetClientConfigure(KisNetClient *in_cli, int in_recon) {
if (in_cli->RegisterProtoHandler("DOT11DEVICE", proto_dot11device_fields,
CPD11_DOT11DEVICE, this) < 0) {
_MSG("Could not register *DOT11DEVICE sentence; is this an old version of "
"Kismet you're trying to connect to? Connection will be terminated.",
MSGFLAG_ERROR);
in_cli->KillConnection();
return;
}
if (in_cli->RegisterProtoHandler("DOT11SSID", proto_dot11ssid_fields,
CPD11_DOT11SSID, this) < 0) {
_MSG("Could not register *DOT11SSID sentence; is this an old version of "
"Kismet you're trying to connect to? Connection will be terminated.",
MSGFLAG_ERROR);
in_cli->KillConnection();
return;
}
if (in_cli->RegisterProtoHandler("DOT11CLIENT", proto_dot11client_fields,
CPD11_DOT11CLIENT, this) < 0) {
_MSG("Could not register *DOT11CLIENT sentence; is this an old version of "
"Kismet you're trying to connect to? Connection will be terminated.",
MSGFLAG_ERROR);
in_cli->KillConnection();
return;
}
_MSG("Registered 802.11 client phy components", MSGFLAG_INFO);
devicelist = NULL;
col_dot11d = col_sub_lastssid = -1;
PanelInitialized();
}
void Client_Phy80211::PanelInitialized() {
devicelist =
(Kis_Devicelist *) globalreg->FetchGlobal("MAIN_DEVICELIST");
if (devicelist == NULL)
return;
if (col_dot11d == -1)
col_dot11d = devicelist->RegisterColumn("Dot11d", "802.11d country", 3,
LABEL_POS_LEFT, CPD11_Dot11Column_Cb,
this, false);
if (col_sub_lastssid == -1)
col_sub_lastssid =
devicelist->RegisterColumn("LastSSID", "Most recent 802.11 SSID", 0,
LABEL_POS_LEFT, CPD11_Dot11Column_Cb,
this, true);
devicelist->ParseColumnConfig();
_MSG("Phy80211 panel initialized", MSGFLAG_INFO);
}
void Client_Phy80211::Proto_DOT11SSID(CLIPROTO_CB_PARMS) {
if ((int) proto_parsed->size() < proto_dot11ssid_fields_num)
return;
int fnum = 0;
int tint;
unsigned int tuint;
mac_addr tmac;
map<uint32_t, dot11_ssid *>::iterator dsi;
vector<string> dot11d;
tmac = mac_addr((*proto_parsed)[fnum++].word.c_str());
if (tmac.error) {
return;
}
tmac.SetPhy(phyid);
kis_tracked_device *device =
devicetracker->FetchDevice(tmac);
bool ssid_new = false;
dot11_ssid *ssid = NULL;
if (device == NULL)
return;
dot11_device *dot11dev =
(dot11_device *) device->fetch(devcomp_ref_dot11);
if (dot11dev == NULL)
return;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dsi = dot11dev->ssid_map.find(tuint);
if (dsi == dot11dev->ssid_map.end()) {
ssid_new = true;
ssid = new dot11_ssid();
ssid->checksum = tuint;
} else {
ssid = dsi->second;
}
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%d", &tint) != 1)
goto proto_fail;
ssid->type = (dot11_ssid_type) tint;
ssid->ssid = (*proto_parsed)[fnum++].word;
ssid->beacon_info = (*proto_parsed)[fnum++].word;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%d", &tint) != 1)
goto proto_fail;
ssid->cryptset = tint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%d", &tint) != 1)
goto proto_fail;
ssid->ssid_cloaked = tint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
ssid->first_time = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
ssid->last_time = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
ssid->beaconrate = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
ssid->beacons = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%d", &tint) != 1)
goto proto_fail;
ssid->channel = tint;
dot11d = StrTokenize((*proto_parsed)[fnum++].word, ":");
ssid->dot11d_vec.clear();
if (dot11d.size() >= 2) {
ssid->dot11d_country = MungeToPrintable(dot11d[0]);
for (unsigned int x = 1; x < dot11d.size(); x++) {
dot11_11d_range_info ri;
if (sscanf(dot11d[x].c_str(), "%u-%u-%u", &(ri.startchan),
&(ri.numchan), &(ri.txpower)) != 3) {
goto proto_fail;
}
ssid->dot11d_vec.push_back(ri);
}
}
// _MSG("phydot11ssid got ssid " + ssid->ssid + " csum " + UIntToString(ssid->checksum), MSGFLAG_INFO);
if (ssid_new) {
dot11dev->ssid_map[ssid->checksum] = ssid;
}
if (ssid->checksum == dot11dev->lastssid_csum) {
// _MSG("dot11ssid matched lastssid checksum", MSGFLAG_INFO);
dot11dev->lastssid = ssid;
}
return;
proto_fail:
_MSG("PHYDOT11 failed to process *DOT11SSID", MSGFLAG_ERROR);
if (ssid_new) {
delete(ssid);
}
return;
}
void Client_Phy80211::Proto_DOT11DEVICE(CLIPROTO_CB_PARMS) {
if ((int) proto_parsed->size() < proto_dot11ssid_fields_num)
return;
int fnum = 0;
unsigned int tuint;
unsigned long tulong;
mac_addr tmac;
tmac = mac_addr((*proto_parsed)[fnum++].word.c_str());
if (tmac.error) {
return;
}
tmac.SetPhy(phyid);
kis_tracked_device *device =
devicetracker->FetchDevice(tmac);
if (device == NULL)
return;
bool dot11dev_new = false;
dot11_device *dot11dev =
(dot11_device *) device->fetch(devcomp_ref_dot11);
if (dot11dev == NULL) {
dot11dev_new = true;
dot11dev = new dot11_device();
}
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11dev->type_set = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%lu", &tulong) != 1)
goto proto_fail;
dot11dev->tx_cryptset = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%lu", &tulong) != 1)
goto proto_fail;
dot11dev->rx_cryptset = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11dev->decrypted = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11dev->client_disconnects = tuint;
dot11dev->cdp_dev_id = (*proto_parsed)[fnum++].word;
dot11dev->cdp_port_id = (*proto_parsed)[fnum++].word;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11dev->fragments = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11dev->retries = tuint;
dot11dev->lastssid_str = (*proto_parsed)[fnum++].word;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11dev->lastssid_csum = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%lu", &tulong) != 1)
goto proto_fail;
dot11dev->tx_datasize = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%lu", &tulong) != 1)
goto proto_fail;
dot11dev->rx_datasize = tuint;
tmac = mac_addr((*proto_parsed)[fnum++].word.c_str());
if (tmac.error)
goto proto_fail;
tmac.SetPhy(phyid);
dot11dev->last_bssid = tmac;
dot11dev->dhcp_host = (*proto_parsed)[fnum++].word;
dot11dev->dhcp_vendor = (*proto_parsed)[fnum++].word;
dot11dev->eap_id = (*proto_parsed)[fnum++].word;
if (dot11dev_new) {
// _MSG("Got new dot11 device for " + device->key.Mac2String(), MSGFLAG_INFO);
device->insert(devcomp_ref_dot11, dot11dev);
}
return;
proto_fail:
_MSG("PHYDOT11 failed to process *DOT11DEVICE", MSGFLAG_ERROR);
if (dot11dev_new) {
delete(dot11dev);
}
return;
}
void Client_Phy80211::Proto_DOT11CLIENT(CLIPROTO_CB_PARMS) {
if ((int) proto_parsed->size() < proto_dot11client_fields_num)
return;
int fnum = 0;
unsigned int tuint;
unsigned long tulong;
mac_addr cmac, dmac;
cmac = mac_addr((*proto_parsed)[fnum++].word.c_str());
if (cmac.error) {
return;
}
cmac.SetPhy(phyid);
dmac = mac_addr((*proto_parsed)[fnum++].word.c_str());
if (dmac.error) {
return;
}
dmac.SetPhy(phyid);
kis_tracked_device *device =
devicetracker->FetchDevice(dmac);
if (device == NULL)
return;
dot11_device *dot11dev =
(dot11_device *) device->fetch(devcomp_ref_dot11);
if (dot11dev == NULL) {
return;
}
bool dot11cli_new = false;
dot11_client *dot11cli = NULL;
map<mac_addr, dot11_client *>::iterator cmi =
dot11dev->client_map.find(cmac);
if (cmi == dot11dev->client_map.end()) {
dot11cli = new dot11_client();
dot11cli_new = true;
} else {
dot11cli = cmi->second;
}
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11cli->first_time = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11cli->last_time = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11cli->decrypted = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%lu", &tulong) != 1)
goto proto_fail;
dot11cli->tx_cryptset = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%lu", &tulong) != 1)
goto proto_fail;
dot11cli->rx_cryptset = tuint;
dot11cli->lastssid_str = (*proto_parsed)[fnum++].word;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%u", &tuint) != 1)
goto proto_fail;
dot11cli->lastssid_csum = tuint;
dot11cli->cdp_dev_id = (*proto_parsed)[fnum++].word;
dot11cli->cdp_port_id = (*proto_parsed)[fnum++].word;
dot11cli->dhcp_host = (*proto_parsed)[fnum++].word;
dot11cli->dhcp_vendor = (*proto_parsed)[fnum++].word;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%lu", &tulong) != 1)
goto proto_fail;
dot11cli->tx_datasize = tuint;
if (sscanf((*proto_parsed)[fnum++].word.c_str(), "%lu", &tulong) != 1)
goto proto_fail;
dot11cli->rx_datasize = tuint;
dot11cli->manuf = (*proto_parsed)[fnum++].word;
dot11cli->eap_id = (*proto_parsed)[fnum++].word;
if (dot11cli_new) {
dot11dev->client_map[cmac] = dot11cli;
}
return;
proto_fail:
_MSG("PHYDOT11 failed to process *DOT11CLIENT", MSGFLAG_ERROR);
if (dot11cli_new)
delete dot11cli;
}
string Client_Phy80211::Dot11Column(kdl_display_device *in_dev, int columnid,
bool header) {
char hdr[16];
char buf[64];
kdl_column *col = NULL;
dot11_device *dot11dev = NULL;
col = devicelist->FetchColumn(columnid);
if (col == NULL)
return "[INVALID]";
if (col->alignment == LABEL_POS_LEFT)
snprintf(hdr, 16, "%%%ds", col->width);
else
snprintf(hdr, 16, "%%-%d.%ds", col->width, col->width);
snprintf(buf, 64, hdr, "Unk");
if (!header) {
if (in_dev != NULL && in_dev->device != NULL)
dot11dev =
(dot11_device *) in_dev->device->fetch(devcomp_ref_dot11);
if (dot11dev == NULL) {
snprintf(buf, 64, hdr, "---");
return buf;
}
}
if (columnid == col_dot11d) {
if (header) {
snprintf(buf, 64, hdr, "11d");
} else {
if (dot11dev->lastssid == NULL)
snprintf(buf, 64, hdr, "---");
else if (dot11dev->lastssid->dot11d_country == "")
snprintf(buf, 64, hdr, "---");
else
snprintf(buf, 64, hdr, dot11dev->lastssid->dot11d_country.c_str());
}
} else if (columnid == col_sub_lastssid) {
if (dot11dev->lastssid == NULL)
return "";
if (dot11dev->lastssid->ssid == "") {
if (dot11dev->lastssid->type == dot11_ssid_probereq) {
snprintf(buf, 64, "{Broadcast probe}");
} else {
snprintf(buf, 64, "{Unknown, cloaked}");
}
} else {
snprintf(buf, 64, "%s", dot11dev->lastssid->ssid.c_str());
}
}
return buf;
}
void Client_Phy80211::PanelDetails(Kis_DevDetails_Panel *in_panel,
kis_tracked_device *in_dev) {
// Nothing special to set up for dot11 networks in the panel
}
string Dot11CryptToString(uint64_t cryptset) {
string ret;
if (cryptset == crypt_none)
return "none";
if (cryptset == crypt_unknown)
return "unknown";
if (cryptset & crypt_wps)
ret = "WPS";
if ((cryptset & crypt_protectmask) == crypt_wep)
return StringAppend(ret, "WEP");
if (cryptset & crypt_wpa)
ret = StringAppend(ret, "WPA");
if (cryptset & crypt_psk)
ret = StringAppend(ret, "WPA-PSK");
if (cryptset & crypt_eap)
ret = StringAppend(ret, "EAP");
if (cryptset & crypt_peap)
ret = StringAppend(ret, "WPA-PEAP");
if (cryptset & crypt_leap)
ret = StringAppend(ret, "WPA-LEAP");
if (cryptset & crypt_ttls)
ret = StringAppend(ret, "WPA-TTLS");
if (cryptset & crypt_tls)
ret = StringAppend(ret, "WPA-TLS");
if (cryptset & crypt_wpa_migmode)
ret = StringAppend(ret, "WPA-MIGRATION");
if (cryptset & crypt_wep40)
ret = StringAppend(ret, "WEP40");
if (cryptset & crypt_wep104)
ret = StringAppend(ret, "WEP104");
if (cryptset & crypt_tkip)
ret = StringAppend(ret, "TKIP");
if (cryptset & crypt_aes_ocb)
ret = StringAppend(ret, "AES-OCB");
if (cryptset & crypt_aes_ccm)
ret = StringAppend(ret, "AES-CCMP");
if (cryptset & crypt_layer3)
ret = StringAppend(ret, "Layer 3");
if (cryptset & crypt_isakmp)
ret = StringAppend(ret, "ISA KMP");
if (cryptset & crypt_pptp)
ret = StringAppend(ret, "PPTP");
if (cryptset & crypt_fortress)
ret = StringAppend(ret, "Fortress");
if (cryptset & crypt_keyguard)
ret = StringAppend(ret, "Keyguard");
if (cryptset & crypt_unknown_protected)
ret = StringAppend(ret, "L3/Unknown");
if (cryptset & crypt_unknown_nonwep)
ret = StringAppend(ret, "Non-WEP/Unknown");
return ret;
}
void Client_Phy80211::PanelDetailsText(Kis_Free_Text *in_textbox,
kis_tracked_device *in_dev) {
dot11_device *dot11device =
(dot11_device *) in_dev->fetch(devcomp_ref_dot11);
if (dot11device == NULL)
return;
vector<string> td;
td.push_back("");
string typehdr = "802.11 type: ";
if (dot11device->type_set & dot11_network_ap) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Access Point");
typehdr = "";
}
if (dot11device->type_set & dot11_network_adhoc) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Ad-Hoc");
typehdr = "";
}
if (dot11device->type_set & dot11_network_client) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Client");
typehdr = "";
}
if (dot11device->type_set & dot11_network_wired) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Wired");
typehdr = "";
}
if (dot11device->type_set & dot11_network_wds) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "WDS");
typehdr = "";
}
if (dot11device->type_set & dot11_network_turbocell) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Turbocell");
typehdr = "";
}
if (dot11device->type_set & dot11_network_inferred) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Inferred");
typehdr = "";
}
if (dot11device->ssid_map.size() > 0) {
td.push_back("");
td.push_back(AlignString("", ' ', 2, 16) +
IntToString(dot11device->ssid_map.size()) +
" advertised SSIDs");
td.push_back("");
for (map<uint32_t, dot11_ssid *>::iterator s = dot11device->ssid_map.begin();
s != dot11device->ssid_map.end(); ++s) {
if (s->second->ssid == "") {
if (s->second->type == dot11_ssid_probereq)
td.push_back(AlignString("SSID: ", ' ', 2, 16) +
"Broadcast/Any");
else
td.push_back(AlignString("SSID: ", ' ', 2, 16) +
"Cloaked/Hidden");
} else {
td.push_back(AlignString("SSID: ", ' ', 2, 16) +
s->second->ssid);
}
if (s->second->ssid_cloaked) {
td.push_back(AlignString("", ' ', 2, 16) + "[SSID is cloaked]");
}
td.push_back(AlignString("First time: ", ' ', 2, 16) +
string(ctime((const time_t *)
&(s->second->first_time)) + 4).substr(0, 15));
td.push_back(AlignString("Last time: ", ' ', 2, 16) +
string(ctime((const time_t *)
&(s->second->last_time)) + 4).substr(0, 15));
if (s->second->type == dot11_ssid_beacon) {
td.push_back(AlignString("SSID type: ", ' ', 2, 16) +
"Beaconing/Advertised");
} else if (s->second->type == dot11_ssid_proberesp) {
td.push_back(AlignString("SSID type: ", ' ', 2, 16) +
"Response");
} else if (s->second->type == dot11_ssid_probereq) {
td.push_back(AlignString("SSID type: ", ' ', 2, 16) +
"Probe/Query");
}
if (s->second->beacon_info != "") {
td.push_back(AlignString("Extended info: ", ' ', 2, 16) +
s->second->beacon_info);
}
td.push_back(AlignString("Encryption: ", ' ', 2, 16) +
Dot11CryptToString(s->second->cryptset));
if (s->second->beaconrate) {
td.push_back(AlignString("Beacon rate: ", ' ', 2, 16) +
IntToString(s->second->beaconrate));
}
if (s->second->channel) {
td.push_back(AlignString("Channel: ", ' ', 2, 16) +
IntToString(s->second->channel));
}
if (s->second->dot11d_country != "") {
td.push_back(AlignString("Country: ", ' ', 2, 16) +
s->second->dot11d_country);
}
td.push_back("");
}
}
td.push_back("");
bool cdp = false;
if (dot11device->cdp_dev_id != "") {
td.push_back(AlignString("CDP device: ", ' ', 2, 16) +
dot11device->cdp_dev_id);
cdp = true;
}
if (dot11device->cdp_port_id != "") {
td.push_back(AlignString("CDP port: ", ' ', 2, 16) +
dot11device->cdp_port_id);
cdp = true;
}
if (cdp)
td.push_back("");
td.push_back(AlignString("Fragments: ", ' ', 2, 16) +
UIntToString(dot11device->fragments));
td.push_back(AlignString("Retries: ", ' ', 2, 16) +
UIntToString(dot11device->retries));
td.push_back("");
bool dhcp = false;
if (dot11device->dhcp_host != "") {
td.push_back(AlignString("DHCP host: ", ' ', 2, 16) +
dot11device->dhcp_host);
dhcp = true;
}
if (dot11device->dhcp_vendor != "") {
td.push_back(AlignString("DHCP vendor: ", ' ' , 2, 16) +
dot11device->dhcp_vendor);
dhcp = true;
}
if (dhcp)
td.push_back("");
if (dot11device->eap_id != "") {
td.push_back(AlignString("EAP ID: ", ' ', 2, 16) +
dot11device->eap_id);
td.push_back("");
}
for (map<mac_addr, dot11_client *>::iterator c = dot11device->client_map.begin();
c != dot11device->client_map.end(); ++c) {
td.push_back("");
typehdr = "Client type: ";
if (c->second->type & dot11_network_ap) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Access Point");
typehdr = "";
}
if (c->second->type & dot11_network_adhoc) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Ad-Hoc");
typehdr = "";
}
if (c->second->type & dot11_network_client) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Client");
typehdr = "";
}
if (c->second->type & dot11_network_wired) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Wired");
typehdr = "";
}
if (c->second->type & dot11_network_wds) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "WDS");
typehdr = "";
}
if (c->second->type & dot11_network_turbocell) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Turbocell");
typehdr = "";
}
if (c->second->type & dot11_network_inferred) {
td.push_back(AlignString(typehdr, ' ', 2, 16) + "Inferred");
typehdr = "";
}
td.push_back(AlignString("Client MAC: ", ' ', 2, 16) +
c->second->mac.Mac2String());
td.push_back(AlignString("First time: ", ' ', 2, 16) +
string(ctime((const time_t *)
&(c->second->first_time)) + 4).substr(0, 15));
td.push_back(AlignString("Last time: ", ' ', 2, 16) +
string(ctime((const time_t *)
&(c->second->last_time)) + 4).substr(0, 15));
if (c->second->cdp_dev_id != "")
td.push_back(AlignString("CDP device: ", ' ', 2, 16) +
c->second->cdp_dev_id);
if (c->second->cdp_port_id != "")
td.push_back(AlignString("CDP port: ", ' ', 2, 16) +
c->second->cdp_port_id);
if (c->second->dhcp_host != "")
td.push_back(AlignString("DHCP host: ", ' ', 2, 16) +
c->second->dhcp_host);
if (c->second->dhcp_vendor != "")
td.push_back(AlignString("DHCP vendor: ", ' ', 2, 16) +
c->second->dhcp_vendor);
td.push_back(AlignString("Manuf: ", ' ', 2, 16) +
c->second->manuf);
}
in_textbox->AppendText(td);
}
| 26.752941 | 104 | 0.647713 | [
"vector"
] |
d69b549c46b177667a125fcae1f3cb6f65344d2c | 577 | cpp | C++ | ports/www/chromium-legacy/newport/files/patch-third__party_angle_src_gpu__info__util_SystemInfo__linux.cpp | danielfojt/DeltaPorts | 5710b4af4cacca5eb1ac577df304c788c07c4217 | [
"BSD-2-Clause-FreeBSD"
] | 1 | 2022-02-08T02:24:08.000Z | 2022-02-08T02:24:08.000Z | ports/www/chromium-legacy/newport/files/patch-third__party_angle_src_gpu__info__util_SystemInfo__linux.cpp | danielfojt/DeltaPorts | 5710b4af4cacca5eb1ac577df304c788c07c4217 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | ports/www/chromium-legacy/newport/files/patch-third__party_angle_src_gpu__info__util_SystemInfo__linux.cpp | danielfojt/DeltaPorts | 5710b4af4cacca5eb1ac577df304c788c07c4217 | [
"BSD-2-Clause-FreeBSD"
] | null | null | null | --- third_party/angle/src/gpu_info_util/SystemInfo_linux.cpp.orig 2019-03-11 22:07:59 UTC
+++ third_party/angle/src/gpu_info_util/SystemInfo_linux.cpp
@@ -71,10 +71,18 @@ bool GetPCIDevicesWithLibPCI(std::vector<GPUDeviceInfo
bool GetSystemInfo(SystemInfo *info)
{
+#if defined(__FreeBSD__)
+ if (!CollectMesaCardInfo(&(info->gpus)))
+ {
+ if (!GetPCIDevicesFreeBSD(&(info->gpus)))
+ return false;
+ }
+#else
if (!GetPCIDevicesWithLibPCI(&(info->gpus)))
{
return false;
}
+#endif
if (info->gpus.size() == 0)
{
| 26.227273 | 89 | 0.639515 | [
"vector"
] |
d6a1c1ba516e99426ddfbff985597c0bd3ee47f6 | 475 | cpp | C++ | 705-design-hashset/705-design-hashset.cpp | arpangoswami/LeetcodeSolutions | 17a2450cacf0020c2626023012a5a354c8fee5da | [
"MIT"
] | null | null | null | 705-design-hashset/705-design-hashset.cpp | arpangoswami/LeetcodeSolutions | 17a2450cacf0020c2626023012a5a354c8fee5da | [
"MIT"
] | null | null | null | 705-design-hashset/705-design-hashset.cpp | arpangoswami/LeetcodeSolutions | 17a2450cacf0020c2626023012a5a354c8fee5da | [
"MIT"
] | null | null | null | class MyHashSet {
vector<bool> v;
public:
MyHashSet() {
v.resize(1e6+1,false);
}
void add(int key) {
v[key] = true;
}
void remove(int key) {
v[key] = false;
}
bool contains(int key) {
return v[key];
}
};
/**
* Your MyHashSet object will be instantiated and called as such:
* MyHashSet* obj = new MyHashSet();
* obj->add(key);
* obj->remove(key);
* bool param_3 = obj->contains(key);
*/ | 17.592593 | 65 | 0.530526 | [
"object",
"vector"
] |
d6a2d923adb07f421d6fc0394ba1b773dc1c4c89 | 635 | cpp | C++ | triplets with sum greater than 1 and smaller than 2.cpp | nandani99/Hacktoberfest-1 | 83cdd9f6b5538fa266d0617d53409852111c89b5 | [
"MIT"
] | null | null | null | triplets with sum greater than 1 and smaller than 2.cpp | nandani99/Hacktoberfest-1 | 83cdd9f6b5538fa266d0617d53409852111c89b5 | [
"MIT"
] | null | null | null | triplets with sum greater than 1 and smaller than 2.cpp | nandani99/Hacktoberfest-1 | 83cdd9f6b5538fa266d0617d53409852111c89b5 | [
"MIT"
] | null | null | null | int tiplets_with_sum(vector<string> &A) {
//triplets with sum between 1 and 2
vector<float>v;
for(int i=0;i<A.size();i++){
v.push_back(stof(A[i]));
}
sort(v.begin(),v.end());
int i=0;
int j=v.size()-1;
int k=i+1;
if(v[0]>=2){
return 0;
}
while(i<j&&k<j){
float sum = v[i]+v[j]+v[k];
if(sum>1&&sum<2){
return 1;
}
else{
if(sum<=1){
i++;
k++;
}
else if(sum>=2){
j--;
}
}
}
return 0;
}
| 19.84375 | 42 | 0.344882 | [
"vector"
] |
d6a4b18f001f714f589de50e66e11c99de5b21c1 | 12,131 | hh | C++ | Ghidra/Features/Decompiler/src/decompile/cpp/flow.hh | sigurasg/ghidra | ee268dea09d8f2632d73b0d00cdda3a377a744e1 | [
"Apache-2.0"
] | 115 | 2020-04-29T22:58:59.000Z | 2022-03-21T05:42:12.000Z | Ghidra/Features/Decompiler/src/decompile/cpp/flow.hh | sigurasg/ghidra | ee268dea09d8f2632d73b0d00cdda3a377a744e1 | [
"Apache-2.0"
] | 12 | 2021-05-25T05:06:50.000Z | 2021-10-13T04:35:50.000Z | Ghidra/Features/Decompiler/src/decompile/cpp/flow.hh | sigurasg/ghidra | ee268dea09d8f2632d73b0d00cdda3a377a744e1 | [
"Apache-2.0"
] | 19 | 2020-04-29T12:29:46.000Z | 2022-03-10T02:41:17.000Z | /* ###
* IP: GHIDRA
*
* 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.
*/
/// \file flow.hh
/// \brief Utilities for following control-flow in p-code generated from machine instructions
#ifndef __CPUI_FLOW__
#define __CPUI_FLOW__
#include "funcdata.hh"
/// \brief A class for generating the control-flow structure for a single function
///
/// Control-flow for the function is generated in two phases: the method generateOps() produces
/// all the raw p-code ops for the function, and the method generateBlocks() organizes the
/// p-code ops into basic blocks (PcodeBlockBasic).
/// In generateOps(), p-code is generated for every machine instruction that is reachable starting
/// with the entry point address of the function. All possible flow is followed, trimming flow
/// at instructions that end with the formal RETURN p-code operation. CALL and CALLIND are treated
/// as fall-through operations, and flow is not followed into the sub-function.
///
/// The class supports various options for handling corner cases during the flow following process,
/// including how to handle:
/// - Flow out of range (specified by setRange())
/// - Flow into unimplemened instructions
/// - Flow into unaccessible data
/// - Flow into previously traversed data at an \e off cut (\b reinterpreted data)
/// - Flow that (seemingly) doesn't end, exceeding a threshold on the number of instructions
///
/// In generateBlocks(), all previously generated PcodeOp instructions are assigned to a
/// PcodeBlockBasic. These objects define the formal basic block structure of the function.
/// Directed control-flow edges between the blocks are created at this time based on the
/// flow of p-code.
///
/// A Funcdata object provided to the constructor holds:
/// - The generated PcodeOp objects (within its PcodeOpBank).
/// - The control-flow graph (within its BlockGraph)
/// - The list of discovered sub-function calls (as FuncCallSpec objects)
///
/// The Translate object (provided by the Architecture owning the function) generates
/// the raw p-code ops for a single instruction. This FlowInfo class also handles
/// p-code \e injection triggers encountered during flow following, primarily using
/// the architecture's PcodeInjectLibrary to resolve them.
class FlowInfo {
public:
enum { ignore_outofbounds = 1, ///< Ignore/truncate flow into addresses out of the specified range
ignore_unimplemented = 2, ///< Treat unimplemented instructions as a NOP (no operation)
error_outofbounds = 4, ///< Throw an exception for flow into addresses out of the specified range
error_unimplemented = 8, ///< Throw an exception for flow into unimplemented instructions
error_reinterpreted = 0x10, ///< Throw an exception for flow into previously encountered data at a difference \e cut
error_toomanyinstructions = 0x20, ///< Throw an exception if too many instructions are encountered
unimplemented_present = 0x40, ///< Indicate we have encountered unimplemented instructions
baddata_present = 0x80, ///< Indicate we have encountered flow into unaccessible data
outofbounds_present = 0x100, ///< Indicate we have encountered flow out of the specified range
reinterpreted_present = 0x200, ///< Indicate we have encountered reinterpreted data
toomanyinstructions_present = 0x400, ///< Indicate the maximum instruction threshold was reached
possible_unreachable = 0x1000, ///< Indicate a CALL was converted to a BRANCH and some code may be unreachable
flow_forinline = 0x2000, ///< Indicate flow is being generated to in-line (a function)
record_jumploads = 0x4000 ///< Indicate that any jump table recovery should record the table structure
};
private:
/// \brief A helper function describing the number of bytes in a machine instruction and the starting p-code op
struct VisitStat {
SeqNum seqnum; ///< Sequence number of first PcodeOp in the instruction (or INVALID if no p-code)
int4 size; ///< Number of bytes in the instruction
};
Architecture *glb; ///< Owner of the function
Funcdata &data; ///< The function being flow-followed
PcodeOpBank &obank; ///< Container for generated p-code
BlockGraph &bblocks; ///< Container for the control-flow graph
vector<FuncCallSpecs *> &qlst; ///< The list of discovered sub-function call sites
PcodeEmitFd emitter; ///< PCodeOp factory (configured to allocate into \b data and \b obank)
vector<Address> unprocessed; ///< Addresses which are permanently unprocessed
vector<Address> addrlist; ///< Addresses to which there is flow
vector<PcodeOp *> tablelist; ///< List of BRANCHIND ops (preparing for jump table recovery)
vector<PcodeOp *> injectlist; ///< List of p-code ops that need injection
map<Address,VisitStat> visited; ///< Map of machine instructions that have been visited so far
list<PcodeOp *> block_edge1; ///< Source p-code op (Edges between basic blocks)
list<PcodeOp *> block_edge2; ///< Destination p-code op (Edges between basic blocks)
uint4 insn_count; ///< Number of instructions flowed through
uint4 insn_max; ///< Maximum number of instructions
Address baddr; ///< Start of range in which we are allowed to flow
Address eaddr; ///< End of range in which we are allowed to flow
Address minaddr; ///< Start of actual function range
Address maxaddr; ///< End of actual function range
bool flowoverride_present; ///< Does the function have registered flow override instructions
uint4 flags; ///< Boolean options for flow following
Funcdata *inline_head; ///< First function in the in-lining chain
set<Address> *inline_recursion; ///< Active list of addresses for function that are in-lined
set<Address> inline_base; ///< Storage for addresses of functions that are in-lined
bool hasPossibleUnreachable(void) const { return ((flags & possible_unreachable)!=0); } ///< Are there possible unreachable ops
void setPossibleUnreachable(void) { flags |= possible_unreachable; } ///< Mark that there may be unreachable ops
void clearProperties(void); ///< Clear any discovered flow properties
bool seenInstruction(const Address &addr) const {
return (visited.find(addr) != visited.end()); } ///< Has the given instruction (address) been seen in flow
PcodeOp *fallthruOp(PcodeOp *op) const; ///< Find fallthru pcode-op for given op
void newAddress(PcodeOp *from,const Address &to); ///< Register a new (non fall-thru) flow target
void deleteRemainingOps(list<PcodeOp *>::const_iterator oiter);
PcodeOp *xrefControlFlow(list<PcodeOp *>::const_iterator oiter,bool &startbasic,bool &isfallthru,FuncCallSpecs *fc);
bool processInstruction(const Address &curaddr,bool &startbasic);
void fallthru(void); ///< Process (the next) sequence of instructions in fall-thru order
PcodeOp *findRelTarget(PcodeOp *op,Address &res) const;
void findUnprocessed(void); ///< Add any remaining un-followed addresses to the \b unprocessed list
void dedupUnprocessed(void); ///< Get rid of duplicates in the \b unprocessed list
void fillinBranchStubs(void); ///< Fill-in artificial HALT p-code for \b unprocessed addresses
void collectEdges(void); ///< Collect edges between basic blocks as PcodeOp to PcodeOp pairs
void splitBasic(void); ///< Split raw p-code ops up into basic blocks
void connectBasic(void); ///< Generate edges between basic blocks
bool setFallthruBound(Address &bound); ///< Find end of the next unprocessed region
void handleOutOfBounds(const Address &fromaddr,const Address &toaddr);
PcodeOp *artificialHalt(const Address &addr,uint4 flag); ///< Create an artificial halt p-code op
void reinterpreted(const Address &addr); ///< Generate warning message or exception for a \e reinterpreted address
bool checkForFlowModification(FuncCallSpecs &fspecs);
void queryCall(FuncCallSpecs &fspecs); ///< Try to recover the Funcdata object corresponding to a given call
bool setupCallSpecs(PcodeOp *op,FuncCallSpecs *fc); ///< Set up the FuncCallSpecs object for a new call site
bool setupCallindSpecs(PcodeOp *op,bool tryoverride,FuncCallSpecs *fc);
void xrefInlinedBranch(PcodeOp *op); ///< Check for control-flow in a new injected p-code op
void doInjection(InjectPayload *payload,InjectContext &icontext,PcodeOp *op,FuncCallSpecs *fc);
void injectUserOp(PcodeOp *op); ///< Perform \e injection for a given user-defined p-code op
bool inlineSubFunction(FuncCallSpecs *fc); ///< In-line the sub-function at the given call site
bool injectSubFunction(FuncCallSpecs *fc); ///< Perform \e injection replacing the CALL at the given call site
void checkContainedCall(void);
void checkMultistageJumptables(void);
void deleteCallSpec(FuncCallSpecs *fc); ///< Remove the given call site from the list for \b this function
void truncateIndirectJump(PcodeOp *op,int4 failuremode); ///< Treat indirect jump as indirect call that never returns
static bool isInArray(vector<PcodeOp *> &array,PcodeOp *op);
public:
FlowInfo(Funcdata &d,PcodeOpBank &o,BlockGraph &b,vector<FuncCallSpecs *> &q); ///< Constructor
FlowInfo(Funcdata &d,PcodeOpBank &o,BlockGraph &b,vector<FuncCallSpecs *> &q,const FlowInfo *op2); ///< Cloning constructor
void setRange(const Address &b,const Address &e) { baddr = b; eaddr = e; } ///< Establish the flow bounds
void setMaximumInstructions(uint4 max) { insn_max = max; } ///< Set the maximum number of instructions
void setFlags(uint4 val) { flags |= val; } ///< Enable a specific option
void clearFlags(uint4 val) { flags &= ~val; } ///< Disable a specific option
PcodeOp *target(const Address &addr) const; ///< Return first p-code op for instruction at given address
PcodeOp *branchTarget(PcodeOp *op) const; ///< Find the target referred to by a given BRANCH or CBRANCH
void generateOps(void); ///< Generate raw control-flow from the function's base address
void generateBlocks(void); ///< Generate basic blocks from the raw control-flow
bool testHardInlineRestrictions(Funcdata *inlinefd,PcodeOp *op,Address &retaddr);
bool checkEZModel(void) const; ///< Check if \b this flow matches the EX in-lining model
void injectPcode(void); ///< Perform substitution on any op that requires \e injection
void forwardRecursion(const FlowInfo &op2); ///< Pull in-lining recursion information from another flow
void inlineClone(const FlowInfo &inlineflow,const Address &retaddr);
void inlineEZClone(const FlowInfo &inlineflow,const Address &calladdr);
int4 getSize(void) const { return (int4)(maxaddr.getOffset() - minaddr.getOffset()); } ///< Get the number of bytes covered by the flow
bool hasInject(void) const { return !injectlist.empty(); } ///< Does \b this flow have injections
bool hasUnimplemented(void) const { return ((flags & unimplemented_present)!=0); } ///< Does \b this flow have unimiplemented instructions
bool hasBadData(void) const { return ((flags & baddata_present)!=0); } ///< Does \b this flow reach inaccessible data
bool hasOutOfBounds(void) const { return ((flags & outofbounds_present)!=0); } ///< Does \b this flow out of bound
bool hasReinterpreted(void) const { return ((flags & reinterpreted_present)!=0); } ///< Does \b this flow reinterpret bytes
bool hasTooManyInstructions(void) const { return ((flags & toomanyinstructions_present)!=0); } ///< Does \b this flow have too many instructions
bool isFlowForInline(void) const { return ((flags & flow_forinline)!=0); } ///< Is \b this flow to be in-lined
bool doesJumpRecord(void) const { return ((flags & record_jumploads)!=0); } ///< Should jump table structure be recorded
};
#endif
| 72.208333 | 146 | 0.74289 | [
"object",
"vector",
"model"
] |
d6aa1a9eca669f4b78b3032cb3ba9aa24ceb663d | 822 | cpp | C++ | origin/sequence/range.test/reference_of.cpp | asutton/origin-google | 516482c081a357a06402e5f288d645d3e18f69fa | [
"MIT"
] | 7 | 2017-11-22T19:11:00.000Z | 2020-08-16T15:53:10.000Z | origin/sequence/range.test/reference_of.cpp | asutton/origin-google | 516482c081a357a06402e5f288d645d3e18f69fa | [
"MIT"
] | null | null | null | origin/sequence/range.test/reference_of.cpp | asutton/origin-google | 516482c081a357a06402e5f288d645d3e18f69fa | [
"MIT"
] | 1 | 2020-08-07T12:31:36.000Z | 2020-08-07T12:31:36.000Z | // Copyright (c) 2008-2010 Kent State University
// Copyright (c) 2011-2012 Texas A&M University
//
// This file is distributed under the MIT License. See the accompanying file
// LICENSE.txt or http://www.opensource.org/licenses/mit-license.php for terms
// and conditions.
#include <iostream>
#include <iterator>
#include <vector>
#include <origin/sequence/range.hpp>
#include <origin/type/typestr.hpp>
using namespace std;
using namespace origin;
// Check that the Reference_of can be applied to all kinds of ranges.
int main()
{
using V = vector<int>;
static_assert(Same<Reference_of<V>, V::reference>(), "");
static_assert(Same<Reference_of<const V>, V::const_reference>(), "");
using I = istream_iterator<int>;
using B = bounded_range<I>;
static_assert(Same<Reference_of<B>, const int&>(), "");
}
| 26.516129 | 78 | 0.721411 | [
"vector"
] |
d6aea9d1360c5ffbf26ee18e4b331be1ab9dae15 | 1,233 | cpp | C++ | PETCS/Advanced/sssp_spfa.cpp | dl4us/Competitive-Programming-1 | d42fab3bd68168adbe4b5f594f19ee5dfcd1389b | [
"MIT"
] | null | null | null | PETCS/Advanced/sssp_spfa.cpp | dl4us/Competitive-Programming-1 | d42fab3bd68168adbe4b5f594f19ee5dfcd1389b | [
"MIT"
] | null | null | null | PETCS/Advanced/sssp_spfa.cpp | dl4us/Competitive-Programming-1 | d42fab3bd68168adbe4b5f594f19ee5dfcd1389b | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
const int MAX = 1005;
const int INF = 0x3f3f3f3f;
int N, M, S, T, dist[MAX]; vector<pair<int, int>> adj[MAX];
int spfa(int s, int t) {
fill(dist, dist+MAX, INF);
dist[s] = 0;
deque<int> q;
q.push_back(s);
while(!q.empty()) {
auto u = q.front(); q.pop_front();
for(auto &e : adj[u]) {
int v = e.first;
int w = e.second;
int d = dist[u] + w;
if(d < dist[v]) {
dist[v] = d;
if(find(q.begin(), q.end(), v) == q.end()) {
q.push_back(v);
}
}
}
}
return dist[t];
}
int main() {
cin.tie(0)->sync_with_stdio(0);
#ifndef ONLINE_JUDGE
freopen("../../input.txt", "r", stdin);
freopen("../../output.txt", "w", stdout);
#endif
cin >> N >> M;
for(int i = 0, u, v, w; i < M; i++) {
cin >> u >> v >> w;
adj[u].push_back({v, w});
}
int dis = spfa(1, N);
if(dis == INF) {
cout << "No path" << "\n";
} else if(dis == -1) {
cout << "negative weight" << "\n";
} else {
cout << 1 << " to " << N << ": " << dis << "\n";
}
return 0;
}
| 25.6875 | 60 | 0.418491 | [
"vector"
] |
d6b0295ae2786f6b3491ba658fb8482bc2109386 | 20,183 | cpp | C++ | src/providers/grass/qgsgrassvectormap.cpp | dyna-mis/Hilabeling | cb7d5d4be29624a20c8a367162dbc6fd779b2b52 | [
"MIT"
] | null | null | null | src/providers/grass/qgsgrassvectormap.cpp | dyna-mis/Hilabeling | cb7d5d4be29624a20c8a367162dbc6fd779b2b52 | [
"MIT"
] | null | null | null | src/providers/grass/qgsgrassvectormap.cpp | dyna-mis/Hilabeling | cb7d5d4be29624a20c8a367162dbc6fd779b2b52 | [
"MIT"
] | 1 | 2021-12-25T08:40:30.000Z | 2021-12-25T08:40:30.000Z | /***************************************************************************
qgsgrassvectormap.cpp
-------------------
begin : September, 2015
copyright : (C) 2015 by Radim Blazek
email : radim.blazek@gmail.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <QFileInfo>
#include <QMessageBox>
#include "qgslinestring.h"
#include "qgspolygon.h"
#include "qgspoint.h"
#include "qgslogger.h"
#include "qgsgeometry.h"
#include "qgsgrass.h"
#include "qgsgrassvectormap.h"
#include "qgsgrassvectormaplayer.h"
#include "qgsgrassundocommand.h"
extern "C"
{
#include <grass/version.h>
#if defined(_MSC_VER) && defined(M_PI_4)
#undef M_PI_4 //avoid redefinition warning
#endif
#include <grass/gprojects.h>
#include <grass/gis.h>
#include <grass/dbmi.h>
#include <grass/vector.h>
}
QgsGrassVectorMap::QgsGrassVectorMap( const QgsGrassObject &grassObject )
: mGrassObject( grassObject )
, mValid( false )
, mOpen( false )
, mFrozen( false )
, mIsEdited( false )
, mVersion( 0 )
, mIs3d( false )
, mOldNumLines( 0 )
{
QgsDebugMsg( "grassObject = " + grassObject.toString() );
openMap();
mOpen = true;
}
QgsGrassVectorMap::~QgsGrassVectorMap()
{
QgsDebugMsg( "grassObject = " + mGrassObject.toString() );
// TODO close
QgsGrass::vectDestroyMapStruct( mMap );
}
int QgsGrassVectorMap::userCount() const
{
int count = 0;
const auto constMLayers = mLayers;
for ( QgsGrassVectorMapLayer *layer : constMLayers )
{
count += layer->userCount();
}
QgsDebugMsg( QString( "count = %1" ).arg( count ) );
return count;
}
bool QgsGrassVectorMap::open()
{
QgsDebugMsg( toString() );
if ( mOpen )
{
QgsDebugMsg( "already open" );
return true;
}
lockOpenClose();
bool result = openMap();
mOpen = true;
unlockOpenClose();
return result;
}
void QgsGrassVectorMap::close()
{
QgsDebugMsg( toString() );
if ( !mOpen )
{
QgsDebugMsg( "is not open" );
return;
}
lockOpenClose();
closeAllIterators(); // blocking
closeMap();
mOpen = false;
unlockOpenClose();
}
bool QgsGrassVectorMap::openMap()
{
// TODO: refresh layers (reopen)
QgsDebugMsg( toString() );
QgsGrass::lock();
QgsGrass::setLocation( mGrassObject.gisdbase(), mGrassObject.location() );
// Find the vector
const char *ms = G_find_vector2( mGrassObject.name().toUtf8().constData(), mGrassObject.mapset().toUtf8().constData() );
if ( !ms )
{
QgsDebugMsg( "Cannot find GRASS vector" );
QgsGrass::unlock();
return false;
}
// Read the time of vector dir before Vect_open_old, because it may take long time (when the vector
// could be owerwritten)
QFileInfo di( mGrassObject.mapsetPath() + "/vector/" + mGrassObject.name() );
mLastModified = di.lastModified();
di.setFile( mGrassObject.mapsetPath() + "/vector/" + mGrassObject.name() + "/dbln" );
mLastAttributesModified = di.lastModified();
mMap = QgsGrass::vectNewMapStruct();
// Do we have topology and cidx (level2)
int level = -1;
G_TRY
{
Vect_set_open_level( 2 );
level = Vect_open_old_head( mMap, mGrassObject.name().toUtf8().constData(), mGrassObject.mapset().toUtf8().constData() );
Vect_close( mMap );
}
G_CATCH( QgsGrass::Exception & e )
{
QgsGrass::warning( e );
level = -1;
}
if ( level == -1 )
{
QgsDebugMsg( "Cannot open GRASS vector head" );
QgsGrass::unlock();
return false;
}
else if ( level == 1 )
{
QMessageBox::StandardButton ret = QMessageBox::question( nullptr, QStringLiteral( "Warning" ),
QObject::tr( "GRASS vector map %1 does not have topology. Build topology?" ).arg( mGrassObject.name() ),
QMessageBox::Ok | QMessageBox::Cancel );
if ( ret == QMessageBox::Cancel )
{
QgsGrass::unlock();
return false;
}
}
// Open vector
G_TRY
{
Vect_set_open_level( level );
Vect_open_old( mMap, mGrassObject.name().toUtf8().constData(), mGrassObject.mapset().toUtf8().constData() );
}
G_CATCH( QgsGrass::Exception & e )
{
QgsGrass::warning( QStringLiteral( "Cannot open GRASS vector: %1" ).arg( e.what() ) );
QgsGrass::unlock();
return false;
}
if ( level == 1 )
{
G_TRY
{
Vect_build( mMap );
}
G_CATCH( QgsGrass::Exception & e )
{
QgsGrass::warning( QStringLiteral( "Cannot build topology: %1" ).arg( e.what() ) );
QgsGrass::unlock();
return false;
}
}
QgsDebugMsg( "GRASS map successfully opened" );
mIs3d = Vect_is_3d( mMap );
QgsGrass::unlock();
mValid = true;
return true;
}
bool QgsGrassVectorMap::startEdit()
{
QgsDebugMsg( toString() );
lockOpenClose();
closeAllIterators(); // blocking
// TODO: Can it still happen? QgsGrassVectorMapStore singleton is used now.
#if 0
// Check number of maps (the problem may appear if static variables are not shared - runtime linker)
if ( mMaps.size() == 0 )
{
QMessageBox::warning( 0, "Warning", "No maps opened in mMaps, probably problem in runtime linking, "
"static variables are not shared by provider and plugin." );
return false;
}
#endif
/* Close map */
mValid = false;
QgsGrass::lock();
// Mapset must be set before Vect_close()
QgsGrass::setMapset( mGrassObject.gisdbase(), mGrassObject.location(), mGrassObject.mapset() );
int level = -1;
G_TRY
{
Vect_close( mMap );
Vect_set_open_level( 2 );
level = Vect_open_update( mMap, mGrassObject.name().toUtf8().constData(), mGrassObject.mapset().toUtf8().constData() );
if ( level < 2 )
{
QgsDebugMsg( "Cannot open GRASS vector for update on level 2." );
}
}
G_CATCH( QgsGrass::Exception & e )
{
Q_UNUSED( e );
QgsDebugMsg( QString( "Cannot open GRASS vector for update: %1" ).arg( e.what() ) );
}
if ( level < 2 )
{
// reopen vector for reading
G_TRY
{
Vect_set_open_level( 2 );
level = Vect_open_old( mMap, mGrassObject.name().toUtf8().constData(), mGrassObject.mapset().toUtf8().constData() );
if ( level < 2 )
{
QgsDebugMsg( QString( "Cannot reopen GRASS vector: %1" ).arg( QgsGrass::errorMessage() ) );
}
}
G_CATCH( QgsGrass::Exception & e )
{
Q_UNUSED( e );
QgsDebugMsg( QString( "Cannot reopen GRASS vector: %1" ).arg( e.what() ) );
}
if ( level >= 2 )
{
mValid = true;
}
QgsGrass::unlock();
unlockOpenClose();
return false;
}
Vect_set_category_index_update( mMap );
// Write history
Vect_hist_command( mMap );
mOldNumLines = Vect_get_num_lines( mMap );
QgsDebugMsg( QString( "Vector successfully reopened for update mOldNumLines = %1" ).arg( mOldNumLines ) );
mIsEdited = true;
mValid = true;
printDebug();
QgsGrass::unlock();
unlockOpenClose();
emit dataChanged();
return true;
}
bool QgsGrassVectorMap::closeEdit( bool newMap )
{
Q_UNUSED( newMap );
QgsDebugMsg( toString() );
if ( !mValid || !mIsEdited )
{
return false;
}
// mValid = false; // close() is checking mValid
lockOpenClose();
closeAllIterators(); // blocking
QgsGrass::lock();
mOldLids.clear();
mNewLids.clear();
mOldGeometries.clear();
mNewCats.clear();
clearUndoCommands();
// Mapset must be set before Vect_close()
QgsGrass::setMapset( mGrassObject.gisdbase(), mGrassObject.location(), mGrassObject.mapset() );
Vect_build_partial( mMap, GV_BUILD_NONE );
Vect_build( mMap );
// TODO?
#if 0
// If a new map was created close the map and return
if ( newMap )
{
QgsDebugMsg( QString( "mLayers.size() = %1" ).arg( mLayers.size() ) );
mUpdate = false;
// Map must be set as valid otherwise it is not closed and topo is not written
mValid = true;
// TODO refresh layers ?
//closeLayer( mLayerId );
QgsGrass::unlock();
unlockOpenClose();
return true;
}
#endif
mIsEdited = false;
QgsGrass::unlock();
closeAllIterators(); // blocking
closeMap();
openMap();
reloadLayers();
mVersion++;
unlockOpenClose();
emit dataChanged();
QgsDebugMsg( "edit closed" );
return mValid;
}
void QgsGrassVectorMap::clearUndoCommands()
{
for ( auto it = mUndoCommands.constBegin(); it != mUndoCommands.constEnd(); ++it )
{
const auto constValue = it.value();
for ( QgsGrassUndoCommand *command : constValue )
{
delete command;
}
}
mUndoCommands.clear();
}
QgsGrassVectorMapLayer *QgsGrassVectorMap::openLayer( int field )
{
QgsDebugMsg( QString( "%1 field = %2" ).arg( toString() ).arg( field ) );
// There are 2 locks on openLayer(), it must be locked when the map is being opened/closed/updated
// but that lock must not block closeLayer() because close/update map closes first all iterators
// which call closeLayer() and using single lock would result in dead lock.
lockOpenCloseLayer();
lockOpenClose();
QgsGrassVectorMapLayer *layer = nullptr;
// Check if this layer is already open
const auto constMLayers = mLayers;
for ( QgsGrassVectorMapLayer *l : constMLayers )
{
if ( l->field() == field )
{
QgsDebugMsg( "Layer exists" );
layer = l;
if ( layer->userCount() == 0 )
{
layer->load();
}
}
}
if ( !layer )
{
layer = new QgsGrassVectorMapLayer( this, field );
layer->load();
mLayers << layer;
}
layer->addUser();
unlockOpenClose();
unlockOpenCloseLayer();
return layer;
}
void QgsGrassVectorMap::reloadLayers()
{
const auto constMLayers = mLayers;
for ( QgsGrassVectorMapLayer *l : constMLayers )
{
l->load();
}
}
void QgsGrassVectorMap::closeLayer( QgsGrassVectorMapLayer *layer )
{
if ( !layer )
{
return;
}
QgsDebugMsg( QString( "Close layer %1 usersCount = %2" ).arg( toString() ).arg( layer->userCount() ) );
lockOpenCloseLayer();
layer->removeUser();
if ( layer->userCount() == 0 ) // No more users, free sources
{
QgsDebugMsg( "No more users -> clear" );
layer->clear();
}
QgsDebugMsg( QString( "%1 map users" ).arg( userCount() ) );
if ( userCount() == 0 )
{
QgsDebugMsg( "No more map users -> close" );
// Once was probably causing dead lock; move to QgsGrassVectorMapStore?
close();
}
QgsDebugMsg( "layer closed" );
unlockOpenCloseLayer();
}
void QgsGrassVectorMap::closeMap()
{
QgsDebugMsg( toString() );
QgsGrass::lock();
if ( !mValid )
{
QgsDebugMsg( "map is not valid" );
}
else
{
// Mapset must be set before Vect_close()
QgsGrass::setMapset( mGrassObject.gisdbase(), mGrassObject.location(), mGrassObject.mapset() );
G_TRY
{
Vect_close( mMap );
QgsDebugMsg( "map closed" );
}
G_CATCH( QgsGrass::Exception & e )
{
QgsDebugMsg( "Vect_close failed:" + QString( e.what() ) );
}
}
QgsGrass::vectDestroyMapStruct( mMap );
mMap = nullptr;
mOldNumLines = 0;
mValid = false;
QgsGrass::unlock();
}
void QgsGrassVectorMap::update()
{
QgsDebugMsg( toString() );
lockOpenClose();
closeAllIterators(); // blocking
closeMap();
openMap();
reloadLayers();
unlockOpenClose();
emit dataChanged();
}
bool QgsGrassVectorMap::mapOutdated()
{
QString dp = mGrassObject.mapsetPath() + "/vector/" + mGrassObject.name();
QFileInfo di( dp );
if ( mLastModified < di.lastModified() )
{
// If the cidx file has been deleted, the map is currently being modified
// by an external tool. Do not update until the cidx file has been recreated.
if ( !QFileInfo::exists( dp + "/cidx" ) )
{
QgsDebugMsg( "The map is being modified and is unavailable : " + mGrassObject.toString() );
return false;
}
QgsDebugMsg( "The map was modified : " + mGrassObject.toString() );
return true;
}
return false;
}
bool QgsGrassVectorMap::attributesOutdated()
{
QString dp = mGrassObject.mapsetPath() + "/vector/" + mGrassObject.name() + "/dbln";
QFileInfo di( dp );
if ( mLastAttributesModified < di.lastModified() )
{
QgsDebugMsg( "The attributes of the layer were modified : " + mGrassObject.toString() );
return true;
}
return false;
}
int QgsGrassVectorMap::numLines()
{
return ( Vect_get_num_lines( mMap ) );
}
int QgsGrassVectorMap::numAreas()
{
return ( Vect_get_num_areas( mMap ) );
}
QString QgsGrassVectorMap::toString()
{
return mGrassObject.mapsetPath() + "/" + mGrassObject.name();
}
void QgsGrassVectorMap::printDebug()
{
if ( !mValid || !mMap )
{
QgsDebugMsg( "map not valid" );
return;
}
G_TRY
{
#ifdef QGISDEBUG
int ncidx = Vect_cidx_get_num_fields( mMap );
QgsDebugMsg( QString( "ncidx = %1" ).arg( ncidx ) );
for ( int i = 0; i < ncidx; i++ )
{
int layer = Vect_cidx_get_field_number( mMap, i );
int ncats = Vect_cidx_get_num_cats_by_index( mMap, i );
QgsDebugMsg( QString( "i = %1 layer = %2 ncats = %3" ).arg( i ).arg( layer ).arg( ncats ) );
}
#endif
}
G_CATCH( QgsGrass::Exception & e )
{
Q_UNUSED( e )
QgsDebugMsg( "Cannot read info from map: " + QString( e.what() ) );
}
}
void QgsGrassVectorMap::lockOpenClose()
{
QgsDebugMsg( "lockOpenClose" );
mOpenCloseMutex.lock();
}
void QgsGrassVectorMap::unlockOpenClose()
{
QgsDebugMsg( "unlockOpenClose" );
mOpenCloseMutex.unlock();
}
void QgsGrassVectorMap::lockOpenCloseLayer()
{
QgsDebugMsg( "lockOpenCloseLayer" );
mOpenCloseLayerMutex.lock();
}
void QgsGrassVectorMap::unlockOpenCloseLayer()
{
QgsDebugMsg( "unlockOpenCloseLayer" );
mOpenCloseLayerMutex.unlock();
}
void QgsGrassVectorMap::lockReadWrite()
{
if ( isEdited() )
{
QgsDebugMsgLevel( "lockReadWrite", 3 );
mReadWriteMutex.lock();
}
}
void QgsGrassVectorMap::unlockReadWrite()
{
if ( isEdited() )
{
QgsDebugMsgLevel( "unlockReadWrite", 3 );
mReadWriteMutex.unlock();
}
}
QgsAbstractGeometry *QgsGrassVectorMap::lineGeometry( int id )
{
QgsDebugMsgLevel( QString( "id = %1" ).arg( id ), 3 );
if ( !Vect_line_alive( mMap, id ) ) // should not happen (update mode!)?
{
QgsDebugMsg( QString( "line %1 is dead" ).arg( id ) );
return nullptr;
}
struct line_pnts *points = Vect_new_line_struct();
int type = Vect_read_line( mMap, points, nullptr, id );
QgsDebugMsgLevel( QString( "type = %1 n_points = %2" ).arg( type ).arg( points->n_points ), 3 );
if ( points->n_points == 0 )
{
Vect_destroy_line_struct( points );
return nullptr;
}
QgsPointSequence pointList;
pointList.reserve( points->n_points );
for ( int i = 0; i < points->n_points; i++ )
{
pointList << QgsPoint( is3d() ? QgsWkbTypes::PointZ : QgsWkbTypes::Point, points->x[i], points->y[i], points->z[i] );
}
Vect_destroy_line_struct( points );
if ( type & GV_POINTS )
{
return pointList.first().clone();
}
else if ( type & GV_LINES )
{
QgsLineString *line = new QgsLineString();
line->setPoints( pointList );
return line;
}
else if ( type & GV_FACE )
{
QgsPolygon *polygon = new QgsPolygon();
QgsLineString *ring = new QgsLineString();
ring->setPoints( pointList );
polygon->setExteriorRing( ring );
return polygon;
}
QgsDebugMsg( QString( "unknown type = %1" ).arg( type ) );
return nullptr;
}
QgsAbstractGeometry *QgsGrassVectorMap::nodeGeometry( int id )
{
QgsDebugMsgLevel( QString( "id = %1" ).arg( id ), 3 );
double x, y, z;
Vect_get_node_coor( mMap, id, &x, &y, &z );
return new QgsPoint( is3d() ? QgsWkbTypes::PointZ : QgsWkbTypes::Point, x, y, z );
}
QgsAbstractGeometry *QgsGrassVectorMap::areaGeometry( int id )
{
QgsDebugMsgLevel( QString( "id = %1" ).arg( id ), 3 );
QgsPolygon *polygon = new QgsPolygon();
struct line_pnts *points = Vect_new_line_struct();
QgsDebugMsgLevel( QString( "points= %1" ).arg( ( quint64 )points ), 3 );
// Vect_get_area_points and Vect_get_isle_pointsis using static variable -> lock
// TODO: Faster to lock the whole feature iterator? Maybe only for areas?
QgsGrass::lock();
Vect_get_area_points( mMap, id, points );
QgsPointSequence pointList;
pointList.reserve( points->n_points );
for ( int i = 0; i < points->n_points; i++ )
{
pointList << QgsPoint( is3d() ? QgsWkbTypes::PointZ : QgsWkbTypes::Point, points->x[i], points->y[i], points->z[i] );
}
QgsLineString *ring = new QgsLineString();
ring->setPoints( pointList );
polygon->setExteriorRing( ring );
int nIsles = Vect_get_area_num_isles( mMap, id );
for ( int i = 0; i < nIsles; i++ )
{
pointList.clear();
int isle = Vect_get_area_isle( mMap, id, i );
Vect_get_isle_points( mMap, isle, points );
pointList.reserve( points->n_points );
for ( int i = 0; i < points->n_points; i++ )
{
pointList << QgsPoint( is3d() ? QgsWkbTypes::PointZ : QgsWkbTypes::Point, points->x[i], points->y[i], points->z[i] );
}
ring = new QgsLineString();
ring->setPoints( pointList );
polygon->addInteriorRing( ring );
}
QgsGrass::unlock();
Vect_destroy_line_struct( points );
return polygon;
}
void QgsGrassVectorMap::closeAllIterators()
{
QgsDebugMsg( toString() );
// cancel and close all iterator
// Iterators must be connected properly, otherwise may it result in dead lock!
emit cancelIterators(); // non blocking
emit closeIterators(); // blocking
QgsDebugMsg( "iterators closed" );
}
//------------------------------------ QgsGrassVectorMapStore ------------------------------------
QgsGrassVectorMapStore *QgsGrassVectorMapStore::sStore = nullptr;
QgsGrassVectorMapStore *QgsGrassVectorMapStore::instance()
{
static QgsGrassVectorMapStore sInstance;
if ( sStore )
{
return sStore;
}
return &sInstance;
}
QgsGrassVectorMap *QgsGrassVectorMapStore::openMap( const QgsGrassObject &grassObject )
{
QgsDebugMsg( "grassObject = " + grassObject.toString() );
mMutex.lock();
QgsGrassVectorMap *map = nullptr;
// Check if this map is already open
const auto constMMaps = mMaps;
for ( QgsGrassVectorMap *m : constMMaps )
{
if ( m->grassObject() == grassObject )
{
QgsDebugMsg( "The map already exists" );
map = m;
if ( !map->isOpen() )
{
map->open();
}
}
}
if ( !map )
{
map = new QgsGrassVectorMap( grassObject );
mMaps << map;
}
mMutex.unlock();
return map;
}
QgsGrassVectorMap::TopoSymbol QgsGrassVectorMap::topoSymbol( int lid )
{
int type = Vect_read_line( mMap, nullptr, nullptr, lid );
TopoSymbol symbol = TopoUndefined;
if ( type == GV_POINT )
{
symbol = TopoPoint;
}
else if ( type == GV_CENTROID )
{
int area = Vect_get_centroid_area( mMap, lid );
if ( area == 0 )
symbol = TopoCentroidOut;
else if ( area > 0 )
symbol = TopoCentroidIn;
else
symbol = TopoCentroidDupl; /* area < 0 */
}
else if ( type == GV_LINE )
{
symbol = TopoLine;
}
else if ( type == GV_BOUNDARY )
{
int left, right;
Vect_get_line_areas( mMap, lid, &left, &right );
if ( left != 0 && right != 0 )
{
symbol = TopoBoundaryOk;
}
else if ( left == 0 && right == 0 )
{
symbol = TopoBoundaryError;
}
else if ( left == 0 )
{
symbol = TopoBoundaryErrorLeft;
}
else if ( right == 0 )
{
symbol = TopoBoundaryErrorRight;
}
}
QgsDebugMsgLevel( QString( "lid = %1 type = %2 symbol = %3" ).arg( lid ).arg( type ).arg( symbol ), 3 );
return symbol;
}
| 24.88656 | 142 | 0.61968 | [
"vector"
] |
d6b0f549a4f7e30e068b21c1404dea976d8659f0 | 8,037 | hpp | C++ | src/core/problems/TChem_Impl_PlugFlowReactor_Problem.hpp | kyungjoo-kim/TChem | 69915ca8de71df9a6a463aae45c5bd6db31646bc | [
"BSD-2-Clause"
] | null | null | null | src/core/problems/TChem_Impl_PlugFlowReactor_Problem.hpp | kyungjoo-kim/TChem | 69915ca8de71df9a6a463aae45c5bd6db31646bc | [
"BSD-2-Clause"
] | null | null | null | src/core/problems/TChem_Impl_PlugFlowReactor_Problem.hpp | kyungjoo-kim/TChem | 69915ca8de71df9a6a463aae45c5bd6db31646bc | [
"BSD-2-Clause"
] | 1 | 2022-02-26T18:04:44.000Z | 2022-02-26T18:04:44.000Z | /* =====================================================================================
TChem version 2.0
Copyright (2020) NTESS
https://github.com/sandialabs/TChem
Copyright 2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains
certain rights in this software.
This file is part of TChem. TChem is open source software: you can redistribute it
and/or modify it under the terms of BSD 2-Clause License
(https://opensource.org/licenses/BSD-2-Clause). A copy of the licese is also
provided under the main directory
Questions? Contact Cosmin Safta at <csafta@sandia.gov>, or
Kyungjoo Kim at <kyukim@sandia.gov>, or
Oscar Diaz-Ibarra at <odiazib@sandia.gov>
Sandia National Laboratories, Livermore, CA, USA
===================================================================================== */
#ifndef __TCHEM_IMPL_PLUG_FLOW_REACTOR_PROBLEM_HPP__
#define __TCHEM_IMPL_PLUG_FLOW_REACTOR_PROBLEM_HPP__
/* This problem advance a PFR with surface reactions.
*/
// #include "TChem_Impl_PlugFlowReactorNumJacobian.hpp"
#include "TChem_Impl_NumericalJacobianCentralDifference.hpp"
#include "TChem_Impl_NumericalJacobianForwardDifference.hpp"
#include "TChem_Impl_NumericalJacobianRichardsonExtrapolation.hpp"
#include "TChem_Impl_PlugFlowReactorRHS.hpp"
#include "TChem_Util.hpp"
namespace TChem {
namespace Impl {
template<typename KineticModelConstDataType,
typename KineticSurfModelConstDataType,
typename PlugFlowReactorConstDataType>
struct PlugFlowReactor_Problem
{
using kmcd_type = KineticModelConstDataType;
using exec_space_type = typename kmcd_type::exec_space_type;
using real_type_1d_view_type = typename kmcd_type::real_type_1d_view_type;
using real_type_2d_view_type = typename kmcd_type::real_type_2d_view_type;
KOKKOS_DEFAULTED_FUNCTION
PlugFlowReactor_Problem() = default;
/// public access to these member functions
real_type_1d_view _x;
real_type_1d_view _work;
real_type_1d_view _fac; /// numerical jacobian
KineticModelConstDataType _kmcd;
KineticSurfModelConstDataType _kmcdSurf;
PlugFlowReactorConstDataType _pfrd;
KOKKOS_INLINE_FUNCTION
static ordinal_type getWorkSpaceSize(
const KineticModelConstDataType& kmcd,
const KineticSurfModelConstDataType& kmcdSurf)
{
// const ordinal_type jac_workspace_size =
// PlugFlowReactorNumJacobian ::getWorkSpaceSize(kmcd, kmcdSurf);
const ordinal_type jac_workspace_size = 2 * getNumberOfEquations(kmcd, kmcdSurf);
const ordinal_type source_workspace_size = Impl::PlugFlowReactorRHS::
getWorkSpaceSize(kmcd, kmcdSurf) ;
const ordinal_type workspace_size =
jac_workspace_size + source_workspace_size;
return workspace_size;
}
KOKKOS_INLINE_FUNCTION
static ordinal_type getNumberOfTimeODEs(const KineticModelConstDataType& kmcd)
{
return kmcd.nSpec + 3; // Temp, mass fraction, density, velocity
}
KOKKOS_INLINE_FUNCTION
static ordinal_type getNumberOfConstraints(
const KineticSurfModelConstDataType& kmcdSurf)
{
return kmcdSurf.nSpec; // site fraction
}
KOKKOS_INLINE_FUNCTION
static ordinal_type getNumberOfEquations(
const KineticModelConstDataType& kmcd,
const KineticSurfModelConstDataType& kmcdSurf)
{
return getNumberOfTimeODEs(kmcd) + getNumberOfConstraints(kmcdSurf);
}
///
/// non static functions that require the object
/// workspace size is required without kmcd
///
KOKKOS_INLINE_FUNCTION
ordinal_type getWorkSpaceSize() const
{
return getWorkSpaceSize(_kmcd, _kmcdSurf);
}
KOKKOS_INLINE_FUNCTION
ordinal_type getNumberOfTimeODEs() const
{
return getNumberOfTimeODEs(_kmcd);
}
KOKKOS_INLINE_FUNCTION
ordinal_type getNumberOfConstraints() const
{
return getNumberOfConstraints(_kmcdSurf);
}
KOKKOS_INLINE_FUNCTION
ordinal_type getNumberOfEquations() const
{
return getNumberOfTimeODEs() + getNumberOfConstraints();
}
template<typename MemberType, typename RealType1DViewType>
KOKKOS_INLINE_FUNCTION void computeInitValues(
const MemberType& member,
const RealType1DViewType& x) const
{
/// this is probably not used
Kokkos::parallel_for(Kokkos::TeamVectorRange(member, x.extent(0)),
[&](const ordinal_type& i) { x(i) = _x(i); });
// compute constraint and store value to be use in function and jacobian
// resolve a non linear system
member.team_barrier();
}
template<typename MemberType,
typename RealType1DViewType,
typename RealType2DViewType>
KOKKOS_INLINE_FUNCTION void computeJacobian(const MemberType& member,
const RealType1DViewType& x,
const RealType2DViewType& J) const
{
const ordinal_type m = getNumberOfEquations();
/// _work is used for evaluating a function
/// f_0 and f_h should be gained from the tail
real_type* wptr = _work.data() + (_work.span() - 2 * m);
RealType1DViewType f_0(wptr, m);
wptr += f_0.span();
RealType1DViewType f_h(wptr, m);
wptr += f_h.span();
/// use the default values
const real_type fac_min(-1), fac_max(-1);
NumericalJacobianForwardDifference::team_invoke_detail
(member, *this, fac_min, fac_max, _fac, x, f_0, f_h, J);
// NumericalJacobianCentralDifference::team_invoke_detail(
// member, *this, fac_min, fac_max, _fac, x, f_0, f_h, J);
// NumericalJacobianRichardsonExtrapolation::team_invoke_detail
// (member, *this, fac_min, fac_max, _fac, x, f_0, f_h, J);
}
template<typename MemberType, typename RealType1DViewType>
KOKKOS_INLINE_FUNCTION void computeFunction(const MemberType& member,
const RealType1DViewType& x,
const RealType1DViewType& f) const
{
const real_type t = x(0);
const real_type_1d_view Ys(&x(1), _kmcd.nSpec);
const real_type density = x(_kmcd.nSpec + 1);
const real_type vel = x(_kmcd.nSpec + 2);
const real_type_1d_view siteFraction(&x(_kmcd.nSpec + 3), _kmcdSurf.nSpec);
const real_type Wmix = MolarWeights::team_invoke(member, Ys, _kmcd);
const real_type p = _kmcd.Runiv * t * density / Wmix; // compute pressure
Impl::PlugFlowReactorRHS ::team_invoke(member,
t,
Ys,
siteFraction,
density,
p,
vel,
f,
_work,
_kmcd,
_kmcdSurf,
_pfrd);
//
#if defined(TCHEM_ENABLE_SERIAL_TEST_OUTPUT) && !defined(__CUDA_ARCH__)
if (member.league_rank() == 0) {
FILE* fs = fopen(
"PlugFlowReactor_Problem_computeFunction.team_invoke.test.out", "a+");
fprintf(fs, ":::: input\n");
fprintf(fs,
" nSpec %3d, nReac %3d, site density %e\n",
_kmcdSurf.nSpec,
_kmcdSurf.nReac,
_kmcdSurf.sitedensity);
fprintf(fs, " Area %e, pfrd.Pcat %e", _pfrd.Area, _pfrd.Pcat);
fprintf(fs, " t %e, p %e, velocity %e\n", t, p, vel);
for (int i = 0; i < Ys.extent(0); ++i)
fprintf(fs, " i %3d, Ys %e, \n", i, Ys(i));
for (int i = 0; i < siteFraction.extent(0); ++i)
fprintf(fs, " i %3d, siteFraction %e, \n", i, siteFraction(i));
for (int i = 0; i < x.extent(0); ++i)
fprintf(fs, " i %3d, x %e, \n", i, x(i));
fprintf(fs, ":::: output\n");
for (int i = 0; i < f.extent(0); ++i)
fprintf(fs, " i %3d, f %e, \n", i, f(i));
}
#endif
}
};
} // namespace Impl
} // namespace TChem
#endif
| 35.879464 | 88 | 0.646137 | [
"object",
"3d"
] |
d6bdc5a8b3e1c25912053fe193332b256fc754ca | 4,184 | cpp | C++ | Online Judges/UVA/10020/5139508_AC_26ms_0kB.cpp | moni-roy/COPC | f5918304815413c18574ef4af2e23a604bd9f704 | [
"MIT"
] | 4 | 2017-02-20T17:41:14.000Z | 2019-07-15T14:15:34.000Z | Online Judges/UVA/10020/5139508_AC_26ms_0kB.cpp | moni-roy/COPC | f5918304815413c18574ef4af2e23a604bd9f704 | [
"MIT"
] | null | null | null | Online Judges/UVA/10020/5139508_AC_26ms_0kB.cpp | moni-roy/COPC | f5918304815413c18574ef4af2e23a604bd9f704 | [
"MIT"
] | null | null | null | /* * * * * * * * * * * *
* :Krishna (MRoy) *
* :JU *
* :mkroy.cs@gmail.com *
* * * * * * * * * * * */
#include <bits/stdc++.h>
//~ c
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
#include <climits>
//~ c++
#include <algorithm>
#include <bitset>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#include <numeric>
#include <iterator>
#include <typeinfo>
#include <valarray>
#include <functional>
using namespace std;
typedef long long ll;
typedef long long unsigned llu;
typedef double dl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef map<string,int> msi;
typedef map<char,int> mci;
typedef pair<int ,pii> piii;
typedef vector<pii> vpii;
typedef vector<piii> vpiii;
//~ Define
#define pi acos(-1.0)
#define S second
#define F first
#define pb push_back
#define MP make_pair
#define P push
#define zero(a) memset(a,0,sizeof a)
#define minus(a) memset(a,-1,sizeof a)
#define setinf(a) memset(a,126,sizeof a)
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(),v.end())
#define I_O ios_base::sync_with_stdio(0); cin.tie(0)
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a,b) __gcd(a,b)
//~ Input
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define D(a) scanf("%lf",&a)
#define sc scanf
//~ Output
#define nl puts("")
#define sp printf(" ");
#define SP cout<<" ";
#define tcase(cs) printf("Case %d:",++cs)
#define TC(cs) cout<<"Case "<<++cs<<":"
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PD(a) printf("%lf",a)
#define pr printf
template <class T> inline T BMOD(T p,T e,T m){T ret=1;while(e){if(e&1) ret=(ret*p)%m;p=(p*p)%m;e>>=1;}return (T)ret;}
template <class T> inline T MODINV(T a,T m){return BMOD(a,m-2,m);}
template <class T> inline T isPrime(T a){for(T i=2;i<=sqrt(double(a));i++){if(a%i==0){return 0;}}return 1;}
template <class T> inline T lcm(T a, T b){return (a/gcd(a,b))*b;}
template <class T> inline T power(T a, T b){return (b==0)?1:a*power(a,b-1);}
#define READ(in) freopen("in.in","r",stdin)
#define WRITE(out) freopen("out.out","w",stdout)
//~ cout << fixed << setprecision(20) << Ans << endl;
//~ priority_queue<piii,vpiii, greater<piii> >pq; //for dijkstra
/******************************Let's GO*********************************/
struct st{
int x,y;
bool operator<(const st &p) const{
return x<p.x;
}
}a[1000010];
int ts,ls,mx,m,i,l,r;
vpii v;
int main()
{
I_O;
cin>>ts;
while(ts--){
cin>>m;
int n=0;
while(1){
cin>>l>>r;
if(!l && !r) break;
a[n].x=l;
a[n++].y=r;
}
sort(a,a+n);
ls=0;
mx=-9999999;
i=0;
int fl=0,id;
v.clear();
while(1){
if(n==0) break;
while(a[i].x<=ls){
if(mx<a[i].y){
id=i;
mx=a[i].y;
}
i++;
fl=1;
if(i==n || mx>=m ) break;
}
ls=mx;
if(i!=0) v.pb(MP(a[id].x,a[id].y));
if(i==n || fl==0 || ls>= m) break;
fl=0;
}
if(ls<m) cout<<0<<endl;
else{
cout<<v.size()<<endl;
for( i=0;i<(int)v.size();i++){
cout<<v[i].F<<" "<<v[i].S<<endl;
}
}
if(ts) cout<<endl;
}
return 0;
}
| 26.15 | 117 | 0.510277 | [
"vector"
] |
d6bf8f1952d8f8cc0b336d447091fc09ac781252 | 7,899 | cpp | C++ | medgpc/src/inference/c_inference_exact.cpp | bee-hive/MedGP | 596a24ca519900507cce42cb4e2061319cef801e | [
"BSD-3-Clause"
] | 25 | 2018-03-18T18:09:03.000Z | 2022-02-24T07:47:33.000Z | medgpc/src/inference/c_inference_exact.cpp | bee-hive/MedGP | 596a24ca519900507cce42cb4e2061319cef801e | [
"BSD-3-Clause"
] | 3 | 2021-04-12T16:11:00.000Z | 2021-04-12T16:26:17.000Z | medgpc/src/inference/c_inference_exact.cpp | bee-hive/MedGP | 596a24ca519900507cce42cb4e2061319cef801e | [
"BSD-3-Clause"
] | 4 | 2019-04-27T23:18:26.000Z | 2021-12-03T20:19:09.000Z | /*
-------------------------------------------------------------------------
This is the function file for the class exact inference.
-------------------------------------------------------------------------
*/
#include <iostream>
#include <vector>
#include <string>
#include <assert.h>
#include <mkl.h>
#include <omp.h>
#include <math.h>
#include <time.h>
#include "core/gp_model_include.h"
#include "inference/c_inference_exact.h"
#include "util/global_settings.h"
using namespace std;
c_inference_exact::c_inference_exact(){
inffunc_name = "c_inference_exact";
inf_thread_num = 1;
}
c_inference_exact::c_inference_exact(const int &thread_num){
inffunc_name = "c_inference_exact";
inf_thread_num = thread_num;
}
bool c_inference_exact::compute_nlml(
const bool &flag_grad,
const vector<int> &meta,
const vector<float> &x,
const vector<float> &y,
c_kernel *kernel,
c_meanfunc *meanfunc,
c_likelihood *likfunc,
c_prior *prior,
float *&chol_alpha,
float *&chol_factor_inv,
float &beta,
double &nlml,
vector<double> &dnlml
){
// initialization
bool flag_success = false;
char *lower = "L";
char *nunit = "N";
double logDet = 0.0;
double quadDot = 0.0;
int i, j, k;
int count = 0;
int n_train_sample = int(y.size());
// set local thread #
assert(inf_thread_num >= 1);
mkl_set_num_threads_local(inf_thread_num);
omp_set_num_threads(inf_thread_num);
// timing variables
time_t t1, t2, t3, t4;
clock_t ct1, ct2;
float *mean_vec, *lik_vec, *gram_matrix;
vector<float*> grad_mean, grad_lik;
mean_vec = new float[n_train_sample];
lik_vec = new float[n_train_sample];
gram_matrix = new float[n_train_sample*n_train_sample];
// MKL parameters
MKL_INT info;
MKL_INT n = n_train_sample;
MKL_INT lda = n_train_sample;
time(&t3);
// compute mean vector
meanfunc -> compute_mean_vector(meta, x, flag_grad, mean_vec, grad_mean);
cblas_sscal(n, -1, mean_vec, 1);
cblas_saxpy(n, 1, &y[0], 1, mean_vec, 1);
// compute likelihood vector
likfunc -> compute_lik_vector(meta, x, flag_grad, lik_vec, grad_lik);
// compute gram matrix
time(&t1);
kernel -> compute_self_gram_matrix(meta, x, gram_matrix);
#pragma omp parallel for private(i) firstprivate(n_train_sample)
for(i = 0; i < n_train_sample; i++){
double temp_diag = gram_matrix[ i*n_train_sample + i ] + lik_vec[i];
gram_matrix[ i*n_train_sample + i ] = (float)(temp_diag);
}
time(&t2);
// do cholesky decomposition
time(&t1);
cblas_scopy(n*n, gram_matrix, 1, chol_factor_inv, 1);
info = LAPACKE_spotrf(LAPACK_ROW_MAJOR, *lower, n, chol_factor_inv, lda);
while((info != 0) && (count < 10)){
cout << "WARNING: Cholesky decomposition failed! Start jittering count = " << count << endl;
#pragma omp parallel for private(i) firstprivate(n_train_sample)
for(i = 0; i < n_train_sample; i++){
gram_matrix[ i*n_train_sample + i ] = gram_matrix[ i*n_train_sample + i ] + lik_vec[i];
}
cblas_scopy(n*n, gram_matrix, 1, chol_factor_inv, 1);
info = LAPACKE_spotrf(LAPACK_ROW_MAJOR, *lower, n, chol_factor_inv, lda);
count += 1;
}
if(info != 0){
return flag_success;
}
time(&t2);
delete[] gram_matrix;
// compute the log determinant
flag_success = true;
for(i = 0; i < n_train_sample; i++){
logDet = logDet + log(chol_factor_inv[ i*n_train_sample + i ]);
}
// compute the inversion of gram matrix
time(&t1);
cblas_scopy(n, mean_vec, 1, chol_alpha, 1);
info = LAPACKE_spotrs(LAPACK_ROW_MAJOR, *lower, n, 1, chol_factor_inv, n, chol_alpha, 1);
time(&t2);
// compute the inverse of cholesky factor
time(&t1);
info = LAPACKE_strtri(LAPACK_ROW_MAJOR, *lower, *nunit, n, chol_factor_inv, lda);
if(info != 0){
cout << "ERROR: Cholesky factor inversion failed!" << endl;
flag_success = false;
return flag_success;
}
time(&t2);
for(i = 0; i < (n_train_sample-1); i++){
for(j = (i+1); j < n_train_sample; j++){
chol_factor_inv[ i*n_train_sample + j ] = 0.0;
}
}
// compute log marginal likelihood
quadDot = cblas_dsdot(n, mean_vec, 1, chol_alpha, 1);
beta = (float)(quadDot);
double term1 = quadDot/2.0;
double term2 = logDet;
double term3 = n_train_sample*log(2.*PI)/2.0;
nlml = term1 + term2 + term3;
time(&t4);
// compute gradients
time(&t3);
if(flag_grad){
if(!dnlml.empty()){
dnlml.clear();
}
float *Q;
double sum = 0.0;
int offset = 0;
vector<double> temp_hyp;
// compute Q matrix
Q = new float[n_train_sample*n_train_sample];
time(&t1);
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasTrans, n, n, 1, 1.0f, chol_alpha, 1, chol_alpha, 1, 0.0f, Q, n);
cblas_sgemm(CblasRowMajor, CblasTrans, CblasNoTrans, n, n, n, 1.0f, chol_factor_inv, n, chol_factor_inv, n, -1.0f, Q, n);
time(&t2);
// compute gradients for likelihood hypers
time(&t1);
temp_hyp = likfunc -> get_likfunc_hyp();
if(meta.empty()){
if(int(temp_hyp.size()) != 1){
cout << "ERROR: the # of lik hyperparameter != 1 but no meta specified!" << endl;
exit(1);
}
for(i = 0; i < int(temp_hyp.size()); i++){
dnlml.push_back(0.0);
}
sum = 0.0;
for(i = 0; i < n_train_sample; i++){
sum = sum + pow(temp_hyp[0], 2.0)*Q[ i*n_train_sample + i];
}
dnlml[0] = sum;
}
else{
for(i = 0; i < int(temp_hyp.size()); i++){
dnlml.push_back(0.0);
sum = 0.0;
for(j = 0; j < n_train_sample; j++){
if(meta[j] == i)
sum = sum + pow(temp_hyp[i], 2.0)*(Q[ j*n_train_sample + j]);
}
dnlml[i] = sum;
}
}
offset += int(temp_hyp.size());
time(&t2);
// compute gradients for kernel hypers
temp_hyp.clear();
temp_hyp = kernel -> get_kernel_hyp();
for(i = 0; i < int(temp_hyp.size()); i++){
dnlml.push_back(0.0);
}
vector<double> grad_kernel_vec(temp_hyp.size(), 0.0);
kernel -> compute_self_gradients(meta, x, Q, grad_kernel_vec);
for(i = 0; i < int(temp_hyp.size()); i++){
dnlml[ i + offset ] = grad_kernel_vec[i];
}
offset += int(temp_hyp.size());
// compute gradients for mean hypers
temp_hyp.clear();
temp_hyp = meanfunc -> get_meanfunc_hyp();
for(i = 0; i < int(temp_hyp.size()); i++){
dnlml.push_back(0.0);
}
vector<double> grad_mean_vec(temp_hyp.size(), 0.0);
meanfunc -> compute_mean_gradients(meta, x, chol_alpha, grad_mean_vec);
for(i = 0; i < int(temp_hyp.size()); i++){
dnlml[ i + offset ] = -1.*grad_mean_vec[i];
}
delete[] Q;
}
// free memory
delete[] mean_vec;
delete[] lik_vec;
time(&t4);
return flag_success;
}
| 32.240816 | 132 | 0.528295 | [
"vector"
] |
d6c0f5e98592ed20be012716d135d2943f382692 | 13,320 | cpp | C++ | src/BabylonCpp/src/maths/path3d.cpp | samdauwe/BabylonCpp | eea9f761a49bb460ff1324c20e4674ef120e94f1 | [
"Apache-2.0"
] | 277 | 2017-05-18T08:27:10.000Z | 2022-03-26T01:31:37.000Z | src/BabylonCpp/src/maths/path3d.cpp | samdauwe/BabylonCpp | eea9f761a49bb460ff1324c20e4674ef120e94f1 | [
"Apache-2.0"
] | 77 | 2017-09-03T15:35:02.000Z | 2022-03-28T18:47:20.000Z | src/BabylonCpp/src/maths/path3d.cpp | samdauwe/BabylonCpp | eea9f761a49bb460ff1324c20e4674ef120e94f1 | [
"Apache-2.0"
] | 37 | 2017-03-30T03:36:24.000Z | 2022-01-28T08:28:36.000Z | #include <babylon/maths/path3d.h>
#include <babylon/babylon_stl_util.h>
#include <babylon/maths/scalar.h>
#include <babylon/misc/tools.h>
namespace BABYLON {
Path3D::Path3D() = default;
Path3D::Path3D(const std::vector<Vector3>& iPath, const std::optional<Vector3>& firstNormal,
bool raw, bool alignTangentsWithPath)
: path{iPath}, _raw{raw}
{
for (auto& vector : iPath) {
_curve.emplace_back(vector);
}
_alignTangentsWithPath = alignTangentsWithPath;
_compute(firstNormal, alignTangentsWithPath);
}
Path3D::Path3D(const Path3D& otherPath) = default;
Path3D::Path3D(Path3D&& otherPath) = default;
Path3D& Path3D::operator=(const Path3D& otherPath) = default;
Path3D& Path3D::operator=(Path3D&& otherPath) = default;
Path3D::~Path3D() = default;
Path3D Path3D::copy() const
{
return Path3D(*this);
}
std::unique_ptr<Path3D> Path3D::clone() const
{
return std::make_unique<Path3D>(*this);
}
std::ostream& operator<<(std::ostream& os, const Path3D& path)
{
os << "{\"Raw\":" << path._raw;
os << ",\"Curve\":[";
if (!path._curve.empty()) {
for (unsigned int i = 0; i < path._curve.size() - 1; ++i) {
os << path._curve[i] << ",";
}
os << path._curve.back();
}
os << "],\"Distances\":[";
if (!path._distances.empty()) {
for (unsigned int i = 0; i < path._distances.size() - 1; ++i) {
os << path._distances[i] << ",";
}
os << path._distances.back();
}
os << "],\"Tangents\":[";
if (!path._tangents.empty()) {
for (unsigned int i = 0; i < path._tangents.size() - 1; ++i) {
os << path._tangents[i] << ",";
}
os << path._tangents.back();
}
os << "],\"Normals\":[";
if (!path._normals.empty()) {
for (unsigned int i = 0; i < path._normals.size() - 1; ++i) {
os << path._normals[i] << ",";
}
os << path._normals.back();
}
os << "],\"Binormals\":[";
if (!path._binormals.empty()) {
for (unsigned int i = 0; i < path._binormals.size() - 1; ++i) {
os << path._binormals[i] << ",";
}
os << path._binormals.back();
}
os << "]}";
return os;
}
std::vector<Vector3>& Path3D::getCurve()
{
return _curve;
}
std::vector<Vector3>& Path3D::getPoints()
{
return _curve;
}
float Path3D::length() const
{
return _distances.back();
}
std::vector<Vector3>& Path3D::getTangents()
{
return _tangents;
}
std::vector<Vector3>& Path3D::getNormals()
{
return _normals;
}
std::vector<Vector3>& Path3D::getBinormals()
{
return _binormals;
}
Float32Array& Path3D::getDistances()
{
return _distances;
}
Vector3 Path3D::getPointAt(float position)
{
return _updatePointAtData(position).point;
}
Vector3 Path3D::getTangentAt(float position, bool interpolated)
{
_updatePointAtData(position, interpolated);
return interpolated ?
Vector3::TransformCoordinates(Vector3::Forward(), _pointAtData.interpolationMatrix) :
_tangents[_pointAtData.previousPointArrayIndex];
}
Vector3 Path3D::getNormalAt(float position, bool interpolated)
{
_updatePointAtData(position, interpolated);
return interpolated ?
Vector3::TransformCoordinates(Vector3::Right(), _pointAtData.interpolationMatrix) :
_normals[_pointAtData.previousPointArrayIndex];
}
Vector3 Path3D::getBinormalAt(float position, bool interpolated)
{
_updatePointAtData(position, interpolated);
return interpolated ?
Vector3::TransformCoordinates(Vector3::UpReadOnly(), _pointAtData.interpolationMatrix) :
_binormals[_pointAtData.previousPointArrayIndex];
}
float Path3D::getDistanceAt(float position) const
{
return length() * position;
}
size_t Path3D::getPreviousPointIndexAt(float position)
{
_updatePointAtData(position);
return _pointAtData.previousPointArrayIndex;
}
float Path3D::getSubPositionAt(float position)
{
_updatePointAtData(position);
return _pointAtData.subPosition;
}
float Path3D::getClosestPositionTo(const Vector3& target)
{
auto smallestDistance = std::numeric_limits<float>::max();
auto closestPosition = 0.f;
for (size_t i = 0; !_curve.empty() && i < _curve.size() - 1; ++i) {
const auto point = _curve[i + 0];
const auto tangent = _curve[i + 1].subtract(point).normalize();
const auto subLength = _distances[i + 1] - _distances[i + 0];
const auto subPosition
= std::min((std::max(Vector3::Dot(tangent, target.subtract(point).normalize()), 0.f)
* Vector3::Distance(point, target))
/ subLength,
1.f);
const auto distance
= Vector3::Distance(point.add(tangent.scale(subPosition * subLength)), target);
if (distance < smallestDistance) {
smallestDistance = distance;
closestPosition = (_distances[i + 0] + subLength * subPosition) / length();
}
}
return closestPosition;
}
Path3D Path3D::slice(float start, float end)
{
if (start < 0.f) {
start = 1.f - (start * -1.f) /* % 1.f */;
}
if (end < 0.f) {
end = 1.f - (end * -1.f) /* % 1.f */;
}
if (start > end) {
auto _start = start;
start = end;
end = _start;
}
auto curvePoints = getCurve();
auto startPoint = getPointAt(start);
auto startIndex = getPreviousPointIndexAt(start);
auto endPoint = getPointAt(end);
auto endIndex = getPreviousPointIndexAt(end) + 1;
std::vector<Vector3> slicePoints;
if (start != 0.f) {
startIndex++;
slicePoints.emplace_back(startPoint);
}
auto slice
= stl_util::slice(curvePoints, static_cast<int>(startIndex), static_cast<int>(endIndex));
stl_util::concat(slicePoints, slice);
if (end != 1.f || start == 1.f) {
slicePoints.emplace_back(endPoint);
}
return Path3D(slicePoints, getNormalAt(start), _raw, _alignTangentsWithPath);
}
Path3D& Path3D::update(const std::vector<Vector3>& iPath, const std::optional<Vector3>& firstNormal,
bool alignTangentsWithPath)
{
if (_curve.size() < iPath.size()) {
_curve.resize(iPath.size());
}
for (unsigned int p = 0; p < iPath.size(); ++p) {
_curve[p].x = iPath[p].x;
_curve[p].y = iPath[p].y;
_curve[p].z = iPath[p].z;
}
_compute(firstNormal, alignTangentsWithPath);
return *this;
}
void Path3D::_compute(const std::optional<Vector3>& firstNormal, bool alignTangentsWithPath)
{
const auto l = _curve.size();
if (l < 2) {
return;
}
_binormals.resize(l);
_distances.resize(l);
_normals.resize(l);
_tangents.resize(l);
// first and last tangents
_tangents[0] = _getFirstNonNullVector(0);
if (!_raw) {
_tangents[0].normalize();
}
_tangents[l - 1] = _curve[l - 1].subtract(_curve[l - 2]);
if (!_raw) {
_tangents[l - 1].normalize();
}
// normals and binormals at first point : arbitrary vector with
// _normalVector()
const auto& tg0 = _tangents[0];
const auto pp0 = _normalVector(tg0, firstNormal);
_normals[0] = pp0;
if (!_raw) {
_normals[0].normalize();
}
_binormals[0] = Vector3::Cross(tg0, _normals[0]);
if (!_raw) {
_binormals[0].normalize();
}
_distances[0] = 0.f;
// normals and binormals : next points
Vector3 prev; // previous vector (segment)
Vector3 cur; // current vector (segment)
Vector3 curTang; // current tangent
Vector3 prevNor; // previous normal
Vector3 prevBinor; // previous binormal
for (unsigned int i = 1; i < l; ++i) {
// tangents
prev = _getLastNonNullVector(i);
if (i < l - 1) {
cur = _getFirstNonNullVector(i);
_tangents[i] = alignTangentsWithPath ? cur : prev.add(cur);
_tangents[i].normalize();
}
_distances[i] = _distances[i - 1] + _curve[i].subtract(_curve[i - 1]).length();
// normals and binormals
// http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
curTang = _tangents[i];
prevBinor = _binormals[i - 1];
_normals[i] = Vector3::Cross(prevBinor, curTang);
if (!_raw) {
if (_normals[i].length() == 0.f) {
prevNor = _normals[i - 1];
_normals[i] = prevNor;
}
else {
_normals[i].normalize();
}
}
_binormals[i] = Vector3::Cross(curTang, _normals[i]);
if (!_raw) {
_binormals[i].normalize();
}
}
_pointAtData.id = std::nullopt;
}
Vector3 Path3D::_getFirstNonNullVector(unsigned int index)
{
unsigned int i = 1;
Vector3 nNVector = _curve[index + i].subtract(_curve[index]);
while (stl_util::almost_equal(nNVector.length(), 0.f) && index + i + 1 < _curve.size()) {
++i;
nNVector = _curve[index + i].subtract(_curve[index]);
}
return nNVector;
}
Vector3 Path3D::_getLastNonNullVector(unsigned int index)
{
unsigned int i = 1;
Vector3 nLVector = _curve[index].subtract(_curve[index - i]);
while (stl_util::almost_equal(nLVector.length(), 0.f) && index > i + 1) {
++i;
nLVector = _curve[index].subtract(_curve[index - i]);
}
return nLVector;
}
Vector3 Path3D::_normalVector(const Vector3& vt, const std::optional<Vector3>& va)
{
Vector3 normal0;
float tgl = vt.length();
if (stl_util::almost_equal(tgl, 0.f)) {
tgl = 1.f;
}
if (va == std::nullopt) {
Vector3 point;
if (!Scalar::WithinEpsilon(std::abs(vt.y) / tgl, 1.f, Math::Epsilon)) {
// search for a point in the plane
point = Vector3(0.f, -1.f, 0.f);
}
else if (!Scalar::WithinEpsilon(std::abs(vt.x) / tgl, 1.f, Math::Epsilon)) {
point = Vector3(1.f, 0.f, 0.f);
}
else if (!Scalar::WithinEpsilon(std::abs(vt.z) / tgl, 1.f, Math::Epsilon)) {
point = Vector3(0.f, 0.f, 1.f);
}
else {
point = Vector3::Zero();
}
normal0 = Vector3::Cross(vt, point);
}
else {
normal0 = Vector3::Cross(vt, *va);
Vector3::CrossToRef(normal0, vt, normal0);
}
normal0.normalize();
return normal0;
}
Path3D::PointAtData& Path3D::_updatePointAtData(float position, bool interpolateTNB)
{
// set an id for caching the result
if (_pointAtData.id.has_value() && stl_util::almost_equal(_pointAtData.id.value(), position)) {
if (!_pointAtData.interpolateReady) {
_updateInterpolationMatrix();
}
return _pointAtData;
}
else {
_pointAtData.id = position;
}
const auto& curvePoints = getPoints();
// clamp position between 0.0 and 1.0
if (position <= 0.f) {
return _setPointAtData(0.f, 0.f, curvePoints[0], 0, interpolateTNB);
}
else if (position >= 1.f) {
return _setPointAtData(1.f, 1.f, curvePoints.back(), curvePoints.size() - 1, interpolateTNB);
}
auto previousPoint = curvePoints[0];
Vector3 currentPoint;
auto currentLength = 0.f;
auto targetLength = position * length();
for (size_t i = 1; i < curvePoints.size(); ++i) {
currentPoint = curvePoints[i];
auto distance = Vector3::Distance(previousPoint, currentPoint);
currentLength += distance;
if (stl_util::almost_equal(currentLength, targetLength)) {
return _setPointAtData(position, 1.f, currentPoint, i, interpolateTNB);
}
else if (currentLength > targetLength) {
auto toLength = currentLength - targetLength;
auto diff = toLength / distance;
auto dir = previousPoint.subtract(currentPoint);
auto point = currentPoint.add(dir.scaleInPlace(diff));
return _setPointAtData(position, 1.f - diff, point, i - 1, interpolateTNB);
}
previousPoint = currentPoint;
}
return _pointAtData;
}
Path3D::PointAtData& Path3D::_setPointAtData(float position, float subPosition,
const Vector3& point, size_t parentIndex,
bool interpolateTNB)
{
_pointAtData.point = point;
_pointAtData.position = position;
_pointAtData.subPosition = subPosition;
_pointAtData.previousPointArrayIndex = parentIndex;
_pointAtData.interpolateReady = interpolateTNB;
if (interpolateTNB) {
_updateInterpolationMatrix();
}
return _pointAtData;
}
void Path3D::_updateInterpolationMatrix()
{
_pointAtData.interpolationMatrix = Matrix::Identity();
auto parentIndex = _pointAtData.previousPointArrayIndex;
if (parentIndex != _tangents.size() - 1) {
auto index = parentIndex + 1;
auto tangentFrom = _tangents[parentIndex];
auto normalFrom = _normals[parentIndex];
auto binormalFrom = _binormals[parentIndex];
auto tangentTo = _tangents[index];
auto normalTo = _normals[index];
auto binormalTo = _binormals[index];
auto quatFrom = Quaternion::RotationQuaternionFromAxis(normalFrom, binormalFrom, tangentFrom);
auto quatTo = Quaternion::RotationQuaternionFromAxis(normalTo, binormalTo, tangentTo);
auto quatAt = Quaternion::Slerp(quatFrom, quatTo, _pointAtData.subPosition);
quatAt.toRotationMatrix(_pointAtData.interpolationMatrix);
}
}
} // end of namespace BABYLON
| 29.082969 | 101 | 0.620571 | [
"vector"
] |
d6c9c52279613c951c12cfcf9d85a0f5fad84ab1 | 1,868 | cpp | C++ | test/unit/meta/cardinal.cpp | clayne/eve | dc268b5db474376e1c53f5a474f5bb42b7c4cb59 | [
"MIT"
] | 340 | 2020-09-16T21:12:48.000Z | 2022-03-28T15:40:33.000Z | test/unit/meta/cardinal.cpp | clayne/eve | dc268b5db474376e1c53f5a474f5bb42b7c4cb59 | [
"MIT"
] | 383 | 2020-09-17T06:56:35.000Z | 2022-03-13T15:58:53.000Z | test/unit/meta/cardinal.cpp | clayne/eve | dc268b5db474376e1c53f5a474f5bb42b7c4cb59 | [
"MIT"
] | 28 | 2021-02-27T23:11:23.000Z | 2022-03-25T12:31:29.000Z | //==================================================================================================
/**
EVE - Expressive Vector Engine
Copyright : EVE Contributors & Maintainers
SPDX-License-Identifier: MIT
**/
//==================================================================================================
#include "test.hpp"
#include <eve/traits/cardinal.hpp>
#include <eve/logical.hpp>
#include <eve/wide.hpp>
TTS_CASE( "Check for scalar cardinals")
{
TTS_TYPE_IS( eve::cardinal_t<float> , eve::scalar_cardinal );
TTS_EQUAL ( eve::cardinal_v<float> , 1 );
TTS_TYPE_IS( eve::cardinal_t<eve::logical<float>> , eve::scalar_cardinal );
TTS_EQUAL ( eve::cardinal_v<eve::logical<float>> , 1 );
};
TTS_CASE_TPL( "Check for wide cardinals"
, eve::fixed<1>
, eve::fixed<2>
, eve::fixed<4>
, eve::fixed<8>
, eve::fixed<16>
, eve::fixed<32>
, eve::fixed<64>
, eve::fixed<128>
)
<typename T>(::tts::type<T>)
{
TTS_TYPE_IS( (eve::cardinal_t< eve::wide<float, T> >), T );
TTS_EQUAL ( (eve::cardinal_v< eve::wide<float, T> >), T::value );
TTS_TYPE_IS( (eve::cardinal_t< eve::logical<eve::wide<float, T> >>), T );
TTS_EQUAL ( (eve::cardinal_v< eve::logical<eve::wide<float, T> >>), T::value );
};
TTS_CASE_TPL( "Check for SIMD tuple-like type cardinals"
, eve::fixed<1>
, eve::fixed<2>
, eve::fixed<4>
, eve::fixed<8>
, eve::fixed<16>
, eve::fixed<32>
, eve::fixed<64>
, eve::fixed<128>
)
<typename T>(::tts::type<T>)
{
using tuple_t = kumi::tuple<float,double,char>;
TTS_TYPE_IS( (eve::cardinal_t<eve::wide<tuple_t, T>>), T );
TTS_EQUAL ( (eve::cardinal_v<eve::wide<tuple_t, T>>), T::value );
};
| 32.206897 | 100 | 0.496253 | [
"vector"
] |
d6ca747e84753d2d8462b8284bbfe215a456f902 | 3,336 | cpp | C++ | Implementations/11 - Math (4)/Numerical/Vector Operators.cpp | wangdongx/USACO | b920acd85e1d1e633333b14b424026a4dfe42234 | [
"MIT"
] | null | null | null | Implementations/11 - Math (4)/Numerical/Vector Operators.cpp | wangdongx/USACO | b920acd85e1d1e633333b14b424026a4dfe42234 | [
"MIT"
] | null | null | null | Implementations/11 - Math (4)/Numerical/Vector Operators.cpp | wangdongx/USACO | b920acd85e1d1e633333b14b424026a4dfe42234 | [
"MIT"
] | null | null | null | /**
* Description: modular arithmetic with vectors
* use for NTT
* Source: Own
* Verification: see FFT
*/
namespace vecOp {
template<class T> vector<T> rev(vector<T> v) { reverse(all(v)); return v; }
template<class T> vector<T> shift(vector<T> v, int x) { v.insert(v.begin(),x,0); return v; }
template<class T> vector<T> integ(const vector<T>& v) {
vector<T> res(sz(v)+1);
F0R(i,sz(v)) res[i+1] = v[i]/(i+1);
return res;
}
template<class T> vector<T> dif(const vector<T>& v) {
if (!sz(v)) return v;
vector<T> res(sz(v)-1); FOR(i,1,sz(v)) res[i-1] = i*v[i];
return res;
}
template<class T> vector<T>& remLead(vector<T>& v) {
while (sz(v) && v.back() == 0) v.pop_back();
return v;
}
template<class T> T eval(const vector<T>& v, const T& x) {
T res = 0; F0Rd(i,sz(v)) res = x*res+v[i];
return res;
}
template<class T> vector<T>& operator+=(vector<T>& l, const vector<T>& r) {
l.rsz(max(sz(l),sz(r))); F0R(i,sz(r)) l[i] += r[i]; return l;
}
template<class T> vector<T>& operator-=(vector<T>& l, const vector<T>& r) {
l.rsz(max(sz(l),sz(r))); F0R(i,sz(r)) l[i] -= r[i]; return l;
}
template<class T> vector<T>& operator*=(vector<T>& l, const T& r) { trav(t,l) t *= r; return l; }
template<class T> vector<T>& operator/=(vector<T>& l, const T& r) { trav(t,l) t /= r; return l; }
template<class T> vector<T> operator+(vector<T> l, const vector<T>& r) { return l += r; }
template<class T> vector<T> operator-(vector<T> l, const vector<T>& r) { return l -= r; }
template<class T> vector<T> operator*(vector<T> l, const T& r) { return l *= r; }
template<class T> vector<T> operator*(const T& r, const vector<T>& l) { return l*r; }
template<class T> vector<T> operator/(vector<T> l, const T& r) { return l /= r; }
template<class T> vector<T> operator*(const vector<T>& l, const vector<T>& r) {
if (min(sz(l),sz(r)) == 0) return {};
vector<T> x(sz(l)+sz(r)-1); F0R(i,sz(l)) F0R(j,sz(r)) x[i+j] += l[i]*r[j];
return x;
}
template<class T> vector<T>& operator*=(vector<T>& l, const vector<T>& r) { return l = l*r; }
template<class T> pair<vector<T>,vector<T>> qr(vector<T> a, vector<T> b) { // quotient and remainder
auto B = b.back(); assert(sz(b) && B != 0);
B = 1/B; trav(t,b) t *= B;
remLead(a); vector<T> q(max(sz(a)-sz(b)+1,0));
while (sz(a) >= sz(b)) {
q[sz(a)-sz(b)] = a.back();
a -= a.back()*shift(b,sz(a)-sz(b));
remLead(a);
}
trav(t,q) t *= B;
return {q,a};
}
template<class T> vector<T> quo(const vector<T>& a, const vector<T>& b) { return qr(a,b).f; }
template<class T> vector<T> rem(const vector<T>& a, const vector<T>& b) { return qr(a,b).s; }
template<class T> vector<T> interpolate(vector<pair<T,T>> v) {
vector<T> ret, prod = {1};
F0R(i,sz(v)) {
vector<T> tmp = {-v[i].f,1};
prod *= tmp;
}
F0R(i,sz(v)) {
T todiv = 1; F0R(j,sz(v)) if (i != j) todiv *= v[i].f-v[j].f;
ret += qr(prod,{-v[i].f,1}).f*(v[i].s/todiv);
}
return ret;
}
}
using namespace vecOp; | 40.192771 | 104 | 0.516487 | [
"vector"
] |
d6cfd18797ddf0d8683a562420d3b8783d12a1b4 | 1,444 | hpp | C++ | lumino/Graphics/include/LuminoGraphics/RHI/DepthBuffer.hpp | lriki/Lumino | 1a80430f4a83dbdfbe965b3d5b16064991b3edb0 | [
"MIT"
] | 30 | 2016-01-24T05:35:45.000Z | 2020-03-03T09:54:27.000Z | lumino/Graphics/include/LuminoGraphics/RHI/DepthBuffer.hpp | lriki/Lumino | 1a80430f4a83dbdfbe965b3d5b16064991b3edb0 | [
"MIT"
] | 35 | 2016-04-18T06:14:08.000Z | 2020-02-09T15:51:58.000Z | lumino/Graphics/include/LuminoGraphics/RHI/DepthBuffer.hpp | lriki/Lumino | 1a80430f4a83dbdfbe965b3d5b16064991b3edb0 | [
"MIT"
] | 5 | 2016-04-03T02:52:05.000Z | 2018-01-02T16:53:06.000Z | // Copyright (c) 2019+ lriki. Distributed under the MIT license.
#pragma once
#include "GraphicsResource.hpp"
namespace ln {
/** 深度バッファのクラスです。 */
class DepthBuffer
: public Object
, public IGraphicsResource
{
public:
/**
* 深度バッファを作成します。
* @param[in] width : 幅 (px 単位)
* @param[in] height : 高さ (px 単位)
*/
static Ref<DepthBuffer> create(int width, int height);
/** 一時的な DepthBuffer を取得します。(内容の保証はありません。使用する前に必ずクリアしてください) */
static Ref<DepthBuffer> getTemporary(int width, int height);
/** getTemporary で取得した一時的な DepthBuffer を解放します。 */
static void releaseTemporary(DepthBuffer* depthBuffer);
/** 幅を取得します。(ピクセル単位) */
int width() const { return m_size.width; }
/** 高さを取得します。 (ピクセル単位) */
int height() const { return m_size.height; }
bool m_cleared = false;
protected:
void onDispose(bool explicitDisposing) override;
void onManagerFinalizing() override { dispose(); }
void onChangeDevice(detail::IGraphicsDevice* device) override;
LN_CONSTRUCT_ACCESS:
DepthBuffer();
virtual ~DepthBuffer();
/** @copydoc create(int, int) */
void init(int width, int height);
private:
detail::RHIResource* resolveRHIObject(GraphicsCommandList* context, bool* outModified);
detail::GraphicsManager* m_manager;
Ref<detail::RHIResource> m_rhiObject;
SizeI m_size;
friend class detail::GraphicsResourceInternal;
};
} // namespace ln
| 25.333333 | 91 | 0.682133 | [
"object"
] |
d6d2346e2db4c7a730bd7d49a007fc28555d3b05 | 4,638 | hpp | C++ | include/indicators/progress_spinner.hpp | sdmg15/indicators | a41c7c118ec4170ab2302bc75e2c540d1a65d788 | [
"BSD-3-Clause",
"MIT"
] | 1 | 2021-09-18T22:25:23.000Z | 2021-09-18T22:25:23.000Z | include/indicators/progress_spinner.hpp | sdmg15/indicators | a41c7c118ec4170ab2302bc75e2c540d1a65d788 | [
"BSD-3-Clause",
"MIT"
] | null | null | null | include/indicators/progress_spinner.hpp | sdmg15/indicators | a41c7c118ec4170ab2302bc75e2c540d1a65d788 | [
"BSD-3-Clause",
"MIT"
] | null | null | null | /*
Activity Indicators for Modern C++
https://github.com/p-ranav/indicators
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
SPDX-License-Identifier: MIT
Copyright (c) 2019 Pranav Srinivas Kumar <pranav.srinivas.kumar@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.
*/
#pragma once
#include <atomic>
#include <indicators/color.hpp>
#include <iostream>
#include <mutex>
#include <string>
#include <thread>
#include <vector>
namespace indicators {
class ProgressSpinner {
public:
void set_foreground_color(Color color) {
std::unique_lock<std::mutex> lock{_mutex};
_foreground_color = color;
}
void set_prefix_text(const std::string &text) {
std::unique_lock<std::mutex> lock{_mutex};
_prefix_text = text;
}
void set_postfix_text(const std::string &text) {
std::unique_lock<std::mutex> lock{_mutex};
_postfix_text = text;
if (_postfix_text.length() > _max_postfix_text_length)
_max_postfix_text_length = _postfix_text.length();
}
void show_percentage() { _show_percentage = true; }
void hide_percentage() { _show_percentage = false; }
void show_spinner() { _show_spinner = true; }
void hide_spinner() { _show_spinner = false; }
void set_progress(float value) {
{
std::unique_lock<std::mutex> lock{_mutex};
_progress = value;
}
_print_progress();
}
void tick() {
{
std::unique_lock<std::mutex> lock{_mutex};
_progress += 1;
}
_print_progress();
}
size_t current() {
return std::min(static_cast<size_t>(_progress), size_t(100));
}
bool is_completed() const { return _completed; }
void mark_as_completed() {
_completed = true;
_print_progress();
}
void set_spinner_states(const std::vector<std::string> &states) {
std::unique_lock<std::mutex> lock{_mutex};
_states = states;
}
private:
float _progress{0.0};
std::string _prefix_text{""};
size_t _index{0};
std::vector<std::string> _states{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"};
std::string _postfix_text{""};
std::atomic<size_t> _max_postfix_text_length{0};
std::atomic<bool> _completed{false};
std::atomic<bool> _show_percentage{true};
std::atomic<bool> _show_spinner{true};
std::mutex _mutex;
Color _foreground_color;
void _print_progress() {
std::unique_lock<std::mutex> lock{_mutex};
std::cout << termcolor::bold;
switch (_foreground_color) {
case Color::GREY:
std::cout << termcolor::grey;
break;
case Color::RED:
std::cout << termcolor::red;
break;
case Color::GREEN:
std::cout << termcolor::green;
break;
case Color::YELLOW:
std::cout << termcolor::yellow;
break;
case Color::BLUE:
std::cout << termcolor::blue;
break;
case Color::MAGENTA:
std::cout << termcolor::magenta;
break;
case Color::CYAN:
std::cout << termcolor::cyan;
break;
case Color::WHITE:
std::cout << termcolor::white;
break;
}
std::cout << _prefix_text;
if (_show_spinner)
std::cout << _states[_index % _states.size()];
if (_show_percentage) {
std::cout << " " << std::min(static_cast<size_t>(_progress), size_t(100)) << "%";
}
if (_max_postfix_text_length == 0)
_max_postfix_text_length = 10;
std::cout << " " << _postfix_text << std::string(_max_postfix_text_length, ' ') << "\r";
std::cout.flush();
_index += 1;
if (_progress > 100.0) {
_completed = true;
}
if (_completed)
std::cout << termcolor::reset << std::endl;
}
};
} // namespace indicators
| 29.169811 | 92 | 0.667529 | [
"vector"
] |
d6d3166e9bc3a90ebc2423d65a17eb502fc3de81 | 1,903 | hpp | C++ | clove/components/core/graphics/include/Clove/Graphics/Metal/MetalDescriptorPool.hpp | AGarlicMonkey/Garlic | 4f439b789b7db9fc7b2c104705f259c318be62fd | [
"MIT"
] | 33 | 2020-01-09T04:57:29.000Z | 2021-08-14T08:02:43.000Z | clove/components/core/graphics/include/Clove/Graphics/Metal/MetalDescriptorPool.hpp | AGarlicMonkey/Garlic | 4f439b789b7db9fc7b2c104705f259c318be62fd | [
"MIT"
] | 234 | 2019-10-25T06:04:35.000Z | 2021-08-18T05:47:41.000Z | clove/components/core/graphics/include/Clove/Graphics/Metal/MetalDescriptorPool.hpp | AGarlicMonkey/Garlic | 4f439b789b7db9fc7b2c104705f259c318be62fd | [
"MIT"
] | 4 | 2020-02-11T15:28:42.000Z | 2020-09-07T16:22:58.000Z | #pragma once
#include "Clove/Graphics/GhaDescriptorPool.hpp"
#include <MetalKit/MetalKit.h>
#include <unordered_map>
#include <vector>
namespace clove {
class MetalDescriptorSet;
}
namespace clove {
class MetalDescriptorPool : public GhaDescriptorPool {
//TYPES
private:
class BufferPool {
//TYPES
private:
struct BufferEntry {
bool isFree{ true };
id<MTLBuffer> buffer{ nullptr };
};
//VARIABLES
private:
std::unordered_map<size_t, std::vector<BufferEntry>> buffers{};
//FUNCTIONS
public:
BufferPool();
~BufferPool();
id<MTLBuffer> allocateBuffer(id<MTLDevice> device, size_t size);
void freeBuffer(id<MTLBuffer> buffer);
void reset();
};
//VARIABLES
private:
Descriptor descriptor{};
id<MTLDevice> device{ nullptr };
BufferPool bufferPool{};
//FUNCTIONS
public:
MetalDescriptorPool() = delete;
MetalDescriptorPool(Descriptor descriptor, id<MTLDevice> device);
MetalDescriptorPool(MetalDescriptorPool const &other) = delete;
MetalDescriptorPool(MetalDescriptorPool &&other) noexcept;
MetalDescriptorPool &operator=(MetalDescriptorPool const &other) = delete;
MetalDescriptorPool &operator=(MetalDescriptorPool &&other) noexcept;
~MetalDescriptorPool();
Descriptor const &getDescriptor() const override;
std::unique_ptr<GhaDescriptorSet> allocateDescriptorSets(GhaDescriptorSetLayout const *const layout) override;
std::vector<std::unique_ptr<GhaDescriptorSet>> allocateDescriptorSets(std::vector<GhaDescriptorSetLayout const *> const &layouts) override;
void freeDescriptorSets(std::unique_ptr<GhaDescriptorSet> &descriptorSet) override;
void freeDescriptorSets(std::vector<std::unique_ptr<GhaDescriptorSet>> &descriptorSets) override;
void reset() override;
private:
void freeBuffers(MetalDescriptorSet &descriptorSet);
};
}
| 25.373333 | 141 | 0.730426 | [
"vector"
] |
d6de1ce21d13b1cb1a5e6a93998b1d9516105b47 | 6,336 | cpp | C++ | examples/__oldFiles__/bufferInstancing.cpp | maldicion069/monkeybrush- | 2bccca097402ff1f5344e356f06de19c8c70065b | [
"MIT"
] | 1 | 2016-11-15T09:04:12.000Z | 2016-11-15T09:04:12.000Z | examples/__oldFiles__/bufferInstancing.cpp | maldicion069/monkeybrush- | 2bccca097402ff1f5344e356f06de19c8c70065b | [
"MIT"
] | null | null | null | examples/__oldFiles__/bufferInstancing.cpp | maldicion069/monkeybrush- | 2bccca097402ff1f5344e356f06de19c8c70065b | [
"MIT"
] | null | null | null | /*
* Copyright (c) 2016 maldicion069
*
* Authors: Cristian Rodríguez Bernal <ccrisrober@gmail.com>
*
* This file is part of MonkeyBrushPlusPlus <https://github.com/maldicion069/monkeybrushplusplus>
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3.0 as published
* by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include <iostream>
#include <mb/mb.h>
mb::Scene* scene;
void renderFunc( float dt );
mb::Program program;
mb::Drawable* model;
class BufferGeometry
{
public:
std::map<std::string, mb::BufferAttribute*> data;
std::map<std::string, mb::VertexBuffer*> buffers;
std::vector<unsigned int> indices;
};
BufferGeometry geometry;
GLuint VertexArrayID;
GLuint vertexbuffer;
GLuint colorbuffer;
int main(void)
{
mb::GLContext context(3, 3, 1024, 768, "Hello MonkeyBrush");
auto engine = new mb::Engine(&context, false);
scene = new mb::Scene(engine, new mb::SimpleCamera(mb::Vect3(0.2f, 0.18f, 8.44f)));
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
static const GLfloat g_vertex_buffer_data[] = {
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f
};
static const GLfloat g_color_buffer_data[] = {
0.583f, 0.771f, 0.014f,
0.609f, 0.115f, 0.436f,
0.327f, 0.483f, 0.844f,
0.822f, 0.569f, 0.201f,
0.435f, 0.602f, 0.223f,
0.310f, 0.747f, 0.185f,
0.597f, 0.770f, 0.761f,
0.559f, 0.436f, 0.730f,
0.359f, 0.583f, 0.152f,
0.483f, 0.596f, 0.789f,
0.559f, 0.861f, 0.639f,
0.195f, 0.548f, 0.859f,
0.014f, 0.184f, 0.576f,
0.771f, 0.328f, 0.970f,
0.406f, 0.615f, 0.116f,
0.676f, 0.977f, 0.133f,
0.971f, 0.572f, 0.833f,
0.140f, 0.616f, 0.489f,
0.997f, 0.513f, 0.064f,
0.945f, 0.719f, 0.592f,
0.543f, 0.021f, 0.978f,
0.279f, 0.317f, 0.505f,
0.167f, 0.620f, 0.077f,
0.347f, 0.857f, 0.137f,
0.055f, 0.953f, 0.042f,
0.714f, 0.505f, 0.345f,
0.783f, 0.290f, 0.734f,
0.722f, 0.645f, 0.174f,
0.302f, 0.455f, 0.848f,
0.225f, 0.587f, 0.040f,
0.517f, 0.713f, 0.338f,
0.053f, 0.959f, 0.120f,
0.393f, 0.621f, 0.362f,
0.673f, 0.211f, 0.457f,
0.820f, 0.883f, 0.371f,
0.982f, 0.099f, 0.879f
};
glGenBuffers(1, &vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_buffer_data), g_vertex_buffer_data, GL_STATIC_DRAW);
glGenBuffers(1, &colorbuffer);
glBindBuffer(GL_ARRAY_BUFFER, colorbuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_color_buffer_data), g_color_buffer_data, GL_STATIC_DRAW);
program.loadVertexShaderFromText("#version 330\n"
"in vec3 position;\n"
"in vec3 vertexColor;\n"
"flat out vec3 fragmentColor;\n"
"uniform mat4 proj;\n"
"uniform mat4 view;\n"
"uniform mat4 model;\n"
"void main( void ) {\n"
" gl_Position = proj * view * model * vec4(position, 1.0);\n"
" fragmentColor = vertexColor;\n"
"}\n"
);
program.loadFragmentShaderFromText("#version 330\n"
"out vec4 fragColor;\n"
"flat in vec3 fragmentColor;\n"
"void main( void ) {\n"
" fragColor = vec4(fragmentColor, 1.0);\n"
"}\n");
program.compileAndLink( );
program.autocatching(true, true);
auto attrs = program.attributes();
engine->run(renderFunc);
delete(scene);
delete(engine);
return 0;
}
void renderFunc( float dt )
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
scene->mainCamera->update(dt);
program.use();
mb::Mat4 proj = scene->mainCamera->projectionMatrix(1024, 768);
mb::Mat4 view = scene->mainCamera->viewMatrix();
program.sendUniform4m("proj", proj._values.data());
program.sendUniform4m("view", view._values.data());
program.sendUniform4m("model", mb::Mat4()._values);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_CULL_FACE);
glBindVertexArray(VertexArrayID);
// 1rst attribute buffer : vertices
glEnableVertexAttribArray(0);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
0, // attribute. No particular reason for 0, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// 2nd attribute buffer : colors
glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, colorbuffer);
glVertexAttribPointer(
1, // attribute. No particular reason for 1, but must match the layout in the shader.
3, // size
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
// Draw the triangle !
glDrawArrays(GL_TRIANGLES, 0, 12*3); // 12*3 indices starting at 0 -> 12 triangles
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);
program.unuse();
}
| 28.669683 | 120 | 0.613005 | [
"geometry",
"vector",
"model"
] |
d6e09aa4fd38a7bce6e682ed5ab0c1d7098cb204 | 3,927 | cxx | C++ | Modules/Segmentation/Conversion/test/otbVectorDataToLabelImageFilterWithoutReader.cxx | qingswu/otb | ed903b6a5e51a27a3d04786e4ad1637cf6b2772e | [
"Apache-2.0"
] | null | null | null | Modules/Segmentation/Conversion/test/otbVectorDataToLabelImageFilterWithoutReader.cxx | qingswu/otb | ed903b6a5e51a27a3d04786e4ad1637cf6b2772e | [
"Apache-2.0"
] | null | null | null | Modules/Segmentation/Conversion/test/otbVectorDataToLabelImageFilterWithoutReader.cxx | qingswu/otb | ed903b6a5e51a27a3d04786e4ad1637cf6b2772e | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* 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 "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"
#include "otbVectorDataToLabelImageFilter.h"
#include "otbStandardOneLineFilterWatcher.h"
typedef otb::Image<unsigned int, 2> ImageType;
typedef otb::VectorData<> VectorDataType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ImageFileWriter<ImageType> WriterType;
typedef otb::VectorDataToLabelImageFilter<VectorDataType, ImageType> RasterizationFilterType;
typedef VectorDataType::DataNodeType DataNodeType;
typedef DataNodeType::PointType PointType;
typedef DataNodeType::LineType LineType;
typedef DataNodeType::PolygonType PolygonType;
typedef LineType::VertexType VertexType;
int main(int itkNotUsed(argc), char* argv[])
{
// OGRRegisterAll();
// Create vector Data
VectorDataType::Pointer data = VectorDataType::New();
DataNodeType::Pointer document = DataNodeType::New();
DataNodeType::Pointer folder = DataNodeType::New();
DataNodeType::Pointer polygon1 = DataNodeType::New();
DataNodeType::Pointer polygon2 = DataNodeType::New();
DataNodeType::Pointer polygon3 = DataNodeType::New();
DataNodeType::Pointer polygon4 = DataNodeType::New();
DataNodeType::Pointer polygon5 = DataNodeType::New();
document->SetNodeType(otb::DOCUMENT);
folder->SetNodeType(otb::FOLDER);
polygon1->SetNodeType(otb::FEATURE_POLYGON);
document->SetNodeId("DOCUMENT");
folder->SetNodeId("THE_FOLDER");
polygon1->SetNodeId("FEATURE_POLYGON");
VertexType p1;
p1.Fill(1);
VertexType p3;
p3.Fill(11);
VertexType p2;
p2[0] = 1;
p2[1] = 11;
VertexType p4;
p4[0] = 11;
p4[1] = 1;
PolygonType::Pointer poly1 = PolygonType::New();
poly1->AddVertex(p1);
poly1->AddVertex(p2);
poly1->AddVertex(p3);
poly1->AddVertex(p4);
poly1->AddVertex(p1);
polygon1->SetPolygonExteriorRing(poly1);
polygon1->SetFieldAsInt("DN", 32);
p1.Fill(51);
p3.Fill(61);
p2[0] = 51;
p2[1] = 61;
p4[0] = 61;
p4[1] = 51;
PolygonType::Pointer poly2 = PolygonType::New();
poly2->AddVertex(p1);
poly2->AddVertex(p2);
poly2->AddVertex(p3);
poly2->AddVertex(p4);
poly2->AddVertex(p1);
polygon2->SetLine(poly2);
polygon2->SetFieldAsInt("DN", 64);
DataNodeType::Pointer root = data->GetDataTree()->GetRoot()->Get();
data->GetDataTree()->Add(document, root);
data->GetDataTree()->Add(folder, document);
data->GetDataTree()->Add(polygon1, folder);
data->GetDataTree()->Add(polygon2, folder);
data->Update();
// rasterize
RasterizationFilterType::Pointer rasterization = RasterizationFilterType::New();
rasterization->AddVectorData(data);
rasterization->SetBurnAttribute("DN");
// image infos
ImageType::SizeType size;
size[0] = 100;
size[1] = 100;
ImageType::PointType origin;
origin[0] = 0;
origin[1] = 0;
ImageType::SpacingType spacing;
spacing[0] = 1;
spacing[1] = 1;
rasterization->SetOutputSize(size);
rasterization->SetOutputOrigin(origin);
rasterization->SetOutputSpacing(spacing);
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(argv[1]);
writer->SetInput(rasterization->GetOutput());
writer->Update();
return EXIT_SUCCESS;
}
| 25.5 | 93 | 0.71454 | [
"vector"
] |
d6e40c96615875af75048c974a0cce3f8ad389fe | 10,509 | cpp | C++ | bindings/Fortran/f2c/adios2_f2c_variable.cpp | germasch/ADIOS2 | 9930706da50ebb59dda9c1ef3ee51992e8ce217a | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | bindings/Fortran/f2c/adios2_f2c_variable.cpp | germasch/ADIOS2 | 9930706da50ebb59dda9c1ef3ee51992e8ce217a | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | bindings/Fortran/f2c/adios2_f2c_variable.cpp | germasch/ADIOS2 | 9930706da50ebb59dda9c1ef3ee51992e8ce217a | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | /*
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* adios2_f2c_variable.cpp
*
* Created on: Nov 12, 2017
* Author: William F Godoy godoywf@ornl.gov
*/
#include "adios2_f2c_common.h"
#include "adios2/helper/adiosFunctions.h"
#ifdef __cplusplus
extern "C" {
#endif
void FC_GLOBAL(adios2_variable_name_f2c,
ADIOS2_VARIABLE_NAME_F2C)(char name[4096], int *size,
const adios2_variable **variable,
int *ierr)
{
*size = -1;
size_t sizeC;
*ierr = static_cast<int>(adios2_variable_name(name, &sizeC, *variable));
if (*ierr == static_cast<int>(adios2_error_none))
{
*size = static_cast<int>(sizeC);
}
}
void FC_GLOBAL(adios2_variable_type_f2c,
ADIOS2_VARIABLE_TYPE_F2C)(int *type,
const adios2_variable **variable,
int *ierr)
{
*type = -1;
adios2_type typeC;
*ierr = static_cast<int>(adios2_variable_type(&typeC, *variable));
if (*ierr == static_cast<int>(adios2_error_none))
{
*type = static_cast<int>(typeC);
}
}
void FC_GLOBAL(adios2_variable_ndims_f2c,
ADIOS2_VARIABLE_NDIMS_F2C)(int *ndims,
const adios2_variable **variable,
int *ierr)
{
*ndims = -1;
size_t ndimsC;
*ierr = static_cast<int>(adios2_variable_ndims(&ndimsC, *variable));
if (*ierr == static_cast<int>(adios2_error_none))
{
*ndims = static_cast<int>(ndimsC);
}
}
void FC_GLOBAL(adios2_variable_shape_f2c,
ADIOS2_VARIABLE_SHAPE_F2C)(int64_t *shape,
const adios2_variable **variable,
int *ierr)
{
size_t ndims;
*ierr = static_cast<int>(adios2_variable_ndims(&ndims, *variable));
if (*ierr > 0)
{
return;
}
size_t shapeC[ndims];
*ierr = static_cast<int>(adios2_variable_shape(shapeC, *variable));
if (*ierr > 0)
{
return;
}
for (auto d = 0; d < ndims; ++d)
{
shape[d] = static_cast<int64_t>(shapeC[d]);
}
}
void FC_GLOBAL(adios2_variable_steps_f2c,
adios2_variable_STEPS_F2C)(int64_t *steps,
const adios2_variable **variable,
int *ierr)
{
*steps = -1;
size_t stepsC;
*ierr = static_cast<int>(adios2_variable_steps(&stepsC, *variable));
if (*ierr == static_cast<int>(adios2_error_none))
{
*steps = static_cast<int64_t>(stepsC);
}
}
void FC_GLOBAL(adios2_set_shape_f2c,
ADIOS2_SET_SHAPE_F2C)(adios2_variable **variable,
const int *ndims, const int64_t *shape,
int *ierr)
{
auto lf_IntToSizeT = [](const int64_t *dimensions, const int size,
std::vector<std::size_t> &output) {
output.resize(size);
for (auto d = 0; d < size; ++d)
{
output[d] = dimensions[d];
}
};
try
{
if (shape == nullptr || ndims == nullptr)
{
throw std::invalid_argument(
"ERROR: either shape_dims, or ndims is a null pointer, in call "
"to adios2_set_shape\n");
}
std::vector<std::size_t> shapeV;
lf_IntToSizeT(shape, *ndims, shapeV);
*ierr = static_cast<int>(
adios2_set_shape(*variable, *ndims, shapeV.data()));
}
catch (...)
{
*ierr = static_cast<int>(
adios2::helper::ExceptionToError("adios2_set_shape"));
}
}
void FC_GLOBAL(adios2_set_block_selection_f2c,
ADIOS2_SET_BLOCK_SELECTION_F2C)(adios2_variable **variable,
const int64_t *block_id,
int *ierr)
{
*ierr = static_cast<int>(adios2_set_block_selection(*variable, *block_id));
}
void FC_GLOBAL(adios2_set_selection_f2c,
ADIOS2_SET_SELECTION_F2C)(adios2_variable **variable,
const int *ndims, const int64_t *start,
const int64_t *count, int *ierr)
{
auto lf_IntToSizeT = [](const int64_t *dimensions, const int size,
std::vector<std::size_t> &output) {
output.resize(size);
for (auto d = 0; d < size; ++d)
{
output[d] = dimensions[d];
}
};
try
{
if (start == nullptr || count == nullptr || ndims == nullptr)
{
throw std::invalid_argument("ERROR: either start_dims, count_dims "
"or ndims is a null pointer, in call "
"to adios2_set_selection\n");
}
std::vector<std::size_t> startV, countV;
lf_IntToSizeT(start, *ndims, startV);
lf_IntToSizeT(count, *ndims, countV);
*ierr = static_cast<int>(adios2_set_selection(
*variable, *ndims, startV.data(), countV.data()));
}
catch (...)
{
*ierr = static_cast<int>(
adios2::helper::ExceptionToError("adios2_set_selection"));
}
}
void FC_GLOBAL(adios2_set_memory_selection_f2c,
ADIOS2_SET_MEMORY_SELECTION_F2C)(adios2_variable **variable,
const int *ndims,
const int64_t *memory_start,
const int64_t *memory_count,
int *ierr)
{
auto lf_IntToSizeT = [](const int64_t *dimensions, const int size,
std::vector<std::size_t> &output) {
output.resize(size);
for (auto d = 0; d < size; ++d)
{
output[d] = dimensions[d];
}
};
try
{
if (memory_start == nullptr || memory_count == nullptr ||
ndims == nullptr)
{
throw std::invalid_argument("ERROR: either start_dims, count_dims "
"or ndims is a null pointer, in call "
"to adios2_set_memory_selection\n");
}
std::vector<std::size_t> memoryStartV, memoryCountV;
lf_IntToSizeT(memory_start, *ndims, memoryStartV);
lf_IntToSizeT(memory_count, *ndims, memoryCountV);
*ierr = static_cast<int>(adios2_set_memory_selection(
*variable, *ndims, memoryStartV.data(), memoryCountV.data()));
}
catch (...)
{
*ierr = static_cast<int>(
adios2::helper::ExceptionToError("adios2_set_memory_selection"));
}
}
void FC_GLOBAL(adios2_set_step_selection_f2c,
ADIOS2_SET_STEP_SELECTION_F2C)(adios2_variable **variable,
const int64_t *step_start,
const int64_t *step_count,
int *ierr)
{
try
{
if (step_start == nullptr || step_count == nullptr)
{
throw std::invalid_argument(
"ERROR: either step_start or step_count "
"are null pointers, in call to "
"adios2_set_step_selection\n");
}
if (step_start[0] < 0)
{
throw std::invalid_argument("ERROR: negative step_start in call to "
"adios2_set_step_selection\n");
}
if (step_count[0] < 0)
{
throw std::invalid_argument("ERROR: negative step_count in call to "
"adios2_set_step_selection\n");
}
const std::size_t stepStart = static_cast<std::size_t>(*step_start);
const std::size_t stepCount = static_cast<std::size_t>(*step_count);
*ierr = adios2_set_step_selection(*variable, stepStart, stepCount);
}
catch (...)
{
*ierr = static_cast<int>(
adios2::helper::ExceptionToError("adios2_set_selection"));
}
}
void FC_GLOBAL(adios2_add_operation_f2c,
ADIOS2_ADD_OPERATION_F2C)(int *operation_id,
adios2_variable **variable,
adios2_operator **op, const char *key,
const char *value, int *ierr)
{
*operation_id = -1;
size_t operation_idC;
*ierr = static_cast<int>(
adios2_add_operation(&operation_idC, *variable, *op, key, value));
if (*ierr == static_cast<int>(adios2_error_none))
{
*operation_id = static_cast<int>(operation_idC);
}
}
void FC_GLOBAL(adios2_set_operation_parameter_f2c,
ADIOS2_SET_OPERATION_PARAMETER_F2C)(adios2_variable **variable,
const int *operation_id,
const char *key,
const char *value, int *ierr)
{
try
{
if (*operation_id < 0)
{
throw std::invalid_argument("ERROR: operation_id can't be "
"negative, in call to "
"adios2_set_operation_paramter");
}
*ierr = static_cast<int>(adios2_set_operation_parameter(
*variable, static_cast<std::size_t>(*operation_id), key, value));
}
catch (...)
{
*ierr = static_cast<int>(
adios2::helper::ExceptionToError("adios2_set_operation_parameter"));
}
}
void FC_GLOBAL(adios2_variable_min_f2c,
ADIOS2_VARIABLE_MIN_F2C)(void *min,
const adios2_variable **variable,
int *ierr)
{
*ierr = static_cast<int>(adios2_variable_min(min, *variable));
}
void FC_GLOBAL(adios2_variable_max_f2c,
ADIOS2_VARIABLE_MAX_F2C)(void *max,
const adios2_variable **variable,
int *ierr)
{
*ierr = static_cast<int>(adios2_variable_max(max, *variable));
}
#ifdef __cplusplus
}
#endif
| 32.636646 | 80 | 0.517937 | [
"shape",
"vector"
] |
d6e768b97e33ac1fb897681e3c39f55a591a70e2 | 10,252 | cpp | C++ | src/objs/Projections.cpp | nasa-jpl/Cassini_RADAR_Software | 93a5be34d013c2913cf74f06e01c59b625bb4a17 | [
"Apache-2.0"
] | 4 | 2021-08-12T23:55:41.000Z | 2022-02-23T03:32:46.000Z | src/objs/Projections.cpp | nasa-jpl/Cassini_RADAR_Software | 93a5be34d013c2913cf74f06e01c59b625bb4a17 | [
"Apache-2.0"
] | null | null | null | src/objs/Projections.cpp | nasa-jpl/Cassini_RADAR_Software | 93a5be34d013c2913cf74f06e01c59b625bb4a17 | [
"Apache-2.0"
] | null | null | null | // Class Methods for OblCylProj
static const char rcs_id_projections_c[] =
"@(#) $Id: Projections.cpp,v 11.5 2011/09/16 00:03:30 richw Exp $";
#include<string>
#include"SARFunctions.h"
#include"Projections.h"
#include"Constants.h"
#include"DebugInfo.h"
using std::string;
using std::endl;
//--------------
// Constructors
//--------------
//------------------------------------------------------------------
// Trivial (standard) projection
//------------------------------------------------------------------
OblCylProj::OblCylProj()
: is_trivial(true)
{
}
//------------------------------------------------------------------
// OblCylProj()
//
// Set up an oblique cylindrical projection in which the spacecraft
// position in s denotes the intersection of the equator and the
// prime meridian, and the spacecraft velocity direction defines the
// equator. s is presumed to be the state of Cassini in the Target
// Body Fixed frame at the time of closest approach. Note that the
// direction of the y-axis no longer depends on the look direction.
//------------------------------------------------------------------
OblCylProj::OblCylProj(StateVector& s)
{
DebugInfo dbg("OblCylProj::OblCylProj");
DirectionVector basis_x("", s.position());
DirectionVector basis_z("", cross(basis_x, s.velocity()));
DirectionVector basis_y("", cross(basis_z,basis_x));
if(dbg.level){
dbg.file << "Debug Output for OblCylProj constructor ..." << endl;
dbg.file << "Closest approach S/C position direction vector=" <<
DirectionVector("", s.position()) << endl;
dbg.file << "Closest approach S/C velocity direction vector=" <<
DirectionVector("", s.velocity()) << endl;
dbg.file << "Basis X vector=" << basis_x << endl;
dbg.file << "Basis Y vector=" << basis_y << endl;
dbg.file << "Basis Z vector=" << basis_z << endl;
dbg.file << "End Debug Output for OblCylProj constructor" << endl;
}
// Populate the rotation matrix
rotation_matrix_[0][0] = basis_x[DirectionVector::X];
rotation_matrix_[0][1] = basis_x[DirectionVector::Y];
rotation_matrix_[0][2] = basis_x[DirectionVector::Z];
rotation_matrix_[1][0] = basis_y[DirectionVector::X];
rotation_matrix_[1][1] = basis_y[DirectionVector::Y];
rotation_matrix_[1][2] = basis_y[DirectionVector::Z];
rotation_matrix_[2][0] = basis_z[DirectionVector::X];
rotation_matrix_[2][1] = basis_z[DirectionVector::Y];
rotation_matrix_[2][2] = basis_z[DirectionVector::Z];
// The Z basis vector gives the latitude (gamma_p) and longitude
// (lambda_p) of the north pole in terms of the standard system.
pole_latitude_ = atan2(rotation_matrix_[2][2],
sqrt(pow(rotation_matrix_[2][0],2) + pow(rotation_matrix_[2][1],2)));
pole_longitude_ = atan2(rotation_matrix_[2][1], rotation_matrix_[2][0]);
// The X basis vector gives the reference latitude and longitude.
reference_latitude_ = atan2(rotation_matrix_[0][2],
sqrt(pow(rotation_matrix_[0][0],2) + pow(rotation_matrix_[0][1],2)));
reference_longitude_ = atan2(rotation_matrix_[0][1], rotation_matrix_[0][0]);
// Determine the pole rotation theta_p. Use the equation for
// tan(lambda_a + theta_p). Set (gamma, lambda) to the reference
// latitude and longitude; this point lies on the X basis vector
// and thus lambda_a = 0.
pole_rotation_ = atan2(cos(reference_latitude_)*sin(reference_longitude_ -
pole_longitude_), sin(pole_latitude_)*cos(reference_latitude_)*
cos(reference_longitude_ - pole_longitude_) -
cos(pole_latitude_)*sin(reference_latitude_));
is_trivial = false;
}
//------------------------------------------------------------------
// initBurstTransformation()
//
// Right now this does nothing
// But eventually it should be used to speed up Standard <> Oblique Cyl
// transformations within a single burst
//------------------------------------------------------------------
void
OblCylProj::initBurstTransformation(){}
//------------------------------------------------------------------
// standardLatInRad()
//
// Given a latitude and longitude in the oblique system, return the
// corresponding latitude in the standard system.
//
// Use the equation for sin(gamma) from Section 2.6.2 of the BIDR SIS.
// gamma is the value being calculated, slatrad; gamma_a and lambda_a
// are the input parameters latrad and lonrad, respectively.
//------------------------------------------------------------------
double
OblCylProj::standardLatInRad(double lonrad, double latrad) const{
double slatrad;
if(is_trivial){
slatrad=latrad;
}
else{
// asin() returns values between -pi/2 and pi/2
slatrad = asin( sin(pole_latitude_)*sin(latrad) -
cos(pole_latitude_)*cos(latrad)*cos(lonrad + pole_rotation_) );
}
return(slatrad);
}
//------------------------------------------------------------------
// standardLonInRad()
//
// Given a latitude and longitude in the oblique system, return the
// corresponding longitude in the standard system.
//
// Use the equation for tan(lambda - lambda_p) from Section 2.6.2 of the
// BIDR SIS. lambda is the value being calculated, slonrad; gamma_a and
// lambda_a are the input parameters latrad and lonrad, respectively.
//
// The input parameters and return value are in radians.
//------------------------------------------------------------------
double
OblCylProj::standardLonInRad(double lonrad, double latrad) const{
double slonrad;
if(is_trivial){
slonrad=lonrad;
}
else{
slonrad = pole_longitude_ +
atan2(cos(latrad)*sin(lonrad + pole_rotation_),
sin(pole_latitude_)*cos(latrad)*cos(lonrad + pole_rotation_) +
cos(pole_latitude_)*sin(latrad));
}
return(boundLongitude(slonrad));
}
//------------------------------------------------------------------
// latInRad()
//
// Given a latitude and longitude in the standard system, return the
// corresponding latitude in the oblique system.
//
// The input parameters and return value are in radians.
//------------------------------------------------------------------
double
OblCylProj::latInRad(double slonrad, double slatrad) const {
double latrad;
double s[3], obl[3];
if(is_trivial){
latrad=slatrad;
}
else{
// Construct the position vector equivalent to (slatrad, slonrad)
s[0] = cos(slatrad)*cos(slonrad);
s[1] = cos(slatrad)*sin(slonrad);
s[2] = sin(slatrad);
rotate_vector(s, const_cast<double(*)[3]>(rotation_matrix_), obl);
latrad = atan2(obl[2], sqrt(pow(obl[0],2) + pow(obl[1],2)));
}
return(latrad);
}
//------------------------------------------------------------------
// lonInRad()
//
// Given a latitude and longitude in the standard system, return the
// corresponding longitude in the oblique system.
//
// The input parameters and return value are in radians.
//------------------------------------------------------------------
double
OblCylProj::lonInRad(double slonrad, double slatrad) const {
double lonrad;
double s[3], obl[3];
if(is_trivial){
lonrad=slonrad;
}
else{
// Construct the position vector equivalent to (slatrad, slonrad)
s[0] = cos(slatrad)*cos(slonrad);
s[1] = cos(slatrad)*sin(slonrad);
s[2] = sin(slatrad);
rotate_vector(s, const_cast<double(*)[3]>(rotation_matrix_), obl);
lonrad = atan2(obl[1], obl[0]);
}
return(boundLongitude(lonrad));
}
//------------------------------------------------------------------
// rotationMatrix()
//
// Return the 3x3 matrix for the transformation from standard to
// oblique coordinates. Its rows are OBLIQUE_PROJ_X_AXIS_VECTOR,
// OBLIQUE_PROJ_Y_AXIS_VECTOR, and OBLIQUE_PROJ_Z_AXIS_VECTOR.
//------------------------------------------------------------------
void
OblCylProj::rotationMatrix(double m[3][3]){
m[0][0] = rotation_matrix_[0][0];
m[0][1] = rotation_matrix_[0][1];
m[0][2] = rotation_matrix_[0][2];
m[1][0] = rotation_matrix_[1][0];
m[1][1] = rotation_matrix_[1][1];
m[1][2] = rotation_matrix_[1][2];
m[2][0] = rotation_matrix_[2][0];
m[2][1] = rotation_matrix_[2][1];
m[2][2] = rotation_matrix_[2][2];
}
//------------------------------------------------------------------
// poleLatitude()
//
// Return the value of OBLIQUE_PROJ_POLE_LATITUDE in degrees.
//------------------------------------------------------------------
double
OblCylProj::poleLatitude(){
return(pole_latitude_ * radtodeg);
}
//------------------------------------------------------------------
// poleLongitude()
//
// Return the value of OBLIQUE_PROJ_POLE_LONGITUDE as a positive-west
// quantity in degrees.
//------------------------------------------------------------------
double
OblCylProj::poleLongitude(){
if (pole_longitude_ == 0.0) {
return(0.0);
}
return(360.0 - boundLongitude(pole_longitude_)*radtodeg);
}
//------------------------------------------------------------------
// poleRotation()
//
// Return the value of OBLIQUE_PROJ_POLE_ROTATION in degrees.
// Use a range of 0 to 360 degrees.
//------------------------------------------------------------------
double
OblCylProj::poleRotation(){
return(boundLongitude(pole_rotation_)*radtodeg);
}
//------------------------------------------------------------------
// referenceLatitude()
//
// Return the value of REFERENCE_LATITUDE in degrees.
//------------------------------------------------------------------
double
OblCylProj::referenceLatitude(){
return(radtodeg * reference_latitude_);
}
//------------------------------------------------------------------
// referenceLongitude()
//
// Return the value of REFERENCE_LONGITUDE as a positive-west
// quantity in degrees.
//------------------------------------------------------------------
double
OblCylProj::referenceLongitude(){
if (reference_longitude_ == 0.0) {
return(0.0);
}
return(360.0 - boundLongitude(reference_longitude_)*radtodeg);
}
//------------------------------------------------------------------
// boundLongitude()
//
// Recalculate angle d as the equivalent angle in the range
// [0, 2*pi) radians.
//------------------------------------------------------------------
double
OblCylProj::boundLongitude(double d) const {
while (d < 0) {
d += 2*pi;
}
while (d >= 2*pi) {
d -= 2*pi;
}
return(d);
}
| 33.834983 | 79 | 0.570328 | [
"vector"
] |
d6ea79b0d50c483d55af3a459d58e67c55fb39d1 | 294 | cpp | C++ | less_equal.cpp | ebayboy/cpp_demos | b01df202c0285bf232900662d336505520d5d24d | [
"Apache-2.0"
] | null | null | null | less_equal.cpp | ebayboy/cpp_demos | b01df202c0285bf232900662d336505520d5d24d | [
"Apache-2.0"
] | null | null | null | less_equal.cpp | ebayboy/cpp_demos | b01df202c0285bf232900662d336505520d5d24d | [
"Apache-2.0"
] | null | null | null | #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
int main(int args, char **argv)
{
//template<class _Ty = void> struct std::less_equal<_Ty>
std::less_equal<int> le;
cout << le(5, 10) << endl;
return 0;
} | 18.375 | 60 | 0.656463 | [
"vector"
] |
d6ec8b48a79d7e820eb44fd826cae6f00f82ff7d | 1,429 | cpp | C++ | Code/Projects/Rosa/src/SDPs/sdprosafoliage.cpp | dphrygian/zeta | 2b32760558cf2b20c626cf46fcf2a382924988fe | [
"Zlib",
"Unlicense"
] | 6 | 2022-01-22T02:18:07.000Z | 2022-02-14T09:30:53.000Z | Code/Projects/Rosa/src/SDPs/sdprosafoliage.cpp | dphrygian/zeta | 2b32760558cf2b20c626cf46fcf2a382924988fe | [
"Zlib",
"Unlicense"
] | null | null | null | Code/Projects/Rosa/src/SDPs/sdprosafoliage.cpp | dphrygian/zeta | 2b32760558cf2b20c626cf46fcf2a382924988fe | [
"Zlib",
"Unlicense"
] | null | null | null | #include "core.h"
#include "sdprosafoliage.h"
#include "irenderer.h"
#include "mesh.h"
#include "rosamesh.h"
#include "vector4.h"
#include "matrix.h"
#include "rosaframework.h"
#include "rosagame.h"
#include "clock.h"
#include "view.h"
SDPRosaFoliage::SDPRosaFoliage()
{
}
SDPRosaFoliage::~SDPRosaFoliage()
{
}
/*virtual*/ void SDPRosaFoliage::SetShaderParameters( IRenderer* const pRenderer, Mesh* const pMesh, const View& CurrentView ) const
{
SDPRosaGeo::SetShaderParameters( pRenderer, pMesh, CurrentView );
RosaFramework* const pFramework = RosaFramework::GetInstance();
RosaGame* const pGame = pFramework->GetGame();
const Matrix& WindMatrix = pGame->GetWindMatrix();
Vector4 WindPhaseTime = pGame->GetWindPhaseTime();
WindPhaseTime.w = pFramework->GetClock()->GetGameCurrentTime();
const Vector4& WindPhaseSpace = pGame->GetWindPhaseSpace();
View* const pMainView = pFramework->GetMainView();
const Vector4 ViewPosition = pMainView->GetLocation();
STATIC_HASHED_STRING( WindMatrix );
pRenderer->SetVertexShaderUniform( sWindMatrix, WindMatrix );
STATIC_HASHED_STRING( WindPhaseTime );
pRenderer->SetVertexShaderUniform( sWindPhaseTime, WindPhaseTime );
STATIC_HASHED_STRING( WindPhaseSpace );
pRenderer->SetVertexShaderUniform( sWindPhaseSpace, WindPhaseSpace );
STATIC_HASHED_STRING( EyePosition );
pRenderer->SetVertexShaderUniform( sEyePosition, ViewPosition );
}
| 29.163265 | 132 | 0.760672 | [
"mesh"
] |
d6eed1fd1b5ec27881a802de8bf49624c265a67c | 9,903 | cpp | C++ | ablateLibrary/boundarySolver/lodi/inlet.cpp | mtmcgurn-buffalo/ablate | 35ee9a30277908775a61d78462ea9724ee631a9b | [
"BSD-3-Clause"
] | null | null | null | ablateLibrary/boundarySolver/lodi/inlet.cpp | mtmcgurn-buffalo/ablate | 35ee9a30277908775a61d78462ea9724ee631a9b | [
"BSD-3-Clause"
] | 8 | 2020-12-28T16:05:56.000Z | 2021-01-12T14:36:22.000Z | ablateLibrary/boundarySolver/lodi/inlet.cpp | mtmcgurn-buffalo/ablate | 35ee9a30277908775a61d78462ea9724ee631a9b | [
"BSD-3-Clause"
] | 1 | 2021-12-14T22:39:13.000Z | 2021-12-14T22:39:13.000Z | #include "inlet.hpp"
#include <utilities/mathUtilities.hpp>
#include "finiteVolume/compressibleFlowFields.hpp"
using fp = ablate::finiteVolume::processes::FlowProcess;
ablate::boundarySolver::lodi::Inlet::Inlet(std::shared_ptr<eos::EOS> eos) : LODIBoundary(std::move(eos)) {}
void ablate::boundarySolver::lodi::Inlet::Initialize(ablate::boundarySolver::BoundarySolver &bSolver) {
ablate::boundarySolver::lodi::LODIBoundary::Initialize(bSolver);
bSolver.RegisterFunction(InletFunction, this, fieldNames, fieldNames, {});
}
PetscErrorCode ablate::boundarySolver::lodi::Inlet::InletFunction(PetscInt dim, const ablate::boundarySolver::BoundarySolver::BoundaryFVFaceGeom *fg, const PetscFVCellGeom *boundaryCell,
const PetscInt *uOff, const PetscScalar *boundaryValues, const PetscScalar **stencilValues, const PetscInt *aOff,
const PetscScalar *auxValues, const PetscScalar **stencilAuxValues, PetscInt stencilSize, const PetscInt *stencil,
const PetscScalar *stencilWeights, const PetscInt *sOff, PetscScalar *source, void *ctx) {
PetscFunctionBeginUser;
auto inletBoundary = (Inlet *)ctx;
auto decodeStateFunction = inletBoundary->eos->GetDecodeStateFunction();
auto decodeStateContext = inletBoundary->eos->GetDecodeStateContext();
// Compute the transformation matrix
PetscReal transformationMatrix[3][3];
utilities::MathUtilities::ComputeTransformationMatrix(dim, fg->normal, transformationMatrix);
// Compute the pressure/values on the boundary
PetscReal boundaryDensity;
PetscReal boundaryVel[3];
PetscReal boundaryNormalVelocity;
PetscReal boundaryInternalEnergy;
PetscReal boundarySpeedOfSound;
PetscReal boundaryMach;
PetscReal boundaryPressure;
// Get the densityYi pointer if available
const PetscScalar *boundaryDensityYi = inletBoundary->nSpecEqs > 0 ? boundaryValues + uOff[inletBoundary->speciesId] : nullptr;
// Get the velocity and pressure on the surface
finiteVolume::processes::FlowProcess::DecodeEulerState(decodeStateFunction,
decodeStateContext,
dim,
boundaryValues + uOff[inletBoundary->eulerId],
boundaryDensityYi,
fg->normal,
&boundaryDensity,
&boundaryNormalVelocity,
boundaryVel,
&boundaryInternalEnergy,
&boundarySpeedOfSound,
&boundaryMach,
&boundaryPressure);
// Map the boundary velocity into the normal coord system
PetscReal boundaryVelNormCord[3];
utilities::MathUtilities::Multiply(dim, transformationMatrix, boundaryVel, boundaryVelNormCord);
// Compute each stencil point
std::vector<PetscReal> stencilDensity(stencilSize);
std::vector<std::vector<PetscReal>> stencilVel(stencilSize, std::vector<PetscReal>(dim));
std::vector<PetscReal> stencilInternalEnergy(stencilSize);
std::vector<PetscReal> stencilNormalVelocity(stencilSize);
std::vector<PetscReal> stencilSpeedOfSound(stencilSize);
std::vector<PetscReal> stencilMach(stencilSize);
std::vector<PetscReal> stencilPressure(stencilSize);
for (PetscInt s = 0; s < stencilSize; s++) {
finiteVolume::processes::FlowProcess::DecodeEulerState(decodeStateFunction,
decodeStateContext,
dim,
&stencilValues[s][uOff[inletBoundary->eulerId]],
inletBoundary->nSpecEqs > 0 ? &stencilValues[s][uOff[inletBoundary->speciesId]] : nullptr,
fg->normal,
&stencilDensity[s],
&stencilNormalVelocity[s],
&stencilVel[s][0],
&stencilInternalEnergy[s],
&stencilSpeedOfSound[s],
&stencilMach[s],
&stencilPressure[s]);
}
// Interpolate the normal velocity gradient to the surface
PetscScalar dVeldNorm;
BoundarySolver::ComputeGradientAlongNormal(dim, fg, boundaryNormalVelocity, stencilSize, &stencilNormalVelocity[0], stencilWeights, dVeldNorm);
PetscScalar dPdNorm;
BoundarySolver::ComputeGradientAlongNormal(dim, fg, boundaryPressure, stencilSize, &stencilPressure[0], stencilWeights, dPdNorm);
// Compute the temperature at the boundary
PetscReal boundaryTemperature;
inletBoundary->eos->GetComputeTemperatureFunction()(dim,
boundaryDensity,
boundaryValues[uOff[inletBoundary->eulerId] + fp::RHOE] / boundaryDensity,
boundaryValues + uOff[inletBoundary->eulerId] + fp::RHOU,
boundaryDensityYi,
&boundaryTemperature,
inletBoundary->eos->GetComputeTemperatureContext()) >>
checkError;
// Compute the cp, cv from the eos
std::vector<PetscReal> boundaryYi(inletBoundary->nSpecEqs);
for (PetscInt i = 0; i < inletBoundary->nSpecEqs; i++) {
boundaryYi[i] = boundaryDensityYi[i] / boundaryDensity;
}
PetscReal boundaryCp, boundaryCv;
inletBoundary->eos->GetComputeSpecificHeatConstantPressureFunction()(
boundaryTemperature, boundaryDensity, boundaryYi.data(), &boundaryCp, inletBoundary->eos->GetComputeSpecificHeatConstantPressureContext()) >>
checkError;
inletBoundary->eos->GetComputeSpecificHeatConstantVolumeFunction()(
boundaryTemperature, boundaryDensity, boundaryYi.data(), &boundaryCv, inletBoundary->eos->GetComputeSpecificHeatConstantVolumeContext()) >>
checkError;
// Compute the enthalpy
PetscReal boundarySensibleEnthalpy;
inletBoundary->eos->GetComputeSensibleEnthalpyFunction()(
boundaryTemperature, boundaryDensity, boundaryYi.data(), &boundarySensibleEnthalpy, inletBoundary->eos->GetComputeSensibleEnthalpyContext()) >>
checkError;
// get_vel_and_c_prims(PGS, velwall[0], C, Cp, Cv, velnprm, Cprm);
PetscReal velNormPrim, speedOfSoundPrim;
GetVelAndCPrims(boundaryNormalVelocity, boundarySpeedOfSound, boundaryCp, boundaryCv, velNormPrim, speedOfSoundPrim);
// get_eigenvalues
std::vector<PetscReal> lambda(inletBoundary->nEqs);
inletBoundary->GetEigenValues(boundaryNormalVelocity, boundarySpeedOfSound, velNormPrim, speedOfSoundPrim, &lambda[0]);
// Get scriptL
std::vector<PetscReal> scriptL(inletBoundary->nEqs);
// Outgoing acoustic wave
scriptL[1 + dim] = lambda[1 + dim] * (dPdNorm - boundaryDensity * dVeldNorm * (velNormPrim - boundaryNormalVelocity - speedOfSoundPrim));
// Incoming acoustic wave
scriptL[0] = scriptL[1 + dim];
// Entropy wave
scriptL[1] = 0.5e+0 * (boundaryCp / boundaryCv - 1.e+0) * (scriptL[1 + dim] + scriptL[0]) -
0.5 * (boundaryCp / boundaryCv + 1.e+0) * (scriptL[0] - scriptL[1 + dim]) * (velNormPrim - boundaryNormalVelocity) / speedOfSoundPrim;
// Tangential velocities
for (int d = 1; d < dim; d++) {
scriptL[1 + d] = 0.e+0;
}
for (int ns = 0; ns < inletBoundary->nSpecEqs; ns++) {
// Species
scriptL[2 + dim + ns] = 0.e+0;
}
for (int ne = 0; ne < inletBoundary->nEvEqs; ne++) {
// Extra variables
scriptL[2 + dim + inletBoundary->nSpecEqs + ne] = 0.e+0;
}
// Directly compute the source terms, note that this may be problem in the future with multiple source terms on the same boundary cell
inletBoundary->GetmdFdn(sOff,
boundaryVelNormCord,
boundaryDensity,
boundaryTemperature,
boundaryCp,
boundaryCv,
boundarySpeedOfSound,
boundarySensibleEnthalpy,
velNormPrim,
speedOfSoundPrim,
boundaryDensityYi /* PetscReal* Yi*/,
inletBoundary->nEvEqs > 0 ? boundaryValues + uOff[inletBoundary->evId] : nullptr /* PetscReal* EV*/,
&scriptL[0],
transformationMatrix,
source);
PetscFunctionReturn(0);
}
#include "registrar.hpp"
REGISTER(ablate::boundarySolver::BoundaryProcess, ablate::boundarySolver::lodi::Inlet, "Enforces an inlet with specified velocity",
ARG(ablate::eos::EOS, "eos", "The EOS describing the flow field at the wall"));
| 56.588571 | 186 | 0.566697 | [
"vector"
] |
d6f7f8319b89b10ee73a645d67121f17ec3c9c73 | 2,791 | cc | C++ | components/autofill_assistant/browser/actions/show_details_action.cc | Ron423c/chromium | 2edf7b980065b648f8b2a6e52193d83832fe36b7 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 575 | 2015-06-18T23:58:20.000Z | 2022-03-23T09:32:39.000Z | components/autofill_assistant/browser/actions/show_details_action.cc | Ron423c/chromium | 2edf7b980065b648f8b2a6e52193d83832fe36b7 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 113 | 2015-05-04T09:58:14.000Z | 2022-01-31T19:35:03.000Z | components/autofill_assistant/browser/actions/show_details_action.cc | iridium-browser/iridium-browser | 907e31cf5ce5ad14d832796e3a7c11e496828959 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 52 | 2015-07-14T10:40:50.000Z | 2022-03-15T01:11:49.000Z | // Copyright 2018 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 "components/autofill_assistant/browser/actions/show_details_action.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/bind.h"
#include "base/callback.h"
#include "components/autofill_assistant/browser/actions/action_delegate.h"
#include "components/autofill_assistant/browser/details.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
namespace autofill_assistant {
ShowDetailsAction::ShowDetailsAction(ActionDelegate* delegate,
const ActionProto& proto)
: Action(delegate, proto) {
DCHECK(proto_.has_show_details());
}
ShowDetailsAction::~ShowDetailsAction() {}
void ShowDetailsAction::InternalProcessAction(ProcessActionCallback callback) {
std::unique_ptr<Details> details = nullptr;
bool details_valid = true;
switch (proto_.show_details().data_to_show_case()) {
case ShowDetailsProto::DataToShowCase::kDetails:
details = std::make_unique<Details>();
details_valid =
Details::UpdateFromProto(proto_.show_details(), details.get());
break;
case ShowDetailsProto::DataToShowCase::kContactDetails:
details = std::make_unique<Details>();
details_valid = Details::UpdateFromContactDetails(
proto_.show_details(), delegate_->GetUserData(),
delegate_->GetLastSuccessfulUserDataOptions(), details.get());
break;
case ShowDetailsProto::DataToShowCase::kShippingAddress:
details = std::make_unique<Details>();
details_valid = Details::UpdateFromShippingAddress(
proto_.show_details(), delegate_->GetUserData(), details.get());
break;
case ShowDetailsProto::DataToShowCase::kCreditCard:
details = std::make_unique<Details>();
details_valid = Details::UpdateFromSelectedCreditCard(
proto_.show_details(), delegate_->GetUserData(), details.get());
break;
case ShowDetailsProto::DataToShowCase::DATA_TO_SHOW_NOT_SET:
// Clear Details. Calling SetDetails with nullptr clears the details.
break;
}
if (!details_valid) {
VLOG(1) << "Failed to fill the details";
UpdateProcessedAction(INVALID_ACTION);
} else {
base::TimeDelta delay =
base::TimeDelta::FromMilliseconds(proto_.show_details().delay_ms());
if (proto_.show_details().append()) {
delegate_->AppendDetails(std::move(details), delay);
} else {
delegate_->SetDetails(std::move(details), delay);
}
UpdateProcessedAction(ACTION_APPLIED);
}
std::move(callback).Run(std::move(processed_action_proto_));
}
} // namespace autofill_assistant
| 36.723684 | 79 | 0.717306 | [
"vector"
] |
d6fd51a54f3fc552588e42cc7fc4f321598af1c3 | 3,448 | cpp | C++ | src/plugins/gmailnotifier/notifier.cpp | rayslava/leechcraft | 4ecc8aa56dc6030d2593922ff41b00ff50902db8 | [
"BSL-1.0"
] | 1 | 2017-01-12T07:05:45.000Z | 2017-01-12T07:05:45.000Z | src/plugins/gmailnotifier/notifier.cpp | ForNeVeR/leechcraft | 384d041d23b1cdb7cc3c758612ac8d68d3d3d88c | [
"BSL-1.0"
] | null | null | null | src/plugins/gmailnotifier/notifier.cpp | ForNeVeR/leechcraft | 384d041d23b1cdb7cc3c758612ac8d68d3d3d88c | [
"BSL-1.0"
] | null | null | null | /**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2006-2014 Georg Rudoy
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
#include "notifier.h"
#include <QTextDocument>
#include <util/xpc/util.h>
#include <util/sll/qtutil.h>
#include <interfaces/core/ientitymanager.h>
#include "xmlsettingsmanager.h"
namespace LeechCraft
{
namespace GmailNotifier
{
Notifier::Notifier (ICoreProxy_ptr proxy, QObject *parent)
: QObject (parent)
, Proxy_ (proxy)
{
}
void Notifier::notifyAbout (const ConvInfos_t& infos)
{
qDebug () << Q_FUNC_INFO << infos.size ();
if (infos == PreviousInfos_)
return;
PreviousInfos_ = infos;
if (infos.isEmpty ())
return;
const int fullShow = XmlSettingsManager::Instance ()->
property ("ShowLastNMessages").toInt ();
auto textWFallback = [] (const QString& text, const QString& fallback)
{
return text.isEmpty () ?
fallback :
Util::Escape (text);
};
int handledMsgs = 0;
QString result;
for (const auto& info : infos)
{
result += QString::fromUtf8 ("<p><font color=\"#004C00\">\302\273</font> <a href=\"");
result += info.Link_.toString () + "\">";
result += textWFallback (info.Title_, tr ("No subject")) + "</a> " + tr ("from") + " ";
result += "<a href=\"https://mail.google.com/mail?extsrc=mailto&url=mailto:";
result += info.AuthorEmail_ + "\">";
result += info.AuthorName_ + "</a><br/>";
result += tr ("at") + " ";
result += info.Modified_.toString (Qt::SystemLocaleLongDate);
result += "</p><p class=\"additionaltext\">";
result += Util::Escape (info.Summary_) + "</p>";
if (++handledMsgs == fullShow)
break;
}
if (infos.size () > fullShow)
result += "<p><em>…" +
tr ("and %1 more").arg (infos.size () - fullShow) +
"</em></p>";
const auto& e = Util::MakeNotification ("GMail", result, PInfo_);
Proxy_->GetEntityManager ()->HandleEntity (e);
}
}
}
| 35.546392 | 94 | 0.661253 | [
"object"
] |
d90123746d9be28874eef0616568409655e2867f | 874 | cpp | C++ | 3-Problem_Solving_Paradigms/3.2-Complete_Search/2-Iterative_(Two_Nested_Loops)/vitorvgc/10487.cpp | IFCE-CP/CP3-solutions | 1abcabd9a06968184a55d3b0414637019014694c | [
"MIT"
] | 1 | 2017-11-16T10:56:17.000Z | 2017-11-16T10:56:17.000Z | 3-Problem_Solving_Paradigms/3.2-Complete_Search/2-Iterative_(Two_Nested_Loops)/vitorvgc/10487.cpp | IFCE-CP/CP3-solutions | 1abcabd9a06968184a55d3b0414637019014694c | [
"MIT"
] | null | null | null | 3-Problem_Solving_Paradigms/3.2-Complete_Search/2-Iterative_(Two_Nested_Loops)/vitorvgc/10487.cpp | IFCE-CP/CP3-solutions | 1abcabd9a06968184a55d3b0414637019014694c | [
"MIT"
] | null | null | null | #include <bits/stdc++.h>
using namespace std;
int l[1010];
int main() {
int n, m, caso = 0;
while(scanf("%d", &n) && n) {
for(int i = 0; i < n; ++i)
scanf("%d", &l[i]);
vector<int> v;
for(int i = 0; i < n; ++i)
for(int j = i+1; j < n; ++j)
v.push_back(l[i] + l[j]);
sort(v.begin(), v.end());
printf("Case %d:\n", ++caso);
for(scanf("%d", &m); m--; ) {
int x, ans;
scanf("%d", &x);
auto it = lower_bound(v.begin(), v.end(), x);
if(it == v.end())
ans = *(it-1);
else if(it == v.begin())
ans = *it;
else
ans = (abs(x - *it) < abs(x - *(it-1)) ? *it : *(it-1));
printf("Closest sum to %d is %d.\n", x, ans);
}
}
return 0;
}
| 21.85 | 72 | 0.356979 | [
"vector"
] |
d9019848460cf75488255d01f451c7878e9a8146 | 6,845 | cpp | C++ | external/webkit/Source/WebCore/platform/network/ResourceHandle.cpp | ghsecuritylab/android_platform_sony_nicki | 526381be7808e5202d7865aa10303cb5d249388a | [
"Apache-2.0"
] | 6 | 2017-05-31T01:46:45.000Z | 2018-06-12T10:53:30.000Z | Source/WebCore/platform/network/ResourceHandle.cpp | FMSoftCN/mdolphin-core | 48ffdcf587a48a7bb4345ae469a45c5b64ffad0e | [
"Apache-2.0"
] | 2 | 2017-07-25T09:37:22.000Z | 2017-08-04T07:18:56.000Z | Source/WebCore/platform/network/ResourceHandle.cpp | FMSoftCN/mdolphin-core | 48ffdcf587a48a7bb4345ae469a45c5b64ffad0e | [
"Apache-2.0"
] | 2 | 2017-07-17T06:02:42.000Z | 2018-09-19T10:08:38.000Z | /*
* Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "config.h"
#include "ResourceHandle.h"
#include "ResourceHandleInternal.h"
#include "BlobRegistry.h"
#include "DNS.h"
#include "Logging.h"
#include "ResourceHandleClient.h"
#include "Timer.h"
#include <algorithm>
#include <wtf/text/CString.h>
namespace WebCore {
static bool shouldForceContentSniffing;
ResourceHandle::ResourceHandle(const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff)
: d(new ResourceHandleInternal(this, request, client, defersLoading, shouldContentSniff && shouldContentSniffURL(request.url())))
{
if (!request.url().isValid()) {
scheduleFailure(InvalidURLFailure);
return;
}
if (!portAllowed(request.url())) {
scheduleFailure(BlockedFailure);
return;
}
}
PassRefPtr<ResourceHandle> ResourceHandle::create(NetworkingContext* context, const ResourceRequest& request, ResourceHandleClient* client, bool defersLoading, bool shouldContentSniff)
{
#if ENABLE(BLOB)
if (request.url().protocolIs("blob")) {
PassRefPtr<ResourceHandle> handle = blobRegistry().createResourceHandle(request, client);
if (handle)
return handle;
}
#endif
RefPtr<ResourceHandle> newHandle(adoptRef(new ResourceHandle(request, client, defersLoading, shouldContentSniff)));
if (newHandle->d->m_scheduledFailureType != NoFailure)
return newHandle.release();
if (newHandle->start(context))
return newHandle.release();
return 0;
}
void ResourceHandle::scheduleFailure(FailureType type)
{
d->m_scheduledFailureType = type;
d->m_failureTimer.startOneShot(0);
}
void ResourceHandle::fireFailure(Timer<ResourceHandle>*)
{
if (!client())
return;
switch (d->m_scheduledFailureType) {
case NoFailure:
ASSERT_NOT_REACHED();
return;
case BlockedFailure:
d->m_scheduledFailureType = NoFailure;
client()->wasBlocked(this);
return;
case InvalidURLFailure:
d->m_scheduledFailureType = NoFailure;
client()->cannotShowURL(this);
return;
}
ASSERT_NOT_REACHED();
}
ResourceHandleClient* ResourceHandle::client() const
{
return d->m_client;
}
void ResourceHandle::setClient(ResourceHandleClient* client)
{
d->m_client = client;
}
ResourceRequest& ResourceHandle::firstRequest()
{
return d->m_firstRequest;
}
const String& ResourceHandle::lastHTTPMethod() const
{
return d->m_lastHTTPMethod;
}
bool ResourceHandle::hasAuthenticationChallenge() const
{
return !d->m_currentWebChallenge.isNull();
}
void ResourceHandle::clearAuthentication()
{
#if PLATFORM(MAC)
d->m_currentMacChallenge = nil;
#endif
d->m_currentWebChallenge.nullify();
}
bool ResourceHandle::shouldContentSniff() const
{
return d->m_shouldContentSniff;
}
bool ResourceHandle::shouldContentSniffURL(const KURL& url)
{
#if PLATFORM(MAC)
if (shouldForceContentSniffing)
return true;
#endif
// We shouldn't content sniff file URLs as their MIME type should be established via their extension.
return !url.protocolIs("file");
}
void ResourceHandle::forceContentSniffing()
{
shouldForceContentSniffing = true;
}
void ResourceHandle::setDefersLoading(bool defers)
{
LOG(Network, "Handle %p setDefersLoading(%s)", this, defers ? "true" : "false");
ASSERT(d->m_defersLoading != defers); // Deferring is not counted, so calling setDefersLoading() repeatedly is likely to be in error.
d->m_defersLoading = defers;
if (defers) {
ASSERT(d->m_failureTimer.isActive() == (d->m_scheduledFailureType != NoFailure));
if (d->m_failureTimer.isActive())
d->m_failureTimer.stop();
} else if (d->m_scheduledFailureType != NoFailure) {
ASSERT(!d->m_failureTimer.isActive());
d->m_failureTimer.startOneShot(0);
}
platformSetDefersLoading(defers);
}
#if !USE(SOUP)
void ResourceHandle::prepareForURL(const KURL& url)
{
return prefetchDNS(url.host());
}
#endif
void ResourceHandle::cacheMetadata(const ResourceResponse&, const Vector<char>&)
{
// Optionally implemented by platform.
}
#if USE(CFURLSTORAGESESSIONS)
static RetainPtr<CFURLStorageSessionRef>& privateStorageSession()
{
DEFINE_STATIC_LOCAL(RetainPtr<CFURLStorageSessionRef>, storageSession, ());
return storageSession;
}
static String& privateBrowsingStorageSessionIdentifierBase()
{
DEFINE_STATIC_LOCAL(String, base, ());
return base;
}
void ResourceHandle::setPrivateBrowsingEnabled(bool enabled)
{
if (!enabled) {
privateStorageSession() = nullptr;
return;
}
if (privateStorageSession())
return;
String base = privateBrowsingStorageSessionIdentifierBase().isNull() ? privateBrowsingStorageSessionIdentifierDefaultBase() : privateBrowsingStorageSessionIdentifierBase();
RetainPtr<CFStringRef> cfIdentifier(AdoptCF, String::format("%s.PrivateBrowsing", base.utf8().data()).createCFString());
privateStorageSession() = createPrivateBrowsingStorageSession(cfIdentifier.get());
}
CFURLStorageSessionRef ResourceHandle::privateBrowsingStorageSession()
{
return privateStorageSession().get();
}
void ResourceHandle::setPrivateBrowsingStorageSessionIdentifierBase(const String& identifier)
{
privateBrowsingStorageSessionIdentifierBase() = identifier;
}
#endif // USE(CFURLSTORAGESESSIONS)
} // namespace WebCore
| 29.50431 | 184 | 0.725931 | [
"vector"
] |
d901b6ded5707b3418a3dd68c1c54926c4faeff3 | 6,830 | cpp | C++ | src/Client/ClientConsole.cpp | Stral9315/xsngine | 4a4afe21f12483dbe266113b17a4b51ea850ee56 | [
"MIT"
] | 13 | 2015-02-05T22:44:29.000Z | 2021-09-04T21:28:10.000Z | src/Client/ClientConsole.cpp | Stral9315/xsngine | 4a4afe21f12483dbe266113b17a4b51ea850ee56 | [
"MIT"
] | 47 | 2015-03-23T14:11:06.000Z | 2017-05-21T05:14:57.000Z | src/Client/ClientConsole.cpp | Stral9315/xsngine | 4a4afe21f12483dbe266113b17a4b51ea850ee56 | [
"MIT"
] | 7 | 2015-04-29T00:48:23.000Z | 2018-04-01T13:12:40.000Z | #include <algorithm>
#include "Common/Common.h"
#include "Common/Console.h"
#include "Common/Cvar.h"
#include "Common/MessageBuffer.h"
#include "Common/String.h"
#include "Common/Colours.h"
#include "Input/InputField.h"
#include "Client/Client.h"
#include "Client/ClientConsole.h"
#include "Input/Mouse.h"
#include "Renderer/Font.h"
#include "Renderer/View.h"
#include "Renderer/Renderer.h"
namespace Client {
static void InputCallback( const char *text ) {
Command::Append( text );
}
static const char *InputAutoComplete( const char *match ) {
//TODO: advanced auto completion (ala zsh/oh-my-zsh)
return "Autocompleted";
}
void ClientConsole::Toggle( void ) {
if ( isVisible ) {
input->Clear();
}
privateIsVisible = !privateIsVisible;
Input::CaptureMouse( !isVisible );
}
// negative for down, positive for up
void ClientConsole::Scroll( int amount ) {
if ( amount > 0 ) {
if ( scrollAmount + amount < static_cast<int32_t>( console->buffer->size() - lineCount ) ) {
scrollAmount += amount;
}
}
else if ( amount < 0 ) {
scrollAmount += amount;
if ( scrollAmount < 0 ) {
scrollAmount = 0;
}
}
}
bool ClientConsole::KeyboardEvent( const struct KeyboardEvent &ev ) {
if ( !isVisible ) {
return false;
}
if ( ev.down ) {
if ( ev.key == SDLK_PAGEUP ) {
Scroll( 1 );
}
else if ( ev.key == SDLK_PAGEDOWN ) {
Scroll( -1 );
}
else {
input->KeyboardEvent( ev );
}
}
return true;
}
bool ClientConsole::MouseButtonEvent( const struct MouseButtonEvent &ev ) {
if ( !isVisible ) {
return false;
}
// ...
return true;
}
bool ClientConsole::MouseMotionEvent( const struct MouseMotionEvent &ev ) {
if ( !isVisible ) {
return false;
}
// ...
return true;
}
bool ClientConsole::MouseWheelEvent( const struct MouseWheelEvent &ev ) {
if ( !isVisible ) {
return false;
}
if ( ev.up ) {
Scroll( ev.amount );
}
else {
Scroll ( ev.amount * -1 );
}
return true;
}
ClientConsole::ClientConsole( Console *consoleInstance )
: console( consoleInstance ),
privateIsVisible( false ),
scrollAmount( 0 ),
lineCount( 24u ),
font( nullptr ),
isVisible( privateIsVisible )
{
con_fontSize = Cvar::Create( "con_fontSize", "16",
"Size of the console font", CVAR_ARCHIVE
);
input = new InputField( InputCallback, InputAutoComplete );
view = new Renderer::View( 0u, 0u, true );
font = Renderer::Font::Register( "console" );
}
ClientConsole::~ClientConsole() {
delete view;
delete input;
}
void ClientConsole::Resize( void ) {
if ( font ) {
const uint16_t fontSize = static_cast<uint16_t>( con_fontSize->GetInt32() );
lineCount = ((view->height / 2) / std::floor( font->lineHeight[fontSize] )) - 1;
}
}
// split a string into multiple chunks
void ClientConsole::Split( const std::string &line, std::vector<std::string> &lines ) {
const uint16_t fontSize = static_cast<uint16_t>( con_fontSize->GetInt32() );
const real32_t lineWidth = view->width;
ptrdiff_t startOffset = 0u;
real32_t accumWidth = 0.0f;
const char *p = line.c_str();
for ( char c = *p; c != '\0'; c = *p++ ) {
if ( c == '\t' ) {
//FIXME: actually handle tab stops properly
accumWidth += font->GetGlyphWidth( ' ', fontSize );
}
else {
accumWidth += font->GetGlyphWidth( c, fontSize );
}
if ( accumWidth >= lineWidth ) {
// splice and reset counters
const ptrdiff_t endOffset = p - line.c_str();
lines.push_back( std::string( line.cbegin() + startOffset, line.cbegin() + endOffset ) );
startOffset = endOffset;
accumWidth = 0.0f;
}
}
// push the remainder of the line
lines.push_back( std::string( line.cbegin() + startOffset, line.cend() ) );
}
void ClientConsole::Draw( void ) {
if ( !isVisible || !view ) {
return;
}
view->Bind();
const vector4 consoleColour{ 0.0f, 0.0f, 0.0f, 0.5f };
Renderer::DrawQuad(
0, 0, view->width, view->height / 2,
0.0f, 0.0f, 1.0f, 1.0f,
consoleColour,
nullptr
);
Resize();
const uint16_t fontSize = static_cast<uint16_t>( con_fontSize->GetInt32() );
const real32_t x = 0.0f;
vector2 pos = {
x,
(view->height / 2.0f) - font->lineHeight[fontSize]
};
// draw the input line
font->Draw( pos, String::Format( ">%s", input->GetLine() ), fontSize );
// and now the cursor
const char *line = input->GetLine();
real32_t savedX = pos[0];
pos[0] = font->GetGlyphWidth( '>', fontSize );
for ( const char *p = line; *p; p++ ) {
if ( p - line >= static_cast<int32_t>( input->GetCursorPos() ) ) {
break;
}
pos[0] += font->GetGlyphWidth( *p, fontSize );
}
//TODO: overstrike mode
if ( static_cast<uint32_t>( GetElapsedTime() ) & 256 ) {
// flash every 250ms
font->Draw( pos, "_", fontSize );
}
pos[0] = savedX;
// draw version information
static const std::vector<std::string> helpInfoList {
PRODUCT_NAME " on " OS_STRING " (" ARCH_STRING ")",
PRODUCT_VERSION,
};
const uint16_t helpFontSize = 12u;
uint32_t numHelpLinesDrawn = 0u;
for ( auto helpInfo = helpInfoList.crbegin(); helpInfo != helpInfoList.crend(); ++helpInfo ) {
real32_t helpWidth = 0u;
for ( const char *p = (*helpInfo).c_str(); *p; p++ ) {
helpWidth += font->GetGlyphWidth( *p, helpFontSize );
}
const vector2 helpPos = {
view->width - helpWidth,
(view->height / 2)
- (font->lineHeight[helpFontSize] * numHelpLinesDrawn)
- font->lineHeight[fontSize]
- 4u
};
font->Draw( helpPos, *helpInfo, helpFontSize );
numHelpLinesDrawn++;
}
// grab a subset of the console buffer that we may want to draw - we do word-wrapping in realtime
// line breaks and carriage returns are preprocessed in the Console
const uint32_t numLines = console->buffer->size();
const uint32_t start = std::max(
0,
static_cast<int32_t>( numLines )
- static_cast<int32_t>( scrollAmount )
- static_cast<int32_t>( lineCount )
);
const uint32_t begin = std::min( numLines, start );
const uint32_t end = std::min( begin + lineCount, numLines );
std::vector<std::string> lines( console->buffer->begin() + begin, console->buffer->begin() + end );
uint32_t drawn = 0u;
for ( auto line = lines.crbegin(); line != lines.crend(); ++line ) {
// substring of renderable characters
std::vector<std::string> subsets;
Split( *line, subsets );
for ( auto subset = subsets.crbegin(); subset != subsets.crend(); ++subset ) {
const uint32_t subsetLineCount = font->GetTextLineCount( pos, *subset, fontSize );
drawn += subsetLineCount;
if ( drawn > lineCount ) {
break;
}
pos[1] -= font->lineHeight[fontSize] * subsetLineCount;
font->Draw( pos, *subset, fontSize, &colourTable[ColourIndex( COLOUR_WHITE )] );
}
}
}
} // namespace Client
| 25.969582 | 101 | 0.638507 | [
"vector"
] |
d90b4389bf1da450d39872eef4637db16760a352 | 5,295 | cpp | C++ | example-AllComponentsGui/src/ofApp.cpp | oneandonlyoddo/ofxDatGuiFork | ae304810792f0b3a5618735b86fd094ac2b2aae4 | [
"MIT"
] | 1 | 2018-04-27T22:48:37.000Z | 2018-04-27T22:48:37.000Z | example-AllComponentsGui/src/ofApp.cpp | oneandonlyoddo/ofxDatGuiFork | ae304810792f0b3a5618735b86fd094ac2b2aae4 | [
"MIT"
] | 1 | 2018-07-13T14:40:32.000Z | 2018-07-13T14:40:32.000Z | example-AllComponentsGui/src/ofApp.cpp | oneandonlyoddo/ofxDatGuiFork | ae304810792f0b3a5618735b86fd094ac2b2aae4 | [
"MIT"
] | 5 | 2016-08-01T03:37:00.000Z | 2019-05-30T04:33:53.000Z | #include "ofApp.h"
/*
All components instantiated within a gui
https://github.com/braitsch/ofxDatGui @braitsch
*/
void ofApp::setup()
{
// instantiate and position the gui //
gui = new ofxDatGui( ofxDatGuiAnchor::TOP_RIGHT );
// add some components //
gui->addTextInput("message", "# open frameworks #");
gui->addFRM();
gui->addBreak();
// add a folder to group a few components together //
ofxDatGuiFolder* folder = gui->addFolder("white folder", ofColor::white);
folder->addTextInput("** input", "nested input field");
folder->addSlider("** slider", 0, 100);
folder->addToggle("** toggle");
folder->addColorPicker("** picker", ofColor::fromHex(0xFFD00B));
// let's have it open by default. note: call this only after you're done adding items //
folder->expand();
gui->addBreak();
// add a couple range sliders //
gui->addSlider("position X", 0, 120, 75);
gui->addSlider("position Y", -40, 240, 200);
gui->addSlider("position Z", -80, 120, -40);
// and a slider to adjust the gui opacity //
gui->addSlider("datgui opacity", 0, 100, 100);
// and a colorpicker //
gui->addColorPicker("color picker", ofColor::fromHex(0xeeeeee));
// add a wave monitor //
// take a look inside example-TimeGraph for more examples of this component and the value plotter //
gui->addWaveMonitor("wave\nmonitor", 3, .2);
gui->addBreak();
// add a dropdown menu //
vector<string> opts = {"option - 1", "option - 2", "option - 3", "option - 4"};
gui->addDropdown("select option", opts);
gui->addBreak();
// add a 2d pad //
ofxDatGui2dPad* pad = gui->add2dPad("2d pad");
// a button matrix //
gui->addMatrix("matrix", 21, true);
// and a couple of simple buttons //
gui->addButton("click");
gui->addToggle("toggle fullscreen", true);
// adding the optional header allows you to drag the gui around //
gui->addHeader(":: drag me to reposition ::");
// adding the optional footer allows you to collapse/expand the gui //
gui->addFooter();
// once the gui has been assembled, register callbacks to listen for component specific events //
gui->onButtonEvent(this, &ofApp::onButtonEvent);
gui->onToggleEvent(this, &ofApp::onToggleEvent);
gui->onSliderEvent(this, &ofApp::onSliderEvent);
gui->onTextInputEvent(this, &ofApp::onTextInputEvent);
gui->on2dPadEvent(this, &ofApp::on2dPadEvent);
gui->onDropdownEvent(this, &ofApp::onDropdownEvent);
gui->onColorPickerEvent(this, &ofApp::onColorPickerEvent);
gui->onMatrixEvent(this, &ofApp::onMatrixEvent);
gui->setOpacity(gui->getSlider("datgui opacity")->getScale());
// gui->setLabelAlignment(ofxDatGuiAlignment::CENTER);
// finally let's load up the stock themes, press spacebar to cycle through them //
themes = { new ofxDatGuiTheme(true),
new ofxDatGuiThemeSmoke(),
new ofxDatGuiThemeWireframe(),
new ofxDatGuiThemeMidnight(),
new ofxDatGuiThemeAqua(),
new ofxDatGuiThemeCharcoal(),
new ofxDatGuiThemeAutumn(),
new ofxDatGuiThemeCandy()};
tIndex = 0;
// launch the app //
mFullscreen = true;
refreshWindow();
}
void ofApp::onButtonEvent(ofxDatGuiButtonEvent e)
{
cout << "onButtonEvent: " << e.target->getLabel() << endl;
}
void ofApp::onToggleEvent(ofxDatGuiToggleEvent e)
{
if (e.target->is("toggle fullscreen")) toggleFullscreen();
cout << "onToggleEvent: " << e.target->getLabel() << " " << e.checked << endl;
}
void ofApp::onSliderEvent(ofxDatGuiSliderEvent e)
{
cout << "onSliderEvent: " << e.target->getLabel() << " "; e.target->printValue();
if (e.target->is("datgui opacity")) gui->setOpacity(e.scale);
}
void ofApp::onTextInputEvent(ofxDatGuiTextInputEvent e)
{
cout << "onTextInputEvent: " << e.target->getLabel() << " " << e.target->getText() << endl;
}
void ofApp::on2dPadEvent(ofxDatGui2dPadEvent e)
{
cout << "on2dPadEvent: " << e.target->getLabel() << " " << e.x << ":" << e.y << endl;
}
void ofApp::onDropdownEvent(ofxDatGuiDropdownEvent e)
{
cout << "onDropdownEvent: " << e.target->getLabel() << " Selected" << endl;
}
void ofApp::onColorPickerEvent(ofxDatGuiColorPickerEvent e)
{
cout << "onColorPickerEvent: " << e.target->getLabel() << " " << e.target->getColor() << endl;
ofSetBackgroundColor(e.color);
}
void ofApp::onMatrixEvent(ofxDatGuiMatrixEvent e)
{
cout << "onMatrixEvent " << e.child << " : " << e.enabled << endl;
cout << "onMatrixEvent " << e.target->getLabel() << " : " << e.target->getSelected().size() << endl;
}
void ofApp::draw() { }
void ofApp::update() { }
void ofApp::keyPressed(int key)
{
if (key == 'f') {
toggleFullscreen();
} else if (key == 32){
tIndex = tIndex < themes.size()-1 ? tIndex+1 : 0;
gui->setTheme(themes[tIndex]);
}
}
void ofApp::toggleFullscreen()
{
mFullscreen = !mFullscreen;
gui->getToggle("toggle fullscreen")->setChecked(mFullscreen);
refreshWindow();
}
void ofApp::refreshWindow()
{
ofSetFullscreen(mFullscreen);
if (!mFullscreen) {
ofSetWindowShape(1920, 1400);
ofSetWindowPosition((ofGetScreenWidth()/2)-(1920/2), 0);
}
}
| 31.147059 | 104 | 0.638527 | [
"vector"
] |
d9101ab3047e37eea6acca307c1ca10caf93ceaa | 3,017 | hpp | C++ | Code/Include/maxGif/Parsing/LogicalScreenDescriptorBlockToken.hpp | ProgramMax/maxGif | de509a1512dd56015c7f044bfc177ae662e57694 | [
"BSD-3-Clause"
] | 1 | 2016-11-13T17:50:10.000Z | 2016-11-13T17:50:10.000Z | Code/Include/maxGif/Parsing/LogicalScreenDescriptorBlockToken.hpp | ProgramMax/maxGif | de509a1512dd56015c7f044bfc177ae662e57694 | [
"BSD-3-Clause"
] | 23 | 2016-11-13T18:41:42.000Z | 2017-12-27T13:58:07.000Z | Code/Include/maxGif/Parsing/LogicalScreenDescriptorBlockToken.hpp | ProgramMax/maxGif | de509a1512dd56015c7f044bfc177ae662e57694 | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2016, The maxGif Contributors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MAXGIF_PARSING_LOGICALSCREENDESCRIPTORBLOCKTOKEN_HPP
#define MAXGIF_PARSING_LOGICALSCREENDESCRIPTORBLOCKTOKEN_HPP
#include <max/Compiling/CurrentVersionNamespace.hpp>
#include <maxGif/Parsing/Token.hpp>
#include <vector>
#include <maxGif/Parsing/BitManipulation.hpp>
namespace maxGif
{
MAX_CURRENT_VERSION_NAMESPACE_BEGIN( v0 )
{
namespace Parsing
{
class LogicalScreenDescriptorBlockToken : public Token
{
public:
explicit constexpr LogicalScreenDescriptorBlockToken( const size_t StartOffset ) noexcept
: Token( StartOffset )
{
}
static constexpr size_t SizeInBytes() noexcept
{
return 7;
}
uint16_t CanvasWidth( const std::vector< uint8_t > & Buffer ) const noexcept
{
constexpr size_t CanvasWidthOffset = 0;
return Get16BitsLittleEndian( & Buffer[ 0 ], StartOffset + CanvasWidthOffset );
}
uint16_t CanvasHeight( const std::vector< uint8_t > & Buffer ) const noexcept
{
constexpr size_t CanvasHeightOffset = 2;
return Get16BitsLittleEndian( & Buffer[ 0 ], StartOffset + CanvasHeightOffset );
}
bool GlobalColorTableFlag( const std::vector< uint8_t > & Buffer ) const noexcept
{
constexpr uint8_t GlobalColorTableFlagMask = 0b1000'0000;
return GetFlag( & Buffer[ 0 ], StartOffset + PackedFieldOffset, GlobalColorTableFlagMask );
}
uint8_t ColorResolution( const std::vector< uint8_t > & Buffer ) const noexcept
{
constexpr uint8_t ColorResolutionMask = 0b0111'0000;
constexpr uint8_t ColorResolutionShift = 4;
return Get8Bits( & Buffer[ 0 ], StartOffset + PackedFieldOffset, ColorResolutionMask, ColorResolutionShift );
}
bool SortFlag( const std::vector< uint8_t > & Buffer ) const noexcept
{
constexpr uint8_t SortFlagMask = 0b0000'1000;
return GetFlag( & Buffer[ 0 ], StartOffset + PackedFieldOffset, SortFlagMask );
}
uint8_t SizeOfGlobalColorTable( const std::vector< uint8_t > & Buffer ) const noexcept
{
constexpr uint8_t SizeOfGlobalColorTableMask = 0b0000'0111;
constexpr uint8_t SizeOfGlobalColorTableShift = 0;
return Get8Bits( & Buffer[ 0 ], StartOffset + PackedFieldOffset, SizeOfGlobalColorTableMask, SizeOfGlobalColorTableShift );
}
uint8_t BackgroundColorIndex( const std::vector< uint8_t > & Buffer ) const noexcept
{
constexpr size_t BackgroundColorIndexOffset = 5;
return Buffer[ StartOffset + BackgroundColorIndexOffset ];
}
uint8_t PixelAspectRatio( const std::vector< uint8_t > & Buffer ) const noexcept
{
constexpr size_t PixelAspectRatioOffset = 6;
return Buffer[ StartOffset + PixelAspectRatioOffset ];
}
static constexpr size_t PackedFieldOffset = 4;
};
} // namespace Parsing
} // MAX_CURRENT_VERSION_NAMESPACE_BEGIN( v0 )
MAX_CURRENT_VERSION_NAMESPACE_END( v0 )
} // namespace maxGif
#endif // #ifndef MAXGIF_PARSING_LOGICALSCREENDESCRIPTORBLOCKTOKEN_HPP
| 29.578431 | 126 | 0.758701 | [
"vector"
] |
d919fe08335be5967355c8adf36c5a31262fcfb1 | 1,293 | cpp | C++ | N0994-Rotting-Oranges/solution1.cpp | loyio/leetcode | 366393c29a434a621592ef6674a45795a3086184 | [
"CC0-1.0"
] | null | null | null | N0994-Rotting-Oranges/solution1.cpp | loyio/leetcode | 366393c29a434a621592ef6674a45795a3086184 | [
"CC0-1.0"
] | null | null | null | N0994-Rotting-Oranges/solution1.cpp | loyio/leetcode | 366393c29a434a621592ef6674a45795a3086184 | [
"CC0-1.0"
] | 2 | 2022-01-25T05:31:31.000Z | 2022-02-26T07:22:23.000Z | class Solution {
int cnt = 0;
int dis[10][10];
static constexpr int dirs[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
public:
int orangesRotting(vector<vector<int>>& grid) {
queue<pair<int ,int>> que;
memset(dis, -1, sizeof(dis));
int n = grid.size(), m = grid[0].size(), ans = 0;
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
if(grid[i][j] == 2){
que.push(make_pair(i, j));
dis[i][j] = 0;
}else if(grid[i][j] == 1){
cnt += 1;
}
}
}
while(!que.empty()){
pair<int ,int> x = que.front();
que.pop();
for(int i = 0; i < 4; i++){
int nx = x.first + dirs[i][0];
int ny = x.second + dirs[i][1];
if(nx < 0 || nx >= n || ny < 0 || ny >= m || ~dis[nx][ny] || !grid[nx][ny]) continue;
dis[nx][ny] = dis[x.first][x.second] + 1;
que.push(make_pair(nx, ny));
if(grid[nx][ny] == 1){
cnt -= 1;
ans = dis[nx][ny];
if(!cnt) break;
}
}
}
return cnt ? -1 : ans;
}
};
| 32.325 | 101 | 0.349575 | [
"vector"
] |
d91af5255c6c9c80b793092f5bf747d5b715ce3d | 6,290 | cpp | C++ | Vision/src/Vision/Platform/Windows/Win32FileSystem.cpp | ProjectElon/Vision | b3294565ab6bf79b84e163a5fdc448a36f163672 | [
"MIT"
] | 4 | 2020-01-10T12:43:02.000Z | 2020-10-28T02:01:58.000Z | Vision/src/Vision/Platform/Windows/Win32FileSystem.cpp | ProjectElon/Vision | b3294565ab6bf79b84e163a5fdc448a36f163672 | [
"MIT"
] | null | null | null | Vision/src/Vision/Platform/Windows/Win32FileSystem.cpp | ProjectElon/Vision | b3294565ab6bf79b84e163a5fdc448a36f163672 | [
"MIT"
] | null | null | null | #include "pch.hpp"
#include "Vision/Core/Defines.h"
#ifdef VN_PLATFORM_WINDOWS
#include "Vision/Platform/FileSystem.h"
#include <windows.h>
#include <fileapi.h>
namespace Vision
{
bool FileSystem::FileExists(const std::string& filepath)
{
DWORD attributes = GetFileAttributesA(filepath.c_str());
return (attributes != INVALID_FILE_ATTRIBUTES && !(attributes & FILE_ATTRIBUTE_DIRECTORY));
}
bool FileSystem::DirectoryExists(const std::string& path)
{
DWORD attributes = GetFileAttributesA(path.c_str());
return (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY));
}
std::string FileSystem::GetExecutableAbsolutePath()
{
char path[MAX_PATH];
GetModuleFileNameA(0, path, ARRAYSIZE(path));
std::string result = path;
std::replace(result.begin(), result.end(), '\\', '/');
return result;
}
std::string FileSystem::GetCurrentWorkingDirectory()
{
char path[MAX_PATH];
GetCurrentDirectoryA(ARRAYSIZE(path), path);
std::string result = path;
std::replace(result.begin(), result.end(), '\\', '/');
return result;
}
bool FileSystem::SetCurrentWorkingDirectory(const std::string& path)
{
return SetCurrentDirectoryA(path.c_str());
}
bool FileSystem::MakeDirectory(const std::string& path)
{
return CreateDirectoryA(path.c_str(), 0);
}
bool FileSystem::MakeDirectoryRecursive(const std::string& path)
{
uint32 firstSlash = path.find_first_of("/\\");
uint32 count = path.size();
uint32 index = firstSlash + 1;
while (index < count)
{
if (path[index] == '/' || path[index] == '\\')
{
uint32 countFromStart = index;
std::string subPath = path.substr(0, countFromStart);
MakeDirectory(subPath);
}
++index;
}
return MakeDirectory(path);
}
std::vector<std::string> FileSystem::ScanDirectory(const std::string& path,
const std::vector<std::string>& extensions,
bool includeSubDirectories)
{
WIN32_FIND_DATAA info;
HANDLE handle = FindFirstFileA((path + "/*").c_str(), &info);
if (handle == INVALID_HANDLE_VALUE)
{
return std::vector<std::string>();
}
// @Note: so we can make the . in the extensions optional
bool includeDot = true;
if (!extensions.empty() && extensions.front()[0] != '.')
{
includeDot = false;
}
std::vector<std::string> result;
while (FindNextFileA(handle, &info))
{
bool isDirectory = info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
if (isDirectory)
{
std::string directoryName = info.cFileName;
if (includeSubDirectories && directoryName.back() != '.')
result.push_back(directoryName);
continue;
}
std::string name = info.cFileName;
std::string extension = FileSystem::GetFileExtension(name, includeDot);
if (extensions.empty() || std::find(extensions.begin(), extensions.end(), extension) != extensions.end())
{
std::string filepath = path + "/" + name;
std::replace(filepath.begin(), filepath.end(), '\\', '/');
result.push_back(filepath);
}
}
FindClose(handle);
return result;
}
struct DirectoryInfo
{
HANDLE Handle;
std::string Path;
};
std::vector<std::string> FileSystem::ScanDirectoryRecursive(const std::string& path, const std::vector<std::string>& extensions, bool includeSubDirectories)
{
WIN32_FIND_DATAA info;
DirectoryInfo parentDirectory;
parentDirectory.Handle = FindFirstFileA((path + "/*").c_str(), &info);
parentDirectory.Path = path;
if (parentDirectory.Handle == INVALID_HANDLE_VALUE)
{
return std::vector<std::string>();
}
// @Note: so we can make the . in the extensions optional
bool includeDot = true;
if (!extensions.empty() && extensions.front()[0] != '.')
{
includeDot = false;
}
std::stack<DirectoryInfo> directories;
directories.push(parentDirectory);
std::vector<std::string> result;
while (!directories.empty())
{
const DirectoryInfo& currentDirectory = directories.top();
if (!FindNextFileA(currentDirectory.Handle, &info))
{
directories.pop();
continue;
}
std::string name = info.cFileName;
bool isDirectory = (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
if (isDirectory)
{
if (name != "." && name != "..")
{
DirectoryInfo nextDirectory;
nextDirectory.Path = currentDirectory.Path + "/" + name;
nextDirectory.Handle = FindFirstFileA((nextDirectory.Path + "/*").c_str(), &info);
directories.push(nextDirectory);
}
if (includeSubDirectories)
{
if (currentDirectory.Path.back() != '.')
result.push_back(currentDirectory.Path);
}
}
else
{
std::string extension = FileSystem::GetFileExtension(name, includeDot);
if (extensions.empty() || std::find(extensions.begin(), extensions.end(), extension) != extensions.end())
{
std::string currentFilePath = currentDirectory.Path + "/" + name;
std::replace(currentFilePath.begin(), currentFilePath.end(), '\\', '/');
result.push_back(currentFilePath);
}
}
}
FindClose(parentDirectory.Handle);
return result;
}
}
#endif | 29.669811 | 160 | 0.540859 | [
"vector"
] |
d91d08a943d3d4e1fe3791eddc235cf7de73008b | 1,413 | cpp | C++ | SWExpertAcademy/SWEA1215.cpp | sungmen/Acmicpc_Solve | 0298a6aec84993a4d8767bd2c00490b7201e06a4 | [
"MIT"
] | 1 | 2020-07-08T23:16:19.000Z | 2020-07-08T23:16:19.000Z | SWExpertAcademy/SWEA1215.cpp | sungmen/Acmicpc_Solve | 0298a6aec84993a4d8767bd2c00490b7201e06a4 | [
"MIT"
] | 1 | 2020-05-16T03:12:24.000Z | 2020-05-16T03:14:42.000Z | SWExpertAcademy/SWEA1215.cpp | sungmen/Acmicpc_Solve | 0298a6aec84993a4d8767bd2c00490b7201e06a4 | [
"MIT"
] | 2 | 2020-05-16T03:25:16.000Z | 2021-02-10T16:51:25.000Z | #include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
for(int test_case = 1; test_case <= 10; test_case++) {
int n;
cin >> n;
vector<vector<char> > vi(8, vector<char>(8));
for(int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
cin >> vi[i][j];
int cnt = 0;
for(int i = 0; i < 8; i++) {
for (int j = 0; j < 8 - n + 1; j++) {
int left = j, right = n - 1 + j;
int chk = 1;
while(left <= right) {
if (vi[i][left] != vi[i][right]){
chk = 0;
break;
}
left++; right--;
}
if(chk != 0)
cnt++;
chk = 1;
left = j, right = n - 1 + j;
while(left <= right) {
if (vi[left][i] != vi[right][i]){
chk = 0;
break;
}
left++; right--;
}
if(chk != 0)
cnt++;
}
}
cout << "#" << test_case << " " << cnt << endl;
}
return 0;
}
| 26.660377 | 59 | 0.295824 | [
"vector"
] |
0baac47cd7e0ce92dfa33d45adee2d6143556dd4 | 2,729 | cpp | C++ | tests/libs/trilinos/tests/lesson_tpetra_init.cpp | viniciusferrao/ohpc | edae86737aeeeee1a9d0c1e6a1ac7139d5fce971 | [
"Apache-2.0"
] | 692 | 2015-11-12T13:56:43.000Z | 2022-03-30T03:45:59.000Z | tests/libs/trilinos/tests/lesson_tpetra_init.cpp | viniciusferrao/ohpc | edae86737aeeeee1a9d0c1e6a1ac7139d5fce971 | [
"Apache-2.0"
] | 1,096 | 2015-11-12T09:08:22.000Z | 2022-03-31T21:48:41.000Z | tests/libs/trilinos/tests/lesson_tpetra_init.cpp | viniciusferrao/ohpc | edae86737aeeeee1a9d0c1e6a1ac7139d5fce971 | [
"Apache-2.0"
] | 224 | 2015-11-12T21:17:03.000Z | 2022-03-30T00:57:48.000Z | /*!
\example lesson01_mpi_only_through_Tpetra.cpp
\brief Initialization example for a code that only uses MPI through Tpetra.
\ref Tpetra_Lesson01 gives a full description of this example.
*/
//
// This example includes MPI initialization, getting a Teuchos::Comm
// communicator, and printing out Tpetra version information.
//
#include <Tpetra_Core.hpp>
#include <Tpetra_Version.hpp>
// Do something with the given communicator. In this case, we just
// print Tpetra's version to stdout on Process 0.
void
exampleRoutine (const Teuchos::RCP<const Teuchos::Comm<int> >& comm)
{
if (comm->getRank () == 0) {
// On (MPI) Process 0, print out the Tpetra software version.
std::cout << Tpetra::version () << std::endl << std::endl;
}
}
int
main (int argc, char *argv[])
{
// These "using" declarations make the code more concise, in that
// you don't have to write the namespace along with the class or
// object name. This is especially helpful with commonly used
// things like std::endl.
using std::cout;
using std::endl;
// Start up MPI, if using MPI. Trilinos doesn't have to be built
// with MPI; it's called a "serial" build if you build without MPI.
// Tpetra::ScopeGuard hides this implementation detail.
Tpetra::ScopeGuard tpetraScope (&argc, &argv);
{
// Never let Tpetra objects persist after either MPI_Finalize or
// Kokkos::finalize has been called. This is because the objects'
// destructors may need to call MPI or Kokkos functions. In
// particular, never create Tpetra objects at main scope.
// Get a pointer to the communicator object representing
// MPI_COMM_WORLD. The function knows whether or not we built with
// MPI support. If we didn't build with MPI, we'll get a
// "communicator" with size 1, whose only process has rank 0.
Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm ();
// Get my process' rank, and the total number of processes.
// Equivalent to MPI_Comm_rank resp. MPI_Comm_size.
const int myRank = comm->getRank ();
const int numProcs = comm->getSize ();
if (myRank == 0) {
cout << "Total number of processes: " << numProcs << endl;
}
// Do something with the new communicator.
exampleRoutine (comm);
// This tells the Trilinos test framework that the test passed.
if (myRank == 0) {
cout << "End Result: TEST PASSED" << endl;
}
// ScopeGuard's destructor calls MPI_Finalize, if its constructor
// called MPI_Init. Likewise, it calls Kokkos::finalize, if its
// constructor called Kokkos::initialize.
}
// You don't have to do anything here! Just return from main().
// Isn't that helpful?
return 0;
}
| 34.544304 | 77 | 0.689996 | [
"object"
] |
0bac70f981b2787af4a8ac4603c7c421ca0aebc7 | 5,392 | cpp | C++ | src/mongo/db/catalog/index_build_entry_test.cpp | benety/mongo | 203430ac9559f82ca01e3cbb3b0e09149fec0835 | [
"Apache-2.0"
] | null | null | null | src/mongo/db/catalog/index_build_entry_test.cpp | benety/mongo | 203430ac9559f82ca01e3cbb3b0e09149fec0835 | [
"Apache-2.0"
] | null | null | null | src/mongo/db/catalog/index_build_entry_test.cpp | benety/mongo | 203430ac9559f82ca01e3cbb3b0e09149fec0835 | [
"Apache-2.0"
] | null | null | null | /**
* Copyright (C) 2018-present MongoDB, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* 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
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the Server Side Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*/
#include "mongo/platform/basic.h"
#include <string>
#include <vector>
#include "mongo/bson/bsonobj.h"
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/bson/bsontypes.h"
#include "mongo/db/catalog/commit_quorum_options.h"
#include "mongo/db/catalog/index_build_entry_gen.h"
#include "mongo/unittest/unittest.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/net/hostandport.h"
#include "mongo/util/uuid.h"
namespace mongo {
namespace {
std::vector<std::string> generateIndexes(size_t numIndexes) {
std::vector<std::string> indexes;
for (size_t i = 0; i < numIndexes; i++) {
indexes.push_back("index_" + std::to_string(i));
}
return indexes;
}
std::vector<HostAndPort> generateCommitReadyMembers(size_t numMembers) {
std::vector<HostAndPort> members;
for (size_t i = 0; i < numMembers; i++) {
members.push_back(HostAndPort("localhost:27017"));
}
return members;
}
void checkIfEqual(IndexBuildEntry lhs, IndexBuildEntry rhs) {
ASSERT_EQ(lhs.getBuildUUID(), rhs.getBuildUUID());
ASSERT_EQ(lhs.getCollectionUUID(), rhs.getCollectionUUID());
BSONObj commitQuorumOptionsBsonLHS = lhs.getCommitQuorum().toBSON();
BSONObj commitQuorumOptionsBsonRHS = rhs.getCommitQuorum().toBSON();
ASSERT_BSONOBJ_EQ(commitQuorumOptionsBsonLHS, commitQuorumOptionsBsonRHS);
auto lhsIndexNames = lhs.getIndexNames();
auto rhsIndexNames = rhs.getIndexNames();
ASSERT_TRUE(std::equal(lhsIndexNames.begin(), lhsIndexNames.end(), rhsIndexNames.begin()));
if (lhs.getCommitReadyMembers() && rhs.getCommitReadyMembers()) {
auto lhsMembers = lhs.getCommitReadyMembers().get();
auto rhsMembers = rhs.getCommitReadyMembers().get();
ASSERT_TRUE(std::equal(lhsMembers.begin(), lhsMembers.end(), rhsMembers.begin()));
} else {
ASSERT_FALSE(lhs.getCommitReadyMembers());
ASSERT_FALSE(rhs.getCommitReadyMembers());
}
}
TEST(IndexBuildEntryTest, IndexBuildEntryWithRequiredFields) {
const UUID id = UUID::gen();
const UUID collectionUUID = UUID::gen();
const CommitQuorumOptions commitQuorum(1);
const std::vector<std::string> indexes = generateIndexes(1);
IndexBuildEntry entry(id, collectionUUID, commitQuorum, indexes);
ASSERT_EQUALS(entry.getBuildUUID(), id);
ASSERT_EQUALS(entry.getCollectionUUID(), collectionUUID);
ASSERT_EQUALS(entry.getCommitQuorum().numNodes, 1);
ASSERT_EQUALS(entry.getIndexNames().size(), indexes.size());
}
TEST(IndexBuildEntryTest, IndexBuildEntryWithOptionalFields) {
const UUID id = UUID::gen();
const UUID collectionUUID = UUID::gen();
const CommitQuorumOptions commitQuorum(CommitQuorumOptions::kMajority);
const std::vector<std::string> indexes = generateIndexes(3);
IndexBuildEntry entry(id, collectionUUID, commitQuorum, indexes);
entry.setCommitReadyMembers(generateCommitReadyMembers(2));
ASSERT_EQUALS(entry.getBuildUUID(), id);
ASSERT_EQUALS(entry.getCollectionUUID(), collectionUUID);
ASSERT_EQUALS(entry.getCommitQuorum().mode, CommitQuorumOptions::kMajority);
ASSERT_EQUALS(entry.getIndexNames().size(), indexes.size());
ASSERT_EQ(entry.getCommitReadyMembers()->size(), 2U);
}
TEST(IndexBuildEntryTest, SerializeAndDeserialize) {
const UUID id = UUID::gen();
const UUID collectionUUID = UUID::gen();
const CommitQuorumOptions commitQuorum("someTag");
const std::vector<std::string> indexes = generateIndexes(1);
IndexBuildEntry entry(id, collectionUUID, commitQuorum, indexes);
entry.setCommitReadyMembers(generateCommitReadyMembers(3));
BSONObj obj = entry.toBSON();
ASSERT_TRUE(obj.valid());
IDLParserErrorContext ctx("IndexBuildsEntry Parser");
IndexBuildEntry rebuiltEntry = IndexBuildEntry::parse(ctx, obj);
checkIfEqual(entry, rebuiltEntry);
}
} // namespace
} // namespace mongo
| 39.357664 | 95 | 0.728672 | [
"vector"
] |
0bad8d0d86e4cee41ce6e83f236b73c6106188b5 | 7,382 | cpp | C++ | assets/win32/winclip.cpp | ajeep8/vscode-vditor | e872345e6538db59f995fb90d2a2f8917877229a | [
"MIT"
] | null | null | null | assets/win32/winclip.cpp | ajeep8/vscode-vditor | e872345e6538db59f995fb90d2a2f8917877229a | [
"MIT"
] | null | null | null | assets/win32/winclip.cpp | ajeep8/vscode-vditor | e872345e6538db59f995fb90d2a2f8917877229a | [
"MIT"
] | null | null | null | #include <windows.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <sstream>
#include <iomanip>
typedef struct {
UINT format;
char *name;
} FORMATDATA;
FORMATDATA formatlist[] = {
{CF_TEXT, "ANSI text"},
{CF_BITMAP, "Handle to a bitmap (GDI object)"},
{CF_METAFILEPICT, "Windows-Format Metafiles picture"},
{CF_SYLK, "Microsoft Symbolic Link"},
{CF_DIF, "Software Arts Data Interchange Format"},
{CF_TIFF, "TIFF image"},
{CF_OEMTEXT, "8-Bit DOS text"},
{CF_DIB, "Device Independent Bitmap"},
{CF_PALETTE, "Handle to a color palette (GDI object)"},
{CF_PENDATA, "Windows 3.1 pen extension data"},
{CF_RIFF, "Resource Interchange File Format (RIFF) audio"},
{CF_WAVE, "WAVE audio"},
{CF_UNICODETEXT, "Unicode text"},
{CF_ENHMETAFILE, "Enhanced-Format Metafiles handle"},
{CF_HDROP, "List of file names"},
{CF_LOCALE, "LCID for CF_TEXT to CF_UNICODE conversion"},
{CF_DIBV5, "Structure followed by bitmap bits"},
{CF_DSPTEXT, "ANSI text"},
{CF_DSPBITMAP, "Handle to a bitmap (GDI object)"},
{CF_DSPMETAFILEPICT, "Windows-Format Metafiles picture"},
{CF_DSPENHMETAFILE, "Enhanced-Format Metafiles handle"},
{0, NULL}
};
UINT cf_html, cf_csv, cf_rtf;
std::map<UINT, std::string> supportedFormats = {
{CF_UNICODETEXT, "Plain Text"},
{CF_HDROP, "List of filenames"},
};
static void StopWithError(int code, std::string message)
{
printf("{\n");
printf("\t\"format\": \"none\",\n");
printf("\t\"errnr\": %d,\n", code);
printf("\t\"error\": \"%s\"\n", message.c_str());
printf("}\n");
CloseClipboard();
exit(1);
}
// base64 encode code by René Nyffenegger (rene.nyffenegger@adp-gmbh.ch)
static const std::string base64_chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789+/";
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len)
{
std::string ret;
int i = 0;
int j = 0;
unsigned char char_array_3[3];
unsigned char char_array_4[4];
while (in_len--) {
char_array_3[i++] = *(bytes_to_encode++);
if (i == 3) {
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
char_array_4[3] = char_array_3[2] & 0x3f;
for(i = 0; i < 4; i++) {
ret += base64_chars[char_array_4[i]];
}
i = 0;
}
}
if (i) {
for(j = i; j < 3; j++) {
char_array_3[j] = '\0';
}
char_array_4[0] = ( char_array_3[0] & 0xfc) >> 2;
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
for (j = 0; j < i + 1; j++) {
ret += base64_chars[char_array_4[j]];
}
while (i++ < 3) {
ret += '=';
}
}
return ret;
}
static std::string escape_json(const std::string &s)
{
std::ostringstream o;
for (auto c = s.cbegin(); c != s.cend(); c++) {
if (*c == '"' || *c == '\\' || ('\x00' <= *c && *c <= '\x1f')) {
o << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (int)*c;
} else {
o << *c;
}
}
return o.str();
}
static std::string unicode2utf8(const WCHAR *unicode)
{
int utf8_size = WideCharToMultiByte(CP_UTF8, 0, unicode, -1, NULL, 0, NULL, NULL) + 1;
char* utf8_str = (char*)malloc(utf8_size);
WideCharToMultiByte(CP_UTF8, 0, unicode, -1, utf8_str, utf8_size, NULL, NULL);
return utf8_str;
}
static char *GetFormatName(UINT format)
{
for (int i=0; formatlist[i].format; i++) {
if (format == formatlist[i].format) return formatlist[i].name;
}
static char name[128];
if (GetClipboardFormatNameA(format, name, sizeof(name)) > 0) {
return name;
}
return "unknown";
}
static void EnumAllFormats(void)
{
UINT format = 0;
while ((format = EnumClipboardFormats(format))) {
char *name = GetFormatName(format);
printf("%5u %s\n", format, name);
}
}
static void EnumFormats(void)
{
std::vector<UINT> list;
UINT format = 0;
while ((format = EnumClipboardFormats(format))) {
if (supportedFormats.count(format) > 0) {
list.push_back(format);
}
}
std::sort(list.begin(), list.end());
int count = 0;
printf("[\n");
for(auto const& value: list) {
if (count++ > 0) printf("\t,{\n"); else printf("\t{\n");
printf("\t\t\"format\": %d,\n", value);
printf("\t\t\"name\": \"%s\"\n", supportedFormats[value].c_str());
printf("\t}\n");
}
printf("]\n");
}
static void CreateResponse(UINT format, const std::string& text)
{
std::string json_text = escape_json(text);
printf("{\n");
printf("\t\"format\": %d,\n", format);
printf("\t\"data\": \"%s\"\n", json_text.c_str());
printf("}\n");
}
static std::string ExtractEntity(const std::string s)
{
const std::string start_token = "StartFragment:";
const std::string end_token = "EndFragment:";
unsigned long int start = 0, end = 0;
std::istringstream iss(s);
std::string line;
while (std::getline(iss, line)) {
if (line.substr(0, start_token.length()) == start_token) {
start = strtoul(line.substr(start_token.length()).c_str(), NULL, 10);
}
if (line.substr(0, end_token.length()) == end_token) {
end = strtoul(line.substr(end_token.length()).c_str(), NULL, 10);
}
}
if (start > 0 && end > 0) {
return s.substr(start, end - start);
}
return s;
}
static void GetData(UINT format)
{
HANDLE hData = GetClipboardData(format);
if (hData == NULL) {
StopWithError(-2, "no data found for format");
return;
}
void *pData = GlobalLock(hData);
if (pData == NULL) {
StopWithError(-3, "error retrieving data for format");
return;
}
if (format == CF_UNICODETEXT) {
std::string text = unicode2utf8((WCHAR*)pData);
CreateResponse(format, text);
} else if (format == CF_HDROP) {
HDROP hDrop = (HDROP)pData;
UINT fileCount = DragQueryFile(hDrop, 0xFFFFFFFF, NULL, 0);
WCHAR buffer[MAX_PATH];
std::string filelist;
for (UINT i = 0; i < fileCount; i++) {
DragQueryFileW(hDrop, i, buffer, MAX_PATH);
std::string filename = unicode2utf8(buffer);
filelist += filename + "\r\n";
}
CreateResponse(format, filelist);
} else if (format == cf_html) {
std::string text = (char*)pData;
text = ExtractEntity(text);
CreateResponse(format, text);
} else if (format == cf_csv) {
std::string text = (char*)pData;
CreateResponse(format, text);
} else if (format == cf_rtf) {
std::string text = (char*)pData;
CreateResponse(format, text);
}
GlobalUnlock(hData);
}
int main(int argc, char **argv)
{
if (OpenClipboard(NULL) == FALSE) return 1;
cf_html = RegisterClipboardFormat("HTML Format");
supportedFormats.insert(std::pair<UINT, std::string>(cf_html, "HTML source"));
cf_csv = RegisterClipboardFormat("Csv");
supportedFormats.insert(std::pair<UINT, std::string>(cf_csv, "Commma-separated values"));
cf_rtf = RegisterClipboardFormat("Rich Text Format");
supportedFormats.insert(std::pair<UINT, std::string>(cf_rtf, "Rich Text Format"));
if (argc > 1) {
if (argv[1][0] == '*') {
EnumAllFormats();
} else {
char *endptr;
UINT format = strtoul(argv[1], &endptr, 10);
if (format == 0 && argv[1] == endptr) {
StopWithError(-1, "parameter not a number");
return 1;
}
GetData(format);
}
} else {
EnumFormats();
}
CloseClipboard();
return 0;
}
| 25.280822 | 90 | 0.633162 | [
"object",
"vector"
] |
0bb56af23689fabeba1cc897225b8f0376fc6036 | 16,335 | cpp | C++ | examples/video/enroll_callback.cpp | Sensory-Cloud/cpp-sdk | 9bd5171c529f6a5d6fa6b8ff58994a1709212709 | [
"Apache-2.0"
] | 3 | 2022-01-04T20:03:24.000Z | 2022-01-10T19:12:59.000Z | examples/video/enroll_callback.cpp | Sensory-Cloud/cpp-sdk | 9bd5171c529f6a5d6fa6b8ff58994a1709212709 | [
"Apache-2.0"
] | null | null | null | examples/video/enroll_callback.cpp | Sensory-Cloud/cpp-sdk | 9bd5171c529f6a5d6fa6b8ff58994a1709212709 | [
"Apache-2.0"
] | null | null | null | // An example of face services based on OpenCV camera streams.
//
// Author: Christian Kauten (ckauten@sensoryinc.com)
//
// Copyright (c) 2021 Sensory, 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, EXTERNRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
#include <iostream>
#include <thread>
#include <mutex>
#include <google/protobuf/util/time_util.h>
#include <sensorycloud/config.hpp>
#include <sensorycloud/services/health_service.hpp>
#include <sensorycloud/services/oauth_service.hpp>
#include <sensorycloud/services/video_service.hpp>
#include <sensorycloud/token_manager/insecure_credential_store.hpp>
#include <sensorycloud/token_manager/token_manager.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/imgproc.hpp>
#include "dep/argparse.hpp"
using sensory::token_manager::TokenManager;
using sensory::token_manager::InsecureCredentialStore;
using sensory::service::HealthService;
using sensory::service::VideoService;
using sensory::service::OAuthService;
/// @brief A bidirection stream reactor for biometric enrollments from video
/// stream data.
///
/// @details
/// Input data for the stream is provided by an OpenCV capture device.
///
class OpenCVReactor :
public VideoService<InsecureCredentialStore>::CreateEnrollmentBidiReactor {
private:
/// A flag determining whether the last sent frame was enrolled. This flag
/// is atomic to support thread safe reads and writes.
std::atomic<bool> isEnrolled;
/// The completion percentage of the enrollment request.
std::atomic<float> percentComplete;
/// A flag determining whether the last sent frame was detected as live.
std::atomic<bool> isLive;
/// An OpenCV matrix containing the frame data from the camera.
cv::Mat frame;
/// A mutual exclusion for locking access to the frame between foreground
/// (frame capture) and background (network stream processing) threads.
std::mutex frameMutex;
/// Whether to produce verbose output in the reactor
bool verbose = false;
public:
/// @brief Initialize a reactor for streaming video from an OpenCV stream.
OpenCVReactor(const bool& verbose_ = false) :
VideoService<InsecureCredentialStore>::CreateEnrollmentBidiReactor(),
isEnrolled(false),
percentComplete(0),
isLive(false),
verbose(verbose_) { }
/// @brief React to a _write done_ event.
///
/// @param ok whether the write succeeded.
///
void OnWriteDone(bool ok) override {
if (isEnrolled) { // Successfully enrolled! Close the stream.
StartWritesDone();
return;
}
// If the status is not OK, then an error occurred during the stream.
if (!ok) return;
std::vector<unsigned char> buffer;
{ // Lock the mutex and encode the frame with JPEG into a buffer.
std::lock_guard<std::mutex> lock(frameMutex);
cv::imencode(".jpg", frame, buffer);
}
// Create the request from the encoded image data.
request.set_imagecontent(buffer.data(), buffer.size());
/// Start the next write request with the current frame.
StartWrite(&request);
}
/// @brief React to a _read done_ event.
///
/// @param ok whether the read succeeded.
///
void OnReadDone(bool ok) override {
// If the enrollment is complete, there is no more data to read.
if (isEnrolled) return;
// If the status is not OK, then an error occurred during the stream.
if (!ok) return;
// Log information about the response to the terminal.
if (verbose) {
std::cout << "Frame Response: " << std::endl;
std::cout << "\tPercent Complete: " << response.percentcomplete() << std::endl;
std::cout << "\tIs Alive?: " << response.isalive() << std::endl;
std::cout << "\tEnrollment ID: " << response.enrollmentid() << std::endl;
std::cout << "\tModel Name: " << response.modelname() << std::endl;
std::cout << "\tModel Version: " << response.modelversion() << std::endl;
}
// If the enrollment ID is not empty, then the enrollment succeeded.
isEnrolled = !response.enrollmentid().empty();
// Set the completion percentage of the enrollment.
percentComplete = response.percentcomplete() / 100.f;
// Set the liveness status of the last frame.
isLive = response.isalive();
if (!isEnrolled) { // Start the next read request.
StartRead(&response);
} else {
std::cout << "Successfully enrolled with ID: "
<< response.enrollmentid() << std::endl;
}
}
/// @brief Stream video from an OpenCV capture device.
///
/// @param capture The OpenCV capture device.
/// @param isLivenessEnabled `true` to enable the liveness check interface,
/// `false` to disable the interface.
///
::grpc::Status streamVideo(cv::VideoCapture& capture, const bool& isLivenessEnabled) {
// Start the call to initiate the stream in the background.
StartCall();
// Start capturing frames from the device.
while (!isEnrolled) {
{ // Lock the mutex and read a frame.
std::lock_guard<std::mutex> lock(frameMutex);
capture >> frame;
}
// If the frame is empty, something went wrong, exit the capture
// loop.
if (frame.empty()) break;
// Draw the progress bar on the frame. Do this on a copy of the
// so that the presentation frame is not sent to the server for
// enrollment.
auto presentationFrame = frame.clone();
cv::rectangle(
presentationFrame,
cv::Point(0, 0),
cv::Point(presentationFrame.size().width, 10),
cv::Scalar(0, 0, 0), -1);
cv::rectangle(
presentationFrame,
cv::Point(0, 0),
cv::Point(percentComplete * presentationFrame.size().width, 10),
cv::Scalar(0, 255, 0), -1);
// Draw text indicating the liveness status of the last frame.
if (isLivenessEnabled) { // Liveness is enabled.
cv::putText(presentationFrame,
isLive ? "Live" : "Not Live",
cv::Point(10, 40),
cv::FONT_HERSHEY_SIMPLEX,
1, // font scale
isLive ? cv::Scalar(0, 255, 0) : cv::Scalar(0, 0, 255),
2 // thickness
);
}
// Show the frame in a view-finder window.
cv::imshow("Sensory Cloud Face Enrollment Demo", presentationFrame);
// Listen for keyboard interrupts to terminate the capture.
char c = (char) cv::waitKey(10);
if (c == 27 || c == 'q' || c == 'Q') break;
}
return await();
}
};
int main(int argc, const char** argv) {
// Create an argument parser to parse inputs from the command line.
auto parser = argparse::ArgumentParser(argc, argv)
.prog("enroll")
.description("A tool for authenticating with face biometrics using Sensory Cloud.");
parser.add_argument({ "-H", "--host" })
.required(true)
.help("HOST The hostname of a Sensory Cloud inference server.");
parser.add_argument({ "-P", "--port" })
.required(true)
.help("PORT The port number that the Sensory Cloud inference server is running at.");
parser.add_argument({ "-T", "--tenant" })
.required(true)
.help("TENANT The ID of your tenant on a Sensory Cloud inference server.");
parser.add_argument({ "-I", "--insecure" })
.action("store_true")
.help("INSECURE Disable TLS.");
parser.add_argument({ "-g", "--getmodels" })
.action("store_true")
.help("GETMODELS Whether to query for a list of available models.");
parser.add_argument({ "-m", "--model" })
.help("MODEL The model to use for the enrollment.");
parser.add_argument({ "-u", "--userid" })
.help("USERID The name of the user ID to query the enrollments for.");
parser.add_argument({ "-d", "--description" })
.help("DESCRIPTION A text description of the enrollment.");
parser.add_argument({ "-l", "--liveness" })
.action("store_true")
.help("LIVENESS Whether to conduct a liveness check in addition to the enrollment.");
parser.add_argument({ "-t", "--threshold" })
.choices({"LOW", "MEDIUM", "HIGH", "HIGHEST"})
.default_value("HIGH")
.help("THRESHOLD The security threshold for conducting the liveness check.");
parser.add_argument({ "-D", "--device" })
.default_value(0)
.help("DEVICE The ID of the OpenCV device to use.");
parser.add_argument({ "-v", "--verbose" })
.action("store_true")
.help("VERBOSE Produce verbose output during authentication.");
// Parse the arguments from the command line.
const auto args = parser.parse_args();
const auto HOSTNAME = args.get<std::string>("host");
const auto PORT = args.get<uint16_t>("port");
const auto TENANT = args.get<std::string>("tenant");
const auto IS_SECURE = !args.get<bool>("insecure");
const auto GETMODELS = args.get<bool>("getmodels");
const auto MODEL = args.get<std::string>("model");
const auto USER_ID = args.get<std::string>("userid");
const auto DESCRIPTION = args.get<std::string>("description");
const auto LIVENESS = args.get<bool>("liveness");
sensory::api::v1::video::RecognitionThreshold THRESHOLD;
if (args.get<std::string>("threshold") == "LOW")
THRESHOLD = sensory::api::v1::video::RecognitionThreshold::LOW;
else if (args.get<std::string>("threshold") == "MEDIUM")
THRESHOLD = sensory::api::v1::video::RecognitionThreshold::MEDIUM;
else if (args.get<std::string>("threshold") == "HIGH")
THRESHOLD = sensory::api::v1::video::RecognitionThreshold::HIGH;
else if (args.get<std::string>("threshold") == "HIGHEST")
THRESHOLD = sensory::api::v1::video::RecognitionThreshold::HIGHEST;
const auto DEVICE = args.get<int>("device");
const auto VERBOSE = args.get<bool>("verbose");
// Create an insecure credential store for keeping OAuth credentials in.
sensory::token_manager::InsecureCredentialStore keychain(".", "com.sensory.cloud.examples");
if (!keychain.contains("deviceID"))
keychain.emplace("deviceID", sensory::token_manager::uuid_v4());
const auto DEVICE_ID(keychain.at("deviceID"));
// Initialize the configuration to the host for given address and port
sensory::Config config(HOSTNAME, PORT, TENANT, DEVICE_ID, IS_SECURE);
config.connect();
// Query the health of the remote service.
sensory::service::HealthService healthService(config);
sensory::api::common::ServerHealthResponse serverHealth;
auto status = healthService.getHealth(&serverHealth);
if (!status.ok()) { // the call failed, print a descriptive message
std::cout << "Failed to get server health with\n\t" <<
status.error_code() << ": " << status.error_message() << std::endl;
return 1;
} else if (VERBOSE) {
// Report the health of the remote service
std::cout << "Server status:" << std::endl;
std::cout << "\tisHealthy: " << serverHealth.ishealthy() << std::endl;
std::cout << "\tserverVersion: " << serverHealth.serverversion() << std::endl;
std::cout << "\tid: " << serverHealth.id() << std::endl;
}
// ------ Enroll the current user ----------------------------------------
// Create an OAuth service
OAuthService oauthService(config);
TokenManager<InsecureCredentialStore> tokenManager(oauthService, keychain);
if (!tokenManager.hasToken()) { // the device is not registered
// Generate a new clientID and clientSecret for this device
const auto credentials = tokenManager.hasSavedCredentials() ?
tokenManager.getSavedCredentials() : tokenManager.generateCredentials();
std::cout << "Registering device with server..." << std::endl;
// Query the friendly device name
std::string name = "";
std::cout << "Device Name: ";
std::cin >> name;
// Query the shared pass-phrase
std::string password = "";
std::cout << "Password: ";
std::cin >> password;
// Register this device with the remote host
oauthService.registerDevice(
name, password, credentials.id, credentials.secret,
[](OAuthService::RegisterDeviceCallData* call) {
if (!call->getStatus().ok()) { // The call failed.
std::cout << "Failed to register device with\n\t" <<
call->getStatus().error_code() << ": " <<
call->getStatus().error_message() << std::endl;
}
})->await();
}
// ------ Create the video service -----------------------------------------
// Create the video service based on the configuration and token manager.
VideoService<InsecureCredentialStore> videoService(config, tokenManager);
// ------ Query the available video models ---------------------------------
if (GETMODELS) {
int errCode = 0;
videoService.getModels([&errCode](VideoService<InsecureCredentialStore>::GetModelsCallData* call) {
if (!call->getStatus().ok()) { // The call failed.
std::cout << "Failed to get video models with\n\t" <<
call->getStatus().error_code() << ": " <<
call->getStatus().error_message() << std::endl;
errCode = 1;
} else {
// Iterate over the models returned in the response
for (auto& model : call->getResponse().models()) {
// Ignore models that aren't face biometric models.
if (model.modeltype() != sensory::api::common::FACE_BIOMETRIC)
continue;
std::cout << model.name() << std::endl;
}
}
})->await();
return errCode;
}
// Create an image capture object
cv::VideoCapture capture;
if (!capture.open(DEVICE)) {
std::cout << "Capture from camera #" << DEVICE << " failed" << std::endl;
return 1;
}
// Create the stream.
OpenCVReactor reactor(VERBOSE);
videoService.createEnrollment(&reactor,
sensory::service::video::newCreateEnrollmentConfig(
MODEL, USER_ID, DESCRIPTION, LIVENESS, THRESHOLD
)
);
// Wait for the stream to conclude. This is necessary to check the final
// status of the call and allow any dynamically allocated data to be cleaned
// up. If the stream is destroyed before the final `onDone` callback, odd
// runtime errors can occur.
status = reactor.streamVideo(capture, LIVENESS);
if (!status.ok()) {
std::cout << "Failed to enroll with\n\t" <<
status.error_code() << ": " <<
status.error_message() << std::endl;
}
return 0;
}
| 44.631148 | 107 | 0.615733 | [
"object",
"vector",
"model"
] |
0bba5ebb7650cc35d8b8ea06fe170b7d62e4f92d | 30,895 | cpp | C++ | src/frontends/onnx/frontend/src/op/com.microsoft/attention.cpp | ryanloney/openvino-1 | 4e0a740eb3ee31062ba0df88fcf438564f67edb7 | [
"Apache-2.0"
] | 1,127 | 2018-10-15T14:36:58.000Z | 2020-04-20T09:29:44.000Z | src/frontends/onnx/frontend/src/op/com.microsoft/attention.cpp | ryanloney/openvino-1 | 4e0a740eb3ee31062ba0df88fcf438564f67edb7 | [
"Apache-2.0"
] | 439 | 2018-10-20T04:40:35.000Z | 2020-04-19T05:56:25.000Z | src/frontends/onnx/frontend/src/op/com.microsoft/attention.cpp | ryanloney/openvino-1 | 4e0a740eb3ee31062ba0df88fcf438564f67edb7 | [
"Apache-2.0"
] | 414 | 2018-10-17T05:53:46.000Z | 2020-04-16T17:29:53.000Z | // Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "op/com.microsoft/attention.hpp"
#include "default_opset.hpp"
#include "ngraph/builder/split.hpp"
#include "onnx_import/core/null_node.hpp"
namespace ngraph {
namespace onnx_import {
namespace op {
namespace detail {
namespace {
NodeVector split_to_QKV(const std::shared_ptr<default_opset::Add>& node,
int64_t num_heads,
const std::vector<int64_t>& qkv_hidden_sizes);
using NodeTuple = std::tuple<std::shared_ptr<ngraph::Node>, std::shared_ptr<ngraph::Node>>;
NodeTuple get_attention_mask(const OutputVector& op_inputs, bool unidirectional);
std::shared_ptr<ngraph::Node> attention_softmax(const OutputVector& op_inputs,
const std::shared_ptr<ngraph::Node>& Q,
std::shared_ptr<ngraph::Node> K,
std::shared_ptr<ngraph::Node> V,
const std::shared_ptr<ngraph::Node>& attention_mask,
const std::shared_ptr<ngraph::Node>& bin_mask,
const std::shared_ptr<ngraph::Node>& head_size,
bool unidirectional);
std::shared_ptr<ngraph::Node> get_present_state(const std::shared_ptr<ngraph::Node>& K,
const std::shared_ptr<ngraph::Node>& V,
const OutputVector& op_inputs);
} // namespace
} // namespace detail
namespace set_1 {
OutputVector attention(const Node& node) {
auto nodes = node.get_ng_inputs();
const auto& input = nodes[0];
const auto& weights = nodes[1];
const auto& bias = nodes[2];
// Attention is defined as:
// Q = input x Wq, K = input x Wk, V = input x Wv
// attention = softmax((Q x K') / sqrt(head_size)) x V
//
// In this operator, Wq, Wk and Wv are combined in a single input 'weights' along the second axis.
// So the approach here is to do a single big matrix multiply
// and then split the result into Q, K, V matrices
auto matmul = std::make_shared<default_opset::MatMul>(input, weights);
auto add = std::make_shared<default_opset::Add>(matmul, bias);
const auto num_heads = node.get_attribute_value<int64_t>("num_heads");
const auto qkv_hidden_sizes = node.get_attribute_value<std::vector<int64_t>>("qkv_hidden_sizes", {});
const auto split_result = detail::split_to_QKV(add, num_heads, qkv_hidden_sizes);
bool unidirectional = static_cast<bool>(node.get_attribute_value<int64_t>("unidirectional", 0));
// mask has values either 0 or -10000 and its shape must be
// broadcastable to (batch_size, num_heads, sequence_length, past_sequence_length + sequence_length)
// so it can be added to Q x K' later
// past_sequence_length can be 0 if 'past' input is not available
std::shared_ptr<ngraph::Node> attention_mask = nullptr, bin_mask = nullptr;
std::tie(attention_mask, bin_mask) = detail::get_attention_mask(nodes, unidirectional);
const auto& Q = split_result[0];
const auto& K = split_result[1];
const auto& V = split_result[2];
const auto& head_size = split_result[3];
// compute softmax((Q x K' + mask) / sqrt(head_size))
const auto output = detail::attention_softmax(nodes, Q, K, V, attention_mask, bin_mask, head_size, unidirectional);
// present = concat(K, V) if 'past' input is unavailable
// or
// present = concat(past, K, V)
const auto present = detail::get_present_state(K, V, nodes);
return {output, present};
}
} // namespace set_1
namespace detail {
namespace {
std::shared_ptr<ngraph::Node> get_dimensions(const std::shared_ptr<default_opset::ShapeOf>& shape,
const std::vector<int>& dims) {
static const auto zero = default_opset::Constant::create(element::i32, Shape{}, {0});
const auto dims_const = default_opset::Constant::create(element::i32, Shape{dims.size()}, dims);
return std::make_shared<default_opset::Gather>(shape, dims_const, zero);
}
std::shared_ptr<ngraph::Node> get_dimensions(const std::shared_ptr<ngraph::Node>& node, const std::vector<int>& dims) {
return get_dimensions(std::make_shared<default_opset::ShapeOf>(node), dims);
}
std::shared_ptr<ngraph::Node> get_hidden_size(const std::shared_ptr<default_opset::ShapeOf>& node_shape) {
// node has shape (batch_size, sequence_length, 3 * hidden_size)
const auto zero = default_opset::Constant::create(element::i32, Shape{}, {0});
const auto hidden_size_x3 = get_dimensions(node_shape, {2});
const auto three = default_opset::Constant::create(element::i64, Shape{}, {3});
const auto hidden_size = std::make_shared<default_opset::Divide>(hidden_size_x3, three);
return hidden_size;
}
NodeVector split_to_QKV(const std::shared_ptr<default_opset::Add>& node,
int64_t num_heads,
const std::vector<int64_t>& qkv_hidden_sizes) {
OutputVector split;
std::shared_ptr<ngraph::Node> head_size = nullptr;
const auto& node_type = node->get_element_type();
const auto node_shape = std::make_shared<default_opset::ShapeOf>(node);
// node has shape (batch_size, sequence_length, 3 * hidden_size)
// fetch the first two dimensions
const auto batch_size_seq_len = get_dimensions(node_shape, {0, 1});
const auto num_heads_node = default_opset::Constant::create(element::i64, Shape{1}, {num_heads});
if (qkv_hidden_sizes.size() == 0) {
const auto hidden_size = get_hidden_size(node_shape);
// head_size = hidden_size / num_heads
head_size = std::make_shared<default_opset::Divide>(hidden_size, num_heads_node);
// split the node into 3 even parts Q, K, V with shape (batch_size, sequence_len, hidden_size)
split = ngraph::builder::opset1::split(node, 3, 2);
// and reshape each part to new shape (batch_size, sequence_len, num_heads, head_size)
auto new_shape =
std::make_shared<default_opset::Concat>(NodeVector{batch_size_seq_len, num_heads_node, head_size}, 0);
for (size_t i = 0; i < split.size(); i++) {
split[i] = std::make_shared<default_opset::Reshape>(split[i], new_shape, false);
}
head_size = std::make_shared<default_opset::Convert>(head_size, node_type);
} else {
// in this case, weights have shape
// (input_hidden_size, qkv_hidden_sizes[0] + qkv_hidden_sizes[1] + qkv_hidden_sizes[2])
// so user specified hidden_sizes for Q, K and V
NGRAPH_CHECK(qkv_hidden_sizes.size() == 3, "qkv_hidden_sizes attribute needs to have 3 values");
NGRAPH_CHECK(qkv_hidden_sizes[0] == qkv_hidden_sizes[1],
"qkv_hidden_sizes first element should be same as the second");
// split the node into 3 parts Q, K, V with shapes
// Q: (batch_size, sequence_len, qkv_hidden_sizes[0])
// K: (batch_size, sequence_len, qkv_hidden_sizes[1])
// V: (batch_size, sequence_len, qkv_hidden_sizes[2])
split = ngraph::builder::opset1::split(node, qkv_hidden_sizes, 2);
// and reshape each part to new shape (batch_size, sequence_len, num_heads, head_size)
for (size_t i = 0; i < split.size(); i++) {
auto new_shape = std::make_shared<default_opset::Concat>(
NodeVector{batch_size_seq_len,
num_heads_node,
default_opset::Constant::create(element::i64, Shape{1}, {qkv_hidden_sizes[i] / num_heads})},
0);
split[i] = std::make_shared<default_opset::Reshape>(split[i], new_shape, false);
}
float head_size_val = qkv_hidden_sizes[0] > 0 ? static_cast<float>(qkv_hidden_sizes[0]) / num_heads
: static_cast<float>(qkv_hidden_sizes[2]) / num_heads;
head_size = default_opset::Constant::create(node_type, Shape{1}, {head_size_val});
}
// transpose Q, K and V to (batch_size, num_heads, sequence_len, head_size)
auto perm = default_opset::Constant::create(element::i64, Shape{4}, {0, 2, 1, 3});
auto Q = std::make_shared<default_opset::Transpose>(split[0], perm);
auto K = std::make_shared<default_opset::Transpose>(split[1], perm);
auto V = std::make_shared<default_opset::Transpose>(split[2], perm);
return {Q, K, V, head_size};
}
// This function handles the case when mask_index rank is 1 - so its shape is (batch_size) or (2 * batch_size).
// The returned mask consists of 0 and -10000 and has shape (batch_size, 1, 1, all_seq_len). 'mask_index' input contains
// positions from where the -10000 values start appearing in the final mask per batch (if shape is (batch_size)) or if
// shape is (2 * batch_size), user can define two ranges of -10000 values appearing in the final mask. For example:
//
// batch_size = 3, all_seq_len = 5, mask_index = [2, 4, 3]
// the function returns following mask with shape (3, 1, 1, 5):
// 0, 0, -10000, -10000, -10000
// 0, 0, 0, 0, -10000
// 0, 0, 0, -10000, -10000
//
// e.g., for batch = 2, -10000 values appear within range [mask_index[2]:5] (or [3:5])
//
// Another example, but with mask_index shape (2 * batch_size)
// batch_size = 3, all_seq_len = 5, mask_index = [2, 4, 3, 1, 2, 2]
// the function returns following mask with shape (3, 1, 1, 5):
// -10000, 0, -10000, -10000, -10000
// -10000, -10000, 0, 0, -10000
// -10000, -10000, 0, -10000, -10000
//
// e.g., for batch = 1, -10000 values appear within two ranges [0, mask_index[4]] and [mask_index[1]:5] (or [0:2],[4:5])
//
//
// This is how it's done with nGraph operations:
//
// First the 'base' is generated by range + broadcast:
// base = range(0, all_seq_len)
// base = broadcast(base, shape=(batch_size, all_seq_len))
//
// With batch_size = 3 and all_seq_len = 5, 'base' looks as follows:
// [[0, 1, 2, 3, 4],
// [0, 1, 2, 3, 4],
// [0, 1, 2, 3, 4]]
//
// Next step is to reshape mask_index:
// mask_index = reshape(mask_index, shape=(-1, batch_size))
//
// With the second example above (mask_index = [2, 4, 3, 1, 2, 2]), now it looks like:
// mask_index = [[2, 4, 3],
// [1, 2, 2]]
//
// Now we get the first row and reshape it to (batch_size, 1) to have indices laid out in column:
// tail_range_indices = gather(mask_index, indices=[0], axis=0) # tail_range_indices = [2, 4, 3]
// tail_range_indices = reshape(tail_range_indices, shape=(batch_size, 1)
// # tail_range_indices = [[2],
// # [4],
// # [3]]
//
// Then the base is compared with the indices
// tail_range_mask = base >= tail_range_indices
//
// Thanks to autobroadcast in elementwise operators, the comparison conceptually happens between:
// [[0, 1, 2, 3, 4], [[2, 2, 2, 2, 2],
// [0, 1, 2, 3, 4], >= [4, 4, 4, 4, 4],
// [0, 1, 2, 3, 4]] [3, 3, 3, 3, 3]]
//
// and the result is:
// [[0, 0, 1, 1, 1],
// [0, 0, 0, 0, 1],
// [0, 0, 0, 1, 1]]
//
// So we get the final tail range mask by multiplying this by -10000
//
// Similarly we process with head range - we fetch the second row from reshaped mask_index,
// compare it with 'base' (but with 'Less' operator instead of 'GreaterEqual') and combine it
// with tail_range_mask.
//
// Handling both mask_index variants (so (batch_size) and (2 * batch_size)) is tricky since we don't
// know its dimensions upfront. So we compute both variants and use Select operator to select
// the right one in the runtime (unless it gets constantfolded before).
std::shared_ptr<ngraph::Node> attention_mask_from_indices(const Output<ngraph::Node>& mask_index,
const element::Type_t& type,
const std::shared_ptr<ngraph::Node>& batch_size,
const std::shared_ptr<ngraph::Node>& all_seq_len) {
const auto zero = default_opset::Constant::create(element::i64, Shape{}, {0});
const auto one = default_opset::Constant::create(element::i64, Shape{}, {1});
const auto stop = std::make_shared<default_opset::Squeeze>(all_seq_len, zero);
std::shared_ptr<ngraph::Node> base =
std::make_shared<default_opset::Range>(zero, stop, one, mask_index.get_element_type());
const auto target_shape = std::make_shared<default_opset::Concat>(NodeVector{batch_size, all_seq_len}, 0);
// broadcast 'base' to (batch_size, all_seq_len)
base = std::make_shared<default_opset::Broadcast>(base, target_shape);
const auto indices_shape = std::make_shared<default_opset::Concat>(
NodeVector{default_opset::Constant::create(element::i64, Shape{1}, {-1}), batch_size},
0);
std::shared_ptr<ngraph::Node> indices = std::make_shared<default_opset::Reshape>(mask_index, indices_shape, false);
// fetch first row from indices
std::shared_ptr<ngraph::Node> tail_range_indices = std::make_shared<default_opset::Gather>(indices, zero, zero);
tail_range_indices =
std::make_shared<default_opset::Reshape>(tail_range_indices,
default_opset::Constant::create(element::i32, Shape{2}, {-1, 1}),
false);
const auto greater_eq = std::make_shared<default_opset::GreaterEqual>(base, tail_range_indices);
std::shared_ptr<ngraph::Node> tail_range_mask =
std::make_shared<default_opset::Multiply>(std::make_shared<default_opset::Convert>(greater_eq, type),
default_opset::Constant::create(type, Shape{}, {-10000}));
tail_range_mask =
std::make_shared<default_opset::Unsqueeze>(tail_range_mask,
default_opset::Constant::create(element::i64, Shape{2}, {1, 2}));
const auto gather_index =
std::make_shared<default_opset::FloorMod>(default_opset::Constant::create(element::i64, Shape{}, {1}),
get_dimensions(indices, {0}));
// fetch indices from the second row (or first if not available)
std::shared_ptr<ngraph::Node> head_range_indices =
std::make_shared<default_opset::Gather>(indices, gather_index, zero);
head_range_indices =
std::make_shared<default_opset::Reshape>(head_range_indices,
default_opset::Constant::create(element::i32, Shape{2}, {-1, 1}),
false);
const auto less = std::make_shared<default_opset::Less>(base, head_range_indices);
std::shared_ptr<ngraph::Node> mask = std::make_shared<default_opset::LogicalOr>(less, greater_eq);
mask = std::make_shared<default_opset::Multiply>(std::make_shared<default_opset::Convert>(mask, type),
default_opset::Constant::create(type, Shape{}, {-10000}));
// reshape from (batch_size, all_seq_len) to (batch_size, 1, 1, all_seq_len)
mask = std::make_shared<default_opset::Unsqueeze>(mask,
default_opset::Constant::create(element::i64, Shape{2}, {1, 2}));
const auto mask_index_first_dim = get_dimensions(mask_index.get_node_shared_ptr(), {0});
// compare mask_index.shape[0] with batch_size value
// if they're equal - select tail_range_mask
// else select full mask
mask = std::make_shared<default_opset::Select>(
std::make_shared<default_opset::Equal>(batch_size, mask_index_first_dim),
tail_range_mask,
mask);
return mask;
}
// Prepare unidirectional_mask like it's done in
// https://github.com/microsoft/onnxruntime/blob/851554536ca8185b3413ee57449ea5ac93370193/onnxruntime/contrib_ops/cpu/bert/attention_helper.h#L87-L96
//
// Function returns two masks - one attention mask with values 0 or -10000 with shape (seq_len, all_seq_len),
// the second one is a binary mask where it has 0 on positions where attention mask has -10000 values and 1 otherwise.
//
// For example:
// seq_len = 4, all_seq_len = 7, past_seq_len = 3. Returned attention mask has shape (4, 7) and contains:
// 0 0 0 0 -10000 -10000 -10000
// 0 0 0 0 0 -10000 -10000
// 0 0 0 0 0 0 -10000
// 0 0 0 0 0 0 0
//
// Returned binary mask has the shape (4, 7) and following values:
// 1 1 1 1 0 0 0
// 1 1 1 1 1 0 0
// 1 1 1 1 1 1 0
// 1 1 1 1 1 1 1
//
// Binary mask is used later before softmax to achieve
// https://github.com/microsoft/onnxruntime/blob/851554536ca8185b3413ee57449ea5ac93370193/onnxruntime/contrib_ops/cpu/bert/attention_cpu_base.h#L158-L166
//
// The approach used to generate those masks is similar to one from attention_mask_from_indices function (see comments
// there).
NodeTuple unidirectional_mask(const element::Type_t& type,
const std::shared_ptr<ngraph::Node>& seq_len,
const std::shared_ptr<ngraph::Node>& all_seq_len,
const std::shared_ptr<ngraph::Node>& past_seq_len) {
const auto zero = default_opset::Constant::create(element::i64, Shape{}, {0});
const auto one = default_opset::Constant::create(element::i64, Shape{}, {1});
const auto stop = std::make_shared<default_opset::Squeeze>(all_seq_len, zero);
std::shared_ptr<ngraph::Node> bin_mask = std::make_shared<default_opset::Range>(zero, stop, one, element::i32);
auto target_shape = std::make_shared<default_opset::Concat>(NodeVector{seq_len, all_seq_len}, 0);
bin_mask = std::make_shared<default_opset::Broadcast>(bin_mask, target_shape);
auto start =
std::make_shared<default_opset::Squeeze>(std::make_shared<default_opset::Add>(past_seq_len, one), zero);
auto end = std::make_shared<default_opset::Squeeze>(std::make_shared<default_opset::Add>(all_seq_len, one), zero);
auto indices = std::make_shared<default_opset::Unsqueeze>(
std::make_shared<default_opset::Range>(start, end, one, element::i32),
default_opset::Constant::create(element::i32, Shape{1}, {1}));
bin_mask = std::make_shared<default_opset::GreaterEqual>(bin_mask, indices);
std::shared_ptr<ngraph::Node> attention_mask =
std::make_shared<default_opset::Multiply>(std::make_shared<default_opset::Convert>(bin_mask, type),
default_opset::Constant::create(type, Shape{}, {-10000}));
bin_mask = std::make_shared<default_opset::Convert>(std::make_shared<default_opset::LogicalNot>(bin_mask), type);
return NodeTuple{attention_mask, bin_mask};
}
// This is the easiest variant of 'mask_index' input - the input consists of 0 or 1 values
// and we transform them to:
// * -10000 for positions where mask_index == 0
// * 0 for positions where mask_index == 1
//
// It handles mask_index with shapes:
// (batch_size, past_sequence_length + sequence_length) or
// (batch_size, sequence_length, past_sequence_length + sequence_length)
//
// Shape (batch_size, 1, max_sequence_length, max_sequence_length) is not supported in onnxruntime:
// https://github.com/microsoft/onnxruntime/blob/851554536ca8185b3413ee57449ea5ac93370193/onnxruntime/contrib_ops/cpu/bert/attention_helper.h#L78
std::shared_ptr<ngraph::Node> raw_mask(const Output<ngraph::Node>& mask_index,
Dimension::value_type mask_rank,
const element::Type_t& type) {
std::shared_ptr<ngraph::Node> mask = std::make_shared<default_opset::Convert>(mask_index, type);
mask = std::make_shared<default_opset::Convert>(mask, type);
mask = std::make_shared<default_opset::Subtract>(default_opset::Constant::create(type, Shape{}, {1}), mask);
mask = std::make_shared<default_opset::Multiply>(mask, default_opset::Constant::create(type, Shape{}, {-10000}));
switch (mask_rank) {
// Handle mask_index with (batch_size, past_sequence_length + sequence_length) shape
// Reshape it to (batch_size, 1, 1, past_sequence_length + sequence_length)
case 2:
mask = std::make_shared<default_opset::Reshape>(
mask,
default_opset::Constant::create(element::i64, Shape{4}, {0, 1, 1, -1}),
true);
break;
// Handle mask_index with (batch_size, sequence_length, past_sequence_length + sequence_length) shape
// Reshape it to (batch_size, 1, sequence_length, past_sequence_length + sequence_length)
case 3:
mask = std::make_shared<default_opset::Reshape>(
mask,
default_opset::Constant::create(element::i64, Shape{4}, {0, 1, 0, -1}),
true);
break;
}
return mask;
}
bool is_past_input_available(const OutputVector& op_inputs) {
return op_inputs.size() > 4 && !ngraph::op::is_null(op_inputs[4]);
}
NodeTuple get_attention_mask(const OutputVector& op_inputs, bool unidirectional) {
const auto zero = default_opset::Constant::create(element::i64, Shape{1}, {0});
const auto one = default_opset::Constant::create(element::i64, Shape{1}, {1});
std::shared_ptr<ngraph::Node> past_seq_len;
// get the value of past_sequence_length
if (is_past_input_available(op_inputs)) {
const auto& past = op_inputs[4];
// 'past' node has shape (2, batch_size, num_heads, past_sequence_length, head_size)
past_seq_len = get_dimensions(past.get_node_shared_ptr(), {3});
} else {
past_seq_len = zero;
}
// 'input' node has shape (batch_size, sequence_length, input_hidden_size)
auto input_shape = std::make_shared<default_opset::ShapeOf>(op_inputs[0]);
auto seq_len = get_dimensions(input_shape, {1});
auto all_seq_len = std::make_shared<default_opset::Add>(seq_len, past_seq_len);
const auto& type = op_inputs[0].get_element_type();
std::shared_ptr<ngraph::Node> attention_mask = nullptr;
std::shared_ptr<ngraph::Node> bin_mask = nullptr;
if (unidirectional) {
std::tie(attention_mask, bin_mask) = unidirectional_mask(type, seq_len, all_seq_len, past_seq_len);
}
if (op_inputs.size() > 3 && !ngraph::op::is_null(op_inputs[3])) {
const auto& mask_index = op_inputs[3];
NGRAPH_CHECK(mask_index.get_element_type() == element::i32, "'mask_index' type must be int32");
auto batch_size = get_dimensions(input_shape, {0});
const auto mask_rank = mask_index.get_partial_shape().rank();
NGRAPH_CHECK(mask_rank.is_static(), "'mask_index' rank must be static");
auto mask_rank_val = mask_rank.get_length();
std::shared_ptr<ngraph::Node> mask;
if (mask_rank_val == 1) {
// case when mask_index has shape (batch_size) or (2 * batch_size)
// so it contains positions that specify how mask should be generated
mask = attention_mask_from_indices(mask_index, type, batch_size, all_seq_len);
} else if (mask_rank_val < 4) {
mask = raw_mask(mask_index, mask_rank.get_length(), type);
} else {
NGRAPH_CHECK(false, "mask_index with rank " + std::to_string(mask_rank_val) + " is not supported");
}
// add the mask with unidirectional mask if available
if (attention_mask) {
attention_mask = std::make_shared<default_opset::Add>(attention_mask, mask);
} else {
attention_mask = mask;
}
}
return NodeTuple{attention_mask, bin_mask};
}
// Compute softmax(Q x K' / sqrt(head_size)) x V
std::shared_ptr<ngraph::Node> attention_softmax(const OutputVector& op_inputs,
const std::shared_ptr<ngraph::Node>& Q,
std::shared_ptr<ngraph::Node> K,
std::shared_ptr<ngraph::Node> V,
const std::shared_ptr<ngraph::Node>& attention_mask,
const std::shared_ptr<ngraph::Node>& bin_mask,
const std::shared_ptr<ngraph::Node>& head_size,
bool unidirectional) {
auto zero = default_opset::Constant::create(element::i64, Shape{}, {0});
if (is_past_input_available(op_inputs)) {
// concat past K and V with present ones
const auto& past = op_inputs[4];
// 'past' input has two matrices K and V with shape (1, batch_size, num_heads, past_sequence_length, head_size)
// concatenated along first axis to a single
// (2, batch_size, num_heads, past_sequence_length + sequence_length, head_size)
// so we need to split it into two parts, remove first dimension from each part and concatenate first part
// with current K and second part with current V
const auto split = ngraph::builder::opset1::split(past, 2, 0);
const auto past_K = std::make_shared<default_opset::Squeeze>(split[0], zero);
K = std::make_shared<default_opset::Concat>(NodeVector{past_K, K}, 2);
const auto past_V = std::make_shared<default_opset::Squeeze>(split[1], zero);
V = std::make_shared<default_opset::Concat>(NodeVector{past_V, V}, 2);
}
// perform Q x K'
std::shared_ptr<ngraph::Node> softmax_input = std::make_shared<default_opset::MatMul>(Q, K, false, true);
// Q x K' + mask
if (attention_mask) {
if (unidirectional) {
// Perform the equivalent of
// https://github.com/microsoft/onnxruntime/blob/851554536ca8185b3413ee57449ea5ac93370193/onnxruntime/contrib_ops/cpu/bert/attention_cpu_base.h#L158-L166
// For positions where unidirectional_mask has -10000 values - attention_mask is moved to softmax input
softmax_input = std::make_shared<default_opset::Multiply>(softmax_input, bin_mask);
}
softmax_input = std::make_shared<default_opset::Add>(softmax_input, attention_mask);
}
const auto sqrt = std::make_shared<default_opset::Sqrt>(head_size);
// (Q x K' + mask) / sqrt(head_size)
softmax_input = std::make_shared<default_opset::Divide>(softmax_input, sqrt);
// handle 'extra_add' input
if (op_inputs.size() > 5 && !ngraph::op::is_null(op_inputs[5])) {
NGRAPH_CHECK(!is_past_input_available(op_inputs),
"Cannot use both 'past' and 'extra_add' inputs in the same node");
const auto& extra_add = op_inputs[5];
softmax_input = std::make_shared<default_opset::Add>(softmax_input, extra_add);
}
// softmax((Q x K' + mask) / sqrt(head_size))
const auto softmax = std::make_shared<default_opset::Softmax>(softmax_input, 3);
// softmax((Q x K' + mask) / sqrt(head_size)) x V
std::shared_ptr<ngraph::Node> output = std::make_shared<default_opset::MatMul>(softmax, V);
// transpose the result from (batch_size, num_heads, sequence_length, head_size)
// to (batch_size, sequence_length, num_heads, head_size)
const auto perm = default_opset::Constant::create(element::i64, Shape{4}, {0, 2, 1, 3});
output = std::make_shared<default_opset::Transpose>(output, perm);
auto new_shape = default_opset::Constant::create(element::i32, Shape{3}, {0, 0, -1});
// reshape the result from (batch_size, sequence_length, num_heads, head_size) to (batch_size, sequence_length,
// num_heads * head_size)
output = std::make_shared<default_opset::Reshape>(output, new_shape, true);
return output;
}
// Make present state from K and V matrices by reshaping them from:
// (batch_size, num_heads, sequence_length, head_size) to (1, batch_size, num_heads, sequence_length, head_size)
// and concatenating them along first axis to make 'present' output.
// If fifth input ('past') is available, it gets concatenated with 'present' output along fourth axis.
std::shared_ptr<ngraph::Node> get_present_state(const std::shared_ptr<ngraph::Node>& K,
const std::shared_ptr<ngraph::Node>& V,
const OutputVector& op_inputs) {
auto zero = default_opset::Constant::create(element::i64, Shape{1}, {0});
// expand K shape (batch_size, num_heads, sequence_length, head_size) to
// (1, batch_size, num_heads, sequence_length, head_size)
auto K_unsqueezed = std::make_shared<default_opset::Unsqueeze>(K, zero);
// similarly expand V shape
auto V_unsqueezed = std::make_shared<default_opset::Unsqueeze>(V, zero);
// add padding in case K and V have different shapes (it happens when used provided uneven qkv_hidden_sizes)
// if the shapes are equal (so padding will be zero), Pad gets eliminated in NopElimination pass
const auto K_shape = std::make_shared<default_opset::ShapeOf>(K_unsqueezed);
const auto V_shape = std::make_shared<default_opset::ShapeOf>(V_unsqueezed);
const auto K_pads_end =
std::make_shared<default_opset::Maximum>(std::make_shared<default_opset::Subtract>(V_shape, K_shape), zero);
const auto V_pads_end =
std::make_shared<default_opset::Maximum>(std::make_shared<default_opset::Subtract>(K_shape, V_shape), zero);
const auto pads_begin =
std::make_shared<default_opset::Broadcast>(zero, std::make_shared<default_opset::ShapeOf>(K_shape));
const auto K_padded =
std::make_shared<default_opset::Pad>(K_unsqueezed, pads_begin, K_pads_end, ngraph::op::PadMode::CONSTANT);
const auto V_padded =
std::make_shared<default_opset::Pad>(V_unsqueezed, pads_begin, V_pads_end, ngraph::op::PadMode::CONSTANT);
// concat key and value tensors along first axis to make 'present' state
// after that operation, 'present' has shape (2, batch_size, num_heads, sequence_length, head_size)
std::shared_ptr<ngraph::Node> present = std::make_shared<default_opset::Concat>(NodeVector{K_padded, V_padded}, 0);
if (is_past_input_available(op_inputs)) {
const auto& past = op_inputs[4];
// concat 'past' to 'present' output along fourth axis
// after that operation, 'present' has shape:
// (2, batch_size, num_heads, past_sequence_length + sequence_length, head_size)
present = std::make_shared<default_opset::Concat>(OutputVector{past, present}, 3);
}
return present;
}
} // namespace
} // namespace detail
} // namespace op
} // namespace onnx_import
} // namespace ngraph
| 56.275046 | 165 | 0.647419 | [
"shape",
"vector",
"transform"
] |
0bc1f8c1b5daa3537a1ec63eec3230cdeda4a686 | 7,198 | cpp | C++ | sources/model/AssembleOptions.cpp | groupdocs-assembly-cloud/assembly-cpp-sdk | a6c6049d745a0203cbe3812d66b81f9952758349 | [
"MIT"
] | null | null | null | sources/model/AssembleOptions.cpp | groupdocs-assembly-cloud/assembly-cpp-sdk | a6c6049d745a0203cbe3812d66b81f9952758349 | [
"MIT"
] | null | null | null | sources/model/AssembleOptions.cpp | groupdocs-assembly-cloud/assembly-cpp-sdk | a6c6049d745a0203cbe3812d66b81f9952758349 | [
"MIT"
] | null | null | null | /** --------------------------------------------------------------------------------------------------------------------
* <copyright company="Aspose" file="AssembleOptions.cpp">
* Copyright (c) 2021 GroupDocs.Assembly for Cloud
* </copyright>
* <summary>
* 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.
* </summary>
-------------------------------------------------------------------------------------------------------------------- **/
#include "AssembleOptions.h"
namespace groupdocs {
namespace assembly {
namespace cloud {
namespace api {
namespace models {
AssembleOptions::AssembleOptions()
{
m_TemplateFileInfoIsSet = false;
m_SaveFormat = utility::conversions::to_string_t("");
m_SaveFormatIsSet = false;
m_ReportData = utility::conversions::to_string_t("");
m_ReportDataIsSet = false;
m_OutputPath = utility::conversions::to_string_t("");
m_OutputPathIsSet = false;
}
AssembleOptions::~AssembleOptions()
{
}
void AssembleOptions::validate()
{
// TODO: implement validation
}
web::json::value AssembleOptions::toJson() const
{
web::json::value val = web::json::value::object();
if(m_TemplateFileInfoIsSet)
{
val[_XPLATSTR("TemplateFileInfo")] = ModelBase::toJson(m_TemplateFileInfo);
}
if(m_SaveFormatIsSet)
{
val[_XPLATSTR("SaveFormat")] = ModelBase::toJson(m_SaveFormat);
}
if(m_ReportDataIsSet)
{
val[_XPLATSTR("ReportData")] = ModelBase::toJson(m_ReportData);
}
if(m_OutputPathIsSet)
{
val[_XPLATSTR("OutputPath")] = ModelBase::toJson(m_OutputPath);
}
return val;
}
void AssembleOptions::fromJson(web::json::value& val)
{
if(val.has_field(_XPLATSTR("TemplateFileInfo")))
{
web::json::value& fieldValue = val[_XPLATSTR("TemplateFileInfo")];
if(!fieldValue.is_null())
{
std::shared_ptr<TemplateFileInfo> newItem(new TemplateFileInfo());
newItem->fromJson(fieldValue);
setTemplateFileInfo( newItem );
}
}
if(val.has_field(_XPLATSTR("SaveFormat")))
{
web::json::value& fieldValue = val[_XPLATSTR("SaveFormat")];
if(!fieldValue.is_null())
{
setSaveFormat(ModelBase::stringFromJson(fieldValue));
}
}
if(val.has_field(_XPLATSTR("ReportData")))
{
web::json::value& fieldValue = val[_XPLATSTR("ReportData")];
if(!fieldValue.is_null())
{
setReportData(ModelBase::stringFromJson(fieldValue));
}
}
if(val.has_field(_XPLATSTR("OutputPath")))
{
web::json::value& fieldValue = val[_XPLATSTR("OutputPath")];
if(!fieldValue.is_null())
{
setOutputPath(ModelBase::stringFromJson(fieldValue));
}
}
}
void AssembleOptions::toMultipart(const std::shared_ptr<MultipartFormData>& multipart, const utility::string_t& prefix) const
{
auto namePrefix = ModelBase::fixNamePrefix(prefix);
if(m_TemplateFileInfoIsSet)
{
if (m_TemplateFileInfo.get())
{
m_TemplateFileInfo->toMultipart(multipart, _XPLATSTR("TemplateFileInfo."));
}
}
if(m_SaveFormatIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + _XPLATSTR("SaveFormat"), m_SaveFormat));
}
if(m_ReportDataIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + _XPLATSTR("ReportData"), m_ReportData));
}
if(m_OutputPathIsSet)
{
multipart->add(ModelBase::toHttpContent(namePrefix + _XPLATSTR("OutputPath"), m_OutputPath));
}
}
void AssembleOptions::fromMultiPart(const std::shared_ptr<MultipartFormData>& multipart, const utility::string_t& prefix)
{
if(multipart->hasContent(_XPLATSTR("TemplateFileInfo")))
{
if(multipart->hasContent(_XPLATSTR("TemplateFileInfo")))
{
std::shared_ptr<TemplateFileInfo> newItem(new TemplateFileInfo());
newItem->fromMultiPart(multipart, _XPLATSTR("TemplateFileInfo."));
setTemplateFileInfo( newItem );
}
}
if(multipart->hasContent(_XPLATSTR("SaveFormat")))
{
setSaveFormat(ModelBase::stringFromHttpContent(multipart->getContent(_XPLATSTR("SaveFormat"))));
}
if(multipart->hasContent(_XPLATSTR("ReportData")))
{
setReportData(ModelBase::stringFromHttpContent(multipart->getContent(_XPLATSTR("ReportData"))));
}
if(multipart->hasContent(_XPLATSTR("OutputPath")))
{
setOutputPath(ModelBase::stringFromHttpContent(multipart->getContent(_XPLATSTR("OutputPath"))));
}
}
std::shared_ptr<TemplateFileInfo> AssembleOptions::getTemplateFileInfo() const
{
return m_TemplateFileInfo;
}
void AssembleOptions::setTemplateFileInfo(std::shared_ptr<TemplateFileInfo> value)
{
m_TemplateFileInfo = value;
m_TemplateFileInfoIsSet = true;
}
bool AssembleOptions::templateFileInfoIsSet() const
{
return m_TemplateFileInfoIsSet;
}
void AssembleOptions::unsetTemplateFileInfo()
{
m_TemplateFileInfoIsSet = false;
}
utility::string_t AssembleOptions::getSaveFormat() const
{
return m_SaveFormat;
}
void AssembleOptions::setSaveFormat(utility::string_t value)
{
m_SaveFormat = value;
m_SaveFormatIsSet = true;
}
bool AssembleOptions::saveFormatIsSet() const
{
return m_SaveFormatIsSet;
}
void AssembleOptions::unsetSaveFormat()
{
m_SaveFormatIsSet = false;
}
utility::string_t AssembleOptions::getReportData() const
{
return m_ReportData;
}
void AssembleOptions::setReportData(utility::string_t value)
{
m_ReportData = value;
m_ReportDataIsSet = true;
}
bool AssembleOptions::reportDataIsSet() const
{
return m_ReportDataIsSet;
}
void AssembleOptions::unsetReportData()
{
m_ReportDataIsSet = false;
}
utility::string_t AssembleOptions::getOutputPath() const
{
return m_OutputPath;
}
void AssembleOptions::setOutputPath(utility::string_t value)
{
m_OutputPath = value;
m_OutputPathIsSet = true;
}
bool AssembleOptions::outputPathIsSet() const
{
return m_OutputPathIsSet;
}
void AssembleOptions::unsetOutputPath()
{
m_OutputPathIsSet = false;
}
}
}
}
}
}
| 27.578544 | 125 | 0.66963 | [
"object"
] |
0bc801dce45fd5e34d21c18e53c18d158ae915d1 | 476,893 | cpp | C++ | solvers/WAM7_arm.cpp | Stonelinks/js-iksolvers | e911d6e24b6e4a4f2c61753a1a0d1721f8560ff2 | [
"MIT"
] | null | null | null | solvers/WAM7_arm.cpp | Stonelinks/js-iksolvers | e911d6e24b6e4a4f2c61753a1a0d1721f8560ff2 | [
"MIT"
] | null | null | null | solvers/WAM7_arm.cpp | Stonelinks/js-iksolvers | e911d6e24b6e4a4f2c61753a1a0d1721f8560ff2 | [
"MIT"
] | 1 | 2020-09-21T13:02:41.000Z | 2020-09-21T13:02:41.000Z | /// autogenerated analytical inverse kinematics code from ikfast program part of OpenRAVE
/// \author Rosen Diankov
///
/// 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.
///
/// ikfast version 0x10000048 generated on 2015-05-22 07:20:15.541882
/// To compile with gcc:
/// gcc -lstdc++ ik.cpp
/// To compile without any main function as a shared object (might need -llapack):
/// gcc -fPIC -lstdc++ -DIKFAST_NO_MAIN -DIKFAST_CLIBRARY -shared -Wl,-soname,libik.so -o libik.so ik.cpp
#define IKFAST_HAS_LIBRARY
#include "ikfast.h" // found inside share/openrave-X.Y/python/ikfast.h
using namespace ikfast;
// check if the included ikfast version matches what this file was compiled with
#define IKFAST_COMPILE_ASSERT(x) extern int __dummy[(int)x]
IKFAST_COMPILE_ASSERT(IKFAST_VERSION==0x10000048);
#include <cmath>
#include <vector>
#include <limits>
#include <algorithm>
#include <complex>
#ifndef IKFAST_ASSERT
#include <stdexcept>
#include <sstream>
#include <iostream>
#ifdef _MSC_VER
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __FUNCDNAME__
#endif
#endif
#ifndef __PRETTY_FUNCTION__
#define __PRETTY_FUNCTION__ __func__
#endif
#define IKFAST_ASSERT(b) { if( !(b) ) { std::stringstream ss; ss << "ikfast exception: " << __FILE__ << ":" << __LINE__ << ": " <<__PRETTY_FUNCTION__ << ": Assertion '" << #b << "' failed"; throw std::runtime_error(ss.str()); } }
#endif
#if defined(_MSC_VER)
#define IKFAST_ALIGNED16(x) __declspec(align(16)) x
#else
#define IKFAST_ALIGNED16(x) x __attribute((aligned(16)))
#endif
#define IK2PI ((IkReal)6.28318530717959)
#define IKPI ((IkReal)3.14159265358979)
#define IKPI_2 ((IkReal)1.57079632679490)
#ifdef _MSC_VER
#ifndef isnan
#define isnan _isnan
#endif
#ifndef isinf
#define isinf _isinf
#endif
//#ifndef isfinite
//#define isfinite _isfinite
//#endif
#endif // _MSC_VER
// lapack routines
extern "C" {
void dgetrf_ (const int* m, const int* n, double* a, const int* lda, int* ipiv, int* info);
void zgetrf_ (const int* m, const int* n, std::complex<double>* a, const int* lda, int* ipiv, int* info);
void dgetri_(const int* n, const double* a, const int* lda, int* ipiv, double* work, const int* lwork, int* info);
void dgesv_ (const int* n, const int* nrhs, double* a, const int* lda, int* ipiv, double* b, const int* ldb, int* info);
void dgetrs_(const char *trans, const int *n, const int *nrhs, double *a, const int *lda, int *ipiv, double *b, const int *ldb, int *info);
void dgeev_(const char *jobvl, const char *jobvr, const int *n, double *a, const int *lda, double *wr, double *wi,double *vl, const int *ldvl, double *vr, const int *ldvr, double *work, const int *lwork, int *info);
}
using namespace std; // necessary to get std math routines
#ifdef IKFAST_NAMESPACE
namespace IKFAST_NAMESPACE {
#endif
inline float IKabs(float f) { return fabsf(f); }
inline double IKabs(double f) { return fabs(f); }
inline float IKsqr(float f) { return f*f; }
inline double IKsqr(double f) { return f*f; }
inline float IKlog(float f) { return logf(f); }
inline double IKlog(double f) { return log(f); }
// allows asin and acos to exceed 1
#ifndef IKFAST_SINCOS_THRESH
#define IKFAST_SINCOS_THRESH ((IkReal)2e-6)
#endif
// used to check input to atan2 for degenerate cases
#ifndef IKFAST_ATAN2_MAGTHRESH
#define IKFAST_ATAN2_MAGTHRESH ((IkReal)2e-6)
#endif
// minimum distance of separate solutions
#ifndef IKFAST_SOLUTION_THRESH
#define IKFAST_SOLUTION_THRESH ((IkReal)1e-6)
#endif
// there are checkpoints in ikfast that are evaluated to make sure they are 0. This threshold speicfies by how much they can deviate
#ifndef IKFAST_EVALCOND_THRESH
#define IKFAST_EVALCOND_THRESH ((IkReal)0.000005)
#endif
inline float IKasin(float f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return float(-IKPI_2);
else if( f >= 1 ) return float(IKPI_2);
return asinf(f);
}
inline double IKasin(double f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return -IKPI_2;
else if( f >= 1 ) return IKPI_2;
return asin(f);
}
// return positive value in [0,y)
inline float IKfmod(float x, float y)
{
while(x < 0) {
x += y;
}
return fmodf(x,y);
}
// return positive value in [0,y)
inline double IKfmod(double x, double y)
{
while(x < 0) {
x += y;
}
return fmod(x,y);
}
inline float IKacos(float f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return float(IKPI);
else if( f >= 1 ) return float(0);
return acosf(f);
}
inline double IKacos(double f)
{
IKFAST_ASSERT( f > -1-IKFAST_SINCOS_THRESH && f < 1+IKFAST_SINCOS_THRESH ); // any more error implies something is wrong with the solver
if( f <= -1 ) return IKPI;
else if( f >= 1 ) return 0;
return acos(f);
}
inline float IKsin(float f) { return sinf(f); }
inline double IKsin(double f) { return sin(f); }
inline float IKcos(float f) { return cosf(f); }
inline double IKcos(double f) { return cos(f); }
inline float IKtan(float f) { return tanf(f); }
inline double IKtan(double f) { return tan(f); }
inline float IKsqrt(float f) { if( f <= 0.0f ) return 0.0f; return sqrtf(f); }
inline double IKsqrt(double f) { if( f <= 0.0 ) return 0.0; return sqrt(f); }
inline float IKatan2Simple(float fy, float fx) {
return atan2f(fy,fx);
}
inline float IKatan2(float fy, float fx) {
if( isnan(fy) ) {
IKFAST_ASSERT(!isnan(fx)); // if both are nan, probably wrong value will be returned
return float(IKPI_2);
}
else if( isnan(fx) ) {
return 0;
}
return atan2f(fy,fx);
}
inline double IKatan2Simple(double fy, double fx) {
return atan2(fy,fx);
}
inline double IKatan2(double fy, double fx) {
if( isnan(fy) ) {
IKFAST_ASSERT(!isnan(fx)); // if both are nan, probably wrong value will be returned
return IKPI_2;
}
else if( isnan(fx) ) {
return 0;
}
return atan2(fy,fx);
}
template <typename T>
struct CheckValue
{
T value;
bool valid;
};
template <typename T>
inline CheckValue<T> IKatan2WithCheck(T fy, T fx, T epsilon)
{
CheckValue<T> ret;
ret.valid = false;
ret.value = 0;
if( !isnan(fy) && !isnan(fx) ) {
if( IKabs(fy) >= IKFAST_ATAN2_MAGTHRESH || IKabs(fx) > IKFAST_ATAN2_MAGTHRESH ) {
ret.value = IKatan2Simple(fy,fx);
ret.valid = true;
}
}
return ret;
}
inline float IKsign(float f) {
if( f > 0 ) {
return float(1);
}
else if( f < 0 ) {
return float(-1);
}
return 0;
}
inline double IKsign(double f) {
if( f > 0 ) {
return 1.0;
}
else if( f < 0 ) {
return -1.0;
}
return 0;
}
template <typename T>
inline CheckValue<T> IKPowWithIntegerCheck(T f, int n)
{
CheckValue<T> ret;
ret.valid = true;
if( n == 0 ) {
ret.value = 1.0;
return ret;
}
else if( n == 1 )
{
ret.value = f;
return ret;
}
else if( n < 0 )
{
if( f == 0 )
{
ret.valid = false;
ret.value = (T)1.0e30;
return ret;
}
if( n == -1 ) {
ret.value = T(1.0)/f;
return ret;
}
}
int num = n > 0 ? n : -n;
if( num == 2 ) {
ret.value = f*f;
}
else if( num == 3 ) {
ret.value = f*f*f;
}
else {
ret.value = 1.0;
while(num>0) {
if( num & 1 ) {
ret.value *= f;
}
num >>= 1;
f *= f;
}
}
if( n < 0 ) {
ret.value = T(1.0)/ret.value;
}
return ret;
}
/// solves the forward kinematics equations.
/// \param pfree is an array specifying the free joints of the chain.
IKFAST_API void ComputeFk(const IkReal* j, IkReal* eetrans, IkReal* eerot) {
IkReal x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15,x16,x17,x18,x19,x20,x21,x22,x23,x24,x25,x26,x27,x28,x29,x30,x31,x32,x33,x34,x35,x36,x37,x38,x39,x40,x41,x42,x43,x44,x45,x46,x47,x48,x49,x50,x51,x52,x53,x54,x55,x56,x57,x58,x59,x60,x61,x62,x63,x64,x65,x66,x67,x68,x69,x70,x71,x72,x73;
x0=IKcos(j[0]);
x1=IKcos(j[1]);
x2=IKcos(j[2]);
x3=IKsin(j[0]);
x4=IKsin(j[2]);
x5=IKsin(j[3]);
x6=IKcos(j[3]);
x7=IKsin(j[1]);
x8=IKcos(j[4]);
x9=IKsin(j[4]);
x10=IKsin(j[6]);
x11=IKsin(j[5]);
x12=IKcos(j[5]);
x13=IKcos(j[6]);
x14=((0.06)*x5);
x15=((0.045)*x1);
x16=((1.0)*x5);
x17=((0.06)*x9);
x18=((0.3)*x1);
x19=((0.06)*x6);
x20=((1.0)*x11);
x21=((0.045)*x5);
x22=((1.0)*x1);
x23=((1.0)*x12);
x24=((0.06)*x8);
x25=((1.0)*x6);
x26=(x0*x4);
x27=(x0*x2);
x28=(x2*x7);
x29=(x3*x4);
x30=(x0*x7);
x31=(x2*x3);
x32=(x3*x7);
x33=((1.0)*x29);
x34=((0.045)*x29);
x35=((0.045)*x26);
x36=(x22*x6);
x37=(x32*x6);
x38=(x4*x7*x9);
x39=(x16*x30);
x40=(x25*x30);
x41=(x15*x27);
x42=(x16*x32);
x43=(x25*x32);
x44=(x15*x31);
x45=((((-1.0)*x33))+((x1*x27)));
x46=(x26+((x1*x31)));
x47=(x27+(((-1.0)*x22*x29)));
x48=((((-1.0)*x36))+((x28*x5)));
x49=(x33+(((-1.0)*x22*x27)));
x50=((((-1.0)*x31))+(((-1.0)*x22*x26)));
x51=((((-1.0)*x26))+(((-1.0)*x22*x31)));
x52=(((x1*x16))+((x25*x28)));
x53=((-1.0)*x52);
x54=(x35+x44);
x55=(x46*x6);
x56=(x11*x48);
x57=(x45*x6);
x58=(x5*x51);
x59=(x50*x9);
x60=(x53*x8);
x61=((((-1.0)*x39))+x57);
x62=((((-1.0)*x42))+x55);
x63=((((-1.0)*x40))+((x49*x5)));
x64=((((-1.0)*x43))+x58);
x65=(((x4*x7*x8))+((x52*x9)));
x66=(x38+x60);
x67=(x61*x8);
x68=(x11*x64);
x69=(((x47*x9))+((x62*x8)));
x70=(((x47*x8))+((x9*(((((-1.0)*x25*x46))+x42)))));
x71=(x59+x67);
x72=(x12*x69);
x73=(((x50*x8))+((x9*((x39+(((-1.0)*x57)))))));
eerot[0]=(((x10*x73))+((x13*((((x11*x63))+((x12*x71)))))));
eerot[1]=(((x10*(((((-1.0)*x20*x63))+(((-1.0)*x23*x71))))))+((x13*x73)));
eerot[2]=(((x12*(((((-1.0)*x16*x49))+x40))))+((x11*x71)));
eetrans[0]=((0.22)+(((-1.0)*x34))+((x12*((((x19*x30))+(((-1.0)*x14*x49))))))+((x11*((((x17*x50))+((x24*x61))))))+((x21*x30))+(((0.3)*x30*x6))+(((0.55)*x30))+x41+((x5*((((x18*x27))+(((-0.3)*x29))))))+((x6*(((((-1.0)*x41))+x34)))));
eerot[3]=(((x10*x70))+((x13*((x72+x68)))));
eerot[4]=(((x10*(((((-1.0)*x20*x64))+(((-1.0)*x23*x69))))))+((x13*x70)));
eerot[5]=(((x11*x69))+((x12*((x43+(((-1.0)*x16*x51)))))));
eetrans[1]=((0.14)+((x5*((((x18*x31))+(((0.3)*x26))))))+(((-1.0)*x54*x6))+((x21*x32))+(((0.55)*x32))+x54+((x12*((((x19*x32))+(((-1.0)*x14*x51))))))+((x11*((((x17*x47))+((x24*x62))))))+(((0.3)*x37)));
eerot[6]=(((x13*((((x12*x66))+x56))))+((x10*x65)));
eerot[7]=(((x13*x65))+((x10*(((((-1.0)*x20*x48))+(((-1.0)*x23*x66)))))));
eerot[8]=(((x11*x66))+((x12*(((((-1.0)*x16*x28))+x36)))));
IkReal x74=((0.045)*x28);
eetrans[2]=((0.346)+((x18*x6))+((x11*((((x24*x53))+((x17*x4*x7))))))+(((-0.3)*x28*x5))+(((-1.0)*x74))+((x12*((((x1*x19))+(((-1.0)*x14*x28))))))+((x6*x74))+(((0.55)*x1))+((x15*x5)));
}
IKFAST_API int GetNumFreeParameters() { return 1; }
IKFAST_API int* GetFreeParameters() { static int freeparams[] = {2}; return freeparams; }
IKFAST_API int GetNumJoints() { return 7; }
IKFAST_API int GetIkRealSize() { return sizeof(IkReal); }
IKFAST_API int GetIkType() { return 0x67000001; }
class IKSolver {
public:
IkReal j0,cj0,sj0,htj0,j0mul,j1,cj1,sj1,htj1,j1mul,j3,cj3,sj3,htj3,j3mul,j4,cj4,sj4,htj4,j4mul,j5,cj5,sj5,htj5,j5mul,j6,cj6,sj6,htj6,j6mul,j2,cj2,sj2,htj2,new_r00,r00,rxp0_0,new_r01,r01,rxp0_1,new_r02,r02,rxp0_2,new_r10,r10,rxp1_0,new_r11,r11,rxp1_1,new_r12,r12,rxp1_2,new_r20,r20,rxp2_0,new_r21,r21,rxp2_1,new_r22,r22,rxp2_2,new_px,px,npx,new_py,py,npy,new_pz,pz,npz,pp;
unsigned char _ij0[2], _nj0,_ij1[2], _nj1,_ij3[2], _nj3,_ij4[2], _nj4,_ij5[2], _nj5,_ij6[2], _nj6,_ij2[2], _nj2;
IkReal j100, cj100, sj100;
unsigned char _ij100[2], _nj100;
bool ComputeIk(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, IkSolutionListBase<IkReal>& solutions) {
j0=numeric_limits<IkReal>::quiet_NaN(); _ij0[0] = -1; _ij0[1] = -1; _nj0 = -1; j1=numeric_limits<IkReal>::quiet_NaN(); _ij1[0] = -1; _ij1[1] = -1; _nj1 = -1; j3=numeric_limits<IkReal>::quiet_NaN(); _ij3[0] = -1; _ij3[1] = -1; _nj3 = -1; j4=numeric_limits<IkReal>::quiet_NaN(); _ij4[0] = -1; _ij4[1] = -1; _nj4 = -1; j5=numeric_limits<IkReal>::quiet_NaN(); _ij5[0] = -1; _ij5[1] = -1; _nj5 = -1; j6=numeric_limits<IkReal>::quiet_NaN(); _ij6[0] = -1; _ij6[1] = -1; _nj6 = -1; _ij2[0] = -1; _ij2[1] = -1; _nj2 = 0;
for(int dummyiter = 0; dummyiter < 1; ++dummyiter) {
solutions.Clear();
j2=pfree[0]; cj2=cos(pfree[0]); sj2=sin(pfree[0]), htj2=tan(pfree[0]*0.5);
r00 = eerot[0*3+0];
r01 = eerot[0*3+1];
r02 = eerot[0*3+2];
r10 = eerot[1*3+0];
r11 = eerot[1*3+1];
r12 = eerot[1*3+2];
r20 = eerot[2*3+0];
r21 = eerot[2*3+1];
r22 = eerot[2*3+2];
px = eetrans[0]; py = eetrans[1]; pz = eetrans[2];
new_r00=r00;
new_r01=r01;
new_r02=r02;
new_px=((-0.22)+(((-0.06)*r02))+px);
new_r10=r10;
new_r11=r11;
new_r12=r12;
new_py=((-0.14)+py+(((-0.06)*r12)));
new_r20=r20;
new_r21=r21;
new_r22=r22;
new_pz=((-0.346)+(((-0.06)*r22))+pz);
r00 = new_r00; r01 = new_r01; r02 = new_r02; r10 = new_r10; r11 = new_r11; r12 = new_r12; r20 = new_r20; r21 = new_r21; r22 = new_r22; px = new_px; py = new_py; pz = new_pz;
IkReal x75=((1.0)*px);
IkReal x76=((1.0)*pz);
IkReal x77=((1.0)*py);
pp=((px*px)+(py*py)+(pz*pz));
npx=(((px*r00))+((py*r10))+((pz*r20)));
npy=(((px*r01))+((py*r11))+((pz*r21)));
npz=(((px*r02))+((py*r12))+((pz*r22)));
rxp0_0=((((-1.0)*r20*x77))+((pz*r10)));
rxp0_1=(((px*r20))+(((-1.0)*r00*x76)));
rxp0_2=((((-1.0)*r10*x75))+((py*r00)));
rxp1_0=((((-1.0)*r21*x77))+((pz*r11)));
rxp1_1=(((px*r21))+(((-1.0)*r01*x76)));
rxp1_2=(((py*r01))+(((-1.0)*r11*x75)));
rxp2_0=((((-1.0)*r22*x77))+((pz*r12)));
rxp2_1=(((px*r22))+(((-1.0)*r02*x76)));
rxp2_2=(((py*r02))+(((-1.0)*r12*x75)));
{
IkReal j3array[2], cj3array[2], sj3array[2];
bool j3valid[2]={false};
_nj3 = 2;
if( (((1.18441410190393)+(((-2.9867963734811)*pp)))) < -1-IKFAST_SINCOS_THRESH || (((1.18441410190393)+(((-2.9867963734811)*pp)))) > 1+IKFAST_SINCOS_THRESH )
continue;
IkReal x78=IKasin(((1.18441410190393)+(((-2.9867963734811)*pp))));
j3array[0]=((-1.34027003705633)+(((-1.0)*x78)));
sj3array[0]=IKsin(j3array[0]);
cj3array[0]=IKcos(j3array[0]);
j3array[1]=((1.80132261653346)+x78);
sj3array[1]=IKsin(j3array[1]);
cj3array[1]=IKcos(j3array[1]);
if( j3array[0] > IKPI )
{
j3array[0]-=IK2PI;
}
else if( j3array[0] < -IKPI )
{ j3array[0]+=IK2PI;
}
j3valid[0] = true;
if( j3array[1] > IKPI )
{
j3array[1]-=IK2PI;
}
else if( j3array[1] < -IKPI )
{ j3array[1]+=IK2PI;
}
j3valid[1] = true;
for(int ij3 = 0; ij3 < 2; ++ij3)
{
if( !j3valid[ij3] )
{
continue;
}
_ij3[0] = ij3; _ij3[1] = -1;
for(int iij3 = ij3+1; iij3 < 2; ++iij3)
{
if( j3valid[iij3] && IKabs(cj3array[ij3]-cj3array[iij3]) < IKFAST_SOLUTION_THRESH && IKabs(sj3array[ij3]-sj3array[iij3]) < IKFAST_SOLUTION_THRESH )
{
j3valid[iij3]=false; _ij3[1] = iij3; break;
}
}
j3 = j3array[ij3]; cj3 = cj3array[ij3]; sj3 = sj3array[ij3];
{
IkReal j0eval[2];
j0eval[0]=((px*px)+(py*py));
j0eval[1]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
IkReal x79=cj2*cj2;
IkReal x80=sj3*sj3;
IkReal x81=cj3*cj3;
IkReal x82=((3.0)*cj2);
IkReal x83=((13.3333333333333)*cj3*sj3);
j1eval[0]=((IKabs(((((20.0)*cj2*sj3))+x82+(((-1.0)*cj3*x82)))))+(((66.6666666666667)*(IKabs(((-0.55)+(((-0.045)*sj3))+(((-0.3)*cj3))))))));
j1eval[1]=((149.382716049383)+((x79*x81))+(((24.4444444444444)*sj3))+(((13.3333333333333)*sj3*x79))+(((-1.0)*x79*x83))+(((-2.0)*cj3*x79))+(((44.4444444444444)*x79*x80))+x79+x83+x80+(((44.4444444444444)*x81))+(((162.962962962963)*cj3)));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
IkReal x84=cj2*cj2;
IkReal x85=sj2*sj2;
IkReal x86=px*px;
IkReal x87=py*py;
IkReal x88=py*py*py*py;
IkReal x89=sj2*sj2*sj2*sj2;
IkReal x90=cj2*cj2*cj2*cj2;
IkReal x91=((1.0)*px*py);
IkReal x92=(x86*x87);
IkReal x93=((2.0)*x84*x85);
j0eval[0]=(((x89*x92))+((x92*x93))+((x90*x92))+((x88*x93))+((x88*x90))+((x88*x89)));
j0eval[1]=((IKabs((((x84*x87))+((x85*x87)))))+(IKabs(((((-1.0)*x84*x91))+(((-1.0)*x85*x91))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
continue; // no branches [j0, j1]
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
IkReal x94=cj2*cj2;
IkReal x95=py*py;
IkReal x96=sj2*sj2;
IkReal x97=((0.045)*py*sj2);
IkReal x98=((1.0)*px*py);
IkReal x99=(((x95*x96))+((x94*x95)));
IkReal x100=((((-1.0)*x94*x98))+(((-1.0)*x96*x98)));
CheckValue<IkReal> x103 = IKatan2WithCheck(IkReal(x99),x100,IKFAST_ATAN2_MAGTHRESH);
if(!x103.valid){
continue;
}
IkReal x101=((1.0)*(x103.value));
if((((x99*x99)+(x100*x100))) < -0.00001)
continue;
CheckValue<IkReal> x104=IKPowWithIntegerCheck(IKabs(IKsqrt(((x99*x99)+(x100*x100)))),-1);
if(!x104.valid){
continue;
}
if( (((x104.value)*(((((-0.3)*py*sj2*sj3))+((cj3*x97))+(((-1.0)*x97)))))) < -1-IKFAST_SINCOS_THRESH || (((x104.value)*(((((-0.3)*py*sj2*sj3))+((cj3*x97))+(((-1.0)*x97)))))) > 1+IKFAST_SINCOS_THRESH )
continue;
IkReal x102=IKasin(((x104.value)*(((((-0.3)*py*sj2*sj3))+((cj3*x97))+(((-1.0)*x97))))));
j0array[0]=((((-1.0)*x101))+(((-1.0)*x102)));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x101))+x102);
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x105=sj2*sj2;
IkReal x106=cj2*cj2;
IkReal x107=px*px;
IkReal x108=IKsin(j0);
IkReal x109=IKcos(j0);
IkReal x110=(px*py);
IkReal x111=((0.045)*sj2);
IkReal x112=((1.0)*x107);
IkReal x113=((0.3)*sj2*sj3);
evalcond[0]=(((x108*(((((-1.0)*x106*x112))+(((-1.0)*x105*x112))))))+(((-1.0)*px*x113))+(((-1.0)*px*x111))+((x109*((((x106*x110))+((x105*x110))))))+((cj3*px*x111)));
evalcond[1]=((((-1.0)*cj3*x111))+x113+x111+((px*x108))+(((-1.0)*py*x109)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j1eval[2];
IkReal x114=(py*sj0);
IkReal x115=((0.3)*cj3);
IkReal x116=((0.045)*sj3);
IkReal x117=(cj2*pz);
IkReal x118=((6.66666666666667)*cj3);
IkReal x119=(cj0*px);
IkReal x120=((1.0)*sj3);
j1eval[0]=((((-1.0)*x119*x120))+((cj3*x117))+(((-1.0)*x118*x119))+(((-6.66666666666667)*sj3*x117))+(((-12.2222222222222)*x119))+(((-12.2222222222222)*x114))+(((-1.0)*x114*x118))+(((-1.0)*x114*x120))+(((-1.0)*x117)));
j1eval[1]=IKsign(((((-0.55)*x119))+(((-0.55)*x114))+(((-1.0)*x116*x119))+(((-1.0)*x115*x119))+(((-1.0)*x114*x116))+(((-1.0)*x114*x115))+(((-0.3)*sj3*x117))+(((0.045)*cj3*x117))+(((-0.045)*x117))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
IkReal x121=cj0*cj0;
IkReal x122=py*py;
IkReal x123=(sj2*x121);
IkReal x124=(((x123*(px*px)))+((sj2*x122))+(((-1.0)*x122*x123))+((sj2*(pz*pz)))+(((2.0)*cj0*px*py*sj0*sj2)));
j1eval[0]=x124;
j1eval[1]=IKsign(x124);
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
IkReal x125=(pz*sj2);
IkReal x126=(py*sj0);
IkReal x127=(cj0*px);
IkReal x128=(cj2*sj2);
IkReal x129=((1.0)*cj3);
IkReal x130=((0.045)*x128);
IkReal x131=(sj3*x128);
IkReal x132=(x126*x131);
j1eval[0]=((((-12.2222222222222)*x125))+(((6.66666666666667)*x132))+(((-6.66666666666667)*cj3*x125))+(((-1.0)*x126*x128*x129))+(((6.66666666666667)*x127*x131))+(((-1.0)*x127*x128*x129))+((x126*x128))+(((-1.0)*sj3*x125))+((x127*x128)));
j1eval[1]=IKsign((((x127*x130))+(((-0.55)*x125))+(((-1.0)*cj3*x126*x130))+(((-0.3)*cj3*x125))+(((0.3)*x132))+(((-1.0)*cj3*x127*x130))+((x126*x130))+(((0.3)*x127*x131))+(((-0.045)*sj3*x125))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
IkReal x133=(((px*sj0))+(((-1.0)*cj0*py)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j2))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=x133;
evalcond[3]=x133;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[2];
sj2=0;
cj2=1.0;
j2=0;
IkReal x134=(cj0*px);
IkReal x135=((0.310561435803037)*sj3);
IkReal x136=(pp*pz);
IkReal x137=(py*sj0);
IkReal x138=((0.138057984353428)*pp);
IkReal x139=((12.2222222222222)*sj3);
IkReal x140=((5.4333061668025)*pp);
IkReal x141=(pz*sj3);
j1eval[0]=((((7.28153581454315)*pz))+(((-1.0)*x134*x139))+((x137*x140))+(((-1.0)*x137*x139))+(((-1.0)*x141))+(((36.2220411120167)*x136))+((x134*x140))+(((-3.92556370551481)*x134))+(((-3.92556370551481)*x137)));
j1eval[1]=IKsign(((((-1.0)*x135*x137))+(((-1.0)*x134*x135))+((x137*x138))+(((0.185020708697653)*pz))+((x134*x138))+(((-0.099746893695352)*x137))+(((-0.099746893695352)*x134))+(((-0.0254095720202485)*x141))+(((0.92038656235619)*x136))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
sj2=0;
cj2=1.0;
j2=0;
IkReal x142=(cj0*px);
IkReal x143=(py*sj0);
IkReal x144=((0.3)*sj3);
IkReal x145=((0.045)*cj3);
IkReal x146=(pz*sj3);
IkReal x147=((6.66666666666667)*sj3);
IkReal x148=((1.0)*cj3);
IkReal x149=(cj3*pz);
j1eval[0]=(((x142*x147))+(((-1.0)*x143*x148))+(((-1.0)*x142*x148))+(((-6.66666666666667)*x149))+x142+x143+(((-1.0)*x146))+(((-12.2222222222222)*pz))+((x143*x147)));
j1eval[1]=IKsign(((((-0.55)*pz))+(((-0.3)*x149))+((x142*x144))+(((-1.0)*x143*x145))+(((-1.0)*x142*x145))+(((-0.045)*x146))+(((0.045)*x143))+(((0.045)*x142))+((x143*x144))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
sj2=0;
cj2=1.0;
j2=0;
IkReal x150=(py*sj0);
IkReal x151=(cj0*px);
IkReal x152=(pp*pz);
IkReal x153=((0.92038656235619)*pp);
IkReal x154=(pz*sj3);
IkReal x155=((36.2220411120167)*pp);
IkReal x156=((0.0254095720202485)*sj3);
j1eval[0]=((((-1.0)*x151*x155))+(((-1.0)*x150*x155))+(((-3.92556370551481)*pz))+(((5.4333061668025)*x152))+((sj3*x150))+((sj3*x151))+(((-7.28153581454315)*x150))+(((-7.28153581454315)*x151))+(((-12.2222222222222)*x154)));
j1eval[1]=IKsign(((((-0.310561435803037)*x154))+(((-0.099746893695352)*pz))+(((-1.0)*x151*x153))+((x150*x156))+(((-1.0)*x150*x153))+((x151*x156))+(((0.138057984353428)*x152))+(((-0.185020708697653)*x151))+(((-0.185020708697653)*x150))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
IkReal x157=x133;
evalcond[0]=((IKabs(pz))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=x157;
evalcond[3]=x157;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x158=((-1.0)*py);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x158);
rxp0_1=(px*r20);
rxp1_0=(r21*x158);
rxp1_1=(px*r21);
rxp2_0=(r22*x158);
rxp2_1=(px*r22);
j1eval[0]=(((cj0*px))+((py*sj0)));
if( IKabs(j1eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[6];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(px))+(IKabs(py)));
evalcond[1]=0.7225;
evalcond[2]=-0.85;
evalcond[3]=0;
evalcond[4]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=0;
npx=0;
npy=0;
npz=0;
rxp0_0=0;
rxp0_1=0;
rxp1_0=0;
rxp1_1=0;
rxp2_0=0;
rxp2_1=0;
px=0;
py=0;
rxp0_2=0;
rxp1_2=0;
rxp2_2=0;
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j0), 6.28318530717959)))))+(IKabs(px)));
evalcond[1]=((0.7225)+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=((-1.0)*py);
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x594=((-1.0)*py);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=py*py;
npx=(py*r10);
npy=(py*r11);
npz=(py*r12);
rxp0_0=(r20*x594);
rxp0_1=0;
rxp1_0=(r21*x594);
rxp1_1=0;
rxp2_0=(r22*x594);
rxp2_1=0;
px=0;
j0=0;
sj0=0;
cj0=1.0;
rxp0_2=(py*r00);
rxp1_2=(py*r01);
rxp2_2=(py*r02);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(px))+(IKabs(((-3.14159265358979)+(IKfmod(j0, 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=py;
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x595=((-1.0)*py);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=py*py;
npx=(py*r10);
npy=(py*r11);
npz=(py*r12);
rxp0_0=(r20*x595);
rxp0_1=0;
rxp1_0=(r21*x595);
rxp1_1=0;
rxp2_0=(r22*x595);
rxp2_1=0;
px=0;
j0=3.14159265358979;
sj0=0;
cj0=-1.0;
rxp0_2=(py*r00);
rxp1_2=(py*r01);
rxp2_2=(py*r02);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(py))+(IKabs(((-3.14159265358979)+(IKfmod(((1.5707963267949)+j0), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(px*px))));
evalcond[2]=-0.85;
evalcond[3]=px;
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x596=((-1.0)*px);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=px*px;
npx=(px*r00);
npy=(px*r01);
npz=(px*r02);
rxp0_0=0;
rxp0_1=(px*r20);
rxp1_0=0;
rxp1_1=(px*r21);
rxp2_0=0;
rxp2_1=(px*r22);
py=0;
j0=1.5707963267949;
sj0=1.0;
cj0=0;
rxp0_2=(r10*x596);
rxp1_2=(r11*x596);
rxp2_2=(r12*x596);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(py))+(IKabs(((-3.14159265358979)+(IKfmod(((4.71238898038469)+j0), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(px*px))));
evalcond[2]=-0.85;
evalcond[3]=((-1.0)*px);
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x597=((-1.0)*px);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=px*px;
npx=(px*r00);
npy=(px*r01);
npz=(px*r02);
rxp0_0=0;
rxp0_1=(px*r20);
rxp1_0=0;
rxp1_1=(px*r21);
rxp2_0=0;
rxp2_1=(px*r22);
py=0;
j0=-1.5707963267949;
sj0=-1.0;
cj0=0;
rxp0_2=(r10*x597);
rxp1_2=(r11*x597);
rxp2_2=(r12*x597);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x598=py*py;
IkReal x599=cj0*cj0;
IkReal x600=(cj0*px);
IkReal x601=(py*sj0);
IkReal x602=((4400.0)*x598);
CheckValue<IkReal> x603=IKPowWithIntegerCheck(((((306.0)*x601))+(((306.0)*x600))),-1);
if(!x603.valid){
continue;
}
if( IKabs(((((1.17647058823529)*x600))+(((1.17647058823529)*x601)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((x603.value)*(((3179.0)+(((-4400.0)*x599*(px*px)))+(((-8800.0)*x600*x601))+(((-1.0)*x602))+((x599*x602)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((1.17647058823529)*x600))+(((1.17647058823529)*x601))))+IKsqr(((x603.value)*(((3179.0)+(((-4400.0)*x599*(px*px)))+(((-8800.0)*x600*x601))+(((-1.0)*x602))+((x599*x602))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j1array[0]=IKatan2(((((1.17647058823529)*x600))+(((1.17647058823529)*x601))), ((x603.value)*(((3179.0)+(((-4400.0)*x599*(px*px)))+(((-8800.0)*x600*x601))+(((-1.0)*x602))+((x599*x602))))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x604=IKsin(j1);
IkReal x605=IKcos(j1);
IkReal x606=(py*sj0);
IkReal x607=(cj0*px);
IkReal x608=((0.09)*x605);
IkReal x609=((1.0)*x605);
IkReal x610=((1.1)*x604);
evalcond[0]=((-0.85)*x605);
evalcond[1]=((-0.85)+((x604*x606))+((x604*x607)));
evalcond[2]=((((0.85)*x604))+(((-1.0)*x607))+(((-1.0)*x606)));
evalcond[3]=((((-1.0)*x606*x609))+(((-1.0)*x607*x609)));
evalcond[4]=((-0.935)+((x607*x608))+((x606*x608))+((x606*x610))+((x607*x610)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x611=cj3*cj3;
IkReal x612=(cj3*sj3);
IkReal x613=(cj0*px);
IkReal x614=((0.92038656235619)*pp);
IkReal x615=((0.0254095720202485)*sj3);
IkReal x616=(py*sj0);
IkReal x617=(pp*sj3);
IkReal x618=((1.0)*pz);
IkReal x619=(cj3*pp);
CheckValue<IkReal> x620 = IKatan2WithCheck(IkReal(((-0.100617959042798)+(((-0.0414173953060285)*x617))+(((0.00762287160607455)*x612))+(pz*pz)+(((-0.00114343074091118)*x611))+(((-0.506212609295904)*pp))+(((0.00564933271974229)*sj3))+(((-0.276115968706857)*x619))+(((-0.0555062126092959)*cj3)))),((-0.0688360561435803)+(((0.00621260929590428)*x617))+(((-0.0299240681086056)*cj3))+(((-0.0931684307409112)*x612))+(((0.0759318913943856)*pp))+(((0.0139752646111367)*x611))+(((-0.175297399907961)*sj3))+(((-1.0)*x613*x618))+(((-1.0)*x616*x618))+(((0.0414173953060285)*x619))),IKFAST_ATAN2_MAGTHRESH);
if(!x620.valid){
continue;
}
CheckValue<IkReal> x621=IKPowWithIntegerCheck(IKsign(((((-1.0)*x614*x616))+(((-0.099746893695352)*pz))+(((-0.310561435803037)*pz*sj3))+(((-0.185020708697653)*x613))+(((-0.185020708697653)*x616))+((x613*x615))+((x615*x616))+(((-1.0)*x613*x614))+(((0.138057984353428)*pp*pz)))),-1);
if(!x621.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(x620.value)+(((1.5707963267949)*(x621.value))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x622=IKsin(j1);
IkReal x623=IKcos(j1);
IkReal x624=((0.045)*sj3);
IkReal x625=((0.3)*cj3);
IkReal x626=((0.045)*cj3);
IkReal x627=(cj0*px);
IkReal x628=(py*sj0);
IkReal x629=((1.0)*x623);
IkReal x630=(sj3*x623);
IkReal x631=(pz*x622);
IkReal x632=(pz*x623);
IkReal x633=((0.09)*x623);
IkReal x634=((1.1)*x622);
evalcond[0]=((-0.55)+(((-1.0)*x624))+(((-1.0)*x625))+x632+((x622*x627))+((x622*x628)));
evalcond[1]=((0.045)+(((-1.0)*x628*x629))+(((-1.0)*x626))+(((-1.0)*x627*x629))+x631+(((0.3)*sj3)));
evalcond[2]=((((-0.185020708697653)*x623))+(((0.0254095720202485)*x630))+(((0.310561435803037)*sj3*x622))+(((0.099746893695352)*x622))+(((-0.138057984353428)*pp*x622))+(((-0.92038656235619)*pp*x623))+pz);
evalcond[3]=((((-1.0)*x623*x626))+(((0.3)*x630))+(((-1.0)*x628))+(((-1.0)*x627))+(((0.55)*x622))+(((0.045)*x623))+((x622*x624))+((x622*x625)));
evalcond[4]=((-0.2125)+((x628*x634))+((x628*x633))+(((1.1)*x632))+(((-0.09)*x631))+(((-1.0)*pp))+((x627*x634))+((x627*x633)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x635=cj0*cj0;
IkReal x636=py*py;
IkReal x637=cj3*cj3;
IkReal x638=(py*sj0);
IkReal x639=((0.3)*sj3);
IkReal x640=((0.045)*cj3);
IkReal x641=(cj0*px);
IkReal x642=(cj3*sj3);
IkReal x643=((1.0)*pz);
CheckValue<IkReal> x644=IKPowWithIntegerCheck(IKsign(((((-0.55)*pz))+(((-0.3)*cj3*pz))+((x639*x641))+(((-1.0)*x640*x641))+(((-0.045)*pz*sj3))+((x638*x639))+(((0.045)*x641))+(((-1.0)*x638*x640))+(((0.045)*x638)))),-1);
if(!x644.valid){
continue;
}
CheckValue<IkReal> x645 = IKatan2WithCheck(IkReal(((0.03825)+(((0.087975)*x642))+(((-0.01125)*cj3))+(((-1.0)*x641*x643))+(((-0.027)*x637))+(((0.167025)*sj3))+(((-1.0)*x638*x643)))),((-0.304525)+(((2.0)*x638*x641))+(((-0.0495)*sj3))+(((-1.0)*x635*x636))+(((-0.027)*x642))+((x635*(px*px)))+(((-0.087975)*x637))+x636+(((-0.33)*cj3))),IKFAST_ATAN2_MAGTHRESH);
if(!x645.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(((1.5707963267949)*(x644.value)))+(x645.value));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x646=IKsin(j1);
IkReal x647=IKcos(j1);
IkReal x648=((0.045)*sj3);
IkReal x649=((0.3)*cj3);
IkReal x650=((0.045)*cj3);
IkReal x651=(cj0*px);
IkReal x652=(py*sj0);
IkReal x653=((1.0)*x647);
IkReal x654=(sj3*x647);
IkReal x655=(pz*x646);
IkReal x656=(pz*x647);
IkReal x657=((0.09)*x647);
IkReal x658=((1.1)*x646);
evalcond[0]=((-0.55)+((x646*x652))+((x646*x651))+(((-1.0)*x648))+(((-1.0)*x649))+x656);
evalcond[1]=((0.045)+(((-1.0)*x651*x653))+(((-1.0)*x650))+x655+(((0.3)*sj3))+(((-1.0)*x652*x653)));
evalcond[2]=((((0.310561435803037)*sj3*x646))+(((0.0254095720202485)*x654))+(((-0.138057984353428)*pp*x646))+(((0.099746893695352)*x646))+pz+(((-0.92038656235619)*pp*x647))+(((-0.185020708697653)*x647)));
evalcond[3]=((((0.55)*x646))+(((-1.0)*x651))+(((-1.0)*x652))+(((-1.0)*x647*x650))+(((0.045)*x647))+(((0.3)*x654))+((x646*x648))+((x646*x649)));
evalcond[4]=((-0.2125)+(((-0.09)*x655))+((x652*x658))+((x652*x657))+((x651*x657))+((x651*x658))+(((-1.0)*pp))+(((1.1)*x656)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x659=cj3*cj3;
IkReal x660=(cj0*px);
IkReal x661=((0.00621260929590428)*pp);
IkReal x662=(cj3*sj3);
IkReal x663=(py*sj0);
IkReal x664=((0.138057984353428)*pp);
IkReal x665=((0.0414173953060285)*pp);
IkReal x666=((0.310561435803037)*sj3);
CheckValue<IkReal> x667=IKPowWithIntegerCheck(IKsign(((((-0.0254095720202485)*pz*sj3))+(((-1.0)*x663*x666))+(((-1.0)*x660*x666))+((x663*x664))+(((-0.099746893695352)*x660))+(((-0.099746893695352)*x663))+(((0.185020708697653)*pz))+((x660*x664))+(((0.92038656235619)*pp*pz)))),-1);
if(!x667.valid){
continue;
}
CheckValue<IkReal> x668 = IKatan2WithCheck(IkReal(((-0.000703060285319834)+((cj3*x665))+(((-0.276115968706857)*pp*sj3))+(((-0.00762287160607455)*x659))+(((-1.0)*x665))+((pz*x663))+((pz*x660))+(((-0.00114343074091118)*x662))+(((-0.0543627818683847)*sj3))+(((0.00832593189139439)*cj3)))),((-0.097657040957202)+(((-1.0)*cj3*x661))+(((0.0931684307409112)*x659))+(pz*pz)+(((0.00448861021629084)*cj3))+(((0.0139752646111367)*x662))+x661+((sj3*x665))+(((-0.0438993327197423)*sj3))),IKFAST_ATAN2_MAGTHRESH);
if(!x668.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(((1.5707963267949)*(x667.value)))+(x668.value));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x669=IKsin(j1);
IkReal x670=IKcos(j1);
IkReal x671=((0.045)*sj3);
IkReal x672=((0.3)*cj3);
IkReal x673=((0.045)*cj3);
IkReal x674=(cj0*px);
IkReal x675=(py*sj0);
IkReal x676=((1.0)*x670);
IkReal x677=(sj3*x670);
IkReal x678=(pz*x669);
IkReal x679=(pz*x670);
IkReal x680=((0.09)*x670);
IkReal x681=((1.1)*x669);
evalcond[0]=((-0.55)+((x669*x675))+((x669*x674))+x679+(((-1.0)*x671))+(((-1.0)*x672)));
evalcond[1]=((0.045)+(((-1.0)*x675*x676))+x678+(((0.3)*sj3))+(((-1.0)*x674*x676))+(((-1.0)*x673)));
evalcond[2]=((((-0.138057984353428)*pp*x669))+(((-0.92038656235619)*pp*x670))+(((-0.185020708697653)*x670))+(((0.0254095720202485)*x677))+pz+(((0.099746893695352)*x669))+(((0.310561435803037)*sj3*x669)));
evalcond[3]=((((0.045)*x670))+(((0.55)*x669))+(((0.3)*x677))+((x669*x671))+((x669*x672))+(((-1.0)*x670*x673))+(((-1.0)*x674))+(((-1.0)*x675)));
evalcond[4]=((-0.2125)+((x674*x681))+((x674*x680))+(((1.1)*x679))+(((-1.0)*pp))+(((-0.09)*x678))+((x675*x681))+((x675*x680)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x682=(px*sj0);
IkReal x683=(cj0*py);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=(x682+(((-1.0)*x683)));
evalcond[3]=(x683+(((-1.0)*x682)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[2];
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x684=cj0*cj0;
IkReal x685=py*py;
IkReal x686=((((-1.0)*x684*x685))+((x684*(px*px)))+(pz*pz)+x685+(((2.0)*cj0*px*py*sj0)));
j1eval[0]=x686;
j1eval[1]=IKsign(x686);
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x687=(py*sj0);
IkReal x688=((0.3)*sj3);
IkReal x689=(cj0*px);
IkReal x690=((6.66666666666667)*sj3);
IkReal x691=(pz*sj3);
IkReal x692=(cj3*pz);
IkReal x693=((0.045)*x689);
j1eval[0]=((((-1.0)*x687*x690))+(((-6.66666666666667)*x692))+(((-12.2222222222222)*pz))+(((-1.0)*x689*x690))+(((-1.0)*x687))+(((-1.0)*x689))+((cj3*x689))+((cj3*x687))+(((-1.0)*x691)));
j1eval[1]=IKsign(((((-0.55)*pz))+(((-1.0)*x687*x688))+(((-1.0)*x688*x689))+(((-0.045)*x687))+((cj3*x693))+(((-1.0)*x693))+(((-0.045)*x691))+(((0.045)*cj3*x687))+(((-0.3)*x692))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x694=(py*sj0);
IkReal x695=(cj0*px);
IkReal x696=(pp*pz);
IkReal x697=((0.92038656235619)*pp);
IkReal x698=(pz*sj3);
IkReal x699=((36.2220411120167)*pp);
IkReal x700=((0.0254095720202485)*sj3);
j1eval[0]=((((-5.4333061668025)*x696))+(((12.2222222222222)*x698))+(((-7.28153581454315)*x695))+(((-7.28153581454315)*x694))+(((3.92556370551481)*pz))+(((-1.0)*x695*x699))+(((-1.0)*x694*x699))+((sj3*x695))+((sj3*x694)));
j1eval[1]=IKsign(((((0.310561435803037)*x698))+((x694*x700))+((x695*x700))+(((0.099746893695352)*pz))+(((-1.0)*x695*x697))+(((-0.138057984353428)*x696))+(((-1.0)*x694*x697))+(((-0.185020708697653)*x694))+(((-0.185020708697653)*x695))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
IkReal x701=(px*sj0);
IkReal x702=(cj0*py);
evalcond[0]=((IKabs(pz))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((((-1.0)*x702))+x701);
evalcond[3]=((((-1.0)*x701))+x702);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x703=((-1.0)*py);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x703);
rxp0_1=(px*r20);
rxp1_0=(r21*x703);
rxp1_1=(px*r21);
rxp2_0=(r22*x703);
rxp2_1=(px*r22);
j1eval[0]=((((-1.0)*py*sj0))+(((-1.0)*cj0*px)));
if( IKabs(j1eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[6];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(px))+(IKabs(py)));
evalcond[1]=0.7225;
evalcond[2]=-0.85;
evalcond[3]=0;
evalcond[4]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=0;
npx=0;
npy=0;
npz=0;
rxp0_0=0;
rxp0_1=0;
rxp1_0=0;
rxp1_1=0;
rxp2_0=0;
rxp2_1=0;
px=0;
py=0;
rxp0_2=0;
rxp1_2=0;
rxp2_2=0;
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j0), 6.28318530717959)))))+(IKabs(px)));
evalcond[1]=((0.7225)+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=((-1.0)*py);
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x704=((-1.0)*py);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=py*py;
npx=(py*r10);
npy=(py*r11);
npz=(py*r12);
rxp0_0=(r20*x704);
rxp0_1=0;
rxp1_0=(r21*x704);
rxp1_1=0;
rxp2_0=(r22*x704);
rxp2_1=0;
px=0;
j0=0;
sj0=0;
cj0=1.0;
rxp0_2=(py*r00);
rxp1_2=(py*r01);
rxp2_2=(py*r02);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(px))+(IKabs(((-3.14159265358979)+(IKfmod(j0, 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=py;
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x705=((-1.0)*py);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=py*py;
npx=(py*r10);
npy=(py*r11);
npz=(py*r12);
rxp0_0=(r20*x705);
rxp0_1=0;
rxp1_0=(r21*x705);
rxp1_1=0;
rxp2_0=(r22*x705);
rxp2_1=0;
px=0;
j0=3.14159265358979;
sj0=0;
cj0=-1.0;
rxp0_2=(py*r00);
rxp1_2=(py*r01);
rxp2_2=(py*r02);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(py))+(IKabs(((-3.14159265358979)+(IKfmod(((1.5707963267949)+j0), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(px*px))));
evalcond[2]=-0.85;
evalcond[3]=px;
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x706=((-1.0)*px);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=px*px;
npx=(px*r00);
npy=(px*r01);
npz=(px*r02);
rxp0_0=0;
rxp0_1=(px*r20);
rxp1_0=0;
rxp1_1=(px*r21);
rxp2_0=0;
rxp2_1=(px*r22);
py=0;
j0=1.5707963267949;
sj0=1.0;
cj0=0;
rxp0_2=(r10*x706);
rxp1_2=(r11*x706);
rxp2_2=(r12*x706);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(py))+(IKabs(((-3.14159265358979)+(IKfmod(((4.71238898038469)+j0), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(px*px))));
evalcond[2]=-0.85;
evalcond[3]=((-1.0)*px);
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x707=((-1.0)*px);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=px*px;
npx=(px*r00);
npy=(px*r01);
npz=(px*r02);
rxp0_0=0;
rxp0_1=(px*r20);
rxp1_0=0;
rxp1_1=(px*r21);
rxp2_0=0;
rxp2_1=(px*r22);
py=0;
j0=-1.5707963267949;
sj0=-1.0;
cj0=0;
rxp0_2=(r10*x707);
rxp1_2=(r11*x707);
rxp2_2=(r12*x707);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x708=py*py;
IkReal x709=cj0*cj0;
IkReal x710=(cj0*px);
IkReal x711=(py*sj0);
IkReal x712=((4400.0)*x708);
CheckValue<IkReal> x713=IKPowWithIntegerCheck(((((-306.0)*x711))+(((-306.0)*x710))),-1);
if(!x713.valid){
continue;
}
if( IKabs(((((1.17647058823529)*x710))+(((1.17647058823529)*x711)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((x713.value)*(((3179.0)+(((-4400.0)*x709*(px*px)))+((x709*x712))+(((-1.0)*x712))+(((-8800.0)*x710*x711)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((1.17647058823529)*x710))+(((1.17647058823529)*x711))))+IKsqr(((x713.value)*(((3179.0)+(((-4400.0)*x709*(px*px)))+((x709*x712))+(((-1.0)*x712))+(((-8800.0)*x710*x711))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j1array[0]=IKatan2(((((1.17647058823529)*x710))+(((1.17647058823529)*x711))), ((x713.value)*(((3179.0)+(((-4400.0)*x709*(px*px)))+((x709*x712))+(((-1.0)*x712))+(((-8800.0)*x710*x711))))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x714=IKcos(j1);
IkReal x715=IKsin(j1);
IkReal x716=(py*sj0);
IkReal x717=(cj0*px);
IkReal x718=((0.09)*x714);
IkReal x719=(x715*x716);
evalcond[0]=((-0.85)*x714);
evalcond[1]=(((x714*x717))+((x714*x716)));
evalcond[2]=((-0.85)+((x715*x717))+x719);
evalcond[3]=((((-1.0)*x717))+(((-1.0)*x716))+(((0.85)*x715)));
evalcond[4]=((-0.935)+(((1.1)*x719))+(((1.1)*x715*x717))+(((-1.0)*x717*x718))+(((-1.0)*x716*x718)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x720=cj3*cj3;
IkReal x721=(cj3*sj3);
IkReal x722=(cj0*px);
IkReal x723=((0.92038656235619)*pp);
IkReal x724=((0.0254095720202485)*sj3);
IkReal x725=(py*sj0);
IkReal x726=((0.0414173953060285)*pp);
IkReal x727=((1.0)*pz);
CheckValue<IkReal> x728 = IKatan2WithCheck(IkReal(((-0.100617959042798)+(((0.00762287160607455)*x721))+(((-0.276115968706857)*cj3*pp))+(pz*pz)+(((-0.506212609295904)*pp))+(((0.00564933271974229)*sj3))+(((-0.00114343074091118)*x720))+(((-1.0)*sj3*x726))+(((-0.0555062126092959)*cj3)))),((0.0688360561435803)+(((0.175297399907961)*sj3))+(((-1.0)*cj3*x726))+(((-1.0)*x722*x727))+(((0.0931684307409112)*x721))+(((-1.0)*x725*x727))+(((-0.00621260929590428)*pp*sj3))+(((-0.0139752646111367)*x720))+(((-0.0759318913943856)*pp))+(((0.0299240681086056)*cj3))),IKFAST_ATAN2_MAGTHRESH);
if(!x728.valid){
continue;
}
CheckValue<IkReal> x729=IKPowWithIntegerCheck(IKsign(((((-0.138057984353428)*pp*pz))+(((-1.0)*x723*x725))+(((0.310561435803037)*pz*sj3))+(((-1.0)*x722*x723))+((x722*x724))+(((0.099746893695352)*pz))+(((-0.185020708697653)*x722))+(((-0.185020708697653)*x725))+((x724*x725)))),-1);
if(!x729.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(x728.value)+(((1.5707963267949)*(x729.value))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x730=IKsin(j1);
IkReal x731=IKcos(j1);
IkReal x732=((0.045)*sj3);
IkReal x733=((0.3)*cj3);
IkReal x734=((0.045)*cj3);
IkReal x735=(cj0*px);
IkReal x736=(py*sj0);
IkReal x737=(sj3*x731);
IkReal x738=(pz*x730);
IkReal x739=(pz*x731);
IkReal x740=((0.09)*x731);
IkReal x741=((1.1)*x730);
evalcond[0]=((-0.55)+(((-1.0)*x733))+(((-1.0)*x732))+x739+((x730*x735))+((x730*x736)));
evalcond[1]=((0.045)+((x731*x736))+((x731*x735))+(((-1.0)*x738))+(((-1.0)*x734))+(((0.3)*sj3)));
evalcond[2]=((((0.138057984353428)*pp*x730))+(((0.0254095720202485)*x737))+(((-0.099746893695352)*x730))+(((-0.310561435803037)*sj3*x730))+pz+(((-0.185020708697653)*x731))+(((-0.92038656235619)*pp*x731)));
evalcond[3]=(((x731*x734))+(((0.55)*x730))+(((-0.045)*x731))+(((-1.0)*x736))+(((-1.0)*x735))+(((-0.3)*x737))+((x730*x732))+((x730*x733)));
evalcond[4]=((-0.2125)+(((1.1)*x739))+(((0.09)*x738))+(((-1.0)*pp))+(((-1.0)*x735*x740))+(((-1.0)*x736*x740))+((x735*x741))+((x736*x741)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x742=cj0*cj0;
IkReal x743=py*py;
IkReal x744=cj3*cj3;
IkReal x745=(py*sj0);
IkReal x746=((0.3)*sj3);
IkReal x747=((0.045)*cj3);
IkReal x748=(cj0*px);
IkReal x749=(cj3*sj3);
IkReal x750=((1.0)*pz);
CheckValue<IkReal> x751 = IKatan2WithCheck(IkReal(((-0.03825)+(((0.027)*x744))+(((0.01125)*cj3))+(((-1.0)*x745*x750))+(((-0.167025)*sj3))+(((-0.087975)*x749))+(((-1.0)*x748*x750)))),((-0.304525)+(((-0.0495)*sj3))+((x742*(px*px)))+(((-1.0)*x742*x743))+(((2.0)*x745*x748))+(((-0.087975)*x744))+x743+(((-0.027)*x749))+(((-0.33)*cj3))),IKFAST_ATAN2_MAGTHRESH);
if(!x751.valid){
continue;
}
CheckValue<IkReal> x752=IKPowWithIntegerCheck(IKsign(((((-0.55)*pz))+(((-0.3)*cj3*pz))+((x745*x747))+(((-1.0)*x745*x746))+(((-1.0)*x746*x748))+(((-0.045)*pz*sj3))+((x747*x748))+(((-0.045)*x748))+(((-0.045)*x745)))),-1);
if(!x752.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(x751.value)+(((1.5707963267949)*(x752.value))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x753=IKsin(j1);
IkReal x754=IKcos(j1);
IkReal x755=((0.045)*sj3);
IkReal x756=((0.3)*cj3);
IkReal x757=((0.045)*cj3);
IkReal x758=(cj0*px);
IkReal x759=(py*sj0);
IkReal x760=(sj3*x754);
IkReal x761=(pz*x753);
IkReal x762=(pz*x754);
IkReal x763=((0.09)*x754);
IkReal x764=((1.1)*x753);
evalcond[0]=((-0.55)+x762+((x753*x759))+((x753*x758))+(((-1.0)*x756))+(((-1.0)*x755)));
evalcond[1]=((0.045)+(((-1.0)*x761))+(((0.3)*sj3))+(((-1.0)*x757))+((x754*x758))+((x754*x759)));
evalcond[2]=((((-0.92038656235619)*pp*x754))+(((-0.310561435803037)*sj3*x753))+(((-0.185020708697653)*x754))+pz+(((-0.099746893695352)*x753))+(((0.0254095720202485)*x760))+(((0.138057984353428)*pp*x753)));
evalcond[3]=((((0.55)*x753))+(((-0.3)*x760))+(((-1.0)*x759))+(((-1.0)*x758))+(((-0.045)*x754))+((x753*x756))+((x753*x755))+((x754*x757)));
evalcond[4]=((-0.2125)+(((-1.0)*x758*x763))+(((0.09)*x761))+(((1.1)*x762))+((x759*x764))+((x758*x764))+(((-1.0)*pp))+(((-1.0)*x759*x763)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x765=cj0*cj0;
IkReal x766=py*py;
IkReal x767=(pz*sj3);
IkReal x768=(py*sj0);
IkReal x769=((0.3)*cj3);
IkReal x770=((0.045)*sj3);
IkReal x771=((0.045)*cj3);
IkReal x772=(cj0*px);
IkReal x773=((0.3)*sj3);
CheckValue<IkReal> x774=IKPowWithIntegerCheck(IKsign(((pz*pz)+(((2.0)*x768*x772))+(((-1.0)*x765*x766))+x766+((x765*(px*px))))),-1);
if(!x774.valid){
continue;
}
CheckValue<IkReal> x775 = IKatan2WithCheck(IkReal((((x770*x772))+((x768*x769))+(((0.045)*pz))+((x769*x772))+(((-1.0)*pz*x771))+(((0.55)*x772))+(((0.3)*x767))+(((0.55)*x768))+((x768*x770)))),((((-1.0)*x768*x773))+((x771*x772))+(((-0.045)*x768))+(((0.045)*x767))+((pz*x769))+(((-0.045)*x772))+(((-1.0)*x772*x773))+(((0.55)*pz))+((x768*x771))),IKFAST_ATAN2_MAGTHRESH);
if(!x775.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(((1.5707963267949)*(x774.value)))+(x775.value));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x776=IKsin(j1);
IkReal x777=IKcos(j1);
IkReal x778=((0.045)*sj3);
IkReal x779=((0.3)*cj3);
IkReal x780=((0.045)*cj3);
IkReal x781=(cj0*px);
IkReal x782=(py*sj0);
IkReal x783=(sj3*x777);
IkReal x784=(pz*x776);
IkReal x785=(pz*x777);
IkReal x786=((0.09)*x777);
IkReal x787=((1.1)*x776);
evalcond[0]=((-0.55)+x785+(((-1.0)*x778))+(((-1.0)*x779))+((x776*x781))+((x776*x782)));
evalcond[1]=((0.045)+(((-1.0)*x780))+(((0.3)*sj3))+(((-1.0)*x784))+((x777*x781))+((x777*x782)));
evalcond[2]=((((-0.185020708697653)*x777))+(((-0.099746893695352)*x776))+pz+(((-0.310561435803037)*sj3*x776))+(((0.138057984353428)*pp*x776))+(((0.0254095720202485)*x783))+(((-0.92038656235619)*pp*x777)));
evalcond[3]=(((x776*x778))+((x776*x779))+(((-0.045)*x777))+(((0.55)*x776))+(((-1.0)*x781))+(((-1.0)*x782))+(((-0.3)*x783))+((x777*x780)));
evalcond[4]=((-0.2125)+((x781*x787))+(((0.09)*x784))+(((1.1)*x785))+((x782*x787))+(((-1.0)*x781*x786))+(((-1.0)*pp))+(((-1.0)*x782*x786)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x788=cj2*cj2;
IkReal x789=((0.045)*px);
IkReal x790=(sj0*sj2);
IkReal x791=(pz*sj2);
IkReal x792=(cj0*cj3);
IkReal x793=((0.55)*cj2);
IkReal x794=(px*sj0);
IkReal x795=(cj0*py);
IkReal x796=((0.3)*cj3);
IkReal x797=((0.3)*sj3);
IkReal x798=((0.045)*sj3);
IkReal x799=(sj0*x788);
IkReal x800=(cj0*cj2*sj2);
IkReal x801=((0.3)*cj2*py);
IkReal x802=((0.045)*x788);
IkReal x803=((0.045)*cj2*py);
CheckValue<IkReal> x804 = IKatan2WithCheck(IkReal(((((-1.0)*cj0*px*x791))+((x793*x795))+(((-1.0)*x793*x794))+((cj2*x795*x798))+(((-1.0)*cj2*x794*x796))+((x792*x801))+(((-1.0)*py*pz*x790))+(((-1.0)*cj2*sj0*sj3*x789)))),((((-1.0)*x788*x794*x797))+((cj3*x789*x799))+((x795*x802))+(((-1.0)*pz*x791))+(((-1.0)*x789*x799))+(((-1.0)*py*x792*x802))+((x788*x795*x797))),IKFAST_ATAN2_MAGTHRESH);
if(!x804.valid){
continue;
}
CheckValue<IkReal> x805=IKPowWithIntegerCheck(IKsign(((((-0.55)*x791))+((x790*x803))+((px*x797*x800))+((x789*x800))+(((-1.0)*x791*x798))+(((-1.0)*x791*x796))+(((-1.0)*cj2*sj2*x789*x792))+(((-1.0)*cj3*x790*x803))+((cj2*py*x790*x797)))),-1);
if(!x805.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(x804.value)+(((1.5707963267949)*(x805.value))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[6];
IkReal x806=IKsin(j1);
IkReal x807=IKcos(j1);
IkReal x808=(px*sj2);
IkReal x809=((0.3)*sj3);
IkReal x810=((0.09)*sj0);
IkReal x811=(cj2*px);
IkReal x812=((0.045)*cj3);
IkReal x813=((0.045)*cj2);
IkReal x814=(py*sj0);
IkReal x815=((0.045)*sj3);
IkReal x816=((1.0)*cj0);
IkReal x817=((0.3)*cj3);
IkReal x818=(py*sj2);
IkReal x819=(cj0*x807);
IkReal x820=(cj3*x806);
IkReal x821=(cj2*x807);
IkReal x822=(cj2*x806);
IkReal x823=(pz*x807);
IkReal x824=(cj0*px*x806);
evalcond[0]=((-0.55)+(((-1.0)*x815))+(((-1.0)*x817))+((x806*x814))+x823+x824);
evalcond[1]=((((-1.0)*pz*sj2*x806))+((sj0*x811))+((sj2*x807*x814))+((x808*x819))+(((-1.0)*cj2*py*x816)));
evalcond[2]=(((x809*x822))+(((-1.0)*x812*x822))+(((-0.55)*x807))+pz+(((-1.0)*x807*x815))+(((-1.0)*x807*x817))+((x806*x813)));
evalcond[3]=((0.045)+((pz*x822))+(((-1.0)*x814*x821))+(((-1.0)*x816*x818))+(((-1.0)*x812))+(((-1.0)*x807*x811*x816))+((sj0*x808))+x809);
evalcond[4]=(((x809*x821))+(((-1.0)*x812*x821))+(((-1.0)*x814))+((x807*x813))+(((-1.0)*px*x816))+((x806*x817))+((x806*x815))+(((0.55)*x806)));
evalcond[5]=((-0.2125)+(((-0.09)*pz*x822))+((py*x810*x821))+(((-1.0)*x808*x810))+(((0.09)*x811*x819))+(((0.09)*cj0*x818))+(((-1.0)*pp))+(((1.1)*x824))+(((1.1)*x823))+(((1.1)*x806*x814)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x825=cj0*cj0;
IkReal x826=py*py;
IkReal x827=px*px;
IkReal x828=(px*py);
IkReal x829=((1.0)*cj2);
IkReal x830=(cj0*sj2);
IkReal x831=(cj2*sj0);
IkReal x832=((0.3)*cj3);
IkReal x833=(pz*sj2);
IkReal x834=((0.045)*sj3);
IkReal x835=(sj2*x826);
IkReal x836=(py*sj0*sj2);
CheckValue<IkReal> x837 = IKatan2WithCheck(IkReal((((x832*x836))+(((0.55)*x836))+((x834*x836))+(((-1.0)*cj0*py*pz*x829))+((px*pz*x831))+(((0.55)*px*x830))+((px*x830*x834))+((px*x830*x832)))),((((-1.0)*x828*x829))+((x832*x833))+((x833*x834))+(((0.55)*x833))+(((2.0)*cj2*x825*x828))+((cj0*x826*x831))+(((-1.0)*cj0*sj0*x827*x829))),IKFAST_ATAN2_MAGTHRESH);
if(!x837.valid){
continue;
}
CheckValue<IkReal> x838=IKPowWithIntegerCheck(IKsign((((sj2*x825*x827))+(((2.0)*sj0*x828*x830))+((pz*x833))+x835+(((-1.0)*x825*x835)))),-1);
if(!x838.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(x837.value)+(((1.5707963267949)*(x838.value))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[6];
IkReal x839=IKsin(j1);
IkReal x840=IKcos(j1);
IkReal x841=(px*sj2);
IkReal x842=((0.3)*sj3);
IkReal x843=((0.09)*sj0);
IkReal x844=(cj2*px);
IkReal x845=((0.045)*cj3);
IkReal x846=((0.045)*cj2);
IkReal x847=(py*sj0);
IkReal x848=((0.045)*sj3);
IkReal x849=((1.0)*cj0);
IkReal x850=((0.3)*cj3);
IkReal x851=(py*sj2);
IkReal x852=(cj0*x840);
IkReal x853=(cj3*x839);
IkReal x854=(cj2*x840);
IkReal x855=(cj2*x839);
IkReal x856=(pz*x840);
IkReal x857=(cj0*px*x839);
evalcond[0]=((-0.55)+(((-1.0)*x850))+((x839*x847))+(((-1.0)*x848))+x856+x857);
evalcond[1]=((((-1.0)*pz*sj2*x839))+((x841*x852))+(((-1.0)*cj2*py*x849))+((sj2*x840*x847))+((sj0*x844)));
evalcond[2]=(((x842*x855))+((x839*x846))+(((-1.0)*x845*x855))+(((-1.0)*x840*x848))+pz+(((-1.0)*x840*x850))+(((-0.55)*x840)));
evalcond[3]=((0.045)+(((-1.0)*x847*x854))+(((-1.0)*x849*x851))+(((-1.0)*x845))+(((-1.0)*x840*x844*x849))+x842+((sj0*x841))+((pz*x855)));
evalcond[4]=(((x842*x854))+((x840*x846))+((x839*x848))+(((-1.0)*x845*x854))+(((-1.0)*px*x849))+(((0.55)*x839))+(((-1.0)*x847))+((x839*x850)));
evalcond[5]=((-0.2125)+(((-1.0)*x841*x843))+(((0.09)*cj0*x851))+((py*x843*x854))+(((1.1)*x856))+(((1.1)*x857))+(((0.09)*x844*x852))+(((1.1)*x839*x847))+(((-0.09)*pz*x855))+(((-1.0)*pp)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x858=cj3*cj3;
IkReal x859=(cj2*sj3);
IkReal x860=(py*sj0);
IkReal x861=((0.3)*cj3);
IkReal x862=((0.045)*sj3);
IkReal x863=(cj0*px);
IkReal x864=(cj2*cj3);
IkReal x865=((0.045)*pz);
IkReal x866=((1.0)*pz);
CheckValue<IkReal> x867=IKPowWithIntegerCheck(IKsign(((((-1.0)*cj2*x865))+(((-0.3)*pz*x859))+(((-1.0)*x862*x863))+(((-1.0)*x861*x863))+(((-1.0)*x860*x861))+(((-1.0)*x860*x862))+(((-0.55)*x863))+(((-0.55)*x860))+((x864*x865)))),-1);
if(!x867.valid){
continue;
}
CheckValue<IkReal> x868 = IKatan2WithCheck(IkReal(((-0.304525)+(((-0.087975)*x858))+(((-0.0495)*sj3))+(((-0.027)*cj3*sj3))+(pz*pz)+(((-0.33)*cj3)))),((((-0.167025)*x859))+(((-0.087975)*cj3*x859))+(((-1.0)*x860*x866))+(((0.027)*cj2*x858))+(((0.01125)*x864))+(((-0.03825)*cj2))+(((-1.0)*x863*x866))),IKFAST_ATAN2_MAGTHRESH);
if(!x868.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(((1.5707963267949)*(x867.value)))+(x868.value));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[6];
IkReal x869=IKsin(j1);
IkReal x870=IKcos(j1);
IkReal x871=(px*sj2);
IkReal x872=((0.3)*sj3);
IkReal x873=((0.09)*sj0);
IkReal x874=(cj2*px);
IkReal x875=((0.045)*cj3);
IkReal x876=((0.045)*cj2);
IkReal x877=(py*sj0);
IkReal x878=((0.045)*sj3);
IkReal x879=((1.0)*cj0);
IkReal x880=((0.3)*cj3);
IkReal x881=(py*sj2);
IkReal x882=(cj0*x870);
IkReal x883=(cj3*x869);
IkReal x884=(cj2*x870);
IkReal x885=(cj2*x869);
IkReal x886=(pz*x870);
IkReal x887=(cj0*px*x869);
evalcond[0]=((-0.55)+(((-1.0)*x880))+((x869*x877))+x887+x886+(((-1.0)*x878)));
evalcond[1]=(((sj2*x870*x877))+(((-1.0)*cj2*py*x879))+((sj0*x874))+((x871*x882))+(((-1.0)*pz*sj2*x869)));
evalcond[2]=((((-1.0)*x870*x880))+pz+(((-0.55)*x870))+(((-1.0)*x870*x878))+((x869*x876))+((x872*x885))+(((-1.0)*x875*x885)));
evalcond[3]=((0.045)+(((-1.0)*x879*x881))+((pz*x885))+(((-1.0)*x870*x874*x879))+((sj0*x871))+(((-1.0)*x877*x884))+x872+(((-1.0)*x875)));
evalcond[4]=(((x870*x876))+(((0.55)*x869))+(((-1.0)*x877))+((x869*x880))+((x869*x878))+(((-1.0)*px*x879))+((x872*x884))+(((-1.0)*x875*x884)));
evalcond[5]=((-0.2125)+(((1.1)*x887))+(((1.1)*x886))+(((1.1)*x869*x877))+(((0.09)*x874*x882))+(((-1.0)*x871*x873))+((py*x873*x884))+(((-1.0)*pp))+(((0.09)*cj0*x881))+(((-0.09)*pz*x885)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
}
}
}
} else
{
{
IkReal j1array[2], cj1array[2], sj1array[2];
bool j1valid[2]={false};
_nj1 = 2;
IkReal x888=((0.045)*cj2);
IkReal x889=((-0.55)+(((-0.045)*sj3))+(((-0.3)*cj3)));
IkReal x890=((((-1.0)*cj3*x888))+(((0.3)*cj2*sj3))+x888);
CheckValue<IkReal> x893 = IKatan2WithCheck(IkReal(x889),x890,IKFAST_ATAN2_MAGTHRESH);
if(!x893.valid){
continue;
}
IkReal x891=((1.0)*(x893.value));
if((((x889*x889)+(x890*x890))) < -0.00001)
continue;
CheckValue<IkReal> x894=IKPowWithIntegerCheck(IKabs(IKsqrt(((x889*x889)+(x890*x890)))),-1);
if(!x894.valid){
continue;
}
if( ((pz*(x894.value))) < -1-IKFAST_SINCOS_THRESH || ((pz*(x894.value))) > 1+IKFAST_SINCOS_THRESH )
continue;
IkReal x892=IKasin((pz*(x894.value)));
j1array[0]=((((-1.0)*x891))+(((-1.0)*x892)));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
j1array[1]=((3.14159265358979)+(((-1.0)*x891))+x892);
sj1array[1]=IKsin(j1array[1]);
cj1array[1]=IKcos(j1array[1]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
if( j1array[1] > IKPI )
{
j1array[1]-=IK2PI;
}
else if( j1array[1] < -IKPI )
{ j1array[1]+=IK2PI;
}
j1valid[1] = true;
for(int ij1 = 0; ij1 < 2; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 2; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal j0eval[2];
IkReal x895=(((pp*sj1))+(((-1.0)*sj1*(pz*pz))));
j0eval[0]=x895;
j0eval[1]=IKsign(x895);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
IkReal x896=(cj2*sj1);
IkReal x897=(((x896*(pz*pz)))+(((-1.0)*pp*x896)));
j0eval[0]=x897;
j0eval[1]=IKsign(x897);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
IkReal x898=(pp+(((-1.0)*(pz*pz))));
j0eval[0]=x898;
j0eval[1]=IKsign(x898);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=((((-0.045)*cj1*sj3))+(((-0.55)*cj1))+pz+(((-0.3)*cj1*cj3)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
IkReal x899=(cj1*px);
IkReal x900=((0.3)*sj3);
IkReal x901=(cj1*py);
IkReal x902=(pz*sj1);
IkReal x903=((0.045)*cj3);
IkReal x904=(((cj1*pp))+(((-1.0)*cj1*(pz*pz))));
j0eval[0]=x904;
j0eval[1]=((IKabs((((px*x902))+((x900*x901))+(((0.045)*x901))+(((-1.0)*x901*x903)))))+(IKabs(((((-0.045)*x899))+((x899*x903))+(((-1.0)*x899*x900))+((py*x902))))));
j0eval[2]=IKsign(x904);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
IkReal x905=pz*pz;
IkReal x906=((1.1)*pz);
IkReal x907=(cj1*pp);
IkReal x908=((0.2125)*cj1);
IkReal x909=(cj1*x905);
IkReal x910=((0.09)*pz*sj1);
j0eval[0]=((((-1.0)*x909))+x907);
j0eval[1]=((IKabs(((((-1.0)*px*x908))+((px*x906))+(((-1.0)*px*x907))+((py*x910)))))+(IKabs((((px*x910))+(((-1.0)*py*x906))+((py*x907))+((py*x908))))));
j0eval[2]=IKsign(((((0.09)*x907))+(((-0.09)*x909))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
IkReal x911=((0.3)*sj3);
IkReal x912=(py*sj1);
IkReal x913=((0.3)*cj3);
IkReal x914=(px*sj1);
IkReal x915=((0.045)*sj3);
IkReal x916=((0.045)*px);
IkReal x917=((0.045)*py);
IkReal x918=(pp+(((-1.0)*(pz*pz))));
j0eval[0]=x918;
j0eval[1]=((IKabs(((((-1.0)*px*x911))+(((-1.0)*x916))+((cj3*x916))+(((0.55)*x912))+((x912*x915))+((x912*x913)))))+(IKabs(((((-1.0)*cj3*x917))+((x914*x915))+(((0.55)*x914))+((x913*x914))+x917+((py*x911))))));
j0eval[2]=IKsign(x918);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j1)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=((-1.0)*pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj1=1.0;
cj1=0;
j1=1.5707963267949;
IkReal x919=pz*pz;
IkReal x920=sj3*sj3;
IkReal x921=cj3*cj3;
IkReal x922=((4.26078431372549)*cj3);
IkReal x923=((((-1.0)*pp))+x919);
IkReal x924=((1.20294117647059)*x921);
IkReal x925=((1.20294117647059)*x920);
j0eval[0]=x923;
j0eval[1]=((((-3.98071895424837)*x919))+(((-1.0)*sj3*x919))+((pp*sj3))+((pp*x925))+((pp*x922))+((pp*x924))+(((-1.0)*x919*x925))+(((-1.0)*x919*x922))+(((-1.0)*x919*x924))+(((3.98071895424837)*pp)));
j0eval[2]=IKsign(x923);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj1=1.0;
cj1=0;
j1=1.5707963267949;
IkReal x926=pz*pz;
IkReal x927=((0.00405)*sj3);
IkReal x928=((0.33)*cj3);
IkReal x929=((0.027)*cj3);
IkReal x930=((0.0495)*sj3);
j0eval[0]=((((-1.0)*x926))+pp);
j0eval[1]=IKsign(((((-0.09)*x926))+(((0.09)*pp))));
j0eval[2]=((IKabs(((((0.0495)*px))+(((-1.0)*py*x928))+(((-1.0)*py*x930))+((px*x927))+((px*x929))+(((-0.3925)*py))+((pp*py)))))+(IKabs(((((-1.0)*pp*px))+(((0.0495)*py))+((py*x929))+((py*x927))+((px*x928))+((px*x930))+(((0.3925)*px))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj1=1.0;
cj1=0;
j1=1.5707963267949;
IkReal x931=pz*pz;
IkReal x932=(cj3*py);
IkReal x933=(py*sj3);
IkReal x934=((1.0)*pp);
IkReal x935=(cj3*px);
IkReal x936=(px*sj3);
j0eval[0]=(x931+(((-1.0)*x934)));
j0eval[1]=IKsign(((((1.1)*x931))+(((-1.1)*pp))));
j0eval[2]=((IKabs(((((0.33)*x936))+(((0.0495)*px))+(((-0.0495)*x935))+(((0.027)*x933))+(((-1.0)*py*x934))+(((-0.00405)*x932))+(((-0.20845)*py)))))+(IKabs(((((0.0495)*x932))+(((-1.0)*px*x934))+(((-0.0495)*py))+(((-0.33)*x933))+(((0.027)*x936))+(((-0.00405)*x935))+(((-0.20845)*px))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x937=(cj3*py);
IkReal x938=(py*sj3);
IkReal x939=((1.0)*pp);
IkReal x940=(cj3*px);
IkReal x941=(px*sj3);
CheckValue<IkReal> x942=IKPowWithIntegerCheck(IKsign(((((-1.1)*pp))+(((1.1)*(pz*pz))))),-1);
if(!x942.valid){
continue;
}
CheckValue<IkReal> x943 = IKatan2WithCheck(IkReal(((((0.0495)*px))+(((0.33)*x941))+(((-0.0495)*x940))+(((0.027)*x938))+(((-1.0)*py*x939))+(((-0.00405)*x937))+(((-0.20845)*py)))),((((0.0495)*x937))+(((-0.00405)*x940))+(((-1.0)*px*x939))+(((-0.0495)*py))+(((0.027)*x941))+(((-0.33)*x938))+(((-0.20845)*px))),IKFAST_ATAN2_MAGTHRESH);
if(!x943.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x942.value)))+(x943.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x944=IKsin(j0);
IkReal x945=IKcos(j0);
IkReal x946=(px*x944);
IkReal x947=(py*x945);
IkReal x948=(px*x945);
IkReal x949=(py*x944);
evalcond[0]=((-0.55)+(((-0.045)*sj3))+(((-0.3)*cj3))+x948+x949);
evalcond[1]=((0.045)+(((-1.0)*x947))+(((-0.045)*cj3))+(((0.3)*sj3))+x946);
evalcond[2]=((-0.2125)+(((0.09)*x947))+(((-1.0)*pp))+(((1.1)*x948))+(((1.1)*x949))+(((-0.09)*x946)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x950=((0.33)*cj3);
IkReal x951=((0.027)*cj3);
IkReal x952=((0.00405)*sj3);
IkReal x953=((0.0495)*sj3);
CheckValue<IkReal> x954=IKPowWithIntegerCheck(IKsign(((((-0.09)*(pz*pz)))+(((0.09)*pp)))),-1);
if(!x954.valid){
continue;
}
CheckValue<IkReal> x955 = IKatan2WithCheck(IkReal((((px*x953))+((px*x950))+(((-1.0)*pp*px))+(((0.0495)*py))+((py*x951))+((py*x952))+(((0.3925)*px)))),((((-1.0)*py*x950))+(((-1.0)*py*x953))+((px*x951))+((px*x952))+(((0.0495)*px))+(((-0.3925)*py))+((pp*py))),IKFAST_ATAN2_MAGTHRESH);
if(!x955.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x954.value)))+(x955.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x956=IKsin(j0);
IkReal x957=IKcos(j0);
IkReal x958=(px*x956);
IkReal x959=(py*x957);
IkReal x960=(px*x957);
IkReal x961=(py*x956);
evalcond[0]=((-0.55)+(((-0.045)*sj3))+(((-0.3)*cj3))+x960+x961);
evalcond[1]=((0.045)+(((-1.0)*x959))+(((-0.045)*cj3))+(((0.3)*sj3))+x958);
evalcond[2]=((-0.2125)+(((-0.09)*x958))+(((0.09)*x959))+(((-1.0)*pp))+(((1.1)*x960))+(((1.1)*x961)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x962=((0.3)*py);
IkReal x963=((0.045)*px);
IkReal x964=((0.045)*py);
IkReal x965=((0.3)*px);
CheckValue<IkReal> x966=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp))+(pz*pz))),-1);
if(!x966.valid){
continue;
}
CheckValue<IkReal> x967 = IKatan2WithCheck(IkReal(((((-0.55)*py))+(((-1.0)*cj3*x963))+(((-1.0)*cj3*x962))+(((-1.0)*sj3*x964))+((sj3*x965))+x963)),((((-0.55)*px))+(((-1.0)*cj3*x965))+(((-1.0)*sj3*x963))+(((-1.0)*sj3*x962))+((cj3*x964))+(((-1.0)*x964))),IKFAST_ATAN2_MAGTHRESH);
if(!x967.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x966.value)))+(x967.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x968=IKsin(j0);
IkReal x969=IKcos(j0);
IkReal x970=(px*x968);
IkReal x971=(py*x969);
IkReal x972=(px*x969);
IkReal x973=(py*x968);
evalcond[0]=((-0.55)+(((-0.045)*sj3))+(((-0.3)*cj3))+x973+x972);
evalcond[1]=((0.045)+(((-1.0)*x971))+(((-0.045)*cj3))+(((0.3)*sj3))+x970);
evalcond[2]=((-0.2125)+(((-0.09)*x970))+(((0.09)*x971))+(((-1.0)*pp))+(((1.1)*x973))+(((1.1)*x972)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j1)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=pz;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj1=-1.0;
cj1=0;
j1=-1.5707963267949;
IkReal x974=pz*pz;
IkReal x975=sj3*sj3;
IkReal x976=cj3*cj3;
IkReal x977=((4.26078431372549)*cj3);
IkReal x978=((((-1.0)*x974))+pp);
IkReal x979=((1.20294117647059)*x976);
IkReal x980=((1.0)*x974);
IkReal x981=((1.20294117647059)*x975);
j0eval[0]=x978;
j0eval[1]=(((pp*x981))+(((-1.0)*x974*x981))+((pp*sj3))+((pp*x977))+((pp*x979))+(((-1.0)*x974*x977))+(((-1.0)*x974*x979))+(((-3.98071895424837)*x974))+(((3.98071895424837)*pp))+(((-1.0)*sj3*x980)));
j0eval[2]=IKsign(x978);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj1=-1.0;
cj1=0;
j1=-1.5707963267949;
IkReal x982=pz*pz;
IkReal x983=((0.00405)*sj3);
IkReal x984=((0.33)*cj3);
IkReal x985=((0.027)*cj3);
IkReal x986=((0.0495)*sj3);
j0eval[0]=((((-1.0)*x982))+pp);
j0eval[1]=IKsign(((((-0.09)*x982))+(((0.09)*pp))));
j0eval[2]=((IKabs(((((-1.0)*pp*px))+(((-1.0)*py*x983))+(((-1.0)*py*x985))+(((-0.0495)*py))+(((0.3925)*px))+((px*x986))+((px*x984)))))+(IKabs(((((-1.0)*px*x983))+(((-1.0)*px*x985))+(((-1.0)*py*x986))+(((-1.0)*py*x984))+(((-0.0495)*px))+(((-0.3925)*py))+((pp*py))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj1=-1.0;
cj1=0;
j1=-1.5707963267949;
IkReal x987=pz*pz;
IkReal x988=(cj3*py);
IkReal x989=(py*sj3);
IkReal x990=((1.0)*pp);
IkReal x991=(cj3*px);
IkReal x992=(px*sj3);
j0eval[0]=((((-1.0)*x987))+pp);
j0eval[1]=IKsign(((((-1.1)*x987))+(((1.1)*pp))));
j0eval[2]=((IKabs(((((-1.0)*px*x990))+(((0.0495)*py))+(((-0.00405)*x991))+(((0.33)*x989))+(((-0.0495)*x988))+(((0.027)*x992))+(((-0.20845)*px)))))+(IKabs(((((-0.33)*x992))+(((-1.0)*py*x990))+(((0.0495)*x991))+(((0.027)*x989))+(((-0.0495)*px))+(((-0.00405)*x988))+(((-0.20845)*py))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x993=(cj3*py);
IkReal x994=(py*sj3);
IkReal x995=((1.0)*pp);
IkReal x996=(cj3*px);
IkReal x997=(px*sj3);
CheckValue<IkReal> x998 = IKatan2WithCheck(IkReal(((((-0.33)*x997))+(((-1.0)*py*x995))+(((0.0495)*x996))+(((-0.00405)*x993))+(((-0.0495)*px))+(((0.027)*x994))+(((-0.20845)*py)))),((((-1.0)*px*x995))+(((0.0495)*py))+(((-0.00405)*x996))+(((0.33)*x994))+(((0.027)*x997))+(((-0.0495)*x993))+(((-0.20845)*px))),IKFAST_ATAN2_MAGTHRESH);
if(!x998.valid){
continue;
}
CheckValue<IkReal> x999=IKPowWithIntegerCheck(IKsign(((((-1.1)*(pz*pz)))+(((1.1)*pp)))),-1);
if(!x999.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x998.value)+(((1.5707963267949)*(x999.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1000=IKcos(j0);
IkReal x1001=IKsin(j0);
IkReal x1002=(px*x1001);
IkReal x1003=((1.0)*x1000);
IkReal x1004=(py*x1001);
evalcond[0]=((0.045)+x1002+(((-1.0)*py*x1003))+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[1]=((-0.55)+(((-0.045)*sj3))+(((-1.0)*x1004))+(((-0.3)*cj3))+(((-1.0)*px*x1003)));
evalcond[2]=((-0.2125)+(((-1.1)*px*x1000))+(((-1.1)*x1004))+(((0.09)*py*x1000))+(((-1.0)*pp))+(((-0.09)*x1002)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1005=((0.00405)*sj3);
IkReal x1006=((0.33)*cj3);
IkReal x1007=((0.027)*cj3);
IkReal x1008=((0.0495)*sj3);
CheckValue<IkReal> x1009 = IKatan2WithCheck(IkReal((((px*x1008))+((px*x1006))+(((-1.0)*pp*px))+(((-1.0)*py*x1005))+(((-1.0)*py*x1007))+(((-0.0495)*py))+(((0.3925)*px)))),((((-1.0)*py*x1008))+(((-1.0)*py*x1006))+(((-0.0495)*px))+(((-0.3925)*py))+(((-1.0)*px*x1007))+(((-1.0)*px*x1005))+((pp*py))),IKFAST_ATAN2_MAGTHRESH);
if(!x1009.valid){
continue;
}
CheckValue<IkReal> x1010=IKPowWithIntegerCheck(IKsign(((((-0.09)*(pz*pz)))+(((0.09)*pp)))),-1);
if(!x1010.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1009.value)+(((1.5707963267949)*(x1010.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1011=IKcos(j0);
IkReal x1012=IKsin(j0);
IkReal x1013=(px*x1012);
IkReal x1014=((1.0)*x1011);
IkReal x1015=(py*x1012);
evalcond[0]=((0.045)+x1013+(((-1.0)*py*x1014))+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[1]=((-0.55)+(((-0.045)*sj3))+(((-1.0)*px*x1014))+(((-0.3)*cj3))+(((-1.0)*x1015)));
evalcond[2]=((-0.2125)+(((-1.1)*px*x1011))+(((0.09)*py*x1011))+(((-1.1)*x1015))+(((-0.09)*x1013))+(((-1.0)*pp)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1016=((0.3)*py);
IkReal x1017=((0.045)*px);
IkReal x1018=((0.045)*py);
IkReal x1019=((0.3)*px);
CheckValue<IkReal> x1020=IKPowWithIntegerCheck(IKsign((pp+(((-1.0)*(pz*pz))))),-1);
if(!x1020.valid){
continue;
}
CheckValue<IkReal> x1021 = IKatan2WithCheck(IkReal(((((-0.55)*py))+(((-1.0)*x1017))+((cj3*x1017))+(((-1.0)*cj3*x1016))+(((-1.0)*sj3*x1019))+(((-1.0)*sj3*x1018)))),((((-0.55)*px))+x1018+((sj3*x1016))+(((-1.0)*cj3*x1018))+(((-1.0)*cj3*x1019))+(((-1.0)*sj3*x1017))),IKFAST_ATAN2_MAGTHRESH);
if(!x1021.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1020.value)))+(x1021.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1022=IKcos(j0);
IkReal x1023=IKsin(j0);
IkReal x1024=(px*x1023);
IkReal x1025=((1.0)*x1022);
IkReal x1026=(py*x1023);
evalcond[0]=((0.045)+x1024+(((-1.0)*py*x1025))+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[1]=((-0.55)+(((-0.045)*sj3))+(((-1.0)*x1026))+(((-0.3)*cj3))+(((-1.0)*px*x1025)));
evalcond[2]=((-0.2125)+(((-1.1)*x1026))+(((-1.1)*px*x1022))+(((-0.09)*x1024))+(((-1.0)*pp))+(((0.09)*py*x1022)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(pz))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)*cj1);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
IkReal x1027=((-1.0)*py);
sj2=1.0;
cj2=0;
j2=1.5707963267949;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x1027);
rxp0_1=(px*r20);
rxp1_0=(r21*x1027);
rxp1_1=(px*r21);
rxp2_0=(r22*x1027);
rxp2_1=(px*r22);
IkReal x1028=px*px;
IkReal x1029=py*py;
IkReal x1030=(sj1*x1028);
IkReal x1031=(sj1*x1029);
j0eval[0]=(x1030+x1031);
j0eval[1]=IKsign(((((20.0)*x1031))+(((20.0)*x1030))));
j0eval[2]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[4];
IkReal x1032=((-1.0)*py);
sj2=1.0;
cj2=0;
j2=1.5707963267949;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x1032);
rxp0_1=(px*r20);
rxp1_0=(r21*x1032);
rxp1_1=(px*r21);
rxp2_0=(r22*x1032);
rxp2_1=(px*r22);
IkReal x1033=px*px;
IkReal x1034=py*py;
j0eval[0]=(x1033+x1034);
j0eval[1]=289.0;
j0eval[2]=sj1;
j0eval[3]=IKsign(((((20.0)*x1033))+(((20.0)*x1034))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 || IKabs(j0eval[3]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j1))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*(px*px)))+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=-0.85;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
IkReal x1035=((-1.0)*py);
sj2=1.0;
cj2=0;
j2=1.5707963267949;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x1035);
rxp0_1=(px*r20);
rxp1_0=(r21*x1035);
rxp1_1=(px*r21);
rxp2_0=(r22*x1035);
rxp2_1=(px*r22);
sj1=0;
cj1=1.0;
j1=0;
IkReal x1036=py*py;
IkReal x1037=px*px;
j0eval[0]=((((-1.0)*x1037))+(((-1.0)*x1036)));
j0eval[1]=((IKabs(px))+(IKabs(py)));
j0eval[2]=IKsign(((((-18.0)*x1036))+(((-18.0)*x1037))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
CheckValue<IkReal> x1038=IKPowWithIntegerCheck(IKsign(((((-18.0)*(px*px)))+(((-18.0)*(py*py))))),-1);
if(!x1038.valid){
continue;
}
CheckValue<IkReal> x1039 = IKatan2WithCheck(IkReal(((187.0)*px)),((-187.0)*py),IKFAST_ATAN2_MAGTHRESH);
if(!x1039.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1038.value)))+(x1039.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1040=IKcos(j0);
IkReal x1041=IKsin(j0);
IkReal x1042=(px*x1041);
IkReal x1043=((1.0)*x1040);
evalcond[0]=(x1042+(((-1.0)*py*x1043)));
evalcond[1]=((((-1.0)*py*x1041))+(((-1.0)*px*x1043)));
evalcond[2]=((-0.935)+(((0.09)*py*x1040))+(((-0.09)*x1042)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j1)))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*(px*px)))+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=0.85;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
IkReal x1044=((-1.0)*py);
sj2=1.0;
cj2=0;
j2=1.5707963267949;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x1044);
rxp0_1=(px*r20);
rxp1_0=(r21*x1044);
rxp1_1=(px*r21);
rxp2_0=(r22*x1044);
rxp2_1=(px*r22);
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
IkReal x1045=py*py;
IkReal x1046=px*px;
j0eval[0]=((((-1.0)*x1046))+(((-1.0)*x1045)));
j0eval[1]=((IKabs(px))+(IKabs(py)));
j0eval[2]=IKsign(((((-18.0)*x1045))+(((-18.0)*x1046))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
CheckValue<IkReal> x1047=IKPowWithIntegerCheck(IKsign(((((-18.0)*(px*px)))+(((-18.0)*(py*py))))),-1);
if(!x1047.valid){
continue;
}
CheckValue<IkReal> x1048 = IKatan2WithCheck(IkReal(((187.0)*px)),((-187.0)*py),IKFAST_ATAN2_MAGTHRESH);
if(!x1048.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1047.value)))+(x1048.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1049=IKcos(j0);
IkReal x1050=IKsin(j0);
IkReal x1051=(px*x1050);
IkReal x1052=((1.0)*x1049);
evalcond[0]=(x1051+(((-1.0)*py*x1052)));
evalcond[1]=((((-1.0)*py*x1050))+(((-1.0)*px*x1052)));
evalcond[2]=((-0.935)+(((0.09)*py*x1049))+(((-0.09)*x1051)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1053=((17.0)*sj1);
CheckValue<IkReal> x1054=IKPowWithIntegerCheck(IKsign(((((20.0)*(px*px)))+(((20.0)*(py*py))))),-1);
if(!x1054.valid){
continue;
}
CheckValue<IkReal> x1055 = IKatan2WithCheck(IkReal((py*x1053)),(px*x1053),IKFAST_ATAN2_MAGTHRESH);
if(!x1055.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1054.value)))+(x1055.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1056=IKcos(j0);
IkReal x1057=IKsin(j0);
IkReal x1058=((1.0)*py);
IkReal x1059=((1.1)*sj1);
IkReal x1060=(px*x1057);
IkReal x1061=(px*x1056);
IkReal x1062=(py*x1057);
evalcond[0]=(x1060+(((-1.0)*x1056*x1058)));
evalcond[1]=((-0.85)+((sj1*x1062))+((sj1*x1061)));
evalcond[2]=((((0.85)*sj1))+(((-1.0)*x1057*x1058))+(((-1.0)*x1061)));
evalcond[3]=((-0.935)+(((0.09)*py*x1056))+((x1059*x1062))+((x1059*x1061))+(((-0.09)*x1060)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1063=((20.0)*sj1);
CheckValue<IkReal> x1064 = IKatan2WithCheck(IkReal(((17.0)*py)),((17.0)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1064.valid){
continue;
}
CheckValue<IkReal> x1065=IKPowWithIntegerCheck(IKsign((((x1063*(py*py)))+((x1063*(px*px))))),-1);
if(!x1065.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1064.value)+(((1.5707963267949)*(x1065.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1066=IKcos(j0);
IkReal x1067=IKsin(j0);
IkReal x1068=((1.0)*py);
IkReal x1069=((1.1)*sj1);
IkReal x1070=(px*x1067);
IkReal x1071=(px*x1066);
IkReal x1072=(py*x1067);
evalcond[0]=(x1070+(((-1.0)*x1066*x1068)));
evalcond[1]=((-0.85)+((sj1*x1071))+((sj1*x1072)));
evalcond[2]=((((0.85)*sj1))+(((-1.0)*x1071))+(((-1.0)*x1067*x1068)));
evalcond[3]=((-0.935)+((x1069*x1072))+((x1069*x1071))+(((0.09)*py*x1066))+(((-0.09)*x1070)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959)))))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j1), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
j3=0;
sj3=0;
cj3=1.0;
j1=0;
sj1=0;
cj1=1.0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
j3=0;
sj3=0;
cj3=1.0;
j1=0;
sj1=0;
cj1=1.0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1074 = IKatan2WithCheck(IkReal(((0.09)*py)),((-0.09)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1074.valid){
continue;
}
IkReal x1073=x1074.value;
j0array[0]=((-1.0)*x1073);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1073)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1075=IKsin(j0);
IkReal x1076=IKcos(j0);
evalcond[0]=(((px*x1076))+((py*x1075)));
evalcond[1]=((((-1.0)*py*x1076))+((px*x1075)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1078 = IKatan2WithCheck(IkReal(px),py,IKFAST_ATAN2_MAGTHRESH);
if(!x1078.valid){
continue;
}
IkReal x1077=x1078.value;
j0array[0]=((-1.0)*x1077);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1077)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1079=IKcos(j0);
IkReal x1080=IKsin(j0);
IkReal x1081=(px*x1080);
IkReal x1082=(py*x1079);
evalcond[0]=(x1081+(((-1.0)*x1082)));
evalcond[1]=((((-0.09)*x1081))+(((0.09)*x1082)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(((-3.14159265358979)+(IKfmod(j1, 6.28318530717959)))))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+(((-1.0)*pz)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
j3=0;
sj3=0;
cj3=1.0;
j1=3.14159265358979;
sj1=0;
cj1=-1.0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj2=1.0;
cj2=0;
j2=1.5707963267949;
j3=0;
sj3=0;
cj3=1.0;
j1=3.14159265358979;
sj1=0;
cj1=-1.0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1084 = IKatan2WithCheck(IkReal(((0.09)*py)),((-0.09)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1084.valid){
continue;
}
IkReal x1083=x1084.value;
j0array[0]=((-1.0)*x1083);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1083)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1085=IKcos(j0);
IkReal x1086=IKsin(j0);
IkReal x1087=((1.0)*x1085);
evalcond[0]=((((-1.0)*py*x1087))+((px*x1086)));
evalcond[1]=((((-1.0)*py*x1086))+(((-1.0)*px*x1087)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1089 = IKatan2WithCheck(IkReal(((-1.0)*py)),px,IKFAST_ATAN2_MAGTHRESH);
if(!x1089.valid){
continue;
}
IkReal x1088=x1089.value;
j0array[0]=((-1.0)*x1088);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1088)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1090=IKcos(j0);
IkReal x1091=IKsin(j0);
evalcond[0]=((((-1.0)*px*x1090))+(((-1.0)*py*x1091)));
evalcond[1]=((((0.09)*py*x1090))+(((-0.09)*px*x1091)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1092=((0.3)*py);
IkReal x1093=(cj3*sj1);
IkReal x1094=(px*sj1);
IkReal x1095=((0.3)*px);
IkReal x1096=((0.045)*py);
IkReal x1097=((0.045)*px);
CheckValue<IkReal> x1098 = IKatan2WithCheck(IkReal(((((0.55)*py*sj1))+(((-1.0)*x1097))+((sj1*sj3*x1096))+((x1092*x1093))+(((-1.0)*sj3*x1095))+((cj3*x1097)))),(x1096+(((-1.0)*cj3*x1096))+(((0.045)*sj3*x1094))+((x1093*x1095))+((sj3*x1092))+(((0.55)*x1094))),IKFAST_ATAN2_MAGTHRESH);
if(!x1098.valid){
continue;
}
CheckValue<IkReal> x1099=IKPowWithIntegerCheck(IKsign((pp+(((-1.0)*(pz*pz))))),-1);
if(!x1099.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1098.value)+(((1.5707963267949)*(x1099.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1100=IKsin(j0);
IkReal x1101=IKcos(j0);
IkReal x1102=((0.3)*cj3);
IkReal x1103=((0.045)*sj3);
IkReal x1104=(cj1*pz);
IkReal x1105=(px*x1100);
IkReal x1106=(px*x1101);
IkReal x1107=(py*x1100);
IkReal x1108=(py*x1101);
IkReal x1109=(sj1*x1107);
evalcond[0]=(((cj1*x1106))+((cj1*x1107))+(((-1.0)*pz*sj1)));
evalcond[1]=((0.045)+x1105+(((-1.0)*x1108))+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[2]=((-0.55)+x1104+x1109+((sj1*x1106))+(((-1.0)*x1103))+(((-1.0)*x1102)));
evalcond[3]=((((-1.0)*x1106))+(((-1.0)*x1107))+((sj1*x1103))+((sj1*x1102))+(((0.55)*sj1)));
evalcond[4]=((-0.2125)+(((0.09)*x1108))+(((-1.0)*pp))+(((1.1)*x1109))+(((1.1)*x1104))+(((-0.09)*x1105))+(((1.1)*sj1*x1106)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1110=((1.1)*pz);
IkReal x1111=((0.09)*cj1);
IkReal x1112=((0.2125)*cj1);
IkReal x1113=(cj1*pp);
IkReal x1114=((0.09)*pz*sj1);
CheckValue<IkReal> x1115=IKPowWithIntegerCheck(IKsign(((((-1.0)*x1111*(pz*pz)))+((pp*x1111)))),-1);
if(!x1115.valid){
continue;
}
CheckValue<IkReal> x1116 = IKatan2WithCheck(IkReal(((((-1.0)*px*x1112))+((py*x1114))+(((-1.0)*px*x1113))+((px*x1110)))),((((-1.0)*py*x1110))+((py*x1112))+((py*x1113))+((px*x1114))),IKFAST_ATAN2_MAGTHRESH);
if(!x1116.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1115.value)))+(x1116.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1117=IKsin(j0);
IkReal x1118=IKcos(j0);
IkReal x1119=((0.3)*cj3);
IkReal x1120=((0.045)*sj3);
IkReal x1121=(cj1*pz);
IkReal x1122=(px*x1117);
IkReal x1123=(px*x1118);
IkReal x1124=(py*x1117);
IkReal x1125=(py*x1118);
IkReal x1126=(sj1*x1124);
evalcond[0]=((((-1.0)*pz*sj1))+((cj1*x1124))+((cj1*x1123)));
evalcond[1]=((0.045)+x1122+(((-0.045)*cj3))+(((-1.0)*x1125))+(((0.3)*sj3)));
evalcond[2]=((-0.55)+x1121+x1126+((sj1*x1123))+(((-1.0)*x1120))+(((-1.0)*x1119)));
evalcond[3]=(((sj1*x1120))+(((-1.0)*x1124))+(((-1.0)*x1123))+((sj1*x1119))+(((0.55)*sj1)));
evalcond[4]=((-0.2125)+(((1.1)*sj1*x1123))+(((0.09)*x1125))+(((-1.0)*pp))+(((1.1)*x1121))+(((1.1)*x1126))+(((-0.09)*x1122)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1127=((0.045)*cj1);
IkReal x1128=(pz*sj1);
IkReal x1129=((0.3)*cj1*sj3);
CheckValue<IkReal> x1130=IKPowWithIntegerCheck(IKsign((((cj1*pp))+(((-1.0)*cj1*(pz*pz))))),-1);
if(!x1130.valid){
continue;
}
CheckValue<IkReal> x1131 = IKatan2WithCheck(IkReal((((cj3*px*x1127))+((py*x1128))+(((-1.0)*px*x1127))+(((-1.0)*px*x1129)))),(((px*x1128))+((py*x1129))+((py*x1127))+(((-1.0)*cj3*py*x1127))),IKFAST_ATAN2_MAGTHRESH);
if(!x1131.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1130.value)))+(x1131.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1132=IKsin(j0);
IkReal x1133=IKcos(j0);
IkReal x1134=((0.3)*cj3);
IkReal x1135=((0.045)*sj3);
IkReal x1136=(cj1*pz);
IkReal x1137=(px*x1132);
IkReal x1138=(px*x1133);
IkReal x1139=(py*x1132);
IkReal x1140=(py*x1133);
IkReal x1141=(sj1*x1139);
evalcond[0]=((((-1.0)*pz*sj1))+((cj1*x1139))+((cj1*x1138)));
evalcond[1]=((0.045)+x1137+(((-1.0)*x1140))+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[2]=((-0.55)+x1141+x1136+((sj1*x1138))+(((-1.0)*x1134))+(((-1.0)*x1135)));
evalcond[3]=(((sj1*x1134))+((sj1*x1135))+(((-1.0)*x1139))+(((-1.0)*x1138))+(((0.55)*sj1)));
evalcond[4]=((-0.2125)+(((1.1)*x1141))+(((1.1)*sj1*x1138))+(((-1.0)*pp))+(((-0.09)*x1137))+(((0.09)*x1140))+(((1.1)*x1136)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=((((-0.045)*cj1*sj3))+(((-0.55)*cj1))+pz+(((-0.3)*cj1*cj3)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
IkReal x1142=((0.045)*cj1);
IkReal x1143=(pz*sj1);
IkReal x1144=((0.3)*cj1*sj3);
IkReal x1145=(((cj1*pp))+(((-1.0)*cj1*(pz*pz))));
j0eval[0]=x1145;
j0eval[1]=IKsign(x1145);
j0eval[2]=((IKabs((((cj3*py*x1142))+((px*x1143))+(((-1.0)*py*x1144))+(((-1.0)*py*x1142)))))+(IKabs((((py*x1143))+(((-1.0)*cj3*px*x1142))+((px*x1142))+((px*x1144))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
IkReal x1146=pz*pz;
IkReal x1147=(cj1*pp);
IkReal x1148=((1.1)*pz);
IkReal x1149=((0.2125)*cj1);
IkReal x1150=(cj1*x1146);
IkReal x1151=((0.09)*pz*sj1);
j0eval[0]=(x1150+(((-1.0)*x1147)));
j0eval[1]=((IKabs(((((-1.0)*px*x1149))+(((-1.0)*py*x1151))+(((-1.0)*px*x1147))+((px*x1148)))))+(IKabs(((((-1.0)*px*x1151))+((py*x1147))+((py*x1149))+(((-1.0)*py*x1148))))));
j0eval[2]=IKsign(((((-0.09)*x1147))+(((0.09)*x1150))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
IkReal x1152=((0.3)*py);
IkReal x1153=(cj3*sj1);
IkReal x1154=((0.55)*sj1);
IkReal x1155=((0.3)*px);
IkReal x1156=((0.045)*py);
IkReal x1157=(sj1*sj3);
IkReal x1158=((0.045)*px);
IkReal x1159=(pp+(((-1.0)*(pz*pz))));
j0eval[0]=x1159;
j0eval[1]=((IKabs(((((-1.0)*x1156))+((cj3*x1156))+((x1153*x1155))+(((-1.0)*sj3*x1152))+((px*x1154))+((x1157*x1158)))))+(IKabs((x1158+((sj3*x1155))+((x1152*x1153))+(((-1.0)*cj3*x1158))+((x1156*x1157))+((py*x1154))))));
j0eval[2]=IKsign(x1159);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j1)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=pz;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj1=1.0;
cj1=0;
j1=1.5707963267949;
IkReal x1160=pz*pz;
IkReal x1161=sj3*sj3;
IkReal x1162=cj3*cj3;
IkReal x1163=((4.26078431372549)*cj3);
IkReal x1164=(x1160+(((-1.0)*pp)));
IkReal x1165=((1.20294117647059)*x1162);
IkReal x1166=((1.20294117647059)*x1161);
j0eval[0]=x1164;
j0eval[1]=(((pp*sj3))+(((-1.0)*sj3*x1160))+(((3.98071895424837)*pp))+((pp*x1163))+((pp*x1165))+((pp*x1166))+(((-1.0)*x1160*x1163))+(((-1.0)*x1160*x1165))+(((-1.0)*x1160*x1166))+(((-3.98071895424837)*x1160)));
j0eval[2]=IKsign(x1164);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj1=1.0;
cj1=0;
j1=1.5707963267949;
IkReal x1167=pz*pz;
IkReal x1168=((0.33)*cj3);
IkReal x1169=((1.0)*pp);
IkReal x1170=((0.027)*cj3);
IkReal x1171=((0.00405)*sj3);
IkReal x1172=((0.0495)*sj3);
j0eval[0]=(x1167+(((-1.0)*x1169)));
j0eval[1]=((IKabs(((((-1.0)*py*x1172))+(((-1.0)*py*x1168))+(((-0.0495)*px))+(((-1.0)*px*x1170))+(((-1.0)*px*x1171))+(((-0.3925)*py))+((pp*py)))))+(IKabs((((px*x1168))+((px*x1172))+(((-1.0)*py*x1171))+(((-1.0)*py*x1170))+(((-0.0495)*py))+(((-1.0)*px*x1169))+(((0.3925)*px))))));
j0eval[2]=IKsign(((((-0.09)*pp))+(((0.09)*x1167))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj1=1.0;
cj1=0;
j1=1.5707963267949;
IkReal x1173=pz*pz;
IkReal x1174=(cj3*py);
IkReal x1175=(py*sj3);
IkReal x1176=((1.0)*pp);
IkReal x1177=(cj3*px);
IkReal x1178=(px*sj3);
j0eval[0]=(x1173+(((-1.0)*x1176)));
j0eval[1]=IKsign(((((-1.1)*pp))+(((1.1)*x1173))));
j0eval[2]=((IKabs(((((-0.33)*x1178))+(((0.027)*x1175))+(((-0.00405)*x1174))+(((0.0495)*x1177))+(((-1.0)*py*x1176))+(((-0.0495)*px))+(((-0.20845)*py)))))+(IKabs(((((0.0495)*py))+(((0.027)*x1178))+(((-0.00405)*x1177))+(((-0.0495)*x1174))+(((-1.0)*px*x1176))+(((0.33)*x1175))+(((-0.20845)*px))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1179=(cj3*py);
IkReal x1180=(py*sj3);
IkReal x1181=((1.0)*pp);
IkReal x1182=(cj3*px);
IkReal x1183=(px*sj3);
CheckValue<IkReal> x1184=IKPowWithIntegerCheck(IKsign(((((-1.1)*pp))+(((1.1)*(pz*pz))))),-1);
if(!x1184.valid){
continue;
}
CheckValue<IkReal> x1185 = IKatan2WithCheck(IkReal(((((0.027)*x1180))+(((0.0495)*x1182))+(((-0.33)*x1183))+(((-0.00405)*x1179))+(((-1.0)*py*x1181))+(((-0.0495)*px))+(((-0.20845)*py)))),((((0.027)*x1183))+(((0.33)*x1180))+(((0.0495)*py))+(((-0.0495)*x1179))+(((-1.0)*px*x1181))+(((-0.00405)*x1182))+(((-0.20845)*px))),IKFAST_ATAN2_MAGTHRESH);
if(!x1185.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1184.value)))+(x1185.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1186=IKsin(j0);
IkReal x1187=IKcos(j0);
IkReal x1188=(px*x1186);
IkReal x1189=(py*x1187);
IkReal x1190=(px*x1187);
IkReal x1191=(py*x1186);
evalcond[0]=((-0.55)+(((-0.045)*sj3))+x1191+x1190+(((-0.3)*cj3)));
evalcond[1]=((-0.045)+x1188+(((0.045)*cj3))+(((-1.0)*x1189))+(((-0.3)*sj3)));
evalcond[2]=((-0.2125)+(((-0.09)*x1189))+(((0.09)*x1188))+(((-1.0)*pp))+(((1.1)*x1191))+(((1.1)*x1190)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1192=((0.00405)*sj3);
IkReal x1193=((0.33)*cj3);
IkReal x1194=((0.027)*cj3);
IkReal x1195=((0.0495)*sj3);
CheckValue<IkReal> x1196=IKPowWithIntegerCheck(IKsign(((((-0.09)*pp))+(((0.09)*(pz*pz))))),-1);
if(!x1196.valid){
continue;
}
CheckValue<IkReal> x1197 = IKatan2WithCheck(IkReal(((((-1.0)*pp*px))+(((-1.0)*py*x1192))+(((-1.0)*py*x1194))+(((-0.0495)*py))+((px*x1195))+((px*x1193))+(((0.3925)*px)))),((((-1.0)*py*x1193))+(((-1.0)*py*x1195))+(((-0.0495)*px))+(((-1.0)*px*x1194))+(((-1.0)*px*x1192))+(((-0.3925)*py))+((pp*py))),IKFAST_ATAN2_MAGTHRESH);
if(!x1197.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1196.value)))+(x1197.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1198=IKsin(j0);
IkReal x1199=IKcos(j0);
IkReal x1200=(px*x1198);
IkReal x1201=(py*x1199);
IkReal x1202=(px*x1199);
IkReal x1203=(py*x1198);
evalcond[0]=((-0.55)+(((-0.045)*sj3))+x1203+x1202+(((-0.3)*cj3)));
evalcond[1]=((-0.045)+x1200+(((0.045)*cj3))+(((-1.0)*x1201))+(((-0.3)*sj3)));
evalcond[2]=((-0.2125)+(((0.09)*x1200))+(((-1.0)*pp))+(((-0.09)*x1201))+(((1.1)*x1203))+(((1.1)*x1202)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1204=((0.3)*py);
IkReal x1205=((0.045)*px);
IkReal x1206=((0.045)*py);
IkReal x1207=((0.3)*px);
CheckValue<IkReal> x1208=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp))+(pz*pz))),-1);
if(!x1208.valid){
continue;
}
CheckValue<IkReal> x1209 = IKatan2WithCheck(IkReal(((((-0.55)*py))+(((-1.0)*sj3*x1206))+(((-1.0)*sj3*x1207))+(((-1.0)*cj3*x1204))+((cj3*x1205))+(((-1.0)*x1205)))),((((-0.55)*px))+x1206+(((-1.0)*sj3*x1205))+(((-1.0)*cj3*x1207))+(((-1.0)*cj3*x1206))+((sj3*x1204))),IKFAST_ATAN2_MAGTHRESH);
if(!x1209.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1208.value)))+(x1209.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1210=IKsin(j0);
IkReal x1211=IKcos(j0);
IkReal x1212=(px*x1210);
IkReal x1213=(py*x1211);
IkReal x1214=(px*x1211);
IkReal x1215=(py*x1210);
evalcond[0]=((-0.55)+(((-0.045)*sj3))+x1214+x1215+(((-0.3)*cj3)));
evalcond[1]=((-0.045)+x1212+(((0.045)*cj3))+(((-0.3)*sj3))+(((-1.0)*x1213)));
evalcond[2]=((-0.2125)+(((-0.09)*x1213))+(((0.09)*x1212))+(((-1.0)*pp))+(((1.1)*x1215))+(((1.1)*x1214)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j1)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=((-1.0)*pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj1=-1.0;
cj1=0;
j1=-1.5707963267949;
IkReal x1216=pz*pz;
IkReal x1217=sj3*sj3;
IkReal x1218=cj3*cj3;
IkReal x1219=((4.26078431372549)*cj3);
IkReal x1220=(pp+(((-1.0)*x1216)));
IkReal x1221=((1.20294117647059)*x1218);
IkReal x1222=((1.0)*x1216);
IkReal x1223=((1.20294117647059)*x1217);
j0eval[0]=x1220;
j0eval[1]=(((pp*x1219))+(((-1.0)*x1216*x1219))+((pp*sj3))+((pp*x1221))+((pp*x1223))+(((3.98071895424837)*pp))+(((-3.98071895424837)*x1216))+(((-1.0)*x1216*x1223))+(((-1.0)*x1216*x1221))+(((-1.0)*sj3*x1222)));
j0eval[2]=IKsign(x1220);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj1=-1.0;
cj1=0;
j1=-1.5707963267949;
IkReal x1224=pz*pz;
IkReal x1225=((0.33)*cj3);
IkReal x1226=((1.0)*pp);
IkReal x1227=((0.027)*cj3);
IkReal x1228=((0.00405)*sj3);
IkReal x1229=((0.0495)*sj3);
j0eval[0]=(x1224+(((-1.0)*x1226)));
j0eval[1]=((IKabs(((((0.0495)*px))+(((-1.0)*py*x1229))+(((-1.0)*py*x1225))+((px*x1228))+((px*x1227))+(((-0.3925)*py))+((pp*py)))))+(IKabs(((((-1.0)*px*x1226))+((py*x1228))+((py*x1227))+(((0.0495)*py))+((px*x1225))+((px*x1229))+(((0.3925)*px))))));
j0eval[2]=IKsign(((((-0.09)*pp))+(((0.09)*x1224))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj1=-1.0;
cj1=0;
j1=-1.5707963267949;
IkReal x1230=pz*pz;
IkReal x1231=(cj3*py);
IkReal x1232=(py*sj3);
IkReal x1233=((1.0)*pp);
IkReal x1234=(cj3*px);
IkReal x1235=(px*sj3);
j0eval[0]=((((-1.0)*x1230))+pp);
j0eval[1]=((IKabs(((((0.0495)*px))+(((-0.0495)*x1234))+(((0.027)*x1232))+(((-1.0)*py*x1233))+(((-0.00405)*x1231))+(((0.33)*x1235))+(((-0.20845)*py)))))+(IKabs(((((-1.0)*px*x1233))+(((0.0495)*x1231))+(((-0.0495)*py))+(((0.027)*x1235))+(((-0.00405)*x1234))+(((-0.33)*x1232))+(((-0.20845)*px))))));
j0eval[2]=IKsign(((((1.1)*pp))+(((-1.1)*x1230))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1236=(cj3*py);
IkReal x1237=(py*sj3);
IkReal x1238=((1.0)*pp);
IkReal x1239=(cj3*px);
IkReal x1240=(px*sj3);
CheckValue<IkReal> x1241 = IKatan2WithCheck(IkReal(((((0.0495)*px))+(((-0.0495)*x1239))+(((0.027)*x1237))+(((0.33)*x1240))+(((-1.0)*py*x1238))+(((-0.00405)*x1236))+(((-0.20845)*py)))),((((-1.0)*px*x1238))+(((0.0495)*x1236))+(((-0.0495)*py))+(((-0.00405)*x1239))+(((0.027)*x1240))+(((-0.33)*x1237))+(((-0.20845)*px))),IKFAST_ATAN2_MAGTHRESH);
if(!x1241.valid){
continue;
}
CheckValue<IkReal> x1242=IKPowWithIntegerCheck(IKsign(((((-1.1)*(pz*pz)))+(((1.1)*pp)))),-1);
if(!x1242.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1241.value)+(((1.5707963267949)*(x1242.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1243=IKcos(j0);
IkReal x1244=IKsin(j0);
IkReal x1245=(px*x1244);
IkReal x1246=((1.0)*x1243);
IkReal x1247=(py*x1244);
evalcond[0]=((-0.045)+x1245+(((0.045)*cj3))+(((-1.0)*py*x1246))+(((-0.3)*sj3)));
evalcond[1]=((-0.55)+(((-0.045)*sj3))+(((-1.0)*px*x1246))+(((-0.3)*cj3))+(((-1.0)*x1247)));
evalcond[2]=((-0.2125)+(((0.09)*x1245))+(((-0.09)*py*x1243))+(((-1.1)*x1247))+(((-1.0)*pp))+(((-1.1)*px*x1243)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1248=((0.33)*cj3);
IkReal x1249=((0.027)*cj3);
IkReal x1250=((0.00405)*sj3);
IkReal x1251=((0.0495)*sj3);
CheckValue<IkReal> x1252=IKPowWithIntegerCheck(IKsign(((((-0.09)*pp))+(((0.09)*(pz*pz))))),-1);
if(!x1252.valid){
continue;
}
CheckValue<IkReal> x1253 = IKatan2WithCheck(IkReal(((((-1.0)*pp*px))+(((0.0495)*py))+((py*x1249))+((px*x1248))+(((0.3925)*px))+((px*x1251))+((py*x1250)))),((((-1.0)*py*x1248))+(((0.0495)*px))+((px*x1249))+(((-1.0)*py*x1251))+((px*x1250))+(((-0.3925)*py))+((pp*py))),IKFAST_ATAN2_MAGTHRESH);
if(!x1253.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1252.value)))+(x1253.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1254=IKcos(j0);
IkReal x1255=IKsin(j0);
IkReal x1256=(px*x1255);
IkReal x1257=((1.0)*x1254);
IkReal x1258=(py*x1255);
evalcond[0]=((-0.045)+x1256+(((0.045)*cj3))+(((-1.0)*py*x1257))+(((-0.3)*sj3)));
evalcond[1]=((-0.55)+(((-0.045)*sj3))+(((-0.3)*cj3))+(((-1.0)*px*x1257))+(((-1.0)*x1258)));
evalcond[2]=((-0.2125)+(((-1.1)*px*x1254))+(((-1.0)*pp))+(((0.09)*x1256))+(((-0.09)*py*x1254))+(((-1.1)*x1258)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1259=((0.3)*py);
IkReal x1260=((0.045)*px);
IkReal x1261=((0.045)*py);
IkReal x1262=((0.3)*px);
CheckValue<IkReal> x1263=IKPowWithIntegerCheck(IKsign((pp+(((-1.0)*(pz*pz))))),-1);
if(!x1263.valid){
continue;
}
CheckValue<IkReal> x1264 = IKatan2WithCheck(IkReal(((((-0.55)*py))+x1260+(((-1.0)*cj3*x1260))+(((-1.0)*cj3*x1259))+(((-1.0)*sj3*x1261))+((sj3*x1262)))),((((-0.55)*px))+(((-1.0)*cj3*x1262))+((cj3*x1261))+(((-1.0)*sj3*x1259))+(((-1.0)*sj3*x1260))+(((-1.0)*x1261))),IKFAST_ATAN2_MAGTHRESH);
if(!x1264.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1263.value)))+(x1264.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1265=IKcos(j0);
IkReal x1266=IKsin(j0);
IkReal x1267=(px*x1266);
IkReal x1268=((1.0)*x1265);
IkReal x1269=(py*x1266);
evalcond[0]=((-0.045)+x1267+(((0.045)*cj3))+(((-1.0)*py*x1268))+(((-0.3)*sj3)));
evalcond[1]=((-0.55)+(((-0.045)*sj3))+(((-0.3)*cj3))+(((-1.0)*px*x1268))+(((-1.0)*x1269)));
evalcond[2]=((-0.2125)+(((-1.1)*px*x1265))+(((-1.0)*pp))+(((0.09)*x1267))+(((-0.09)*py*x1265))+(((-1.1)*x1269)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(pz))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)*cj1);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
IkReal x1270=((-1.0)*py);
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x1270);
rxp0_1=(px*r20);
rxp1_0=(r21*x1270);
rxp1_1=(px*r21);
rxp2_0=(r22*x1270);
rxp2_1=(px*r22);
IkReal x1271=px*px;
IkReal x1272=py*py;
IkReal x1273=(sj1*x1271);
IkReal x1274=(sj1*x1272);
j0eval[0]=(x1273+x1274);
j0eval[1]=IKsign(((((20.0)*x1274))+(((20.0)*x1273))));
j0eval[2]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[4];
IkReal x1275=((-1.0)*py);
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x1275);
rxp0_1=(px*r20);
rxp1_0=(r21*x1275);
rxp1_1=(px*r21);
rxp2_0=(r22*x1275);
rxp2_1=(px*r22);
IkReal x1276=px*px;
IkReal x1277=py*py;
j0eval[0]=(x1276+x1277);
j0eval[1]=289.0;
j0eval[2]=sj1;
j0eval[3]=IKsign(((((20.0)*x1277))+(((20.0)*x1276))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 || IKabs(j0eval[3]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j1))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*(px*px)))+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=-0.85;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
IkReal x1278=((-1.0)*py);
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x1278);
rxp0_1=(px*r20);
rxp1_0=(r21*x1278);
rxp1_1=(px*r21);
rxp2_0=(r22*x1278);
rxp2_1=(px*r22);
sj1=0;
cj1=1.0;
j1=0;
IkReal x1279=py*py;
IkReal x1280=px*px;
j0eval[0]=(x1279+x1280);
j0eval[1]=IKsign(((((18.0)*x1279))+(((18.0)*x1280))));
j0eval[2]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
CheckValue<IkReal> x1281=IKPowWithIntegerCheck(IKsign(((((18.0)*(py*py)))+(((18.0)*(px*px))))),-1);
if(!x1281.valid){
continue;
}
CheckValue<IkReal> x1282 = IKatan2WithCheck(IkReal(((187.0)*px)),((-187.0)*py),IKFAST_ATAN2_MAGTHRESH);
if(!x1282.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1281.value)))+(x1282.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1283=IKcos(j0);
IkReal x1284=IKsin(j0);
IkReal x1285=(px*x1284);
IkReal x1286=((1.0)*x1283);
evalcond[0]=(x1285+(((-1.0)*py*x1286)));
evalcond[1]=((((-1.0)*py*x1284))+(((-1.0)*px*x1286)));
evalcond[2]=((-0.935)+(((0.09)*x1285))+(((-0.09)*py*x1283)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j1)))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*(px*px)))+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=0.85;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
IkReal x1287=((-1.0)*py);
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x1287);
rxp0_1=(px*r20);
rxp1_0=(r21*x1287);
rxp1_1=(px*r21);
rxp2_0=(r22*x1287);
rxp2_1=(px*r22);
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
IkReal x1288=py*py;
IkReal x1289=px*px;
j0eval[0]=(x1289+x1288);
j0eval[1]=IKsign(((((18.0)*x1288))+(((18.0)*x1289))));
j0eval[2]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
CheckValue<IkReal> x1290=IKPowWithIntegerCheck(IKsign(((((18.0)*(py*py)))+(((18.0)*(px*px))))),-1);
if(!x1290.valid){
continue;
}
CheckValue<IkReal> x1291 = IKatan2WithCheck(IkReal(((187.0)*px)),((-187.0)*py),IKFAST_ATAN2_MAGTHRESH);
if(!x1291.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1290.value)))+(x1291.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1292=IKcos(j0);
IkReal x1293=IKsin(j0);
IkReal x1294=(px*x1293);
IkReal x1295=((1.0)*x1292);
evalcond[0]=(x1294+(((-1.0)*py*x1295)));
evalcond[1]=((((-1.0)*py*x1293))+(((-1.0)*px*x1295)));
evalcond[2]=((-0.935)+(((-0.09)*py*x1292))+(((0.09)*x1294)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1296=((17.0)*sj1);
CheckValue<IkReal> x1297 = IKatan2WithCheck(IkReal((py*x1296)),(px*x1296),IKFAST_ATAN2_MAGTHRESH);
if(!x1297.valid){
continue;
}
CheckValue<IkReal> x1298=IKPowWithIntegerCheck(IKsign(((((20.0)*(px*px)))+(((20.0)*(py*py))))),-1);
if(!x1298.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1297.value)+(((1.5707963267949)*(x1298.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1299=IKcos(j0);
IkReal x1300=IKsin(j0);
IkReal x1301=((1.0)*py);
IkReal x1302=((1.1)*sj1);
IkReal x1303=(px*x1300);
IkReal x1304=(px*x1299);
IkReal x1305=(py*x1300);
evalcond[0]=(x1303+(((-1.0)*x1299*x1301)));
evalcond[1]=((-0.85)+((sj1*x1305))+((sj1*x1304)));
evalcond[2]=((((-1.0)*x1304))+(((-1.0)*x1300*x1301))+(((0.85)*sj1)));
evalcond[3]=((-0.935)+(((0.09)*x1303))+(((-0.09)*py*x1299))+((x1302*x1305))+((x1302*x1304)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1306=((20.0)*sj1);
CheckValue<IkReal> x1307 = IKatan2WithCheck(IkReal(((17.0)*py)),((17.0)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1307.valid){
continue;
}
CheckValue<IkReal> x1308=IKPowWithIntegerCheck(IKsign((((x1306*(px*px)))+((x1306*(py*py))))),-1);
if(!x1308.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1307.value)+(((1.5707963267949)*(x1308.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1309=IKcos(j0);
IkReal x1310=IKsin(j0);
IkReal x1311=((1.0)*py);
IkReal x1312=((1.1)*sj1);
IkReal x1313=(px*x1310);
IkReal x1314=(px*x1309);
IkReal x1315=(py*x1310);
evalcond[0]=(x1313+(((-1.0)*x1309*x1311)));
evalcond[1]=((-0.85)+((sj1*x1314))+((sj1*x1315)));
evalcond[2]=((((-1.0)*x1314))+(((0.85)*sj1))+(((-1.0)*x1310*x1311)));
evalcond[3]=((-0.935)+(((0.09)*x1313))+(((-0.09)*py*x1309))+((x1312*x1315))+((x1312*x1314)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959)))))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j1), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
j3=0;
sj3=0;
cj3=1.0;
j1=0;
sj1=0;
cj1=1.0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
j3=0;
sj3=0;
cj3=1.0;
j1=0;
sj1=0;
cj1=1.0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1317 = IKatan2WithCheck(IkReal(((-0.09)*py)),((0.09)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1317.valid){
continue;
}
IkReal x1316=x1317.value;
j0array[0]=((-1.0)*x1316);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1316)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1318=IKcos(j0);
IkReal x1319=IKsin(j0);
IkReal x1320=((1.0)*x1318);
evalcond[0]=(((px*x1319))+(((-1.0)*py*x1320)));
evalcond[1]=((((-1.0)*py*x1319))+(((-1.0)*px*x1320)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1322 = IKatan2WithCheck(IkReal(((-1.0)*py)),px,IKFAST_ATAN2_MAGTHRESH);
if(!x1322.valid){
continue;
}
IkReal x1321=x1322.value;
j0array[0]=((-1.0)*x1321);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1321)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1323=IKsin(j0);
IkReal x1324=IKcos(j0);
evalcond[0]=((((-1.0)*px*x1324))+(((-1.0)*py*x1323)));
evalcond[1]=((((0.09)*px*x1323))+(((-0.09)*py*x1324)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(((-3.14159265358979)+(IKfmod(j1, 6.28318530717959)))))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+(((-1.0)*pz)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
j3=0;
sj3=0;
cj3=1.0;
j1=3.14159265358979;
sj1=0;
cj1=-1.0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
j3=0;
sj3=0;
cj3=1.0;
j1=3.14159265358979;
sj1=0;
cj1=-1.0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1326 = IKatan2WithCheck(IkReal(((-0.09)*py)),((0.09)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1326.valid){
continue;
}
IkReal x1325=x1326.value;
j0array[0]=((-1.0)*x1325);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1325)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1327=IKsin(j0);
IkReal x1328=IKcos(j0);
evalcond[0]=(((py*x1327))+((px*x1328)));
evalcond[1]=(((px*x1327))+(((-1.0)*py*x1328)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1330 = IKatan2WithCheck(IkReal(px),py,IKFAST_ATAN2_MAGTHRESH);
if(!x1330.valid){
continue;
}
IkReal x1329=x1330.value;
j0array[0]=((-1.0)*x1329);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1329)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1331=IKsin(j0);
IkReal x1332=IKcos(j0);
IkReal x1333=(px*x1331);
IkReal x1334=(py*x1332);
evalcond[0]=(x1333+(((-1.0)*x1334)));
evalcond[1]=((((-0.09)*x1334))+(((0.09)*x1333)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1335=((0.3)*py);
IkReal x1336=(cj3*sj1);
IkReal x1337=((0.55)*sj1);
IkReal x1338=((0.3)*px);
IkReal x1339=((0.045)*py);
IkReal x1340=(sj1*sj3);
IkReal x1341=((0.045)*px);
CheckValue<IkReal> x1342=IKPowWithIntegerCheck(IKsign((pp+(((-1.0)*(pz*pz))))),-1);
if(!x1342.valid){
continue;
}
CheckValue<IkReal> x1343 = IKatan2WithCheck(IkReal((x1341+((x1339*x1340))+((x1335*x1336))+((py*x1337))+(((-1.0)*cj3*x1341))+((sj3*x1338)))),(((px*x1337))+((x1336*x1338))+((x1340*x1341))+((cj3*x1339))+(((-1.0)*sj3*x1335))+(((-1.0)*x1339))),IKFAST_ATAN2_MAGTHRESH);
if(!x1343.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1342.value)))+(x1343.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1344=IKsin(j0);
IkReal x1345=IKcos(j0);
IkReal x1346=((1.1)*sj1);
IkReal x1347=((0.3)*cj3);
IkReal x1348=((0.045)*sj3);
IkReal x1349=((1.0)*cj1);
IkReal x1350=(cj1*pz);
IkReal x1351=(px*x1344);
IkReal x1352=(px*x1345);
IkReal x1353=(py*x1344);
IkReal x1354=(py*x1345);
evalcond[0]=(((pz*sj1))+(((-1.0)*x1349*x1353))+(((-1.0)*x1349*x1352)));
evalcond[1]=((-0.045)+x1351+(((-1.0)*x1354))+(((0.045)*cj3))+(((-0.3)*sj3)));
evalcond[2]=((-0.55)+x1350+((sj1*x1352))+((sj1*x1353))+(((-1.0)*x1348))+(((-1.0)*x1347)));
evalcond[3]=((((-1.0)*x1353))+(((-1.0)*x1352))+((sj1*x1348))+((sj1*x1347))+(((0.55)*sj1)));
evalcond[4]=((-0.2125)+(((-0.09)*x1354))+(((0.09)*x1351))+(((-1.0)*pp))+((x1346*x1353))+((x1346*x1352))+(((1.1)*x1350)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1355=((1.1)*pz);
IkReal x1356=((0.2125)*cj1);
IkReal x1357=((0.09)*cj1);
IkReal x1358=(cj1*pp);
IkReal x1359=((0.09)*pz*sj1);
CheckValue<IkReal> x1360 = IKatan2WithCheck(IkReal(((((-1.0)*px*x1358))+(((-1.0)*px*x1356))+((px*x1355))+(((-1.0)*py*x1359)))),((((-1.0)*px*x1359))+((py*x1358))+((py*x1356))+(((-1.0)*py*x1355))),IKFAST_ATAN2_MAGTHRESH);
if(!x1360.valid){
continue;
}
CheckValue<IkReal> x1361=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp*x1357))+((x1357*(pz*pz))))),-1);
if(!x1361.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1360.value)+(((1.5707963267949)*(x1361.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1362=IKsin(j0);
IkReal x1363=IKcos(j0);
IkReal x1364=((1.1)*sj1);
IkReal x1365=((0.3)*cj3);
IkReal x1366=((0.045)*sj3);
IkReal x1367=((1.0)*cj1);
IkReal x1368=(cj1*pz);
IkReal x1369=(px*x1362);
IkReal x1370=(px*x1363);
IkReal x1371=(py*x1362);
IkReal x1372=(py*x1363);
evalcond[0]=((((-1.0)*x1367*x1371))+(((-1.0)*x1367*x1370))+((pz*sj1)));
evalcond[1]=((-0.045)+x1369+(((0.045)*cj3))+(((-1.0)*x1372))+(((-0.3)*sj3)));
evalcond[2]=((-0.55)+x1368+((sj1*x1370))+((sj1*x1371))+(((-1.0)*x1366))+(((-1.0)*x1365)));
evalcond[3]=((((-1.0)*x1371))+(((-1.0)*x1370))+((sj1*x1366))+((sj1*x1365))+(((0.55)*sj1)));
evalcond[4]=((-0.2125)+(((1.1)*x1368))+(((0.09)*x1369))+(((-1.0)*pp))+(((-0.09)*x1372))+((x1364*x1371))+((x1364*x1370)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1373=((0.045)*cj1);
IkReal x1374=(pz*sj1);
IkReal x1375=((0.3)*cj1*sj3);
CheckValue<IkReal> x1376=IKPowWithIntegerCheck(IKsign((((cj1*pp))+(((-1.0)*cj1*(pz*pz))))),-1);
if(!x1376.valid){
continue;
}
CheckValue<IkReal> x1377 = IKatan2WithCheck(IkReal((((px*x1375))+((px*x1373))+((py*x1374))+(((-1.0)*cj3*px*x1373)))),(((px*x1374))+((cj3*py*x1373))+(((-1.0)*py*x1375))+(((-1.0)*py*x1373))),IKFAST_ATAN2_MAGTHRESH);
if(!x1377.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1376.value)))+(x1377.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1378=IKsin(j0);
IkReal x1379=IKcos(j0);
IkReal x1380=((1.1)*sj1);
IkReal x1381=((0.3)*cj3);
IkReal x1382=((0.045)*sj3);
IkReal x1383=((1.0)*cj1);
IkReal x1384=(cj1*pz);
IkReal x1385=(px*x1378);
IkReal x1386=(px*x1379);
IkReal x1387=(py*x1378);
IkReal x1388=(py*x1379);
evalcond[0]=((((-1.0)*x1383*x1387))+(((-1.0)*x1383*x1386))+((pz*sj1)));
evalcond[1]=((-0.045)+x1385+(((0.045)*cj3))+(((-1.0)*x1388))+(((-0.3)*sj3)));
evalcond[2]=((-0.55)+(((-1.0)*x1382))+(((-1.0)*x1381))+x1384+((sj1*x1387))+((sj1*x1386)));
evalcond[3]=(((sj1*x1382))+((sj1*x1381))+(((-1.0)*x1386))+(((-1.0)*x1387))+(((0.55)*sj1)));
evalcond[4]=((-0.2125)+((x1380*x1386))+((x1380*x1387))+(((-0.09)*x1388))+(((1.1)*x1384))+(((-1.0)*pp))+(((0.09)*x1385)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1389=((-0.55)+(((-0.045)*sj3))+(((-0.3)*cj3))+pz);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j1))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=x1389;
evalcond[3]=x1389;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=1.0;
j1=0;
IkReal x1390=((0.3)*sj3);
IkReal x1391=(px*sj2);
IkReal x1392=((0.045)*py);
IkReal x1393=(pp+(((-1.0)*(pz*pz))));
IkReal x1394=(cj3*x1392);
IkReal x1395=((0.045)*cj2*px);
j0eval[0]=x1393;
j0eval[1]=((IKabs((((cj2*x1392))+(((-1.0)*x1390*x1391))+(((0.045)*cj3*x1391))+(((-1.0)*cj2*x1394))+(((-0.045)*x1391))+((cj2*py*x1390)))))+(IKabs((x1395+((py*sj2*x1390))+((sj2*x1392))+(((-1.0)*cj3*x1395))+((cj2*px*x1390))+(((-1.0)*sj2*x1394))))));
j0eval[2]=IKsign(x1393);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
sj1=0;
cj1=1.0;
j1=0;
IkReal x1396=((((-1.0)*cj2*pp))+((cj2*(pz*pz))));
j0eval[0]=x1396;
j0eval[1]=IKsign(x1396);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
sj1=0;
cj1=1.0;
j1=0;
IkReal x1397=((((-1.0)*pp*sj2))+((sj2*(pz*pz))));
j0eval[0]=x1397;
j0eval[1]=IKsign(x1397);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
IkReal x1398=x1389;
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j2))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=x1398;
evalcond[3]=x1398;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=1.0;
j1=0;
sj2=0;
cj2=1.0;
j2=0;
IkReal x1399=((20.0)*sj3);
IkReal x1400=((3.0)*px);
IkReal x1401=((3.0)*py);
IkReal x1402=(pp+(((-1.0)*(pz*pz))));
j0eval[0]=x1402;
j0eval[1]=((IKabs(((((-1.0)*cj3*x1401))+((py*x1399))+x1401)))+(IKabs((((px*x1399))+(((-1.0)*cj3*x1400))+x1400))));
j0eval[2]=IKsign(x1402);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj1=0;
cj1=1.0;
j1=0;
sj2=0;
cj2=1.0;
j2=0;
IkReal x1403=pz*pz;
IkReal x1404=((80.0)*pp);
IkReal x1405=((88.0)*pz);
j0eval[0]=((((-1.0)*pp))+x1403);
j0eval[1]=IKsign(((((-9.0)*pp))+(((9.0)*x1403))));
j0eval[2]=((IKabs((((py*x1405))+(((-17.0)*py))+(((-1.0)*py*x1404)))))+(IKabs((((px*x1405))+(((-1.0)*px*x1404))+(((-17.0)*px))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj2=0;
cj2=1.0;
j2=0;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj2=0;
cj2=1.0;
j2=0;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1407 = IKatan2WithCheck(IkReal(((0.09)*px)),((0.09)*py),IKFAST_ATAN2_MAGTHRESH);
if(!x1407.valid){
continue;
}
IkReal x1406=x1407.value;
j0array[0]=((-1.0)*x1406);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1406)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1408=IKcos(j0);
IkReal x1409=IKsin(j0);
IkReal x1410=((1.0)*x1408);
evalcond[0]=(((px*x1409))+(((-1.0)*py*x1410)));
evalcond[1]=((((-1.0)*py*x1409))+(((-1.0)*px*x1410)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1412 = IKatan2WithCheck(IkReal(((-1.0)*py)),px,IKFAST_ATAN2_MAGTHRESH);
if(!x1412.valid){
continue;
}
IkReal x1411=x1412.value;
j0array[0]=((-1.0)*x1411);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1411)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1413=IKcos(j0);
IkReal x1414=IKsin(j0);
IkReal x1415=(py*x1414);
IkReal x1416=(px*x1413);
evalcond[0]=((((-1.0)*x1416))+(((-1.0)*x1415)));
evalcond[1]=((((0.09)*x1416))+(((0.09)*x1415)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1417=((110.0)*pz);
IkReal x1418=((100.0)*pp);
CheckValue<IkReal> x1419=IKPowWithIntegerCheck(IKsign(((((-9.0)*pp))+(((9.0)*(pz*pz))))),-1);
if(!x1419.valid){
continue;
}
CheckValue<IkReal> x1420 = IKatan2WithCheck(IkReal((((py*x1417))+(((-21.25)*py))+(((-1.0)*py*x1418)))),(((px*x1417))+(((-21.25)*px))+(((-1.0)*px*x1418))),IKFAST_ATAN2_MAGTHRESH);
if(!x1420.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1419.value)))+(x1420.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1421=IKcos(j0);
IkReal x1422=IKsin(j0);
IkReal x1423=((1.0)*py);
IkReal x1424=(px*x1421);
evalcond[0]=((((-1.0)*x1421*x1423))+((px*x1422)));
evalcond[1]=((0.045)+(((-0.045)*cj3))+(((-1.0)*x1424))+(((-1.0)*x1422*x1423))+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((0.09)*py*x1422))+(((-1.0)*pp))+(((1.1)*pz))+(((0.09)*x1424)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1425=((0.3)*sj3);
IkReal x1426=((0.045)*px);
IkReal x1427=((0.045)*py);
CheckValue<IkReal> x1428=IKPowWithIntegerCheck(IKsign((pp+(((-1.0)*(pz*pz))))),-1);
if(!x1428.valid){
continue;
}
CheckValue<IkReal> x1429 = IKatan2WithCheck(IkReal((x1427+(((-1.0)*cj3*x1427))+((py*x1425)))),(x1426+((px*x1425))+(((-1.0)*cj3*x1426))),IKFAST_ATAN2_MAGTHRESH);
if(!x1429.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1428.value)))+(x1429.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1430=IKcos(j0);
IkReal x1431=IKsin(j0);
IkReal x1432=((1.0)*py);
IkReal x1433=(px*x1430);
evalcond[0]=(((px*x1431))+(((-1.0)*x1430*x1432)));
evalcond[1]=((0.045)+(((-1.0)*x1433))+(((-1.0)*x1431*x1432))+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((0.09)*x1433))+(((-1.0)*pp))+(((1.1)*pz))+(((0.09)*py*x1431)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1434=x1389;
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=x1434;
evalcond[3]=x1434;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=1.0;
j1=0;
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x1435=((20.0)*sj3);
IkReal x1436=((3.0)*px);
IkReal x1437=((3.0)*py);
IkReal x1438=((((-1.0)*pp))+(pz*pz));
j0eval[0]=x1438;
j0eval[1]=((IKabs(((((-1.0)*cj3*x1437))+((py*x1435))+x1437)))+(IKabs((((px*x1435))+(((-1.0)*cj3*x1436))+x1436))));
j0eval[2]=IKsign(x1438);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj1=0;
cj1=1.0;
j1=0;
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x1439=pz*pz;
IkReal x1440=((80.0)*pp);
IkReal x1441=((88.0)*pz);
j0eval[0]=((((-1.0)*x1439))+pp);
j0eval[1]=IKsign(((((-9.0)*x1439))+(((9.0)*pp))));
j0eval[2]=((IKabs(((((-1.0)*py*x1440))+((py*x1441))+(((-17.0)*py)))))+(IKabs(((((-1.0)*px*x1440))+((px*x1441))+(((-17.0)*px))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1443 = IKatan2WithCheck(IkReal(((-0.09)*px)),((-0.09)*py),IKFAST_ATAN2_MAGTHRESH);
if(!x1443.valid){
continue;
}
IkReal x1442=x1443.value;
j0array[0]=((-1.0)*x1442);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1442)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1444=IKsin(j0);
IkReal x1445=IKcos(j0);
evalcond[0]=(((py*x1444))+((px*x1445)));
evalcond[1]=((((-1.0)*py*x1445))+((px*x1444)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1447 = IKatan2WithCheck(IkReal(px),py,IKFAST_ATAN2_MAGTHRESH);
if(!x1447.valid){
continue;
}
IkReal x1446=x1447.value;
j0array[0]=((-1.0)*x1446);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1446)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1448=IKcos(j0);
IkReal x1449=IKsin(j0);
evalcond[0]=((((-1.0)*py*x1448))+((px*x1449)));
evalcond[1]=((((-0.09)*py*x1449))+(((-0.09)*px*x1448)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1450=((110.0)*pz);
IkReal x1451=((100.0)*pp);
CheckValue<IkReal> x1452 = IKatan2WithCheck(IkReal((((py*x1450))+(((-21.25)*py))+(((-1.0)*py*x1451)))),(((px*x1450))+(((-1.0)*px*x1451))+(((-21.25)*px))),IKFAST_ATAN2_MAGTHRESH);
if(!x1452.valid){
continue;
}
CheckValue<IkReal> x1453=IKPowWithIntegerCheck(IKsign(((((9.0)*pp))+(((-9.0)*(pz*pz))))),-1);
if(!x1453.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1452.value)+(((1.5707963267949)*(x1453.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1454=IKsin(j0);
IkReal x1455=IKcos(j0);
IkReal x1456=(px*x1455);
IkReal x1457=(py*x1454);
evalcond[0]=(((px*x1454))+(((-1.0)*py*x1455)));
evalcond[1]=((0.045)+(((-0.045)*cj3))+x1456+x1457+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((-1.0)*pp))+(((-0.09)*x1457))+(((-0.09)*x1456))+(((1.1)*pz)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1458=((0.3)*sj3);
IkReal x1459=((0.045)*px);
IkReal x1460=((0.045)*py);
CheckValue<IkReal> x1461 = IKatan2WithCheck(IkReal((((py*x1458))+(((-1.0)*cj3*x1460))+x1460)),((((-1.0)*cj3*x1459))+((px*x1458))+x1459),IKFAST_ATAN2_MAGTHRESH);
if(!x1461.valid){
continue;
}
CheckValue<IkReal> x1462=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp))+(pz*pz))),-1);
if(!x1462.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1461.value)+(((1.5707963267949)*(x1462.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1463=IKsin(j0);
IkReal x1464=IKcos(j0);
IkReal x1465=(px*x1464);
IkReal x1466=(py*x1463);
evalcond[0]=((((-1.0)*py*x1464))+((px*x1463)));
evalcond[1]=((0.045)+(((-0.045)*cj3))+x1465+x1466+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((-1.0)*pp))+(((1.1)*pz))+(((-0.09)*x1465))+(((-0.09)*x1466)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1467=x1389;
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=x1467;
evalcond[3]=x1467;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=1.0;
j1=0;
sj2=1.0;
cj2=0;
j2=1.5707963267949;
IkReal x1468=((20.0)*sj3);
IkReal x1469=((3.0)*px);
IkReal x1470=((3.0)*py);
IkReal x1471=((((-1.0)*pp))+(pz*pz));
j0eval[0]=x1471;
j0eval[1]=((IKabs(((((-1.0)*py*x1468))+((cj3*x1470))+(((-1.0)*x1470)))))+(IKabs(((((-1.0)*cj3*x1469))+((px*x1468))+x1469))));
j0eval[2]=IKsign(x1471);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj1=0;
cj1=1.0;
j1=0;
sj2=1.0;
cj2=0;
j2=1.5707963267949;
IkReal x1472=pz*pz;
IkReal x1473=((80.0)*pp);
IkReal x1474=((88.0)*pz);
j0eval[0]=((((-1.0)*x1472))+pp);
j0eval[1]=IKsign(((((-9.0)*x1472))+(((9.0)*pp))));
j0eval[2]=((IKabs(((((17.0)*py))+(((-1.0)*py*x1474))+((py*x1473)))))+(IKabs(((((-1.0)*px*x1473))+(((-17.0)*px))+((px*x1474))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1476 = IKatan2WithCheck(IkReal(((0.09)*py)),((-0.09)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1476.valid){
continue;
}
IkReal x1475=x1476.value;
j0array[0]=((-1.0)*x1475);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1475)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1477=IKsin(j0);
IkReal x1478=IKcos(j0);
evalcond[0]=(((py*x1477))+((px*x1478)));
evalcond[1]=((((-1.0)*py*x1478))+((px*x1477)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1480 = IKatan2WithCheck(IkReal(px),py,IKFAST_ATAN2_MAGTHRESH);
if(!x1480.valid){
continue;
}
IkReal x1479=x1480.value;
j0array[0]=((-1.0)*x1479);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1479)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1481=IKcos(j0);
IkReal x1482=IKsin(j0);
IkReal x1483=(px*x1482);
IkReal x1484=(py*x1481);
evalcond[0]=((((-1.0)*x1484))+x1483);
evalcond[1]=((((0.09)*x1484))+(((-0.09)*x1483)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1485=((110.0)*pz);
IkReal x1486=((100.0)*pp);
CheckValue<IkReal> x1487 = IKatan2WithCheck(IkReal(((((-1.0)*px*x1486))+(((-21.25)*px))+((px*x1485)))),(((py*x1486))+(((21.25)*py))+(((-1.0)*py*x1485))),IKFAST_ATAN2_MAGTHRESH);
if(!x1487.valid){
continue;
}
CheckValue<IkReal> x1488=IKPowWithIntegerCheck(IKsign(((((9.0)*pp))+(((-9.0)*(pz*pz))))),-1);
if(!x1488.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1487.value)+(((1.5707963267949)*(x1488.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1489=IKsin(j0);
IkReal x1490=IKcos(j0);
IkReal x1491=(px*x1489);
IkReal x1492=(py*x1490);
evalcond[0]=(((py*x1489))+((px*x1490)));
evalcond[1]=((0.045)+(((-1.0)*x1492))+(((-0.045)*cj3))+x1491+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((0.09)*x1492))+(((-0.09)*x1491))+(((-1.0)*pp))+(((1.1)*pz)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1493=((0.3)*sj3);
IkReal x1494=((0.045)*px);
IkReal x1495=((0.045)*py);
CheckValue<IkReal> x1496 = IKatan2WithCheck(IkReal(((((-1.0)*cj3*x1494))+x1494+((px*x1493)))),(((cj3*x1495))+(((-1.0)*x1495))+(((-1.0)*py*x1493))),IKFAST_ATAN2_MAGTHRESH);
if(!x1496.valid){
continue;
}
CheckValue<IkReal> x1497=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp))+(pz*pz))),-1);
if(!x1497.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1496.value)+(((1.5707963267949)*(x1497.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1498=IKsin(j0);
IkReal x1499=IKcos(j0);
IkReal x1500=(px*x1498);
IkReal x1501=(py*x1499);
evalcond[0]=(((py*x1498))+((px*x1499)));
evalcond[1]=((0.045)+(((-1.0)*x1501))+(((-0.045)*cj3))+x1500+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((-0.09)*x1500))+(((0.09)*x1501))+(((-1.0)*pp))+(((1.1)*pz)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1502=x1389;
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=x1502;
evalcond[3]=x1502;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=1.0;
j1=0;
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
IkReal x1503=((20.0)*sj3);
IkReal x1504=((3.0)*px);
IkReal x1505=((3.0)*py);
IkReal x1506=((((-1.0)*pp))+(pz*pz));
j0eval[0]=x1506;
j0eval[1]=((IKabs((x1505+(((-1.0)*cj3*x1505))+((py*x1503)))))+(IKabs(((((-1.0)*x1504))+((cj3*x1504))+(((-1.0)*px*x1503))))));
j0eval[2]=IKsign(x1506);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj1=0;
cj1=1.0;
j1=0;
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
IkReal x1507=pz*pz;
IkReal x1508=((80.0)*pp);
IkReal x1509=((88.0)*pz);
j0eval[0]=((((-1.0)*pp))+x1507);
j0eval[1]=IKsign(((((-9.0)*pp))+(((9.0)*x1507))));
j0eval[2]=((IKabs(((((17.0)*py))+((py*x1508))+(((-1.0)*py*x1509)))))+(IKabs(((((-1.0)*px*x1508))+((px*x1509))+(((-17.0)*px))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1511 = IKatan2WithCheck(IkReal(((-0.09)*py)),((0.09)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1511.valid){
continue;
}
IkReal x1510=x1511.value;
j0array[0]=((-1.0)*x1510);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1510)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1512=IKcos(j0);
IkReal x1513=IKsin(j0);
IkReal x1514=((1.0)*x1512);
evalcond[0]=((((-1.0)*py*x1514))+((px*x1513)));
evalcond[1]=((((-1.0)*py*x1513))+(((-1.0)*px*x1514)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1516 = IKatan2WithCheck(IkReal(((-1.0)*py)),px,IKFAST_ATAN2_MAGTHRESH);
if(!x1516.valid){
continue;
}
IkReal x1515=x1516.value;
j0array[0]=((-1.0)*x1515);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1515)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1517=IKsin(j0);
IkReal x1518=IKcos(j0);
evalcond[0]=((((-1.0)*py*x1517))+(((-1.0)*px*x1518)));
evalcond[1]=((((-0.09)*py*x1518))+(((0.09)*px*x1517)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1519=((110.0)*pz);
IkReal x1520=((100.0)*pp);
CheckValue<IkReal> x1521=IKPowWithIntegerCheck(IKsign(((((-9.0)*pp))+(((9.0)*(pz*pz))))),-1);
if(!x1521.valid){
continue;
}
CheckValue<IkReal> x1522 = IKatan2WithCheck(IkReal(((((-21.25)*px))+(((-1.0)*px*x1520))+((px*x1519)))),((((21.25)*py))+(((-1.0)*py*x1519))+((py*x1520))),IKFAST_ATAN2_MAGTHRESH);
if(!x1522.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1521.value)))+(x1522.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1523=IKsin(j0);
IkReal x1524=IKcos(j0);
IkReal x1525=(px*x1523);
IkReal x1526=((1.0)*x1524);
evalcond[0]=((((-1.0)*px*x1526))+(((-1.0)*py*x1523)));
evalcond[1]=((-0.045)+(((0.045)*cj3))+x1525+(((-1.0)*py*x1526))+(((-0.3)*sj3)));
evalcond[2]=((-0.2125)+(((0.09)*x1525))+(((-1.0)*pp))+(((1.1)*pz))+(((-0.09)*py*x1524)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1527=((0.3)*sj3);
IkReal x1528=((0.045)*px);
IkReal x1529=((0.045)*py);
CheckValue<IkReal> x1530=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp))+(pz*pz))),-1);
if(!x1530.valid){
continue;
}
CheckValue<IkReal> x1531 = IKatan2WithCheck(IkReal(((((-1.0)*x1528))+((cj3*x1528))+(((-1.0)*px*x1527)))),(x1529+(((-1.0)*cj3*x1529))+((py*x1527))),IKFAST_ATAN2_MAGTHRESH);
if(!x1531.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1530.value)))+(x1531.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1532=IKsin(j0);
IkReal x1533=IKcos(j0);
IkReal x1534=(px*x1532);
IkReal x1535=((1.0)*x1533);
evalcond[0]=((((-1.0)*px*x1535))+(((-1.0)*py*x1532)));
evalcond[1]=((-0.045)+(((0.045)*cj3))+x1534+(((-1.0)*py*x1535))+(((-0.3)*sj3)));
evalcond[2]=((-0.2125)+(((0.09)*x1534))+(((-1.0)*pp))+(((1.1)*pz))+(((-0.09)*py*x1533)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(((((-1.0)*cj2*py))+((px*sj2)))))+(IKabs((((cj2*px))+((py*sj2))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=1.0;
j1=0;
sj3=0;
cj3=1.0;
j3=0;
IkReal x1536=((1.0)*py);
j0eval[0]=((IKabs(((((-1.0)*sj2*x1536))+(((-1.0)*cj2*px)))))+(IKabs((((px*sj2))+(((-1.0)*cj2*x1536))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
IkReal x1537=((1.0)*cj2);
CheckValue<IkReal> x1539 = IKatan2WithCheck(IkReal(((((-1.0)*px*x1537))+(((-1.0)*py*sj2)))),(((px*sj2))+(((-1.0)*py*x1537))),IKFAST_ATAN2_MAGTHRESH);
if(!x1539.valid){
continue;
}
IkReal x1538=x1539.value;
j0array[0]=((-1.0)*x1538);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1538)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1540=IKcos(j0);
IkReal x1541=IKsin(j0);
IkReal x1542=((0.09)*py);
IkReal x1543=(px*x1541);
IkReal x1544=((1.0)*x1540);
IkReal x1545=(sj2*x1540);
IkReal x1546=(py*x1541);
evalcond[0]=((((-1.0)*py*x1544))+x1543);
evalcond[1]=((((-1.0)*x1546))+(((-1.0)*px*x1544)));
evalcond[2]=((((-1.0)*cj2*py*x1544))+((cj2*x1543))+((px*x1545))+((sj2*x1546)));
evalcond[3]=(((cj2*x1541*x1542))+(((-0.09)*sj2*x1543))+(((0.09)*cj2*px*x1540))+((x1542*x1545)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1548 = IKatan2WithCheck(IkReal(((((-1.0)*cj2*py))+((px*sj2)))),(((cj2*px))+((py*sj2))),IKFAST_ATAN2_MAGTHRESH);
if(!x1548.valid){
continue;
}
IkReal x1547=x1548.value;
j0array[0]=((-1.0)*x1547);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1547)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1549=IKcos(j0);
IkReal x1550=IKsin(j0);
IkReal x1551=((0.09)*sj2);
IkReal x1552=(cj2*px);
IkReal x1553=(px*x1550);
IkReal x1554=((1.0)*x1549);
IkReal x1555=(py*x1550);
evalcond[0]=((((-1.0)*py*x1554))+x1553);
evalcond[1]=((((-1.0)*x1555))+(((-1.0)*px*x1554)));
evalcond[2]=((((-1.0)*x1552*x1554))+(((-1.0)*cj2*x1555))+(((-1.0)*py*sj2*x1554))+((sj2*x1553)));
evalcond[3]=(((py*x1549*x1551))+(((0.09)*x1549*x1552))+(((0.09)*cj2*x1555))+(((-1.0)*x1551*x1553)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1557 = IKatan2WithCheck(IkReal(((-1.0)*py)),px,IKFAST_ATAN2_MAGTHRESH);
if(!x1557.valid){
continue;
}
IkReal x1556=x1557.value;
j0array[0]=((-1.0)*x1556);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1556)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1558=IKcos(j0);
IkReal x1559=IKsin(j0);
IkReal x1560=(py*sj2);
IkReal x1561=(px*sj2);
IkReal x1562=(cj2*px);
IkReal x1563=((1.0)*x1558);
IkReal x1564=((0.09)*x1558);
IkReal x1565=(py*x1559);
evalcond[0]=((((-1.0)*px*x1563))+(((-1.0)*x1565)));
evalcond[1]=((((-1.0)*cj2*py*x1563))+((x1559*x1560))+((x1559*x1562))+((x1558*x1561)));
evalcond[2]=((((-1.0)*x1560*x1563))+(((-1.0)*x1562*x1563))+(((-1.0)*cj2*x1565))+((x1559*x1561)));
evalcond[3]=(((x1560*x1564))+(((-0.09)*x1559*x1561))+((x1562*x1564))+(((0.09)*cj2*x1565)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1566=cj2*cj2;
IkReal x1567=((0.045)*px);
IkReal x1568=(cj2*sj2);
IkReal x1569=((0.3)*sj3);
IkReal x1570=((0.045)*cj3);
IkReal x1571=((0.045)*py);
IkReal x1572=(py*x1566);
CheckValue<IkReal> x1573=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp*sj2))+((sj2*(pz*pz))))),-1);
if(!x1573.valid){
continue;
}
CheckValue<IkReal> x1574 = IKatan2WithCheck(IkReal(((((-1.0)*px*x1566*x1569))+(((-1.0)*x1566*x1567))+((cj3*x1566*x1567))+(((-1.0)*x1568*x1571))+x1567+((px*x1569))+((py*x1568*x1570))+(((-1.0)*cj3*x1567))+(((-1.0)*py*x1568*x1569)))),(((x1566*x1571))+((x1569*x1572))+(((-1.0)*x1570*x1572))+(((-1.0)*x1567*x1568))+(((-1.0)*py*x1569))+(((-1.0)*px*x1568*x1569))+((cj3*x1567*x1568))+((py*x1570))+(((-1.0)*x1571))),IKFAST_ATAN2_MAGTHRESH);
if(!x1574.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1573.value)))+(x1574.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1575=IKcos(j0);
IkReal x1576=IKsin(j0);
IkReal x1577=((0.045)*cj2);
IkReal x1578=((0.09)*sj2);
IkReal x1579=((0.3)*sj3);
IkReal x1580=((0.045)*cj3);
IkReal x1581=((0.09)*cj2);
IkReal x1582=((1.0)*cj2);
IkReal x1583=(px*x1576);
IkReal x1584=(px*x1575);
IkReal x1585=(py*x1575);
IkReal x1586=(py*x1576);
evalcond[0]=((((0.045)*sj2))+x1583+(((-1.0)*x1585))+(((-1.0)*sj2*x1580))+((sj2*x1579)));
evalcond[1]=(((cj2*x1579))+x1577+(((-1.0)*x1586))+(((-1.0)*x1584))+(((-1.0)*cj3*x1577)));
evalcond[2]=(((sj2*x1586))+((sj2*x1584))+((cj2*x1583))+(((-1.0)*x1582*x1585)));
evalcond[3]=((0.045)+(((-1.0)*x1580))+((sj2*x1583))+x1579+(((-1.0)*sj2*x1585))+(((-1.0)*x1582*x1586))+(((-1.0)*x1582*x1584)));
evalcond[4]=((-0.2125)+(((-1.0)*x1578*x1583))+(((-1.0)*pp))+(((1.1)*pz))+((x1578*x1585))+((x1581*x1584))+((x1581*x1586)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1587=cj2*cj2;
IkReal x1588=((0.045)*px);
IkReal x1589=(cj2*sj2);
IkReal x1590=((0.045)*cj3);
IkReal x1591=((0.3)*sj3);
IkReal x1592=(py*x1587);
CheckValue<IkReal> x1593=IKPowWithIntegerCheck(IKsign(((((-1.0)*cj2*pp))+((cj2*(pz*pz))))),-1);
if(!x1593.valid){
continue;
}
CheckValue<IkReal> x1594 = IKatan2WithCheck(IkReal((((px*x1589*x1591))+((x1590*x1592))+(((-1.0)*cj3*x1588*x1589))+(((-0.045)*x1592))+((x1588*x1589))+(((-1.0)*x1591*x1592)))),(((py*x1589*x1590))+(((-1.0)*px*x1587*x1591))+((cj3*x1587*x1588))+(((-1.0)*py*x1589*x1591))+(((-1.0)*x1587*x1588))+(((-0.045)*py*x1589))),IKFAST_ATAN2_MAGTHRESH);
if(!x1594.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1593.value)))+(x1594.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1595=IKcos(j0);
IkReal x1596=IKsin(j0);
IkReal x1597=((0.045)*cj2);
IkReal x1598=((0.09)*sj2);
IkReal x1599=((0.3)*sj3);
IkReal x1600=((0.045)*cj3);
IkReal x1601=((0.09)*cj2);
IkReal x1602=((1.0)*cj2);
IkReal x1603=(px*x1596);
IkReal x1604=(px*x1595);
IkReal x1605=(py*x1595);
IkReal x1606=(py*x1596);
evalcond[0]=(((sj2*x1599))+(((-1.0)*x1605))+x1603+(((0.045)*sj2))+(((-1.0)*sj2*x1600)));
evalcond[1]=((((-1.0)*cj3*x1597))+(((-1.0)*x1606))+(((-1.0)*x1604))+x1597+((cj2*x1599)));
evalcond[2]=(((sj2*x1606))+((sj2*x1604))+((cj2*x1603))+(((-1.0)*x1602*x1605)));
evalcond[3]=((0.045)+((sj2*x1603))+(((-1.0)*x1600))+x1599+(((-1.0)*sj2*x1605))+(((-1.0)*x1602*x1606))+(((-1.0)*x1602*x1604)));
evalcond[4]=((-0.2125)+((x1601*x1606))+((x1601*x1604))+(((-1.0)*pp))+((x1598*x1605))+(((1.1)*pz))+(((-1.0)*x1598*x1603)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1607=(px*sj2);
IkReal x1608=((0.3)*sj3);
IkReal x1609=(cj2*py);
IkReal x1610=(py*sj2);
IkReal x1611=((0.045)*cj3*py);
IkReal x1612=((0.045)*cj2*px);
CheckValue<IkReal> x1613 = IKatan2WithCheck(IkReal(((((-1.0)*x1607*x1608))+(((-0.045)*x1607))+(((0.045)*cj3*x1607))+((x1608*x1609))+(((0.045)*x1609))+(((-0.045)*cj3*x1609)))),((((-0.045)*cj3*x1610))+(((-1.0)*cj3*x1612))+x1612+((cj2*px*x1608))+((x1608*x1610))+(((0.045)*x1610))),IKFAST_ATAN2_MAGTHRESH);
if(!x1613.valid){
continue;
}
CheckValue<IkReal> x1614=IKPowWithIntegerCheck(IKsign((pp+(((-1.0)*(pz*pz))))),-1);
if(!x1614.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1613.value)+(((1.5707963267949)*(x1614.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1615=IKcos(j0);
IkReal x1616=IKsin(j0);
IkReal x1617=((0.045)*cj2);
IkReal x1618=((0.09)*sj2);
IkReal x1619=((0.3)*sj3);
IkReal x1620=((0.045)*cj3);
IkReal x1621=((0.09)*cj2);
IkReal x1622=((1.0)*cj2);
IkReal x1623=(px*x1616);
IkReal x1624=(px*x1615);
IkReal x1625=(py*x1615);
IkReal x1626=(py*x1616);
evalcond[0]=((((-1.0)*x1625))+((sj2*x1619))+x1623+(((0.045)*sj2))+(((-1.0)*sj2*x1620)));
evalcond[1]=((((-1.0)*cj3*x1617))+(((-1.0)*x1624))+(((-1.0)*x1626))+x1617+((cj2*x1619)));
evalcond[2]=(((sj2*x1624))+((sj2*x1626))+(((-1.0)*x1622*x1625))+((cj2*x1623)));
evalcond[3]=((0.045)+((sj2*x1623))+x1619+(((-1.0)*x1620))+(((-1.0)*x1622*x1624))+(((-1.0)*x1622*x1626))+(((-1.0)*sj2*x1625)));
evalcond[4]=((-0.2125)+(((-1.0)*pp))+(((1.1)*pz))+((x1618*x1625))+(((-1.0)*x1618*x1623))+((x1621*x1624))+((x1621*x1626)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1627=((0.045)*sj3);
IkReal x1628=((0.3)*cj3);
IkReal x1629=(x1627+x1628);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j1)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=((-0.55)+(((-1.0)*x1629))+(((-1.0)*pz)));
evalcond[3]=((0.55)+x1629+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
IkReal x1630=((0.3)*sj3);
IkReal x1631=(px*sj2);
IkReal x1632=((0.045)*py);
IkReal x1633=(pp+(((-1.0)*(pz*pz))));
IkReal x1634=(cj3*x1632);
IkReal x1635=((0.045)*cj2*px);
j0eval[0]=x1633;
j0eval[1]=((IKabs(((((0.045)*cj3*x1631))+((cj2*x1634))+(((-1.0)*cj2*x1632))+(((-0.045)*x1631))+(((-1.0)*x1630*x1631))+(((-1.0)*cj2*py*x1630)))))+(IKabs(((((-1.0)*sj2*x1634))+((cj3*x1635))+((sj2*x1632))+(((-1.0)*x1635))+((py*sj2*x1630))+(((-1.0)*cj2*px*x1630))))));
j0eval[2]=IKsign(x1633);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
IkReal x1636=((((-1.0)*cj2*pp))+((cj2*(pz*pz))));
j0eval[0]=x1636;
j0eval[1]=IKsign(x1636);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal j0eval[2];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
IkReal x1637=((((-1.0)*sj2*(pz*pz)))+((pp*sj2)));
j0eval[0]=x1637;
j0eval[1]=IKsign(x1637);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
IkReal x1638=((0.045)*sj3);
IkReal x1639=((0.3)*cj3);
IkReal x1640=(x1638+x1639);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j2))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=((-0.55)+(((-1.0)*x1640))+(((-1.0)*pz)));
evalcond[3]=((0.55)+x1640+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=0;
cj2=1.0;
j2=0;
IkReal x1641=((20.0)*sj3);
IkReal x1642=((3.0)*px);
IkReal x1643=((3.0)*py);
IkReal x1644=((((-1.0)*pp))+(pz*pz));
j0eval[0]=x1644;
j0eval[1]=((IKabs((x1643+((py*x1641))+(((-1.0)*cj3*x1643)))))+(IKabs((x1642+((px*x1641))+(((-1.0)*cj3*x1642))))));
j0eval[2]=IKsign(x1644);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=0;
cj2=1.0;
j2=0;
IkReal x1645=pz*pz;
IkReal x1646=((80.0)*pp);
IkReal x1647=((88.0)*pz);
j0eval[0]=((((-1.0)*x1645))+pp);
j0eval[1]=IKsign(((((-9.0)*x1645))+(((9.0)*pp))));
j0eval[2]=((IKabs(((((-1.0)*py*x1646))+(((-1.0)*py*x1647))+(((-17.0)*py)))))+(IKabs(((((-1.0)*px*x1647))+(((-1.0)*px*x1646))+(((-17.0)*px))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+(((-1.0)*pz)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=0;
cj2=1.0;
j2=0;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=0;
cj2=1.0;
j2=0;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1649 = IKatan2WithCheck(IkReal(((-0.09)*px)),((-0.09)*py),IKFAST_ATAN2_MAGTHRESH);
if(!x1649.valid){
continue;
}
IkReal x1648=x1649.value;
j0array[0]=((-1.0)*x1648);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1648)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1650=IKsin(j0);
IkReal x1651=IKcos(j0);
evalcond[0]=(((px*x1651))+((py*x1650)));
evalcond[1]=((((-1.0)*py*x1651))+((px*x1650)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1653 = IKatan2WithCheck(IkReal(px),py,IKFAST_ATAN2_MAGTHRESH);
if(!x1653.valid){
continue;
}
IkReal x1652=x1653.value;
j0array[0]=((-1.0)*x1652);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1652)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1654=IKcos(j0);
IkReal x1655=IKsin(j0);
evalcond[0]=((((-1.0)*py*x1654))+((px*x1655)));
evalcond[1]=((((-0.09)*px*x1654))+(((-0.09)*py*x1655)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1656=((110.0)*pz);
IkReal x1657=((100.0)*pp);
CheckValue<IkReal> x1658 = IKatan2WithCheck(IkReal(((((-1.0)*py*x1657))+(((-1.0)*py*x1656))+(((-21.25)*py)))),((((-1.0)*px*x1656))+(((-1.0)*px*x1657))+(((-21.25)*px))),IKFAST_ATAN2_MAGTHRESH);
if(!x1658.valid){
continue;
}
CheckValue<IkReal> x1659=IKPowWithIntegerCheck(IKsign(((((9.0)*pp))+(((-9.0)*(pz*pz))))),-1);
if(!x1659.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1658.value)+(((1.5707963267949)*(x1659.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1660=IKsin(j0);
IkReal x1661=IKcos(j0);
IkReal x1662=(px*x1661);
IkReal x1663=(py*x1660);
evalcond[0]=((((-1.0)*py*x1661))+((px*x1660)));
evalcond[1]=((0.045)+x1663+x1662+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((-0.09)*x1663))+(((-0.09)*x1662))+(((-1.0)*pp))+(((-1.1)*pz)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1664=((0.3)*sj3);
IkReal x1665=((0.045)*px);
IkReal x1666=((0.045)*py);
CheckValue<IkReal> x1667 = IKatan2WithCheck(IkReal((x1666+((py*x1664))+(((-1.0)*cj3*x1666)))),(x1665+((px*x1664))+(((-1.0)*cj3*x1665))),IKFAST_ATAN2_MAGTHRESH);
if(!x1667.valid){
continue;
}
CheckValue<IkReal> x1668=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp))+(pz*pz))),-1);
if(!x1668.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1667.value)+(((1.5707963267949)*(x1668.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1669=IKsin(j0);
IkReal x1670=IKcos(j0);
IkReal x1671=(px*x1670);
IkReal x1672=(py*x1669);
evalcond[0]=(((px*x1669))+(((-1.0)*py*x1670)));
evalcond[1]=((0.045)+x1671+x1672+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((-0.09)*x1672))+(((-0.09)*x1671))+(((-1.0)*pp))+(((-1.1)*pz)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1673=((0.045)*sj3);
IkReal x1674=((0.3)*cj3);
IkReal x1675=(x1674+x1673);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=((-0.55)+(((-1.0)*pz))+(((-1.0)*x1675)));
evalcond[3]=((0.55)+x1675+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x1676=((20.0)*sj3);
IkReal x1677=((3.0)*px);
IkReal x1678=((3.0)*py);
IkReal x1679=(pp+(((-1.0)*(pz*pz))));
j0eval[0]=x1679;
j0eval[1]=((IKabs((x1677+((px*x1676))+(((-1.0)*cj3*x1677)))))+(IKabs((x1678+((py*x1676))+(((-1.0)*cj3*x1678))))));
j0eval[2]=IKsign(x1679);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x1680=pz*pz;
IkReal x1681=((80.0)*pp);
IkReal x1682=((88.0)*pz);
j0eval[0]=(x1680+(((-1.0)*pp)));
j0eval[1]=IKsign(((((-9.0)*pp))+(((9.0)*x1680))));
j0eval[2]=((IKabs(((((-1.0)*py*x1681))+(((-1.0)*py*x1682))+(((-17.0)*py)))))+(IKabs(((((-17.0)*px))+(((-1.0)*px*x1682))+(((-1.0)*px*x1681))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+(((-1.0)*pz)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1684 = IKatan2WithCheck(IkReal(((0.09)*px)),((0.09)*py),IKFAST_ATAN2_MAGTHRESH);
if(!x1684.valid){
continue;
}
IkReal x1683=x1684.value;
j0array[0]=((-1.0)*x1683);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1683)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1685=IKcos(j0);
IkReal x1686=IKsin(j0);
IkReal x1687=((1.0)*x1685);
evalcond[0]=((((-1.0)*py*x1687))+((px*x1686)));
evalcond[1]=((((-1.0)*py*x1686))+(((-1.0)*px*x1687)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1689 = IKatan2WithCheck(IkReal(((-1.0)*py)),px,IKFAST_ATAN2_MAGTHRESH);
if(!x1689.valid){
continue;
}
IkReal x1688=x1689.value;
j0array[0]=((-1.0)*x1688);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1688)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1690=IKcos(j0);
IkReal x1691=IKsin(j0);
IkReal x1692=(py*x1691);
IkReal x1693=(px*x1690);
evalcond[0]=((((-1.0)*x1692))+(((-1.0)*x1693)));
evalcond[1]=((((0.09)*x1692))+(((0.09)*x1693)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1694=((110.0)*pz);
IkReal x1695=((100.0)*pp);
CheckValue<IkReal> x1696=IKPowWithIntegerCheck(IKsign(((((-9.0)*pp))+(((9.0)*(pz*pz))))),-1);
if(!x1696.valid){
continue;
}
CheckValue<IkReal> x1697 = IKatan2WithCheck(IkReal(((((-1.0)*py*x1694))+(((-1.0)*py*x1695))+(((-21.25)*py)))),((((-21.25)*px))+(((-1.0)*px*x1695))+(((-1.0)*px*x1694))),IKFAST_ATAN2_MAGTHRESH);
if(!x1697.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1696.value)))+(x1697.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1698=IKcos(j0);
IkReal x1699=IKsin(j0);
IkReal x1700=((1.0)*py);
IkReal x1701=(px*x1698);
evalcond[0]=((((-1.0)*x1698*x1700))+((px*x1699)));
evalcond[1]=((0.045)+(((-1.0)*x1701))+(((-1.0)*x1699*x1700))+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((-1.0)*pp))+(((-1.1)*pz))+(((0.09)*x1701))+(((0.09)*py*x1699)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1702=((0.3)*sj3);
IkReal x1703=((0.045)*px);
IkReal x1704=((0.045)*py);
CheckValue<IkReal> x1705 = IKatan2WithCheck(IkReal(((((-1.0)*cj3*x1704))+x1704+((py*x1702)))),((((-1.0)*cj3*x1703))+x1703+((px*x1702))),IKFAST_ATAN2_MAGTHRESH);
if(!x1705.valid){
continue;
}
CheckValue<IkReal> x1706=IKPowWithIntegerCheck(IKsign((pp+(((-1.0)*(pz*pz))))),-1);
if(!x1706.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1705.value)+(((1.5707963267949)*(x1706.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1707=IKcos(j0);
IkReal x1708=IKsin(j0);
IkReal x1709=((1.0)*py);
IkReal x1710=(px*x1707);
evalcond[0]=((((-1.0)*x1707*x1709))+((px*x1708)));
evalcond[1]=((0.045)+(((-1.0)*x1708*x1709))+(((-1.0)*x1710))+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((-1.0)*pp))+(((-1.1)*pz))+(((0.09)*x1710))+(((0.09)*py*x1708)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1711=((0.045)*sj3);
IkReal x1712=((0.3)*cj3);
IkReal x1713=(x1712+x1711);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=((-0.55)+(((-1.0)*x1713))+(((-1.0)*pz)));
evalcond[3]=((0.55)+x1713+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=1.0;
cj2=0;
j2=1.5707963267949;
IkReal x1714=((20.0)*sj3);
IkReal x1715=((3.0)*px);
IkReal x1716=((3.0)*py);
IkReal x1717=((((-1.0)*pp))+(pz*pz));
j0eval[0]=x1717;
j0eval[1]=((IKabs(((((-1.0)*x1716))+((cj3*x1716))+(((-1.0)*py*x1714)))))+(IKabs(((((-1.0)*cj3*x1715))+x1715+((px*x1714))))));
j0eval[2]=IKsign(x1717);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=1.0;
cj2=0;
j2=1.5707963267949;
IkReal x1718=pz*pz;
IkReal x1719=((80.0)*pp);
IkReal x1720=((88.0)*pz);
j0eval[0]=((((-1.0)*x1718))+pp);
j0eval[1]=((IKabs(((((-1.0)*px*x1719))+(((-1.0)*px*x1720))+(((-17.0)*px)))))+(IKabs((((py*x1720))+(((17.0)*py))+((py*x1719))))));
j0eval[2]=IKsign(((((-9.0)*x1718))+(((9.0)*pp))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+(((-1.0)*pz)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=1.0;
cj2=0;
j2=1.5707963267949;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1722 = IKatan2WithCheck(IkReal(((0.09)*py)),((-0.09)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1722.valid){
continue;
}
IkReal x1721=x1722.value;
j0array[0]=((-1.0)*x1721);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1721)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1723=IKcos(j0);
IkReal x1724=IKsin(j0);
IkReal x1725=((1.0)*x1723);
evalcond[0]=(((px*x1724))+(((-1.0)*py*x1725)));
evalcond[1]=((((-1.0)*py*x1724))+(((-1.0)*px*x1725)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1727 = IKatan2WithCheck(IkReal(((-1.0)*py)),px,IKFAST_ATAN2_MAGTHRESH);
if(!x1727.valid){
continue;
}
IkReal x1726=x1727.value;
j0array[0]=((-1.0)*x1726);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1726)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1728=IKcos(j0);
IkReal x1729=IKsin(j0);
evalcond[0]=((((-1.0)*py*x1729))+(((-1.0)*px*x1728)));
evalcond[1]=((((0.09)*py*x1728))+(((-0.09)*px*x1729)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1730=((110.0)*pz);
IkReal x1731=((100.0)*pp);
CheckValue<IkReal> x1732 = IKatan2WithCheck(IkReal(((((-1.0)*px*x1730))+(((-1.0)*px*x1731))+(((-21.25)*px)))),(((py*x1730))+((py*x1731))+(((21.25)*py))),IKFAST_ATAN2_MAGTHRESH);
if(!x1732.valid){
continue;
}
CheckValue<IkReal> x1733=IKPowWithIntegerCheck(IKsign(((((9.0)*pp))+(((-9.0)*(pz*pz))))),-1);
if(!x1733.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1732.value)+(((1.5707963267949)*(x1733.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1734=IKsin(j0);
IkReal x1735=IKcos(j0);
IkReal x1736=(px*x1734);
IkReal x1737=((1.0)*x1735);
evalcond[0]=((((-1.0)*px*x1737))+(((-1.0)*py*x1734)));
evalcond[1]=((0.045)+x1736+(((-1.0)*py*x1737))+(((-0.045)*cj3))+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((0.09)*py*x1735))+(((-1.0)*pp))+(((-1.1)*pz))+(((-0.09)*x1736)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1738=((0.3)*sj3);
IkReal x1739=((0.045)*px);
IkReal x1740=((0.045)*py);
CheckValue<IkReal> x1741=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp))+(pz*pz))),-1);
if(!x1741.valid){
continue;
}
CheckValue<IkReal> x1742 = IKatan2WithCheck(IkReal((((px*x1738))+x1739+(((-1.0)*cj3*x1739)))),((((-1.0)*py*x1738))+((cj3*x1740))+(((-1.0)*x1740))),IKFAST_ATAN2_MAGTHRESH);
if(!x1742.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1741.value)))+(x1742.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1743=IKsin(j0);
IkReal x1744=IKcos(j0);
IkReal x1745=(px*x1743);
IkReal x1746=((1.0)*x1744);
evalcond[0]=((((-1.0)*py*x1743))+(((-1.0)*px*x1746)));
evalcond[1]=((0.045)+x1745+(((-0.045)*cj3))+(((-1.0)*py*x1746))+(((0.3)*sj3)));
evalcond[2]=((-0.2125)+(((0.09)*py*x1744))+(((-1.0)*pp))+(((-1.1)*pz))+(((-0.09)*x1745)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x1747=((0.045)*sj3);
IkReal x1748=((0.3)*cj3);
IkReal x1749=(x1748+x1747);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=((-0.55)+(((-1.0)*pz))+(((-1.0)*x1749)));
evalcond[3]=((0.55)+x1749+pz);
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[3];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
IkReal x1750=((20.0)*sj3);
IkReal x1751=((3.0)*px);
IkReal x1752=((3.0)*py);
IkReal x1753=((((-1.0)*pp))+(pz*pz));
j0eval[0]=x1753;
j0eval[1]=((IKabs((x1752+(((-1.0)*cj3*x1752))+((py*x1750)))))+(IKabs((((cj3*x1751))+(((-1.0)*x1751))+(((-1.0)*px*x1750))))));
j0eval[2]=IKsign(x1753);
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal j0eval[3];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
IkReal x1754=pz*pz;
IkReal x1755=((80.0)*pp);
IkReal x1756=((88.0)*pz);
j0eval[0]=(x1754+(((-1.0)*pp)));
j0eval[1]=IKsign(((((-9.0)*pp))+(((9.0)*x1754))));
j0eval[2]=((IKabs(((((-1.0)*px*x1755))+(((-1.0)*px*x1756))+(((-17.0)*px)))))+(IKabs(((((17.0)*py))+((py*x1755))+((py*x1756))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 || IKabs(j0eval[1]) < 0.0000010000000000 || IKabs(j0eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[3];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+(((-1.0)*pz)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj2=-1.0;
cj2=0;
j2=-1.5707963267949;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=(pp+(((-1.0)*(pz*pz))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // 3 cases reached
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1758 = IKatan2WithCheck(IkReal(((-0.09)*py)),((0.09)*px),IKFAST_ATAN2_MAGTHRESH);
if(!x1758.valid){
continue;
}
IkReal x1757=x1758.value;
j0array[0]=((-1.0)*x1757);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1757)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1759=IKsin(j0);
IkReal x1760=IKcos(j0);
evalcond[0]=(((px*x1760))+((py*x1759)));
evalcond[1]=(((px*x1759))+(((-1.0)*py*x1760)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1762 = IKatan2WithCheck(IkReal(px),py,IKFAST_ATAN2_MAGTHRESH);
if(!x1762.valid){
continue;
}
IkReal x1761=x1762.value;
j0array[0]=((-1.0)*x1761);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1761)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[2];
IkReal x1763=IKsin(j0);
IkReal x1764=IKcos(j0);
IkReal x1765=(px*x1763);
IkReal x1766=(py*x1764);
evalcond[0]=((((-1.0)*x1766))+x1765);
evalcond[1]=((((-0.09)*x1766))+(((0.09)*x1765)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1767=((110.0)*pz);
IkReal x1768=((100.0)*pp);
CheckValue<IkReal> x1769=IKPowWithIntegerCheck(IKsign(((((-9.0)*pp))+(((9.0)*(pz*pz))))),-1);
if(!x1769.valid){
continue;
}
CheckValue<IkReal> x1770 = IKatan2WithCheck(IkReal(((((-1.0)*px*x1768))+(((-1.0)*px*x1767))+(((-21.25)*px)))),((((21.25)*py))+((py*x1768))+((py*x1767))),IKFAST_ATAN2_MAGTHRESH);
if(!x1770.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1769.value)))+(x1770.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1771=IKsin(j0);
IkReal x1772=IKcos(j0);
IkReal x1773=(px*x1771);
IkReal x1774=(py*x1772);
evalcond[0]=(((px*x1772))+((py*x1771)));
evalcond[1]=((-0.045)+(((0.045)*cj3))+(((-1.0)*x1774))+x1773+(((-0.3)*sj3)));
evalcond[2]=((-0.2125)+(((-0.09)*x1774))+(((-1.0)*pp))+(((-1.1)*pz))+(((0.09)*x1773)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1775=((0.3)*sj3);
IkReal x1776=((0.045)*px);
IkReal x1777=((0.045)*py);
CheckValue<IkReal> x1778=IKPowWithIntegerCheck(IKsign(((((-1.0)*pp))+(pz*pz))),-1);
if(!x1778.valid){
continue;
}
CheckValue<IkReal> x1779 = IKatan2WithCheck(IkReal(((((-1.0)*px*x1775))+(((-1.0)*x1776))+((cj3*x1776)))),((((-1.0)*cj3*x1777))+x1777+((py*x1775))),IKFAST_ATAN2_MAGTHRESH);
if(!x1779.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1778.value)))+(x1779.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[3];
IkReal x1780=IKsin(j0);
IkReal x1781=IKcos(j0);
IkReal x1782=(px*x1780);
IkReal x1783=(py*x1781);
evalcond[0]=(((py*x1780))+((px*x1781)));
evalcond[1]=((-0.045)+(((0.045)*cj3))+x1782+(((-1.0)*x1783))+(((-0.3)*sj3)));
evalcond[2]=((-0.2125)+(((0.09)*x1782))+(((-1.0)*pp))+(((-1.1)*pz))+(((-0.09)*x1783)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j3))), 6.28318530717959)));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=((-0.85)+(((-1.0)*pz)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs(px))+(IKabs(py)));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj3=0;
cj3=1.0;
j3=0;
j0eval[0]=((IKabs((((cj2*px))+(((-1.0)*py*sj2)))))+(IKabs((((cj2*py))+((px*sj2))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
{
IkReal j0eval[1];
sj1=0;
cj1=-1.0;
j1=3.14159265358979;
sj3=0;
cj3=1.0;
j3=0;
IkReal x1784=((1.0)*sj2);
j0eval[0]=((IKabs(((((-1.0)*py*x1784))+((cj2*px)))))+(IKabs(((((-1.0)*cj2*py))+(((-1.0)*px*x1784))))));
if( IKabs(j0eval[0]) < 0.0000010000000000 )
{
continue; // no branches [j0]
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
IkReal x1785=((1.0)*py);
CheckValue<IkReal> x1787 = IKatan2WithCheck(IkReal(((((-1.0)*cj2*x1785))+(((-1.0)*px*sj2)))),(((cj2*px))+(((-1.0)*sj2*x1785))),IKFAST_ATAN2_MAGTHRESH);
if(!x1787.valid){
continue;
}
IkReal x1786=x1787.value;
j0array[0]=((-1.0)*x1786);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1786)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1788=IKcos(j0);
IkReal x1789=IKsin(j0);
IkReal x1790=((0.09)*sj2);
IkReal x1791=(px*x1789);
IkReal x1792=((1.0)*x1788);
IkReal x1793=(py*x1789);
IkReal x1794=(cj2*px*x1788);
evalcond[0]=(x1791+(((-1.0)*py*x1792)));
evalcond[1]=((((-1.0)*x1793))+(((-1.0)*px*x1792)));
evalcond[2]=(((sj2*x1791))+x1794+((cj2*x1793))+(((-1.0)*py*sj2*x1792)));
evalcond[3]=((((-1.0)*x1790*x1791))+((py*x1788*x1790))+(((-0.09)*x1794))+(((-0.09)*cj2*x1793)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1796 = IKatan2WithCheck(IkReal((((cj2*px))+(((-1.0)*py*sj2)))),(((cj2*py))+((px*sj2))),IKFAST_ATAN2_MAGTHRESH);
if(!x1796.valid){
continue;
}
IkReal x1795=x1796.value;
j0array[0]=((-1.0)*x1795);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1795)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1797=IKcos(j0);
IkReal x1798=IKsin(j0);
IkReal x1799=((0.09)*sj2);
IkReal x1800=(cj2*py);
IkReal x1801=(px*x1798);
IkReal x1802=((1.0)*x1797);
IkReal x1803=((1.0)*py*x1798);
evalcond[0]=((((-1.0)*py*x1802))+x1801);
evalcond[1]=((((-1.0)*x1803))+(((-1.0)*px*x1802)));
evalcond[2]=(((cj2*x1801))+(((-1.0)*x1800*x1802))+(((-1.0)*px*sj2*x1802))+(((-1.0)*sj2*x1803)));
evalcond[3]=((((-1.0)*x1799*x1801))+((py*x1797*x1799))+(((-0.09)*cj2*px*x1797))+(((-0.09)*x1798*x1800)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
CheckValue<IkReal> x1805 = IKatan2WithCheck(IkReal(((-1.0)*py)),px,IKFAST_ATAN2_MAGTHRESH);
if(!x1805.valid){
continue;
}
IkReal x1804=x1805.value;
j0array[0]=((-1.0)*x1804);
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1804)));
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[4];
IkReal x1806=IKsin(j0);
IkReal x1807=IKcos(j0);
IkReal x1808=(py*sj2);
IkReal x1809=(cj2*px);
IkReal x1810=((1.0)*x1807);
IkReal x1811=((0.09)*x1807);
IkReal x1812=(py*x1806);
IkReal x1813=(px*sj2*x1806);
evalcond[0]=((((-1.0)*px*x1810))+(((-1.0)*x1812)));
evalcond[1]=(((cj2*x1812))+(((-1.0)*x1808*x1810))+x1813+((x1807*x1809)));
evalcond[2]=((((-1.0)*px*sj2*x1810))+((x1806*x1809))+(((-1.0)*x1806*x1808))+(((-1.0)*cj2*py*x1810)));
evalcond[3]=((((-1.0)*x1809*x1811))+(((-0.09)*cj2*x1812))+((x1808*x1811))+(((-0.09)*x1813)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1814=cj2*cj2;
IkReal x1815=((0.045)*px);
IkReal x1816=(cj2*sj2);
IkReal x1817=((0.3)*sj3);
IkReal x1818=((0.045)*py);
IkReal x1819=(cj3*x1818);
IkReal x1820=(py*x1814);
CheckValue<IkReal> x1821=IKPowWithIntegerCheck(IKsign(((((-1.0)*sj2*(pz*pz)))+((pp*sj2)))),-1);
if(!x1821.valid){
continue;
}
CheckValue<IkReal> x1822 = IKatan2WithCheck(IkReal(((((-1.0)*x1815))+(((-1.0)*py*x1816*x1817))+(((-1.0)*cj3*x1814*x1815))+((cj3*x1815))+((x1816*x1819))+(((-1.0)*x1816*x1818))+((x1814*x1815))+((px*x1814*x1817))+(((-1.0)*px*x1817)))),((((-1.0)*x1819))+(((-1.0)*x1817*x1820))+(((-1.0)*px*x1816*x1817))+((py*x1817))+((x1814*x1819))+(((-1.0)*x1814*x1818))+x1818+(((-1.0)*x1815*x1816))+((cj3*x1815*x1816))),IKFAST_ATAN2_MAGTHRESH);
if(!x1822.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1821.value)))+(x1822.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1823=IKcos(j0);
IkReal x1824=IKsin(j0);
IkReal x1825=((0.045)*cj2);
IkReal x1826=((0.09)*sj2);
IkReal x1827=((0.3)*sj3);
IkReal x1828=((0.045)*cj3);
IkReal x1829=((1.0)*sj2);
IkReal x1830=((0.09)*cj2);
IkReal x1831=(px*x1824);
IkReal x1832=(px*x1823);
IkReal x1833=(py*x1823);
IkReal x1834=(py*x1824);
evalcond[0]=((((-1.0)*x1833))+(((0.045)*sj2))+x1831+((sj2*x1827))+(((-1.0)*sj2*x1828)));
evalcond[1]=((((-1.0)*x1825))+(((-1.0)*x1834))+(((-1.0)*x1832))+(((-1.0)*cj2*x1827))+((cj3*x1825)));
evalcond[2]=(((cj2*x1831))+(((-1.0)*x1829*x1832))+(((-1.0)*x1829*x1834))+(((-1.0)*cj2*x1833)));
evalcond[3]=((0.045)+(((-1.0)*x1828))+((cj2*x1834))+((cj2*x1832))+((sj2*x1831))+x1827+(((-1.0)*x1829*x1833)));
evalcond[4]=((-0.2125)+((x1826*x1833))+(((-1.0)*pp))+(((-1.1)*pz))+(((-1.0)*x1826*x1831))+(((-1.0)*x1830*x1832))+(((-1.0)*x1830*x1834)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1835=cj2*cj2;
IkReal x1836=((0.045)*px);
IkReal x1837=((0.045)*py);
IkReal x1838=(cj2*sj2);
IkReal x1839=(cj3*x1838);
IkReal x1840=(cj3*x1835);
IkReal x1841=((0.3)*py*sj3);
IkReal x1842=((0.3)*px*sj3);
CheckValue<IkReal> x1843=IKPowWithIntegerCheck(IKsign(((((-1.0)*cj2*pp))+((cj2*(pz*pz))))),-1);
if(!x1843.valid){
continue;
}
CheckValue<IkReal> x1844 = IKatan2WithCheck(IkReal((((x1838*x1842))+(((-1.0)*x1836*x1839))+((x1835*x1837))+(((-1.0)*x1837*x1840))+((x1835*x1841))+((x1836*x1838)))),((((-1.0)*x1837*x1838))+((x1835*x1836))+(((-1.0)*x1836*x1840))+((x1837*x1839))+(((-1.0)*x1838*x1841))+((x1835*x1842))),IKFAST_ATAN2_MAGTHRESH);
if(!x1844.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1843.value)))+(x1844.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1845=IKcos(j0);
IkReal x1846=IKsin(j0);
IkReal x1847=((0.045)*cj2);
IkReal x1848=((0.09)*sj2);
IkReal x1849=((0.3)*sj3);
IkReal x1850=((0.045)*cj3);
IkReal x1851=((1.0)*sj2);
IkReal x1852=((0.09)*cj2);
IkReal x1853=(px*x1846);
IkReal x1854=(px*x1845);
IkReal x1855=(py*x1845);
IkReal x1856=(py*x1846);
evalcond[0]=((((-1.0)*x1855))+((sj2*x1849))+(((0.045)*sj2))+x1853+(((-1.0)*sj2*x1850)));
evalcond[1]=((((-1.0)*x1847))+(((-1.0)*x1856))+(((-1.0)*x1854))+((cj3*x1847))+(((-1.0)*cj2*x1849)));
evalcond[2]=((((-1.0)*cj2*x1855))+(((-1.0)*x1851*x1854))+(((-1.0)*x1851*x1856))+((cj2*x1853)));
evalcond[3]=((0.045)+(((-1.0)*x1851*x1855))+((cj2*x1854))+((cj2*x1856))+x1849+((sj2*x1853))+(((-1.0)*x1850)));
evalcond[4]=((-0.2125)+(((-1.0)*x1848*x1853))+((x1848*x1855))+(((-1.0)*x1852*x1856))+(((-1.0)*x1852*x1854))+(((-1.0)*pp))+(((-1.1)*pz)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1857=(px*sj2);
IkReal x1858=((0.3)*sj3);
IkReal x1859=(cj2*py);
IkReal x1860=(py*sj2);
IkReal x1861=((0.045)*cj3*py);
IkReal x1862=((0.045)*cj2*px);
CheckValue<IkReal> x1863=IKPowWithIntegerCheck(IKsign((pp+(((-1.0)*(pz*pz))))),-1);
if(!x1863.valid){
continue;
}
CheckValue<IkReal> x1864 = IKatan2WithCheck(IkReal(((((-1.0)*x1858*x1859))+(((-0.045)*x1859))+(((-0.045)*x1857))+(((-1.0)*x1857*x1858))+(((0.045)*cj3*x1859))+(((0.045)*cj3*x1857)))),(((cj3*x1862))+(((0.045)*x1860))+(((-1.0)*cj2*px*x1858))+((x1858*x1860))+(((-1.0)*x1862))+(((-0.045)*cj3*x1860))),IKFAST_ATAN2_MAGTHRESH);
if(!x1864.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(((1.5707963267949)*(x1863.value)))+(x1864.value));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[5];
IkReal x1865=IKcos(j0);
IkReal x1866=IKsin(j0);
IkReal x1867=((0.045)*cj2);
IkReal x1868=((0.09)*sj2);
IkReal x1869=((0.3)*sj3);
IkReal x1870=((0.045)*cj3);
IkReal x1871=((1.0)*sj2);
IkReal x1872=((0.09)*cj2);
IkReal x1873=(px*x1866);
IkReal x1874=(px*x1865);
IkReal x1875=(py*x1865);
IkReal x1876=(py*x1866);
evalcond[0]=((((0.045)*sj2))+(((-1.0)*sj2*x1870))+x1873+((sj2*x1869))+(((-1.0)*x1875)));
evalcond[1]=(((cj3*x1867))+(((-1.0)*cj2*x1869))+(((-1.0)*x1876))+(((-1.0)*x1874))+(((-1.0)*x1867)));
evalcond[2]=(((cj2*x1873))+(((-1.0)*x1871*x1876))+(((-1.0)*x1871*x1874))+(((-1.0)*cj2*x1875)));
evalcond[3]=((0.045)+(((-1.0)*x1870))+((sj2*x1873))+((cj2*x1876))+((cj2*x1874))+x1869+(((-1.0)*x1871*x1875)));
evalcond[4]=((-0.2125)+(((-1.0)*x1872*x1874))+(((-1.0)*x1872*x1876))+(((-1.0)*x1868*x1873))+(((-1.0)*pp))+(((-1.1)*pz))+((x1868*x1875)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j0]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1877=(cj3*py);
IkReal x1878=((0.3)*sj1);
IkReal x1879=((0.045)*sj2);
IkReal x1880=(cj3*px);
IkReal x1881=(px*sj1);
IkReal x1882=((0.3)*sj3);
IkReal x1883=((0.045)*sj3);
IkReal x1884=(py*sj1);
IkReal x1885=(cj1*cj2);
IkReal x1886=((0.045)*x1885);
CheckValue<IkReal> x1887 = IKatan2WithCheck(IkReal(((((0.55)*x1884))+((x1879*x1880))+(((-1.0)*px*x1879))+((x1883*x1884))+((x1877*x1878))+((py*x1886))+(((-1.0)*px*sj2*x1882))+((py*x1882*x1885))+(((-1.0)*x1877*x1886)))),((((0.55)*x1881))+((x1881*x1883))+(((-1.0)*x1880*x1886))+((py*sj2*x1882))+((px*x1882*x1885))+(((-1.0)*x1877*x1879))+((x1878*x1880))+((px*x1886))+((py*x1879))),IKFAST_ATAN2_MAGTHRESH);
if(!x1887.valid){
continue;
}
CheckValue<IkReal> x1888=IKPowWithIntegerCheck(IKsign((pp+(((-1.0)*(pz*pz))))),-1);
if(!x1888.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1887.value)+(((1.5707963267949)*(x1888.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[6];
IkReal x1889=IKsin(j0);
IkReal x1890=IKcos(j0);
IkReal x1891=(cj1*sj2);
IkReal x1892=((0.09)*sj2);
IkReal x1893=((0.3)*sj3);
IkReal x1894=((0.045)*cj3);
IkReal x1895=((1.1)*sj1);
IkReal x1896=((0.3)*cj3);
IkReal x1897=(cj1*cj2);
IkReal x1898=((0.045)*sj3);
IkReal x1899=((1.0)*sj2);
IkReal x1900=(cj1*pz);
IkReal x1901=(px*x1889);
IkReal x1902=(px*x1890);
IkReal x1903=(py*x1890);
IkReal x1904=(py*x1889);
IkReal x1905=(cj2*pz*sj1);
evalcond[0]=((-0.55)+x1900+((sj1*x1902))+((sj1*x1904))+(((-1.0)*x1898))+(((-1.0)*x1896)));
evalcond[1]=(((sj2*x1893))+(((-1.0)*sj2*x1894))+(((0.045)*sj2))+(((-1.0)*x1903))+x1901);
evalcond[2]=((((-1.0)*pz*sj1*x1899))+(((-1.0)*cj2*x1903))+((cj2*x1901))+((x1891*x1902))+((x1891*x1904)));
evalcond[3]=((((0.045)*x1897))+((x1893*x1897))+(((-1.0)*x1904))+(((-1.0)*x1902))+(((-1.0)*x1894*x1897))+((sj1*x1896))+((sj1*x1898))+(((0.55)*sj1)));
evalcond[4]=((0.045)+(((-1.0)*x1899*x1903))+(((-1.0)*x1897*x1902))+(((-1.0)*x1897*x1904))+x1905+x1893+(((-1.0)*x1894))+((sj2*x1901)));
evalcond[5]=((-0.2125)+((x1892*x1903))+(((1.1)*x1900))+(((-1.0)*x1892*x1901))+(((-1.0)*pp))+((x1895*x1902))+((x1895*x1904))+(((0.09)*x1897*x1904))+(((0.09)*x1897*x1902))+(((-0.09)*x1905)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1906=((0.55)*cj2);
IkReal x1907=(cj2*sj1);
IkReal x1908=(py*sj2);
IkReal x1909=((0.045)*sj3);
IkReal x1910=(px*pz);
IkReal x1911=(cj2*px);
IkReal x1912=(cj1*cj2);
IkReal x1913=(cj2*py);
IkReal x1914=((0.3)*cj3);
IkReal x1915=((0.55)*cj1*sj2);
IkReal x1916=(cj1*px*sj2);
CheckValue<IkReal> x1917 = IKatan2WithCheck(IkReal(((((-1.0)*py*x1906))+((x1914*x1916))+(((-1.0)*sj2*x1910))+((px*x1915))+((x1909*x1916))+(((-1.0)*x1913*x1914))+(((-1.0)*x1909*x1913))+((py*pz*x1912)))),((((-1.0)*x1911*x1914))+(((-1.0)*cj1*x1908*x1909))+(((-1.0)*px*x1906))+((x1910*x1912))+(((-1.0)*cj1*x1908*x1914))+((pz*x1908))+(((-0.55)*cj1*x1908))+(((-1.0)*x1909*x1911))),IKFAST_ATAN2_MAGTHRESH);
if(!x1917.valid){
continue;
}
CheckValue<IkReal> x1918=IKPowWithIntegerCheck(IKsign((((x1907*(pz*pz)))+(((-1.0)*pp*x1907)))),-1);
if(!x1918.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1917.value)+(((1.5707963267949)*(x1918.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[6];
IkReal x1919=IKsin(j0);
IkReal x1920=IKcos(j0);
IkReal x1921=(cj1*sj2);
IkReal x1922=((0.09)*sj2);
IkReal x1923=((0.3)*sj3);
IkReal x1924=((0.045)*cj3);
IkReal x1925=((1.1)*sj1);
IkReal x1926=((0.3)*cj3);
IkReal x1927=(cj1*cj2);
IkReal x1928=((0.045)*sj3);
IkReal x1929=((1.0)*sj2);
IkReal x1930=(cj1*pz);
IkReal x1931=(px*x1919);
IkReal x1932=(px*x1920);
IkReal x1933=(py*x1920);
IkReal x1934=(py*x1919);
IkReal x1935=(cj2*pz*sj1);
evalcond[0]=((-0.55)+(((-1.0)*x1926))+(((-1.0)*x1928))+((sj1*x1934))+((sj1*x1932))+x1930);
evalcond[1]=((((-1.0)*x1933))+(((0.045)*sj2))+((sj2*x1923))+x1931+(((-1.0)*sj2*x1924)));
evalcond[2]=(((x1921*x1934))+((x1921*x1932))+(((-1.0)*cj2*x1933))+((cj2*x1931))+(((-1.0)*pz*sj1*x1929)));
evalcond[3]=((((-1.0)*x1934))+(((-1.0)*x1932))+(((0.045)*x1927))+((x1923*x1927))+(((-1.0)*x1924*x1927))+(((0.55)*sj1))+((sj1*x1928))+((sj1*x1926)));
evalcond[4]=((0.045)+((sj2*x1931))+(((-1.0)*x1927*x1934))+(((-1.0)*x1927*x1932))+(((-1.0)*x1924))+x1923+x1935+(((-1.0)*x1929*x1933)));
evalcond[5]=((-0.2125)+(((1.1)*x1930))+((x1922*x1933))+((x1925*x1934))+((x1925*x1932))+(((-1.0)*pp))+(((0.09)*x1927*x1934))+(((0.09)*x1927*x1932))+(((-1.0)*x1922*x1931))+(((-0.09)*x1935)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j0array[1], cj0array[1], sj0array[1];
bool j0valid[1]={false};
_nj0 = 1;
IkReal x1936=((0.045)*px);
IkReal x1937=((0.3)*sj3);
IkReal x1938=(sj1*sj2);
IkReal x1939=((0.3)*cj3);
IkReal x1940=(py*x1938);
IkReal x1941=((1.0)*cj1*pz);
CheckValue<IkReal> x1942 = IKatan2WithCheck(IkReal(((((-1.0)*px*x1937*x1938))+(((0.045)*py*sj3))+((py*x1939))+(((-1.0)*py*x1941))+((cj3*x1936*x1938))+(((0.55)*py))+(((-1.0)*x1936*x1938)))),((((0.045)*x1940))+((x1937*x1940))+((px*x1939))+(((-1.0)*px*x1941))+(((-0.045)*cj3*x1940))+(((0.55)*px))+((sj3*x1936))),IKFAST_ATAN2_MAGTHRESH);
if(!x1942.valid){
continue;
}
CheckValue<IkReal> x1943=IKPowWithIntegerCheck(IKsign((((pp*sj1))+(((-1.0)*sj1*(pz*pz))))),-1);
if(!x1943.valid){
continue;
}
j0array[0]=((-1.5707963267949)+(x1942.value)+(((1.5707963267949)*(x1943.value))));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
for(int ij0 = 0; ij0 < 1; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 1; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal evalcond[6];
IkReal x1944=IKsin(j0);
IkReal x1945=IKcos(j0);
IkReal x1946=(cj1*sj2);
IkReal x1947=((0.09)*sj2);
IkReal x1948=((0.3)*sj3);
IkReal x1949=((0.045)*cj3);
IkReal x1950=((1.1)*sj1);
IkReal x1951=((0.3)*cj3);
IkReal x1952=(cj1*cj2);
IkReal x1953=((0.045)*sj3);
IkReal x1954=((1.0)*sj2);
IkReal x1955=(cj1*pz);
IkReal x1956=(px*x1944);
IkReal x1957=(px*x1945);
IkReal x1958=(py*x1945);
IkReal x1959=(py*x1944);
IkReal x1960=(cj2*pz*sj1);
evalcond[0]=((-0.55)+(((-1.0)*x1953))+(((-1.0)*x1951))+((sj1*x1957))+((sj1*x1959))+x1955);
evalcond[1]=(((sj2*x1948))+(((-1.0)*sj2*x1949))+(((0.045)*sj2))+x1956+(((-1.0)*x1958)));
evalcond[2]=(((cj2*x1956))+((x1946*x1957))+((x1946*x1959))+(((-1.0)*cj2*x1958))+(((-1.0)*pz*sj1*x1954)));
evalcond[3]=((((-1.0)*x1949*x1952))+(((0.045)*x1952))+((sj1*x1953))+((sj1*x1951))+(((-1.0)*x1957))+(((-1.0)*x1959))+((x1948*x1952))+(((0.55)*sj1)));
evalcond[4]=((0.045)+((sj2*x1956))+(((-1.0)*x1954*x1958))+(((-1.0)*x1949))+x1960+x1948+(((-1.0)*x1952*x1957))+(((-1.0)*x1952*x1959)));
evalcond[5]=((-0.2125)+(((1.1)*x1955))+((x1950*x1957))+((x1950*x1959))+(((-1.0)*x1947*x1956))+(((0.09)*x1952*x1957))+(((0.09)*x1952*x1959))+(((-1.0)*pp))+(((-0.09)*x1960))+((x1947*x1958)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
}
}
}
} else
{
{
IkReal j0array[2], cj0array[2], sj0array[2];
bool j0valid[2]={false};
_nj0 = 2;
IkReal x1961=((0.045)*sj2);
CheckValue<IkReal> x1964 = IKatan2WithCheck(IkReal(((-1.0)*py)),px,IKFAST_ATAN2_MAGTHRESH);
if(!x1964.valid){
continue;
}
IkReal x1962=((1.0)*(x1964.value));
if((((px*px)+(py*py))) < -0.00001)
continue;
CheckValue<IkReal> x1965=IKPowWithIntegerCheck(IKabs(IKsqrt(((px*px)+(py*py)))),-1);
if(!x1965.valid){
continue;
}
if( (((x1965.value)*(((((0.3)*sj2*sj3))+x1961+(((-1.0)*cj3*x1961)))))) < -1-IKFAST_SINCOS_THRESH || (((x1965.value)*(((((0.3)*sj2*sj3))+x1961+(((-1.0)*cj3*x1961)))))) > 1+IKFAST_SINCOS_THRESH )
continue;
IkReal x1963=IKasin(((x1965.value)*(((((0.3)*sj2*sj3))+x1961+(((-1.0)*cj3*x1961))))));
j0array[0]=((((-1.0)*x1962))+(((-1.0)*x1963)));
sj0array[0]=IKsin(j0array[0]);
cj0array[0]=IKcos(j0array[0]);
j0array[1]=((3.14159265358979)+(((-1.0)*x1962))+x1963);
sj0array[1]=IKsin(j0array[1]);
cj0array[1]=IKcos(j0array[1]);
if( j0array[0] > IKPI )
{
j0array[0]-=IK2PI;
}
else if( j0array[0] < -IKPI )
{ j0array[0]+=IK2PI;
}
j0valid[0] = true;
if( j0array[1] > IKPI )
{
j0array[1]-=IK2PI;
}
else if( j0array[1] < -IKPI )
{ j0array[1]+=IK2PI;
}
j0valid[1] = true;
for(int ij0 = 0; ij0 < 2; ++ij0)
{
if( !j0valid[ij0] )
{
continue;
}
_ij0[0] = ij0; _ij0[1] = -1;
for(int iij0 = ij0+1; iij0 < 2; ++iij0)
{
if( j0valid[iij0] && IKabs(cj0array[ij0]-cj0array[iij0]) < IKFAST_SOLUTION_THRESH && IKabs(sj0array[ij0]-sj0array[iij0]) < IKFAST_SOLUTION_THRESH )
{
j0valid[iij0]=false; _ij0[1] = iij0; break;
}
}
j0 = j0array[ij0]; cj0 = cj0array[ij0]; sj0 = sj0array[ij0];
{
IkReal j1eval[2];
IkReal x1966=(py*sj0);
IkReal x1967=((0.3)*cj3);
IkReal x1968=((0.045)*sj3);
IkReal x1969=(cj2*pz);
IkReal x1970=((6.66666666666667)*cj3);
IkReal x1971=(cj0*px);
IkReal x1972=((1.0)*sj3);
j1eval[0]=(((cj3*x1969))+(((-1.0)*x1969))+(((-1.0)*x1966*x1972))+(((-1.0)*x1966*x1970))+(((-1.0)*x1971*x1972))+(((-1.0)*x1970*x1971))+(((-6.66666666666667)*sj3*x1969))+(((-12.2222222222222)*x1971))+(((-12.2222222222222)*x1966)));
j1eval[1]=IKsign(((((0.045)*cj3*x1969))+(((-1.0)*x1966*x1967))+(((-1.0)*x1966*x1968))+(((-1.0)*x1968*x1971))+(((-0.3)*sj3*x1969))+(((-0.55)*x1971))+(((-0.55)*x1966))+(((-0.045)*x1969))+(((-1.0)*x1967*x1971))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
IkReal x1973=cj0*cj0;
IkReal x1974=py*py;
IkReal x1975=(sj2*x1973);
IkReal x1976=(((sj2*x1974))+(((-1.0)*x1974*x1975))+((sj2*(pz*pz)))+((x1975*(px*px)))+(((2.0)*cj0*px*py*sj0*sj2)));
j1eval[0]=x1976;
j1eval[1]=IKsign(x1976);
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
IkReal x1977=(pz*sj2);
IkReal x1978=(py*sj0);
IkReal x1979=(cj0*px);
IkReal x1980=(cj2*sj2);
IkReal x1981=((1.0)*cj3);
IkReal x1982=((0.045)*x1980);
IkReal x1983=(sj3*x1980);
IkReal x1984=(x1978*x1983);
j1eval[0]=((((6.66666666666667)*x1984))+(((-6.66666666666667)*cj3*x1977))+((x1978*x1980))+((x1979*x1980))+(((-1.0)*x1978*x1980*x1981))+(((-1.0)*x1979*x1980*x1981))+(((-12.2222222222222)*x1977))+(((6.66666666666667)*x1979*x1983))+(((-1.0)*sj3*x1977)));
j1eval[1]=IKsign(((((-1.0)*cj3*x1979*x1982))+(((-0.045)*sj3*x1977))+(((-1.0)*cj3*x1978*x1982))+(((-0.3)*cj3*x1977))+((x1978*x1982))+(((0.3)*x1979*x1983))+((x1979*x1982))+(((0.3)*x1984))+(((-0.55)*x1977))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
IkReal x1985=(((px*sj0))+(((-1.0)*cj0*py)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j2))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=x1985;
evalcond[3]=x1985;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[2];
sj2=0;
cj2=1.0;
j2=0;
IkReal x1986=(cj0*px);
IkReal x1987=((0.310561435803037)*sj3);
IkReal x1988=(pp*pz);
IkReal x1989=(py*sj0);
IkReal x1990=((0.138057984353428)*pp);
IkReal x1991=((12.2222222222222)*sj3);
IkReal x1992=((5.4333061668025)*pp);
IkReal x1993=(pz*sj3);
j1eval[0]=((((7.28153581454315)*pz))+(((-1.0)*x1986*x1991))+((x1986*x1992))+(((-1.0)*x1989*x1991))+(((-3.92556370551481)*x1989))+(((-3.92556370551481)*x1986))+((x1989*x1992))+(((-1.0)*x1993))+(((36.2220411120167)*x1988)));
j1eval[1]=IKsign(((((-1.0)*x1986*x1987))+((x1986*x1990))+(((-1.0)*x1987*x1989))+(((0.185020708697653)*pz))+(((-0.0254095720202485)*x1993))+(((-0.099746893695352)*x1989))+(((-0.099746893695352)*x1986))+((x1989*x1990))+(((0.92038656235619)*x1988))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
sj2=0;
cj2=1.0;
j2=0;
IkReal x1994=(cj0*px);
IkReal x1995=(py*sj0);
IkReal x1996=((0.3)*sj3);
IkReal x1997=((0.045)*cj3);
IkReal x1998=(pz*sj3);
IkReal x1999=((6.66666666666667)*sj3);
IkReal x2000=((1.0)*cj3);
IkReal x2001=(cj3*pz);
j1eval[0]=((((-1.0)*x1994*x2000))+(((-1.0)*x1995*x2000))+((x1995*x1999))+((x1994*x1999))+x1995+x1994+(((-6.66666666666667)*x2001))+(((-12.2222222222222)*pz))+(((-1.0)*x1998)));
j1eval[1]=IKsign(((((-0.55)*pz))+(((-0.045)*x1998))+((x1995*x1996))+((x1994*x1996))+(((0.045)*x1994))+(((0.045)*x1995))+(((-1.0)*x1995*x1997))+(((-1.0)*x1994*x1997))+(((-0.3)*x2001))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
sj2=0;
cj2=1.0;
j2=0;
IkReal x2002=(py*sj0);
IkReal x2003=(cj0*px);
IkReal x2004=(pp*pz);
IkReal x2005=((0.92038656235619)*pp);
IkReal x2006=(pz*sj3);
IkReal x2007=((36.2220411120167)*pp);
IkReal x2008=((0.0254095720202485)*sj3);
j1eval[0]=((((-12.2222222222222)*x2006))+(((-1.0)*x2003*x2007))+((sj3*x2003))+((sj3*x2002))+(((-1.0)*x2002*x2007))+(((-3.92556370551481)*pz))+(((5.4333061668025)*x2004))+(((-7.28153581454315)*x2003))+(((-7.28153581454315)*x2002)));
j1eval[1]=IKsign((((x2002*x2008))+(((-0.099746893695352)*pz))+(((-1.0)*x2003*x2005))+(((-0.310561435803037)*x2006))+(((-1.0)*x2002*x2005))+(((-0.185020708697653)*x2002))+(((-0.185020708697653)*x2003))+(((0.138057984353428)*x2004))+((x2003*x2008))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
IkReal x2009=x1985;
evalcond[0]=((IKabs(pz))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=x2009;
evalcond[3]=x2009;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2010=((-1.0)*py);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x2010);
rxp0_1=(px*r20);
rxp1_0=(r21*x2010);
rxp1_1=(px*r21);
rxp2_0=(r22*x2010);
rxp2_1=(px*r22);
j1eval[0]=(((cj0*px))+((py*sj0)));
if( IKabs(j1eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[6];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(px))+(IKabs(py)));
evalcond[1]=0.7225;
evalcond[2]=-0.85;
evalcond[3]=0;
evalcond[4]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=0;
npx=0;
npy=0;
npz=0;
rxp0_0=0;
rxp0_1=0;
rxp1_0=0;
rxp1_1=0;
rxp2_0=0;
rxp2_1=0;
px=0;
py=0;
rxp0_2=0;
rxp1_2=0;
rxp2_2=0;
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j0), 6.28318530717959)))))+(IKabs(px)));
evalcond[1]=((0.7225)+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=((-1.0)*py);
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2011=((-1.0)*py);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=py*py;
npx=(py*r10);
npy=(py*r11);
npz=(py*r12);
rxp0_0=(r20*x2011);
rxp0_1=0;
rxp1_0=(r21*x2011);
rxp1_1=0;
rxp2_0=(r22*x2011);
rxp2_1=0;
px=0;
j0=0;
sj0=0;
cj0=1.0;
rxp0_2=(py*r00);
rxp1_2=(py*r01);
rxp2_2=(py*r02);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(px))+(IKabs(((-3.14159265358979)+(IKfmod(j0, 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=py;
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2012=((-1.0)*py);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=py*py;
npx=(py*r10);
npy=(py*r11);
npz=(py*r12);
rxp0_0=(r20*x2012);
rxp0_1=0;
rxp1_0=(r21*x2012);
rxp1_1=0;
rxp2_0=(r22*x2012);
rxp2_1=0;
px=0;
j0=3.14159265358979;
sj0=0;
cj0=-1.0;
rxp0_2=(py*r00);
rxp1_2=(py*r01);
rxp2_2=(py*r02);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(py))+(IKabs(((-3.14159265358979)+(IKfmod(((1.5707963267949)+j0), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(px*px))));
evalcond[2]=-0.85;
evalcond[3]=px;
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2013=((-1.0)*px);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=px*px;
npx=(px*r00);
npy=(px*r01);
npz=(px*r02);
rxp0_0=0;
rxp0_1=(px*r20);
rxp1_0=0;
rxp1_1=(px*r21);
rxp2_0=0;
rxp2_1=(px*r22);
py=0;
j0=1.5707963267949;
sj0=1.0;
cj0=0;
rxp0_2=(r10*x2013);
rxp1_2=(r11*x2013);
rxp2_2=(r12*x2013);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(py))+(IKabs(((-3.14159265358979)+(IKfmod(((4.71238898038469)+j0), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(px*px))));
evalcond[2]=-0.85;
evalcond[3]=((-1.0)*px);
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2014=((-1.0)*px);
sj2=0;
cj2=1.0;
j2=0;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=px*px;
npx=(px*r00);
npy=(px*r01);
npz=(px*r02);
rxp0_0=0;
rxp0_1=(px*r20);
rxp1_0=0;
rxp1_1=(px*r21);
rxp2_0=0;
rxp2_1=(px*r22);
py=0;
j0=-1.5707963267949;
sj0=-1.0;
cj0=0;
rxp0_2=(r10*x2014);
rxp1_2=(r11*x2014);
rxp2_2=(r12*x2014);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2015=py*py;
IkReal x2016=cj0*cj0;
IkReal x2017=(cj0*px);
IkReal x2018=(py*sj0);
IkReal x2019=((4400.0)*x2015);
CheckValue<IkReal> x2020=IKPowWithIntegerCheck(((((306.0)*x2018))+(((306.0)*x2017))),-1);
if(!x2020.valid){
continue;
}
if( IKabs(((((1.17647058823529)*x2017))+(((1.17647058823529)*x2018)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((x2020.value)*(((3179.0)+(((-1.0)*x2019))+((x2016*x2019))+(((-8800.0)*x2017*x2018))+(((-4400.0)*x2016*(px*px))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((1.17647058823529)*x2017))+(((1.17647058823529)*x2018))))+IKsqr(((x2020.value)*(((3179.0)+(((-1.0)*x2019))+((x2016*x2019))+(((-8800.0)*x2017*x2018))+(((-4400.0)*x2016*(px*px)))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j1array[0]=IKatan2(((((1.17647058823529)*x2017))+(((1.17647058823529)*x2018))), ((x2020.value)*(((3179.0)+(((-1.0)*x2019))+((x2016*x2019))+(((-8800.0)*x2017*x2018))+(((-4400.0)*x2016*(px*px)))))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x2021=IKsin(j1);
IkReal x2022=IKcos(j1);
IkReal x2023=(py*sj0);
IkReal x2024=(cj0*px);
IkReal x2025=((0.09)*x2022);
IkReal x2026=((1.0)*x2022);
IkReal x2027=((1.1)*x2021);
evalcond[0]=((-0.85)*x2022);
evalcond[1]=((-0.85)+((x2021*x2024))+((x2021*x2023)));
evalcond[2]=((((0.85)*x2021))+(((-1.0)*x2023))+(((-1.0)*x2024)));
evalcond[3]=((((-1.0)*x2023*x2026))+(((-1.0)*x2024*x2026)));
evalcond[4]=((-0.935)+((x2024*x2025))+((x2024*x2027))+((x2023*x2025))+((x2023*x2027)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2028=cj3*cj3;
IkReal x2029=(cj3*sj3);
IkReal x2030=(cj0*px);
IkReal x2031=((0.92038656235619)*pp);
IkReal x2032=((0.0254095720202485)*sj3);
IkReal x2033=(py*sj0);
IkReal x2034=(pp*sj3);
IkReal x2035=((1.0)*pz);
IkReal x2036=(cj3*pp);
CheckValue<IkReal> x2037 = IKatan2WithCheck(IkReal(((-0.100617959042798)+(((-0.0414173953060285)*x2034))+(((-0.276115968706857)*x2036))+(((-0.00114343074091118)*x2028))+(pz*pz)+(((-0.506212609295904)*pp))+(((0.00564933271974229)*sj3))+(((-0.0555062126092959)*cj3))+(((0.00762287160607455)*x2029)))),((-0.0688360561435803)+(((0.0414173953060285)*x2036))+(((0.0139752646111367)*x2028))+(((-0.0299240681086056)*cj3))+(((0.0759318913943856)*pp))+(((-0.175297399907961)*sj3))+(((-0.0931684307409112)*x2029))+(((-1.0)*x2030*x2035))+(((0.00621260929590428)*x2034))+(((-1.0)*x2033*x2035))),IKFAST_ATAN2_MAGTHRESH);
if(!x2037.valid){
continue;
}
CheckValue<IkReal> x2038=IKPowWithIntegerCheck(IKsign(((((-0.099746893695352)*pz))+((x2030*x2032))+(((-0.185020708697653)*x2033))+(((-0.185020708697653)*x2030))+(((-0.310561435803037)*pz*sj3))+((x2032*x2033))+(((-1.0)*x2030*x2031))+(((0.138057984353428)*pp*pz))+(((-1.0)*x2031*x2033)))),-1);
if(!x2038.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(x2037.value)+(((1.5707963267949)*(x2038.value))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x2039=IKsin(j1);
IkReal x2040=IKcos(j1);
IkReal x2041=((0.045)*sj3);
IkReal x2042=((0.3)*cj3);
IkReal x2043=((0.045)*cj3);
IkReal x2044=(cj0*px);
IkReal x2045=(py*sj0);
IkReal x2046=((1.0)*x2040);
IkReal x2047=(sj3*x2040);
IkReal x2048=(pz*x2039);
IkReal x2049=(pz*x2040);
IkReal x2050=((0.09)*x2040);
IkReal x2051=((1.1)*x2039);
evalcond[0]=((-0.55)+(((-1.0)*x2041))+(((-1.0)*x2042))+x2049+((x2039*x2044))+((x2039*x2045)));
evalcond[1]=((0.045)+(((-1.0)*x2043))+x2048+(((-1.0)*x2045*x2046))+(((-1.0)*x2044*x2046))+(((0.3)*sj3)));
evalcond[2]=((((-0.92038656235619)*pp*x2040))+pz+(((0.310561435803037)*sj3*x2039))+(((-0.185020708697653)*x2040))+(((0.0254095720202485)*x2047))+(((-0.138057984353428)*pp*x2039))+(((0.099746893695352)*x2039)));
evalcond[3]=((((0.045)*x2040))+(((0.55)*x2039))+(((0.3)*x2047))+((x2039*x2041))+((x2039*x2042))+(((-1.0)*x2044))+(((-1.0)*x2045))+(((-1.0)*x2040*x2043)));
evalcond[4]=((-0.2125)+(((1.1)*x2049))+((x2044*x2050))+((x2044*x2051))+(((-1.0)*pp))+((x2045*x2050))+((x2045*x2051))+(((-0.09)*x2048)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2052=cj0*cj0;
IkReal x2053=py*py;
IkReal x2054=cj3*cj3;
IkReal x2055=(py*sj0);
IkReal x2056=((0.3)*sj3);
IkReal x2057=((0.045)*cj3);
IkReal x2058=(cj0*px);
IkReal x2059=(cj3*sj3);
IkReal x2060=((1.0)*pz);
CheckValue<IkReal> x2061 = IKatan2WithCheck(IkReal(((0.03825)+(((-0.01125)*cj3))+(((-1.0)*x2058*x2060))+(((-0.027)*x2054))+(((-1.0)*x2055*x2060))+(((0.167025)*sj3))+(((0.087975)*x2059)))),((-0.304525)+(((-0.027)*x2059))+x2053+(((-0.0495)*sj3))+(((-1.0)*x2052*x2053))+(((2.0)*x2055*x2058))+(((-0.087975)*x2054))+((x2052*(px*px)))+(((-0.33)*cj3))),IKFAST_ATAN2_MAGTHRESH);
if(!x2061.valid){
continue;
}
CheckValue<IkReal> x2062=IKPowWithIntegerCheck(IKsign(((((-0.55)*pz))+(((-0.3)*cj3*pz))+((x2055*x2056))+(((-0.045)*pz*sj3))+(((-1.0)*x2057*x2058))+(((0.045)*x2055))+(((0.045)*x2058))+((x2056*x2058))+(((-1.0)*x2055*x2057)))),-1);
if(!x2062.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(x2061.value)+(((1.5707963267949)*(x2062.value))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x2063=IKsin(j1);
IkReal x2064=IKcos(j1);
IkReal x2065=((0.045)*sj3);
IkReal x2066=((0.3)*cj3);
IkReal x2067=((0.045)*cj3);
IkReal x2068=(cj0*px);
IkReal x2069=(py*sj0);
IkReal x2070=((1.0)*x2064);
IkReal x2071=(sj3*x2064);
IkReal x2072=(pz*x2063);
IkReal x2073=(pz*x2064);
IkReal x2074=((0.09)*x2064);
IkReal x2075=((1.1)*x2063);
evalcond[0]=((-0.55)+x2073+(((-1.0)*x2066))+(((-1.0)*x2065))+((x2063*x2069))+((x2063*x2068)));
evalcond[1]=((0.045)+x2072+(((-1.0)*x2067))+(((-1.0)*x2069*x2070))+(((0.3)*sj3))+(((-1.0)*x2068*x2070)));
evalcond[2]=((((0.099746893695352)*x2063))+(((-0.138057984353428)*pp*x2063))+(((-0.92038656235619)*pp*x2064))+pz+(((0.0254095720202485)*x2071))+(((0.310561435803037)*sj3*x2063))+(((-0.185020708697653)*x2064)));
evalcond[3]=((((-1.0)*x2064*x2067))+(((0.3)*x2071))+(((-1.0)*x2068))+(((-1.0)*x2069))+(((0.55)*x2063))+((x2063*x2065))+((x2063*x2066))+(((0.045)*x2064)));
evalcond[4]=((-0.2125)+((x2069*x2074))+((x2069*x2075))+((x2068*x2075))+((x2068*x2074))+(((1.1)*x2073))+(((-1.0)*pp))+(((-0.09)*x2072)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2076=cj3*cj3;
IkReal x2077=(cj0*px);
IkReal x2078=((0.00621260929590428)*pp);
IkReal x2079=(cj3*sj3);
IkReal x2080=(py*sj0);
IkReal x2081=((0.138057984353428)*pp);
IkReal x2082=((0.0414173953060285)*pp);
IkReal x2083=((0.310561435803037)*sj3);
CheckValue<IkReal> x2084=IKPowWithIntegerCheck(IKsign(((((-0.099746893695352)*x2080))+(((-0.0254095720202485)*pz*sj3))+(((-0.099746893695352)*x2077))+(((-1.0)*x2077*x2083))+(((0.185020708697653)*pz))+((x2077*x2081))+(((0.92038656235619)*pp*pz))+(((-1.0)*x2080*x2083))+((x2080*x2081)))),-1);
if(!x2084.valid){
continue;
}
CheckValue<IkReal> x2085 = IKatan2WithCheck(IkReal(((-0.000703060285319834)+(((-1.0)*x2082))+((pz*x2080))+(((-0.276115968706857)*pp*sj3))+(((-0.00762287160607455)*x2076))+(((-0.00114343074091118)*x2079))+((pz*x2077))+(((-0.0543627818683847)*sj3))+(((0.00832593189139439)*cj3))+((cj3*x2082)))),((-0.097657040957202)+x2078+(((-1.0)*cj3*x2078))+(((0.0139752646111367)*x2079))+(pz*pz)+(((0.0931684307409112)*x2076))+(((0.00448861021629084)*cj3))+((sj3*x2082))+(((-0.0438993327197423)*sj3))),IKFAST_ATAN2_MAGTHRESH);
if(!x2085.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(((1.5707963267949)*(x2084.value)))+(x2085.value));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x2086=IKsin(j1);
IkReal x2087=IKcos(j1);
IkReal x2088=((0.045)*sj3);
IkReal x2089=((0.3)*cj3);
IkReal x2090=((0.045)*cj3);
IkReal x2091=(cj0*px);
IkReal x2092=(py*sj0);
IkReal x2093=((1.0)*x2087);
IkReal x2094=(sj3*x2087);
IkReal x2095=(pz*x2086);
IkReal x2096=(pz*x2087);
IkReal x2097=((0.09)*x2087);
IkReal x2098=((1.1)*x2086);
evalcond[0]=((-0.55)+x2096+(((-1.0)*x2089))+(((-1.0)*x2088))+((x2086*x2091))+((x2086*x2092)));
evalcond[1]=((0.045)+(((-1.0)*x2090))+(((-1.0)*x2091*x2093))+x2095+(((-1.0)*x2092*x2093))+(((0.3)*sj3)));
evalcond[2]=((((-0.138057984353428)*pp*x2086))+(((-0.185020708697653)*x2087))+(((0.099746893695352)*x2086))+pz+(((0.310561435803037)*sj3*x2086))+(((-0.92038656235619)*pp*x2087))+(((0.0254095720202485)*x2094)));
evalcond[3]=((((0.045)*x2087))+((x2086*x2088))+((x2086*x2089))+(((-1.0)*x2087*x2090))+(((-1.0)*x2092))+(((-1.0)*x2091))+(((0.55)*x2086))+(((0.3)*x2094)));
evalcond[4]=((-0.2125)+(((-0.09)*x2095))+(((1.1)*x2096))+((x2091*x2098))+((x2091*x2097))+(((-1.0)*pp))+((x2092*x2098))+((x2092*x2097)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x2099=(px*sj0);
IkReal x2100=(cj0*py);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j2)))), 6.28318530717959)));
evalcond[1]=((0.39655)+(((0.0765)*sj3))+(((-1.0)*pp))+(((0.32595)*cj3)));
evalcond[2]=(x2099+(((-1.0)*x2100)));
evalcond[3]=(x2100+(((-1.0)*x2099)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[2];
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x2101=cj0*cj0;
IkReal x2102=py*py;
IkReal x2103=(((x2101*(px*px)))+x2102+(pz*pz)+(((2.0)*cj0*px*py*sj0))+(((-1.0)*x2101*x2102)));
j1eval[0]=x2103;
j1eval[1]=IKsign(x2103);
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x2104=(py*sj0);
IkReal x2105=((0.3)*sj3);
IkReal x2106=(cj0*px);
IkReal x2107=((6.66666666666667)*sj3);
IkReal x2108=(pz*sj3);
IkReal x2109=(cj3*pz);
IkReal x2110=((0.045)*x2106);
j1eval[0]=((((-1.0)*x2106*x2107))+((cj3*x2106))+((cj3*x2104))+(((-1.0)*x2104))+(((-1.0)*x2106))+(((-1.0)*x2108))+(((-12.2222222222222)*pz))+(((-1.0)*x2104*x2107))+(((-6.66666666666667)*x2109)));
j1eval[1]=IKsign(((((-0.55)*pz))+(((0.045)*cj3*x2104))+(((-0.045)*x2104))+(((-0.045)*x2108))+(((-1.0)*x2105*x2106))+(((-0.3)*x2109))+(((-1.0)*x2110))+(((-1.0)*x2104*x2105))+((cj3*x2110))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal j1eval[2];
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
IkReal x2111=(py*sj0);
IkReal x2112=(cj0*px);
IkReal x2113=(pp*pz);
IkReal x2114=((0.92038656235619)*pp);
IkReal x2115=(pz*sj3);
IkReal x2116=((36.2220411120167)*pp);
IkReal x2117=((0.0254095720202485)*sj3);
j1eval[0]=((((-5.4333061668025)*x2113))+(((-1.0)*x2112*x2116))+(((12.2222222222222)*x2115))+((sj3*x2111))+((sj3*x2112))+(((-1.0)*x2111*x2116))+(((3.92556370551481)*pz))+(((-7.28153581454315)*x2111))+(((-7.28153581454315)*x2112)));
j1eval[1]=IKsign(((((0.310561435803037)*x2115))+(((-1.0)*x2112*x2114))+((x2111*x2117))+(((-1.0)*x2111*x2114))+(((0.099746893695352)*pz))+(((-0.138057984353428)*x2113))+(((-0.185020708697653)*x2111))+(((-0.185020708697653)*x2112))+((x2112*x2117))));
if( IKabs(j1eval[0]) < 0.0000010000000000 || IKabs(j1eval[1]) < 0.0000010000000000 )
{
{
IkReal evalcond[4];
bool bgotonextstatement = true;
do
{
IkReal x2118=(px*sj0);
IkReal x2119=(cj0*py);
evalcond[0]=((IKabs(pz))+(IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j3), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*pp)));
evalcond[2]=(x2118+(((-1.0)*x2119)));
evalcond[3]=(x2119+(((-1.0)*x2118)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2120=((-1.0)*py);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=((px*px)+(py*py));
npx=(((px*r00))+((py*r10)));
npy=(((px*r01))+((py*r11)));
npz=(((px*r02))+((py*r12)));
rxp0_0=(r20*x2120);
rxp0_1=(px*r20);
rxp1_0=(r21*x2120);
rxp1_1=(px*r21);
rxp2_0=(r22*x2120);
rxp2_1=(px*r22);
j1eval[0]=((((-1.0)*py*sj0))+(((-1.0)*cj0*px)));
if( IKabs(j1eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[6];
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(px))+(IKabs(py)));
evalcond[1]=0.7225;
evalcond[2]=-0.85;
evalcond[3]=0;
evalcond[4]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=0;
npx=0;
npy=0;
npz=0;
rxp0_0=0;
rxp0_1=0;
rxp1_0=0;
rxp1_1=0;
rxp2_0=0;
rxp2_1=0;
px=0;
py=0;
rxp0_2=0;
rxp1_2=0;
rxp2_2=0;
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(((-3.14159265358979)+(IKfmod(((3.14159265358979)+j0), 6.28318530717959)))))+(IKabs(px)));
evalcond[1]=((0.7225)+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=((-1.0)*py);
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2121=((-1.0)*py);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=py*py;
npx=(py*r10);
npy=(py*r11);
npz=(py*r12);
rxp0_0=(r20*x2121);
rxp0_1=0;
rxp1_0=(r21*x2121);
rxp1_1=0;
rxp2_0=(r22*x2121);
rxp2_1=0;
px=0;
j0=0;
sj0=0;
cj0=1.0;
rxp0_2=(py*r00);
rxp1_2=(py*r01);
rxp2_2=(py*r02);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(px))+(IKabs(((-3.14159265358979)+(IKfmod(j0, 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(py*py))));
evalcond[2]=-0.85;
evalcond[3]=py;
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2122=((-1.0)*py);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=py*py;
npx=(py*r10);
npy=(py*r11);
npz=(py*r12);
rxp0_0=(r20*x2122);
rxp0_1=0;
rxp1_0=(r21*x2122);
rxp1_1=0;
rxp2_0=(r22*x2122);
rxp2_1=0;
px=0;
j0=3.14159265358979;
sj0=0;
cj0=-1.0;
rxp0_2=(py*r00);
rxp1_2=(py*r01);
rxp2_2=(py*r02);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(py))+(IKabs(((-3.14159265358979)+(IKfmod(((1.5707963267949)+j0), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(px*px))));
evalcond[2]=-0.85;
evalcond[3]=px;
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2123=((-1.0)*px);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=px*px;
npx=(px*r00);
npy=(px*r01);
npz=(px*r02);
rxp0_0=0;
rxp0_1=(px*r20);
rxp1_0=0;
rxp1_1=(px*r21);
rxp2_0=0;
rxp2_1=(px*r22);
py=0;
j0=1.5707963267949;
sj0=1.0;
cj0=0;
rxp0_2=(r10*x2123);
rxp1_2=(r11*x2123);
rxp2_2=(r12*x2123);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((IKabs(py))+(IKabs(((-3.14159265358979)+(IKfmod(((4.71238898038469)+j0), 6.28318530717959))))));
evalcond[1]=((0.7225)+(((-1.0)*(px*px))));
evalcond[2]=-0.85;
evalcond[3]=((-1.0)*px);
evalcond[4]=0;
evalcond[5]=-0.935;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j1eval[1];
IkReal x2124=((-1.0)*px);
sj2=0;
cj2=-1.0;
j2=3.14159265358979;
pz=0;
j3=0;
sj3=0;
cj3=1.0;
pp=px*px;
npx=(px*r00);
npy=(px*r01);
npz=(px*r02);
rxp0_0=0;
rxp0_1=(px*r20);
rxp1_0=0;
rxp1_1=(px*r21);
rxp2_0=0;
rxp2_1=(px*r22);
py=0;
j0=-1.5707963267949;
sj0=-1.0;
cj0=0;
rxp0_2=(r10*x2124);
rxp1_2=(r11*x2124);
rxp2_2=(r12*x2124);
j1eval[0]=1.0;
if( IKabs(j1eval[0]) < 0.0000000100000000 )
{
continue; // 3 cases reached
} else
{
IkReal op[2+1], zeror[2];
int numroots;
op[0]=1.0;
op[1]=0;
op[2]=-1.0;
polyroots2(op,zeror,numroots);
IkReal j1array[2], cj1array[2], sj1array[2], tempj1array[1];
int numsolutions = 0;
for(int ij1 = 0; ij1 < numroots; ++ij1)
{
IkReal htj1 = zeror[ij1];
tempj1array[0]=((2.0)*(atan(htj1)));
for(int kj1 = 0; kj1 < 1; ++kj1)
{
j1array[numsolutions] = tempj1array[kj1];
if( j1array[numsolutions] > IKPI )
{
j1array[numsolutions]-=IK2PI;
}
else if( j1array[numsolutions] < -IKPI )
{
j1array[numsolutions]+=IK2PI;
}
sj1array[numsolutions] = IKsin(j1array[numsolutions]);
cj1array[numsolutions] = IKcos(j1array[numsolutions]);
numsolutions++;
}
}
bool j1valid[2]={true,true};
_nj1 = 2;
for(int ij1 = 0; ij1 < numsolutions; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
htj1 = IKtan(j1/2);
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < numsolutions; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
rotationfunction0(solutions);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2125=py*py;
IkReal x2126=cj0*cj0;
IkReal x2127=(cj0*px);
IkReal x2128=(py*sj0);
IkReal x2129=((4400.0)*x2125);
CheckValue<IkReal> x2130=IKPowWithIntegerCheck(((((-306.0)*x2128))+(((-306.0)*x2127))),-1);
if(!x2130.valid){
continue;
}
if( IKabs(((((1.17647058823529)*x2128))+(((1.17647058823529)*x2127)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((x2130.value)*(((3179.0)+(((-4400.0)*x2126*(px*px)))+(((-1.0)*x2129))+((x2126*x2129))+(((-8800.0)*x2127*x2128)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((1.17647058823529)*x2128))+(((1.17647058823529)*x2127))))+IKsqr(((x2130.value)*(((3179.0)+(((-4400.0)*x2126*(px*px)))+(((-1.0)*x2129))+((x2126*x2129))+(((-8800.0)*x2127*x2128))))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j1array[0]=IKatan2(((((1.17647058823529)*x2128))+(((1.17647058823529)*x2127))), ((x2130.value)*(((3179.0)+(((-4400.0)*x2126*(px*px)))+(((-1.0)*x2129))+((x2126*x2129))+(((-8800.0)*x2127*x2128))))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x2131=IKcos(j1);
IkReal x2132=IKsin(j1);
IkReal x2133=(py*sj0);
IkReal x2134=(cj0*px);
IkReal x2135=((0.09)*x2131);
IkReal x2136=(x2132*x2133);
evalcond[0]=((-0.85)*x2131);
evalcond[1]=(((x2131*x2134))+((x2131*x2133)));
evalcond[2]=((-0.85)+x2136+((x2132*x2134)));
evalcond[3]=((((0.85)*x2132))+(((-1.0)*x2134))+(((-1.0)*x2133)));
evalcond[4]=((-0.935)+(((1.1)*x2136))+(((-1.0)*x2134*x2135))+(((1.1)*x2132*x2134))+(((-1.0)*x2133*x2135)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2137=cj3*cj3;
IkReal x2138=(cj3*sj3);
IkReal x2139=(cj0*px);
IkReal x2140=((0.92038656235619)*pp);
IkReal x2141=((0.0254095720202485)*sj3);
IkReal x2142=(py*sj0);
IkReal x2143=((0.0414173953060285)*pp);
IkReal x2144=((1.0)*pz);
CheckValue<IkReal> x2145 = IKatan2WithCheck(IkReal(((-0.100617959042798)+(((0.00762287160607455)*x2138))+(((-0.276115968706857)*cj3*pp))+(((-0.00114343074091118)*x2137))+(((-1.0)*sj3*x2143))+(pz*pz)+(((-0.506212609295904)*pp))+(((0.00564933271974229)*sj3))+(((-0.0555062126092959)*cj3)))),((0.0688360561435803)+(((0.175297399907961)*sj3))+(((-1.0)*x2142*x2144))+(((0.0931684307409112)*x2138))+(((-0.00621260929590428)*pp*sj3))+(((-0.0139752646111367)*x2137))+(((-0.0759318913943856)*pp))+(((0.0299240681086056)*cj3))+(((-1.0)*cj3*x2143))+(((-1.0)*x2139*x2144))),IKFAST_ATAN2_MAGTHRESH);
if(!x2145.valid){
continue;
}
CheckValue<IkReal> x2146=IKPowWithIntegerCheck(IKsign(((((-0.185020708697653)*x2139))+(((-0.138057984353428)*pp*pz))+(((0.310561435803037)*pz*sj3))+(((-1.0)*x2140*x2142))+((x2141*x2142))+(((0.099746893695352)*pz))+(((-0.185020708697653)*x2142))+(((-1.0)*x2139*x2140))+((x2139*x2141)))),-1);
if(!x2146.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(x2145.value)+(((1.5707963267949)*(x2146.value))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x2147=IKsin(j1);
IkReal x2148=IKcos(j1);
IkReal x2149=((0.045)*sj3);
IkReal x2150=((0.3)*cj3);
IkReal x2151=((0.045)*cj3);
IkReal x2152=(cj0*px);
IkReal x2153=(py*sj0);
IkReal x2154=(sj3*x2148);
IkReal x2155=(pz*x2147);
IkReal x2156=(pz*x2148);
IkReal x2157=((0.09)*x2148);
IkReal x2158=((1.1)*x2147);
evalcond[0]=((-0.55)+((x2147*x2152))+((x2147*x2153))+x2156+(((-1.0)*x2149))+(((-1.0)*x2150)));
evalcond[1]=((0.045)+(((-1.0)*x2151))+((x2148*x2153))+((x2148*x2152))+(((0.3)*sj3))+(((-1.0)*x2155)));
evalcond[2]=((((-0.310561435803037)*sj3*x2147))+(((-0.099746893695352)*x2147))+pz+(((0.0254095720202485)*x2154))+(((0.138057984353428)*pp*x2147))+(((-0.185020708697653)*x2148))+(((-0.92038656235619)*pp*x2148)));
evalcond[3]=(((x2147*x2150))+(((-0.3)*x2154))+(((-0.045)*x2148))+((x2148*x2151))+(((0.55)*x2147))+(((-1.0)*x2152))+(((-1.0)*x2153))+((x2147*x2149)));
evalcond[4]=((-0.2125)+((x2152*x2158))+(((-1.0)*x2152*x2157))+(((-1.0)*x2153*x2157))+(((-1.0)*pp))+(((0.09)*x2155))+(((1.1)*x2156))+((x2153*x2158)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2159=cj0*cj0;
IkReal x2160=py*py;
IkReal x2161=cj3*cj3;
IkReal x2162=(py*sj0);
IkReal x2163=((0.3)*sj3);
IkReal x2164=((0.045)*cj3);
IkReal x2165=(cj0*px);
IkReal x2166=(cj3*sj3);
IkReal x2167=((1.0)*pz);
CheckValue<IkReal> x2168=IKPowWithIntegerCheck(IKsign(((((-0.55)*pz))+(((-0.3)*cj3*pz))+(((-1.0)*x2163*x2165))+((x2164*x2165))+(((-0.045)*pz*sj3))+(((-0.045)*x2165))+(((-0.045)*x2162))+((x2162*x2164))+(((-1.0)*x2162*x2163)))),-1);
if(!x2168.valid){
continue;
}
CheckValue<IkReal> x2169 = IKatan2WithCheck(IkReal(((-0.03825)+(((0.01125)*cj3))+(((-0.167025)*sj3))+(((0.027)*x2161))+(((-1.0)*x2165*x2167))+(((-0.087975)*x2166))+(((-1.0)*x2162*x2167)))),((-0.304525)+(((2.0)*x2162*x2165))+((x2159*(px*px)))+(((-0.0495)*sj3))+x2160+(((-0.027)*x2166))+(((-0.087975)*x2161))+(((-0.33)*cj3))+(((-1.0)*x2159*x2160))),IKFAST_ATAN2_MAGTHRESH);
if(!x2169.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(((1.5707963267949)*(x2168.value)))+(x2169.value));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x2170=IKsin(j1);
IkReal x2171=IKcos(j1);
IkReal x2172=((0.045)*sj3);
IkReal x2173=((0.3)*cj3);
IkReal x2174=((0.045)*cj3);
IkReal x2175=(cj0*px);
IkReal x2176=(py*sj0);
IkReal x2177=(sj3*x2171);
IkReal x2178=(pz*x2170);
IkReal x2179=(pz*x2171);
IkReal x2180=((0.09)*x2171);
IkReal x2181=((1.1)*x2170);
evalcond[0]=((-0.55)+((x2170*x2176))+((x2170*x2175))+x2179+(((-1.0)*x2173))+(((-1.0)*x2172)));
evalcond[1]=((0.045)+((x2171*x2176))+((x2171*x2175))+(((-1.0)*x2178))+(((0.3)*sj3))+(((-1.0)*x2174)));
evalcond[2]=((((-0.310561435803037)*sj3*x2170))+(((0.138057984353428)*pp*x2170))+pz+(((-0.099746893695352)*x2170))+(((0.0254095720202485)*x2177))+(((-0.92038656235619)*pp*x2171))+(((-0.185020708697653)*x2171)));
evalcond[3]=((((0.55)*x2170))+((x2170*x2172))+((x2170*x2173))+(((-0.3)*x2177))+((x2171*x2174))+(((-0.045)*x2171))+(((-1.0)*x2176))+(((-1.0)*x2175)));
evalcond[4]=((-0.2125)+(((-1.0)*x2175*x2180))+(((-1.0)*pp))+((x2176*x2181))+(((1.1)*x2179))+(((-1.0)*x2176*x2180))+((x2175*x2181))+(((0.09)*x2178)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2182=cj0*cj0;
IkReal x2183=py*py;
IkReal x2184=(pz*sj3);
IkReal x2185=(py*sj0);
IkReal x2186=((0.3)*cj3);
IkReal x2187=((0.045)*sj3);
IkReal x2188=((0.045)*cj3);
IkReal x2189=(cj0*px);
IkReal x2190=((0.3)*sj3);
CheckValue<IkReal> x2191=IKPowWithIntegerCheck(IKsign(((((2.0)*x2185*x2189))+x2183+((x2182*(px*px)))+(pz*pz)+(((-1.0)*x2182*x2183)))),-1);
if(!x2191.valid){
continue;
}
CheckValue<IkReal> x2192 = IKatan2WithCheck(IkReal(((((0.3)*x2184))+(((0.045)*pz))+((x2186*x2189))+(((-1.0)*pz*x2188))+((x2187*x2189))+(((0.55)*x2185))+(((0.55)*x2189))+((x2185*x2186))+((x2185*x2187)))),(((pz*x2186))+(((-1.0)*x2189*x2190))+(((-1.0)*x2185*x2190))+(((-0.045)*x2189))+(((-0.045)*x2185))+((x2188*x2189))+(((0.045)*x2184))+(((0.55)*pz))+((x2185*x2188))),IKFAST_ATAN2_MAGTHRESH);
if(!x2192.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(((1.5707963267949)*(x2191.value)))+(x2192.value));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[5];
IkReal x2193=IKsin(j1);
IkReal x2194=IKcos(j1);
IkReal x2195=((0.045)*sj3);
IkReal x2196=((0.3)*cj3);
IkReal x2197=((0.045)*cj3);
IkReal x2198=(cj0*px);
IkReal x2199=(py*sj0);
IkReal x2200=(sj3*x2194);
IkReal x2201=(pz*x2193);
IkReal x2202=(pz*x2194);
IkReal x2203=((0.09)*x2194);
IkReal x2204=((1.1)*x2193);
evalcond[0]=((-0.55)+x2202+((x2193*x2198))+((x2193*x2199))+(((-1.0)*x2196))+(((-1.0)*x2195)));
evalcond[1]=((0.045)+(((-1.0)*x2201))+((x2194*x2198))+((x2194*x2199))+(((-1.0)*x2197))+(((0.3)*sj3)));
evalcond[2]=((((-0.92038656235619)*pp*x2194))+(((0.0254095720202485)*x2200))+(((-0.310561435803037)*sj3*x2193))+(((-0.185020708697653)*x2194))+(((0.138057984353428)*pp*x2193))+pz+(((-0.099746893695352)*x2193)));
evalcond[3]=((((-0.3)*x2200))+((x2193*x2195))+((x2193*x2196))+((x2194*x2197))+(((-1.0)*x2198))+(((-1.0)*x2199))+(((-0.045)*x2194))+(((0.55)*x2193)));
evalcond[4]=((-0.2125)+((x2198*x2204))+(((0.09)*x2201))+(((-1.0)*pp))+(((-1.0)*x2198*x2203))+(((-1.0)*x2199*x2203))+((x2199*x2204))+(((1.1)*x2202)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j1]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2205=cj2*cj2;
IkReal x2206=((0.045)*px);
IkReal x2207=(sj0*sj2);
IkReal x2208=(pz*sj2);
IkReal x2209=(cj0*cj3);
IkReal x2210=((0.55)*cj2);
IkReal x2211=(px*sj0);
IkReal x2212=(cj0*py);
IkReal x2213=((0.3)*cj3);
IkReal x2214=((0.3)*sj3);
IkReal x2215=((0.045)*sj3);
IkReal x2216=(sj0*x2205);
IkReal x2217=(cj0*cj2*sj2);
IkReal x2218=((0.3)*cj2*py);
IkReal x2219=((0.045)*x2205);
IkReal x2220=((0.045)*cj2*py);
CheckValue<IkReal> x2221=IKPowWithIntegerCheck(IKsign(((((-1.0)*x2208*x2213))+(((-1.0)*x2208*x2215))+(((-1.0)*cj2*sj2*x2206*x2209))+((x2206*x2217))+((px*x2214*x2217))+(((-1.0)*cj3*x2207*x2220))+(((-0.55)*x2208))+((x2207*x2220))+((cj2*py*x2207*x2214)))),-1);
if(!x2221.valid){
continue;
}
CheckValue<IkReal> x2222 = IKatan2WithCheck(IkReal(((((-1.0)*x2210*x2211))+((cj2*x2212*x2215))+((x2210*x2212))+(((-1.0)*py*pz*x2207))+(((-1.0)*cj0*px*x2208))+(((-1.0)*cj2*x2211*x2213))+(((-1.0)*cj2*sj0*sj3*x2206))+((x2209*x2218)))),(((cj3*x2206*x2216))+(((-1.0)*x2205*x2211*x2214))+(((-1.0)*pz*x2208))+((x2205*x2212*x2214))+((x2212*x2219))+(((-1.0)*py*x2209*x2219))+(((-1.0)*x2206*x2216))),IKFAST_ATAN2_MAGTHRESH);
if(!x2222.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(((1.5707963267949)*(x2221.value)))+(x2222.value));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[6];
IkReal x2223=IKsin(j1);
IkReal x2224=IKcos(j1);
IkReal x2225=(px*sj2);
IkReal x2226=((0.3)*sj3);
IkReal x2227=((0.09)*sj0);
IkReal x2228=(cj2*px);
IkReal x2229=((0.045)*cj3);
IkReal x2230=((0.045)*cj2);
IkReal x2231=(py*sj0);
IkReal x2232=((0.045)*sj3);
IkReal x2233=((1.0)*cj0);
IkReal x2234=((0.3)*cj3);
IkReal x2235=(py*sj2);
IkReal x2236=(cj0*x2224);
IkReal x2237=(cj3*x2223);
IkReal x2238=(cj2*x2224);
IkReal x2239=(cj2*x2223);
IkReal x2240=(pz*x2224);
IkReal x2241=(cj0*px*x2223);
evalcond[0]=((-0.55)+x2240+x2241+(((-1.0)*x2234))+(((-1.0)*x2232))+((x2223*x2231)));
evalcond[1]=((((-1.0)*cj2*py*x2233))+((sj0*x2228))+((x2225*x2236))+((sj2*x2224*x2231))+(((-1.0)*pz*sj2*x2223)));
evalcond[2]=((((-0.55)*x2224))+((x2226*x2239))+(((-1.0)*x2224*x2234))+(((-1.0)*x2224*x2232))+(((-1.0)*x2229*x2239))+pz+((x2223*x2230)));
evalcond[3]=((0.045)+((pz*x2239))+x2226+(((-1.0)*x2231*x2238))+((sj0*x2225))+(((-1.0)*x2224*x2228*x2233))+(((-1.0)*x2229))+(((-1.0)*x2233*x2235)));
evalcond[4]=(((x2226*x2238))+(((-1.0)*x2229*x2238))+((x2224*x2230))+(((-1.0)*x2231))+(((-1.0)*px*x2233))+((x2223*x2232))+((x2223*x2234))+(((0.55)*x2223)));
evalcond[5]=((-0.2125)+(((-1.0)*x2225*x2227))+((py*x2227*x2238))+(((-1.0)*pp))+(((0.09)*cj0*x2235))+(((-0.09)*pz*x2239))+(((1.1)*x2240))+(((1.1)*x2241))+(((1.1)*x2223*x2231))+(((0.09)*x2228*x2236)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2242=cj0*cj0;
IkReal x2243=py*py;
IkReal x2244=px*px;
IkReal x2245=(px*py);
IkReal x2246=((1.0)*cj2);
IkReal x2247=(cj0*sj2);
IkReal x2248=(cj2*sj0);
IkReal x2249=((0.3)*cj3);
IkReal x2250=(pz*sj2);
IkReal x2251=((0.045)*sj3);
IkReal x2252=(sj2*x2243);
IkReal x2253=(py*sj0*sj2);
CheckValue<IkReal> x2254 = IKatan2WithCheck(IkReal(((((0.55)*px*x2247))+((px*x2247*x2251))+((px*x2247*x2249))+((px*pz*x2248))+((x2249*x2253))+(((0.55)*x2253))+((x2251*x2253))+(((-1.0)*cj0*py*pz*x2246)))),(((x2249*x2250))+(((2.0)*cj2*x2242*x2245))+(((0.55)*x2250))+((cj0*x2243*x2248))+((x2250*x2251))+(((-1.0)*x2245*x2246))+(((-1.0)*cj0*sj0*x2244*x2246))),IKFAST_ATAN2_MAGTHRESH);
if(!x2254.valid){
continue;
}
CheckValue<IkReal> x2255=IKPowWithIntegerCheck(IKsign((x2252+((sj2*x2242*x2244))+(((-1.0)*x2242*x2252))+(((2.0)*sj0*x2245*x2247))+((pz*x2250)))),-1);
if(!x2255.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(x2254.value)+(((1.5707963267949)*(x2255.value))));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[6];
IkReal x2256=IKsin(j1);
IkReal x2257=IKcos(j1);
IkReal x2258=(px*sj2);
IkReal x2259=((0.3)*sj3);
IkReal x2260=((0.09)*sj0);
IkReal x2261=(cj2*px);
IkReal x2262=((0.045)*cj3);
IkReal x2263=((0.045)*cj2);
IkReal x2264=(py*sj0);
IkReal x2265=((0.045)*sj3);
IkReal x2266=((1.0)*cj0);
IkReal x2267=((0.3)*cj3);
IkReal x2268=(py*sj2);
IkReal x2269=(cj0*x2257);
IkReal x2270=(cj3*x2256);
IkReal x2271=(cj2*x2257);
IkReal x2272=(cj2*x2256);
IkReal x2273=(pz*x2257);
IkReal x2274=(cj0*px*x2256);
evalcond[0]=((-0.55)+((x2256*x2264))+x2274+x2273+(((-1.0)*x2267))+(((-1.0)*x2265)));
evalcond[1]=((((-1.0)*pz*sj2*x2256))+((x2258*x2269))+((sj0*x2261))+(((-1.0)*cj2*py*x2266))+((sj2*x2257*x2264)));
evalcond[2]=(((x2256*x2263))+((x2259*x2272))+(((-1.0)*x2257*x2267))+(((-1.0)*x2257*x2265))+pz+(((-0.55)*x2257))+(((-1.0)*x2262*x2272)));
evalcond[3]=((0.045)+x2259+(((-1.0)*x2257*x2261*x2266))+((pz*x2272))+((sj0*x2258))+(((-1.0)*x2262))+(((-1.0)*x2264*x2271))+(((-1.0)*x2266*x2268)));
evalcond[4]=(((x2256*x2265))+((x2256*x2267))+((x2257*x2263))+((x2259*x2271))+(((-1.0)*px*x2266))+(((0.55)*x2256))+(((-1.0)*x2262*x2271))+(((-1.0)*x2264)));
evalcond[5]=((-0.2125)+(((1.1)*x2273))+(((1.1)*x2274))+(((1.1)*x2256*x2264))+(((-0.09)*pz*x2272))+(((0.09)*x2261*x2269))+(((-1.0)*x2258*x2260))+(((-1.0)*pp))+(((0.09)*cj0*x2268))+((py*x2260*x2271)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
} else
{
{
IkReal j1array[1], cj1array[1], sj1array[1];
bool j1valid[1]={false};
_nj1 = 1;
IkReal x2275=cj3*cj3;
IkReal x2276=(cj2*sj3);
IkReal x2277=(py*sj0);
IkReal x2278=((0.3)*cj3);
IkReal x2279=((0.045)*sj3);
IkReal x2280=(cj0*px);
IkReal x2281=(cj2*cj3);
IkReal x2282=((0.045)*pz);
IkReal x2283=((1.0)*pz);
CheckValue<IkReal> x2284=IKPowWithIntegerCheck(IKsign(((((-1.0)*cj2*x2282))+((x2281*x2282))+(((-0.55)*x2277))+(((-1.0)*x2278*x2280))+(((-1.0)*x2279*x2280))+(((-1.0)*x2277*x2279))+(((-1.0)*x2277*x2278))+(((-0.55)*x2280))+(((-0.3)*pz*x2276)))),-1);
if(!x2284.valid){
continue;
}
CheckValue<IkReal> x2285 = IKatan2WithCheck(IkReal(((-0.304525)+(((-0.0495)*sj3))+(((-0.027)*cj3*sj3))+(pz*pz)+(((-0.087975)*x2275))+(((-0.33)*cj3)))),((((-1.0)*x2280*x2283))+(((-1.0)*x2277*x2283))+(((0.01125)*x2281))+(((-0.087975)*cj3*x2276))+(((-0.167025)*x2276))+(((0.027)*cj2*x2275))+(((-0.03825)*cj2))),IKFAST_ATAN2_MAGTHRESH);
if(!x2285.valid){
continue;
}
j1array[0]=((-1.5707963267949)+(((1.5707963267949)*(x2284.value)))+(x2285.value));
sj1array[0]=IKsin(j1array[0]);
cj1array[0]=IKcos(j1array[0]);
if( j1array[0] > IKPI )
{
j1array[0]-=IK2PI;
}
else if( j1array[0] < -IKPI )
{ j1array[0]+=IK2PI;
}
j1valid[0] = true;
for(int ij1 = 0; ij1 < 1; ++ij1)
{
if( !j1valid[ij1] )
{
continue;
}
_ij1[0] = ij1; _ij1[1] = -1;
for(int iij1 = ij1+1; iij1 < 1; ++iij1)
{
if( j1valid[iij1] && IKabs(cj1array[ij1]-cj1array[iij1]) < IKFAST_SOLUTION_THRESH && IKabs(sj1array[ij1]-sj1array[iij1]) < IKFAST_SOLUTION_THRESH )
{
j1valid[iij1]=false; _ij1[1] = iij1; break;
}
}
j1 = j1array[ij1]; cj1 = cj1array[ij1]; sj1 = sj1array[ij1];
{
IkReal evalcond[6];
IkReal x2286=IKsin(j1);
IkReal x2287=IKcos(j1);
IkReal x2288=(px*sj2);
IkReal x2289=((0.3)*sj3);
IkReal x2290=((0.09)*sj0);
IkReal x2291=(cj2*px);
IkReal x2292=((0.045)*cj3);
IkReal x2293=((0.045)*cj2);
IkReal x2294=(py*sj0);
IkReal x2295=((0.045)*sj3);
IkReal x2296=((1.0)*cj0);
IkReal x2297=((0.3)*cj3);
IkReal x2298=(py*sj2);
IkReal x2299=(cj0*x2287);
IkReal x2300=(cj3*x2286);
IkReal x2301=(cj2*x2287);
IkReal x2302=(cj2*x2286);
IkReal x2303=(pz*x2287);
IkReal x2304=(cj0*px*x2286);
evalcond[0]=((-0.55)+x2303+x2304+((x2286*x2294))+(((-1.0)*x2297))+(((-1.0)*x2295)));
evalcond[1]=(((sj0*x2291))+((sj2*x2287*x2294))+(((-1.0)*cj2*py*x2296))+(((-1.0)*pz*sj2*x2286))+((x2288*x2299)));
evalcond[2]=((((-1.0)*x2292*x2302))+(((-1.0)*x2287*x2295))+(((-1.0)*x2287*x2297))+pz+((x2286*x2293))+(((-0.55)*x2287))+((x2289*x2302)));
evalcond[3]=((0.045)+x2289+((pz*x2302))+((sj0*x2288))+(((-1.0)*x2296*x2298))+(((-1.0)*x2292))+(((-1.0)*x2294*x2301))+(((-1.0)*x2287*x2291*x2296)));
evalcond[4]=((((-1.0)*x2292*x2301))+(((-1.0)*x2294))+((x2287*x2293))+(((0.55)*x2286))+((x2286*x2295))+((x2286*x2297))+(((-1.0)*px*x2296))+((x2289*x2301)));
evalcond[5]=((-0.2125)+(((-0.09)*pz*x2302))+(((1.1)*x2304))+(((1.1)*x2303))+(((0.09)*cj0*x2298))+(((-1.0)*pp))+(((-1.0)*x2288*x2290))+(((0.09)*x2291*x2299))+((py*x2290*x2301))+(((1.1)*x2286*x2294)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
rotationfunction0(solutions);
}
}
}
}
}
}
}
}
}
}
}
return solutions.GetNumSolutions()>0;
}
inline void rotationfunction0(IkSolutionListBase<IkReal>& solutions) {
for(int rotationiter = 0; rotationiter < 1; ++rotationiter) {
IkReal x159=((1.0)*cj3);
IkReal x160=(sj0*sj2);
IkReal x161=(cj2*sj1);
IkReal x162=((1.0)*sj3);
IkReal x163=(cj1*cj2);
IkReal x164=(sj1*sj2);
IkReal x165=(cj0*sj2);
IkReal x166=((1.0)*cj1);
IkReal x167=(((cj3*x163))+(((-1.0)*sj1*x162)));
IkReal x168=((((-1.0)*x160*x166))+((cj0*cj2)));
IkReal x169=(((sj3*x163))+((cj3*sj1)));
IkReal x170=((((-1.0)*x161*x162))+((cj1*cj3)));
IkReal x171=(cj0*x167);
IkReal x172=((((-1.0)*x159*x161))+(((-1.0)*cj1*x162)));
IkReal x173=((((-1.0)*cj2*sj0))+(((-1.0)*x165*x166)));
IkReal x174=(((sj0*x167))+((cj3*x165)));
IkReal x175=(((cj0*x169))+(((-1.0)*x160*x162)));
IkReal x176=(((sj3*x165))+((sj0*x169)));
IkReal x177=((((-1.0)*cj3*x160))+x171);
new_r00=(((r20*x172))+((r00*(((((-1.0)*x159*x160))+x171))))+((r10*x174)));
new_r01=(((r01*x177))+((r21*x172))+((r11*x174)));
new_r02=(((r22*x172))+((r12*x174))+((r02*x177)));
new_r10=(((r00*x173))+((r20*x164))+((r10*x168)));
new_r11=(((r01*x173))+((r21*x164))+((r11*x168)));
new_r12=(((r22*x164))+((r12*x168))+((r02*x173)));
new_r20=(((r00*x175))+((r20*x170))+((r10*x176)));
new_r21=(((r01*x175))+((r21*x170))+((r11*x176)));
new_r22=(((r22*x170))+((r12*x176))+((r02*x175)));
{
IkReal j5array[2], cj5array[2], sj5array[2];
bool j5valid[2]={false};
_nj5 = 2;
cj5array[0]=new_r22;
if( cj5array[0] >= -1-IKFAST_SINCOS_THRESH && cj5array[0] <= 1+IKFAST_SINCOS_THRESH )
{
j5valid[0] = j5valid[1] = true;
j5array[0] = IKacos(cj5array[0]);
sj5array[0] = IKsin(j5array[0]);
cj5array[1] = cj5array[0];
j5array[1] = -j5array[0];
sj5array[1] = -sj5array[0];
}
else if( isnan(cj5array[0]) )
{
// probably any value will work
j5valid[0] = true;
cj5array[0] = 1; sj5array[0] = 0; j5array[0] = 0;
}
for(int ij5 = 0; ij5 < 2; ++ij5)
{
if( !j5valid[ij5] )
{
continue;
}
_ij5[0] = ij5; _ij5[1] = -1;
for(int iij5 = ij5+1; iij5 < 2; ++iij5)
{
if( j5valid[iij5] && IKabs(cj5array[ij5]-cj5array[iij5]) < IKFAST_SOLUTION_THRESH && IKabs(sj5array[ij5]-sj5array[iij5]) < IKFAST_SOLUTION_THRESH )
{
j5valid[iij5]=false; _ij5[1] = iij5; break;
}
}
j5 = j5array[ij5]; cj5 = cj5array[ij5]; sj5 = sj5array[ij5];
{
IkReal j4eval[2];
IkReal x178=((1.0)*cj3);
IkReal x179=(sj0*sj2);
IkReal x180=(cj2*sj1);
IkReal x181=((1.0)*sj3);
IkReal x182=(cj1*cj2);
IkReal x183=(sj1*sj2);
IkReal x184=(cj0*sj2);
IkReal x185=((1.0)*cj1);
IkReal x186=x167;
IkReal x187=x168;
IkReal x188=x169;
IkReal x189=x170;
IkReal x190=(cj0*x186);
IkReal x191=x172;
IkReal x192=x173;
IkReal x193=(((sj0*x186))+((cj3*x184)));
IkReal x194=(((cj0*x188))+(((-1.0)*x179*x181)));
IkReal x195=(((sj3*x184))+((sj0*x188)));
IkReal x196=(x190+(((-1.0)*cj3*x179)));
new_r00=(((r20*x191))+((r10*x193))+((r00*((x190+(((-1.0)*x178*x179)))))));
new_r01=(((r01*x196))+((r21*x191))+((r11*x193)));
new_r02=(((r12*x193))+((r22*x191))+((r02*x196)));
new_r10=(((r00*x192))+((r20*x183))+((r10*x187)));
new_r11=(((r01*x192))+((r21*x183))+((r11*x187)));
new_r12=(((r12*x187))+((r02*x192))+((r22*x183)));
new_r20=(((r00*x194))+((r20*x189))+((r10*x195)));
new_r21=(((r01*x194))+((r21*x189))+((r11*x195)));
new_r22=(((r12*x195))+((r02*x194))+((r22*x189)));
j4eval[0]=sj5;
j4eval[1]=IKsign(sj5);
if( IKabs(j4eval[0]) < 0.0000010000000000 || IKabs(j4eval[1]) < 0.0000010000000000 )
{
{
IkReal j4eval[1];
IkReal x197=((1.0)*cj3);
IkReal x198=(sj0*sj2);
IkReal x199=(cj2*sj1);
IkReal x200=((1.0)*sj3);
IkReal x201=(cj1*cj2);
IkReal x202=(sj1*sj2);
IkReal x203=(cj0*sj2);
IkReal x204=((1.0)*cj1);
IkReal x205=x167;
IkReal x206=x168;
IkReal x207=x169;
IkReal x208=x170;
IkReal x209=(cj0*x205);
IkReal x210=x172;
IkReal x211=x173;
IkReal x212=(((sj0*x205))+((cj3*x203)));
IkReal x213=((((-1.0)*x198*x200))+((cj0*x207)));
IkReal x214=(((sj3*x203))+((sj0*x207)));
IkReal x215=((((-1.0)*cj3*x198))+x209);
new_r00=(((r00*(((((-1.0)*x197*x198))+x209))))+((r10*x212))+((r20*x210)));
new_r01=(((r21*x210))+((r11*x212))+((r01*x215)));
new_r02=(((r12*x212))+((r02*x215))+((r22*x210)));
new_r10=(((r10*x206))+((r20*x202))+((r00*x211)));
new_r11=(((r11*x206))+((r21*x202))+((r01*x211)));
new_r12=(((r22*x202))+((r02*x211))+((r12*x206)));
new_r20=(((r20*x208))+((r00*x213))+((r10*x214)));
new_r21=(((r11*x214))+((r21*x208))+((r01*x213)));
new_r22=(((r22*x208))+((r12*x214))+((r02*x213)));
j4eval[0]=sj5;
if( IKabs(j4eval[0]) < 0.0000010000000000 )
{
{
IkReal evalcond[6];
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j5))), 6.28318530717959)));
evalcond[1]=((-1.0)+new_r22);
evalcond[2]=new_r20;
evalcond[3]=new_r02;
evalcond[4]=new_r12;
evalcond[5]=new_r21;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[2], cj4array[2], sj4array[2];
bool j4valid[2]={false};
_nj4 = 2;
CheckValue<IkReal> x217 = IKatan2WithCheck(IkReal(new_r02),new_r12,IKFAST_ATAN2_MAGTHRESH);
if(!x217.valid){
continue;
}
IkReal x216=x217.value;
j4array[0]=((-1.0)*x216);
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
j4array[1]=((3.14159265358979)+(((-1.0)*x216)));
sj4array[1]=IKsin(j4array[1]);
cj4array[1]=IKcos(j4array[1]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
if( j4array[1] > IKPI )
{
j4array[1]-=IK2PI;
}
else if( j4array[1] < -IKPI )
{ j4array[1]+=IK2PI;
}
j4valid[1] = true;
for(int ij4 = 0; ij4 < 2; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 2; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[1];
evalcond[0]=(((new_r12*(IKcos(j4))))+(((-1.0)*new_r02*(IKsin(j4)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x218=((1.0)*new_r01);
if( IKabs(((((-1.0)*cj4*x218))+(((-1.0)*new_r00*sj4)))) < IKFAST_ATAN2_MAGTHRESH && IKabs((((cj4*new_r00))+(((-1.0)*sj4*x218)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.0)*cj4*x218))+(((-1.0)*new_r00*sj4))))+IKsqr((((cj4*new_r00))+(((-1.0)*sj4*x218))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(((((-1.0)*cj4*x218))+(((-1.0)*new_r00*sj4))), (((cj4*new_r00))+(((-1.0)*sj4*x218))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x219=IKsin(j6);
IkReal x220=IKcos(j6);
IkReal x221=((1.0)*sj4);
IkReal x222=((1.0)*x220);
IkReal x223=(sj4*x219);
IkReal x224=(sj4*x220);
IkReal x225=(cj4*x219);
IkReal x226=(cj4*x222);
evalcond[0]=(((cj4*new_r01))+((new_r11*sj4))+x219);
evalcond[1]=(x225+x224+new_r01);
evalcond[2]=(((cj4*new_r00))+((new_r10*sj4))+(((-1.0)*x222)));
evalcond[3]=(((cj4*new_r10))+(((-1.0)*x219))+(((-1.0)*new_r00*x221)));
evalcond[4]=((((-1.0)*new_r01*x221))+((cj4*new_r11))+(((-1.0)*x222)));
evalcond[5]=(x223+new_r00+(((-1.0)*x226)));
evalcond[6]=(x223+new_r11+(((-1.0)*x226)));
evalcond[7]=((((-1.0)*x220*x221))+new_r10+(((-1.0)*x225)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j5)))), 6.28318530717959)));
evalcond[1]=((1.0)+new_r22);
evalcond[2]=new_r20;
evalcond[3]=new_r02;
evalcond[4]=new_r12;
evalcond[5]=new_r21;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j4array[2], cj4array[2], sj4array[2];
bool j4valid[2]={false};
_nj4 = 2;
CheckValue<IkReal> x228 = IKatan2WithCheck(IkReal(new_r02),new_r12,IKFAST_ATAN2_MAGTHRESH);
if(!x228.valid){
continue;
}
IkReal x227=x228.value;
j4array[0]=((-1.0)*x227);
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
j4array[1]=((3.14159265358979)+(((-1.0)*x227)));
sj4array[1]=IKsin(j4array[1]);
cj4array[1]=IKcos(j4array[1]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
if( j4array[1] > IKPI )
{
j4array[1]-=IK2PI;
}
else if( j4array[1] < -IKPI )
{ j4array[1]+=IK2PI;
}
j4valid[1] = true;
for(int ij4 = 0; ij4 < 2; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 2; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[1];
evalcond[0]=(((new_r12*(IKcos(j4))))+(((-1.0)*new_r02*(IKsin(j4)))));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x229=((1.0)*new_r00);
if( IKabs((((cj4*new_r01))+(((-1.0)*sj4*x229)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*cj4*x229))+(((-1.0)*new_r01*sj4)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((cj4*new_r01))+(((-1.0)*sj4*x229))))+IKsqr(((((-1.0)*cj4*x229))+(((-1.0)*new_r01*sj4))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2((((cj4*new_r01))+(((-1.0)*sj4*x229))), ((((-1.0)*cj4*x229))+(((-1.0)*new_r01*sj4))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x230=IKcos(j6);
IkReal x231=IKsin(j6);
IkReal x232=((1.0)*sj4);
IkReal x233=((1.0)*x231);
IkReal x234=(sj4*x230);
IkReal x235=((1.0)*x230);
IkReal x236=(cj4*x233);
evalcond[0]=(((cj4*new_r00))+((new_r10*sj4))+x230);
evalcond[1]=(((cj4*new_r01))+((new_r11*sj4))+(((-1.0)*x233)));
evalcond[2]=(((sj4*x231))+((cj4*x230))+new_r00);
evalcond[3]=(((cj4*new_r10))+(((-1.0)*x233))+(((-1.0)*new_r00*x232)));
evalcond[4]=(((cj4*new_r11))+(((-1.0)*x235))+(((-1.0)*new_r01*x232)));
evalcond[5]=((((-1.0)*x236))+x234+new_r01);
evalcond[6]=((((-1.0)*x236))+x234+new_r10);
evalcond[7]=((((-1.0)*cj4*x235))+(((-1.0)*x231*x232))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j4, j6]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x238=IKPowWithIntegerCheck(sj5,-1);
if(!x238.valid){
continue;
}
IkReal x237=x238.value;
CheckValue<IkReal> x239=IKPowWithIntegerCheck(new_r12,-1);
if(!x239.valid){
continue;
}
if( IKabs((x237*(x239.value)*(((1.0)+(((-1.0)*(new_r02*new_r02)))+(((-1.0)*(cj5*cj5))))))) < IKFAST_ATAN2_MAGTHRESH && IKabs((new_r02*x237)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x237*(x239.value)*(((1.0)+(((-1.0)*(new_r02*new_r02)))+(((-1.0)*(cj5*cj5)))))))+IKsqr((new_r02*x237))-1) <= IKFAST_SINCOS_THRESH )
continue;
j4array[0]=IKatan2((x237*(x239.value)*(((1.0)+(((-1.0)*(new_r02*new_r02)))+(((-1.0)*(cj5*cj5)))))), (new_r02*x237));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x240=IKcos(j4);
IkReal x241=IKsin(j4);
IkReal x242=((1.0)*sj5);
IkReal x243=((1.0)*cj5);
IkReal x244=(new_r12*x241);
IkReal x245=(new_r02*x240);
evalcond[0]=((((-1.0)*x240*x242))+new_r02);
evalcond[1]=((((-1.0)*x241*x242))+new_r12);
evalcond[2]=(((new_r12*x240))+(((-1.0)*new_r02*x241)));
evalcond[3]=(x245+x244+(((-1.0)*x242)));
evalcond[4]=(((cj5*x244))+((cj5*x245))+(((-1.0)*new_r22*x242)));
evalcond[5]=((((-1.0)*new_r10*x241*x242))+(((-1.0)*new_r00*x240*x242))+(((-1.0)*new_r20*x243)));
evalcond[6]=((((-1.0)*new_r11*x241*x242))+(((-1.0)*new_r01*x240*x242))+(((-1.0)*new_r21*x243)));
evalcond[7]=((1.0)+(((-1.0)*x242*x244))+(((-1.0)*x242*x245))+(((-1.0)*new_r22*x243)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j6eval[2];
IkReal x246=((1.0)*cj3);
IkReal x247=(sj0*sj2);
IkReal x248=(cj2*sj1);
IkReal x249=((1.0)*sj3);
IkReal x250=(cj1*cj2);
IkReal x251=(sj1*sj2);
IkReal x252=(cj0*sj2);
IkReal x253=((1.0)*cj1);
IkReal x254=x167;
IkReal x255=x168;
IkReal x256=x169;
IkReal x257=x170;
IkReal x258=(cj0*x254);
IkReal x259=x172;
IkReal x260=x173;
IkReal x261=(((cj3*x252))+((sj0*x254)));
IkReal x262=(((cj0*x256))+(((-1.0)*x247*x249)));
IkReal x263=(((sj0*x256))+((sj3*x252)));
IkReal x264=(x258+(((-1.0)*cj3*x247)));
new_r00=(((r20*x259))+((r10*x261))+((r00*((x258+(((-1.0)*x246*x247)))))));
new_r01=(((r21*x259))+((r11*x261))+((r01*x264)));
new_r02=(((r02*x264))+((r12*x261))+((r22*x259)));
new_r10=(((r20*x251))+((r10*x255))+((r00*x260)));
new_r11=(((r21*x251))+((r11*x255))+((r01*x260)));
new_r12=(((r02*x260))+((r12*x255))+((r22*x251)));
new_r20=(((r20*x257))+((r00*x262))+((r10*x263)));
new_r21=(((r21*x257))+((r11*x263))+((r01*x262)));
new_r22=(((r02*x262))+((r12*x263))+((r22*x257)));
j6eval[0]=sj5;
j6eval[1]=IKsign(sj5);
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 )
{
{
IkReal j6eval[2];
IkReal x265=((1.0)*cj3);
IkReal x266=(sj0*sj2);
IkReal x267=(cj2*sj1);
IkReal x268=((1.0)*sj3);
IkReal x269=(cj1*cj2);
IkReal x270=(sj1*sj2);
IkReal x271=(cj0*sj2);
IkReal x272=((1.0)*cj1);
IkReal x273=x167;
IkReal x274=x168;
IkReal x275=x169;
IkReal x276=x170;
IkReal x277=(cj0*x273);
IkReal x278=x172;
IkReal x279=x173;
IkReal x280=(((sj0*x273))+((cj3*x271)));
IkReal x281=((((-1.0)*x266*x268))+((cj0*x275)));
IkReal x282=(((sj3*x271))+((sj0*x275)));
IkReal x283=((((-1.0)*cj3*x266))+x277);
new_r00=(((r00*((x277+(((-1.0)*x265*x266))))))+((r10*x280))+((r20*x278)));
new_r01=(((r01*x283))+((r11*x280))+((r21*x278)));
new_r02=(((r22*x278))+((r02*x283))+((r12*x280)));
new_r10=(((r00*x279))+((r10*x274))+((r20*x270)));
new_r11=(((r21*x270))+((r01*x279))+((r11*x274)));
new_r12=(((r02*x279))+((r22*x270))+((r12*x274)));
new_r20=(((r00*x281))+((r10*x282))+((r20*x276)));
new_r21=(((r01*x281))+((r11*x282))+((r21*x276)));
new_r22=(((r22*x276))+((r02*x281))+((r12*x282)));
j6eval[0]=sj4;
j6eval[1]=sj5;
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 )
{
{
IkReal j6eval[3];
IkReal x284=((1.0)*cj3);
IkReal x285=(sj0*sj2);
IkReal x286=(cj2*sj1);
IkReal x287=((1.0)*sj3);
IkReal x288=(cj1*cj2);
IkReal x289=(sj1*sj2);
IkReal x290=(cj0*sj2);
IkReal x291=((1.0)*cj1);
IkReal x292=x167;
IkReal x293=x168;
IkReal x294=x169;
IkReal x295=x170;
IkReal x296=(cj0*x292);
IkReal x297=x172;
IkReal x298=x173;
IkReal x299=(((cj3*x290))+((sj0*x292)));
IkReal x300=((((-1.0)*x285*x287))+((cj0*x294)));
IkReal x301=(((sj0*x294))+((sj3*x290)));
IkReal x302=((((-1.0)*cj3*x285))+x296);
new_r00=(((r20*x297))+((r10*x299))+((r00*((x296+(((-1.0)*x284*x285)))))));
new_r01=(((r01*x302))+((r21*x297))+((r11*x299)));
new_r02=(((r12*x299))+((r02*x302))+((r22*x297)));
new_r10=(((r00*x298))+((r10*x293))+((r20*x289)));
new_r11=(((r21*x289))+((r01*x298))+((r11*x293)));
new_r12=(((r12*x293))+((r22*x289))+((r02*x298)));
new_r20=(((r20*x295))+((r10*x301))+((r00*x300)));
new_r21=(((r11*x301))+((r01*x300))+((r21*x295)));
new_r22=(((r02*x300))+((r22*x295))+((r12*x301)));
j6eval[0]=cj4;
j6eval[1]=cj5;
j6eval[2]=sj5;
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[12];
bool bgotonextstatement = true;
do
{
IkReal x303=(new_r22+(((-1.0)*cj5)));
IkReal x304=((((-1.0)*sj5))+new_r12);
IkReal x305=((1.0)*cj5);
IkReal x306=((1.0)*sj5);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j4)))), 6.28318530717959)));
evalcond[1]=x303;
evalcond[2]=x303;
evalcond[3]=new_r02;
evalcond[4]=x304;
evalcond[5]=x304;
evalcond[6]=((((-1.0)*new_r22*x306))+((cj5*new_r12)));
evalcond[7]=((((-1.0)*new_r20*x305))+(((-1.0)*new_r10*x306)));
evalcond[8]=((((-1.0)*new_r21*x305))+(((-1.0)*new_r11*x306)));
evalcond[9]=((1.0)+(((-1.0)*new_r22*x305))+(((-1.0)*new_r12*x306)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x307 = IKatan2WithCheck(IkReal(new_r21),((-1.0)*new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x307.valid){
continue;
}
CheckValue<IkReal> x308=IKPowWithIntegerCheck(IKsign(new_r12),-1);
if(!x308.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(x307.value)+(((1.5707963267949)*(x308.value))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x309=IKsin(j6);
IkReal x310=IKcos(j6);
IkReal x311=((1.0)*new_r12);
IkReal x312=((1.0)*x310);
evalcond[0]=(((new_r12*x310))+new_r20);
evalcond[1]=(((new_r22*x309))+new_r11);
evalcond[2]=(new_r21+(((-1.0)*x309*x311)));
evalcond[3]=((((-1.0)*new_r22*x312))+new_r10);
evalcond[4]=((((-1.0)*x309))+(((-1.0)*new_r00)));
evalcond[5]=((((-1.0)*x312))+(((-1.0)*new_r01)));
evalcond[6]=((((-1.0)*new_r21*x311))+x309+((new_r11*new_r22)));
evalcond[7]=((((-1.0)*new_r20*x311))+(((-1.0)*x312))+((new_r10*new_r22)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x313=(new_r22+(((-1.0)*cj5)));
IkReal x314=((1.0)*cj5);
IkReal x315=((1.0)*sj5);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j4)))), 6.28318530717959)));
evalcond[1]=x313;
evalcond[2]=x313;
evalcond[3]=new_r02;
evalcond[4]=(sj5+new_r12);
evalcond[5]=((((-1.0)*x315))+(((-1.0)*new_r12)));
evalcond[6]=((((-1.0)*new_r22*x315))+(((-1.0)*new_r12*x314)));
evalcond[7]=(((new_r10*sj5))+(((-1.0)*new_r20*x314)));
evalcond[8]=((((-1.0)*new_r21*x314))+((new_r11*sj5)));
evalcond[9]=((1.0)+((new_r12*sj5))+(((-1.0)*new_r22*x314)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
if( IKabs(new_r00) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r01) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r00)+IKsqr(new_r01)-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(new_r00, new_r01);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x316=IKsin(j6);
IkReal x317=IKcos(j6);
IkReal x318=((1.0)*new_r22);
IkReal x319=((1.0)*x317);
evalcond[0]=(((new_r12*x316))+new_r21);
evalcond[1]=((((-1.0)*x316))+new_r00);
evalcond[2]=((((-1.0)*x319))+new_r01);
evalcond[3]=((((-1.0)*new_r12*x319))+new_r20);
evalcond[4]=((((-1.0)*new_r11))+((new_r22*x316)));
evalcond[5]=((((-1.0)*new_r10))+(((-1.0)*x317*x318)));
evalcond[6]=((((-1.0)*new_r11*x318))+x316+((new_r12*new_r21)));
evalcond[7]=(((new_r12*new_r20))+(((-1.0)*new_r10*x318))+(((-1.0)*x319)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x320=((1.0)*cj4);
IkReal x321=((1.0)*sj4);
IkReal x322=(((cj4*new_r12))+(((-1.0)*new_r02*x321)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j5)))), 6.28318530717959)));
evalcond[1]=new_r22;
evalcond[2]=((((-1.0)*x320))+new_r02);
evalcond[3]=((((-1.0)*x321))+new_r12);
evalcond[4]=x322;
evalcond[5]=x322;
evalcond[6]=((-1.0)+((new_r12*sj4))+((cj4*new_r02)));
evalcond[7]=(((cj4*new_r01))+((new_r11*sj4)));
evalcond[8]=(((cj4*new_r00))+((new_r10*sj4)));
evalcond[9]=((((-1.0)*new_r00*x320))+(((-1.0)*new_r10*x321)));
evalcond[10]=((((-1.0)*new_r01*x320))+(((-1.0)*new_r11*x321)));
evalcond[11]=((1.0)+(((-1.0)*new_r12*x321))+(((-1.0)*new_r02*x320)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 && IKabs(evalcond[10]) < 0.0000010000000000 && IKabs(evalcond[11]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
if( IKabs(new_r21) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r20)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r21)+IKsqr(((-1.0)*new_r20))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(new_r21, ((-1.0)*new_r20));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x323=IKcos(j6);
IkReal x324=IKsin(j6);
IkReal x325=((1.0)*new_r12);
IkReal x326=((1.0)*x324);
IkReal x327=((1.0)*x323);
evalcond[0]=(x323+new_r20);
evalcond[1]=((((-1.0)*x326))+new_r21);
evalcond[2]=(((new_r12*x323))+new_r01);
evalcond[3]=(((new_r12*x324))+new_r00);
evalcond[4]=((((-1.0)*new_r02*x327))+new_r11);
evalcond[5]=((((-1.0)*new_r02*x326))+new_r10);
evalcond[6]=((((-1.0)*x326))+(((-1.0)*new_r00*x325))+((new_r02*new_r10)));
evalcond[7]=((((-1.0)*x327))+(((-1.0)*new_r01*x325))+((new_r02*new_r11)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x328=((((-1.0)*new_r02*sj4))+((cj4*new_r12)));
IkReal x329=(((cj4*new_r00))+((new_r10*sj4)));
IkReal x330=(((cj4*new_r01))+((new_r11*sj4)));
IkReal x331=((1.0)+((new_r12*sj4))+((cj4*new_r02)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j5)))), 6.28318530717959)));
evalcond[1]=new_r22;
evalcond[2]=(cj4+new_r02);
evalcond[3]=(sj4+new_r12);
evalcond[4]=x328;
evalcond[5]=x328;
evalcond[6]=x331;
evalcond[7]=x330;
evalcond[8]=x329;
evalcond[9]=x329;
evalcond[10]=x330;
evalcond[11]=x331;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 && IKabs(evalcond[10]) < 0.0000010000000000 && IKabs(evalcond[11]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
if( IKabs(((-1.0)*new_r21)) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r20) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21))+IKsqr(new_r20)-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(((-1.0)*new_r21), new_r20);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x332=IKcos(j6);
IkReal x333=IKsin(j6);
IkReal x334=((1.0)*new_r02);
IkReal x335=((1.0)*new_r12);
IkReal x336=((1.0)*x332);
evalcond[0]=(x333+new_r21);
evalcond[1]=((((-1.0)*x336))+new_r20);
evalcond[2]=(((new_r02*x332))+new_r11);
evalcond[3]=(((new_r02*x333))+new_r10);
evalcond[4]=((((-1.0)*x332*x335))+new_r01);
evalcond[5]=((((-1.0)*x333*x335))+new_r00);
evalcond[6]=((((-1.0)*new_r10*x334))+((new_r00*new_r12))+(((-1.0)*x333)));
evalcond[7]=((((-1.0)*new_r11*x334))+((new_r01*new_r12))+(((-1.0)*x336)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x337=((((-1.0)*new_r02*sj4))+((cj4*new_r12)));
IkReal x338=(((new_r12*sj4))+((cj4*new_r02)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j5))), 6.28318530717959)));
evalcond[1]=((-1.0)+new_r22);
evalcond[2]=new_r20;
evalcond[3]=new_r02;
evalcond[4]=new_r12;
evalcond[5]=new_r21;
evalcond[6]=x337;
evalcond[7]=x337;
evalcond[8]=x338;
evalcond[9]=x338;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x339=((1.0)*new_r01);
if( IKabs(((((-1.0)*cj4*x339))+(((-1.0)*new_r00*sj4)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*sj4*x339))+((cj4*new_r00)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.0)*cj4*x339))+(((-1.0)*new_r00*sj4))))+IKsqr(((((-1.0)*sj4*x339))+((cj4*new_r00))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(((((-1.0)*cj4*x339))+(((-1.0)*new_r00*sj4))), ((((-1.0)*sj4*x339))+((cj4*new_r00))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x340=IKsin(j6);
IkReal x341=IKcos(j6);
IkReal x342=((1.0)*sj4);
IkReal x343=((1.0)*x341);
IkReal x344=(sj4*x340);
IkReal x345=(sj4*x341);
IkReal x346=(cj4*x340);
IkReal x347=(cj4*x343);
evalcond[0]=(((cj4*new_r01))+((new_r11*sj4))+x340);
evalcond[1]=(x346+x345+new_r01);
evalcond[2]=(((cj4*new_r00))+((new_r10*sj4))+(((-1.0)*x343)));
evalcond[3]=(((cj4*new_r10))+(((-1.0)*new_r00*x342))+(((-1.0)*x340)));
evalcond[4]=(((cj4*new_r11))+(((-1.0)*new_r01*x342))+(((-1.0)*x343)));
evalcond[5]=(x344+new_r00+(((-1.0)*x347)));
evalcond[6]=(x344+new_r11+(((-1.0)*x347)));
evalcond[7]=((((-1.0)*x341*x342))+new_r10+(((-1.0)*x346)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x348=(cj4*new_r02);
IkReal x349=(new_r12*sj4);
IkReal x350=((((-1.0)*new_r02*sj4))+((cj4*new_r12)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j5)))), 6.28318530717959)));
evalcond[1]=((1.0)+new_r22);
evalcond[2]=new_r20;
evalcond[3]=new_r02;
evalcond[4]=new_r12;
evalcond[5]=new_r21;
evalcond[6]=x350;
evalcond[7]=x350;
evalcond[8]=(x348+x349);
evalcond[9]=((((-1.0)*x348))+(((-1.0)*x349)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x351=((1.0)*new_r00);
if( IKabs((((cj4*new_r01))+(((-1.0)*sj4*x351)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*new_r01*sj4))+(((-1.0)*cj4*x351)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((cj4*new_r01))+(((-1.0)*sj4*x351))))+IKsqr(((((-1.0)*new_r01*sj4))+(((-1.0)*cj4*x351))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2((((cj4*new_r01))+(((-1.0)*sj4*x351))), ((((-1.0)*new_r01*sj4))+(((-1.0)*cj4*x351))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x352=IKcos(j6);
IkReal x353=IKsin(j6);
IkReal x354=((1.0)*sj4);
IkReal x355=((1.0)*x353);
IkReal x356=(sj4*x352);
IkReal x357=((1.0)*x352);
IkReal x358=(cj4*x355);
evalcond[0]=(((cj4*new_r00))+((new_r10*sj4))+x352);
evalcond[1]=(((cj4*new_r01))+((new_r11*sj4))+(((-1.0)*x355)));
evalcond[2]=(((sj4*x353))+((cj4*x352))+new_r00);
evalcond[3]=(((cj4*new_r10))+(((-1.0)*x355))+(((-1.0)*new_r00*x354)));
evalcond[4]=(((cj4*new_r11))+(((-1.0)*x357))+(((-1.0)*new_r01*x354)));
evalcond[5]=((((-1.0)*x358))+x356+new_r01);
evalcond[6]=((((-1.0)*x358))+x356+new_r10);
evalcond[7]=((((-1.0)*cj4*x357))+(((-1.0)*x353*x354))+new_r11);
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x359=(new_r22+(((-1.0)*cj5)));
IkReal x360=((((-1.0)*sj5))+new_r02);
IkReal x361=((1.0)*cj5);
IkReal x362=((1.0)*sj5);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j4))), 6.28318530717959)));
evalcond[1]=x359;
evalcond[2]=x359;
evalcond[3]=x360;
evalcond[4]=new_r12;
evalcond[5]=x360;
evalcond[6]=(((cj5*new_r02))+(((-1.0)*new_r22*x362)));
evalcond[7]=((((-1.0)*new_r00*x362))+(((-1.0)*new_r20*x361)));
evalcond[8]=((((-1.0)*new_r01*x362))+(((-1.0)*new_r21*x361)));
evalcond[9]=((1.0)+(((-1.0)*new_r22*x361))+(((-1.0)*new_r02*x362)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
if( IKabs(new_r10) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r11) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r10)+IKsqr(new_r11)-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(new_r10, new_r11);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x363=IKcos(j6);
IkReal x364=IKsin(j6);
IkReal x365=((1.0)*new_r02);
IkReal x366=((1.0)*x363);
evalcond[0]=(new_r20+((new_r02*x363)));
evalcond[1]=((((-1.0)*x364))+new_r10);
evalcond[2]=((((-1.0)*x366))+new_r11);
evalcond[3]=(((new_r22*x364))+new_r01);
evalcond[4]=((((-1.0)*x364*x365))+new_r21);
evalcond[5]=((((-1.0)*new_r22*x366))+new_r00);
evalcond[6]=(((new_r01*new_r22))+x364+(((-1.0)*new_r21*x365)));
evalcond[7]=((((-1.0)*new_r20*x365))+((new_r00*new_r22))+(((-1.0)*x366)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x367=(new_r22+(((-1.0)*cj5)));
IkReal x368=((1.0)*cj5);
IkReal x369=((1.0)*sj5);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j4)))), 6.28318530717959)));
evalcond[1]=x367;
evalcond[2]=x367;
evalcond[3]=(sj5+new_r02);
evalcond[4]=new_r12;
evalcond[5]=((((-1.0)*x369))+(((-1.0)*new_r02)));
evalcond[6]=((((-1.0)*new_r22*x369))+(((-1.0)*new_r02*x368)));
evalcond[7]=((((-1.0)*new_r20*x368))+((new_r00*sj5)));
evalcond[8]=(((new_r01*sj5))+(((-1.0)*new_r21*x368)));
evalcond[9]=((1.0)+((new_r02*sj5))+(((-1.0)*new_r22*x368)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x370 = IKatan2WithCheck(IkReal(((-1.0)*new_r21)),new_r20,IKFAST_ATAN2_MAGTHRESH);
if(!x370.valid){
continue;
}
CheckValue<IkReal> x371=IKPowWithIntegerCheck(IKsign(new_r02),-1);
if(!x371.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(x370.value)+(((1.5707963267949)*(x371.value))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x372=IKsin(j6);
IkReal x373=IKcos(j6);
IkReal x374=((1.0)*new_r01);
IkReal x375=((1.0)*new_r00);
IkReal x376=((1.0)*x373);
evalcond[0]=(new_r21+((new_r02*x372)));
evalcond[1]=(new_r20+(((-1.0)*new_r02*x376)));
evalcond[2]=((((-1.0)*x372))+(((-1.0)*new_r10)));
evalcond[3]=((((-1.0)*x376))+(((-1.0)*new_r11)));
evalcond[4]=((((-1.0)*x374))+((new_r22*x372)));
evalcond[5]=((((-1.0)*x375))+(((-1.0)*new_r22*x376)));
evalcond[6]=((((-1.0)*new_r22*x374))+x372+((new_r02*new_r21)));
evalcond[7]=((((-1.0)*x376))+(((-1.0)*new_r22*x375))+((new_r02*new_r20)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j6]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x378=IKPowWithIntegerCheck(sj5,-1);
if(!x378.valid){
continue;
}
IkReal x377=x378.value;
CheckValue<IkReal> x379=IKPowWithIntegerCheck(cj4,-1);
if(!x379.valid){
continue;
}
CheckValue<IkReal> x380=IKPowWithIntegerCheck(cj5,-1);
if(!x380.valid){
continue;
}
if( IKabs((x377*(x379.value)*(x380.value)*((((new_r20*sj4))+(((-1.0)*new_r01*sj5)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r20*x377)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x377*(x379.value)*(x380.value)*((((new_r20*sj4))+(((-1.0)*new_r01*sj5))))))+IKsqr(((-1.0)*new_r20*x377))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2((x377*(x379.value)*(x380.value)*((((new_r20*sj4))+(((-1.0)*new_r01*sj5))))), ((-1.0)*new_r20*x377));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[12];
IkReal x381=IKsin(j6);
IkReal x382=IKcos(j6);
IkReal x383=((1.0)*sj5);
IkReal x384=((1.0)*sj4);
IkReal x385=(cj5*sj4);
IkReal x386=(cj4*new_r01);
IkReal x387=(cj4*new_r00);
IkReal x388=((1.0)*x382);
IkReal x389=(cj5*x381);
IkReal x390=((1.0)*x381);
evalcond[0]=(((sj5*x382))+new_r20);
evalcond[1]=((((-1.0)*x381*x383))+new_r21);
evalcond[2]=(((new_r11*sj4))+x386+x389);
evalcond[3]=((((-1.0)*x390))+((cj4*new_r10))+(((-1.0)*new_r00*x384)));
evalcond[4]=(((cj4*new_r11))+(((-1.0)*new_r01*x384))+(((-1.0)*x388)));
evalcond[5]=(((sj4*x382))+new_r01+((cj4*x389)));
evalcond[6]=(((new_r10*sj4))+x387+(((-1.0)*cj5*x388)));
evalcond[7]=((((-1.0)*cj4*cj5*x388))+((sj4*x381))+new_r00);
evalcond[8]=((((-1.0)*cj4*x388))+new_r11+((x381*x385)));
evalcond[9]=((((-1.0)*cj4*x390))+(((-1.0)*cj5*x382*x384))+new_r10);
evalcond[10]=(x381+((new_r11*x385))+(((-1.0)*new_r21*x383))+((cj5*x386)));
evalcond[11]=((((-1.0)*new_r20*x383))+((new_r10*x385))+(((-1.0)*x388))+((cj5*x387)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x392=IKPowWithIntegerCheck(sj5,-1);
if(!x392.valid){
continue;
}
IkReal x391=x392.value;
CheckValue<IkReal> x393=IKPowWithIntegerCheck(sj4,-1);
if(!x393.valid){
continue;
}
if( IKabs((x391*(x393.value)*(((((-1.0)*new_r00*sj5))+(((-1.0)*cj4*cj5*new_r20)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r20*x391)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x391*(x393.value)*(((((-1.0)*new_r00*sj5))+(((-1.0)*cj4*cj5*new_r20))))))+IKsqr(((-1.0)*new_r20*x391))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2((x391*(x393.value)*(((((-1.0)*new_r00*sj5))+(((-1.0)*cj4*cj5*new_r20))))), ((-1.0)*new_r20*x391));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[12];
IkReal x394=IKsin(j6);
IkReal x395=IKcos(j6);
IkReal x396=((1.0)*sj5);
IkReal x397=((1.0)*sj4);
IkReal x398=(cj5*sj4);
IkReal x399=(cj4*new_r01);
IkReal x400=(cj4*new_r00);
IkReal x401=((1.0)*x395);
IkReal x402=(cj5*x394);
IkReal x403=((1.0)*x394);
evalcond[0]=(((sj5*x395))+new_r20);
evalcond[1]=((((-1.0)*x394*x396))+new_r21);
evalcond[2]=(((new_r11*sj4))+x399+x402);
evalcond[3]=(((cj4*new_r10))+(((-1.0)*new_r00*x397))+(((-1.0)*x403)));
evalcond[4]=((((-1.0)*new_r01*x397))+((cj4*new_r11))+(((-1.0)*x401)));
evalcond[5]=(((cj4*x402))+new_r01+((sj4*x395)));
evalcond[6]=(((new_r10*sj4))+x400+(((-1.0)*cj5*x401)));
evalcond[7]=(new_r00+(((-1.0)*cj4*cj5*x401))+((sj4*x394)));
evalcond[8]=(((x394*x398))+new_r11+(((-1.0)*cj4*x401)));
evalcond[9]=(new_r10+(((-1.0)*cj4*x403))+(((-1.0)*cj5*x395*x397)));
evalcond[10]=(((new_r11*x398))+(((-1.0)*new_r21*x396))+((cj5*x399))+x394);
evalcond[11]=(((cj5*x400))+(((-1.0)*x401))+(((-1.0)*new_r20*x396))+((new_r10*x398)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x404=IKPowWithIntegerCheck(IKsign(sj5),-1);
if(!x404.valid){
continue;
}
CheckValue<IkReal> x405 = IKatan2WithCheck(IkReal(new_r21),((-1.0)*new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x405.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(((1.5707963267949)*(x404.value)))+(x405.value));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[12];
IkReal x406=IKsin(j6);
IkReal x407=IKcos(j6);
IkReal x408=((1.0)*sj5);
IkReal x409=((1.0)*sj4);
IkReal x410=(cj5*sj4);
IkReal x411=(cj4*new_r01);
IkReal x412=(cj4*new_r00);
IkReal x413=((1.0)*x407);
IkReal x414=(cj5*x406);
IkReal x415=((1.0)*x406);
evalcond[0]=(((sj5*x407))+new_r20);
evalcond[1]=((((-1.0)*x406*x408))+new_r21);
evalcond[2]=(((new_r11*sj4))+x411+x414);
evalcond[3]=(((cj4*new_r10))+(((-1.0)*new_r00*x409))+(((-1.0)*x415)));
evalcond[4]=(((cj4*new_r11))+(((-1.0)*x413))+(((-1.0)*new_r01*x409)));
evalcond[5]=(((cj4*x414))+new_r01+((sj4*x407)));
evalcond[6]=(((new_r10*sj4))+x412+(((-1.0)*cj5*x413)));
evalcond[7]=((((-1.0)*cj4*cj5*x413))+new_r00+((sj4*x406)));
evalcond[8]=(((x406*x410))+(((-1.0)*cj4*x413))+new_r11);
evalcond[9]=((((-1.0)*cj5*x407*x409))+(((-1.0)*cj4*x415))+new_r10);
evalcond[10]=(((cj5*x411))+x406+(((-1.0)*new_r21*x408))+((new_r11*x410)));
evalcond[11]=((((-1.0)*new_r20*x408))+((cj5*x412))+((new_r10*x410))+(((-1.0)*x413)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j4array[1], cj4array[1], sj4array[1];
bool j4valid[1]={false};
_nj4 = 1;
CheckValue<IkReal> x416=IKPowWithIntegerCheck(IKsign(sj5),-1);
if(!x416.valid){
continue;
}
CheckValue<IkReal> x417 = IKatan2WithCheck(IkReal(new_r12),new_r02,IKFAST_ATAN2_MAGTHRESH);
if(!x417.valid){
continue;
}
j4array[0]=((-1.5707963267949)+(((1.5707963267949)*(x416.value)))+(x417.value));
sj4array[0]=IKsin(j4array[0]);
cj4array[0]=IKcos(j4array[0]);
if( j4array[0] > IKPI )
{
j4array[0]-=IK2PI;
}
else if( j4array[0] < -IKPI )
{ j4array[0]+=IK2PI;
}
j4valid[0] = true;
for(int ij4 = 0; ij4 < 1; ++ij4)
{
if( !j4valid[ij4] )
{
continue;
}
_ij4[0] = ij4; _ij4[1] = -1;
for(int iij4 = ij4+1; iij4 < 1; ++iij4)
{
if( j4valid[iij4] && IKabs(cj4array[ij4]-cj4array[iij4]) < IKFAST_SOLUTION_THRESH && IKabs(sj4array[ij4]-sj4array[iij4]) < IKFAST_SOLUTION_THRESH )
{
j4valid[iij4]=false; _ij4[1] = iij4; break;
}
}
j4 = j4array[ij4]; cj4 = cj4array[ij4]; sj4 = sj4array[ij4];
{
IkReal evalcond[8];
IkReal x418=IKcos(j4);
IkReal x419=IKsin(j4);
IkReal x420=((1.0)*sj5);
IkReal x421=((1.0)*cj5);
IkReal x422=(new_r12*x419);
IkReal x423=(new_r02*x418);
evalcond[0]=((((-1.0)*x418*x420))+new_r02);
evalcond[1]=((((-1.0)*x419*x420))+new_r12);
evalcond[2]=((((-1.0)*new_r02*x419))+((new_r12*x418)));
evalcond[3]=((((-1.0)*x420))+x423+x422);
evalcond[4]=((((-1.0)*new_r22*x420))+((cj5*x422))+((cj5*x423)));
evalcond[5]=((((-1.0)*new_r10*x419*x420))+(((-1.0)*new_r00*x418*x420))+(((-1.0)*new_r20*x421)));
evalcond[6]=((((-1.0)*new_r01*x418*x420))+(((-1.0)*new_r11*x419*x420))+(((-1.0)*new_r21*x421)));
evalcond[7]=((1.0)+(((-1.0)*x420*x422))+(((-1.0)*x420*x423))+(((-1.0)*new_r22*x421)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
IkReal j6eval[2];
IkReal x424=((1.0)*cj3);
IkReal x425=(sj0*sj2);
IkReal x426=(cj2*sj1);
IkReal x427=((1.0)*sj3);
IkReal x428=(cj1*cj2);
IkReal x429=(sj1*sj2);
IkReal x430=(cj0*sj2);
IkReal x431=((1.0)*cj1);
IkReal x432=x167;
IkReal x433=x168;
IkReal x434=x169;
IkReal x435=x170;
IkReal x436=(cj0*x432);
IkReal x437=x172;
IkReal x438=x173;
IkReal x439=(((sj0*x432))+((cj3*x430)));
IkReal x440=(((cj0*x434))+(((-1.0)*x425*x427)));
IkReal x441=(((sj0*x434))+((sj3*x430)));
IkReal x442=((((-1.0)*cj3*x425))+x436);
new_r00=(((r10*x439))+((r00*((x436+(((-1.0)*x424*x425))))))+((r20*x437)));
new_r01=(((r21*x437))+((r01*x442))+((r11*x439)));
new_r02=(((r12*x439))+((r02*x442))+((r22*x437)));
new_r10=(((r20*x429))+((r00*x438))+((r10*x433)));
new_r11=(((r21*x429))+((r01*x438))+((r11*x433)));
new_r12=(((r12*x433))+((r02*x438))+((r22*x429)));
new_r20=(((r00*x440))+((r10*x441))+((r20*x435)));
new_r21=(((r21*x435))+((r01*x440))+((r11*x441)));
new_r22=(((r02*x440))+((r22*x435))+((r12*x441)));
j6eval[0]=sj5;
j6eval[1]=IKsign(sj5);
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 )
{
{
IkReal j6eval[2];
IkReal x443=((1.0)*cj3);
IkReal x444=(sj0*sj2);
IkReal x445=(cj2*sj1);
IkReal x446=((1.0)*sj3);
IkReal x447=(cj1*cj2);
IkReal x448=(sj1*sj2);
IkReal x449=(cj0*sj2);
IkReal x450=((1.0)*cj1);
IkReal x451=x167;
IkReal x452=x168;
IkReal x453=x169;
IkReal x454=x170;
IkReal x455=(cj0*x451);
IkReal x456=x172;
IkReal x457=x173;
IkReal x458=(((sj0*x451))+((cj3*x449)));
IkReal x459=((((-1.0)*x444*x446))+((cj0*x453)));
IkReal x460=(((sj0*x453))+((sj3*x449)));
IkReal x461=((((-1.0)*cj3*x444))+x455);
new_r00=(((r20*x456))+((r00*(((((-1.0)*x443*x444))+x455))))+((r10*x458)));
new_r01=(((r11*x458))+((r01*x461))+((r21*x456)));
new_r02=(((r02*x461))+((r12*x458))+((r22*x456)));
new_r10=(((r00*x457))+((r20*x448))+((r10*x452)));
new_r11=(((r21*x448))+((r11*x452))+((r01*x457)));
new_r12=(((r22*x448))+((r12*x452))+((r02*x457)));
new_r20=(((r20*x454))+((r00*x459))+((r10*x460)));
new_r21=(((r11*x460))+((r01*x459))+((r21*x454)));
new_r22=(((r12*x460))+((r02*x459))+((r22*x454)));
j6eval[0]=sj4;
j6eval[1]=sj5;
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 )
{
{
IkReal j6eval[3];
IkReal x462=((1.0)*cj3);
IkReal x463=(sj0*sj2);
IkReal x464=(cj2*sj1);
IkReal x465=((1.0)*sj3);
IkReal x466=(cj1*cj2);
IkReal x467=(sj1*sj2);
IkReal x468=(cj0*sj2);
IkReal x469=((1.0)*cj1);
IkReal x470=x167;
IkReal x471=x168;
IkReal x472=x169;
IkReal x473=x170;
IkReal x474=(cj0*x470);
IkReal x475=x172;
IkReal x476=x173;
IkReal x477=(((cj3*x468))+((sj0*x470)));
IkReal x478=((((-1.0)*x463*x465))+((cj0*x472)));
IkReal x479=(((sj3*x468))+((sj0*x472)));
IkReal x480=(x474+(((-1.0)*cj3*x463)));
new_r00=(((r10*x477))+((r20*x475))+((r00*(((((-1.0)*x462*x463))+x474)))));
new_r01=(((r21*x475))+((r11*x477))+((r01*x480)));
new_r02=(((r02*x480))+((r12*x477))+((r22*x475)));
new_r10=(((r10*x471))+((r20*x467))+((r00*x476)));
new_r11=(((r11*x471))+((r21*x467))+((r01*x476)));
new_r12=(((r22*x467))+((r02*x476))+((r12*x471)));
new_r20=(((r10*x479))+((r20*x473))+((r00*x478)));
new_r21=(((r21*x473))+((r11*x479))+((r01*x478)));
new_r22=(((r02*x478))+((r12*x479))+((r22*x473)));
j6eval[0]=cj4;
j6eval[1]=cj5;
j6eval[2]=sj5;
if( IKabs(j6eval[0]) < 0.0000010000000000 || IKabs(j6eval[1]) < 0.0000010000000000 || IKabs(j6eval[2]) < 0.0000010000000000 )
{
{
IkReal evalcond[12];
bool bgotonextstatement = true;
do
{
IkReal x481=(new_r22+(((-1.0)*cj5)));
IkReal x482=((((-1.0)*sj5))+new_r12);
IkReal x483=((1.0)*cj5);
IkReal x484=((1.0)*sj5);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j4)))), 6.28318530717959)));
evalcond[1]=x481;
evalcond[2]=x481;
evalcond[3]=new_r02;
evalcond[4]=x482;
evalcond[5]=x482;
evalcond[6]=(((cj5*new_r12))+(((-1.0)*new_r22*x484)));
evalcond[7]=((((-1.0)*new_r10*x484))+(((-1.0)*new_r20*x483)));
evalcond[8]=((((-1.0)*new_r21*x483))+(((-1.0)*new_r11*x484)));
evalcond[9]=((1.0)+(((-1.0)*new_r22*x483))+(((-1.0)*new_r12*x484)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x485 = IKatan2WithCheck(IkReal(new_r21),((-1.0)*new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x485.valid){
continue;
}
CheckValue<IkReal> x486=IKPowWithIntegerCheck(IKsign(new_r12),-1);
if(!x486.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(x485.value)+(((1.5707963267949)*(x486.value))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x487=IKsin(j6);
IkReal x488=IKcos(j6);
IkReal x489=((1.0)*new_r12);
IkReal x490=((1.0)*x488);
evalcond[0]=(((new_r12*x488))+new_r20);
evalcond[1]=(new_r11+((new_r22*x487)));
evalcond[2]=((((-1.0)*x487*x489))+new_r21);
evalcond[3]=((((-1.0)*new_r22*x490))+new_r10);
evalcond[4]=((((-1.0)*x487))+(((-1.0)*new_r00)));
evalcond[5]=((((-1.0)*x490))+(((-1.0)*new_r01)));
evalcond[6]=((((-1.0)*new_r21*x489))+x487+((new_r11*new_r22)));
evalcond[7]=((((-1.0)*x490))+(((-1.0)*new_r20*x489))+((new_r10*new_r22)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x491=(new_r22+(((-1.0)*cj5)));
IkReal x492=((1.0)*cj5);
IkReal x493=((1.0)*sj5);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j4)))), 6.28318530717959)));
evalcond[1]=x491;
evalcond[2]=x491;
evalcond[3]=new_r02;
evalcond[4]=(sj5+new_r12);
evalcond[5]=((((-1.0)*x493))+(((-1.0)*new_r12)));
evalcond[6]=((((-1.0)*new_r22*x493))+(((-1.0)*new_r12*x492)));
evalcond[7]=((((-1.0)*new_r20*x492))+((new_r10*sj5)));
evalcond[8]=(((new_r11*sj5))+(((-1.0)*new_r21*x492)));
evalcond[9]=((1.0)+((new_r12*sj5))+(((-1.0)*new_r22*x492)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
if( IKabs(new_r00) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r01) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r00)+IKsqr(new_r01)-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(new_r00, new_r01);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x494=IKsin(j6);
IkReal x495=IKcos(j6);
IkReal x496=((1.0)*new_r22);
IkReal x497=((1.0)*x495);
evalcond[0]=(((new_r12*x494))+new_r21);
evalcond[1]=((((-1.0)*x494))+new_r00);
evalcond[2]=((((-1.0)*x497))+new_r01);
evalcond[3]=(new_r20+(((-1.0)*new_r12*x497)));
evalcond[4]=((((-1.0)*new_r11))+((new_r22*x494)));
evalcond[5]=((((-1.0)*x495*x496))+(((-1.0)*new_r10)));
evalcond[6]=((((-1.0)*new_r11*x496))+((new_r12*new_r21))+x494);
evalcond[7]=((((-1.0)*x497))+(((-1.0)*new_r10*x496))+((new_r12*new_r20)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x498=((1.0)*cj4);
IkReal x499=((1.0)*sj4);
IkReal x500=(((cj4*new_r12))+(((-1.0)*new_r02*x499)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-1.5707963267949)+j5)))), 6.28318530717959)));
evalcond[1]=new_r22;
evalcond[2]=((((-1.0)*x498))+new_r02);
evalcond[3]=((((-1.0)*x499))+new_r12);
evalcond[4]=x500;
evalcond[5]=x500;
evalcond[6]=((-1.0)+((new_r12*sj4))+((cj4*new_r02)));
evalcond[7]=(((cj4*new_r01))+((new_r11*sj4)));
evalcond[8]=(((cj4*new_r00))+((new_r10*sj4)));
evalcond[9]=((((-1.0)*new_r00*x498))+(((-1.0)*new_r10*x499)));
evalcond[10]=((((-1.0)*new_r01*x498))+(((-1.0)*new_r11*x499)));
evalcond[11]=((1.0)+(((-1.0)*new_r02*x498))+(((-1.0)*new_r12*x499)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 && IKabs(evalcond[10]) < 0.0000010000000000 && IKabs(evalcond[11]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
if( IKabs(new_r21) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r20)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r21)+IKsqr(((-1.0)*new_r20))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(new_r21, ((-1.0)*new_r20));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x501=IKcos(j6);
IkReal x502=IKsin(j6);
IkReal x503=((1.0)*new_r12);
IkReal x504=((1.0)*x502);
IkReal x505=((1.0)*x501);
evalcond[0]=(x501+new_r20);
evalcond[1]=((((-1.0)*x504))+new_r21);
evalcond[2]=(((new_r12*x501))+new_r01);
evalcond[3]=(((new_r12*x502))+new_r00);
evalcond[4]=((((-1.0)*new_r02*x505))+new_r11);
evalcond[5]=((((-1.0)*new_r02*x504))+new_r10);
evalcond[6]=((((-1.0)*new_r00*x503))+(((-1.0)*x504))+((new_r02*new_r10)));
evalcond[7]=((((-1.0)*new_r01*x503))+(((-1.0)*x505))+((new_r02*new_r11)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x506=((((-1.0)*new_r02*sj4))+((cj4*new_r12)));
IkReal x507=(((cj4*new_r00))+((new_r10*sj4)));
IkReal x508=(((cj4*new_r01))+((new_r11*sj4)));
IkReal x509=((1.0)+((new_r12*sj4))+((cj4*new_r02)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((1.5707963267949)+j5)))), 6.28318530717959)));
evalcond[1]=new_r22;
evalcond[2]=(cj4+new_r02);
evalcond[3]=(sj4+new_r12);
evalcond[4]=x506;
evalcond[5]=x506;
evalcond[6]=x509;
evalcond[7]=x508;
evalcond[8]=x507;
evalcond[9]=x507;
evalcond[10]=x508;
evalcond[11]=x509;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 && IKabs(evalcond[10]) < 0.0000010000000000 && IKabs(evalcond[11]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
if( IKabs(((-1.0)*new_r21)) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r20) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((-1.0)*new_r21))+IKsqr(new_r20)-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(((-1.0)*new_r21), new_r20);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x510=IKcos(j6);
IkReal x511=IKsin(j6);
IkReal x512=((1.0)*new_r02);
IkReal x513=((1.0)*new_r12);
IkReal x514=((1.0)*x510);
evalcond[0]=(x511+new_r21);
evalcond[1]=(new_r20+(((-1.0)*x514)));
evalcond[2]=(((new_r02*x510))+new_r11);
evalcond[3]=(((new_r02*x511))+new_r10);
evalcond[4]=(new_r01+(((-1.0)*x510*x513)));
evalcond[5]=((((-1.0)*x511*x513))+new_r00);
evalcond[6]=((((-1.0)*new_r10*x512))+(((-1.0)*x511))+((new_r00*new_r12)));
evalcond[7]=((((-1.0)*new_r11*x512))+((new_r01*new_r12))+(((-1.0)*x514)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x515=((((-1.0)*new_r02*sj4))+((cj4*new_r12)));
IkReal x516=(((new_r12*sj4))+((cj4*new_r02)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j5))), 6.28318530717959)));
evalcond[1]=((-1.0)+new_r22);
evalcond[2]=new_r20;
evalcond[3]=new_r02;
evalcond[4]=new_r12;
evalcond[5]=new_r21;
evalcond[6]=x515;
evalcond[7]=x515;
evalcond[8]=x516;
evalcond[9]=x516;
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x517=((1.0)*new_r01);
if( IKabs(((((-1.0)*cj4*x517))+(((-1.0)*new_r00*sj4)))) < IKFAST_ATAN2_MAGTHRESH && IKabs((((cj4*new_r00))+(((-1.0)*sj4*x517)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(((((-1.0)*cj4*x517))+(((-1.0)*new_r00*sj4))))+IKsqr((((cj4*new_r00))+(((-1.0)*sj4*x517))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(((((-1.0)*cj4*x517))+(((-1.0)*new_r00*sj4))), (((cj4*new_r00))+(((-1.0)*sj4*x517))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x518=IKsin(j6);
IkReal x519=IKcos(j6);
IkReal x520=((1.0)*sj4);
IkReal x521=((1.0)*x519);
IkReal x522=(sj4*x518);
IkReal x523=(sj4*x519);
IkReal x524=(cj4*x518);
IkReal x525=(cj4*x521);
evalcond[0]=(((cj4*new_r01))+((new_r11*sj4))+x518);
evalcond[1]=(x523+x524+new_r01);
evalcond[2]=(((cj4*new_r00))+((new_r10*sj4))+(((-1.0)*x521)));
evalcond[3]=(((cj4*new_r10))+(((-1.0)*x518))+(((-1.0)*new_r00*x520)));
evalcond[4]=(((cj4*new_r11))+(((-1.0)*x521))+(((-1.0)*new_r01*x520)));
evalcond[5]=((((-1.0)*x525))+x522+new_r00);
evalcond[6]=((((-1.0)*x525))+x522+new_r11);
evalcond[7]=((((-1.0)*x524))+new_r10+(((-1.0)*x519*x520)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x526=(cj4*new_r02);
IkReal x527=(new_r12*sj4);
IkReal x528=((((-1.0)*new_r02*sj4))+((cj4*new_r12)));
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j5)))), 6.28318530717959)));
evalcond[1]=((1.0)+new_r22);
evalcond[2]=new_r20;
evalcond[3]=new_r02;
evalcond[4]=new_r12;
evalcond[5]=new_r21;
evalcond[6]=x528;
evalcond[7]=x528;
evalcond[8]=(x526+x527);
evalcond[9]=((((-1.0)*x527))+(((-1.0)*x526)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
IkReal x529=((1.0)*new_r00);
if( IKabs((((cj4*new_r01))+(((-1.0)*sj4*x529)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((((-1.0)*new_r01*sj4))+(((-1.0)*cj4*x529)))) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((((cj4*new_r01))+(((-1.0)*sj4*x529))))+IKsqr(((((-1.0)*new_r01*sj4))+(((-1.0)*cj4*x529))))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2((((cj4*new_r01))+(((-1.0)*sj4*x529))), ((((-1.0)*new_r01*sj4))+(((-1.0)*cj4*x529))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x530=IKcos(j6);
IkReal x531=IKsin(j6);
IkReal x532=((1.0)*sj4);
IkReal x533=((1.0)*x531);
IkReal x534=(sj4*x530);
IkReal x535=((1.0)*x530);
IkReal x536=(cj4*x533);
evalcond[0]=(((cj4*new_r00))+((new_r10*sj4))+x530);
evalcond[1]=(((cj4*new_r01))+((new_r11*sj4))+(((-1.0)*x533)));
evalcond[2]=(((cj4*x530))+new_r00+((sj4*x531)));
evalcond[3]=(((cj4*new_r10))+(((-1.0)*new_r00*x532))+(((-1.0)*x533)));
evalcond[4]=(((cj4*new_r11))+(((-1.0)*x535))+(((-1.0)*new_r01*x532)));
evalcond[5]=((((-1.0)*x536))+x534+new_r01);
evalcond[6]=((((-1.0)*x536))+x534+new_r10);
evalcond[7]=((((-1.0)*x531*x532))+new_r11+(((-1.0)*cj4*x535)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x537=(new_r22+(((-1.0)*cj5)));
IkReal x538=((((-1.0)*sj5))+new_r02);
IkReal x539=((1.0)*cj5);
IkReal x540=((1.0)*sj5);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(j4))), 6.28318530717959)));
evalcond[1]=x537;
evalcond[2]=x537;
evalcond[3]=x538;
evalcond[4]=new_r12;
evalcond[5]=x538;
evalcond[6]=((((-1.0)*new_r22*x540))+((cj5*new_r02)));
evalcond[7]=((((-1.0)*new_r00*x540))+(((-1.0)*new_r20*x539)));
evalcond[8]=((((-1.0)*new_r21*x539))+(((-1.0)*new_r01*x540)));
evalcond[9]=((1.0)+(((-1.0)*new_r22*x539))+(((-1.0)*new_r02*x540)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
if( IKabs(new_r10) < IKFAST_ATAN2_MAGTHRESH && IKabs(new_r11) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr(new_r10)+IKsqr(new_r11)-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2(new_r10, new_r11);
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x541=IKcos(j6);
IkReal x542=IKsin(j6);
IkReal x543=((1.0)*new_r02);
IkReal x544=((1.0)*x541);
evalcond[0]=(((new_r02*x541))+new_r20);
evalcond[1]=((((-1.0)*x542))+new_r10);
evalcond[2]=((((-1.0)*x544))+new_r11);
evalcond[3]=(((new_r22*x542))+new_r01);
evalcond[4]=((((-1.0)*x542*x543))+new_r21);
evalcond[5]=((((-1.0)*new_r22*x544))+new_r00);
evalcond[6]=(((new_r01*new_r22))+(((-1.0)*new_r21*x543))+x542);
evalcond[7]=(((new_r00*new_r22))+(((-1.0)*new_r20*x543))+(((-1.0)*x544)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
IkReal x545=(new_r22+(((-1.0)*cj5)));
IkReal x546=((1.0)*cj5);
IkReal x547=((1.0)*sj5);
evalcond[0]=((-3.14159265358979)+(IKfmod(((3.14159265358979)+(IKabs(((-3.14159265358979)+j4)))), 6.28318530717959)));
evalcond[1]=x545;
evalcond[2]=x545;
evalcond[3]=(sj5+new_r02);
evalcond[4]=new_r12;
evalcond[5]=((((-1.0)*x547))+(((-1.0)*new_r02)));
evalcond[6]=((((-1.0)*new_r22*x547))+(((-1.0)*new_r02*x546)));
evalcond[7]=((((-1.0)*new_r20*x546))+((new_r00*sj5)));
evalcond[8]=(((new_r01*sj5))+(((-1.0)*new_r21*x546)));
evalcond[9]=((1.0)+((new_r02*sj5))+(((-1.0)*new_r22*x546)));
if( IKabs(evalcond[0]) < 0.0000010000000000 && IKabs(evalcond[1]) < 0.0000010000000000 && IKabs(evalcond[2]) < 0.0000010000000000 && IKabs(evalcond[3]) < 0.0000010000000000 && IKabs(evalcond[4]) < 0.0000010000000000 && IKabs(evalcond[5]) < 0.0000010000000000 && IKabs(evalcond[6]) < 0.0000010000000000 && IKabs(evalcond[7]) < 0.0000010000000000 && IKabs(evalcond[8]) < 0.0000010000000000 && IKabs(evalcond[9]) < 0.0000010000000000 )
{
bgotonextstatement=false;
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x548 = IKatan2WithCheck(IkReal(((-1.0)*new_r21)),new_r20,IKFAST_ATAN2_MAGTHRESH);
if(!x548.valid){
continue;
}
CheckValue<IkReal> x549=IKPowWithIntegerCheck(IKsign(new_r02),-1);
if(!x549.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(x548.value)+(((1.5707963267949)*(x549.value))));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[8];
IkReal x550=IKsin(j6);
IkReal x551=IKcos(j6);
IkReal x552=((1.0)*new_r01);
IkReal x553=((1.0)*new_r00);
IkReal x554=((1.0)*x551);
evalcond[0]=(((new_r02*x550))+new_r21);
evalcond[1]=(new_r20+(((-1.0)*new_r02*x554)));
evalcond[2]=((((-1.0)*x550))+(((-1.0)*new_r10)));
evalcond[3]=((((-1.0)*x554))+(((-1.0)*new_r11)));
evalcond[4]=((((-1.0)*x552))+((new_r22*x550)));
evalcond[5]=((((-1.0)*new_r22*x554))+(((-1.0)*x553)));
evalcond[6]=((((-1.0)*new_r22*x552))+x550+((new_r02*new_r21)));
evalcond[7]=((((-1.0)*new_r22*x553))+(((-1.0)*x554))+((new_r02*new_r20)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
} while(0);
if( bgotonextstatement )
{
bool bgotonextstatement = true;
do
{
if( 1 )
{
bgotonextstatement=false;
continue; // branch miss [j6]
}
} while(0);
if( bgotonextstatement )
{
}
}
}
}
}
}
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x556=IKPowWithIntegerCheck(sj5,-1);
if(!x556.valid){
continue;
}
IkReal x555=x556.value;
CheckValue<IkReal> x557=IKPowWithIntegerCheck(cj4,-1);
if(!x557.valid){
continue;
}
CheckValue<IkReal> x558=IKPowWithIntegerCheck(cj5,-1);
if(!x558.valid){
continue;
}
if( IKabs((x555*(x557.value)*(x558.value)*((((new_r20*sj4))+(((-1.0)*new_r01*sj5)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r20*x555)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x555*(x557.value)*(x558.value)*((((new_r20*sj4))+(((-1.0)*new_r01*sj5))))))+IKsqr(((-1.0)*new_r20*x555))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2((x555*(x557.value)*(x558.value)*((((new_r20*sj4))+(((-1.0)*new_r01*sj5))))), ((-1.0)*new_r20*x555));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[12];
IkReal x559=IKsin(j6);
IkReal x560=IKcos(j6);
IkReal x561=((1.0)*sj5);
IkReal x562=((1.0)*sj4);
IkReal x563=(cj5*sj4);
IkReal x564=(cj4*new_r01);
IkReal x565=(cj4*new_r00);
IkReal x566=((1.0)*x560);
IkReal x567=(cj5*x559);
IkReal x568=((1.0)*x559);
evalcond[0]=(new_r20+((sj5*x560)));
evalcond[1]=((((-1.0)*x559*x561))+new_r21);
evalcond[2]=(((new_r11*sj4))+x567+x564);
evalcond[3]=((((-1.0)*new_r00*x562))+((cj4*new_r10))+(((-1.0)*x568)));
evalcond[4]=(((cj4*new_r11))+(((-1.0)*x566))+(((-1.0)*new_r01*x562)));
evalcond[5]=(((sj4*x560))+new_r01+((cj4*x567)));
evalcond[6]=(((new_r10*sj4))+(((-1.0)*cj5*x566))+x565);
evalcond[7]=(((sj4*x559))+(((-1.0)*cj4*cj5*x566))+new_r00);
evalcond[8]=((((-1.0)*cj4*x566))+new_r11+((x559*x563)));
evalcond[9]=((((-1.0)*cj5*x560*x562))+(((-1.0)*cj4*x568))+new_r10);
evalcond[10]=(x559+((new_r11*x563))+((cj5*x564))+(((-1.0)*new_r21*x561)));
evalcond[11]=((((-1.0)*new_r20*x561))+((new_r10*x563))+((cj5*x565))+(((-1.0)*x566)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x570=IKPowWithIntegerCheck(sj5,-1);
if(!x570.valid){
continue;
}
IkReal x569=x570.value;
CheckValue<IkReal> x571=IKPowWithIntegerCheck(sj4,-1);
if(!x571.valid){
continue;
}
if( IKabs((x569*(x571.value)*(((((-1.0)*new_r00*sj5))+(((-1.0)*cj4*cj5*new_r20)))))) < IKFAST_ATAN2_MAGTHRESH && IKabs(((-1.0)*new_r20*x569)) < IKFAST_ATAN2_MAGTHRESH && IKabs(IKsqr((x569*(x571.value)*(((((-1.0)*new_r00*sj5))+(((-1.0)*cj4*cj5*new_r20))))))+IKsqr(((-1.0)*new_r20*x569))-1) <= IKFAST_SINCOS_THRESH )
continue;
j6array[0]=IKatan2((x569*(x571.value)*(((((-1.0)*new_r00*sj5))+(((-1.0)*cj4*cj5*new_r20))))), ((-1.0)*new_r20*x569));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[12];
IkReal x572=IKsin(j6);
IkReal x573=IKcos(j6);
IkReal x574=((1.0)*sj5);
IkReal x575=((1.0)*sj4);
IkReal x576=(cj5*sj4);
IkReal x577=(cj4*new_r01);
IkReal x578=(cj4*new_r00);
IkReal x579=((1.0)*x573);
IkReal x580=(cj5*x572);
IkReal x581=((1.0)*x572);
evalcond[0]=(((sj5*x573))+new_r20);
evalcond[1]=(new_r21+(((-1.0)*x572*x574)));
evalcond[2]=(((new_r11*sj4))+x577+x580);
evalcond[3]=(((cj4*new_r10))+(((-1.0)*new_r00*x575))+(((-1.0)*x581)));
evalcond[4]=(((cj4*new_r11))+(((-1.0)*x579))+(((-1.0)*new_r01*x575)));
evalcond[5]=(((sj4*x573))+((cj4*x580))+new_r01);
evalcond[6]=(((new_r10*sj4))+(((-1.0)*cj5*x579))+x578);
evalcond[7]=(((sj4*x572))+(((-1.0)*cj4*cj5*x579))+new_r00);
evalcond[8]=((((-1.0)*cj4*x579))+new_r11+((x572*x576)));
evalcond[9]=((((-1.0)*cj5*x573*x575))+(((-1.0)*cj4*x581))+new_r10);
evalcond[10]=(((cj5*x577))+((new_r11*x576))+x572+(((-1.0)*new_r21*x574)));
evalcond[11]=(((cj5*x578))+((new_r10*x576))+(((-1.0)*x579))+(((-1.0)*new_r20*x574)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
} else
{
{
IkReal j6array[1], cj6array[1], sj6array[1];
bool j6valid[1]={false};
_nj6 = 1;
CheckValue<IkReal> x582=IKPowWithIntegerCheck(IKsign(sj5),-1);
if(!x582.valid){
continue;
}
CheckValue<IkReal> x583 = IKatan2WithCheck(IkReal(new_r21),((-1.0)*new_r20),IKFAST_ATAN2_MAGTHRESH);
if(!x583.valid){
continue;
}
j6array[0]=((-1.5707963267949)+(((1.5707963267949)*(x582.value)))+(x583.value));
sj6array[0]=IKsin(j6array[0]);
cj6array[0]=IKcos(j6array[0]);
if( j6array[0] > IKPI )
{
j6array[0]-=IK2PI;
}
else if( j6array[0] < -IKPI )
{ j6array[0]+=IK2PI;
}
j6valid[0] = true;
for(int ij6 = 0; ij6 < 1; ++ij6)
{
if( !j6valid[ij6] )
{
continue;
}
_ij6[0] = ij6; _ij6[1] = -1;
for(int iij6 = ij6+1; iij6 < 1; ++iij6)
{
if( j6valid[iij6] && IKabs(cj6array[ij6]-cj6array[iij6]) < IKFAST_SOLUTION_THRESH && IKabs(sj6array[ij6]-sj6array[iij6]) < IKFAST_SOLUTION_THRESH )
{
j6valid[iij6]=false; _ij6[1] = iij6; break;
}
}
j6 = j6array[ij6]; cj6 = cj6array[ij6]; sj6 = sj6array[ij6];
{
IkReal evalcond[12];
IkReal x584=IKsin(j6);
IkReal x585=IKcos(j6);
IkReal x586=((1.0)*sj5);
IkReal x587=((1.0)*sj4);
IkReal x588=(cj5*sj4);
IkReal x589=(cj4*new_r01);
IkReal x590=(cj4*new_r00);
IkReal x591=((1.0)*x585);
IkReal x592=(cj5*x584);
IkReal x593=((1.0)*x584);
evalcond[0]=(((sj5*x585))+new_r20);
evalcond[1]=((((-1.0)*x584*x586))+new_r21);
evalcond[2]=(((new_r11*sj4))+x589+x592);
evalcond[3]=(((cj4*new_r10))+(((-1.0)*x593))+(((-1.0)*new_r00*x587)));
evalcond[4]=((((-1.0)*new_r01*x587))+((cj4*new_r11))+(((-1.0)*x591)));
evalcond[5]=(((sj4*x585))+new_r01+((cj4*x592)));
evalcond[6]=((((-1.0)*cj5*x591))+((new_r10*sj4))+x590);
evalcond[7]=((((-1.0)*cj4*cj5*x591))+((sj4*x584))+new_r00);
evalcond[8]=(((x584*x588))+(((-1.0)*cj4*x591))+new_r11);
evalcond[9]=((((-1.0)*cj4*x593))+(((-1.0)*cj5*x585*x587))+new_r10);
evalcond[10]=((((-1.0)*new_r21*x586))+((cj5*x589))+x584+((new_r11*x588)));
evalcond[11]=((((-1.0)*new_r20*x586))+(((-1.0)*x591))+((cj5*x590))+((new_r10*x588)));
if( IKabs(evalcond[0]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[1]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[2]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[3]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[4]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[5]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[6]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[7]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[8]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[9]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[10]) > IKFAST_EVALCOND_THRESH || IKabs(evalcond[11]) > IKFAST_EVALCOND_THRESH )
{
continue;
}
}
{
std::vector<IkSingleDOFSolutionBase<IkReal> > vinfos(7);
vinfos[0].jointtype = 1;
vinfos[0].foffset = j0;
vinfos[0].indices[0] = _ij0[0];
vinfos[0].indices[1] = _ij0[1];
vinfos[0].maxsolutions = _nj0;
vinfos[1].jointtype = 1;
vinfos[1].foffset = j1;
vinfos[1].indices[0] = _ij1[0];
vinfos[1].indices[1] = _ij1[1];
vinfos[1].maxsolutions = _nj1;
vinfos[2].jointtype = 1;
vinfos[2].foffset = j2;
vinfos[2].indices[0] = _ij2[0];
vinfos[2].indices[1] = _ij2[1];
vinfos[2].maxsolutions = _nj2;
vinfos[3].jointtype = 1;
vinfos[3].foffset = j3;
vinfos[3].indices[0] = _ij3[0];
vinfos[3].indices[1] = _ij3[1];
vinfos[3].maxsolutions = _nj3;
vinfos[4].jointtype = 1;
vinfos[4].foffset = j4;
vinfos[4].indices[0] = _ij4[0];
vinfos[4].indices[1] = _ij4[1];
vinfos[4].maxsolutions = _nj4;
vinfos[5].jointtype = 1;
vinfos[5].foffset = j5;
vinfos[5].indices[0] = _ij5[0];
vinfos[5].indices[1] = _ij5[1];
vinfos[5].maxsolutions = _nj5;
vinfos[6].jointtype = 1;
vinfos[6].foffset = j6;
vinfos[6].indices[0] = _ij6[0];
vinfos[6].indices[1] = _ij6[1];
vinfos[6].maxsolutions = _nj6;
std::vector<int> vfree(0);
solutions.AddSolution(vinfos,vfree);
}
}
}
}
}
}
}
}
}
}
}
}
}static inline void polyroots2(IkReal rawcoeffs[2+1], IkReal rawroots[2], int& numroots) {
IkReal det = rawcoeffs[1]*rawcoeffs[1]-4*rawcoeffs[0]*rawcoeffs[2];
if( det < 0 ) {
numroots=0;
}
else if( det == 0 ) {
rawroots[0] = -0.5*rawcoeffs[1]/rawcoeffs[0];
numroots = 1;
}
else {
det = IKsqrt(det);
rawroots[0] = (-rawcoeffs[1]+det)/(2*rawcoeffs[0]);
rawroots[1] = (-rawcoeffs[1]-det)/(2*rawcoeffs[0]);//rawcoeffs[2]/(rawcoeffs[0]*rawroots[0]);
numroots = 2;
}
}
};
/// solves the inverse kinematics equations.
/// \param pfree is an array specifying the free joints of the chain.
IKFAST_API bool ComputeIk(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, IkSolutionListBase<IkReal>& solutions) {
IKSolver solver;
return solver.ComputeIk(eetrans,eerot,pfree,solutions);
}
IKFAST_API bool ComputeIk2(const IkReal* eetrans, const IkReal* eerot, const IkReal* pfree, IkSolutionListBase<IkReal>& solutions, void* pOpenRAVEManip) {
IKSolver solver;
return solver.ComputeIk(eetrans,eerot,pfree,solutions);
}
IKFAST_API const char* GetKinematicsHash() { return "e9a051e4825529aa31892beb41684ca4"; }
IKFAST_API const char* GetIkFastVersion() { return "0x10000048"; }
#ifdef IKFAST_NAMESPACE
} // end namespace
#endif
#ifndef IKFAST_NO_MAIN
#include <stdio.h>
#include <stdlib.h>
#ifdef IKFAST_NAMESPACE
using namespace IKFAST_NAMESPACE;
#endif
int main(int argc, char** argv)
{
if( argc != 12+GetNumFreeParameters()+1 ) {
printf("\nUsage: ./ik r00 r01 r02 t0 r10 r11 r12 t1 r20 r21 r22 t2 free0 ...\n\n"
"Returns the ik solutions given the transformation of the end effector specified by\n"
"a 3x3 rotation R (rXX), and a 3x1 translation (tX).\n"
"There are %d free parameters that have to be specified.\n\n",GetNumFreeParameters());
return 1;
}
IkSolutionList<IkReal> solutions;
std::vector<IkReal> vfree(GetNumFreeParameters());
IkReal eerot[9],eetrans[3];
eerot[0] = atof(argv[1]); eerot[1] = atof(argv[2]); eerot[2] = atof(argv[3]); eetrans[0] = atof(argv[4]);
eerot[3] = atof(argv[5]); eerot[4] = atof(argv[6]); eerot[5] = atof(argv[7]); eetrans[1] = atof(argv[8]);
eerot[6] = atof(argv[9]); eerot[7] = atof(argv[10]); eerot[8] = atof(argv[11]); eetrans[2] = atof(argv[12]);
for(std::size_t i = 0; i < vfree.size(); ++i)
vfree[i] = atof(argv[13+i]);
bool bSuccess = ComputeIk(eetrans, eerot, vfree.size() > 0 ? &vfree[0] : NULL, solutions);
if( !bSuccess ) {
fprintf(stderr,"Failed to get ik solution\n");
return -1;
}
printf("Found %d ik solutions:\n", (int)solutions.GetNumSolutions());
std::vector<IkReal> solvalues(GetNumJoints());
for(std::size_t i = 0; i < solutions.GetNumSolutions(); ++i) {
const IkSolutionBase<IkReal>& sol = solutions.GetSolution(i);
printf("sol%d (free=%d): ", (int)i, (int)sol.GetFree().size());
std::vector<IkReal> vsolfree(sol.GetFree().size());
sol.GetSolution(&solvalues[0],vsolfree.size()>0?&vsolfree[0]:NULL);
for( std::size_t j = 0; j < solvalues.size(); ++j)
printf("%.15f, ", solvalues[j]);
printf("\n");
}
return 0;
}
#endif
| 28.324108 | 606 | 0.637239 | [
"object",
"vector"
] |
0bca27e8cd193863611a980eefae3c08d0ee896a | 4,881 | cpp | C++ | src/web/server.cpp | Kotwic4/tig | fbf7498d47bc7177ee6bb6cfab2dda251f28fb62 | [
"MIT"
] | 3 | 2017-06-08T10:00:30.000Z | 2020-12-19T05:26:47.000Z | src/web/server.cpp | Kotwic4/tig | fbf7498d47bc7177ee6bb6cfab2dda251f28fb62 | [
"MIT"
] | null | null | null | src/web/server.cpp | Kotwic4/tig | fbf7498d47bc7177ee6bb6cfab2dda251f28fb62 | [
"MIT"
] | null | null | null | #include "server.h"
#include "../util/status.h"
#include "../util/common.h"
int server_port;
int web_sock;
int epoll_fd;
struct epoll_event event;
void init_server_web(){
if((epoll_fd = epoll_create1(0)) == -1){
perror("epoll_create1");
exit(EXIT_FAILURE);
}
event.events = EPOLLIN | EPOLLRDHUP;
web_sock = socket(AF_INET,SOCK_STREAM,0);
if(web_sock == -1){
perror("Socket");
exit(EXIT_FAILURE);
}
struct sockaddr_in web_addr;
web_addr.sin_family = AF_INET;
web_addr.sin_addr.s_addr = INADDR_ANY;
web_addr.sin_port = htons((uint16_t) server_port);
if(bind(web_sock,(struct sockaddr *)&web_addr,sizeof(web_addr)) == -1){
perror("Bind");
exit(EXIT_FAILURE);
}
if(listen(web_sock,N) == -1){
perror("listen");
exit(EXIT_FAILURE);
}
event.data.fd = web_sock;
if(epoll_ctl(epoll_fd, EPOLL_CTL_ADD, web_sock, &event)==-1){
perror("epoll_ctl");
exit(EXIT_FAILURE);
}
}
void server_stop(){
close(epoll_fd);
shutdown(web_sock,SHUT_RDWR);
close(web_sock);
}
void server_quit(int sig){
exit(EXIT_SUCCESS);
}
void server_push(int fd, Msg msg) {
Vector<String> client_hashes = msgToStrings(msg.buf2);
Vector<String> server_hashes = read_all_lines(HEAD.c_str());
int i = 0;
int j = 0;
while(i < client_hashes.size() && j < server_hashes.size()){
if(client_hashes[i] == server_hashes[i]){
i++;
j++;
}
else{
msg.type = MSG_END;
send(fd,&msg,sizeof(msg),0);
return;
}
}
if(i < client_hashes.size()){
if(i == 0){
strcpy(msg.buf2,"");
}
else{
strcpy(msg.buf2,client_hashes[i-1].c_str());
}
while(i < client_hashes.size()){
String s = COMMITS_DIR + "/" + deleteEndl(client_hashes[i]);
mkdir(s.c_str(),DEFAULT_PERM);
i++;
}
send(fd,&msg,sizeof(msg),0);
if(recv(fd, &msg, sizeof(msg), MSG_WAITALL) == -1){
perror("recv");
exit(EXIT_FAILURE);
}
while(msg.type != MSG_END){
printf("%s\n",msg.buf);
FILE * file = fopen(msg.buf,"w");
fprintf(file,"%s",msg.buf2);
fclose(file);
if(recv(fd, &msg, sizeof(msg), MSG_WAITALL) == -1){
perror("recv");
exit(EXIT_FAILURE);
}
}
String dir = COMMITS_DIR + "/" + deleteEndl(last_commit_hash()) + "/";
Vector<String> files = ls(dir.c_str());
for(int k = 0; k < files.size();k++){
String source = dir + files[k];
Cout << source << Endl;
String destination = STAGE_DIR + "/" + files[k];
copy(source.c_str(),destination.c_str());
destination = "./" + files[k];
copy(source.c_str(),destination.c_str());
}
}
}
void server_pull(int fd, Msg msg) {
fileToMsg(HEAD,msg);
msg.type = MSG_PULL;
send(fd,&msg,sizeof(msg),0);
recv(fd, &msg, sizeof(msg), MSG_WAITALL);
if(msg.type == MSG_END) return;
String client_hash = msg.buf2;
Vector<String> server_hashes = read_all_lines(HEAD.c_str());
fileToMsg(HEAD,msg);
msg.type = MSG_PULL;
send(fd,&msg,sizeof(msg),0);
fileToMsg(LOG,msg);
send(fd,&msg,sizeof(msg),0);
int i = 0;
if(client_hash != ""){
while(client_hash != server_hashes[i]){
i++;
}
i++;
}
while(i<server_hashes.size()){
String dir = COMMITS_DIR + "/" + deleteEndl(server_hashes[i]) + "/";
Vector<String> files = ls(dir.c_str());
for(int j = 0; j < files.size();j++){
String file = dir + files[j];
fileToMsg(file,msg);
msg.type = MSG_PULL;
send(fd,&msg,sizeof(msg),0);
}
i++;
}
msg.type = MSG_END;
send(fd,&msg,sizeof(msg),0);
}
int server(int argc, char *argv[]){
if(argc < 1){
printf("Need port number\n");
exit(EXIT_FAILURE);
}
server_port = atoi(argv[0]);
signal(SIGINT,server_quit);
atexit(server_stop);
init_server_web();
while(1){
if(epoll_wait(epoll_fd, &event, 1,-1) == -1){
perror("epoll_wait");
exit(EXIT_FAILURE);
}
struct sockaddr in_addr;
socklen_t in_len = sizeof(in_addr);
int fd = accept(event.data.fd, &in_addr, &in_len);
if (fd == -1) {
perror("accept");
exit(EXIT_FAILURE);
}
Msg msg;
recv(fd, &msg, sizeof(msg), MSG_WAITALL);
if(msg.type == MSG_PULL){
server_pull(fd, msg);
}
if(msg.type == MSG_PUSH){
server_push(fd, msg);
}
close(fd);
}
}
| 27.732955 | 78 | 0.527761 | [
"vector"
] |
0bceca320da3a7fb6f7167de1297b65e87f078da | 2,112 | hpp | C++ | Screening/screening_rules.hpp | LedererLab/FOS | 7fe5391fda4a94618db4418943c91f9acadf9140 | [
"MIT"
] | 4 | 2017-05-01T06:26:45.000Z | 2020-11-27T04:20:22.000Z | Screening/screening_rules.hpp | LedererLab/FOS | 7fe5391fda4a94618db4418943c91f9acadf9140 | [
"MIT"
] | null | null | null | Screening/screening_rules.hpp | LedererLab/FOS | 7fe5391fda4a94618db4418943c91f9acadf9140 | [
"MIT"
] | null | null | null | #ifndef SCREENING_RULES_HPP
#define SCREENING_RULES_HPP
// C System-Headers
//
// C++ System headers
#include <vector>
// Eigen Headers
#include <eigen3/Eigen/Dense>
// Boost Headers
//
// Project Specific Headers
#include "../Generic/generics.hpp"
namespace hdim {
template < typename T >
Eigen::Matrix< T, Eigen::Dynamic, 1 > DualPoint(
const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >& X,
const Eigen::Matrix< T, Eigen::Dynamic, 1 >& Y,
const Eigen::Matrix< T, Eigen::Dynamic, 1 >& Beta,
const T lambda ) {
Eigen::Matrix< T, Eigen::Dynamic, 1 > residual = Y - X*Beta;
T alpha = 1.0 / ( X.transpose()*residual ).template lpNorm< Eigen::Infinity >();
T alpha_tilde = static_cast<T>( Y.transpose()*residual ) / ( lambda * residual.squaredNorm() );
T s = std::min( std::max( alpha_tilde, - alpha ), alpha );
return s*residual;
}
template < typename T >
T DualityGap2 ( const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >& X,
const Eigen::Matrix< T, Eigen::Dynamic, 1 >& Y,
const Eigen::Matrix< T, Eigen::Dynamic, 1 >& Beta,
const Eigen::Matrix< T, Eigen::Dynamic, 1 >& Nu,
const T lambda ) {
T f_beta = 0.5*( Y - X*Beta ).squaredNorm() + lambda*Beta.template lpNorm< 1 >();
T d_nu = 0.5*Y.squaredNorm() - square( lambda ) / 2.0 *( Nu - Y * 1.0/lambda ).squaredNorm();
return f_beta - d_nu;
}
template < typename T >
std::vector< unsigned int > SafeActiveSet (
const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic >& X,
const Eigen::Matrix< T, Eigen::Dynamic, 1 >& center,
const T radius ) {
unsigned int p = X.cols();
std::vector< unsigned int > active_indices;
for( unsigned int j = 0; j < p ; j ++ ) {
Eigen::Matrix< T, Eigen::Dynamic, 1 > X_j = X.col( j );
T safe_region = std::abs( static_cast<T>( X_j.transpose() * center ) ) + radius * X_j.norm();
if( safe_region >= static_cast<T>( 1 ) ) {
active_indices.push_back( j );
}
}
return active_indices;
}
}
#endif // SCREENING_RULES_HPP
| 28.16 | 101 | 0.60464 | [
"vector"
] |
0bd345efd6394b4c1ce3191d16368714f884732f | 5,195 | cpp | C++ | Function Wrapper/test.cpp | Himanshu-Singh-1/AdvancedObjectOrientedProgramming | 9a9c8c76279d482daa9172b0dec40e1674d1e038 | [
"Apache-2.0"
] | null | null | null | Function Wrapper/test.cpp | Himanshu-Singh-1/AdvancedObjectOrientedProgramming | 9a9c8c76279d482daa9172b0dec40e1674d1e038 | [
"Apache-2.0"
] | null | null | null | Function Wrapper/test.cpp | Himanshu-Singh-1/AdvancedObjectOrientedProgramming | 9a9c8c76279d482daa9172b0dec40e1674d1e038 | [
"Apache-2.0"
] | null | null | null | #include "Function.hpp"
#include <iostream>
#include <cassert>
int
ret_one_hundred_func() {
return 100;
}
struct ret_two_hundred_functor_t {
int operator()(){
return 200;
}
};
int
sumrange(int a, int b) {
assert(a <= b);
return a < b ? a + sumrange(a + 1, b) : b;
}
int
main(void) {
auto ret_three_hundred_lambda_func = [](){
return 300;
};
{
//Test default construction
cs540::Function<int()> default_constructed;
//Test value construction with a free-function
cs540::Function<int()> ret_one_hundred(ret_one_hundred_func);
//Test value construction with a lambda-function
cs540::Function<int()> ret_three_hundred_lambda(ret_three_hundred_lambda_func);
//Test value construction with a functor
cs540::Function<int()> ret_two_hundred_functor(ret_two_hundred_functor_t{});
//Test function operator on default constructed
int testval = 30;
try {
default_constructed();
} catch(cs540::BadFunctionCall &bfc) {
//We modify testval here so that we can assert that a change happened later to make sure an exception was caught
testval += 10;
}
assert(testval == 40);
//Test function operator on free-function target, also test that results are correct
assert(ret_one_hundred() == ret_one_hundred_func());
//Test function operator on functor target, also test that results are correct
assert(ret_two_hundred_functor() == ret_two_hundred_functor_t{}());
//Test function operator on lambda target, also test that results are correct
assert(ret_three_hundred_lambda() == ret_three_hundred_lambda_func());
{
//Test assignment from Function
cs540::Function<int()> tmp;
tmp = ret_one_hundred;
assert(tmp() == ret_one_hundred_func());
}
{
//Test assignment from free-function
cs540::Function<int()> tmp;
tmp = ret_one_hundred_func;
assert(tmp() == ret_one_hundred_func());
}
{
//Test assignment from Function containing functor
cs540::Function<int()> tmp;
tmp = ret_two_hundred_functor;
assert(tmp() == ret_two_hundred_functor_t{}());
}
{
//Test assignment from functor
cs540::Function<int()> tmp;
ret_two_hundred_functor_t functor;
tmp = functor;
assert(tmp() == ret_two_hundred_functor_t{}());
}
{
//Test assignment from Function containing lambda
cs540::Function<int()> tmp;
tmp = ret_three_hundred_lambda;
assert(tmp() == ret_three_hundred_lambda_func());
}
{
//Test assignment from lambda
cs540::Function<int()> tmp;
tmp = ret_three_hundred_lambda_func;
assert(tmp() == ret_three_hundred_lambda_func());
}
// Test that it is using value semantics.
{
struct Functor {
int operator()() {
return i++;
}
int i = 0;
} functor;
cs540::Function<int ()> f{functor};
assert(f() == 0);
assert(f() == 1);
assert(f() == 2);
assert(functor.i == 0);
}
{
//Test equality operators
assert((!ret_one_hundred.operator bool()) == (ret_one_hundred == nullptr));
assert((!ret_one_hundred.operator bool()) == (nullptr == ret_one_hundred));
//Test equality operators with a default constructed object
cs540::Function<void(void)> tmp;
assert((!tmp.operator bool()) == (tmp == nullptr));
assert((!tmp.operator bool()) == (nullptr == tmp));
}
{
//Test inequality operators
assert(ret_one_hundred.operator bool() == (ret_one_hundred != nullptr));
assert(ret_one_hundred.operator bool() == (nullptr != ret_one_hundred));
//Test inequality operators with a default constructed object
cs540::Function<void()> tmp;
assert(false == (tmp != nullptr));
assert(false == (nullptr != tmp));
}
{
cs540::Function<int()> tmp(ret_one_hundred);
assert(ret_one_hundred() == tmp());
tmp = ret_two_hundred_functor;
assert(ret_two_hundred_functor() == tmp());
tmp = ret_three_hundred_lambda;
assert(ret_three_hundred_lambda() == tmp());
}
{
//Testing a function that takes arguments
cs540::Function<int(int,int)> sum_range(sumrange);
assert(sumrange(10,15) == sum_range(10,15));
}
{
//Testing a recursive lambda that captures a value from the surrounding scope
const int a = 30;
cs540::Function<int(int)> sum_range = [&sum_range](int b) -> int {
assert(a<=b);
return a==b ? b : b + sum_range(b-1);
};
assert(sum_range(40) == sumrange(30,40));
}
}
}
| 30.922619 | 122 | 0.564389 | [
"object"
] |
0bd3f4e5b476213c95a19646fbbe1cd10594c5a6 | 8,929 | cpp | C++ | toonz/sources/stdfx/igs_resource_msg_from_err_unix.cpp | jcome/opentoonz | b660920f35ce279526fd7e7ca7ff600adfe5c28b | [
"BSD-3-Clause"
] | 36 | 2020-05-18T22:26:35.000Z | 2022-02-19T00:09:25.000Z | toonz/sources/stdfx/igs_resource_msg_from_err_unix.cpp | LibrePhone/opentoonz | cb95a29db4c47ab1f36a6e85a039c4c9c901f88a | [
"BSD-3-Clause"
] | 22 | 2017-03-16T18:52:36.000Z | 2019-09-09T06:02:53.000Z | toonz/sources/stdfx/igs_resource_msg_from_err_unix.cpp | LibrePhone/opentoonz | cb95a29db4c47ab1f36a6e85a039c4c9c901f88a | [
"BSD-3-Clause"
] | 8 | 2020-06-12T17:01:20.000Z | 2021-09-15T07:03:12.000Z | #include <cerrno>
#include <cstring> /* memset */
#include <vector>
#include <stdexcept> // std::domain_error(-)
#include <locale>
#include <iconv.h>
#include "igs_resource_msg_from_err.h"
/*------ localeを日本に設定し日本語を扱うことを指示(必須)
使う文字コードは"locale -a"で調べる */
void igs::resource::locale_to_jp(void) { setlocale(LC_CTYPE, "ja_JP.utf8"); }
#if 0 //------
/*
リサーチ中
日本語環境を環境変数から取ってくる場合のルーチン
deamonの場合これでいいのか???
さらに調査が必要
2013-02-18
*/
#include <X11/Xlib.h>
#include <X11/Xlocale.h>
void igs::resource::locale_to_jp(void) {
/*
Software Design 1993年3月号
"SPECIAL ISSUE どうする?UNIXの日本語環境"
稚内北星短期大学 丸山 不二夫
Page14 リスト4 より
X11R5での日本語処理 - ロケールの設定
標準的な処理手順
全てのX(lib)プログラムの先頭で行う
*/
/* 次の場合、環境変数 LANG から、地域名を得ます
引数locale が "" の場合、
ロケールの各部分の設定には環境変数が参照される。
その詳細は実装依存である。
Linux Programmer’s Manual July 4, 1999より
*/
if ( ::setlocale( LC_ALL ,"" ) == NULL ) {
throw std::domain_error( "Can not set locale." );
}
/* Xlibが、現在の地域をサポートしているかチェックします */
if ( !::XSupportsLocale() ) {
std::string msg("X is not support locale ");
msg += setlocale( LC_ALL ,NULL );
msg += ".\n";
throw std::domain_error( msg.c_str() );
}
/* 次の場合、環境変数 XMODIFIERS から修飾子が得られます
この修飾子は。入力メソッド (IM) の指定に使われます */
if ( ::XSetLocaleModifiers("") == NULL ) {
throw std::domain_error( "Can not set locale modifiers." );
}
}
/*
#g++ -L/usr/X11R6/lib/ -lXmu -lXext -lX11 -lgthread -lglib -lm tes82.cxx
g++ tes82.cxx -L/usr/X11R6/lib/ -lX11
*/
#endif //------
/*------ マルチバイト文字列 --> ワイド文字文字列 ------*/
void igs::resource::mbs_to_wcs(const std::string &mbs, std::wstring &wcs) {
size_t length = 0;
{
const char *src_ptr = mbs.c_str();
mbstate_t ss;
::memset(&ss, 0, sizeof(ss));
length = ::mbsrtowcs(NULL, &src_ptr, 0, &ss);
if (length == (size_t)(-1)) { /* 不正なマルチバイト列に遭遇した */
throw std::domain_error(
"mbstowcs(-) got bad multi byte character,when size");
}
if (length <= 0) {
return;
} /* 文字がないなら何もしない */
++length;
}
// std::vector<wchar_t> dst(length);
wcs.resize(length);
{
const char *src_ptr = mbs.c_str();
mbstate_t ss;
::memset(&ss, 0, sizeof(ss));
// length = ::mbsrtowcs(&dst.at(0) ,&src_ptr ,length ,&ss);
length =
::mbsrtowcs(const_cast<wchar_t *>(wcs.c_str()), &src_ptr, length, &ss);
if (length == (size_t)(-1)) { /* 不正なマルチバイト列に遭遇した */
throw std::domain_error(
"mbstowcs(-) got bad multi byte character,when conv");
}
if (length <= 0) {
throw std::domain_error("mbstowcs(-) got zero or under equal -2 ");
}
}
// wcs = std::wstring(dst.begin() ,dst.end()-1);/* 終端以外を */
wcs.erase(wcs.end() - 1); /* 終端文字を消す */
}
/*------ ワイド文字文字列 --> マルチバイト文字列 ------*/
void igs::resource::wcs_to_mbs(const std::wstring &wcs, std::string &mbs) {
size_t length = 0;
{
const wchar_t *src_ptr = wcs.c_str();
mbstate_t ss;
::memset(&ss, 0, sizeof(ss));
length = ::wcsrtombs(NULL, &src_ptr, 0, &ss);
if (length <= 0) {
return;
} /* 文字がないなら何もしない */
++length;
}
// std::vector<char> dst(length);
mbs.resize(length);
{
const wchar_t *src_ptr = wcs.c_str();
mbstate_t ss;
::memset(&ss, 0, sizeof(ss));
// length = ::wcsrtombs(&dst.at(0) ,&src_ptr ,length ,&ss);
length =
::wcsrtombs(const_cast<char *>(mbs.c_str()), &src_ptr, length, &ss);
if (length <= 0) {
throw std::domain_error("wcstombs(-) got bad wide character");
}
}
// mbs = std::string(dst.begin() ,dst.end()-1);/* 終端以外を */
mbs.erase(mbs.end() - 1); /* 終端文字を消す */
}
/*------ UNICODE宣言ならマルチバイト文字列をワイド文字文字列に変換 ------*/
const std::basic_string<TCHAR> igs::resource::ts_from_mbs(
const std::string &mbs) {
#if defined UNICODE
std::wstring wcs;
igs::resource::mbs_to_wcs(mbs, wcs);
return wcs;
#else
/* MBCSの場合のsize()は文字数ではなくchar(byte)数,2bytes文字は2 */
return mbs;
#endif
}
/*------ UNICODE宣言ならワイド文字文字列をマルチバイト文字列に変換 ------*/
const std::string igs::resource::mbs_from_ts(
const std::basic_string<TCHAR> &ts) {
#if defined UNICODE
std::string mbs;
igs::resource::wcs_to_mbs(ts, mbs);
return mbs;
#else
/* MBCSの場合のsize()は文字数ではなくchar(byte)数,2bytes文字は2 */
return ts;
#endif
}
/*------ cp932を含む文字列をutf-8に変換(マルチバイト文字列) ------*/
namespace {
const std::string iconv_to_from_(const std::string &text, const char *tocode,
const char *fromcode) {
iconv_t icd = ::iconv_open(tocode, fromcode); // "iconv --list"
if (reinterpret_cast<iconv_t>(-1) == icd) {
throw std::domain_error(
igs_resource_msg_from_err(TEXT("iconv_open(-)"), errno));
}
std::vector<char> dst(text.size() * 4);
char *inbuf = const_cast<char *>(text.c_str());
char *outbuf = &dst.at(0);
size_t inbytesleft = text.size();
size_t outbytesleft = dst.size();
size_t ret = ::iconv(icd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
*outbuf = '\0';
/*
retに処理した数が入るはずだが、rhel5ではゼロが帰るので、
処理数を別途計算する
*/
ret = dst.size() - outbytesleft;
if (ret <= 0) {
// if (static_cast<size_t>(-1) == ret) {
::iconv_close(icd);
throw std::domain_error(igs_resource_msg_from_err(TEXT("iconv(-)"), errno));
}
if (-1 == ::iconv_close(icd)) {
throw std::domain_error(
igs_resource_msg_from_err(TEXT("iconv_close(-)"), errno));
}
std::string mbs(std::string(dst.begin(), dst.begin() + ret));
return mbs;
}
}
const std::string igs::resource::utf8_from_cp932_mb(const std::string &text) {
return iconv_to_from_(text, "UTF-8", "CP932"); // "iconv --list"
}
const std::string igs::resource::cp932_from_utf8_mb(const std::string &text) {
return iconv_to_from_(text, "CP932", "UTF-8"); // "iconv --list"
}
/*------ エラーメッセージ表示の元関数、直接呼び出すことはしない ------*/
#include <cerrno> // errno
#include <cstring> // strerror_r()
#include <sstream> // std::istringstream
#include "igs_resource_msg_from_err.h"
const std::string igs::resource::msg_from_err_(
const std::basic_string<TCHAR> &tit, const int erno,
const std::string &file, const std::string &line,
const std::string &pretty_function, const std::string &comp_type,
const std::string &gnuc, const std::string &gnuc_minor,
const std::string &gnuc_patchlevel, const std::string &gnuc_rh_release,
const std::string &date, const std::string &time) {
std::string errmsg;
errmsg += '\"';
/* フルパスで入ってきた場合ファイル名だけにする */
std::string::size_type index = file.find_last_of("/\\");
if (std::basic_string<TCHAR>::npos != index) {
errmsg += file.substr(index + 1);
} else {
errmsg += file;
}
errmsg += ':';
errmsg += line;
errmsg += ':';
errmsg += comp_type;
errmsg += ':';
errmsg += gnuc;
errmsg += '.';
errmsg += gnuc_minor;
errmsg += '.';
errmsg += gnuc_patchlevel;
errmsg += '-';
errmsg += gnuc_rh_release;
{
std::istringstream ist(date);
std::string month, day, year;
ist >> month;
ist >> day;
ist >> year;
errmsg += ':';
errmsg += year;
errmsg += ':';
errmsg += month;
errmsg += ':';
errmsg += day;
}
errmsg += ':';
errmsg += time;
errmsg += '\"';
errmsg += ' ';
errmsg += '\"';
errmsg += pretty_function;
errmsg += '\"';
errmsg += ' ';
errmsg += '\"';
if (0 < tit.size()) {
errmsg += igs::resource::mbs_from_ts(tit);
}
if (0 != erno) {
errmsg += ':';
#if defined __HP_aCC
/*
HP-UX(v11.23)では、strerror_r()をサポートしない。
注意::strerror()はThread SafeではなくMulti Threadでは正常動作しない
*/
errmsg += ::strerror(erno);
#elif ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE)
/*
http://japanese-linux-man-pages.coding-school.com/man/X_strerror_r-3
より、POSIX.1.2002で規定されたXSI準拠のバージョンのstrerror_r()
*/
char buff[4096];
const int ret = ::strerror_r(erno, buff, sizeof(buff));
if (0 == ret) {
errmsg += buff;
} else if (-1 == ret) {
swtich(errno) {
case EINVAL:
errmsg +=
"strerror_r() gets Error : The value of errnum is not a "
"valid error number.";
/* errnum の値が有効なエラー番号ではない */
break;
case ERANGE:
errmsg +=
"strerror_r() gets Error : Insufficient storage was "
"supplied via strerrbuf and buflen to contain the "
"generated message string.";
/* エラーコードを説明する文字列のために、
充分な領域が確保できな かった */
break;
deatult:
errmsg += "strerror_r() gets Error and Returns bad errno";
break;
}
} else {
errmsg += "strerror_r() returns bad value";
}
#elif defined(__APPLE__)
char buff[4096];
int ret = ::strerror_r(erno, buff, sizeof(buff));
if (!ret) {
errmsg += buff;
}
#else
/* linuxはここに来る?
http://japanese-linux-man-pages.coding-school.com/man/X_strerror_r-3
より、GNU仕様のバージョンのstrerror_r()。非標準の拡張
これはThread Safeか??????
*/
char buff[4096];
const char *ret = ::strerror_r(erno, buff, sizeof(buff));
errmsg += ret;
#endif
}
errmsg += '\"';
return errmsg;
}
| 27.903125 | 80 | 0.607459 | [
"vector"
] |
0bdb79923457b82600fb3948254947c8e70ac0c4 | 9,913 | cpp | C++ | Microsoft.WindowsAzure.Storage/src/authentication.cpp | ShippyMSFT/azure-storage-cpp | ee3a3f7db31a39ed5041fe1cb947c784ce64295b | [
"Apache-2.0"
] | null | null | null | Microsoft.WindowsAzure.Storage/src/authentication.cpp | ShippyMSFT/azure-storage-cpp | ee3a3f7db31a39ed5041fe1cb947c784ce64295b | [
"Apache-2.0"
] | null | null | null | Microsoft.WindowsAzure.Storage/src/authentication.cpp | ShippyMSFT/azure-storage-cpp | ee3a3f7db31a39ed5041fe1cb947c784ce64295b | [
"Apache-2.0"
] | 1 | 2021-08-02T15:58:34.000Z | 2021-08-02T15:58:34.000Z | // -----------------------------------------------------------------------------------------
// <copyright file="authentication.cpp" company="Microsoft">
// Copyright 2013 Microsoft Corporation
//
// 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.
// </copyright>
// -----------------------------------------------------------------------------------------
#include "stdafx.h"
#include "was/auth.h"
#include "wascore/util.h"
#include "wascore/constants.h"
#include "wascore/logging.h"
#include "wascore/streams.h"
namespace azure { namespace storage { namespace protocol {
utility::string_t calculate_hmac_sha256_hash(const utility::string_t& string_to_hash, const storage_credentials& credentials)
{
std::string utf8_string_to_hash = utility::conversions::to_utf8string(string_to_hash);
core::hash_provider provider = core::hash_provider::create_hmac_sha256_hash_provider(credentials.account_key());
provider.write(reinterpret_cast<const uint8_t*>(utf8_string_to_hash.data()), utf8_string_to_hash.size());
provider.close();
return provider.hash().hmac_sha256();
}
void sas_authentication_handler::sign_request(web::http::http_request& request, operation_context context) const
{
web::http::uri request_uri = request.request_uri();
request_uri = m_credentials.transform_uri(request_uri);
request.set_request_uri(request_uri);
}
void shared_key_authentication_handler::sign_request(web::http::http_request& request, operation_context context) const
{
web::http::http_headers& headers = request.headers();
headers.add(ms_header_date, utility::datetime::utc_now().to_string());
if (m_credentials.is_shared_key())
{
utility::string_t string_to_sign = m_canonicalizer->canonicalize(request, context);
if (core::logger::instance().should_log(context, client_log_level::log_level_verbose))
{
utility::string_t with_dots(string_to_sign);
std::replace(with_dots.begin(), with_dots.end(), _XPLATSTR('\n'), _XPLATSTR('.'));
core::logger::instance().log(context, client_log_level::log_level_verbose, _XPLATSTR("StringToSign: ") + with_dots);
}
utility::string_t header_value;
header_value.reserve(256);
header_value.append(m_canonicalizer->authentication_scheme());
header_value.append(_XPLATSTR(" "));
header_value.append(m_credentials.account_name());
header_value.append(_XPLATSTR(":"));
header_value.append(calculate_hmac_sha256_hash(string_to_sign, m_credentials));
headers.add(web::http::header_names::authorization, header_value);
}
}
void bearer_token_authentication_handler::sign_request(web::http::http_request& request, operation_context context) const
{
web::http::http_headers& headers = request.headers();
headers.add(ms_header_date, utility::datetime::utc_now().to_string());
if (m_credentials.is_bearer_token())
{
headers.add(web::http::header_names::authorization, _XPLATSTR("Bearer ") + m_credentials.bearer_token());
}
}
void canonicalizer_helper::append_resource(bool query_only_comp)
{
m_result.append(_XPLATSTR("/"));
m_result.append(m_account_name);
web::http::uri uri = m_request.request_uri();
const utility::string_t& resource = uri.path();
if (resource.front() != _XPLATSTR('/'))
{
m_result.append(_XPLATSTR("/"));
}
m_result.append(resource);
std::map<utility::string_t, utility::string_t> query_map = web::http::uri::split_query(uri.query());
if (query_only_comp)
{
std::map<utility::string_t, utility::string_t>::iterator it = query_map.find(_XPLATSTR("comp"));
if (it != query_map.end())
{
m_result.append(_XPLATSTR("?comp="));
m_result.append(web::http::uri::decode(it->second));
}
}
else
{
// std::map keys are already sorted
for (std::map<utility::string_t, utility::string_t>::const_iterator it = query_map.cbegin(); it != query_map.cend(); ++it)
{
utility::string_t parameter_name = it->first;
std::transform(parameter_name.begin(), parameter_name.end(), parameter_name.begin(), core::utility_char_tolower);
m_result.append(_XPLATSTR("\n"));
m_result.append(parameter_name);
m_result.append(_XPLATSTR(":"));
m_result.append(web::http::uri::decode(it->second));
}
}
}
void canonicalizer_helper::append_header(const utility::string_t& header_name)
{
utility::string_t value;
m_request.headers().match(header_name, value);
append(value);
}
void canonicalizer_helper::append_content_length_header()
{
utility::string_t value;
m_request.headers().match(web::http::header_names::content_length, value);
if (value == _XPLATSTR("0"))
{
value.clear();
}
append(value);
}
void canonicalizer_helper::append_date_header(bool allow_x_ms_date)
{
utility::string_t value;
if (!m_request.headers().match(ms_header_date, value))
{
append_header(web::http::header_names::date);
}
else if (allow_x_ms_date)
{
append(value);
}
else
{
append(utility::string_t());
}
}
void canonicalizer_helper::append_x_ms_headers()
{
const web::http::http_headers& headers = m_request.headers();
for (web::http::http_headers::const_iterator it = headers.begin(); it != headers.end(); ++it)
{
const utility::char_t *key = it->first.c_str();
size_t key_size = it->first.size();
// disables warning 4996 to bypass the usage of std::equal;
// a more secure usage of std::equal with 5 parameters is supported by c++14.
// to be compatible with c++11, warning 4996 is disabled.
if ((key_size > ms_header_prefix_size) &&
std::equal(ms_header_prefix, ms_header_prefix + ms_header_prefix_size, key, [](const utility::char_t &c1, const utility::char_t &c2) {return c1 == c2;}))
{
utility::string_t transformed_key(key);
std::transform(transformed_key.begin(), transformed_key.end(), transformed_key.begin(), core::utility_char_tolower);
m_result.append(transformed_key);
m_result.append(_XPLATSTR(":"));
append(it->second);
}
}
}
utility::string_t shared_key_blob_queue_canonicalizer::canonicalize(const web::http::http_request& request, operation_context context) const
{
canonicalizer_helper helper(request, m_account_name);
helper.append(request.method());
helper.append_header(web::http::header_names::content_encoding);
helper.append_header(web::http::header_names::content_language);
helper.append_content_length_header();
helper.append_header(web::http::header_names::content_md5);
helper.append_header(web::http::header_names::content_type);
helper.append_date_header(false);
helper.append_header(web::http::header_names::if_modified_since);
helper.append_header(web::http::header_names::if_match);
helper.append_header(web::http::header_names::if_none_match);
helper.append_header(web::http::header_names::if_unmodified_since);
helper.append_header(web::http::header_names::range);
helper.append_x_ms_headers();
helper.append_resource(false);
return helper.str();
}
utility::string_t shared_key_lite_blob_queue_canonicalizer::canonicalize(const web::http::http_request& request, operation_context context) const
{
canonicalizer_helper helper(request, m_account_name);
helper.append(request.method());
helper.append_header(web::http::header_names::content_md5);
helper.append_header(web::http::header_names::content_type);
helper.append_date_header(false);
helper.append_x_ms_headers();
helper.append_resource(true);
return helper.str();
}
utility::string_t shared_key_table_canonicalizer::canonicalize(const web::http::http_request& request, operation_context context) const
{
canonicalizer_helper helper(request, m_account_name);
helper.append(request.method());
helper.append_header(web::http::header_names::content_md5);
helper.append_header(web::http::header_names::content_type);
helper.append_date_header(true);
helper.append_resource(true);
return helper.str();
}
utility::string_t shared_key_lite_table_canonicalizer::canonicalize(const web::http::http_request& request, operation_context context) const
{
canonicalizer_helper helper(request, m_account_name);
helper.append_date_header(true);
helper.append_resource(true);
return helper.str();
}
}}} // namespace azure::storage::protocol
| 42.91342 | 169 | 0.639463 | [
"transform"
] |
0bf0d20d616df00541184bf062ce9e03efba1e24 | 1,603 | cpp | C++ | src/libminc/MincPostfixExpr.cpp | RcSepp/minc | 8add46095ba7990ca636a6e6c266dda4148052fd | [
"MIT"
] | null | null | null | src/libminc/MincPostfixExpr.cpp | RcSepp/minc | 8add46095ba7990ca636a6e6c266dda4148052fd | [
"MIT"
] | null | null | null | src/libminc/MincPostfixExpr.cpp | RcSepp/minc | 8add46095ba7990ca636a6e6c266dda4148052fd | [
"MIT"
] | null | null | null | #include "minc_api.hpp"
MincPostfixExpr::MincPostfixExpr(const MincLocation& loc, int op, const char* opstr, MincExpr* a)
: MincExpr(loc, MincExpr::ExprType::POSTOP), op(op), a(a), opstr(opstr)
{
}
bool MincPostfixExpr::match(const MincBlockExpr* block, const MincExpr* expr, MatchScore& score) const
{
return expr->exprtype == this->exprtype && ((MincPostfixExpr*)expr)->op == this->op && a->match(block, ((MincPostfixExpr*)expr)->a, score);
}
void MincPostfixExpr::collectParams(const MincBlockExpr* block, MincExpr* expr, std::vector<MincExpr*>& params, size_t& paramIdx) const
{
a->collectParams(block, ((MincPostfixExpr*)expr)->a, params, paramIdx);
}
void MincPostfixExpr::resolve(const MincBlockExpr* block)
{
if (!isResolved())
{
a->resolve(block);
MincExpr::resolve(block);
}
}
void MincPostfixExpr::forget()
{
a->forget();
MincExpr::forget();
}
std::string MincPostfixExpr::str() const
{
return a->str() + (std::isalpha(opstr.front()) ? opstr + ' ' : opstr);
}
std::string MincPostfixExpr::shortStr() const
{
return a->shortStr() + (std::isalpha(opstr.front()) ? opstr + ' ' : opstr);
}
int MincPostfixExpr::comp(const MincExpr* other) const
{
int c = MincExpr::comp(other);
if (c) return c;
const MincPostfixExpr* _other = (const MincPostfixExpr*)other;
c = this->op - _other->op;
if (c) return c;
return this->a->comp(_other->a);
}
MincExpr* MincPostfixExpr::clone() const
{
return new MincPostfixExpr(loc, op, opstr.c_str(), a->clone());
}
extern "C"
{
bool ExprIsPostfixOp(const MincExpr* expr)
{
return expr->exprtype == MincExpr::ExprType::POSTOP;
}
} | 25.046875 | 140 | 0.694323 | [
"vector"
] |
0bf523269a0da0e5b93d4ad06bb51d9a6b8f3de4 | 10,073 | cpp | C++ | src/gausskernel/optimizer/commands/define.cpp | Mu-L/openGauss-server | 27bdb0d62bc727e5f9172af1889ca35caf1b2c7b | [
"MulanPSL-1.0"
] | null | null | null | src/gausskernel/optimizer/commands/define.cpp | Mu-L/openGauss-server | 27bdb0d62bc727e5f9172af1889ca35caf1b2c7b | [
"MulanPSL-1.0"
] | null | null | null | src/gausskernel/optimizer/commands/define.cpp | Mu-L/openGauss-server | 27bdb0d62bc727e5f9172af1889ca35caf1b2c7b | [
"MulanPSL-1.0"
] | null | null | null | /* -------------------------------------------------------------------------
*
* define.cpp
* Support routines for various kinds of object creation.
*
*
* Portions Copyright (c) 2020 Huawei Technologies Co.,Ltd.
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/gausskernel/optimizer/commands/define.cpp
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
* appropriate arguments/flags, passing the results to the
* corresponding "FooDefine" routines (in src/catalog) that do
* the actual catalog-munging. These routines also verify permission
* of the user to execute the command.
*
* NOTES
* These things must be defined and committed in the following order:
* "create function":
* input/output, recv/send procedures
* "create type":
* type
* "create operator":
* operators
*
*
* -------------------------------------------------------------------------
*/
#ifndef FRONTEND_PARSER
#include "postgres.h"
#include "knl/knl_variable.h"
#else
#include "postgres_fe.h"
#endif
#include <ctype.h>
#include <math.h>
#ifdef FRONTEND_PARSER
#include "nodes/parsenodes_common.h"
#include "commands/defrem.h"
#include "nodes/makefuncs.h"
#include "parser/scansup.h"
#else
#include "catalog/namespace.h"
#include "commands/defrem.h"
#include "nodes/makefuncs.h"
#include "parser/parse_type.h"
#include "parser/scansup.h"
#include "utils/int8.h"
#endif
#ifndef FRONTEND_PARSER
const int INTEGER_SIZE = 64;
/*
* Extract a string value (otherwise uninterpreted) from a DefElem.
*/
char* defGetString(DefElem* def)
{
if (def->arg == NULL)
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a parameter", def->defname)));
switch (nodeTag(def->arg)) {
case T_Integer: {
char* str = (char*)palloc(INTEGER_SIZE);
errno_t rc = snprintf_s(str, INTEGER_SIZE, INTEGER_SIZE - 1, "%ld", (long)intVal(def->arg));
securec_check_ss(rc, "\0", "\0");
return str;
}
case T_Float:
/*
* T_Float values are kept in string form, so this type cheat
* works (and doesn't risk losing precision)
*/
return strVal(def->arg);
case T_String:
return strVal(def->arg);
case T_TypeName:
return TypeNameToString((TypeName*)def->arg);
case T_List:
return NameListToString((List*)def->arg);
case T_A_Star:
return pstrdup("*");
default:
ereport(ERROR,
(errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE),
errmsg("unrecognized node type: %d", (int)nodeTag(def->arg))));
}
return NULL; /* keep compiler quiet */
}
/*
* Extract a numeric value (actually double) from a DefElem.
*/
double defGetNumeric(DefElem* def)
{
if (def->arg == NULL)
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a numeric value", def->defname)));
switch (nodeTag(def->arg)) {
case T_Integer:
return (double)intVal(def->arg);
case T_Float:
return floatVal(def->arg);
default:
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a numeric value", def->defname)));
}
return 0; /* keep compiler quiet */
}
/*
* Extract a boolean value from a DefElem.
*/
bool defGetBoolean(DefElem* def)
{
/*
* If no parameter given, assume "true" is meant.
*/
if (def->arg == NULL)
return true;
/*
* Allow 0, 1, "true", "false", "on", "off"
*/
switch (nodeTag(def->arg)) {
case T_Integer:
switch (intVal(def->arg)) {
case 0:
return false;
case 1:
return true;
default:
/* otherwise, error out below */
break;
}
break;
default: {
char* sval = defGetString(def);
/*
* The set of strings accepted here should match up with the
* grammar's opt_boolean production.
*/
if (pg_strcasecmp(sval, "true") == 0)
return true;
if (pg_strcasecmp(sval, "false") == 0)
return false;
if (pg_strcasecmp(sval, "on") == 0)
return true;
if (pg_strcasecmp(sval, "off") == 0)
return false;
} break;
}
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a Boolean value", def->defname)));
return false; /* keep compiler quiet */
}
/*
* Extract an int64 value from a DefElem.
*/
int64 defGetInt64(DefElem* def)
{
if (def->arg == NULL)
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a numeric value", def->defname)));
switch (nodeTag(def->arg)) {
case T_Integer:
return (int64)intVal(def->arg);
case T_Float:
/*
* Values too large for int4 will be represented as Float
* constants by the lexer. Accept these if they are valid int8
* strings.
*/
return DatumGetInt64(DirectFunctionCall1(int8in, CStringGetDatum(strVal(def->arg))));
default:
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a numeric value", def->defname)));
}
return 0; /* keep compiler quiet */
}
/*
* Extract a possibly-qualified name (as a List of Strings) from a DefElem.
*/
List* defGetQualifiedName(DefElem* def)
{
if (def->arg == NULL)
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a parameter", def->defname)));
switch (nodeTag(def->arg)) {
case T_TypeName:
return ((TypeName*)def->arg)->names;
case T_List:
return (List*)def->arg;
case T_String:
/* Allow quoted name for backwards compatibility */
return list_make1(def->arg);
default:
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("argument of %s must be a name", def->defname)));
}
return NIL; /* keep compiler quiet */
}
/*
* Extract a TypeName from a DefElem.
*
* Note: we do not accept a List arg here, because the parser will only
* return a bare List when the name looks like an operator name.
*/
TypeName* defGetTypeName(DefElem* def)
{
if (def->arg == NULL)
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a parameter", def->defname)));
switch (nodeTag(def->arg)) {
case T_TypeName:
return (TypeName*)def->arg;
case T_String:
/* Allow quoted typename for backwards compatibility */
return makeTypeNameFromNameList(list_make1(def->arg));
default:
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("argument of %s must be a type name", def->defname)));
}
return NULL; /* keep compiler quiet */
}
/*
* Extract a type length indicator (either absolute bytes, or
* -1 for "variable") from a DefElem.
*/
int defGetTypeLength(DefElem* def)
{
if (def->arg == NULL)
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a parameter", def->defname)));
switch (nodeTag(def->arg)) {
case T_Integer:
return intVal(def->arg);
case T_Float:
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires an integer value", def->defname)));
break;
case T_String:
if (pg_strcasecmp(strVal(def->arg), "variable") == 0)
return -1; /* variable length */
break;
case T_TypeName:
/* cope if grammar chooses to believe "variable" is a typename */
if (pg_strcasecmp(TypeNameToString((TypeName*)def->arg), "variable") == 0)
return -1; /* variable length */
break;
case T_List:
/* must be an operator name */
break;
default:
ereport(ERROR,
(errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE),
errmsg("unrecognized node type: %d", (int)nodeTag(def->arg))));
}
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR), errmsg("invalid argument for %s: \"%s\"", def->defname, defGetString(def))));
return 0; /* keep compiler quiet */
}
/*
* Extract a list of string values (otherwise uninterpreted) from a DefElem.
*/
List *defGetStringList(DefElem *def)
{
ListCell *cell;
if (def->arg == NULL) {
ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("%s requires a parameter", def->defname)));
}
if (nodeTag(def->arg) != T_List) {
ereport(ERROR,
(errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE), errmsg("unrecognized node type: %d", (int)nodeTag(def->arg))));
}
foreach (cell, (List *)def->arg) {
Node *str = (Node *)lfirst(cell);
if (!IsA(str, String)) {
ereport(ERROR, (errmsg("unexpected node type in name list: %d", (int)nodeTag(str))));
}
}
return (List *)def->arg;
}
#endif /* !FRONTEND_PARSER */
/*
* Create a DefElem setting "oids" to the specified value.
*/
DefElem* defWithOids(bool value)
{
return makeDefElem("oids", (Node*)makeInteger(value));
}
/*
* Set value with specific option, or add a new def value
*/
List* defSetOption(List* options, const char* name, Node* value)
{
ListCell* lc = NULL;
foreach (lc, options) {
DefElem* elem = (DefElem*)lfirst(lc);
if (strncmp(elem->defname, name, strlen(name)) == 0) {
elem->arg = value;
break;
}
}
#ifndef FRONTEND_PARSER
if (lc == NULL)
options = lappend(options, makeDefElem(pstrdup(name), value));
#else
if (lc == NULL)
options = lappend(options, makeDefElem(strdup(name), value));
#endif
return options;
}
| 30.804281 | 120 | 0.585129 | [
"object"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.