blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
175f80fa6a86f8d58f498ce6d6de4d75ede0792e
8b5d6c8965011d818399df2de6292a377962672d
/src/qt/utilitydialog.h
f289338cd6dfcdedc3f0a9830aba6013a2d04df2
[ "MIT" ]
permissive
catracoin/catracoin
56e921b6bb27f04de0d847c57c9bb7b64d2ecfbd
0ecd8ec316e2bdb180325e26ff6bcb857ceea6c9
refs/heads/master
2023-02-19T14:34:38.056169
2021-01-20T15:07:39
2021-01-20T15:07:39
331,340,760
1
0
null
null
null
null
UTF-8
C++
false
false
1,089
h
// Copyright (c) 2011-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef CATRA_QT_UTILITYDIALOG_H #define CATRA_QT_UTILITYDIALOG_H #include <QDialog> #include <QObject> class CatraGUI; namespace interfaces { class Node; } namespace Ui { class HelpMessageDialog; } /** "Help message" dialog box */ class HelpMessageDialog : public QDialog { Q_OBJECT public: explicit HelpMessageDialog(interfaces::Node& node, QWidget *parent, bool about); ~HelpMessageDialog(); void printToConsole(); void showOrPrint(); private: Ui::HelpMessageDialog *ui; QString text; private Q_SLOTS: void on_okButton_accepted(); }; /** "Shutdown" window */ class ShutdownWindow : public QWidget { Q_OBJECT public: explicit ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0); static QWidget *showShutdownWindow(CatraGUI *window); protected: void closeEvent(QCloseEvent *event); }; #endif // CATRA_QT_UTILITYDIALOG_H
[ "77095210+bitcatra@users.noreply.github.com" ]
77095210+bitcatra@users.noreply.github.com
5af329d579b4551371b2d6803f14e8b490885fcf
e867868c78f972149e085b203dc42c120d60c76a
/ProceduralTexture/Plugins/UnrealShadertoy/Source/UnrealShadertoy/Public/ShaderToy.h
eff46ef6875876f1e2f4a07c76af326b07a0887a
[]
no_license
Sanctorum003/Unreal-4-rendering-programming
c95831d369c1150760497a7c019a54943e0edb7a
c431b82fefcc773e20575c56349245742aa2301c
refs/heads/master
2020-12-05T11:10:50.413852
2020-05-03T08:59:55
2020-05-03T08:59:55
232,091,408
0
0
null
null
null
null
UTF-8
C++
false
false
2,935
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "UObject/ObjectMacros.h" #include "MaterialExpressionIO.h" #include "Materials/MaterialExpression.h" #include "Materials/MaterialExpressionCustom.h" #include "ShaderToy.generated.h" USTRUCT() struct FCodeableString { GENERATED_BODY() public: UPROPERTY(EditAnywhere, Category = "CodeableString") FString Code; FCodeableString() = default; FCodeableString(const FString& Code) :Code(Code) {} template < typename CharType, typename = typename TEnableIf<TIsCharType<CharType>::Value>::Type > FORCEINLINE FCodeableString(const CharType* Src) :Code(Src) {} operator FString() const { return Code; } }; USTRUCT() struct FShaderToyHLSLFunction { GENERATED_USTRUCT_BODY() UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "FuncDecs")) FString FunctionName; UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "FuncBody")) FCodeableString FunctionCodes; }; /** * */ UCLASS(collapsecategories, hidecategories = Object, MinimalAPI) class UShaderToy : public UMaterialExpression { GENERATED_UCLASS_BODY() public: UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "NodeName")) FString NodeTitle; UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "DefineBody")) FCodeableString DefineBody; UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "Inputs")) TArray<struct FCustomInput> Inputs; UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "MainFunctionOutput")) TEnumAsByte<enum ECustomMaterialOutputType> OutputType; UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "MainFunction")) FShaderToyHLSLFunction MainFunction; UPROPERTY(EditAnywhere, Category = MaterialExpressionCustom, meta = (DisplayName = "ChildFunctions")) TArray<FShaderToyHLSLFunction> HLSLFunctions; //~ Begin UObject Interface. #if WITH_EDITOR virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override; #endif // WITH_EDITOR virtual void Serialize(FArchive& Ar) override; //~ End UObject Interface. //~ Begin UMaterialExpression Interface #if WITH_EDITOR virtual int32 Compile(class FMaterialCompiler* Compiler, int32 OutputIndex) override; virtual void GetCaption(TArray<FString>& OutCaptions) const override; #endif virtual const TArray<FExpressionInput*> GetInputs() override; virtual FExpressionInput* GetInput(int32 InputIndex) override; virtual FName GetInputName(int32 InputIndex) const override; #if WITH_EDITOR virtual uint32 GetInputType(int32 InputIndex) override { return MCT_Unknown; } virtual uint32 GetOutputType(int32 OutputIndex) override; #endif // WITH_EDITOR //~ End UMaterialExpression Interface };
[ "lushuchengsky@126.com" ]
lushuchengsky@126.com
4ececd4a01f9989ae006c95eaa322436250762bd
a71b63bc220edcc1ee52fb6ee356c14a20e11ac1
/Project/Oscilloscope/Graphic/gui/src/main_screen/MainPresenter.cpp
852ea626dacb0399c7e283c0f77180878b226383
[]
no_license
mmastouri/Oscilloscope
f57a91e88e2642c1c9e724ff47af141fc858139e
2a5c109ab6f9c530f1a2d71ceae3c792570cbd28
refs/heads/master
2023-06-28T18:54:38.918255
2021-08-07T19:58:44
2021-08-07T19:58:44
363,997,981
0
0
null
null
null
null
UTF-8
C++
false
false
21,204
cpp
/************************************************************************************************** * FILE NAME: MainPresenter.cpp * * * * PURPOSE: Provide Function to manipulate the data stored in Model * * * * FILE REFERENCES: * * * * Name I/O Description * * ---- --- ----------- * * * * EXTERNAL VARIABLES: * * Source: < > * * * * Name Type I/O Description * * ---- ---- --- ----------- * * * * EXTERNAL REFERENCES: * * * * Name Description * * ---- ----------- * * * * ABNORMAL TERMINATION CONDITIONS, ERROR AND WARNING MESSAGES: * * * * ASSUMPTIONS, CONSTRAINTS, RESTRICTIONS: * * * * NOTES: * * * * REQUIREMENTS/FUNCTIONAL SPECIFICATIONS REFERENCES: * * * * DEVELOPMENT HISTORY: * * * * Date Author Change Id Release Description Of Change * * ---- ------ --------- ------- --------------------- * * 30.06.2016 Hai Nguyen 01 2.0 Original * * * ***************************************************************************************************/ #include <gui/main_screen/MainPresenter.hpp> #include <gui/main_screen/MainView.hpp> #include <gui/model/Model.hpp> #include <gui\common\main_header.h> #include <gui/common/FrontendApplication.hpp> #ifdef SIMULATOR uint16_t dummy[1000] = { 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0, 4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0 }; uint16_t dummy1[1000] = { 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919, 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919, 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919, 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919, 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919, 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919, 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919, 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919, 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919, 2048, 2177, 2305, 2432, 2557, 2681, 2802, 2920, 3035, 3145, 3252, 3353, 3450, 3541, 3626, 3705, 3777, 3843, 3901, 3952, 3996, 4032, 4060, 4080, 4092, 4096, 4092, 4080, 4060, 4032, 3996, 3952, 3901, 3843, 3777, 3705, 3626, 3541, 3450, 3353, 3252, 3145, 3035, 2920, 2802, 2681, 2557, 2432, 2305, 2177, 2048, 1919, 1791, 1664, 1539, 1415, 1294, 1176, 1061, 951, 844, 743, 646, 555, 470, 391, 319, 253, 195, 144, 100, 64, 36, 16, 4, 0, 4, 16, 36, 64, 100, 144, 195, 253, 319, 391, 470, 555, 646, 743, 844, 951, 1061, 1176, 1294, 1415, 1539, 1664, 1791, 1919}; #endif /*************************************************************************************************** * * * FUNCTION NAME: MainPresenter * * * * ARGUMENTS: * * * * ARGUMENT TYPE I/O DESCRIPTION * * -------- ---- --- ----------- * * * * RETURNS: * * * ***************************************************************************************************/ MainPresenter::MainPresenter(MainView& v) : view(v) { } /*************************************************************************************************** * * * FUNCTION NAME: activate * * * * ARGUMENTS: * * * * ARGUMENT TYPE I/O DESCRIPTION * * -------- ---- --- ----------- * * * * RETURNS: * * * ***************************************************************************************************/ void MainPresenter::activate() { // Set initial value on main screen } /*************************************************************************************************** * * * FUNCTION NAME: deactivate * * * * ARGUMENTS: * * * * ARGUMENT TYPE I/O DESCRIPTION * * -------- ---- --- ----------- * * * * RETURNS: * * * ***************************************************************************************************/ void MainPresenter::deactivate() { } void MainPresenter::p_SetRawData(int channel) { if(channel == CHANNEL_1) { #ifndef SIMULATOR model->SetRawData(channel, PushDaTaToModel_1()); #else model->SetRawData(channel, dummy1); #endif // !1 } else { #ifndef SIMULATOR model->SetRawData(channel, PushDaTaToModel_2()); #else model->SetRawData(channel, dummy); #endif // !1 } model->ConvertToTriggerData(channel); } int * MainPresenter::p_GetTriggerData(int channel) { return model->GetTriggerData(channel); } void MainPresenter::p_SetTriggerData(int channel, int value) { model->SetTriggerValue(channel, value); } void MainPresenter::p_SetYOffset(int channel, int value) { model->SetYOffset(channel, value); } int MainPresenter::p_GetYOffset(int channel) { return model->GetYOffset(channel); } int MainPresenter::p_GetTriggerValue(int channel) { return model->GetTriggerValue(channel); } void MainPresenter::p_SetTriggerValue(int channel, int value) { model->SetTriggerValue(channel, value); } int MainPresenter::p_getSignalPeak(int channel) { return model->getSignalPeak(channel); } int MainPresenter::p_getSignalFreq(int channel) { return model->getSignalFreq(channel); } bool MainPresenter::p_GetTrigger(int channel) { return model->GetTrigger(channel) ; } void MainPresenter::p_SetTrigger(int channel, bool value) { model->SetTrigger(channel, value); } bool MainPresenter::p_GetTriggerType(int channel) { return model->GetTriggerType(channel); } void MainPresenter::p_SetTriggerType(int channel, bool value) { model->SetTriggerType(channel, value); } int MainPresenter::p_GetTimeScale(int channel) { return model->GetTimeScale(channel); } void MainPresenter::p_SetTimeScale(int channel, int value) { model->SetTimeScale(channel, value); } int MainPresenter::p_GetVoltageScale(int channel) { return model->GetVoltageScale(channel); } void MainPresenter::p_SetVoltageScale(int channel, int value) { model->SetVoltageScale(channel, value); } float MainPresenter::p_GetTimeScale2Pixel(int channel) { return model->GetTimeScale2Pixel(channel); } int MainPresenter::p_GetVoltScale2Pixel(int channel) { return model->GetVoltageScale2Pixel(channel); } float MainPresenter::p_VoltagePerPixel(int channel) { float temp_value = 0; switch (model->GetVoltageScale(channel)) { //div 2V case 7: temp_value = 52.63f; break; //div 1V case 6: temp_value = 26.32f; break; //div 500mV case 5: temp_value = 13.16f; break; //div 200mV case 4: temp_value = 5.26f; break; //div 100mV case 3: temp_value = 2.63f; break; //div 50mV case 2: temp_value = 1.32f; break; //div 20mV case 1: temp_value = 0.53f; break; //div 10mV case 0: temp_value = 0.26f; break; } return temp_value; } void MainPresenter::p_SetXOffset(int channel, int value) { model->SetXOffset(channel, value); } int MainPresenter::p_GetXOffset(int channel) { return model->GetXOffset(channel); }
[ "maher.mastouri@gmail.com" ]
maher.mastouri@gmail.com
3b593dc7a3649d128c74422ba38a27315d9c7fab
777a75e6ed0934c193aece9de4421f8d8db01aac
/src/Providers/UNIXProviders/RelatedSpanningTree/UNIX_RelatedSpanningTreeMain.cpp
f18b3de373bedffdf328982a9969110711b5f766
[ "MIT" ]
permissive
brunolauze/openpegasus-providers-old
20fc13958016e35dc4d87f93d1999db0eae9010a
b00f1aad575bae144b8538bf57ba5fd5582a4ec7
refs/heads/master
2021-01-01T20:05:44.559362
2014-04-30T17:50:06
2014-04-30T17:50:06
19,132,738
1
0
null
null
null
null
UTF-8
C++
false
false
2,210
cpp
//%LICENSE//////////////////////////////////////////////////////////////// // // Licensed to The Open Group (TOG) under one or more contributor license // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with // this work for additional information regarding copyright ownership. // Each contributor licenses this file to you under the OpenPegasus Open // Source License; you may not use this file except in compliance with the // License. // // 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 <Pegasus/Common/Config.h> #include <Pegasus/Common/String.h> #include <Pegasus/Common/PegasusVersion.h> PEGASUS_USING_PEGASUS; PEGASUS_USING_STD; #include "UNIX_RelatedSpanningTreeProvider.h" extern "C" PEGASUS_EXPORT CIMProvider* PegasusCreateProvider(const String& providerName) { if (String::equalNoCase(providerName, CIMHelper::EmptyString)) return NULL; else if (String::equalNoCase(providerName, "UNIX_RelatedSpanningTreeProvider")) return new UNIX_RelatedSpanningTreeProvider(); return NULL; }
[ "brunolauze@msn.com" ]
brunolauze@msn.com
de64adfaab1818173563094e70ca6a5341d956fc
3c7f8ddd3d61da88aa3444196bf29e22f3f452a8
/spoj_codes/HS08FOUR.cpp
8bc90a222f8a33d08b5ae130d5c6359e1efb97b5
[]
no_license
rathi062/codes
c836239092fd5e37e00a0c59412c94203e59ef18
ca06002592927e2a01474eec27209f0b78d05de2
refs/heads/master
2021-01-23T02:30:21.455737
2015-08-23T11:21:42
2015-08-23T11:21:42
21,992,864
0
0
null
null
null
null
UTF-8
C++
false
false
3,208
cpp
#include<iostream> #include<vector> #include<algorithm> #include<map> using namespace std; #define PB push_back #define LL long long #define MX 5 using namespace std; #define getcx getchar_unlocked inline void inp( int &n ) { n=0; int ch=getcx();int sign=1; while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} while( ch >= '0' && ch <= '9' ) n = (n<<3)+(n<<1) + ch-'0', ch=getcx(); n=n*sign; } long MOD; bool check[1000000]; LL MT[MX][MX], pM[MX][MX], tmp[MX][MX], pre[10000000][MX][MX]; LL val[MX],fR[MX]; int cnt=0; map<int,int> m; void createMT(){ LL mat[5][5] = { {1,1,0,0,0}, {0,0,1,1,1}, {3,3,0,0,0}, {0,0,2,1,0}, {0,0,1,0,0} }; for(int i=0; i<MX; i++) for(int j=0; j<MX; j++) MT[i][j] = mat[i][j]; } void init(){ val[0]=1; val[1]=val[2]=val[4]=3; val[3]=6; } void getfRMT(){ for(int i=0;i<MX;i++){ LL ans=0; for(int j=0;j<MX;j++){ ans+=pM[i][j]*val[j]; if(ans >= MOD) ans = ans%MOD; } fR[i]=ans; } } LL numberOfWays(){ LL ans = 0; for(int i=0;i<MX;i++){ ans += fR[i]; if(ans >=MOD) ans = ans % MOD; } return ans; } void copy(){ for(int i=0;i<MX;i++){ for(int j=0;j<MX;j++){ pM[i][j]=tmp[i][j]; } } } void square(){ for(int i=0;i<MX;i++){ for(int j=0;j<MX;j++){ LL ans=0; for(int k=0;k<MX;k++){ ans += pM[i][k] * pM[k][j]; if(ans > MOD) ans = ans%MOD; } tmp[i][j]=ans; } } copy(); } void multi(){ for(int i=0;i<MX;i++){ for(int j=0;j<MX;j++){ LL ans=0; for(int k=0;k<MX;k++){ ans += pM[i][k] * MT[k][j]; if(ans > MOD) ans = ans%MOD; } tmp[i][j]=ans; } } copy(); } void rpSq(int n) { if(m.find(n)!=m.end()){ // cout<<"got it "<<n<<endl; int idx = m.find(n)->second; for(int i=0; i<MX; i++) for(int j=0; j<MX; j++) pM[i][j] = pre[idx][i][j]; return; } if(n<1) return; if(n==1){ for(int i=0;i<MX;i++) for(int j=0;j<MX;j++) pM[i][j] = MT[i][j]; return; } rpSq(n/2); square(); if(n%2){ multi(); } if(cnt<1000000){ for(int i=0; i<MX; i++) for(int j=0; j<MX; j++) pre[cnt][i][j] = pM[i][j]; m[n]=cnt++; } } void copyValTofR(){ for(int j=0;j<MX;j++){ fR[j]=val[j]; } } int main(){ int q,k,i,j; inp(q); MOD = 1000000007; for(i=0;i<MX;i++) for(j=0;j<MX;j++) MT[i][j]=0; createMT(); init(); while(q--){ for(i=0;i<MX;i++) for(j=0;j<MX;j++) pM[i][j]=0; inp(k); if(k==0){ cout<<"0"<<endl; continue; } if(k==1){ cout<<"4"<<endl; continue; } rpSq(k-2); if(k>2) getfRMT(); else copyValTofR(); cout<<numberOfWays()<<endl; } }
[ "mohit.rathi@flipkart.com" ]
mohit.rathi@flipkart.com
3a4b778e7e584bdbd90fef490052d0b3b9858700
b939f147cff6f256c9a30b66e8826d7d3f021ea7
/cpp/gpu-offscreen/external/ktx/other_include/assimp/SceneCombiner.h
9b2be795f4a4201b443c4462787f19f4177dfc24
[]
no_license
evopen/gr
6364db7fc4a8bf72ad047fd30c08aba4f73fe6f8
8947b093d0559a5f90de239e9bc5ead2325e3f5c
refs/heads/master
2021-05-26T03:27:07.030549
2020-09-05T01:14:50
2020-09-05T01:14:50
254,032,767
0
0
null
null
null
null
UTF-8
C++
false
false
14,745
h
/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- Copyright (c) 2006-2017, assimp team All rights reserved. Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the assimp team, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of the assimp team. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ /** @file Declares a helper class, "SceneCombiner" providing various * utilities to merge scenes. */ #ifndef AI_SCENE_COMBINER_H_INC #define AI_SCENE_COMBINER_H_INC #include <assimp/ai_assert.h> #include <assimp/types.h> #include <assimp/Defines.h> #include <stddef.h> #include <set> #include <list> #include <stdint.h> #include <vector> struct aiScene; struct aiNode; struct aiMaterial; struct aiTexture; struct aiCamera; struct aiLight; struct aiMetadata; struct aiBone; struct aiMesh; struct aiAnimation; struct aiNodeAnim; namespace Assimp { // --------------------------------------------------------------------------- /** \brief Helper data structure for SceneCombiner. * * Describes to which node a scene must be attached to. */ struct AttachmentInfo { AttachmentInfo() : scene (NULL) , attachToNode (NULL) {} AttachmentInfo(aiScene* _scene, aiNode* _attachToNode) : scene (_scene) , attachToNode (_attachToNode) {} aiScene* scene; aiNode* attachToNode; }; // --------------------------------------------------------------------------- struct NodeAttachmentInfo { NodeAttachmentInfo() : node (NULL) , attachToNode (NULL) , resolved (false) , src_idx (SIZE_MAX) {} NodeAttachmentInfo(aiNode* _scene, aiNode* _attachToNode,size_t idx) : node (_scene) , attachToNode (_attachToNode) , resolved (false) , src_idx (idx) {} aiNode* node; aiNode* attachToNode; bool resolved; size_t src_idx; }; // --------------------------------------------------------------------------- /** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES * Generate unique names for all named scene items */ #define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES 0x1 /** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES * Generate unique names for materials, too. * This is not absolutely required to pass the validation. */ #define AI_INT_MERGE_SCENE_GEN_UNIQUE_MATNAMES 0x2 /** @def AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY * Use deep copies of duplicate scenes */ #define AI_INT_MERGE_SCENE_DUPLICATES_DEEP_CPY 0x4 /** @def AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS * If attachment nodes are not found in the given master scene, * search the other imported scenes for them in an any order. */ #define AI_INT_MERGE_SCENE_RESOLVE_CROSS_ATTACHMENTS 0x8 /** @def AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY * Can be combined with AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES. * Unique names are generated, but only if this is absolutely * required to avoid name conflicts. */ #define AI_INT_MERGE_SCENE_GEN_UNIQUE_NAMES_IF_NECESSARY 0x10 typedef std::pair<aiBone*,unsigned int> BoneSrcIndex; // --------------------------------------------------------------------------- /** @brief Helper data structure for SceneCombiner::MergeBones. */ struct BoneWithHash : public std::pair<uint32_t,aiString*> { std::vector<BoneSrcIndex> pSrcBones; }; // --------------------------------------------------------------------------- /** @brief Utility for SceneCombiner */ struct SceneHelper { SceneHelper () : scene (NULL) , idlen (0) { id[0] = 0; } explicit SceneHelper (aiScene* _scene) : scene (_scene) , idlen (0) { id[0] = 0; } AI_FORCE_INLINE aiScene* operator-> () const { return scene; } // scene we're working on aiScene* scene; // prefix to be added to all identifiers in the scene ... char id [32]; // and its strlen() unsigned int idlen; // hash table to quickly check whether a name is contained in the scene std::set<unsigned int> hashes; }; // --------------------------------------------------------------------------- /** \brief Static helper class providing various utilities to merge two * scenes. It is intended as internal utility and NOT for use by * applications. * * The class is currently being used by various postprocessing steps * and loaders (ie. LWS). */ class ASSIMP_API SceneCombiner { // class cannot be instanced SceneCombiner() {} public: // ------------------------------------------------------------------- /** Merges two or more scenes. * * @param dest Receives a pointer to the destination scene. If the * pointer doesn't point to NULL when the function is called, the * existing scene is cleared and refilled. * @param src Non-empty list of scenes to be merged. The function * deletes the input scenes afterwards. There may be duplicate scenes. * @param flags Combination of the AI_INT_MERGE_SCENE flags defined above */ static void MergeScenes(aiScene** dest,std::vector<aiScene*>& src, unsigned int flags = 0); // ------------------------------------------------------------------- /** Merges two or more scenes and attaches all scenes to a specific * position in the node graph of the master scene. * * @param dest Receives a pointer to the destination scene. If the * pointer doesn't point to NULL when the function is called, the * existing scene is cleared and refilled. * @param master Master scene. It will be deleted afterwards. All * other scenes will be inserted in its node graph. * @param src Non-empty list of scenes to be merged along with their * corresponding attachment points in the master scene. The function * deletes the input scenes afterwards. There may be duplicate scenes. * @param flags Combination of the AI_INT_MERGE_SCENE flags defined above */ static void MergeScenes(aiScene** dest, aiScene* master, std::vector<AttachmentInfo>& src, unsigned int flags = 0); // ------------------------------------------------------------------- /** Merges two or more meshes * * The meshes should have equal vertex formats. Only components * that are provided by ALL meshes will be present in the output mesh. * An exception is made for VColors - they are set to black. The * meshes should have the same material indices, too. The output * material index is always the material index of the first mesh. * * @param dest Destination mesh. Must be empty. * @param flags Currently no parameters * @param begin First mesh to be processed * @param end Points to the mesh after the last mesh to be processed */ static void MergeMeshes(aiMesh** dest,unsigned int flags, std::vector<aiMesh*>::const_iterator begin, std::vector<aiMesh*>::const_iterator end); // ------------------------------------------------------------------- /** Merges two or more bones * * @param out Mesh to receive the output bone list * @param flags Currently no parameters * @param begin First mesh to be processed * @param end Points to the mesh after the last mesh to be processed */ static void MergeBones(aiMesh* out,std::vector<aiMesh*>::const_iterator it, std::vector<aiMesh*>::const_iterator end); // ------------------------------------------------------------------- /** Merges two or more materials * * The materials should be complementary as much as possible. In case * of a property present in different materials, the first occurrence * is used. * * @param dest Destination material. Must be empty. * @param begin First material to be processed * @param end Points to the material after the last material to be processed */ static void MergeMaterials(aiMaterial** dest, std::vector<aiMaterial*>::const_iterator begin, std::vector<aiMaterial*>::const_iterator end); // ------------------------------------------------------------------- /** Builds a list of uniquely named bones in a mesh list * * @param asBones Receives the output list * @param it First mesh to be processed * @param end Last mesh to be processed */ static void BuildUniqueBoneList(std::list<BoneWithHash>& asBones, std::vector<aiMesh*>::const_iterator it, std::vector<aiMesh*>::const_iterator end); // ------------------------------------------------------------------- /** Add a name prefix to all nodes in a scene. * * @param Current node. This function is called recursively. * @param prefix Prefix to be added to all nodes * @param len STring length */ static void AddNodePrefixes(aiNode* node, const char* prefix, unsigned int len); // ------------------------------------------------------------------- /** Add an offset to all mesh indices in a node graph * * @param Current node. This function is called recursively. * @param offset Offset to be added to all mesh indices */ static void OffsetNodeMeshIndices (aiNode* node, unsigned int offset); // ------------------------------------------------------------------- /** Attach a list of node graphs to well-defined nodes in a master * graph. This is a helper for MergeScenes() * * @param master Master scene * @param srcList List of source scenes along with their attachment * points. If an attachment point is NULL (or does not exist in * the master graph), a scene is attached to the root of the master * graph (as an additional child node) * @duplicates List of duplicates. If elem[n] == n the scene is not * a duplicate. Otherwise elem[n] links scene n to its first occurrence. */ static void AttachToGraph ( aiScene* master, std::vector<NodeAttachmentInfo>& srcList); static void AttachToGraph (aiNode* attach, std::vector<NodeAttachmentInfo>& srcList); // ------------------------------------------------------------------- /** Get a deep copy of a scene * * @param dest Receives a pointer to the destination scene * @param src Source scene - remains unmodified. */ static void CopyScene(aiScene** dest,const aiScene* source,bool allocate = true); // ------------------------------------------------------------------- /** Get a flat copy of a scene * * Only the first hierarchy layer is copied. All pointer members of * aiScene are shared by source and destination scene. If the * pointer doesn't point to NULL when the function is called, the * existing scene is cleared and refilled. * @param dest Receives a pointer to the destination scene * @param src Source scene - remains unmodified. */ static void CopySceneFlat(aiScene** dest,const aiScene* source); // ------------------------------------------------------------------- /** Get a deep copy of a mesh * * @param dest Receives a pointer to the destination mesh * @param src Source mesh - remains unmodified. */ static void Copy (aiMesh** dest, const aiMesh* src); // similar to Copy(): static void Copy (aiMaterial** dest, const aiMaterial* src); static void Copy (aiTexture** dest, const aiTexture* src); static void Copy (aiAnimation** dest, const aiAnimation* src); static void Copy (aiCamera** dest, const aiCamera* src); static void Copy (aiBone** dest, const aiBone* src); static void Copy (aiLight** dest, const aiLight* src); static void Copy (aiNodeAnim** dest, const aiNodeAnim* src); static void Copy (aiMetadata** dest, const aiMetadata* src); // recursive, of course static void Copy (aiNode** dest, const aiNode* src); private: // ------------------------------------------------------------------- // Same as AddNodePrefixes, but with an additional check static void AddNodePrefixesChecked(aiNode* node, const char* prefix, unsigned int len, std::vector<SceneHelper>& input, unsigned int cur); // ------------------------------------------------------------------- // Add node identifiers to a hashing set static void AddNodeHashes(aiNode* node, std::set<unsigned int>& hashes); // ------------------------------------------------------------------- // Search for duplicate names static bool FindNameMatch(const aiString& name, std::vector<SceneHelper>& input, unsigned int cur); }; } #endif // !! AI_SCENE_COMBINER_H_INC
[ "520dhh@gmail.com" ]
520dhh@gmail.com
be0d4c97fb7cb4c3e7d980198886df5341d2929e
8c8820fb84dea70d31c1e31dd57d295bd08dd644
/NavigationSystem/Public/NavFilters/RecastFilter_UseDefaultArea.h
8a932836c655046fb8bb6cace151f0cc6145cee0
[]
no_license
redisread/UE-Runtime
e1a56df95a4591e12c0fd0e884ac6e54f69d0a57
48b9e72b1ad04458039c6ddeb7578e4fc68a7bac
refs/heads/master
2022-11-15T08:30:24.570998
2020-06-20T06:37:55
2020-06-20T06:37:55
274,085,558
3
0
null
null
null
null
UTF-8
C++
false
false
576
h
// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "UObject/ObjectMacros.h" #include "NavFilters/NavigationQueryFilter.h" #include "RecastFilter_UseDefaultArea.generated.h" class ANavigationData; /** Regular navigation area, applied to entire navigation data by default */ UCLASS(MinimalAPI) class URecastFilter_UseDefaultArea : public UNavigationQueryFilter { GENERATED_UCLASS_BODY() virtual void InitializeFilter(const ANavigationData& NavData, const UObject* Querier, FNavigationQueryFilter& Filter) const override; };
[ "wujiahong19981022@outlook.com" ]
wujiahong19981022@outlook.com
c9291bf7db4dea818f453bf630e787dc45ae7235
f46514f494f27d071f812bc0f36dd37a2c2073d1
/PerlinNoise.cpp
7a6835a1a66d26f527e4a90f591dd3af7e78e54e
[]
no_license
Game-Architecture/final-repository-AnthonyVeschi
3bec2dce9e6b902de1a2f2df5dc369803abc414f
e2aaf6cba6d798df5de87b6432be1fc0762d9c98
refs/heads/main
2023-04-18T15:03:10.672014
2021-05-03T15:48:39
2021-05-03T15:48:39
361,569,047
0
0
null
null
null
null
UTF-8
C++
false
false
6,897
cpp
#include "PerlinNoise.h" #include "entity/ga_entity.h" #include "../graphics/ga_material.h" #define GLEW_STATIC #include <GL/glew.h> #include <cstdio> #include <iostream> #include <iomanip> #include <cmath> #include <cstdlib> PerlinNoise::PerlinNoise(ga_entity* ent, const char* texture_file) : ga_component(ent) { _material = new ga_unlit_texture_material(texture_file); _material->init(); int numOctaves = 9; float persistence = 0.2; float amplitude = 6; float seaLevel = 2.5; float perlinNoiseArray[128][128]; float max = -1; float min = 999; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { perlinNoiseArray[i][j] = PerlinNoise_2D(i, j, persistence, numOctaves, false); if (perlinNoiseArray[i][j] > max) { max = perlinNoiseArray[i][j]; } if (perlinNoiseArray[i][j] < min) { min = perlinNoiseArray[i][j]; } } } for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { perlinNoiseArray[i][j] += std::abs(min); perlinNoiseArray[i][j] /= (std::abs(min) + max); perlinNoiseArray[i][j] *= amplitude; if (perlinNoiseArray[i][j] < seaLevel) { perlinNoiseArray[i][j] = seaLevel; } //std::cout << perlinNoiseArray[i][j] << " "; } //std::cout << std::endl; } GLfloat vertices[128*128*3]; GLushort indices[127*127*4 + 127*2 + 127*2]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { vertices[i*128*3 + j*3 + 0] = (float)j; vertices[i*128*3 + j*3 + 1] = perlinNoiseArray[j][i]; vertices[i*128*3 + j*3 + 2] = (float)i; } } int indicesIndex = 0; for (int i = 0; i < 127; i++) { for (int j = 0; j < 127; j++) { indices[indicesIndex] = (unsigned short)i*128 + j; indicesIndex++; indices[indicesIndex] = (unsigned short)i*128 + j + 1; indicesIndex++; indices[indicesIndex] = (unsigned short)i*128 + j; indicesIndex++; indices[indicesIndex] = (unsigned short)i*128 + j + 128; indicesIndex++; } } for (int i = 127; i < 128; i++) { for (int j = 0; j < 127; j++) { indices[indicesIndex] = (unsigned short)i*128 + j; indicesIndex++; indices[indicesIndex] = (unsigned short)i*128 + j + 1; indicesIndex++; } } for (int i = 0; i < 127; i++) { for (int j = 127; j < 128; j++) { indices[indicesIndex] = (unsigned short)i*128 + j; indicesIndex++; indices[indicesIndex] = (unsigned short)i*128 + j + 128; indicesIndex++; } } /*static GLfloat vertices[] = { 0.0, perlinNoiseArray[0][0], 0.0, 1.0, perlinNoiseArray[1][0], 0.0, 2.0, perlinNoiseArray[2][0], 0.0, 3.0, perlinNoiseArray[3][0], 0.0, 0.0, perlinNoiseArray[0][1], 1.0, 1.0, perlinNoiseArray[1][1], 1.0, 2.0, perlinNoiseArray[2][1], 1.0, 3.0, perlinNoiseArray[3][1], 1.0, 0.0, perlinNoiseArray[0][2], 2.0, 1.0, perlinNoiseArray[1][2], 2.0, 2.0, perlinNoiseArray[2][2], 2.0, 3.0, perlinNoiseArray[3][2], 2.0, 0.0, perlinNoiseArray[0][3], 3.0, 1.0, perlinNoiseArray[1][3], 3.0, 2.0, perlinNoiseArray[2][3], 3.0, 3.0, perlinNoiseArray[3][3], 3.0 }; static GLushort indices[] = { 0, 1, 0, 4, 1, 2, 1, 5, 2, 3, 2, 6, 3, 7, 4, 5, 4, 8, 5, 6, 5, 9, 6, 7, 6, 10, 7, 11, 8, 9, 8, 12, 9, 10, 9, 13, 10, 11, 10, 14, 11, 15, 12, 13, 13, 14, 14, 15 };*/ _index_count = uint32_t(sizeof(indices) / sizeof(*indices)); glGenVertexArrays(1, &_vao); glBindVertexArray(_vao); glGenBuffers(2, _vbos); glBindBuffer(GL_ARRAY_BUFFER, _vbos[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vbos[1]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); glBindVertexArray(0); } PerlinNoise::~PerlinNoise() { glDeleteBuffers(2, _vbos); glDeleteVertexArrays(1, &_vao); delete _material; } void PerlinNoise::update(ga_frame_params* params) { /*float dt = std::chrono::duration_cast<std::chrono::duration<float>>(params->_delta_time).count(); ga_quatf axis_angle; axis_angle.make_axis_angle(ga_vec3f::y_vector(), ga_degrees_to_radians(60.0f) * dt); get_entity()->rotate(axis_angle);*/ ga_static_drawcall draw; draw._name = "PerlinNoise"; draw._vao = _vao; draw._index_count = _index_count; draw._transform = get_entity()->get_transform(); draw._draw_mode = GL_LINES; draw._material = _material; while (params->_static_drawcall_lock.test_and_set(std::memory_order_acquire)) {} params->_static_drawcalls.push_back(draw); params->_static_drawcall_lock.clear(std::memory_order_release); } float PerlinNoise::Noise(int x, int y, int p) { int n = x + y * 57; n = (n << 13) ^ n; return (float)(1.0 - ((n * (n * n * primes[p][0] + primes[p][1]) + primes[p][2]) & 0x7fffffff) / 1073741824.0); } float PerlinNoise::SmoothNoise(float x, float y, int p) { float corners = (Noise(x - 1, y - 1, p) + Noise(x + 1, y - 1, p) + Noise(x - 1, y + 1, p) + Noise(x + 1, y + 1, p)) / 16; float sides = (Noise(x - 1, y, p) + Noise(x + 1, y, p) + Noise(x, y - 1, p) + Noise(x, y + 1, p)) / 8; float center = Noise(x, y, p) / 4; return corners + sides + center; } float PerlinNoise::LinearInterpolation(float x, float y, float t) { return x * (1 - t) + y * t; } float PerlinNoise::CosineInterpolation(float x, float y, float t) { float ft = t * 3.1415927; float f = (1 - cos(ft)) * 0.5; return x * (1 - f) + y * f; } float PerlinNoise::InterpolatedNoise(float x, float y, int p, bool linear) { int integer_X = int(x); float fractional_X = x - integer_X; int integer_Y = int(y); float fractional_Y = y - integer_Y; float v1 = SmoothNoise(integer_X, integer_Y, p); float v2 = SmoothNoise(integer_X + 1, integer_Y, p); float v3 = SmoothNoise(integer_X, integer_Y + 1, p); float v4 = SmoothNoise(integer_X + 1, integer_Y + 1, p); if (linear) { float i1 = LinearInterpolation(v1, v2, fractional_X); float i2 = LinearInterpolation(v3, v4, fractional_X); return LinearInterpolation(i1, i2, fractional_Y); } else { float i1 = CosineInterpolation(v1, v2, fractional_X); float i2 = CosineInterpolation(v3, v4, fractional_X); return CosineInterpolation(i1, i2, fractional_Y); } } float PerlinNoise::PerlinNoise_2D(float x, float y, float persistence, int numOctaves, bool linear) { float total = 0; for (int i = 0; i < numOctaves; i++) { float frequency = pow(2, i); float amplitude = pow(persistence, i); total += (InterpolatedNoise(x * frequency, y * frequency, 1, linear) * amplitude); //std::cout << "(" << x << "," << y << "): " << total; } //std::cout << std::endl; return total; /*float total = 0; float frequency = pow(2, numOctaves); float amplitude = 1; for (int i = 0; i < numOctaves; ++i) { frequency /= 2; amplitude *= persistence; total += InterpolatedNoise(x / frequency, y / frequency, i%9, linear) * amplitude; } return total / frequency;*/ }
[ "noreply@github.com" ]
Game-Architecture.noreply@github.com
02c289a9eaa755b29b5514ba73c23135bbe30739
d6b4bdf418ae6ab89b721a79f198de812311c783
/privatedns/include/tencentcloud/privatedns/v20201028/model/DescribeRequestDataResponse.h
91007f4f2b9ceac492242360920a6611b49d42ce
[ "Apache-2.0" ]
permissive
TencentCloud/tencentcloud-sdk-cpp-intl-en
d0781d461e84eb81775c2145bacae13084561c15
d403a6b1cf3456322bbdfb462b63e77b1e71f3dc
refs/heads/master
2023-08-21T12:29:54.125071
2023-08-21T01:12:39
2023-08-21T01:12:39
277,769,407
2
0
null
null
null
null
UTF-8
C++
false
false
3,172
h
/* * 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. */ #ifndef TENCENTCLOUD_PRIVATEDNS_V20201028_MODEL_DESCRIBEREQUESTDATARESPONSE_H_ #define TENCENTCLOUD_PRIVATEDNS_V20201028_MODEL_DESCRIBEREQUESTDATARESPONSE_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/AbstractModel.h> #include <tencentcloud/privatedns/v20201028/model/MetricData.h> namespace TencentCloud { namespace Privatedns { namespace V20201028 { namespace Model { /** * DescribeRequestData response structure. */ class DescribeRequestDataResponse : public AbstractModel { public: DescribeRequestDataResponse(); ~DescribeRequestDataResponse() = default; CoreInternalOutcome Deserialize(const std::string &payload); std::string ToJsonString() const; /** * 获取Request volume statistics table * @return Data Request volume statistics table * */ std::vector<MetricData> GetData() const; /** * 判断参数 Data 是否已赋值 * @return Data 是否已赋值 * */ bool DataHasBeenSet() const; /** * 获取Request volume unit time. Valid values: Day, Hour * @return Interval Request volume unit time. Valid values: Day, Hour * */ std::string GetInterval() const; /** * 判断参数 Interval 是否已赋值 * @return Interval 是否已赋值 * */ bool IntervalHasBeenSet() const; private: /** * Request volume statistics table */ std::vector<MetricData> m_data; bool m_dataHasBeenSet; /** * Request volume unit time. Valid values: Day, Hour */ std::string m_interval; bool m_intervalHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_PRIVATEDNS_V20201028_MODEL_DESCRIBEREQUESTDATARESPONSE_H_
[ "tencentcloudapi@tencent.com" ]
tencentcloudapi@tencent.com
72788706d6a971cb334a0023bf1d7657cb829a0e
0688ed4fbbbd19613cc453c568af75ba59ae5144
/libraries/mojingsdk/src/main/cpp/googlebreakpad/src/third_party/protobuf/protobuf/src/google/protobuf/compiler/zip_writer.h
8e245161562b382e4a2c8b30c3e4048596bf183f
[ "LicenseRef-scancode-protobuf" ]
permissive
playbar/testplayer
49c068e53a5b93768b4d46f4f9b8d2bb739ff7fe
b4869ed9193739ab48c067cd51b4f5084943e924
refs/heads/master
2021-05-07T03:37:09.438661
2017-11-20T03:38:59
2017-11-20T03:38:59
110,958,488
3
0
null
null
null
null
UTF-8
C++
false
false
3,949
h
// Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // http://code.google.com/p/protobuf/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // http://code.google.com/p/protobuf/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Author: kenton@google.com (Kenton Varda) #include <vector> #include <google/protobuf/stubs/common.h> #include <google/protobuf/io/zero_copy_stream.h> namespace google { namespace protobuf { namespace compiler { class ZipWriter { public: ZipWriter(io::ZeroCopyOutputStream* raw_output); ~ZipWriter(); bool Write(const string& filename, const string& contents); bool WriteDirectory(); private: struct FileInfo { string name; uint32 offset; uint32 size; uint32 crc32; }; io::ZeroCopyOutputStream* raw_output_; vector<FileInfo> files_; }; } // namespace compiler } // namespace protobuf } // namespace google
[ "hgl868@126.com" ]
hgl868@126.com
73242a81f3729b2b974e82b196c1f7c3f7ab170a
338f16b907cdca5d99f6fc4ee978b3dede217615
/include/mesos/authentication/http/authenticatee.hpp
00676febe6d90b728d0721a6cca4e4fd9be083ee
[ "Apache-2.0", "GPL-2.0-or-later", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-protobuf", "LGPL-2.1-only", "PSF-2.0", "BSL-1.0", "MIT", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
apache/mesos
24c92eb34ea9cbb2912d6471815a433c9942e0c9
8856d6fba11281df898fd65b0cafa1e20eb90fe8
refs/heads/master
2023-08-28T06:36:36.458732
2023-01-13T21:00:06
2023-01-14T00:29:23
11,469,439
4,860
2,034
Apache-2.0
2023-04-12T06:10:25
2013-07-17T07:00:13
C++
UTF-8
C++
false
false
2,503
hpp
// 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. #ifndef __MESOS_AUTHENTICATION_HTTP_AUTHENTICATEE_HPP__ #define __MESOS_AUTHENTICATION_HTTP_AUTHENTICATEE_HPP__ #include <mesos/v1/mesos.hpp> #include <process/future.hpp> #include <process/http.hpp> #include <stout/option.hpp> namespace mesos { namespace http { namespace authentication { /** * An abstraction enabling any HTTP API consumer to authenticate. */ class Authenticatee { public: virtual ~Authenticatee() = default; /** * Reset the authenticatee to its initial state. * * Allows the implementation to invalidate possibly cached state. * This is useful if for example token-based authentication is * performed and the authenticator signaled an expired token. */ virtual void reset() {}; /** * Name of the authentication scheme implemented. * * @return Authentication scheme. */ virtual std::string scheme() const = 0; /** * Create an HTTP request for authentication. * * Used for mutating a provided `Request` with any means of * authentication-related headers or other additions and changes. * * @param request The HTTP payload intended to be sent to an * authenticated endpoint. * @param credential The principal and secret optionally used to * create the authentication request. * @return The mutated HTTP request object containing all information * needed for authenticating. */ virtual process::Future<process::http::Request> authenticate( const process::http::Request& request, const Option<mesos::v1::Credential>& credential) = 0; }; } // namespace authentication { } // namespace http { } // namespace mesos { #endif // __MESOS_AUTHENTICATION_HTTP_AUTHENTICATEE_HPP__
[ "toenshoff@me.com" ]
toenshoff@me.com
8032e9b66585044096fb5bd01837bf6fe0cb813c
13a32b92b1ba8ffb07e810dcc8ccdf1b8b1671ab
/home--tommy--mypy/mypy/lib/python2.7/site-packages/pystan/stan/lib/stan_math/test/unit/math/prim/mat/prob/agrad_distributions_multi_student_t.hpp
1f46e7157bf083f5375502b58553cae21587e5e2
[ "Unlicense", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
tommybutler/mlearnpy2
8ec52bcd03208c9771d8d02ede8eaa91a95bda30
9e5d377d0242ac5eb1e82a357e6701095a8ca1ff
refs/heads/master
2022-10-24T23:30:18.705329
2022-10-17T15:41:37
2022-10-17T15:41:37
118,529,175
0
2
Unlicense
2022-10-15T23:32:18
2018-01-22T23:27:10
Python
UTF-8
C++
false
false
826
hpp
class agrad_distributions_multi_student_t : public ::testing::Test { protected: virtual void SetUp() { nu = 5; y.resize(3,1); y << 2.0, -2.0, 11.0; y2.resize(3,1); y2 << 15.0, 1.0, -5.0; mu.resize(3,1); mu << 1.0, -1.0, 3.0; mu2.resize(3,1); mu2 << 6.0, 2.0, -6.0; Sigma.resize(3,3); Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; Sigma2.resize(3,3); Sigma2 << 3.0, 1.0, 0.0, 1.0, 5.0, -2.0, 0.0, -2.0, 9.0; } double nu; Eigen::Matrix<double,Eigen::Dynamic,1> y; Eigen::Matrix<double,Eigen::Dynamic,1> y2; Eigen::Matrix<double,Eigen::Dynamic,1> mu; Eigen::Matrix<double,Eigen::Dynamic,1> mu2; Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> Sigma; Eigen::Matrix<double,Eigen::Dynamic,Eigen::Dynamic> Sigma2; };
[ "tbutler.github@internetalias.net" ]
tbutler.github@internetalias.net
6410964114ae42f5967ad2af999ff965082b0ba1
d3a4f1389f5cdd64cb61ea76d63fe4b051843e6f
/ch8/Ex_8_11.cpp
f3ce9cef73ae64c1a4c53268909f8bfacfe9c9f6
[]
no_license
SeA-xiAoD/Cpp_Primer_Homework
3562f61b8518ab51f36a9d202c0c0dffd8b088ec
dfa13331fb44062ea967d176270731b5a921afca
refs/heads/master
2021-04-06T01:36:15.725887
2018-06-04T13:29:34
2018-06-04T13:29:34
124,748,094
1
0
null
null
null
null
UTF-8
C++
false
false
493
cpp
#include <iostream> #include <sstream> #include <vector> #include <string> using namespace std; struct PersonInfo{ string name; vector<string> phones; }; int main() { string line, word; vector<PersonInfo> people; istringstream record; while(getline(cin, line)) { PersonInfo info; record.clear(); record.str(line); while(record >> word) info.phones.push_back(word); people.push_back(info); } return 0; }
[ "1002811562@qq.com" ]
1002811562@qq.com
71164fba1488d26943bdfb331b8fb5766739afc9
87508c6edf6bbfcded3c2dcf17c1c8512fc5b17c
/shifr/des.h
a7e18f6ed751477df58d4d3858025d40ea478f5d
[]
no_license
Yashin20PI1/TIMP_PR_4
845fcbec714a92bed7669b67ca7689902dec1a43
8a221d284b6b9f49ede1f8395fd554cf00ef80f2
refs/heads/master
2023-05-27T21:51:16.443581
2021-05-29T20:00:10
2021-05-29T20:00:10
370,821,278
0
0
null
null
null
null
UTF-8
C++
false
false
743
h
#pragma once #include <cryptopp/cryptlib.h> #include <cryptopp/files.h> #include <cryptopp/sha.h> #include <cryptopp/des.h> #include <cryptopp/pwdbased.h> #include <cryptopp/filters.h> #include <cryptopp/osrng.h> #include "cryptopp/modes.h" #include <iostream> #include <string> #include <fstream> using namespace std; using namespace CryptoPP; class DES_CLASS { private: string in; string out; string IV; string psw; string salt = "saltandsugarforourdearprepodfgfgfgfgfgfggf"; public: DES_CLASS() = delete; DES_CLASS(const string& in, const string& out, const string& pass); DES_CLASS(const string& in, const string& out, const string& pass, const string & iv); void enDES (DES_CLASS enc); void decDES (DES_CLASS dec); };
[ "Yashin20PI1" ]
Yashin20PI1
900435c7292f2dd5f43f3931d2859227abcb29cd
7cfdb0b1bd04783d985eaf063812aea97da922cc
/hdu/2015.cpp
fecea192edc701ac91c41ba9795d09dd562fc641
[ "MIT" ]
permissive
bashell/oj
dcf0eb00825dabdbd71ea701eb121d9e25faa102
9471e32d735168148390d42029998187e0e04e2b
refs/heads/master
2021-01-11T03:25:23.989568
2018-10-30T14:27:37
2018-10-30T14:27:37
71,035,293
0
0
null
null
null
null
UTF-8
C++
false
false
816
cpp
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 111; int arr[maxn]; int n, m; void init(int n) { memset(arr, 0, sizeof(arr)); for(int i = 0; i < n; ++i) arr[i] = 2+2*i; } void solve(int n, int m) { if(m >= n) { printf("%d\n", accumulate(arr, arr+n, 0)/n); } else { printf("%d", accumulate(arr, arr+m, 0)/m); for(int i = m; i < n; ) { if(i+m <= n) printf(" %d", accumulate(arr+i, arr+i+m, 0)/m); else printf(" %d", accumulate(arr+i, arr+n, 0)/(n-i)); i += m; } printf("\n"); } } int main() { //freopen("in.txt", "r", stdin); while(2 == scanf("%d%d", &n, &m)) { init(n); solve(n, m); } return 0; }
[ "nju.liuc@gmail.com" ]
nju.liuc@gmail.com
39bbd6702a3295914227c31be7f4a9c647482be3
641f6bdac7d6969dbd302211e48ac0e224584bd3
/arduino/old/arduino_qianyun/other/testScripts/limitSwitchTest/limitSwitchTest.ino
7b5237779c191370fa42ce54c1ecda68515665bf
[]
no_license
richard-warren/obstacleRig
5fb0d03081863ae6fc977ca434c2b36eb58fba49
4f351aa9bde83cbb0b94c65b02be652ea29dcccd
refs/heads/master
2022-12-07T10:55:59.325000
2020-07-07T16:09:59
2020-07-07T16:09:59
101,103,191
0
0
null
null
null
null
UTF-8
C++
false
false
406
ino
const int startLimitPin = 9; // signal is LOW when engaged const int stopLimitPin = 10; // signal is LOW when engaged void setup() { pinMode(startLimitPin, INPUT_PULLUP); pinMode(stopLimitPin, INPUT_PULLUP); Serial.begin(115200); } void loop() { Serial.print(" start: "); Serial.print(digitalRead(startLimitPin)); Serial.print(" stop: "); Serial.println(digitalRead(stopLimitPin)); }
[ "richardwarren2163@gmail.com" ]
richardwarren2163@gmail.com
81beca2cbb06bf73f41693cfd3033b46d1c3b220
48e4c9712b38a90b819c84db064422e1088c4565
/toolchains/motoezx/qt/include/qt-2.3.8/qgdict.h
93db6a205af015ab5c1fbd8e5d371eadce332492
[]
no_license
blchinezu/EZX-SDK_CPP-QT-SDL
8e4605ed5940805f49d76e7700f19023dea9e36b
cbb01e0f1dd03bdf8b071f503c4e3e43b2e6ac33
refs/heads/master
2020-06-05T15:25:21.527826
2020-05-15T11:11:13
2020-05-15T11:11:13
39,446,244
0
1
null
null
null
null
UTF-8
C++
false
false
6,548
h
/**************************************************************************** ** $Id: qt/src/tools/qgdict.h 2.3.8 edited 2004-08-05 $ ** ** Definition of QGDict and QGDictIterator classes ** ** Created : 920529 ** ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. ** ** This file is part of the tools module of the Qt GUI Toolkit. ** ** This file may be distributed under the terms of the Q Public License ** as defined by Trolltech AS of Norway and appearing in the file ** LICENSE.QPL included in the packaging of this file. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition ** licenses may use this file in accordance with the Qt Commercial License ** Agreement provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for ** information about Qt Commercial License Agreements. ** See http://www.trolltech.com/qpl/ for QPL licensing information. ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef QGDICT_H #define QGDICT_H #ifndef QT_H #include "qcollection.h" #include "qstring.h" #endif // QT_H class QGDictIterator; class QGDItList; class QBaseBucket // internal dict node { public: QCollection::Item getData() { return data; } QCollection::Item setData( QCollection::Item d ) { return data = d; } QBaseBucket *getNext() { return next; } void setNext( QBaseBucket *n) { next = n; } protected: QBaseBucket( QCollection::Item d, QBaseBucket *n ) : data(d), next(n) {} QCollection::Item data; QBaseBucket *next; }; class QStringBucket : public QBaseBucket { public: QStringBucket( const QString &k, QCollection::Item d, QBaseBucket *n ) : QBaseBucket(d,n), key(k) {} const QString &getKey() const { return key; } private: QString key; }; class QAsciiBucket : public QBaseBucket { public: QAsciiBucket( const char *k, QCollection::Item d, QBaseBucket *n ) : QBaseBucket(d,n), key(k) {} const char *getKey() const { return key; } private: const char *key; }; class QIntBucket : public QBaseBucket { public: QIntBucket( long k, QCollection::Item d, QBaseBucket *n ) : QBaseBucket(d,n), key(k) {} long getKey() const { return key; } private: long key; }; class QPtrBucket : public QBaseBucket { public: QPtrBucket( void *k, QCollection::Item d, QBaseBucket *n ) : QBaseBucket(d,n), key(k) {} void *getKey() const { return key; } private: void *key; }; class Q_EXPORT QGDict : public QCollection // generic dictionary class { public: uint count() const { return numItems; } uint size() const { return vlen; } QCollection::Item look_string( const QString& key, QCollection::Item, int ); QCollection::Item look_ascii( const char *key, QCollection::Item, int ); QCollection::Item look_int( long key, QCollection::Item, int ); QCollection::Item look_ptr( void *key, QCollection::Item, int ); #ifndef QT_NO_DATASTREAM QDataStream &read( QDataStream & ); QDataStream &write( QDataStream & ) const; #endif protected: enum KeyType { StringKey, AsciiKey, IntKey, PtrKey }; QGDict( uint len, KeyType kt, bool cs, bool ck ); QGDict( const QGDict & ); ~QGDict(); QGDict &operator=( const QGDict & ); bool remove_string( const QString &key, QCollection::Item item=0 ); bool remove_ascii( const char *key, QCollection::Item item=0 ); bool remove_int( long key, QCollection::Item item=0 ); bool remove_ptr( void *key, QCollection::Item item=0 ); QCollection::Item take_string( const QString &key ); QCollection::Item take_ascii( const char *key ); QCollection::Item take_int( long key ); QCollection::Item take_ptr( void *key ); void clear(); void resize( uint ); int hashKeyString( const QString & ); int hashKeyAscii( const char * ); void statistics() const; #ifndef QT_NO_DATASTREAM virtual QDataStream &read( QDataStream &, QCollection::Item & ); virtual QDataStream &write( QDataStream &, QCollection::Item ) const; #endif private: QBaseBucket **vec; uint vlen; uint numItems; uint keytype : 2; uint cases : 1; uint copyk : 1; QGDItList *iterators; void unlink_common( int, QBaseBucket *, QBaseBucket * ); QStringBucket *unlink_string( const QString &, QCollection::Item item = 0 ); QAsciiBucket *unlink_ascii( const char *, QCollection::Item item = 0 ); QIntBucket *unlink_int( long, QCollection::Item item = 0 ); QPtrBucket *unlink_ptr( void *, QCollection::Item item = 0 ); void init( uint, KeyType, bool, bool ); friend class QGDictIterator; }; class Q_EXPORT QGDictIterator // generic dictionary iterator { friend class QGDict; public: QGDictIterator( const QGDict & ); QGDictIterator( const QGDictIterator & ); QGDictIterator &operator=( const QGDictIterator & ); ~QGDictIterator(); QCollection::Item toFirst(); QCollection::Item get() const; QString getKeyString() const; const char *getKeyAscii() const; long getKeyInt() const; void *getKeyPtr() const; QCollection::Item operator()(); QCollection::Item operator++(); QCollection::Item operator+=(uint); protected: QGDict *dict; private: QBaseBucket *curNode; uint curIndex; }; inline QCollection::Item QGDictIterator::get() const { return curNode ? curNode->getData() : 0; } inline QString QGDictIterator::getKeyString() const { return curNode ? ((QStringBucket*)curNode)->getKey() : QString::null; } inline const char *QGDictIterator::getKeyAscii() const { return curNode ? ((QAsciiBucket*)curNode)->getKey() : 0; } inline long QGDictIterator::getKeyInt() const { return curNode ? ((QIntBucket*)curNode)->getKey() : 0; } inline void *QGDictIterator::getKeyPtr() const { return curNode ? ((QPtrBucket*)curNode)->getKey() : 0; } #endif // QGDICT_H
[ "eu.gabii@yahoo.com" ]
eu.gabii@yahoo.com
2658fc437e564b998b6c8c924a3d7a5987bf8aec
76f99fbe3a809d73e4fd74c39c4175236c33ca42
/binding-genasm/core_bindings.cpp
264e85179b65b1db5f8392ce14611ab4d40974be
[ "BSD-2-Clause" ]
permissive
bokuweb/opencvjs
4f9a90eed5b85eab445cd2372226bbb24c0230cf
290313845d3f937dcd72045675b594d18790d591
refs/heads/Optimizations
2023-04-08T08:59:36.339673
2017-06-19T22:42:51
2017-06-19T22:42:51
98,154,074
0
0
NOASSERTION
2023-04-04T01:14:28
2017-07-24T05:56:56
JavaScript
UTF-8
C++
false
false
15,308
cpp
//////////////////////////////////////////////////////////////////////////////// // AUTHOR: Sajjad Taheri sajjadt[at]uci[at]edu // // LICENSE AGREEMENT // Copyright (c) 2015, University of California, Irvine // // 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. // 3. All advertising materials mentioning features or use of this software // must display the following acknowledgement: // This product includes software developed by the UC Irvine. // 4. Neither the name of the UC Irvine nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY UC IRVINE ''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 UC IRVINE 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 "opencv2/core.hpp" #include "opencv2/core/ocl.hpp" #include "opencv2/flann/flann.hpp" #include "opencv2/ml.hpp" #include "opencv2/photo.hpp" #include "opencv2/shape.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/calib3d.hpp" #include "opencv2/features2d.hpp" #include "opencv2/video/tracking.hpp" #include "opencv2/video/background_segm.hpp" #include "opencv2/objdetect.hpp" #include "opencv2/imgcodecs.hpp" #include <emscripten/bind.h> using namespace emscripten; using namespace cv; using namespace cv::flann; using namespace cv::ml; namespace Utils{ template<typename T> emscripten::val data(const cv::Mat& mat) { return emscripten::val(emscripten::memory_view<T>( (mat.total()*mat.elemSize())/sizeof(T), (T*) mat.data)); } emscripten::val matPtrI(const cv::Mat& mat, int i) { return emscripten::val(emscripten::memory_view<uint8_t>(mat.step1(0), mat.ptr(i))); } emscripten::val matPtrII(const cv::Mat& mat, int i, int j) { return emscripten::val(emscripten::memory_view<uint8_t>(mat.step1(1), mat.ptr(i,j))); } emscripten::val matFromArray(const emscripten::val& object, int type) { int w= object["width"].as<unsigned>(); int h= object["height"].as<unsigned>(); std::string str = object["data"]["buffer"].as<std::string>(); return emscripten::val(cv::Mat(h, w, type, (void*)str.data(), 0)); } cv::Mat* createMat(Size size, int type, intptr_t data, size_t step) { return new cv::Mat(size, type, reinterpret_cast<void*>(data), step); } cv::Mat* createMat2(const std::vector<unsigned char>& vector) { return new cv::Mat(vector, false); } // returning MatSize static std::vector<int> getMatSize(const cv::Mat& mat) { std::vector<int> size; for (int i = 0; i < mat.dims; i++) { size.push_back(mat.size[i]); } return size; } static Mat eye(int rows, int cols, int type) { return Mat(cv::Mat::eye(rows, cols, type)); } static Mat eye(Size size, int type) { return Mat(cv::Mat::eye(size, type)); } void convertTo(const Mat& obj, Mat& m, int rtype, double alpha, double beta) { obj.convertTo(m, rtype, alpha, beta); } Size matSize(const cv::Mat& mat) { return mat.size(); } cv::Mat mat_zeros_iii(int arg0, int arg1, int arg2) { return cv::Mat::zeros(arg0, arg1, arg2); } cv::Mat mat_zeros_Si(cv::Size arg0, int arg1) { return cv::Mat::zeros(arg0,arg1); } cv::Mat mat_zeros_ipii(int arg0, const int* arg1, int arg2) { return cv::Mat::zeros(arg0,arg1,arg2); } cv::Mat mat_ones_iii(int arg0, int arg1, int arg2) { return cv::Mat::ones(arg0, arg1, arg2); } cv::Mat mat_ones_ipii(int arg0, const int* arg1, int arg2) { return cv::Mat::ones(arg0, arg1, arg2); } cv::Mat mat_ones_Si(cv::Size arg0, int arg1) { return cv::Mat::ones(arg0, arg1); } double matDot(const cv::Mat& obj, const Mat& mat) { return obj.dot(mat); } Mat matMul(const cv::Mat& obj, const Mat& mat, double scale) { return Mat(obj.mul(mat, scale)); } Mat matT(const cv::Mat& obj) { return Mat(obj.t()); } Mat matInv(const cv::Mat& obj, int type) { return Mat(obj.inv(type)); } } EMSCRIPTEN_BINDINGS(Utils) { register_vector<int>("IntVector"); register_vector<char>("CharVector"); register_vector<unsigned>("UnsignedVector"); register_vector<unsigned char>("UCharVector"); register_vector<std::string>("StrVector"); register_vector<emscripten::val>("EmvalVector"); register_vector<float>("FloatVector"); register_vector<std::vector<int>>("IntVectorVector"); register_vector<std::vector<Point>>("PointVectorVector"); register_vector<cv::Point>("PointVector"); register_vector<cv::Vec4i>("Vec4iVector"); register_vector<cv::Mat>("MatVector"); register_vector<cv::KeyPoint>("KeyPointVector"); register_vector<cv::Rect>("RectVector"); register_vector<cv::Point2f>("Point2fVector"); emscripten::class_<cv::TermCriteria>("TermCriteria") .constructor<>() .constructor<int, int, double>() .property("type", &cv::TermCriteria::type) .property("maxCount", &cv::TermCriteria::maxCount) .property("epsilon", &cv::TermCriteria::epsilon); emscripten::class_<cv::Mat>("Mat") .constructor<>() //.constructor<const Mat&>() .constructor<Size, int>() .constructor<int, int, int>() .constructor(&Utils::createMat, allow_raw_pointers()) .constructor(&Utils::createMat2, allow_raw_pointers()) .function("elemSize1", select_overload<size_t()const>(&cv::Mat::elemSize1)) //.function("assignTo", select_overload<void(Mat&, int)const>(&cv::Mat::assignTo)) .function("channels", select_overload<int()const>(&cv::Mat::channels)) .function("convertTo", select_overload<void(const Mat&, Mat&, int, double, double)>(&Utils::convertTo)) .function("total", select_overload<size_t()const>(&cv::Mat::total)) .function("row", select_overload<Mat(int)const>(&cv::Mat::row)) .class_function("eye",select_overload<Mat(int, int, int)>(&Utils::eye)) .class_function("eye",select_overload<Mat(Size, int)>(&Utils::eye)) .function("create", select_overload<void(int, int, int)>(&cv::Mat::create)) .function("create", select_overload<void(Size, int)>(&cv::Mat::create)) .function("rowRange", select_overload<Mat(int, int)const>(&cv::Mat::rowRange)) .function("rowRange", select_overload<Mat(const Range&)const>(&cv::Mat::rowRange)) .function("copyTo", select_overload<void(OutputArray)const>(&cv::Mat::copyTo)) .function("copyTo", select_overload<void(OutputArray, InputArray)const>(&cv::Mat::copyTo)) .function("elemSize", select_overload<size_t()const>(&cv::Mat::elemSize)) .function("type", select_overload<int()const>(&cv::Mat::type)) .function("empty", select_overload<bool()const>(&cv::Mat::empty)) .function("colRange", select_overload<Mat(int, int)const>(&cv::Mat::colRange)) .function("colRange", select_overload<Mat(const Range&)const>(&cv::Mat::colRange)) .function("step1", select_overload<size_t(int)const>(&cv::Mat::step1)) .function("clone", select_overload<Mat()const>(&cv::Mat::clone)) .class_function("ones",select_overload<Mat(int, int, int)>(&Utils::mat_ones_iii)) .class_function("ones",select_overload<Mat(Size, int)>(&Utils::mat_ones_Si)) .class_function("zeros",select_overload<Mat(int, int, int)>(&Utils::mat_zeros_iii)) .class_function("zeros",select_overload<Mat(Size, int)>(&Utils::mat_zeros_Si)) .function("depth", select_overload<int()const>(&cv::Mat::depth)) .function("col", select_overload<Mat(int)const>(&cv::Mat::col)) .function("dot", select_overload<double(const Mat&, const Mat&)>(&Utils::matDot)) .function("mul", select_overload<Mat(const Mat&, const Mat&, double)>(&Utils::matMul)) .function("inv", select_overload<Mat(const Mat&, int)>(&Utils::matInv)) .function("t", select_overload<Mat(const Mat&)>(&Utils::matT)) .property("rows", &cv::Mat::rows) .property("cols", &cv::Mat::cols) .function("data", &Utils::data<unsigned char>) .function("data8S", &Utils::data<char>) .function("data16u", &Utils::data<unsigned short>) .function("data16s", &Utils::data<short>) .function("data32s", &Utils::data<int>) .function("data32f", &Utils::data<float>) .function("data64f", &Utils::data<double>) .function("ptr", select_overload<val(const Mat&, int)>(&Utils::matPtrI)) .function("ptr", select_overload<val(const Mat&, int, int)>(&Utils::matPtrII)) .function("size" , &Utils::getMatSize) .function("get_uchar_at" , select_overload<unsigned char&(int)>(&cv::Mat::at<unsigned char>)) .function("get_uchar_at", select_overload<unsigned char&(int, int)>(&cv::Mat::at<unsigned char>)) .function("get_uchar_at", select_overload<unsigned char&(int, int, int)>(&cv::Mat::at<unsigned char>)) .function("get_ushort_at", select_overload<unsigned short&(int)>(&cv::Mat::at<unsigned short>)) .function("get_ushort_at", select_overload<unsigned short&(int, int)>(&cv::Mat::at<unsigned short>)) .function("get_ushort_at", select_overload<unsigned short&(int, int, int)>(&cv::Mat::at<unsigned short>)) .function("get_int_at" , select_overload<int&(int)>(&cv::Mat::at<int>) ) .function("get_int_at", select_overload<int&(int, int)>(&cv::Mat::at<int>) ) .function("get_int_at", select_overload<int&(int, int, int)>(&cv::Mat::at<int>) ) .function("get_double_at", select_overload<double&(int, int, int)>(&cv::Mat::at<double>)) .function("get_double_at", select_overload<double&(int)>(&cv::Mat::at<double>)) .function("get_double_at", select_overload<double&(int, int)>(&cv::Mat::at<double>)) .function("get_float_at", select_overload<float&(int)>(&cv::Mat::at<float>)) .function("get_float_at", select_overload<float&(int, int)>(&cv::Mat::at<float>)) .function("get_float_at", select_overload<float&(int, int, int)>(&cv::Mat::at<float>)) .function( "getROI_Rect", select_overload<Mat(const Rect&)const>(&cv::Mat::operator())); emscripten::class_<cv::Vec<int,4>>("Vec4i") .constructor<>() .constructor<int, int, int, int>(); emscripten::class_<cv::RNG> ("RNG"); value_array<Size>("Size") .element(&Size::height) .element(&Size::width); value_array<Point>("Point") .element(&Point::x) .element(&Point::y); value_array<Point2f>("Point2f") .element(&Point2f::x) .element(&Point2f::y); emscripten::class_<cv::Rect_<int>> ("Rect") .constructor<>() .constructor<const cv::Point_<int>&, const cv::Size_<int>&>() .constructor<int, int, int, int>() .constructor<const cv::Rect_<int>&>() .property("x", &cv::Rect_<int>::x) .property("y", &cv::Rect_<int>::y) .property("width", &cv::Rect_<int>::width) .property("height", &cv::Rect_<int>::height); emscripten::class_<cv::Scalar_<double>> ("Scalar") .constructor<>() .constructor<double>() .constructor<double, double>() .constructor<double, double, double>() .constructor<double, double, double, double>() .class_function("all", &cv::Scalar_<double>::all) .function("isReal", select_overload<bool()const>(&cv::Scalar_<double>::isReal)); function("matFromArray", &Utils::matFromArray); constant("CV_8UC1", CV_8UC1) ; constant("CV_8UC2", CV_8UC2) ; constant("CV_8UC3", CV_8UC3) ; constant("CV_8UC4", CV_8UC4) ; constant("CV_8SC1", CV_8SC1) ; constant("CV_8SC2", CV_8SC2) ; constant("CV_8SC3", CV_8SC3) ; constant("CV_8SC4", CV_8SC4) ; constant("CV_16UC1", CV_16UC1) ; constant("CV_16UC2", CV_16UC2) ; constant("CV_16UC3", CV_16UC3) ; constant("CV_16UC4", CV_16UC4) ; constant("CV_16SC1", CV_16SC1) ; constant("CV_16SC2", CV_16SC2) ; constant("CV_16SC3", CV_16SC3) ; constant("CV_16SC4", CV_16SC4) ; constant("CV_32SC1", CV_32SC1) ; constant("CV_32SC2", CV_32SC2) ; constant("CV_32SC3", CV_32SC3) ; constant("CV_32SC4", CV_32SC4) ; constant("CV_32FC1", CV_32FC1) ; constant("CV_32FC2", CV_32FC2) ; constant("CV_32FC3", CV_32FC3) ; constant("CV_32FC4", CV_32FC4) ; constant("CV_64FC1", CV_64FC1) ; constant("CV_64FC2", CV_64FC2) ; constant("CV_64FC3", CV_64FC3) ; constant("CV_64FC4", CV_64FC4) ; constant("CV_8U", CV_8U); constant("CV_8S", CV_8S); constant("CV_16U", CV_16U); constant("CV_16S", CV_16S); constant("CV_32S", CV_32S); constant("CV_32F", CV_32F); constant("CV_32F", CV_32F); constant("BORDER_CONSTANT", +cv::BorderTypes::BORDER_CONSTANT); constant("BORDER_REPLICATE", +cv::BorderTypes::BORDER_REPLICATE); constant("BORDER_REFLECT", +cv::BorderTypes::BORDER_REFLECT); constant("BORDER_WRAP", +cv::BorderTypes::BORDER_WRAP); constant("BORDER_REFLECT_101", +cv::BorderTypes::BORDER_REFLECT_101); constant("BORDER_TRANSPARENT", +cv::BorderTypes::BORDER_TRANSPARENT); constant("BORDER_REFLECT101", +cv::BorderTypes::BORDER_REFLECT101); constant("BORDER_DEFAULT", +cv::BorderTypes::BORDER_DEFAULT); constant("BORDER_ISOLATED", +cv::BorderTypes::BORDER_ISOLATED); constant("NORM_INF", +cv::NormTypes::NORM_INF); constant("NORM_L1", +cv::NormTypes::NORM_L1); constant("NORM_L2", +cv::NormTypes::NORM_L2); constant("NORM_L2SQR", +cv::NormTypes::NORM_L2SQR); constant("NORM_HAMMING", +cv::NormTypes::NORM_HAMMING); constant("NORM_HAMMING2", +cv::NormTypes::NORM_HAMMING2); constant("NORM_TYPE_MASK", +cv::NormTypes::NORM_TYPE_MASK); constant("NORM_RELATIVE", +cv::NormTypes::NORM_RELATIVE); constant("NORM_MINMAX", +cv::NormTypes::NORM_MINMAX); constant("INPAINT_NS", +cv::INPAINT_NS); constant("INPAINT_TELEA", +cv::INPAINT_TELEA); }
[ "yebastikian@gmail.com" ]
yebastikian@gmail.com
cf814477135e44a59c2b547267942184882c351c
9819d9ef8fd274cc17e50dd1a5295f0b05cb6dce
/source/gui/noname.cpp
01c14cd12bd511b3fb9b06e4e02af3594fe6e37a
[]
no_license
geekgg20/XssDetect
1ffa77724d637367da536d2e37d86661e81148be
5ebeb2c5429fb72cb4c813e27c0e8bd92fce20ff
refs/heads/master
2020-09-24T13:27:01.527228
2016-06-07T09:37:52
2016-06-07T09:37:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
30,665
cpp
/////////////////////////////////////////////////////////////////////////// // C++ code generated with wxFormBuilder (version Jun 17 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "noname.h" /////////////////////////////////////////////////////////////////////////// XssDetectFrame::XssDetectFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); wxBoxSizer* main_bSizer; main_bSizer = new wxBoxSizer( wxVERTICAL ); logo_panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* logo_bSizer; logo_bSizer = new wxBoxSizer( wxVERTICAL ); logo_bitmap = new wxStaticBitmap( logo_panel, wxID_ANY, wxBitmap( wxT("images/logo.jpg"), wxBITMAP_TYPE_ANY ), wxDefaultPosition, wxDefaultSize, 0 ); logo_bSizer->Add( logo_bitmap, 2, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); logo_panel->SetSizer( logo_bSizer ); logo_panel->Layout(); logo_bSizer->Fit( logo_panel ); main_bSizer->Add( logo_panel, 3, wxEXPAND | wxALL, 5 ); m_notebook4 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); setting_panel = new wxPanel( m_notebook4, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* setting_bSizer; setting_bSizer = new wxBoxSizer( wxVERTICAL ); thread_ctrl_panel = new wxPanel( setting_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxStaticBoxSizer* thread_ctrl_sbSizer; thread_ctrl_sbSizer = new wxStaticBoxSizer( new wxStaticBox( thread_ctrl_panel, wxID_ANY, wxT("系统线程设置") ), wxHORIZONTAL ); spider_thread_num_staticText = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxT("爬虫线程数量(0~100):"), wxDefaultPosition, wxDefaultSize, 0 ); spider_thread_num_staticText->Wrap( -1 ); thread_ctrl_sbSizer->Add( spider_thread_num_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); spider_thread_num_slider = new wxSlider( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, 10, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL ); thread_ctrl_sbSizer->Add( spider_thread_num_slider, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_staticText_spider_unit = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxT("10"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText_spider_unit->Wrap( -1 ); thread_ctrl_sbSizer->Add( m_staticText_spider_unit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_staticText_space = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxT("df") ); m_staticText_space->Wrap( -1 ); thread_ctrl_sbSizer->Add( m_staticText_space, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); check_thread_num_staticText = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxT("检测线程数量(0~100):"), wxDefaultPosition, wxDefaultSize, 0 ); check_thread_num_staticText->Wrap( -1 ); thread_ctrl_sbSizer->Add( check_thread_num_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); check_thread_num_slider = new wxSlider( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, 10, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL ); thread_ctrl_sbSizer->Add( check_thread_num_slider, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_staticText_check_unit = new wxStaticText( thread_ctrl_sbSizer->GetStaticBox(), wxID_ANY, wxT("10"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText_check_unit->Wrap( -1 ); thread_ctrl_sbSizer->Add( m_staticText_check_unit, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); thread_ctrl_panel->SetSizer( thread_ctrl_sbSizer ); thread_ctrl_panel->Layout(); thread_ctrl_sbSizer->Fit( thread_ctrl_panel ); setting_bSizer->Add( thread_ctrl_panel, 1, wxEXPAND | wxALL, 5 ); setting_login_info_panel = new wxPanel( setting_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxStaticBoxSizer* setting_login_info_sbSizer; setting_login_info_sbSizer = new wxStaticBoxSizer( new wxStaticBox( setting_login_info_panel, wxID_ANY, wxT("HTTP授权信息") ), wxVERTICAL ); setting_cookie_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* setting_cookie_bSizer; setting_cookie_bSizer = new wxBoxSizer( wxHORIZONTAL ); login_url_staticText = new wxStaticText( setting_cookie_panel, wxID_ANY, wxT("登录链接:"), wxDefaultPosition, wxDefaultSize, 0 ); login_url_staticText->Wrap( -1 ); setting_cookie_bSizer->Add( login_url_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); login_url_textCtrl = new wxTextCtrl( setting_cookie_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); setting_cookie_bSizer->Add( login_url_textCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); cookie_staticText = new wxStaticText( setting_cookie_panel, wxID_ANY, wxT("Cookie:"), wxDefaultPosition, wxDefaultSize, 0 ); cookie_staticText->Wrap( -1 ); setting_cookie_bSizer->Add( cookie_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); cookie_textCtrl = new wxTextCtrl( setting_cookie_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); setting_cookie_bSizer->Add( cookie_textCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); setting_cookie_panel->SetSizer( setting_cookie_bSizer ); setting_cookie_panel->Layout(); setting_cookie_bSizer->Fit( setting_cookie_panel ); setting_login_info_sbSizer->Add( setting_cookie_panel, 1, wxEXPAND | wxALL, 5 ); setting_username_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* setting_username_bSizer; setting_username_bSizer = new wxBoxSizer( wxHORIZONTAL ); username_key_staticText = new wxStaticText( setting_username_panel, wxID_ANY, wxT("username key:"), wxDefaultPosition, wxDefaultSize, 0 ); username_key_staticText->Wrap( -1 ); setting_username_bSizer->Add( username_key_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); username_key_textCtrl = new wxTextCtrl( setting_username_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); setting_username_bSizer->Add( username_key_textCtrl, 3, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); username_value_staticText1 = new wxStaticText( setting_username_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); username_value_staticText1->Wrap( -1 ); setting_username_bSizer->Add( username_value_staticText1, 1, wxALL, 5 ); username_value_staticText = new wxStaticText( setting_username_panel, wxID_ANY, wxT("username value:"), wxDefaultPosition, wxDefaultSize, 0 ); username_value_staticText->Wrap( -1 ); setting_username_bSizer->Add( username_value_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); username_value_textCtr = new wxTextCtrl( setting_username_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); setting_username_bSizer->Add( username_value_textCtr, 3, wxALL, 5 ); setting_username_panel->SetSizer( setting_username_bSizer ); setting_username_panel->Layout(); setting_username_bSizer->Fit( setting_username_panel ); setting_login_info_sbSizer->Add( setting_username_panel, 1, wxEXPAND | wxALL, 5 ); setting_password_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* setting_username_bSizer1; setting_username_bSizer1 = new wxBoxSizer( wxHORIZONTAL ); password_key_staticText = new wxStaticText( setting_password_panel, wxID_ANY, wxT("password key:"), wxDefaultPosition, wxDefaultSize, 0 ); password_key_staticText->Wrap( -1 ); setting_username_bSizer1->Add( password_key_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); password_key_textCtrl = new wxTextCtrl( setting_password_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); setting_username_bSizer1->Add( password_key_textCtrl, 3, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); username_value_staticText11 = new wxStaticText( setting_password_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); username_value_staticText11->Wrap( -1 ); setting_username_bSizer1->Add( username_value_staticText11, 1, wxALL, 5 ); password_value_staticText = new wxStaticText( setting_password_panel, wxID_ANY, wxT("password value:"), wxDefaultPosition, wxDefaultSize, 0 ); password_value_staticText->Wrap( -1 ); setting_username_bSizer1->Add( password_value_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); password_value_textCtr = new wxTextCtrl( setting_password_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); setting_username_bSizer1->Add( password_value_textCtr, 3, wxALL, 5 ); setting_password_panel->SetSizer( setting_username_bSizer1 ); setting_password_panel->Layout(); setting_username_bSizer1->Fit( setting_password_panel ); setting_login_info_sbSizer->Add( setting_password_panel, 1, wxEXPAND | wxALL, 5 ); setting_vercode_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* setting_username_bSizer11; setting_username_bSizer11 = new wxBoxSizer( wxHORIZONTAL ); vercode_key_staticText = new wxStaticText( setting_vercode_panel, wxID_ANY, wxT("vercode key:"), wxDefaultPosition, wxDefaultSize, 0 ); vercode_key_staticText->Wrap( -1 ); setting_username_bSizer11->Add( vercode_key_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); vercode_key_textCtrl = new wxTextCtrl( setting_vercode_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); setting_username_bSizer11->Add( vercode_key_textCtrl, 3, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); username_value_staticText111 = new wxStaticText( setting_vercode_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); username_value_staticText111->Wrap( -1 ); setting_username_bSizer11->Add( username_value_staticText111, 1, wxALL, 5 ); vercode_value_staticText = new wxStaticText( setting_vercode_panel, wxID_ANY, wxT("vercode value:"), wxDefaultPosition, wxDefaultSize, 0 ); vercode_value_staticText->Wrap( -1 ); setting_username_bSizer11->Add( vercode_value_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); vercode_value_textCtr = new wxTextCtrl( setting_vercode_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); setting_username_bSizer11->Add( vercode_value_textCtr, 3, wxALL, 5 ); setting_vercode_panel->SetSizer( setting_username_bSizer11 ); setting_vercode_panel->Layout(); setting_username_bSizer11->Fit( setting_vercode_panel ); setting_login_info_sbSizer->Add( setting_vercode_panel, 1, wxEXPAND | wxALL, 5 ); setting_login_info_ctrl_panel = new wxPanel( setting_login_info_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* settinglogin_bSizer; settinglogin_bSizer = new wxBoxSizer( wxHORIZONTAL ); vercode_staticText = new wxStaticText( setting_login_info_ctrl_panel, wxID_ANY, wxT("验证码链接:"), wxDefaultPosition, wxDefaultSize, 0 ); vercode_staticText->Wrap( -1 ); settinglogin_bSizer->Add( vercode_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); vercode_textCtrl = new wxTextCtrl( setting_login_info_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); settinglogin_bSizer->Add( vercode_textCtrl, 3, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); vercode_bitmap = new wxStaticBitmap( setting_login_info_ctrl_panel, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 ); settinglogin_bSizer->Add( vercode_bitmap, 1, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); get_vercode_button = new wxButton( setting_login_info_ctrl_panel, wxID_ANY, wxT("获取验证码"), wxDefaultPosition, wxDefaultSize, 0 ); settinglogin_bSizer->Add( get_vercode_button, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); login_button = new wxButton( setting_login_info_ctrl_panel, wxID_ANY, wxT("登录"), wxDefaultPosition, wxDefaultSize, 0 ); settinglogin_bSizer->Add( login_button, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); setting_login_info_ctrl_panel->SetSizer( settinglogin_bSizer ); setting_login_info_ctrl_panel->Layout(); settinglogin_bSizer->Fit( setting_login_info_ctrl_panel ); setting_login_info_sbSizer->Add( setting_login_info_ctrl_panel, 1, wxEXPAND | wxALL, 5 ); setting_login_info_panel->SetSizer( setting_login_info_sbSizer ); setting_login_info_panel->Layout(); setting_login_info_sbSizer->Fit( setting_login_info_panel ); setting_bSizer->Add( setting_login_info_panel, 5, wxEXPAND | wxALL, 5 ); setting_payload_panel = new wxPanel( setting_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxStaticBoxSizer* setting_payload_sbSizer; setting_payload_sbSizer = new wxStaticBoxSizer( new wxStaticBox( setting_payload_panel, wxID_ANY, wxT("自定义信息") ), wxHORIZONTAL ); setting_payload_text_panel = new wxPanel( setting_payload_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* setting_payload_text_bSizer; setting_payload_text_bSizer = new wxBoxSizer( wxVERTICAL ); payload_text_panel = new wxPanel( setting_payload_text_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* payload_text_bSizer; payload_text_bSizer = new wxBoxSizer( wxVERTICAL ); payload_staticText = new wxStaticText( payload_text_panel, wxID_ANY, wxT("自定义向量:"), wxDefaultPosition, wxDefaultSize, 0 ); payload_staticText->Wrap( -1 ); payload_text_bSizer->Add( payload_staticText, 0, wxALL, 5 ); payload_textCtrl = new wxTextCtrl( payload_text_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); payload_text_bSizer->Add( payload_textCtrl, 1, wxALL|wxEXPAND, 5 ); payload_text_panel->SetSizer( payload_text_bSizer ); payload_text_panel->Layout(); payload_text_bSizer->Fit( payload_text_panel ); setting_payload_text_bSizer->Add( payload_text_panel, 3, wxEXPAND | wxALL, 5 ); exclude_url_panel = new wxPanel( setting_payload_text_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* exclude_url_bSizer; exclude_url_bSizer = new wxBoxSizer( wxHORIZONTAL ); exclude_url_staticText = new wxStaticText( exclude_url_panel, wxID_ANY, wxT("排除的URL:"), wxDefaultPosition, wxDefaultSize, 0 ); exclude_url_staticText->Wrap( -1 ); exclude_url_bSizer->Add( exclude_url_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); exclude_url_textCtrl = new wxTextCtrl( exclude_url_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); exclude_url_bSizer->Add( exclude_url_textCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); exclude_url_panel->SetSizer( exclude_url_bSizer ); exclude_url_panel->Layout(); exclude_url_bSizer->Fit( exclude_url_panel ); setting_payload_text_bSizer->Add( exclude_url_panel, 1, wxEXPAND | wxALL, 5 ); setting_payload_text_panel->SetSizer( setting_payload_text_bSizer ); setting_payload_text_panel->Layout(); setting_payload_text_bSizer->Fit( setting_payload_text_panel ); setting_payload_sbSizer->Add( setting_payload_text_panel, 3, wxEXPAND | wxALL, 5 ); save_info_panel = new wxPanel( setting_payload_sbSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* save_info_bSizer; save_info_bSizer = new wxBoxSizer( wxVERTICAL ); save_info_staticText = new wxStaticText( save_info_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); save_info_staticText->Wrap( -1 ); save_info_bSizer->Add( save_info_staticText, 1, wxALL, 5 ); save_payload_button = new wxButton( save_info_panel, wxID_ANY, wxT("添加PAYLOAD"), wxDefaultPosition, wxDefaultSize, 0 ); save_info_bSizer->Add( save_payload_button, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); save_info_staticText1 = new wxStaticText( save_info_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); save_info_staticText1->Wrap( -1 ); save_info_bSizer->Add( save_info_staticText1, 1, wxALL, 5 ); m_button6 = new wxButton( save_info_panel, wxID_ANY, wxT("保存系统设置"), wxDefaultPosition, wxDefaultSize, 0 ); save_info_bSizer->Add( m_button6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); save_info_panel->SetSizer( save_info_bSizer ); save_info_panel->Layout(); save_info_bSizer->Fit( save_info_panel ); setting_payload_sbSizer->Add( save_info_panel, 1, wxEXPAND | wxALL, 5 ); setting_payload_panel->SetSizer( setting_payload_sbSizer ); setting_payload_panel->Layout(); setting_payload_sbSizer->Fit( setting_payload_panel ); setting_bSizer->Add( setting_payload_panel, 3, wxEXPAND | wxALL, 5 ); setting_panel->SetSizer( setting_bSizer ); setting_panel->Layout(); setting_bSizer->Fit( setting_panel ); m_notebook4->AddPage( setting_panel, wxT("系统设置"), false ); spider_panel = new wxPanel( m_notebook4, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* spider_bSizer; spider_bSizer = new wxBoxSizer( wxVERTICAL ); spider_ctrl_panel = new wxPanel( spider_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* spider_ctrl_bSizer; spider_ctrl_bSizer = new wxBoxSizer( wxHORIZONTAL ); seed_url_label = new wxStaticText( spider_ctrl_panel, wxID_ANY, wxT("种子连接:"), wxDefaultPosition, wxDefaultSize, 0 ); seed_url_label->Wrap( -1 ); spider_ctrl_bSizer->Add( seed_url_label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); seed_url_text = new wxTextCtrl( spider_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); spider_ctrl_bSizer->Add( seed_url_text, 7, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); m_staticText29 = new wxStaticText( spider_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_staticText29->Wrap( -1 ); spider_ctrl_bSizer->Add( m_staticText29, 1, wxALL, 5 ); crawl_depth_staticText = new wxStaticText( spider_ctrl_panel, wxID_ANY, wxT("爬取深度:"), wxDefaultPosition, wxDefaultSize, 0 ); crawl_depth_staticText->Wrap( -1 ); spider_ctrl_bSizer->Add( crawl_depth_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); crawl_depth_textCtrl = new wxTextCtrl( spider_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); spider_ctrl_bSizer->Add( crawl_depth_textCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); start_crawling_button = new wxButton( spider_ctrl_panel, wxID_ANY, wxT("开始爬取"), wxDefaultPosition, wxDefaultSize, 0 ); spider_ctrl_bSizer->Add( start_crawling_button, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); spider_ctrl_panel->SetSizer( spider_ctrl_bSizer ); spider_ctrl_panel->Layout(); spider_ctrl_bSizer->Fit( spider_ctrl_panel ); spider_bSizer->Add( spider_ctrl_panel, 1, wxALL|wxEXPAND, 5 ); spider_show_panel = new wxPanel( spider_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* spider_grid_bSizer; spider_grid_bSizer = new wxBoxSizer( wxVERTICAL ); spider_grid = new wxGrid( spider_show_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid spider_grid->CreateGrid( 10, 4 ); spider_grid->EnableEditing( true ); spider_grid->EnableGridLines( true ); spider_grid->EnableDragGridSize( false ); spider_grid->SetMargins( 0, 0 ); // Columns spider_grid->SetColSize( 0, 64 ); spider_grid->SetColSize( 1, 446 ); spider_grid->SetColSize( 2, 80 ); spider_grid->SetColSize( 3, 78 ); spider_grid->EnableDragColMove( false ); spider_grid->EnableDragColSize( true ); spider_grid->SetColLabelSize( 30 ); spider_grid->SetColLabelValue( 0, wxT("线程名") ); spider_grid->SetColLabelValue( 1, wxT("URL") ); spider_grid->SetColLabelValue( 2, wxT("请求类型") ); spider_grid->SetColLabelValue( 3, wxT("深度") ); spider_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows spider_grid->EnableDragRowSize( true ); spider_grid->SetRowLabelSize( 80 ); spider_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Cell Defaults spider_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); spider_grid_bSizer->Add( spider_grid, 1, wxALL|wxEXPAND, 5 ); spider_show_panel->SetSizer( spider_grid_bSizer ); spider_show_panel->Layout(); spider_grid_bSizer->Fit( spider_show_panel ); spider_bSizer->Add( spider_show_panel, 6, wxEXPAND | wxALL, 5 ); spider_panel->SetSizer( spider_bSizer ); spider_panel->Layout(); spider_bSizer->Fit( spider_panel ); m_notebook4->AddPage( spider_panel, wxT("网络爬虫"), false ); check_panel = new wxPanel( m_notebook4, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* check_bSizer; check_bSizer = new wxBoxSizer( wxVERTICAL ); check_ctrl_panel = new wxPanel( check_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* reflected_check_bSizer; reflected_check_bSizer = new wxBoxSizer( wxHORIZONTAL ); reflect_check_staticText = new wxStaticText( check_ctrl_panel, wxID_ANY, wxT("反射型XSS检测:"), wxDefaultPosition, wxDefaultSize, 0 ); reflect_check_staticText->Wrap( -1 ); reflected_check_bSizer->Add( reflect_check_staticText, 0, wxALL, 5 ); reflect_checking_url = new wxStaticText( check_ctrl_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); reflect_checking_url->Wrap( -1 ); reflected_check_bSizer->Add( reflect_checking_url, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); start_check_button = new wxButton( check_ctrl_panel, wxID_ANY, wxT("开始检测"), wxDefaultPosition, wxDefaultSize, 0 ); reflected_check_bSizer->Add( start_check_button, 0, wxALL, 5 ); check_ctrl_panel->SetSizer( reflected_check_bSizer ); check_ctrl_panel->Layout(); reflected_check_bSizer->Fit( check_ctrl_panel ); check_bSizer->Add( check_ctrl_panel, 1, wxEXPAND | wxALL, 5 ); check_show_panel = new wxPanel( check_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* check_show_bSizer; check_show_bSizer = new wxBoxSizer( wxVERTICAL ); check_grid = new wxGrid( check_show_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); // Grid check_grid->CreateGrid( 10, 3 ); check_grid->EnableEditing( false ); check_grid->EnableGridLines( true ); check_grid->EnableDragGridSize( false ); check_grid->SetMargins( 0, 0 ); // Columns check_grid->SetColSize( 0, 80 ); check_grid->SetColSize( 1, 422 ); check_grid->SetColSize( 2, 163 ); check_grid->EnableDragColMove( false ); check_grid->EnableDragColSize( true ); check_grid->SetColLabelSize( 30 ); check_grid->SetColLabelValue( 0, wxT("XSS漏洞类型") ); check_grid->SetColLabelValue( 1, wxT("存在漏洞的URL") ); check_grid->SetColLabelValue( 2, wxT("PAYLOAD") ); check_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Rows check_grid->EnableDragRowSize( true ); check_grid->SetRowLabelSize( 80 ); check_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); // Label Appearance // Cell Defaults check_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); check_show_bSizer->Add( check_grid, 1, wxALL|wxEXPAND, 5 ); check_show_panel->SetSizer( check_show_bSizer ); check_show_panel->Layout(); check_show_bSizer->Fit( check_show_panel ); check_bSizer->Add( check_show_panel, 4, wxEXPAND | wxALL, 5 ); check_panel->SetSizer( check_bSizer ); check_panel->Layout(); check_bSizer->Fit( check_panel ); m_notebook4->AddPage( check_panel, wxT("XSS 检测"), true ); main_bSizer->Add( m_notebook4, 3, wxEXPAND | wxALL, 5 ); this->SetSizer( main_bSizer ); this->Layout(); statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY ); this->Centre( wxBOTH ); // Connect Events spider_thread_num_slider->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); check_thread_num_slider->Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Connect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Connect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Connect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); get_vercode_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnGetVercodeButtonClick ), NULL, this ); login_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnLoginButtonClick ), NULL, this ); save_payload_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnSavePayloadButtonClick ), NULL, this ); m_button6->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnSaveSettingInfoButtonClick ), NULL, this ); start_crawling_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnBeginCrawlingButtonClick ), NULL, this ); start_check_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnBeginCheckButtonClick ), NULL, this ); } XssDetectFrame::~XssDetectFrame() { // Disconnect Events spider_thread_num_slider->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Disconnect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Disconnect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Disconnect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); spider_thread_num_slider->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( XssDetectFrame::OnSpiderThreadNumScroll ), NULL, this ); check_thread_num_slider->Disconnect( wxEVT_SCROLL_TOP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Disconnect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Disconnect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Disconnect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Disconnect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Disconnect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Disconnect( wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Disconnect( wxEVT_SCROLL_THUMBRELEASE, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); check_thread_num_slider->Disconnect( wxEVT_SCROLL_CHANGED, wxScrollEventHandler( XssDetectFrame::OnCheckThreadNumScroll ), NULL, this ); get_vercode_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnGetVercodeButtonClick ), NULL, this ); login_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnLoginButtonClick ), NULL, this ); save_payload_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnSavePayloadButtonClick ), NULL, this ); m_button6->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnSaveSettingInfoButtonClick ), NULL, this ); start_crawling_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnBeginCrawlingButtonClick ), NULL, this ); start_check_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( XssDetectFrame::OnBeginCheckButtonClick ), NULL, this ); }
[ "mguichun@foxmail.com" ]
mguichun@foxmail.com
1da9e71d9d21e92bf133d77f3b0881ccd94f7c79
830c3f036753f0afae50c4dcedbb80a6babf119a
/tests/tools/Dx11DemoRemoteWrite.cpp
a3a8444f36c0f3650ea25ee579a6eead39502f24
[ "MIT" ]
permissive
yukunchen/Terminal
e72d8d481391fcc617fbc27e4542f965334d4996
13afb7e69de384eca38a9c03def3fc2ff9fbe600
refs/heads/master
2020-05-20T22:18:58.025272
2019-05-09T23:58:14
2019-05-09T23:58:14
185,779,890
0
0
null
2019-05-09T10:42:52
2019-05-09T10:42:52
null
UTF-8
C++
false
false
11,970
cpp
#include <windows.h> #include <vector> #include <iostream> #include <cassert> // Xfer #include "NetXferInterface.h" #include "resource.h" using namespace std; //-------------------------------------------------------------------------------------- // Global Variables //-------------------------------------------------------------------------------------- HINSTANCE g_hInst = nullptr; HWND g_hMainWnd = nullptr; HWND g_hControlWnd = nullptr; HRESULT InitWindow(HINSTANCE hInstance, int nCmdShow); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM); // For client bool g_ServerConnected; bool ConnectServer(); void DisconnectServer(); void GetServerAddress(wchar_t*, wchar_t*); NetXferInterface* pHvrNetXfer = nullptr; typedef struct _POLLING_THREAD_DATA { HANDLE TerminateThreadsEvent; } POLLING_THREAD_DATA; DWORD WINAPI PollingThread(_In_ void* Param); POLLING_THREAD_DATA g_PollingTData; HANDLE g_PollingTHandle; int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); if (FAILED(InitWindow(hInstance, nCmdShow))) { return 0; } g_ServerConnected = false; g_PollingTHandle = nullptr; RtlZeroMemory(&g_PollingTData, sizeof(g_PollingTData)); g_PollingTData.TerminateThreadsEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr); if (!g_PollingTData.TerminateThreadsEvent) { wprintf(L"Fail call to CreateEvent\n"); return 0; } ResetEvent(g_PollingTData.TerminateThreadsEvent); // Main message loop MSG msg = { 0 }; while (WM_QUIT != msg.message) { if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { // } } CloseHandle(g_PollingTData.TerminateThreadsEvent); return (int)msg.wParam; } HRESULT InitWindow(HINSTANCE hInstance, int nCmdShow) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_APPICON); wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); wcex.lpszMenuName = nullptr; wcex.lpszClassName = L"Dx11DemoRemoteWriteWindowClass"; wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_APPICON); if (!RegisterClassEx(&wcex)) // Create window g_hInst = hInstance; RECT rc = { 0, 0, 640, 480 }; AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); g_hMainWnd = CreateWindow(L"Dx11DemoRemoteWriteWindowClass", L"RemoteVR - Remote Renderer", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, nullptr, nullptr, hInstance, nullptr); if (!g_hMainWnd) return E_FAIL; // Create Control Window g_hControlWnd = CreateDialog(hInstance, MAKEINTRESOURCE(DLG_CONTROL), NULL, (DLGPROC)DlgProc); if (!g_hControlWnd) { return E_FAIL; } //ShowWindow(g_hMainWnd, nCmdShow); ShowWindow(g_hControlWnd, nCmdShow); UpdateWindow(g_hControlWnd); return S_OK; } LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_PAINT: hdc = BeginPaint(hWnd, &ps); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; case WM_SIZE: break; case WM_MOVE: break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } LRESULT CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_DESTROY: if (g_ServerConnected) { DisconnectServer(); } PostQuitMessage(0); break; case WM_INITDIALOG: wchar_t buf[MAX_PATH]; RtlZeroMemory(buf, MAX_PATH); swprintf_s(buf, MAX_PATH, L"%s:%s", L"127.0.0.1", HVR_NET_XFER_SERVER_PORT); SendMessage(GetDlgItem(hWnd, IDC_INPUT_SERVER_ADDR), WM_SETTEXT, (WPARAM)NULL, (LPARAM)buf); return (INT_PTR)TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDCANCEL) { if (g_ServerConnected) { DisconnectServer(); } PostQuitMessage(0); return (INT_PTR)TRUE; } else if (LOWORD(wParam) == IDC_BUTTON_CONNECT) { g_ServerConnected = !g_ServerConnected; wchar_t *btnCap = nullptr; if (g_ServerConnected) { SendMessage(GetDlgItem(hWnd, IDC_INPUT_SERVER_ADDR), EM_SETREADONLY, (WPARAM)true, (LPARAM)btnCap); btnCap = L"Disconnect"; ConnectServer(); } else { SendMessage(GetDlgItem(hWnd, IDC_INPUT_SERVER_ADDR), EM_SETREADONLY, (WPARAM)false, (LPARAM)btnCap); btnCap = L"Connect"; DisconnectServer(); } SendMessage(GetDlgItem(hWnd, IDC_BUTTON_CONNECT), WM_SETTEXT, (WPARAM)NULL, (LPARAM)btnCap); } break; } return (INT_PTR)FALSE; } bool ConnectServer() { bool isSuccess = true; ResetEvent(g_PollingTData.TerminateThreadsEvent); pHvrNetXfer = new NetXferInterface(); DWORD ThreadId; g_PollingTHandle = CreateThread(nullptr, 0, PollingThread, &g_PollingTData, 0, &ThreadId); if (nullptr == g_PollingTHandle) { isSuccess = false; wprintf(L"Fail to create polling thread"); } return isSuccess; } void DisconnectServer() { SetEvent(g_PollingTData.TerminateThreadsEvent); if (g_PollingTHandle) { WaitForMultipleObjectsEx(1, &g_PollingTHandle, TRUE, INFINITE, FALSE); CloseHandle(g_PollingTHandle); } } void GetServerAddress(wchar_t* pServerIP, wchar_t* pServerPort) { if (nullptr != pServerIP && nullptr != pServerPort) { wchar_t buf[MAX_PATH]; SendMessage(GetDlgItem(g_hControlWnd, IDC_INPUT_SERVER_ADDR), WM_GETTEXT, MAX_PATH, LPARAM(buf)); wchar_t* colon = nullptr; wchar_t* nextToken = nullptr; colon = wcstok_s(buf, L":", &nextToken); if (0 == wcslen(colon) || 0 == wcslen(nextToken)) { swprintf_s(pServerIP, MAX_PATH, L"%s", HVR_NET_XFER_SERVER_IP); swprintf_s(pServerPort, MAX_PATH, L"%s", HVR_NET_XFER_SERVER_PORT); } else { wcscpy_s(pServerIP, MAX_PATH, colon); wcscpy_s(pServerPort, MAX_PATH, nextToken); } } } DWORD WINAPI PollingThread(_In_ void* Param) { bool isSuccess = true; POLLING_THREAD_DATA* TData = reinterpret_cast<POLLING_THREAD_DATA*>(Param); wchar_t bufIP[MAX_PATH]; wchar_t bufPort[MAX_PATH]; RtlZeroMemory(bufIP, MAX_PATH); RtlZeroMemory(bufPort, MAX_PATH); GetServerAddress(bufIP, bufPort); if (pHvrNetXfer) { pHvrNetXfer->InitNetXfer(L"Client", L"TCP", bufIP, bufPort); } FILE* pFile = nullptr; UINT32 frameSize = 0; INT64 latency = 0; PBYTE pReceiveBuf = (PBYTE)malloc(HVR_NET_XFER_RECV_ELEMENT_MAX_SIZE); uint32_t receiveSize = 0; bool netXferSuccess = false; UINT64 encodeDoneFrmIdx = 0; bool connected = false; bool infoReceived = false; bool fileCreated = false; bool streamStart = false; bool closeFile = false; HVR_NET_XFER_PACKET_HEADER pktHeader; while (isSuccess && (WaitForSingleObjectEx(TData->TerminateThreadsEvent, 0, FALSE) == WAIT_TIMEOUT)) { netXferSuccess = pHvrNetXfer->GetPacket( &pktHeader, pReceiveBuf, HVR_NET_XFER_RECV_ELEMENT_MAX_SIZE); if (netXferSuccess) { switch (pktHeader.cmdInfo.s.CmdType) { case HVR_NET_XFER_PACKET_COMMAND_TYPE_GENERAL: { if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_GENERAL_COMMAND_CONNECT) { connected = true; } else if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_GENERAL_COMMAND_DISCONNECT) { connected = false; } break; } case HVR_NET_XFER_PACKET_COMMAND_TYPE_ENCODE: { if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_ENCODE_COMMAND_H264_INFO) { infoReceived = true; if (infoReceived && !fileCreated) { PHVR_NET_XFER_ENCODE_H264_INFO pH264Info = (PHVR_NET_XFER_ENCODE_H264_INFO)pReceiveBuf; SYSTEMTIME curTime = { 0 }; GetLocalTime(&curTime); wchar_t buf[MAX_PATH * 2]; ZeroMemory(buf, MAX_PATH * 2 * sizeof(wchar_t)); GetCurrentDirectory(MAX_PATH * 2, buf); swprintf_s(buf, MAX_PATH * 2, L"%s\\Encoded_%dx%d_%dfps_%04d%02d%02d_%02d%02d%02d.h264", buf, pH264Info->width, pH264Info->height, pH264Info->fps, curTime.wYear, curTime.wMonth, curTime.wDay, curTime.wHour, curTime.wMinute, curTime.wSecond); //pFile = _wfopen(buf, L"w+b"); _wfopen_s(&pFile, buf, L"w+b"); if (pFile) { fileCreated = true; } else { assert(0); } } } else if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_ENCODE_COMMAND_H264_START) { streamStart = true; } else if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_ENCODE_COMMAND_H264_END) { if (fileCreated && streamStart) { if (pFile) { fclose(pFile); } fileCreated = false; } streamStart = false; infoReceived = false; } else if (pktHeader.cmdInfo.s.u.CmdId == HVR_NET_XFER_PACKET_ENCODE_COMMAND_H264_DATA) { if (fileCreated && streamStart && pFile) { PHVR_NET_XFER_ENCODE_H264_DATA_HEADER pH264Header = (PHVR_NET_XFER_ENCODE_H264_DATA_HEADER)pReceiveBuf; fwrite(pReceiveBuf + sizeof(HVR_NET_XFER_ENCODE_H264_DATA_HEADER), 1, pH264Header->frameSize, pFile); } } break; } default: break; } } //wprintf(L"OK\n");// Debug using console } if (fileCreated && streamStart) { if (pFile) { fclose(pFile); } fileCreated = false; } streamStart = false; infoReceived = false; netXferSuccess = pHvrNetXfer->SendPacket( HVR_NET_XFER_PACKET_COMMAND_TYPE_GENERAL, HVR_NET_XFER_PACKET_GENERAL_COMMAND_DISCONNECT, nullptr, 0); pHvrNetXfer->DestroyNetXfer(); if (pReceiveBuf) { free(pReceiveBuf); } return 0; }
[ "yukun_chen@hotmail.com" ]
yukun_chen@hotmail.com
0923816457327bb14ff7f7bf2aafd384705a7d96
f7ef7dabcc31ce5e2684a028f25f059302040392
/src/gs2/friend/request/DeleteRequestRequest.hpp
ad6311277376ace40c2179a08ed1be4ca071c1fb
[]
no_license
gs2io/gs2-cpp-sdk
68bb09c0979588b850913feb07406698f661b012
8dc862e247e4cc2924a060701be783096d307a44
refs/heads/develop
2021-08-16T17:11:59.557099
2020-08-03T09:26:00
2020-08-03T09:26:10
148,787,757
0
0
null
2020-11-15T08:08:06
2018-09-14T12:50:30
C++
UTF-8
C++
false
false
7,250
hpp
/* * Copyright 2016 Game Server Services, Inc. or its affiliates. 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. * A copy of the License is located at * * http://www.apache.org/licenses/LICENSE-2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #ifndef GS2_FRIEND_CONTROL_DELETEREQUESTREQUEST_HPP_ #define GS2_FRIEND_CONTROL_DELETEREQUESTREQUEST_HPP_ #include <gs2/core/control/Gs2BasicRequest.hpp> #include <gs2/core/util/List.hpp> #include <gs2/core/util/StringHolder.hpp> #include <gs2/core/util/StandardAllocator.hpp> #include <gs2/core/external/optional/optional.hpp> #include <gs2/friend/Gs2FriendConst.hpp> #include <gs2/friend/model/model.hpp> #include <memory> namespace gs2 { namespace friend_ { /** * フレンドリクエストを削除 のリクエストモデル * * @author Game Server Services, Inc. */ class DeleteRequestRequest : public Gs2BasicRequest, public Gs2Friend { public: constexpr static const Char* const FUNCTION = ""; private: class Data : public Gs2BasicRequest::Data { public: /** アクセストークン */ optional<StringHolder> accessToken; /** ネームスペース名 */ optional<StringHolder> namespaceName; /** リクエストの送信先ユーザID */ optional<StringHolder> targetUserId; /** 重複実行回避機能に使用するID */ optional<StringHolder> duplicationAvoider; Data() = default; Data(const Data& data) : Gs2BasicRequest::Data(data), accessToken(data.accessToken), namespaceName(data.namespaceName), targetUserId(data.targetUserId), duplicationAvoider(data.duplicationAvoider) { } Data(Data&& data) = default; ~Data() = default; Data& operator=(const Data&) = delete; Data& operator=(Data&&) = delete; }; GS2_CORE_SHARED_DATA_DEFINE_MEMBERS(Data, ensureData) Gs2BasicRequest::Data& getData_() GS2_OVERRIDE { return ensureData(); } const Gs2BasicRequest::Data& getData_() const GS2_OVERRIDE { return ensureData(); } public: DeleteRequestRequest() = default; DeleteRequestRequest(const DeleteRequestRequest& deleteRequestRequest) = default; DeleteRequestRequest(DeleteRequestRequest&& deleteRequestRequest) = default; ~DeleteRequestRequest() GS2_OVERRIDE = default; DeleteRequestRequest& operator=(const DeleteRequestRequest& deleteRequestRequest) = default; DeleteRequestRequest& operator=(DeleteRequestRequest&& deleteRequestRequest) = default; DeleteRequestRequest deepCopy() const { GS2_CORE_SHARED_DATA_DEEP_COPY_IMPLEMENTATION(DeleteRequestRequest); } const DeleteRequestRequest* operator->() const { return this; } DeleteRequestRequest* operator->() { return this; } /** * アクセストークンを取得。 * * @return アクセストークン */ const gs2::optional<StringHolder>& getAccessToken() const { return ensureData().accessToken; } /** * アクセストークンを設定。 * * @param accessToken アクセストークン */ void setAccessToken(StringHolder accessToken) { ensureData().accessToken.emplace(std::move(accessToken)); } /** * アクセストークンを設定。 * * @param accessToken アクセストークン * @return this */ DeleteRequestRequest& withAccessToken(StringHolder accessToken) { setAccessToken(std::move(accessToken)); return *this; } /** * ネームスペース名を取得 * * @return ネームスペース名 */ const optional<StringHolder>& getNamespaceName() const { return ensureData().namespaceName; } /** * ネームスペース名を設定 * * @param namespaceName ネームスペース名 */ void setNamespaceName(StringHolder namespaceName) { ensureData().namespaceName.emplace(std::move(namespaceName)); } /** * ネームスペース名を設定 * * @param namespaceName ネームスペース名 */ DeleteRequestRequest& withNamespaceName(StringHolder namespaceName) { ensureData().namespaceName.emplace(std::move(namespaceName)); return *this; } /** * リクエストの送信先ユーザIDを取得 * * @return リクエストの送信先ユーザID */ const optional<StringHolder>& getTargetUserId() const { return ensureData().targetUserId; } /** * リクエストの送信先ユーザIDを設定 * * @param targetUserId リクエストの送信先ユーザID */ void setTargetUserId(StringHolder targetUserId) { ensureData().targetUserId.emplace(std::move(targetUserId)); } /** * リクエストの送信先ユーザIDを設定 * * @param targetUserId リクエストの送信先ユーザID */ DeleteRequestRequest& withTargetUserId(StringHolder targetUserId) { ensureData().targetUserId.emplace(std::move(targetUserId)); return *this; } /** * 重複実行回避機能に使用するIDを取得 * * @return 重複実行回避機能に使用するID */ const optional<StringHolder>& getDuplicationAvoider() const { return ensureData().duplicationAvoider; } /** * 重複実行回避機能に使用するIDを設定 * * @param duplicationAvoider 重複実行回避機能に使用するID */ void setDuplicationAvoider(StringHolder duplicationAvoider) { ensureData().duplicationAvoider.emplace(std::move(duplicationAvoider)); } /** * 重複実行回避機能に使用するIDを設定 * * @param duplicationAvoider 重複実行回避機能に使用するID */ DeleteRequestRequest& withDuplicationAvoider(StringHolder duplicationAvoider) { ensureData().duplicationAvoider.emplace(std::move(duplicationAvoider)); return *this; } /** * GS2認証クライアントIDを設定。 * 通常は自動的に計算されるため、この値を設定する必要はありません。 * * @param gs2ClientId GS2認証クライアントID */ DeleteRequestRequest& withGs2ClientId(StringHolder gs2ClientId) { setGs2ClientId(std::move(gs2ClientId)); return *this; } /** * GS2リクエストIDを設定。 * * @param gs2RequestId GS2リクエストID */ DeleteRequestRequest& withRequestId(StringHolder gs2RequestId) { setRequestId(std::move(gs2RequestId)); return *this; } }; } } #endif //GS2_FRIEND_CONTROL_DELETEREQUESTREQUEST_HPP_
[ "imatake_haruhiko@gs2.io" ]
imatake_haruhiko@gs2.io
8e5f93a2d20a194d2a1b390527d7a153be0b7d38
b9ba37afe2d79814c2e3e4798add49aadf8ed7b2
/Theoretical Practical/TP1/parque.cpp
5b6448d03155b7a353d8397fcb2abbcf45f9cb64
[]
no_license
beatrizlopesdossantos/FEUP-AEDA
aed530f240add2d955feb3d846fcd35eba446768
9a64cbf0d8ca0e9009d5658c2203afaeb73e108c
refs/heads/master
2023-03-04T15:57:50.085482
2021-02-17T23:02:07
2021-02-17T23:02:07
339,875,214
0
0
null
null
null
null
UTF-8
C++
false
false
1,934
cpp
#include "parque.h" using namespace std; ParqueEstacionamento::ParqueEstacionamento(unsigned lot, unsigned nMaxCli): lotacao(lot), numMaximoClientes(nMaxCli) { vagas=lot; } unsigned ParqueEstacionamento::getNumLugares() const { return lotacao; } unsigned ParqueEstacionamento::getNumMaximoClientes() const { return numMaximoClientes; } int ParqueEstacionamento::posicaoCliente(const string & nome) const { for (int i = 0; i < clientes.size(); i++) { if (clientes[i].nome == nome) { return i; } } return -1; } bool ParqueEstacionamento::adicionaCliente(const string & nome) { if (clientes.size() == numMaximoClientes) { return false; } if (posicaoCliente(nome) != -1) { return false; } InfoCartao info; info.nome = nome; info.presente=false; clientes.push_back(info); return true; } bool ParqueEstacionamento::entrar(const string & nome) { int pos = posicaoCliente(nome); if (pos == -1 || clientes[pos].presente == true || vagas == 0) { return false; } clientes[pos].presente = true; vagas--; return true; } bool ParqueEstacionamento::retiraCliente(const string & nome) { for (auto it = clientes.begin(); it != clientes.end(); it++) if ( (*it).nome == nome ) { if ( (*it).presente == false ) { clientes.erase(it); return true; } else return false; } return false; } bool ParqueEstacionamento::sair(const string & nome) { int pos = posicaoCliente(nome); if (pos == -1 || !clientes[pos].presente) { return false; } clientes[pos].presente = false; vagas++; return true; } unsigned ParqueEstacionamento::getNumLugaresOcupados() const { return numMaximoClientes-lotacao; } unsigned ParqueEstacionamento::getNumClientesAtuais() const { return clientes.size(); }
[ "mbrlopes.santos@gmail.com" ]
mbrlopes.santos@gmail.com
6570c7dcb7a8347f005b6bb5cb8ac455605f03f8
9068d0b9762c872be4f4cccc11240a66b0757bd8
/Arduino/libraries/eHealth/eHealth.cpp
38864aeead3ec20b57c303848edaabd671f5e996
[]
no_license
cthylhu/Biofeedback_real-time-plotting
f674aceff8d6a39833c884fc44849b7d85c8c207
e4e69ad4ec2b6eade2ca263e1386a33c68334d61
refs/heads/master
2020-06-04T10:34:51.449207
2015-02-13T23:18:42
2015-02-13T23:18:42
28,119,976
0
0
null
null
null
null
UTF-8
C++
false
false
33,020
cpp
/* * eHealth sensor platform for Arduino and Raspberry from Cooking-hacks. * * Description: "The e-Health Sensor Shield allows Arduino and Raspberry Pi * users to perform biometric and medical applications by using 9 different * sensors: Pulse and Oxygen in Blood Sensor (SPO2), Airflow Sensor (Breathing), * Body Temperature, Electrocardiogram Sensor (ECG), Glucometer, Galvanic Skin * Response Sensor (GSR - Sweating), Blood Pressure (Sphygmomanometer) and * Patient Position (Accelerometer)." * * Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L. * http://www.libelium.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * Version 2.0 * Author: Luis Martín & Ahmad Saad */ // include this library's description file #include "eHealth.h" //*************************************************************** // Accelerometer Variables and definitions * //*************************************************************** //! not the wire library, can't use pull-ups #include "utils/i2c.h" //! Breakout board defaults to 1, set to 0 if SA0 jumper is set #define SA0 1 #if SA0 #define MMA8452_ADDRESS 0x1D //! SA0 is high, 0x1C if low #else #define MMA8452_ADDRESS 0x1C #endif #define int1Pin 2 #define int2Pin 3 //! Set the scale below either 2, 4 or 8. const byte scale = 2; //! Set the output data rate below. Value should be between 0 and 7. //! 0=800Hz, 1=400, 2=200, 3=100, 4=50, 5=12.5, 6=6.25, 7=1.56 const byte dataRate = 0; //*************************************************************** // Constructor of the class * //*************************************************************** //! Function that handles the creation and setup of instances eHealthClass::eHealthClass(void) { /*void constructor*/ } //*************************************************************** // Public Methods * //*************************************************************** //!****************************************************************************** //! Name: initPositionSensor() * //! Description: Initializes the position sensor and configure some values. * //! Param : void * //! Returns: void * //! Example: eHealth.initPositionSensor(); * //!****************************************************************************** void eHealthClass::initPositionSensor(void) { byte c; /* Set up the interrupt pins, they're set as active high, push-pull */ pinMode(int1Pin, INPUT); digitalWrite(int1Pin, LOW); pinMode(int2Pin, INPUT); digitalWrite(int2Pin, LOW); /* Read the WHO_AM_I register, this is a good test of communication */ c = readRegister(0x0D); // Read WHO_AM_I register if (c == 0x2A) { // WHO_AM_I should always be 0x2A initMMA8452(scale, dataRate); // init the accelerometer if communication is good Serial.println("MMA8452Q is online..."); } else { Serial.print("Could not connect to MMA8452Q: 0x"); Serial.println(c, HEX); //while (1); // Loop forever if communication doesn't happen } } //!****************************************************************************** //! Name: readBloodPressureSensor() * //! Description: Initializes the BloodPressureSensor sensor. * //! Param : void * //! Returns: void * //! Example: eHealth.initBloodPressureSensor(); * //!****************************************************************************** void eHealthClass::readBloodPressureSensor(void) { unsigned char _data; int ia=0; length=0; Serial.begin(19200); Serial.write(0xAA); delayMicroseconds(1); Serial.write(0x55); delayMicroseconds(1); Serial.write(0x88); delay(2500); Serial.print("\n"); if (Serial.available() > 0) { // The protocol sends the measures for (int i = 0; i<4; i++){ // Read four dummy data Serial.read(); } while(_data != 0xD1){ if (ia==0){ _data = Serial.read(); } bloodPressureDataVector[length].year = swap(_data); bloodPressureDataVector[length].month = swap(Serial.read()); bloodPressureDataVector[length].day = swap(Serial.read()); bloodPressureDataVector[length].hour = swap(Serial.read()); bloodPressureDataVector[length].minutes = swap(Serial.read()); bloodPressureDataVector[length].systolic = swap(Serial.read()); bloodPressureDataVector[length].diastolic = swap(Serial.read()); bloodPressureDataVector[length].pulse = swap(Serial.read()); length++; ia=1; for (int i = 0; i<4; i++){ // CheckSum 1 Serial.read(); } _data = Serial.read(); } for (int i = 0; i<3; i++){ // CheckSum 2 Serial.read(); } } } //!****************************************************************************** //! Name: initPulsioximeter() * //! Description: Initializes the pulsioximeter sensor. * //! Param : void * //! Returns: void * //! Example: eHealth.initPulsioximeter(); * //!****************************************************************************** void eHealthClass::initPulsioximeter(void) { // Configuring digital pins like INPUTS pinMode(13, INPUT); pinMode(12, INPUT); pinMode(11, INPUT); pinMode(10, INPUT); pinMode( 9, INPUT); pinMode( 8, INPUT); pinMode( 7, INPUT); pinMode( 6, INPUT); // attach a PinChange Interrupt to our pin on the rising edge } //!****************************************************************************** //! Name: getTemperature() * //! Description: Returns the corporal temperature. * //! Param : void * //! Returns: float with the corporal temperature value. * //! Example: float temperature = eHealth.getTemperature(); * //!****************************************************************************** float eHealthClass::getTemperature(void) { //Local variables float Temperature; //Corporal Temperature float Resistance; //Resistance of sensor. float ganancia=5.0; float Vcc=3.3; float RefTension=3.0; // Voltage Reference of Wheatstone bridge. float Ra=4700.0; //Wheatstone bridge resistance. float Rc=4700.0; //Wheatstone bridge resistance. float Rb=821.0; //Wheatstone bridge resistance. int sensorValue = analogRead(A3); float voltage2=((float)sensorValue*Vcc)/1023; // binary to voltage conversion // Wheatstone bridge output voltage. voltage2=voltage2/ganancia; // Resistance sensor calculate float aux=(voltage2/RefTension)+Rb/(Rb+Ra); Resistance=Rc*aux/(1-aux); if (Resistance >=1822.8) { // if temperature between 25ºC and 29.9ºC. R(tª)=6638.20457*(0.95768)^t Temperature=log(Resistance/6638.20457)/log(0.95768); } else { if (Resistance >=1477.1){ // if temperature between 30ºC and 34.9ºC. R(tª)=6403.49306*(0.95883)^t Temperature=log(Resistance/6403.49306)/log(0.95883); } else { if (Resistance >=1204.8){ // if temperature between 35ºC and 39.9ºC. R(tª)=6118.01620*(0.96008)^t Temperature=log(Resistance/6118.01620)/log(0.96008); } else{ if (Resistance >=988.1){ // if temperature between 40ºC and 44.9ºC. R(tª)=5859.06368*(0.96112)^t Temperature=log(Resistance/5859.06368)/log(0.96112); } else { if (Resistance >=811.7){ // if temperature between 45ºC and 50ºC. R(tª)=5575.94572*(0.96218)^t Temperature=log(Resistance/5575.94572)/log(0.96218); } } } } } return Temperature; } //!****************************************************************************** //! Name: getOxygenSaturation() * //! Description: Returns the oxygen saturation in blood in percent. * //! Param : void * //! Returns: int with the oxygen saturation value * //! Example: int SPO2 = eHealth.getOxygenSaturation(); * //!****************************************************************************** int eHealthClass::getOxygenSaturation(void) { return SPO2; } //!****************************************************************************** //! Name: getBPM() * //! Description: Returns the heart beats per minute. * //! Param : void * //! Returns: int with the beats per minute * //! Example: int BPM = eHealth.getBPM(); * //!****************************************************************************** int eHealthClass::getBPM(void) { return BPM; } //!****************************************************************************** //! Name: getSkinConductance() * //! Description: Returns the value of skin conductance. * //! Param : void * //! Returns: float with the value of skin conductance * //! Example: float conductance = eHealth.getSkinConductance(); * //!****************************************************************************** float eHealthClass::getSkinConductance(void) { // Local variable declaration. float resistance; float conductance; delay(1); // Read an analogic value from analogic2 pin. float sensorValue = analogRead(A2); float voltage = sensorValue*5.0/1023; conductance = 2*((voltage - 0.5) / 100000); // Conductance calculation resistance = 1 / conductance; conductance = conductance * 1000000; delay(1); if (conductance > 1.0) return conductance; else return -1.0; } //!****************************************************************************** //! Name: getSkinResistance() * //! Description: Returns the value of skin resistance. * //! Param : void * //! Returns: float with the value of skin resistance * //! Example: float resistance = eHealth.getSkinResistance(); * //!****************************************************************************** float eHealthClass::getSkinResistance(void) { // Local variable declaration. float resistance; float conductance; // Read an analogic value from analogic2 pin. float sensorValue = analogRead(A2); float voltage = (sensorValue * 5.0) / 1023; delay(2); conductance = 2*((voltage - 0.5) / 100000); //Conductance calcultacion resistance = 1 / conductance; delay(2); if (resistance > 1.0 ) return resistance; else return -1.0; } //!****************************************************************************** //! Name: getSkinConductanceVoltage() * //! Description: Returns the skin conductance value in voltage . * //! Param : void * //! Returns: float with the skin conductance value in voltage * //! Example: float volt = eHealth.getSkinConductanceVoltage(); * //!****************************************************************************** float eHealthClass::getSkinConductanceVoltage(void) { delay(2); //Read analogic value from analogic2 pin. int sensorValue = analogRead(A2); //Convert the readed value to voltage. float voltage = ( sensorValue * 5.0 ) / 1023; delay(2); return voltage; } //!****************************************************************************** //! Name: getECG() * //! Description: Returns an analogic value to represent the ECG. * //! Param : void * //! Returns: float with the ECG value in voltage * //! Example: float volt = eHealth.getECG(); * //!****************************************************************************** float eHealthClass::getECG(void) { float analog0; // Read from analogic in. analog0=analogRead(0); // binary to voltage conversion return analog0 = (float)analog0 * 5 / 1023.0; } //!****************************************************************************** //! Name: getEMG() * //! Description: Returns an analogic value to represent the EMG. * //! Param : void * //! Returns: float with the EMG value in voltage * //! Example: float volt = eHealth.getEMG(); * //!****************************************************************************** int eHealthClass::getEMG(void) { int analog0; // Read from analogic in. analog0=analogRead(0); // binary to voltage conversion return analog0; } //!****************************************************************************** //! Name: getBodyPosition() * //! Description: Returns the current body position. * //! Param : void * //! Returns: uint8_t with the the position of the pacient. * //! Example: uint8_t position = eHealth.getBodyPosition(); * //!****************************************************************************** uint8_t eHealthClass::getBodyPosition(void) { static byte source; /* If int1 goes high, all data registers have new data */ if (digitalRead(int1Pin)) {// Interrupt pin, should probably attach to interrupt function readRegisters(0x01, 6, &data[0]); // Read the six data registers into data array. /* For loop to calculate 12-bit ADC and g value for each axis */ for (int i=0; i<6; i+=2) { accelCount[i/2] = ((data[i] << 8) | data[i+1]) >> 4; // Turn the MSB and LSB into a 12-bit value if (data[i] > 0x7F) { accelCount[i/2] = ~accelCount[i/2] + 1; accelCount[i/2] *= -1; // Transform into negative 2's complement # } accel[i/2] = (float) accelCount[i/2]/((1<<12)/(2*scale)); // get actual g value, this depends on scale being set } } /* If int2 goes high, either p/l has changed or there's been a single/double tap */ if (digitalRead(int2Pin)) { source = readRegister(0x0C); // Read the interrupt source reg. if ((source & 0x10)==0x10) // If the p/l bit is set, go check those registers portraitLandscapeHandler(); delay(50); // Delay here for a little printing visibility, make it longer, or delete it } delay(100); return bodyPos; } //!****************************************************************************** //! Name: getGData( void ) * //! Description: Get g data for X, Y, Z Axis * //! Param : void * //! Returns: float with g data. * //! Example: float gData = eHealth.getGdata(); * //!****************************************************************************** void eHealthClass::getGData( void ) { //float gData [3]; if (digitalRead(int1Pin)) {// Interrupt pin, should probably attach to interrupt function readRegisters(0x01, 6, &data[0]); // Read the six data registers into data array. /* For loop to calculate 12-bit ADC and g value for each axis */ for (int i=0; i<6; i+=2) { accelCount[i/2] = ((data[i] << 8) | data[i+1]) >> 4; // Turn the MSB and LSB into a 12-bit value if (data[i] > 0x7F) { accelCount[i/2] = ~accelCount[i/2] + 1; accelCount[i/2] *= -1; // Transform into negative 2's complement # } accel[i/2] = (float) accelCount[i/2]/((1<<12)/(2*scale)); // get actual g value, this depends on scale being set gData[i/2] = accel[i/2]; } } //return 0; } //!****************************************************************************** //! Name: getSystolicPressure() * //! Description: Returns the value of the systolic pressure. * //! Param : int * //! Returns: int with the systolic pressure. * //! Example: int systolic = eHealth.getSystolicPressure(1); * //!****************************************************************************** int eHealthClass::getSystolicPressure(int i) { return bloodPressureDataVector[i].systolic; } //!****************************************************************************** //! Name: getDiastolicPressure() * //! Description: Returns the value of the diastolic pressure. * //! Param : int * //! Returns: int with the diastolic pressure. * //! Example: int diastolic = eHealth.getDiastolicPressure(1); * //!****************************************************************************** int eHealthClass::getDiastolicPressure(int i) { return bloodPressureDataVector[i].diastolic; } //!****************************************************************************** //! Name: getAirFlow() * //! Description: Returns an analogic value to represent the air flow. * //! Param : void * //! Returns: int with the airFlow value (0-1023). * //! Example: int airFlow = eHealth.getAirFlow(); * //!****************************************************************************** int eHealthClass::getAirFlow(void) { int airFlow = analogRead(A1); return airFlow; } //!****************************************************************************** //! Name: printPosition() * //! Description: Returns an analogic value to represent the air flow. * //! Param : uint8_t position : the current body position. * //! Returns: void * //! Example: eHealth.printPosition(position); * //!****************************************************************************** void eHealthClass::printPosition( uint8_t position ) { if (position == 1) { Serial.println("Supine position"); } else if (position == 2) { Serial.println("Left lateral decubitus"); } else if (position == 3) { Serial.println("Rigth lateral decubitus"); } else if (position == 4) { Serial.println("Prone position"); } else if (position == 5) { Serial.println("Stand or sit position"); } else { Serial.println("non-defined position"); } } //!****************************************************************************** //! Name: readPulsioximeter() * //! Description: It reads a value from pulsioximeter sensor. * //! Param : void * //! Returns: void * //! Example: readPulsioximeter(); * //!****************************************************************************** void eHealthClass::readPulsioximeter(void) { uint8_t digito[] = {0,0,0,0,0,0}; uint8_t A = 0; uint8_t B = 0; uint8_t C = 0; uint8_t D = 0; uint8_t E = 0; uint8_t F = 0; uint8_t G = 0; for (int i = 0; i<6 ; i++) { // read all the led's of the module A = !digitalRead(13); B = !digitalRead(12); C = !digitalRead(11); D = !digitalRead(10); E = !digitalRead(9); F = !digitalRead(8); G = !digitalRead(7); digito[i] = segToNumber(A, B, C ,D ,E, F,G); delayMicroseconds(2800); //2800 microseconds } SPO2 = 10 * digito[5] + digito[4]; BPM = 100 * digito[2] + 10 * digito[1] + digito[0]; } //!****************************************************************************** //! Name: airflowWave() * //! Description: It prints air flow wave form in the serial monitor * //! Param : int air with the analogic value * //! Returns: void * //! Example: eHealth.airflowWave(); * //!****************************************************************************** void eHealthClass::airFlowWave(int air) { for (int i=0; i < (air / 5) ; i ++) { Serial.print(".."); } Serial.print(".."); Serial.print("\n"); delay(25); } //!****************************************************************************** //! Name: readGlucometer() * //! Description: It reads the data stored in the glucometer * //! Param : void * //! Returns: void * //! Example: eHealth.readGlucometer(); * //!****************************************************************************** void eHealthClass::readGlucometer(void) { // Configuring digital pins like INPUTS pinMode(5, OUTPUT); digitalWrite(5, HIGH); delay(100); Serial.begin(1200); delay(100); Serial.print("U"); // Start communication command. delay(1000); // Wait while receiving data. Serial.print("\n"); if (Serial.available() > 0) { length = Serial.read();// The protocol sends the number of measures Serial.read(); // Read one dummy data for (int i = 0; i<length; i++) { // The protocol sends data in this order glucoseDataVector[i].year = Serial.read(); glucoseDataVector[i].month = Serial.read(); glucoseDataVector[i].day = Serial.read(); glucoseDataVector[i].hour = Serial.read(); glucoseDataVector[i].minutes = Serial.read(); Serial.read(); // Byte of separation must be 0x00. glucoseDataVector[i].glucose = Serial.read(); glucoseDataVector[i].meridian = Serial.read(); Serial.read(); // CheckSum 1 Serial.read(); // CheckSum 2 } } digitalWrite(5, LOW); } //!****************************************************************************** //! Name: getGlucometerLength() * //! Description: it returns the number of data stored in the glucometer * //! Param : void * //! Returns: uint8_t with length * //! Example: int length = eHealth.getGlucometerLength(); * //!****************************************************************************** uint8_t eHealthClass::getGlucometerLength(void) { return length; } //!****************************************************************************** //! Name: getBloodPressureLength() * //! Description: it returns the number of data stored in * //! the blood pressure sensor * //! Param : void * //! Returns: uint8_t with length * //! Example: int length = eHealth.getBloodPressureLength(); * //!****************************************************************************** uint8_t eHealthClass::getBloodPressureLength(void) { return length; } //!****************************************************************************** //! Name: numberToMonth() * //! Description: Convert month variable from numeric to character. * //! Param : int month in numerical format * //! Returns: String with the month characters (January, February...). * //! Example: Serial.print(eHealth.numberToMonth(month)); * //!****************************************************************************** String eHealthClass::numberToMonth(int month) { if (month == 1) return "January"; else if (month == 2) return "February"; else if (month == 3) return "March"; else if (month == 4) return "April"; else if (month == 5) return "May"; else if (month == 6) return "June"; else if (month == 7) return "July"; else if (month == 8) return "August"; else if (month == 9) return "September"; else if (month == 10) return "October"; else if (month == 11) return "November"; else return "December"; } //!****************************************************************************** //! Name: version() * //! Description: It check the version of the library * //! Param : void * //! Returns: void * //! Example: eHealth.version(); * //!****************************************************************************** int eHealthClass::version(void) { return 2.0; } //*************************************************************** // Private Methods * //*************************************************************** //! This function will read the p/l source register and //! print what direction the sensor is now facing */ void eHealthClass::portraitLandscapeHandler() { byte pl = readRegister(0x10); // Reads the PL_STATUS register switch((pl&0x06)>>1) // Check on the LAPO[1:0] bits { case 0: position[0] = 0; break; case 1: position[0] = 1; break; case 2: position[0] = 2; break; case 3: position[0] = 3; break; } if (pl&0x01) // Check the BAFRO bit position[1] = 0; else position[1] = 1; if (pl&0x40) // Check the LO bit position[2] = 0; else position[2] = 1; bodyPosition(); } /*******************************************************************************************************/ //! Initialize the MMA8452 registers. void eHealthClass::initMMA8452(byte fsr, byte dataRate) { MMA8452Standby(); // Must be in standby to change registers /* Set up the full scale range to 2, 4, or 8g. */ if ((fsr==2)||(fsr==4)||(fsr==8)) writeRegister(0x0E, fsr >> 2); else writeRegister(0x0E, 0); /* Setup the 3 data rate bits, from 0 to 7 */ writeRegister(0x2A, readRegister(0x2A) & ~(0x38)); if (dataRate <= 7) writeRegister(0x2A, readRegister(0x2A) | (dataRate << 3)); /* Set up portrait/landscap registers */ writeRegister(0x11, 0x40); // Enable P/L writeRegister(0x13, 0x14); // 29deg z-lock, writeRegister(0x14, 0x84); // 45deg thresh, 14deg hyst writeRegister(0x12, 0x05); // debounce counter at 100ms /* Set up single and double tap */ writeRegister(0x21, 0x7F); // enable single/double taps on all axes writeRegister(0x23, 0x20); // x thresh at 2g writeRegister(0x24, 0x20); // y thresh at 2g writeRegister(0x25, 0x8); // z thresh at .5g writeRegister(0x26, 0x30); // 60ms time limit, the min/max here is very dependent on output data rate writeRegister(0x27, 0x28); // 200ms between taps min writeRegister(0x28, 0xFF); // 1.275s (max value) between taps max /* Set up interrupt 1 and 2 */ writeRegister(0x2C, 0x02); // Active high, push-pull writeRegister(0x2D, 0x19); // DRDY int enabled, P/L enabled writeRegister(0x2E, 0x01); // DRDY on INT1, P/L on INT2 MMA8452Active(); // Set to active to start reading } /*******************************************************************************************************/ //! Sets the MMA8452 to standby mode. It must be in standby to change most register settings. void eHealthClass::MMA8452Standby() { byte c = readRegister(0x2A); writeRegister(0x2A, c & ~(0x01)); } /*******************************************************************************************************/ //! Sets the MMA8452 to active mode. Needs to be in this mode to output data void eHealthClass::MMA8452Active() { byte c = readRegister(0x2A); writeRegister(0x2A, c | 0x01); } /*******************************************************************************************************/ //! Read i registers sequentially, starting at address into the dest byte array. void eHealthClass::readRegisters(byte address, int i, byte * dest) { i2cSendStart(); i2cWaitForComplete(); i2cSendByte((MMA8452_ADDRESS<<1)); // write 0xB4 i2cWaitForComplete(); i2cSendByte(address); // write register address i2cWaitForComplete(); i2cSendStart(); i2cSendByte((MMA8452_ADDRESS<<1)|0x01); // write 0xB5 i2cWaitForComplete(); for (int j=0; j<i; j++) { i2cReceiveByte(TRUE); i2cWaitForComplete(); dest[j] = i2cGetReceivedByte(); // Get MSB result } i2cWaitForComplete(); i2cSendStop(); cbi(TWCR, TWEN);// Disable TWI sbi(TWCR, TWEN);// Enable TWI } /*******************************************************************************************************/ //! Read a single byte from address and return it as a byte. byte eHealthClass::readRegister(uint8_t address) { byte data; i2cSendStart(); i2cWaitForComplete(); i2cSendByte((MMA8452_ADDRESS<<1)); // write 0xB4 i2cWaitForComplete(); i2cSendByte(address); // write register address i2cWaitForComplete(); i2cSendStart(); i2cSendByte((MMA8452_ADDRESS<<1)|0x01); // write 0xB5 i2cWaitForComplete(); i2cReceiveByte(TRUE); i2cWaitForComplete(); data = i2cGetReceivedByte(); // Get MSB result i2cWaitForComplete(); i2cSendStop(); cbi(TWCR, TWEN); // Disable TWI sbi(TWCR, TWEN); // Enable TWI return data; } /*******************************************************************************************************/ //! Writes a single byte (data) into address void eHealthClass::writeRegister(unsigned char address, unsigned char data) { i2cSendStart(); i2cWaitForComplete(); i2cSendByte((MMA8452_ADDRESS<<1));// write 0xB4 i2cWaitForComplete(); i2cSendByte(address);// write register address i2cWaitForComplete(); i2cSendByte(data); i2cWaitForComplete(); i2cSendStop(); } /*******************************************************************************************************/ //! Assigns a value depending on body position. void eHealthClass::bodyPosition( void ) { if (( position[0] == 0 ) && (position[1] == 1) && (position [2] == 0)) { bodyPos = 1; } else if (( position[0] == 1 ) && (position[1] == 1) && (position [2] == 0)) { bodyPos = 1; } else if (( position[0] == 3 ) && (position[1] == 1) && (position [2] == 0)) { bodyPos = 1; } else if (( position[0] == 2 ) && (position[1] == 0) && (position [2] == 0)) { bodyPos = 1; } else if (( position[0] == 2 ) && (position[1] == 1) && (position [2] == 1)) { bodyPos = 1; } else if (( position[0] == 2 ) && (position[1] == 1) && (position [2] == 0)) { bodyPos = 1; } else if (( position[0] == 0 ) && (position[1] == 1) && (position [2] == 1)) { bodyPos = 2; } else if (( position[0] == 0 ) && (position[1] == 0) && (position [2] == 1)) { bodyPos = 2; } else if (( position[0] == 1 ) && (position[1] == 1) && (position [2] == 1)) { bodyPos = 3; } else if (( position[0] == 1 ) && (position[1] == 0) && (position [2] == 1)) { bodyPos = 3; } else if (( position[0] == 1 ) && (position[1] == 0) && (position [2] == 0)) { bodyPos = 4; } else if (( position[0] == 3 ) && (position[1] == 0) && (position [2] == 0)) { bodyPos = 4; } else if (( position[0] == 3 ) && (position[1] == 0) && (position [2] == 1)) { bodyPos = 5; } else if (( position[0] == 3 ) && (position[1] == 1) && (position [2] == 1)) { bodyPos = 5; } else if (( position[0] == 2 ) && (position[1] == 0) && (position [2] == 1)) { bodyPos = 5; } else { bodyPos = 6; } } /*******************************************************************************************************/ //! Converts from 7 segments to number. uint8_t eHealthClass::segToNumber(uint8_t A, uint8_t B, uint8_t C, uint8_t D, uint8_t E, uint8_t F, uint8_t G ) { if ((A == 1) && (B == 1) && (C == 1) && (D == 0) && (E == 1) && (F == 1) && (G == 1)) { return 0; } else if ((A == 0) && (B == 1) && (C == 0) && (D == 0) && (E == 1) && (F == 0) && (G == 0)) { return 1; } else if ((A == 1) && (B == 1) && (C == 0) && (D == 1) && (E == 0) && (F == 1) && (G == 1)) { return 2; } else if ((A == 1) && (B == 1) && (C == 0) && (D == 1) && (E == 1) && (F == 0) && (G == 1)) { return 3; } else if ((A == 0) && (B == 1) && (C == 1) && (D == 1) && (E == 1) && (F == 0) && (G == 0)) { return 4; } else if ((A == 1) && (B == 0) && (C == 1) && (D == 1) && (E == 1) && (F == 0) && (G == 1)) { return 5; } else if ((A == 1) && (B == 0) && (C == 1) && (D == 1) && (E == 1) && (F == 1) && (G == 1)) { return 6; } else if ((A == 1) && (B == 1) && (C == 0) && (D == 0) && (E == 1) && (F == 0) && (G == 0)) { return 7; } else if ((A == 1) && (B == 1) && (C == 1) && (D == 1) && (E == 1) && (F == 1) && (G == 1)) { return 8; } else if ((A == 1) && (B == 1) && (C == 1) && (D == 1) && (E == 1) && (F == 0) && (G == 1)) { return 9; } else { return 0; } } /*******************************************************************************************************/ //! Swap data for blood pressure mesure char eHealthClass::swap(char _data) { char highBits = (_data & 0xF0) / 16; char lowBits = (_data & 0x0F) * 16; return ~(highBits + lowBits); } /*******************************************************************************************************/ //*************************************************************** // Preinstantiate Objects * //*************************************************************** eHealthClass eHealth = eHealthClass();
[ "cyl35@cornell.edu" ]
cyl35@cornell.edu
926434727b4c0e62e60f582dc027898c14bdd78e
bdc11b8ffdff4d6fd7c8f34eb1cd1e0609edf9e9
/ofApp.cpp
7b8bd5aa829007260306c789a3329272f5bd6710
[]
no_license
junkiyoshi/Insta20170919
a4e02467ae4379ae83c865e5bca75c4d7d2013a7
f2d2f628fd051fe7f24fb4a28ac68ec867fa72da
refs/heads/master
2021-06-29T19:57:27.687280
2017-09-19T08:42:27
2017-09-19T08:42:27
104,049,590
0
0
null
null
null
null
UTF-8
C++
false
false
2,394
cpp
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup(){ ofSetFrameRate(30); ofBackground(0); ofSetWindowTitle("Insta"); ofEnableDepthTest(); ofEnableSmoothing(); this->size = 30; bool flg = true; for (float y = -ofGetHeight(); y < ofGetHeight(); y += this->size + this->size / 2) { for (float x = -ofGetWidth(); x < ofGetWidth(); x += this->size * sqrt(3)) { ofVec3f location; if (flg) { location = ofVec3f(x, y, 0); } else { location = ofVec3f(ofVec3f(x + (this->size * sqrt(3) / 2), y, 0)); } ofColor body_color(255, 0, 0); this->particles.push_back(new Particle(location, this->size, body_color)); } flg = !flg; } } //-------------------------------------------------------------- void ofApp::update(){ for (Particle* p : this->particles) { float height = 300 * ofNoise(p->getLocation().x * 0.0025, p->getLocation().y * 0.0025, ofGetFrameNum() * 0.005); p->update(height); } } //-------------------------------------------------------------- void ofApp::draw() { this->cam.begin(); for (Particle* p : this->particles) { p->draw(); } this->cam.end(); } //-------------------------------------------------------------- void ofApp::keyPressed(int key){ } //-------------------------------------------------------------- void ofApp::keyReleased(int key){ } //-------------------------------------------------------------- void ofApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseEntered(int x, int y){ } //-------------------------------------------------------------- void ofApp::mouseExited(int x, int y){ } //-------------------------------------------------------------- void ofApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void ofApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ }
[ "nakauchi.k@g-hits.co.jp" ]
nakauchi.k@g-hits.co.jp
41b47ca80c569eb443fdaecf1fd84b6458049c14
bcd161e9ba694f0b0a67466fa475e71402d15118
/Binomial Queue/BQ.cpp
82fd60352f5e76b2dce4511431fe97bc79cd2e01
[]
no_license
ydafalla/Data-Structures
3d6354996a7e976ed6c1e798c54269101a8d2df0
3aa14a793b0c599a9eef813e75903a2ebf61b690
refs/heads/master
2020-04-16T08:21:17.534439
2019-01-25T20:25:37
2019-01-25T20:25:37
165,421,867
0
0
null
null
null
null
UTF-8
C++
false
false
6,745
cpp
#include "BQ.h" BQ::BQ() { root=NULL; } BQ::~BQ() { Flush(root); } void BQ::Flush(node* rt) { node* temp=rt; if(temp==NULL) return ; if(temp->firstChild==NULL && temp->rSibling==NULL) delete temp; else { Flush(temp->firstChild); Flush(temp->rSibling); delete temp; } } node* BQ::GetRoot() { return root; } void BQ::SetRoot(node* rt) { root=rt; } int BQ::Size(node* rt) { node* temp=rt; int count=1; while(temp->rSibling!=NULL) { count++; temp=temp->rSibling; } return count; } void BQ::Insert(node* rt,int x) { node* newNode=new node; newNode->data=x; newNode->lSibling=newNode; newNode->rSibling=newNode->firstChild=NULL; newNode->order=0; SetRoot(Concate(newNode,rt)); } node* BQ::Merge(node* T1,node* T2) { if(T1->order!=T2->order) return NULL; else { if(T1->data<=T2->data) { int k=T1->order; if(k==0) { T1->firstChild=T2; T1->order=1; return T1; } if(k>0) { T2->lSibling=T1->firstChild->lSibling; T2->lSibling->rSibling=T2; T1->firstChild->lSibling=T2; T1->order=T1->order+1; return T1; } } else return Merge(T2,T1); } } node* BQ::Concate(node* Q1,node* Q2) { if(Q1==NULL) return Q2; if(Q2==NULL) return Q1; int s1=Size(Q1); int s2=Size(Q2); int i=0,j=0; node* a[s1]; node* b[s2]; node* c=NULL; node* Q3=NULL; node* temp=Q1; while(temp!=NULL) { a[i]=temp; temp=temp->rSibling; i++; } i=0; temp=Q2; while(temp!=NULL) { b[i]=temp; temp=temp->rSibling; i++; } for(i=0;i<s1;i++) { a[i]->lSibling=a[i]; a[i]->rSibling=NULL; } for(i=0;i<s2;i++) { b[i]->lSibling=b[i]; b[i]->rSibling=NULL; } i=0; while(i<s1 && j<s2) { if(a[i]->order < b[j]->order) { if(c==NULL) { Q3=Add(a[i],Q3); i++; } else { if(c->order < a[i]->order) { Q3=Add(c,Q3); c=NULL; Q3=Add(a[i],Q3); i++; } else { if(c->order==a[i]->order) { c=Merge(a[i],c); i++; } } } } else { if(a[i]->order == b[j]->order) { if(c==NULL) { c=Merge(a[i],b[j]); i++; j++; } else { if(c->order<a[i]->order) { Q3=Add(c,Q3); c=Merge(a[i],b[j]); i++; j++; } else { if(c->order==a[i]->order) { Q3=Add(c,Q3); c=Merge(a[i],b[j]); i++; j++; } } } } else { if(c==NULL) { Q3=Add(b[j],Q3); j++; } else { if(c->order < b[j]->order) { Q3=Add(c,Q3); c=NULL; Q3=Add(b[j],Q3); j++; } else { if(c->order==b[j]->order) { c=Merge(b[j],c); j++; } } } } } } while(i<s1) { if(c==NULL) { Q3=Add(a[i],Q3); i++; } else { if(c->order<a[i]->order) { Q3=Add(c,Q3); c=NULL; Q3=Add(a[i],Q3); i++; } else { if(c->order==a[i]->order) { c=Merge(a[i],c); //Q3=Add(c,Q3); //c=NULL; i++; } } } } while(j<s2) { if(c==NULL) { Q3=Add(b[j],Q3); j++; } else { if(c->order<b[j]->order) { Q3=Add(c,Q3); c=NULL; Q3=Add(b[j],Q3); j++; } else { if(c->order==b[j]->order) { c=Merge(b[j],c); //Q3=Add(c,Q3); //c=NULL; j++; } } } } if(c!=NULL) { Q3=Add(c,Q3); c=NULL; } return Q3; } node* BQ::Add(node* t,node* q) { node* pNav=q; if(pNav==NULL) { return t; } while(pNav->rSibling!=NULL) { pNav=pNav->rSibling; } pNav->rSibling=t; t->lSibling=pNav; t->rSibling=NULL; q->lSibling=t; return q; } void BQ::DeleteMin(node* rt) { if(rt==NULL) return ; else { node* temp=rt; node* pNav=rt; node* min=rt; while(pNav!=NULL) { if(pNav->data < min->data) min=pNav; pNav=pNav->rSibling; } while(temp->rSibling!=NULL) { temp=temp->rSibling; } if(min->lSibling==min && min->rSibling==NULL) { SetRoot(Concate(NULL,min->firstChild)); delete min; } else { if(min->lSibling==temp && min->rSibling!=NULL) { min->rSibling->lSibling=temp; SetRoot(Concate(min->rSibling,min->firstChild)); delete min; } else { if(min->lSibling!=temp && min->rSibling!=NULL) { min->lSibling->rSibling=min->rSibling; min->rSibling->lSibling=min->lSibling; SetRoot(Concate(rt,min->firstChild)); delete min; } else { node* t=min->lSibling; rt->lSibling=t; t->rSibling=NULL; SetRoot(Concate(rt,min->firstChild)); delete min; } } } } } int BQ::FindMin(node* rt) { node* temp=rt; if(temp==NULL) { cout<<"Queue is empty\n"; return 0; } int min=temp->data; while(temp!=NULL) { if(temp->data<min) min=temp->data; temp=temp->rSibling; } return min; } void BQ::Print(node* rt) { node* temp=rt; if(temp==NULL) { cout<<"Binomial Queue is empty\n"; return ; } while(temp!=NULL) { PrintBT(temp); cout<<endl<<endl; temp=temp->rSibling; } } void BQ::PrintBT(node* rt) { queue <node*> q; node* temp=rt; if(temp==NULL) return ; node* newNode=new node; newNode->lSibling=newNode->rSibling=newNode->firstChild=NULL; newNode->order=0; newNode->data=-1; while(1) { if(temp==rt) { cout<<temp->data<<endl; temp=temp->firstChild; } if(temp==newNode) cout<<endl; while(temp!=NULL && temp!=newNode) { if(temp->firstChild!=NULL) { if(q.empty()) { q.push(newNode); q.push(temp->firstChild); } else { q.push(temp->firstChild); } } cout<<temp->data<<" "; temp=temp->rSibling; } if(q.empty()) return ; else { temp=q.front(); q.pop(); } } }
[ "noreply@github.com" ]
ydafalla.noreply@github.com
8dfecf879bea29fd77605ec916055332abb590a7
23a8f5bcd50ee94d973e2b5bc86a5b97c6941b7f
/Scientific Programming/SOLUTIONS/series11/serie11/vector.cpp
3e0db1ade6b8e3e364c4c645d62265d0034b15fc
[]
no_license
Johnson2209/TU-Wien-Assignments
b1b7ef92664761c21b0f8cac159efbb11bb55c7a
7fdb176ca4dc99378467f64ea9eeba8ae2e78cfc
refs/heads/master
2023-06-28T20:01:54.409267
2021-08-13T15:36:39
2021-08-13T15:36:39
395,697,288
0
0
null
null
null
null
UTF-8
C++
false
false
2,576
cpp
#include "vector.hpp" #include <iostream> using std::cout; Vector::Vector() { dim = 0; coeff = (double*) 0; // just for demonstration purposes // cout << "constructor, empty\n"; } Vector::Vector(int dim, double init) { assert(dim >= 0); this->dim = dim; if (dim == 0) { coeff = (double*) 0; } else { coeff = new double[dim]; for (int j=0; j<dim; ++j) { coeff[j] = init; } } } Vector::Vector(const Vector& rhs) { dim = rhs.dim; if (dim == 0) { coeff = (double*) 0; } else { coeff = new double[dim]; for (int j=0; j<dim; ++j) { coeff[j] = rhs[j]; } } } Vector::~Vector() { if (dim > 0) { delete[] coeff; } } Vector& Vector::operator=(const Vector& rhs) { if (this != &rhs) { if (dim != rhs.dim) { if (dim > 0) { delete[] coeff; } dim = rhs.dim; if (dim > 0) { coeff = new double[dim]; } else { coeff = (double*) 0; } } for (int j=0; j<dim; ++j) { coeff[j] = rhs[j]; } } // just for demonstration purposes // cout << "deep copy, length " << dim << "\n"; return *this; } int Vector::size() const { return dim; } const double& Vector::operator[](int k) const { assert(k>=0 && k<dim); return coeff[k]; } double& Vector::operator[](int k) { assert(k>=0 && k<dim); return coeff[k]; } double Vector::norm() const { double sum = 0; for (int j=0; j<dim; ++j) { sum = sum + coeff[j]*coeff[j]; } return sqrt(sum); } const Vector operator+(const Vector& rhs1, const Vector& rhs2) { assert(rhs1.size() == rhs2.size()); Vector result(rhs1); for (int j=0; j<result.size(); ++j) { result[j] += rhs2[j]; } return result; } const Vector operator*(const double scalar, const Vector& input) { Vector result(input); for (int j=0; j<result.size(); ++j) { result[j] *= scalar; } return result; } const Vector operator*(const Vector& input, const double scalar) { return scalar*input; } const double operator*(const Vector& rhs1, const Vector& rhs2) { double scalarproduct = 0; assert(rhs1.size() == rhs2.size()); for (int j=0; j<rhs1.size(); ++j) { scalarproduct += rhs1[j]*rhs2[j]; } return scalarproduct; } std::ostream& operator<<(std::ostream& output, const Vector& p) { int deg = p.size(); if (deg == 0) { return output << 0; } else { output << "("; for (int i=0;i<deg-1;i++) { output << p[i] << ","; } return output << p[deg-1] << ")"; } }
[ "johnsonoyero22@gmail.com" ]
johnsonoyero22@gmail.com
8b5531ae427ae85639c4aa5b0983f5671f9c065b
eafabfbd433f01126ef9b0105d86ff720902f931
/BizEntity/TradeFund/stdafx.cpp
0dbdff2dc550e81fdd46ca688572af0b6199ba01
[]
no_license
imuse2012/XCaimi
9b3f06eee4f1b6091e625b3fc8c5b555a18e01c0
ccadd2daefade077e46e3f8be49f3ba3769bf26d
refs/heads/master
2021-01-18T07:47:28.956755
2013-11-18T04:47:27
2013-11-18T04:47:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
202
cpp
// stdafx.cpp : source file that includes just the standard includes // TradeFund.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h"
[ "youqian@vip.sina.com" ]
youqian@vip.sina.com
40db43303abd51acfe56f72e391e2b5b3423648c
d2190cbb5ea5463410eb84ec8b4c6a660e4b3d0e
/old_hydra/hydra/tags/apr07/rich/hrichparset.cc
552c3d319a9fdcaffea85ef8c7da6a089bde1dd2
[]
no_license
wesmail/hydra
6c681572ff6db2c60c9e36ec864a3c0e83e6aa6a
ab934d4c7eff335cc2d25f212034121f050aadf1
refs/heads/master
2021-07-05T17:04:53.402387
2020-08-12T08:54:11
2020-08-12T08:54:11
149,625,232
0
0
null
null
null
null
UTF-8
C++
false
false
2,388
cc
// File: hrichparset.cc // *************************************************************************** //*-- Author : Witold Przygoda (przygoda@psja1.if.uj.edu.pl) //*-- Modified : 1999/12/04 by Witold Przygoda (przygoda@psja1.if.uj.edu.pl) using namespace std; #include <iostream> #include <iomanip> #include "hrichparset.h" #include "hdetector.h" #include "hpario.h" #include "hdetpario.h" // *************************************************************************** //_HADES_CLASS_DESCRIPTION ////////////////////////////////////////////////////////////////////////////// // // HRichParSet // // Set of RICH containers. // ////////////////////////////////////////////////////////////////////////////// // *************************************************************************** ClassImp(HRichParSet) //---------------------------------------------------------------------------- HRichParSet::HRichParSet(const char* name,const char* title, const char* context) : HParSet(name,title,context) { strcpy(detName,"Rich"); } //============================================================================ //---------------------------------------------------------------------------- Bool_t HRichParSet::init(HParIo* inp,Int_t* set) { // intitializes the container from an input HDetParIo* input=inp->getDetParIo("HRichParIo"); if (input) return (input->init(this,set)); return kFALSE; } //============================================================================ //---------------------------------------------------------------------------- Int_t HRichParSet::write(HParIo* output) { HDetParIo* out=output->getDetParIo("HRichParIo"); if (out) return out->write(this); return kFALSE; } //============================================================================ /* //______________________________________________________________________________ void HRichParSet::Streamer(TBuffer &R__b) { // Stream an object of class HRichParSet. if (R__b.IsReading()) { Version_t R__v = R__b.ReadVersion(); if (R__v) { } HParSet::Streamer(R__b); m_pReadParam = NULL; // R__b >> m_pReadParam; } else { R__b.WriteVersion(HRichParSet::IsA()); HParSet::Streamer(R__b); // R__b << m_pReadParam; } } //============================================================================ */
[ "waleed.physics@gmail.com" ]
waleed.physics@gmail.com
763447116b4124a00885ad14958c0df4c9fb2c88
397f37e9db6a52ca5015b31082b465946e0ef1ec
/src/constants.cc
27d13387a72240c974c800ac575dcf29c7b83bba
[ "MIT" ]
permissive
rcythr/RML
c188aadd578430e88e026aab196aad8791d7599f
5f07eb4adba73c289f88f43bd0268225ef1376b4
refs/heads/master
2021-01-19T19:36:09.395215
2014-09-02T14:48:42
2014-09-02T14:48:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,668
cc
// This file is part of RML // RML is licensed with the MIT License. See the LICENSE file for more information. #include <RML/constants.hpp> #include <RML/util.hpp> namespace rml { std::unordered_set<std::string> html5Tags { "a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "math", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "svg", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var" "wbr", }; std::unordered_set<std::string> deprecatedTags { "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "decorator", "dir", "font", "frame", "frameset", "hgroup", "isindex", "listing", "marquee", "nobr", "noframes", "plaintext", "shadow", "spacer", "strike", "tt", "xmp" }; std::unordered_set<std::string> globalAttributes { "accesskey", "class", "contenteditable", "contextmenu", "dir", "draggable", "dropzone", "hidden", "id", "itemid", "itemprop", "itemref", "itemscope", "itemtype", "lang", "spellcheck", "style", "tabindex", "title", // ARIA "role" }; std::unordered_map<std::string, std::set<std::string>> attributeValidationSets { { "a", { "download", "href", "media", "ping", "rel", "target", "datafld", "datasrc", "hreflang", "methods", "type", "urn" } }, { "area", { "alt", "coords", "download", "href", "hreflang", "media", "rel", "shape", "target", "type" } }, {"audio", {"autoplay","buffered","controls","loop", "muted","played", "preload", "src","volume"}}, {"base", {"href","target"}}, {"blockquote", {"cite"}}, {"body", { "onafterprint", "onbeforeprint", "onbeforeunload", "onblur", "onerror", "onfocus", "onhashchange", "onload", "onmessage", "onoffline", "ononline", "onpopstate", "onredo", "onresize", "onstorage", "onundo", "onunload" }}, {"button", { "autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "type", "value"}}, {"canvas", {"width", "height"}}, {"col", {"span"}}, {"colgroup", {"span"}}, {"data", {"value"}}, {"datalist", {}}, {"dd", {"nowrap"}}, {"del", {"cite","datetime"}}, {"details", {"open"}}, {"dl", {"compact"}}, {"embed", {"height","src","type","width"}}, {"fieldset", {"disabled","form","name"}}, {"form", {"accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target",}}, {"head", { "profile" }}, {"hr", {"color"}}, {"html", { "manifest", "version" }}, {"iframe", {"allowfullscreen","height","name","remote","scrolling","sandbox","seamless","src","srcdoc","width"}}, {"img", {"alt","crossorigin","height","ismap","longdesc","src","srcset","width","usemap"}}, {"input", {"type","accept","autocomplete","autofocus","autosave","checked","disabled","form","formaction","formenctype","formmethod","formnovalidate","formtarget","height","inputmode","list","max","maxlength","min","minlength","multiple","name","pattern","placeholder","readonly","required","selectionDirection","size","spellcheck","src","step","value","width"}}, {"ins", {"cite","datetime"}}, {"keygen", { "autofocus", "challenge", "disabled", "form", "keytype", "name"}}, {"label", { "accesskey", "for", "form" }}, {"li", {"value", "type"}}, {"link", { "charset", "disabled", "href", "hreflang", "media", "methods", "rel", "sizes", "target", "type" }}, {"map", {"name"}}, {"menu",{"label","type"}}, {"menuitem", {"checked", "command", "default", "disabled", "icon", "label", "radiogroup", "type"}}, {"meta", { "charset", "content", "http-equiv", "name", "scheme" }}, {"meter", { "value", "min", "max", "low", "high", "optimum", "form"}}, {"object", {"data","form","height","name","type","usemap","width"}}, {"ol", {"reversed", "start", "type"}}, {"optgroup", {"disabled", "label"}}, {"option", {"disabled","label", "selected","value"}}, {"output", { "for", "form", "name" }}, {"param", {"name", "value"}}, {"pre", {"wrap"}}, {"progress", {"max","value"}}, {"q", {"cite"}}, {"script", { "async", "src", "type", "language", "defer", "crossorigin" }}, {"select", {"autofocus", "disabled", "form", "multiple", "name", "required", "size"}}, {"source", {"src", "type"}}, {"style", { "type", "media", "scoped", "title", "disabled" }}, {"td", {"colspan","headers","rowspan"}}, {"template", { "content" }}, {"textarea", {"autocomplete","autofocus","cols","disabled","form","maxlength","minlength","name","placeholder","readonly","required","rows","selectionDirection","selectionEnd","selectionStart","spellcheck","wrap"}}, {"th", {"colspan", "headers", "rowspan", "scope"}}, {"time", {"datetime"}}, {"track", {"default", "kind", "label", "src", "srclang"}}, {"video", {"autoplay", "buffered", "controls", "crossorigin", "height", "loop", "muted", "played", "preload", "poster", "src", "width"}}, }; std::unordered_set<std::string> voidTags { "base", "br", "col", "embed", "img", "input", "keygen", "link", "menuitem", "meta", "param", "source", "track", "wbr", }; bool isHtml5Tag(std::string& tag) { return html5Tags.find(tag) != html5Tags.end(); } bool isDeprecatedTag(std::string& tag) { return deprecatedTags.find(tag) != deprecatedTags.end(); } bool isVoidTag(std::string& tag) { return voidTags.find(tag) != voidTags.end(); } bool isAttributeValidForTag(const std::string& tag, const std::string& attr) { // Special cases if (tag == "svg") return true; else if (tag == "math") return true; else if (tag == "mstyle") return true; if (beginsWith(attr, "data-")) return true; else if(beginsWith(attr, "aria-")) return true; // Handle global attributes auto glob_find = globalAttributes.find(attr); if(glob_find != globalAttributes.end()) return true; // Handle tag specific auto tag_find = attributeValidationSets.find(tag); if (tag_find != attributeValidationSets.end()) { auto attr_find = tag_find->second.find(attr); return attr_find != tag_find->second.end(); } // With an invalid tag there are no valid attributes. return false; } }
[ "rwl3564@rit.edu" ]
rwl3564@rit.edu
ee56185a94f39774424020b11bd54e4f16b006b3
30e1dc84fe8c54d26ef4a1aff000a83af6f612be
/src/external/boost/boost_1_68_0/boost/hof/detail/delegate.hpp
a8413cbaea52010dcf08267614e086bb49f0e416
[ "BSD-3-Clause", "BSL-1.0" ]
permissive
Sitispeaks/turicreate
0bda7c21ee97f5ae7dc09502f6a72abcb729536d
d42280b16cb466a608e7e723d8edfbe5977253b6
refs/heads/main
2023-05-19T17:55:21.938724
2021-06-14T17:53:17
2021-06-14T17:53:17
385,034,849
1
0
BSD-3-Clause
2021-07-11T19:23:21
2021-07-11T19:23:20
null
UTF-8
C++
false
false
4,189
hpp
/*============================================================================= Copyright (c) 2012 Paul Fultz II delgate.h Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef BOOST_HOF_GUARD_FUNCTION_DELGATE_H #define BOOST_HOF_GUARD_FUNCTION_DELGATE_H #include <type_traits> #include <utility> #include <boost/hof/config.hpp> #include <boost/hof/detail/and.hpp> #include <boost/hof/detail/holder.hpp> #include <boost/hof/detail/forward.hpp> #include <boost/hof/detail/using.hpp> #include <boost/hof/detail/intrinsics.hpp> #include <boost/hof/detail/noexcept.hpp> #define BOOST_HOF_ENABLE_IF_CONVERTIBLE(...) \ class=typename std::enable_if<BOOST_HOF_IS_CONVERTIBLE(__VA_ARGS__)>::type #define BOOST_HOF_ENABLE_IF_CONVERTIBLE_UNPACK(...) \ class=typename std::enable_if<BOOST_HOF_AND_UNPACK(BOOST_HOF_IS_CONVERTIBLE(__VA_ARGS__))>::type #define BOOST_HOF_ENABLE_IF_BASE_OF(...) \ class=typename std::enable_if<BOOST_HOF_IS_BASE_OF(__VA_ARGS__)>::type #define BOOST_HOF_ENABLE_IF_CONSTRUCTIBLE(...) \ class=typename std::enable_if<BOOST_HOF_IS_CONSTRUCTIBLE(__VA_ARGS__)>::type #define BOOST_HOF_NOEXCEPT_CONSTRUCTIBLE(...) \ BOOST_HOF_NOEXCEPT(BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(__VA_ARGS__)) #define BOOST_HOF_INHERIT_DEFAULT(C, ...) \ template<bool FitPrivateEnableBool_##__LINE__=true, \ class=typename std::enable_if<FitPrivateEnableBool_##__LINE__ && boost::hof::detail::is_default_constructible_c<__VA_ARGS__>()>::type> \ constexpr C() BOOST_HOF_NOEXCEPT(boost::hof::detail::is_nothrow_default_constructible_c<__VA_ARGS__>()) {} #define BOOST_HOF_INHERIT_DEFAULT_EMPTY(C, ...) \ template<bool FitPrivateEnableBool_##__LINE__=true, \ class=typename std::enable_if<FitPrivateEnableBool_##__LINE__ && \ boost::hof::detail::is_default_constructible_c<__VA_ARGS__>() && BOOST_HOF_IS_EMPTY(__VA_ARGS__) \ >::type> \ constexpr C() BOOST_HOF_NOEXCEPT(boost::hof::detail::is_nothrow_default_constructible_c<__VA_ARGS__>()) {} #if BOOST_HOF_NO_TYPE_PACK_EXPANSION_IN_TEMPLATE #define BOOST_HOF_DELGATE_PRIMITIVE_CONSTRUCTOR(constexpr_, C, T, var) \ template<class... FitXs, typename boost::hof::detail::enable_if_constructible<C, T, FitXs...>::type = 0> \ constexpr_ C(FitXs&&... fit_xs) \ BOOST_HOF_NOEXCEPT_CONSTRUCTIBLE(T, FitXs&&...) \ : var((FitXs&&)boost::hof::forward<FitXs>(fit_xs)...) {} #else #define BOOST_HOF_DELGATE_PRIMITIVE_CONSTRUCTOR(constexpr_, C, T, var) \ template<class... FitXs, BOOST_HOF_ENABLE_IF_CONSTRUCTIBLE(T, FitXs&&...)> \ constexpr_ C(FitXs&&... fit_xs) \ BOOST_HOF_NOEXCEPT_CONSTRUCTIBLE(T, FitXs&&...) \ : var(BOOST_HOF_FORWARD(FitXs)(fit_xs)...) {} #endif #define BOOST_HOF_DELEGATE_CONSTRUCTOR(C, T, var) BOOST_HOF_DELGATE_PRIMITIVE_CONSTRUCTOR(constexpr, C, T, var) // Currently its faster to use `BOOST_HOF_DELEGATE_CONSTRUCTOR` than `using // Base::Base;` #if 1 #define BOOST_HOF_INHERIT_CONSTRUCTOR(Derived, Base) BOOST_HOF_DELEGATE_CONSTRUCTOR(Derived, Base, Base) #else #define BOOST_HOF_INHERIT_CONSTRUCTOR(Derived, Base) \ using fit_inherit_base = Base; \ using fit_inherit_base::fit_inherit_base; \ Derived()=default; \ template<class FitX, BOOST_HOF_ENABLE_IF_CONVERTIBLE(FitX, Base)> \ constexpr Derived(FitX&& fit_x) : Base(BOOST_HOF_FORWARD(FitX)(fit_x)) {} #endif namespace boost { namespace hof { namespace detail { template<class... Xs> constexpr bool is_nothrow_default_constructible_c() { return BOOST_HOF_AND_UNPACK(BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(Xs)); } template<class... Xs> constexpr bool is_default_constructible_c() { return BOOST_HOF_AND_UNPACK(BOOST_HOF_IS_DEFAULT_CONSTRUCTIBLE(Xs)); } template<class... Xs> BOOST_HOF_USING(is_default_constructible, std::integral_constant<bool, is_default_constructible_c<Xs...>()>); template<class C, class X, class... Xs> struct enable_if_constructible : std::enable_if<is_constructible<X, Xs&&...>::value, int> {}; } }} // namespace boost::hof #endif
[ "noreply@github.com" ]
Sitispeaks.noreply@github.com
7adf5d7d022d87ca3b414d11c2c61ae70c122bcd
e5d7314e57789b78b80f5aa9367ba1c0c6cd59b1
/chapter4/strtype3.cpp
599cec213c46af823e6eb1a87c3d521ae158143a
[]
no_license
dga1t/cpp-primer-practice
1b36da26922433647ac1396a3d6ffead88ad0178
8f68b71b16297f8c8d490d811ddc62dc4b3bbe2b
refs/heads/master
2023-05-29T03:44:40.098175
2021-06-06T12:33:50
2021-06-06T12:33:50
321,054,667
1
0
null
null
null
null
UTF-8
C++
false
false
679
cpp
#include <iostream> #include <string> #include <cstring> int main() { using namespace std; char charr1[20]; char charr2[20] = "jaguar"; string str1; string str2 = "panther"; // assignment for string objects and character arrays str1 = str2; strcpy(charr1, charr2); // appending for string objects and character arrays str1 += " paste"; strcat(charr1, " juice"); // finding the length of a string object and a C-style string int len1 = str1.size(); int len2 = strlen(charr1); cout << "The string " << str1 << " contains " << len1 << " characters.\n"; cout << "The string " << charr1 << " contains " << len2 << " characters.\n"; return 0; }
[ "dpsmnsk@gmail.com" ]
dpsmnsk@gmail.com
b6ce59b587487ed4dc97704db9513d7ba7d78910
0577a46d8d28e1fd8636893bbdd2b18270bb8eb8
/update_notifier/thirdparty/wxWidgets/src/generic/colour.cpp
0f21410520f2e7567831bec4ff8ab421ebc99097
[ "BSD-3-Clause" ]
permissive
ric2b/Vivaldi-browser
388a328b4cb838a4c3822357a5529642f86316a5
87244f4ee50062e59667bf8b9ca4d5291b6818d7
refs/heads/master
2022-12-21T04:44:13.804535
2022-12-17T16:30:35
2022-12-17T16:30:35
86,637,416
166
41
BSD-3-Clause
2021-03-31T18:49:30
2017-03-29T23:09:05
null
UTF-8
C++
false
false
1,122
cpp
///////////////////////////////////////////////////////////////////////////// // Name: src/generic/colour.cpp // Purpose: wxColour class // Author: Julian Smart // Modified by: // Created: 01/02/97 // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #include "wx/colour.h" #ifndef WX_PRECOMP #include "wx/gdicmn.h" #endif // Colour void wxColour::Init() { m_red = m_blue = m_green = 0; m_alpha = wxALPHA_OPAQUE; m_isInit = false; } void wxColour::InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { m_red = r; m_green = g; m_blue = b; m_alpha = a; m_isInit = true; } wxColour& wxColour::operator=(const wxColour& col) { m_red = col.m_red; m_green = col.m_green; m_blue = col.m_blue; m_alpha = col.m_alpha; m_isInit = col.m_isInit; return *this; }
[ "mathieu.caroff@free.fr" ]
mathieu.caroff@free.fr
0ecbad2015cd2437c818ee49ecc72260224941e0
d329e7db05b93b26641be508cdc9c9eb993ea067
/recipes/prometheus-cpp/all/test_package/test_package.cpp
f22948e7726c1f26580a73abc352ee87b36891fb
[]
no_license
Tarjei400/conan-packages
2019582cf478b427085fceb4f8c290bed9f8eb48
d68315abf78d2cbec86aa6f9a3fc5869b1e4d054
refs/heads/master
2023-01-30T12:23:09.794868
2020-12-16T10:03:29
2020-12-16T10:03:29
321,362,433
0
0
null
null
null
null
UTF-8
C++
false
false
1,129
cpp
#ifdef ENABLE_PULL #include <prometheus/exposer.h> #endif #include <prometheus/counter.h> #include <prometheus/registry.h> #include <string> #include <iostream> #include <cstdlib> int main(int argc, char *argv[]) { using namespace prometheus; #ifdef ENABLE_PULL // create an http server running on port 8080 Exposer exposer{"127.0.0.1:8081"}; #endif // create a metrics registry with component=main labels applied to all its // metrics auto registry = std::make_shared<Registry>(); // add a new counter family to the registry (families combine values with the // same name, but distinct label dimensions) auto& counter_family = BuildCounter() .Name("time_running_seconds_total") .Help("How many seconds is this server running?") .Labels({{"label", "value"}}) .Register(*registry); // add a counter to the metric family auto& second_counter = counter_family.Add( {{"another_label", "value"}, {"yet_another_label", "value"}}); std::cout << "Tested prometheus-cpp - ok " << std::endl; return EXIT_SUCCESS; }
[ "adrian.jutrowski@redacreltd.com" ]
adrian.jutrowski@redacreltd.com
90d6dc96d5f9e9d7974ff0c273bef7080e1d2a69
995fef3accf2aedbcd431dd98bc9ab2a2ecace9d
/src/plugins/lmp/plugins/graffiti/progressmanager.h
5987e73ce8c47cda860fb3e7ca115eeb999efc3a
[ "BSL-1.0" ]
permissive
eringus/leechcraft
2e3da6263e7530f002b532aae616a4b158d53ff6
415a9a49aa4c942a4953e8c6e59876fc7e217b24
refs/heads/master
2020-12-26T04:56:09.461868
2013-12-17T13:03:26
2013-12-17T13:03:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,384
h
/********************************************************************** * LeechCraft - modular cross-platform feature rich internet client. * Copyright (C) 2006-2013 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. **********************************************************************/ #pragma once #include <QObject> #include <QHash> class QStandardItemModel; class QAbstractItemModel; class QStandardItem; namespace LeechCraft { namespace LMP { namespace Graffiti { class CueSplitter; class ProgressManager : public QObject { Q_OBJECT QStandardItemModel *Model_; QHash<QObject*, QList<QStandardItem*>> TagsFetchObj2Row_; QHash<CueSplitter*, QList<QStandardItem*>> Splitter2Row_; public: ProgressManager (QObject* = 0); QAbstractItemModel* GetModel () const; public slots: void handleTagsFetch (int fetched, int total, QObject *obj); void handleCueSplitter (CueSplitter*); void handleSplitProgress (int, int, CueSplitter*); void handleSplitFinished (CueSplitter*); }; } } }
[ "0xd34df00d@gmail.com" ]
0xd34df00d@gmail.com
d5035e58bee74350fff0b137dfdbd249bf7a7c03
2b1846cd62707be78851f2adb91d3da61fa3a73e
/c_02/list.hpp
66578e14a0882def630c72d5d4991019447a12f2
[]
no_license
y-shindoh/coding_interview
1fb2af920696e4b3d373c87d9bdaae0564696796
88bd5665fd246703832f3e5eccba4daaf2026fbc
refs/heads/master
2020-05-31T01:07:05.629942
2015-12-02T11:39:57
2015-12-02T11:39:57
35,543,121
0
0
null
null
null
null
UTF-8
C++
false
false
3,382
hpp
/* -*- coding: utf-8; tab-width: 4 -*- */ /** * @file list.hpp * @brief 「世界で闘うプログラミング力を鍛える150問」の2章の回答 * @author Yasutaka SHINDOH / 新堂 安孝 * @note see http://www.amazon.co.jp/dp/4839942390 . */ #ifndef __LIST_HPP__ #define __LIST_HPP__ "list.hpp" #include <cstddef> #include <cstdio> #include <cassert> //#define USE_DOUBLY_LINKED_LIST "use_doubly_linked_list" /** * リストを構成するノード */ template<typename TYPE> class Node { private: TYPE data_; ///< データ #ifdef USE_DOUBLY_LINKED_LIST Node<TYPE>* previous_; ///< 前のノード #endif // USE_DOUBLY_LINKED_LIST Node<TYPE>* next_; ///< 次のノード public: #ifdef USE_DOUBLY_LINKED_LIST /** * コンストラクタ * @param[in] data 格納するデータ * @param[in] previous 前のノード * @param[in] next 次のノード */ Node(const TYPE& data, Node<TYPE>* previous = 0, Node<TYPE>* next = 0) : data_(data), previous_(previous), next_(next) { ; } #else // USE_DOUBLY_LINKED_LIST /** * コンストラクタ * @param[in] data 格納するデータ * @param[in] next 次のノード */ Node(const TYPE& data, Node<TYPE>* next = 0) : data_(data), next_(next) { ; } #endif // USE_DOUBLY_LINKED_LIST /** * データを格納 * @param[in] data データ */ void set_data(const TYPE& data) { data_ = data; } /** * データを取得 * @return データ */ TYPE get_data() const { return data_; } #ifdef USE_DOUBLY_LINKED_LIST /** * 前のノードを格納 * @param[in] previous 前のノードのポインタ */ void set_previous(Node<TYPE>* previous) { previous_ = previous; } /** * 前のノードを取得 * @return 前のノードのポインタ */ Node<TYPE>* get_previous() const { return previous_; } #endif // USE_DOUBLY_LINKED_LIST /** * 次のノードを格納 * @param[in] next 次のノード */ void set_next(Node<TYPE>* next) { next_ = next; } /** * 次のノードを取得 * @return 次のノード */ Node<TYPE>* get_next() const { return next_; } /** * 配列からリストを生成 * @param[in] array 配列 * @param[in] length 引数 @a array の要素数 * @return リストの先頭のノード */ static Node<TYPE>* MakeLinkedList(const TYPE* array, size_t length) { Node<TYPE>* top(0); Node<TYPE>* c; Node<TYPE>* p(0); for (size_t i(0); i < length; ++i) { c = new Node<TYPE>(array[i]); #ifdef USE_DOUBLY_LINKED_LIST c->set_previous(p); #endif // USE_DOUBLY_LINKED_LIST if (p) p->set_next(c); if (!top) top = c; p = c; } return top; } /** * リストを削除 * @param[in,out] node リストの先頭ノード */ static void DeleteLinkedList(Node<TYPE>* node) { Node<TYPE>* n; while (node) { n = node->get_next(); delete node; node = n; } } /** * リストの各ノードのデータを表示 * @param[in] node リストの先頭ノード */ static void PrintLinkedList(const Node<TYPE>* node) { bool flag = false; while (node) { if (flag) std::printf(", "); std::printf("%G", (double)node->get_data()); node = node->get_next(); flag = true; } if (flag) std::printf("\n"); } }; #endif // __LIST_HPP__
[ "cube@quruli.ivory.ne.jp" ]
cube@quruli.ivory.ne.jp
e35889b2f1f4bf30ff5d3caa7cf7d5aad639f13a
10047fd47735b78c70834072cc5253784d0d46cc
/pre_85/876(链表的中间结点).cpp
6aaae0096296f2221dee2c74f2590735526c5570
[]
no_license
HccqXd/my_leetcode1
676e6aa2cf901d7705f3944e4b423edc88da9961
170eaeda8d9aac66e70039079c6db2e329d227e4
refs/heads/master
2020-11-25T19:03:54.700682
2020-01-06T14:16:22
2020-01-06T14:16:22
228,803,491
1
0
null
null
null
null
UTF-8
C++
false
false
1,979
cpp
///* //题目描述: // 给定一个带有头结点 head 的非空单链表,返回链表的中间结点。 // 如果有两个中间结点,则返回第二个中间结点。 // //示例 1: // 输入:[1,2,3,4,5] // 输出:此列表中的结点 3 (序列化形式:[3,4,5]) // 返回的结点值为 3 。 (测评系统对该结点序列化表述是 [3,4,5])。 // 注意,我们返回了一个 ListNode 类型的对象 ans,这样: // ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, 以及 ans.next.next.next = NULL. // //示例 2: // 输入:[1,2,3,4,5,6] // 输出:此列表中的结点 4 (序列化形式:[4,5,6]) // 由于该列表有两个中间结点,值分别为 3 和 4,我们返回第二个结点。 //  // //提示: // 给定链表的结点数介于 1 和 100 之间。 //*/ //#include"List.h" // ///*解法1:常规,其实这题根本没有头节点,误人子弟 //先遍历链表,得到链表长度len //再从头遍历链表到第len/2+1个结点即为所求 //*/ //class Solution1 { //public: // ListNode* middleNode(ListNode* head) { // int len = 0; // ListNode* res = head->next; // while (res != nullptr) { // len++; // res = res->next; // } // res = head; // for (int i = 0; i <= len / 2 + 1; i++) { // res = res->next; // } // return res; // } //}; // ///*解法2(官方解答):快慢指针法 // 当用慢指针 slow 遍历列表时,让另一个指针 fast 的速度是它的两倍。 // 当 fast 到达列表的末尾时,slow 必然位于中间。 // //作者:LeetCode //链接:https ://leetcode-cn.com/problems/middle-of-the-linked-list/solution/lian-biao-de-zhong-jian-jie-dian-by-leetcode/ //来源:力扣(LeetCode)*/ //class Solution { //public: // ListNode* middleNode(ListNode* head) { // ListNode* slow = head; // ListNode* fast = head; // while (fast != NULL && fast->next != NULL) { // slow = slow->next; // fast = fast->next->next; // } // return slow; // } //};
[ "hccqxd@qq.com" ]
hccqxd@qq.com
aadb9c727bb81454389ef7a64edfdb899199382d
f5c323253e3abe9eb6097d28ad8124c78e0c8ce2
/src/Modules/Heightmap/filters/raytracing/RayTracing.hpp
a2197e27071c7d1c8717336fad92b516739a11c9
[]
no_license
VCityTeam/DA-POM-Legonizer
5cff7bb6cdce9ff9e6aaf2723910f7f07cb3c52d
0abc3e1ed2147ba2696be81297cd2bd99b3e72fa
refs/heads/main
2023-05-25T09:25:32.923133
2021-05-31T13:07:29
2021-05-31T13:07:29
335,885,254
0
0
null
null
null
null
UTF-8
C++
false
false
883
hpp
// Copyright University of Lyon, 2012 - 2017 // Distributed under the GNU Lesser General Public License Version 2.1 (LGPLv2) // (Refer to accompanying file LICENSE.md or copy at // https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html ) #ifndef __RAYTRACING_HPP__ #define __RAYTRACING_HPP__ #include "Ray.hpp" #include "../../filters_export.h" #include <vector> struct TriangleList; /** * @build Perform raytracing algorithm on a set of triangles * @param triangles List of triangle of a CityGML tile * @param rays List of rays * @param breakOnFirstInter If true, stop raytracing when an intersection is found. * Default : false (compute all intersections between rays and triangles). * @return list of hits */ std::vector<Hit*> *RayTracing( TriangleList* triangles, const std::vector<Ray*>& rays, bool breakOnFirstInter = false ); #endif
[ "remi.lhoste@etu.univ-lyon1.fr" ]
remi.lhoste@etu.univ-lyon1.fr
c3467dfc074f00fdbb8d5a161aea39bf645d01b7
bac9ca4fd8774eb2447297424b6bc9a5bf13a801
/number-of-closed-islands/number-of-closed-islands.cpp
e169068f919c585220cfafbd88de79c877fcd031
[]
no_license
devansh2021/My_LC_Sol
28b10349cd6e77e5da5bfad8a35038844c540dd6
bd8d22fa3de110057e99b75194f5d60ed1874ba2
refs/heads/main
2023-06-21T21:49:36.092740
2021-07-14T11:27:02
2021-07-14T11:27:02
347,848,312
1
0
null
null
null
null
UTF-8
C++
false
false
953
cpp
class Solution { public: bool terminal=0; void dfs(vector<vector<int>> &g, int r, int c) { int dr[4]={1,0,0,-1}; int dc[4]={0,1,-1,0}; int m=g.size(); int n=g[0].size(); if(r<0 ||c<0 ||c>=n||r>=m) { terminal=true; return; } if(g[r][c]) return ; else g[r][c]=1; for(int i=0;i<4;i++) { dfs(g,r+dr[i],c+dc[i]); } return; } int closedIsland(vector<vector<int>>& grid) { int m=grid.size(); int n=grid[0].size(); int ans=0; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { if(!grid[i][j]){ terminal=0; dfs(grid, i, j); if(!terminal) ans++; } } } return ans; } };
[ "devanshsuwalka@gmail.com" ]
devanshsuwalka@gmail.com
348ca97a92445a9273440ed9af23085666ad6a04
329e9e53018631a9f17aa0795d84e52e37d7bb42
/Prog. Genuis.cpp
ea27949fa1525d28da0708e648ee43719f917c25
[]
no_license
Pugnac5/C-and-C-
3bedd6b4f74538b12ab45eb65a986ca9f07250dc
6d25ce263ff9f43622fa3aac3e83a8116b73ec75
refs/heads/master
2021-05-21T01:03:46.043261
2020-04-02T21:14:35
2020-04-02T21:14:35
252,479,359
0
0
null
null
null
null
ISO-8859-1
C++
false
false
3,333
cpp
#include<stdio.h> #include<stdlib.h> #include<conio.h> #include<time.h> #include<windows.h> #include<locale.h> int val=1; int u=9 /*ultima posição do vetor*/,a,level=3,n,idlevel=1; int vet[10];//vetor de tamanho 10 int escolha; void jogo(); void gotoxy(int x,int y){ //Comando para substituir a biblioteca conio2.h COORD c; c.X = x; c.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c); } void aleatorio(){ if(idlevel==1) { printf("Você Está No Nível %d\n",idlevel++); } else printf("Grave esta sequência:\n"); val = 1;a=0; while (val == 1){ vet[a] = rand() % level + 1; if(a==0)printf(" %d ", vet[a]); else printf("- %d ", vet[a]); //posição do vetor é = ao tamanho do vetor if (a == u){ val = 0; }else{ a++; } } printf("\n"); system("pause"); system("cls"); jogo(); } void jogo(){ val = 1; a = 0; while(val == 1){ printf("Digite O %dº Número ",a+1); scanf("%d",&n); if (vet[a] != n){ printf("\n"); printf("Você perdeu no nível %d a sequência correta e:\n",idlevel); //printa a sequencia correta for(int i=0; i<=u; i++){ if(i==0)printf(" %d ", vet[i]); else printf("- %d ", vet[i]); } val = 0; printf("\n\n "); for(val=10;val>-1;val--){ gotoxy(15,5); printf(" %d ",val); Sleep(200); } gotoxy(15,5); printf(" \n\n"); } else if(a == u){ printf("Parabéns! Você passou para o nível %d\n\n",idlevel); level= level + 3; a = 0; n = 0; aleatorio(); idlevel++; level; Sleep(2000); val=0; } else{ a++; } } } int main(){ setlocale(LC_ALL, ""); srand(time(NULL));/* para gerar números randomicos diferentes */ do{ system("cls"); printf("\n\n ================= BEM-VINDO AO GENIUS ================ \n\n"); printf("\n0 - para sair Do Jogo\n1 - Para um jogador\n2 - Para dois jogadores " ); printf("\n "); fflush(stdin); escolha=getch()-48;/* não precisar pessionar enter*/ switch (escolha){ case 1: printf("\n ---- UM JOGADOR ----\n"); aleatorio(); break; case 2: printf("\n ---- DOIS JOGADORES ----\n\n"); printf("voce é o jogador 1\n\n"); aleatorio(); printf("Agora é A Vez Do Jogador 2\n\n"); aleatorio(); break; case 0: printf("\n TCHAU"); for(val=0;val<10;val++){ printf(" ."); Sleep(200); } printf("!\n\n"); break; } }while(escolha != 0); }
[ "noreply@github.com" ]
Pugnac5.noreply@github.com
254615d16adce19cbc5d1b6e010a2eea20bd6b57
d0a039c4df11b50e2781fcc0fc9b4bc301d8e67a
/UVa/514.cpp
5685e57795635309073728fd3d6bb68c62ab4fce
[]
no_license
Somrat-Hossen/Problem-Solution
0574165710d329864567efdb5be2a823ce41152b
d20db61222d0eed5bc2b054de331d65f0391f400
refs/heads/master
2021-05-12T17:43:48.145286
2020-01-01T13:14:01
2020-01-01T13:14:01
117,053,427
0
1
null
null
null
null
UTF-8
C++
false
false
1,070
cpp
#include<bits/stdc++.h> using namespace std; void Solve(int root[],int need[],int n) { stack<int>st; int cnt=0; for(int i=1,j=1;i<=n;i++) { int x=need[i]; if(x==root[j]) j++; else if( j>n && ( (!st.empty()) && st.top()!=x ) ) {cout<<"No"<<endl;cnt=1;break;} else if(!st.empty() && (x==st.top()) ) { st.pop(); } else { while(x!=root[j] && j<=n) { st.push(root[j]); //if(j!=n) j++; } j++; } } if(!cnt) cout<<"Yes"<<endl; } int main() { int i,n,tmp,q,cnt; while(cin>>n && n) { int need[1002],root[1002]; while(cin>>need[1] && need[1]) { root[1]=1; for(int i=2;i<=n;i++) {cin>>need[i];root[i]=i;} Solve(root,need,n); } cout<<endl; } return 0; }
[ "noreply@github.com" ]
Somrat-Hossen.noreply@github.com
8402e6704e5ecc96729c374ab3d8a15e4a52e7f0
5ac21ec9ed202588545b4643ed3bf639f6854afe
/cpp_package/examples/signal_processing/src/csp.cpp
fa5fc20a7ef6bca44084c28aa0a66a8419e34283
[ "MIT" ]
permissive
neuroidss/brainflow
66819cc50f4b1931fcd7a89aaa788e8ed49db67b
fe7e19e83ece03ce23d5fcc7e7883603c10489f7
refs/heads/master
2022-09-15T04:34:19.329472
2022-09-04T09:03:14
2022-09-04T09:03:14
241,398,195
1
0
MIT
2022-05-09T10:39:54
2020-02-18T15:35:06
C++
UTF-8
C++
false
false
819
cpp
#include <iostream> #include <stdlib.h> #ifdef _WIN32 #include <windows.h> #else #include <unistd.h> #endif #include "data_filter.h" int main (int argc, char *argv[]) { constexpr int n_ep = 2; constexpr int n_ch = 2; constexpr int n_times = 4; constexpr int total_len = n_ep * n_ch * n_times; double labels_array[n_ep] = {0, 1}; double data_array[total_len] = {6, 3, 1, 5, 3, 0, 5, 1, 1, 5, 6, 2, 5, 1, 2, 2}; BrainFlowArray<double, 1> labels (labels_array, n_ep); BrainFlowArray<double, 3> data (data_array, n_ep, n_ch, n_times); std::cout << data << std::endl; std::pair<BrainFlowArray<double, 2>, BrainFlowArray<double, 1>> output = DataFilter::get_csp (data, labels); std::cout << output.first << std::endl; std::cout << output.second << std::endl; }
[ "noreply@github.com" ]
neuroidss.noreply@github.com
9fc4f0f296871ee70a577591acd2214f25645058
757a5c0ad5dace24855fdd523019ed3fbb3ca9ce
/3rdparty/spirv-tools/source/opt/debug_info_manager.cpp
6593c3fbded1c5aaea4a77f0413c583f21c05cc0
[ "Apache-2.0", "BSD-2-Clause", "LicenseRef-scancode-free-unknown", "MIT" ]
permissive
VirtualGeo/bgfx
1631f59596c4db9099f8ac7c15d5496fa412f6a8
f2fe00958b07a99403f6cab0b4da8b6ad4bc7d31
refs/heads/master
2023-08-24T11:06:30.571411
2021-10-15T11:12:48
2021-10-15T11:12:48
250,211,166
0
1
BSD-2-Clause
2021-09-14T08:50:03
2020-03-26T09:13:31
C++
UTF-8
C++
false
false
35,895
cpp
// Copyright (c) 2020 Google LLC // // 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 "source/opt/debug_info_manager.h" #include <cassert> #include "source/opt/ir_context.h" // Constants for OpenCL.DebugInfo.100 & NonSemantic.Shader.DebugInfo.100 // extension instructions. static const uint32_t kOpLineOperandLineIndex = 1; static const uint32_t kLineOperandIndexDebugFunction = 7; static const uint32_t kLineOperandIndexDebugLexicalBlock = 5; static const uint32_t kDebugFunctionOperandFunctionIndex = 13; static const uint32_t kDebugFunctionDefinitionOperandDebugFunctionIndex = 4; static const uint32_t kDebugFunctionDefinitionOperandOpFunctionIndex = 5; static const uint32_t kDebugFunctionOperandParentIndex = 9; static const uint32_t kDebugTypeCompositeOperandParentIndex = 9; static const uint32_t kDebugLexicalBlockOperandParentIndex = 7; static const uint32_t kDebugInlinedAtOperandInlinedIndex = 6; static const uint32_t kDebugExpressOperandOperationIndex = 4; static const uint32_t kDebugDeclareOperandLocalVariableIndex = 4; static const uint32_t kDebugDeclareOperandVariableIndex = 5; static const uint32_t kDebugValueOperandExpressionIndex = 6; static const uint32_t kDebugOperationOperandOperationIndex = 4; static const uint32_t kOpVariableOperandStorageClassIndex = 2; static const uint32_t kDebugLocalVariableOperandParentIndex = 9; static const uint32_t kExtInstInstructionInIdx = 1; static const uint32_t kDebugGlobalVariableOperandFlagsIndex = 12; static const uint32_t kDebugLocalVariableOperandFlagsIndex = 10; namespace spvtools { namespace opt { namespace analysis { namespace { void SetInlinedOperand(Instruction* dbg_inlined_at, uint32_t inlined_operand) { assert(dbg_inlined_at); assert(dbg_inlined_at->GetCommonDebugOpcode() == CommonDebugInfoDebugInlinedAt); if (dbg_inlined_at->NumOperands() <= kDebugInlinedAtOperandInlinedIndex) { dbg_inlined_at->AddOperand( {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {inlined_operand}}); } else { dbg_inlined_at->SetOperand(kDebugInlinedAtOperandInlinedIndex, {inlined_operand}); } } uint32_t GetInlinedOperand(Instruction* dbg_inlined_at) { assert(dbg_inlined_at); assert(dbg_inlined_at->GetCommonDebugOpcode() == CommonDebugInfoDebugInlinedAt); if (dbg_inlined_at->NumOperands() <= kDebugInlinedAtOperandInlinedIndex) return kNoInlinedAt; return dbg_inlined_at->GetSingleWordOperand( kDebugInlinedAtOperandInlinedIndex); } bool IsEmptyDebugExpression(Instruction* instr) { return (instr->GetCommonDebugOpcode() == CommonDebugInfoDebugExpression) && instr->NumOperands() == kDebugExpressOperandOperationIndex; } } // namespace DebugInfoManager::DebugInfoManager(IRContext* c) : context_(c) { AnalyzeDebugInsts(*c->module()); } uint32_t DebugInfoManager::GetDbgSetImportId() { uint32_t setId = context()->get_feature_mgr()->GetExtInstImportId_OpenCL100DebugInfo(); if (setId == 0) { setId = context()->get_feature_mgr()->GetExtInstImportId_Shader100DebugInfo(); } return setId; } Instruction* DebugInfoManager::GetDbgInst(uint32_t id) { auto dbg_inst_it = id_to_dbg_inst_.find(id); return dbg_inst_it == id_to_dbg_inst_.end() ? nullptr : dbg_inst_it->second; } void DebugInfoManager::RegisterDbgInst(Instruction* inst) { assert(inst->NumInOperands() != 0 && (GetDbgSetImportId() == inst->GetInOperand(0).words[0]) && "Given instruction is not a debug instruction"); id_to_dbg_inst_[inst->result_id()] = inst; } void DebugInfoManager::RegisterDbgFunction(Instruction* inst) { if (inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction) { auto fn_id = inst->GetSingleWordOperand(kDebugFunctionOperandFunctionIndex); // Do not register function that has been optimized away. auto fn_inst = GetDbgInst(fn_id); if (fn_inst != nullptr) { assert(GetDbgInst(fn_id)->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugInfoNone); return; } assert( fn_id_to_dbg_fn_.find(fn_id) == fn_id_to_dbg_fn_.end() && "Register DebugFunction for a function that already has DebugFunction"); fn_id_to_dbg_fn_[fn_id] = inst; } else if (inst->GetShader100DebugOpcode() == NonSemanticShaderDebugInfo100DebugFunctionDefinition) { auto fn_id = inst->GetSingleWordOperand( kDebugFunctionDefinitionOperandOpFunctionIndex); auto fn_inst = GetDbgInst(inst->GetSingleWordOperand( kDebugFunctionDefinitionOperandDebugFunctionIndex)); assert(fn_inst && fn_inst->GetShader100DebugOpcode() == NonSemanticShaderDebugInfo100DebugFunction); assert(fn_id_to_dbg_fn_.find(fn_id) == fn_id_to_dbg_fn_.end() && "Register DebugFunctionDefinition for a function that already has " "DebugFunctionDefinition"); fn_id_to_dbg_fn_[fn_id] = fn_inst; } else { assert(false && "inst is not a DebugFunction"); } } void DebugInfoManager::RegisterDbgDeclare(uint32_t var_id, Instruction* dbg_declare) { assert(dbg_declare->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare || dbg_declare->GetCommonDebugOpcode() == CommonDebugInfoDebugValue); auto dbg_decl_itr = var_id_to_dbg_decl_.find(var_id); if (dbg_decl_itr == var_id_to_dbg_decl_.end()) { var_id_to_dbg_decl_[var_id] = {dbg_declare}; } else { dbg_decl_itr->second.insert(dbg_declare); } } uint32_t DebugInfoManager::CreateDebugInlinedAt(const Instruction* line, const DebugScope& scope) { uint32_t setId = GetDbgSetImportId(); if (setId == 0) return kNoInlinedAt; spv_operand_type_t line_number_type = spv_operand_type_t::SPV_OPERAND_TYPE_LITERAL_INTEGER; // In NonSemantic.Shader.DebugInfo.100, all constants are IDs of OpConstant, // not literals. if (setId == context()->get_feature_mgr()->GetExtInstImportId_Shader100DebugInfo()) line_number_type = spv_operand_type_t::SPV_OPERAND_TYPE_ID; uint32_t line_number = 0; if (line == nullptr) { auto* lexical_scope_inst = GetDbgInst(scope.GetLexicalScope()); if (lexical_scope_inst == nullptr) return kNoInlinedAt; CommonDebugInfoInstructions debug_opcode = lexical_scope_inst->GetCommonDebugOpcode(); switch (debug_opcode) { case CommonDebugInfoDebugFunction: line_number = lexical_scope_inst->GetSingleWordOperand( kLineOperandIndexDebugFunction); break; case CommonDebugInfoDebugLexicalBlock: line_number = lexical_scope_inst->GetSingleWordOperand( kLineOperandIndexDebugLexicalBlock); break; case CommonDebugInfoDebugTypeComposite: case CommonDebugInfoDebugCompilationUnit: assert(false && "DebugTypeComposite and DebugCompilationUnit are lexical " "scopes, but we inline functions into a function or a block " "of a function, not into a struct/class or a global scope."); break; default: assert(false && "Unreachable. a debug extension instruction for a " "lexical scope must be DebugFunction, DebugTypeComposite, " "DebugLexicalBlock, or DebugCompilationUnit."); break; } } else { line_number = line->GetSingleWordOperand(kOpLineOperandLineIndex); // If we need the line number as an ID, generate that constant now. if (line_number_type == spv_operand_type_t::SPV_OPERAND_TYPE_ID) { uint32_t line_id = context()->get_constant_mgr()->GetUIntConst(line_number); line_number = line_id; } } uint32_t result_id = context()->TakeNextId(); std::unique_ptr<Instruction> inlined_at(new Instruction( context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(), result_id, { {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {setId}}, {spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER, {static_cast<uint32_t>(CommonDebugInfoDebugInlinedAt)}}, {line_number_type, {line_number}}, {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {scope.GetLexicalScope()}}, })); // |scope| already has DebugInlinedAt. We put the existing DebugInlinedAt // into the Inlined operand of this new DebugInlinedAt. if (scope.GetInlinedAt() != kNoInlinedAt) { inlined_at->AddOperand( {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {scope.GetInlinedAt()}}); } RegisterDbgInst(inlined_at.get()); if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) context()->get_def_use_mgr()->AnalyzeInstDefUse(inlined_at.get()); context()->module()->AddExtInstDebugInfo(std::move(inlined_at)); return result_id; } DebugScope DebugInfoManager::BuildDebugScope( const DebugScope& callee_instr_scope, DebugInlinedAtContext* inlined_at_ctx) { return DebugScope(callee_instr_scope.GetLexicalScope(), BuildDebugInlinedAtChain(callee_instr_scope.GetInlinedAt(), inlined_at_ctx)); } uint32_t DebugInfoManager::BuildDebugInlinedAtChain( uint32_t callee_inlined_at, DebugInlinedAtContext* inlined_at_ctx) { if (inlined_at_ctx->GetScopeOfCallInstruction().GetLexicalScope() == kNoDebugScope) return kNoInlinedAt; // Reuse the already generated DebugInlinedAt chain if exists. uint32_t already_generated_chain_head_id = inlined_at_ctx->GetDebugInlinedAtChain(callee_inlined_at); if (already_generated_chain_head_id != kNoInlinedAt) { return already_generated_chain_head_id; } const uint32_t new_dbg_inlined_at_id = CreateDebugInlinedAt(inlined_at_ctx->GetLineOfCallInstruction(), inlined_at_ctx->GetScopeOfCallInstruction()); if (new_dbg_inlined_at_id == kNoInlinedAt) return kNoInlinedAt; if (callee_inlined_at == kNoInlinedAt) { inlined_at_ctx->SetDebugInlinedAtChain(kNoInlinedAt, new_dbg_inlined_at_id); return new_dbg_inlined_at_id; } uint32_t chain_head_id = kNoInlinedAt; uint32_t chain_iter_id = callee_inlined_at; Instruction* last_inlined_at_in_chain = nullptr; do { Instruction* new_inlined_at_in_chain = CloneDebugInlinedAt( chain_iter_id, /* insert_before */ last_inlined_at_in_chain); assert(new_inlined_at_in_chain != nullptr); // Set DebugInlinedAt of the new scope as the head of the chain. if (chain_head_id == kNoInlinedAt) chain_head_id = new_inlined_at_in_chain->result_id(); // Previous DebugInlinedAt of the chain must point to the new // DebugInlinedAt as its Inlined operand to build a recursive // chain. if (last_inlined_at_in_chain != nullptr) { SetInlinedOperand(last_inlined_at_in_chain, new_inlined_at_in_chain->result_id()); } last_inlined_at_in_chain = new_inlined_at_in_chain; chain_iter_id = GetInlinedOperand(new_inlined_at_in_chain); } while (chain_iter_id != kNoInlinedAt); // Put |new_dbg_inlined_at_id| into the end of the chain. SetInlinedOperand(last_inlined_at_in_chain, new_dbg_inlined_at_id); // Keep the new chain information that will be reused it. inlined_at_ctx->SetDebugInlinedAtChain(callee_inlined_at, chain_head_id); return chain_head_id; } Instruction* DebugInfoManager::GetDebugOperationWithDeref() { if (deref_operation_ != nullptr) return deref_operation_; uint32_t result_id = context()->TakeNextId(); std::unique_ptr<Instruction> deref_operation; if (context()->get_feature_mgr()->GetExtInstImportId_OpenCL100DebugInfo()) { deref_operation = std::unique_ptr<Instruction>(new Instruction( context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(), result_id, { {SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}}, {SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER, {static_cast<uint32_t>(OpenCLDebugInfo100DebugOperation)}}, {SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION, {static_cast<uint32_t>(OpenCLDebugInfo100Deref)}}, })); } else { uint32_t deref_id = context()->get_constant_mgr()->GetUIntConst( NonSemanticShaderDebugInfo100Deref); deref_operation = std::unique_ptr<Instruction>( new Instruction(context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(), result_id, { {SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}}, {SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER, {static_cast<uint32_t>( NonSemanticShaderDebugInfo100DebugOperation)}}, {SPV_OPERAND_TYPE_ID, {deref_id}}, })); } // Add to the front of |ext_inst_debuginfo_|. deref_operation_ = context()->module()->ext_inst_debuginfo_begin()->InsertBefore( std::move(deref_operation)); RegisterDbgInst(deref_operation_); if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) context()->get_def_use_mgr()->AnalyzeInstDefUse(deref_operation_); return deref_operation_; } Instruction* DebugInfoManager::DerefDebugExpression(Instruction* dbg_expr) { assert(dbg_expr->GetCommonDebugOpcode() == CommonDebugInfoDebugExpression); std::unique_ptr<Instruction> deref_expr(dbg_expr->Clone(context())); deref_expr->SetResultId(context()->TakeNextId()); deref_expr->InsertOperand( kDebugExpressOperandOperationIndex, {SPV_OPERAND_TYPE_ID, {GetDebugOperationWithDeref()->result_id()}}); auto* deref_expr_instr = context()->ext_inst_debuginfo_end()->InsertBefore(std::move(deref_expr)); AnalyzeDebugInst(deref_expr_instr); if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) context()->get_def_use_mgr()->AnalyzeInstDefUse(deref_expr_instr); return deref_expr_instr; } Instruction* DebugInfoManager::GetDebugInfoNone() { if (debug_info_none_inst_ != nullptr) return debug_info_none_inst_; uint32_t result_id = context()->TakeNextId(); std::unique_ptr<Instruction> dbg_info_none_inst(new Instruction( context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(), result_id, { {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}}, {spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER, {static_cast<uint32_t>(CommonDebugInfoDebugInfoNone)}}, })); // Add to the front of |ext_inst_debuginfo_|. debug_info_none_inst_ = context()->module()->ext_inst_debuginfo_begin()->InsertBefore( std::move(dbg_info_none_inst)); RegisterDbgInst(debug_info_none_inst_); if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) context()->get_def_use_mgr()->AnalyzeInstDefUse(debug_info_none_inst_); return debug_info_none_inst_; } Instruction* DebugInfoManager::GetEmptyDebugExpression() { if (empty_debug_expr_inst_ != nullptr) return empty_debug_expr_inst_; uint32_t result_id = context()->TakeNextId(); std::unique_ptr<Instruction> empty_debug_expr(new Instruction( context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(), result_id, { {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}}, {spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER, {static_cast<uint32_t>(CommonDebugInfoDebugExpression)}}, })); // Add to the front of |ext_inst_debuginfo_|. empty_debug_expr_inst_ = context()->module()->ext_inst_debuginfo_begin()->InsertBefore( std::move(empty_debug_expr)); RegisterDbgInst(empty_debug_expr_inst_); if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) context()->get_def_use_mgr()->AnalyzeInstDefUse(empty_debug_expr_inst_); return empty_debug_expr_inst_; } Instruction* DebugInfoManager::GetDebugInlinedAt(uint32_t dbg_inlined_at_id) { auto* inlined_at = GetDbgInst(dbg_inlined_at_id); if (inlined_at == nullptr) return nullptr; if (inlined_at->GetCommonDebugOpcode() != CommonDebugInfoDebugInlinedAt) { return nullptr; } return inlined_at; } Instruction* DebugInfoManager::CloneDebugInlinedAt(uint32_t clone_inlined_at_id, Instruction* insert_before) { auto* inlined_at = GetDebugInlinedAt(clone_inlined_at_id); if (inlined_at == nullptr) return nullptr; std::unique_ptr<Instruction> new_inlined_at(inlined_at->Clone(context())); new_inlined_at->SetResultId(context()->TakeNextId()); RegisterDbgInst(new_inlined_at.get()); if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) context()->get_def_use_mgr()->AnalyzeInstDefUse(new_inlined_at.get()); if (insert_before != nullptr) return insert_before->InsertBefore(std::move(new_inlined_at)); return context()->module()->ext_inst_debuginfo_end()->InsertBefore( std::move(new_inlined_at)); } bool DebugInfoManager::IsVariableDebugDeclared(uint32_t variable_id) { auto dbg_decl_itr = var_id_to_dbg_decl_.find(variable_id); return dbg_decl_itr != var_id_to_dbg_decl_.end(); } bool DebugInfoManager::KillDebugDeclares(uint32_t variable_id) { bool modified = false; auto dbg_decl_itr = var_id_to_dbg_decl_.find(variable_id); if (dbg_decl_itr != var_id_to_dbg_decl_.end()) { // We intentionally copy the list of DebugDeclare instructions because // context()->KillInst(dbg_decl) will update |var_id_to_dbg_decl_|. If we // directly use |dbg_decl_itr->second|, it accesses a dangling pointer. auto copy_dbg_decls = dbg_decl_itr->second; for (auto* dbg_decl : copy_dbg_decls) { context()->KillInst(dbg_decl); modified = true; } var_id_to_dbg_decl_.erase(dbg_decl_itr); } return modified; } uint32_t DebugInfoManager::GetParentScope(uint32_t child_scope) { auto dbg_scope_itr = id_to_dbg_inst_.find(child_scope); assert(dbg_scope_itr != id_to_dbg_inst_.end()); CommonDebugInfoInstructions debug_opcode = dbg_scope_itr->second->GetCommonDebugOpcode(); uint32_t parent_scope = kNoDebugScope; switch (debug_opcode) { case CommonDebugInfoDebugFunction: parent_scope = dbg_scope_itr->second->GetSingleWordOperand( kDebugFunctionOperandParentIndex); break; case CommonDebugInfoDebugLexicalBlock: parent_scope = dbg_scope_itr->second->GetSingleWordOperand( kDebugLexicalBlockOperandParentIndex); break; case CommonDebugInfoDebugTypeComposite: parent_scope = dbg_scope_itr->second->GetSingleWordOperand( kDebugTypeCompositeOperandParentIndex); break; case CommonDebugInfoDebugCompilationUnit: // DebugCompilationUnit does not have a parent scope. break; default: assert(false && "Unreachable. A debug scope instruction must be " "DebugFunction, DebugTypeComposite, DebugLexicalBlock, " "or DebugCompilationUnit."); break; } return parent_scope; } bool DebugInfoManager::IsAncestorOfScope(uint32_t scope, uint32_t ancestor) { uint32_t ancestor_scope_itr = scope; while (ancestor_scope_itr != kNoDebugScope) { if (ancestor == ancestor_scope_itr) return true; ancestor_scope_itr = GetParentScope(ancestor_scope_itr); } return false; } bool DebugInfoManager::IsDeclareVisibleToInstr(Instruction* dbg_declare, Instruction* scope) { assert(dbg_declare != nullptr); assert(scope != nullptr); std::vector<uint32_t> scope_ids; if (scope->opcode() == SpvOpPhi) { scope_ids.push_back(scope->GetDebugScope().GetLexicalScope()); for (uint32_t i = 0; i < scope->NumInOperands(); i += 2) { auto* value = context()->get_def_use_mgr()->GetDef( scope->GetSingleWordInOperand(i)); if (value != nullptr) scope_ids.push_back(value->GetDebugScope().GetLexicalScope()); } } else { scope_ids.push_back(scope->GetDebugScope().GetLexicalScope()); } uint32_t dbg_local_var_id = dbg_declare->GetSingleWordOperand(kDebugDeclareOperandLocalVariableIndex); auto dbg_local_var_itr = id_to_dbg_inst_.find(dbg_local_var_id); assert(dbg_local_var_itr != id_to_dbg_inst_.end()); uint32_t decl_scope_id = dbg_local_var_itr->second->GetSingleWordOperand( kDebugLocalVariableOperandParentIndex); // If the scope of DebugDeclare is an ancestor scope of the instruction's // scope, the local variable is visible to the instruction. for (uint32_t scope_id : scope_ids) { if (scope_id != kNoDebugScope && IsAncestorOfScope(scope_id, decl_scope_id)) { return true; } } return false; } bool DebugInfoManager::AddDebugValueIfVarDeclIsVisible( Instruction* scope_and_line, uint32_t variable_id, uint32_t value_id, Instruction* insert_pos, std::unordered_set<Instruction*>* invisible_decls) { assert(scope_and_line != nullptr); auto dbg_decl_itr = var_id_to_dbg_decl_.find(variable_id); if (dbg_decl_itr == var_id_to_dbg_decl_.end()) return false; bool modified = false; for (auto* dbg_decl_or_val : dbg_decl_itr->second) { if (!IsDeclareVisibleToInstr(dbg_decl_or_val, scope_and_line)) { if (invisible_decls) invisible_decls->insert(dbg_decl_or_val); continue; } // Avoid inserting the new DebugValue between OpPhi or OpVariable // instructions. Instruction* insert_before = insert_pos->NextNode(); while (insert_before->opcode() == SpvOpPhi || insert_before->opcode() == SpvOpVariable) { insert_before = insert_before->NextNode(); } modified |= AddDebugValueForDecl(dbg_decl_or_val, value_id, insert_before, scope_and_line) != nullptr; } return modified; } Instruction* DebugInfoManager::AddDebugValueForDecl( Instruction* dbg_decl, uint32_t value_id, Instruction* insert_before, Instruction* scope_and_line) { if (dbg_decl == nullptr || !IsDebugDeclare(dbg_decl)) return nullptr; std::unique_ptr<Instruction> dbg_val(dbg_decl->Clone(context())); dbg_val->SetResultId(context()->TakeNextId()); dbg_val->SetInOperand(kExtInstInstructionInIdx, {CommonDebugInfoDebugValue}); dbg_val->SetOperand(kDebugDeclareOperandVariableIndex, {value_id}); dbg_val->SetOperand(kDebugValueOperandExpressionIndex, {GetEmptyDebugExpression()->result_id()}); dbg_val->UpdateDebugInfoFrom(scope_and_line); auto* added_dbg_val = insert_before->InsertBefore(std::move(dbg_val)); AnalyzeDebugInst(added_dbg_val); if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) context()->get_def_use_mgr()->AnalyzeInstDefUse(added_dbg_val); if (context()->AreAnalysesValid( IRContext::Analysis::kAnalysisInstrToBlockMapping)) { auto insert_blk = context()->get_instr_block(insert_before); context()->set_instr_block(added_dbg_val, insert_blk); } return added_dbg_val; } uint32_t DebugInfoManager::GetVulkanDebugOperation(Instruction* inst) { assert(inst->GetShader100DebugOpcode() == NonSemanticShaderDebugInfo100DebugOperation && "inst must be Vulkan DebugOperation"); return context() ->get_constant_mgr() ->GetConstantFromInst(context()->get_def_use_mgr()->GetDef( inst->GetSingleWordOperand(kDebugOperationOperandOperationIndex))) ->GetU32(); } uint32_t DebugInfoManager::GetVariableIdOfDebugValueUsedForDeclare( Instruction* inst) { if (inst->GetCommonDebugOpcode() != CommonDebugInfoDebugValue) return 0; auto* expr = GetDbgInst(inst->GetSingleWordOperand(kDebugValueOperandExpressionIndex)); if (expr == nullptr) return 0; if (expr->NumOperands() != kDebugExpressOperandOperationIndex + 1) return 0; auto* operation = GetDbgInst( expr->GetSingleWordOperand(kDebugExpressOperandOperationIndex)); if (operation == nullptr) return 0; // OpenCL.DebugInfo.100 contains a literal for the operation, Vulkan uses an // OpConstant. if (inst->IsOpenCL100DebugInstr()) { if (operation->GetSingleWordOperand(kDebugOperationOperandOperationIndex) != OpenCLDebugInfo100Deref) { return 0; } } else { uint32_t operation_const = GetVulkanDebugOperation(operation); if (operation_const != NonSemanticShaderDebugInfo100Deref) { return 0; } } uint32_t var_id = inst->GetSingleWordOperand(kDebugDeclareOperandVariableIndex); if (!context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) { assert(false && "Checking a DebugValue can be used for declare needs DefUseManager"); return 0; } auto* var = context()->get_def_use_mgr()->GetDef(var_id); if (var->opcode() == SpvOpVariable && SpvStorageClass(var->GetSingleWordOperand( kOpVariableOperandStorageClassIndex)) == SpvStorageClassFunction) { return var_id; } return 0; } bool DebugInfoManager::IsDebugDeclare(Instruction* instr) { if (!instr->IsCommonDebugInstr()) return false; return instr->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare || GetVariableIdOfDebugValueUsedForDeclare(instr) != 0; } void DebugInfoManager::ReplaceAllUsesInDebugScopeWithPredicate( uint32_t before, uint32_t after, const std::function<bool(Instruction*)>& predicate) { auto scope_id_to_users_itr = scope_id_to_users_.find(before); if (scope_id_to_users_itr != scope_id_to_users_.end()) { for (Instruction* inst : scope_id_to_users_itr->second) { if (predicate(inst)) inst->UpdateLexicalScope(after); } scope_id_to_users_[after] = scope_id_to_users_itr->second; scope_id_to_users_.erase(scope_id_to_users_itr); } auto inlinedat_id_to_users_itr = inlinedat_id_to_users_.find(before); if (inlinedat_id_to_users_itr != inlinedat_id_to_users_.end()) { for (Instruction* inst : inlinedat_id_to_users_itr->second) { if (predicate(inst)) inst->UpdateDebugInlinedAt(after); } inlinedat_id_to_users_[after] = inlinedat_id_to_users_itr->second; inlinedat_id_to_users_.erase(inlinedat_id_to_users_itr); } } void DebugInfoManager::ClearDebugScopeAndInlinedAtUses(Instruction* inst) { auto scope_id_to_users_itr = scope_id_to_users_.find(inst->result_id()); if (scope_id_to_users_itr != scope_id_to_users_.end()) { scope_id_to_users_.erase(scope_id_to_users_itr); } auto inlinedat_id_to_users_itr = inlinedat_id_to_users_.find(inst->result_id()); if (inlinedat_id_to_users_itr != inlinedat_id_to_users_.end()) { inlinedat_id_to_users_.erase(inlinedat_id_to_users_itr); } } void DebugInfoManager::AnalyzeDebugInst(Instruction* inst) { if (inst->GetDebugScope().GetLexicalScope() != kNoDebugScope) { auto& users = scope_id_to_users_[inst->GetDebugScope().GetLexicalScope()]; users.insert(inst); } if (inst->GetDebugInlinedAt() != kNoInlinedAt) { auto& users = inlinedat_id_to_users_[inst->GetDebugInlinedAt()]; users.insert(inst); } if (!inst->IsCommonDebugInstr()) return; RegisterDbgInst(inst); if (inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction || inst->GetShader100DebugOpcode() == NonSemanticShaderDebugInfo100DebugFunctionDefinition) { RegisterDbgFunction(inst); } if (deref_operation_ == nullptr && inst->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugOperation && inst->GetSingleWordOperand(kDebugOperationOperandOperationIndex) == OpenCLDebugInfo100Deref) { deref_operation_ = inst; } if (deref_operation_ == nullptr && inst->GetShader100DebugOpcode() == NonSemanticShaderDebugInfo100DebugOperation) { uint32_t operation_const = GetVulkanDebugOperation(inst); if (operation_const == NonSemanticShaderDebugInfo100Deref) { deref_operation_ = inst; } } if (debug_info_none_inst_ == nullptr && inst->GetCommonDebugOpcode() == CommonDebugInfoDebugInfoNone) { debug_info_none_inst_ = inst; } if (empty_debug_expr_inst_ == nullptr && IsEmptyDebugExpression(inst)) { empty_debug_expr_inst_ = inst; } if (inst->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare) { uint32_t var_id = inst->GetSingleWordOperand(kDebugDeclareOperandVariableIndex); RegisterDbgDeclare(var_id, inst); } if (uint32_t var_id = GetVariableIdOfDebugValueUsedForDeclare(inst)) { RegisterDbgDeclare(var_id, inst); } } void DebugInfoManager::ConvertDebugGlobalToLocalVariable( Instruction* dbg_global_var, Instruction* local_var) { if (dbg_global_var->GetCommonDebugOpcode() != CommonDebugInfoDebugGlobalVariable) { return; } assert(local_var->opcode() == SpvOpVariable || local_var->opcode() == SpvOpFunctionParameter); // Convert |dbg_global_var| to DebugLocalVariable dbg_global_var->SetInOperand(kExtInstInstructionInIdx, {CommonDebugInfoDebugLocalVariable}); auto flags = dbg_global_var->GetSingleWordOperand( kDebugGlobalVariableOperandFlagsIndex); for (uint32_t i = dbg_global_var->NumInOperands() - 1; i >= kDebugLocalVariableOperandFlagsIndex; --i) { dbg_global_var->RemoveOperand(i); } dbg_global_var->SetOperand(kDebugLocalVariableOperandFlagsIndex, {flags}); context()->ForgetUses(dbg_global_var); context()->AnalyzeUses(dbg_global_var); // Create a DebugDeclare std::unique_ptr<Instruction> new_dbg_decl(new Instruction( context(), SpvOpExtInst, context()->get_type_mgr()->GetVoidTypeId(), context()->TakeNextId(), { {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetDbgSetImportId()}}, {spv_operand_type_t::SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER, {static_cast<uint32_t>(CommonDebugInfoDebugDeclare)}}, {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {dbg_global_var->result_id()}}, {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {local_var->result_id()}}, {spv_operand_type_t::SPV_OPERAND_TYPE_ID, {GetEmptyDebugExpression()->result_id()}}, })); // Must insert after all OpVariables in block Instruction* insert_before = local_var; while (insert_before->opcode() == SpvOpVariable) insert_before = insert_before->NextNode(); auto* added_dbg_decl = insert_before->InsertBefore(std::move(new_dbg_decl)); if (context()->AreAnalysesValid(IRContext::Analysis::kAnalysisDefUse)) context()->get_def_use_mgr()->AnalyzeInstDefUse(added_dbg_decl); if (context()->AreAnalysesValid( IRContext::Analysis::kAnalysisInstrToBlockMapping)) { auto insert_blk = context()->get_instr_block(local_var); context()->set_instr_block(added_dbg_decl, insert_blk); } } void DebugInfoManager::AnalyzeDebugInsts(Module& module) { deref_operation_ = nullptr; debug_info_none_inst_ = nullptr; empty_debug_expr_inst_ = nullptr; module.ForEachInst([this](Instruction* cpi) { AnalyzeDebugInst(cpi); }); // Move |empty_debug_expr_inst_| to the beginning of the debug instruction // list. if (empty_debug_expr_inst_ != nullptr && empty_debug_expr_inst_->PreviousNode() != nullptr && empty_debug_expr_inst_->PreviousNode()->IsCommonDebugInstr()) { empty_debug_expr_inst_->InsertBefore( &*context()->module()->ext_inst_debuginfo_begin()); } // Move |debug_info_none_inst_| to the beginning of the debug instruction // list. if (debug_info_none_inst_ != nullptr && debug_info_none_inst_->PreviousNode() != nullptr && debug_info_none_inst_->PreviousNode()->IsCommonDebugInstr()) { debug_info_none_inst_->InsertBefore( &*context()->module()->ext_inst_debuginfo_begin()); } } void DebugInfoManager::ClearDebugInfo(Instruction* instr) { auto scope_id_to_users_itr = scope_id_to_users_.find(instr->GetDebugScope().GetLexicalScope()); if (scope_id_to_users_itr != scope_id_to_users_.end()) { scope_id_to_users_itr->second.erase(instr); } auto inlinedat_id_to_users_itr = inlinedat_id_to_users_.find(instr->GetDebugInlinedAt()); if (inlinedat_id_to_users_itr != inlinedat_id_to_users_.end()) { inlinedat_id_to_users_itr->second.erase(instr); } if (instr == nullptr || !instr->IsCommonDebugInstr()) { return; } id_to_dbg_inst_.erase(instr->result_id()); if (instr->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugFunction) { auto fn_id = instr->GetSingleWordOperand(kDebugFunctionOperandFunctionIndex); fn_id_to_dbg_fn_.erase(fn_id); } if (instr->GetShader100DebugOpcode() == NonSemanticShaderDebugInfo100DebugFunction) { auto fn_id = instr->GetSingleWordOperand( kDebugFunctionDefinitionOperandOpFunctionIndex); fn_id_to_dbg_fn_.erase(fn_id); } if (instr->GetCommonDebugOpcode() == CommonDebugInfoDebugDeclare || instr->GetCommonDebugOpcode() == CommonDebugInfoDebugValue) { auto var_or_value_id = instr->GetSingleWordOperand(kDebugDeclareOperandVariableIndex); auto dbg_decl_itr = var_id_to_dbg_decl_.find(var_or_value_id); if (dbg_decl_itr != var_id_to_dbg_decl_.end()) { dbg_decl_itr->second.erase(instr); } } if (deref_operation_ == instr) { deref_operation_ = nullptr; for (auto dbg_instr_itr = context()->module()->ext_inst_debuginfo_begin(); dbg_instr_itr != context()->module()->ext_inst_debuginfo_end(); ++dbg_instr_itr) { // OpenCL.DebugInfo.100 contains the operation as a literal operand, in // Vulkan it's referenced as an OpConstant. if (instr != &*dbg_instr_itr && dbg_instr_itr->GetOpenCL100DebugOpcode() == OpenCLDebugInfo100DebugOperation && dbg_instr_itr->GetSingleWordOperand( kDebugOperationOperandOperationIndex) == OpenCLDebugInfo100Deref) { deref_operation_ = &*dbg_instr_itr; break; } else if (instr != &*dbg_instr_itr && dbg_instr_itr->GetShader100DebugOpcode() == NonSemanticShaderDebugInfo100DebugOperation) { uint32_t operation_const = GetVulkanDebugOperation(&*dbg_instr_itr); if (operation_const == NonSemanticShaderDebugInfo100Deref) { deref_operation_ = &*dbg_instr_itr; break; } } } } if (debug_info_none_inst_ == instr) { debug_info_none_inst_ = nullptr; for (auto dbg_instr_itr = context()->module()->ext_inst_debuginfo_begin(); dbg_instr_itr != context()->module()->ext_inst_debuginfo_end(); ++dbg_instr_itr) { if (instr != &*dbg_instr_itr && dbg_instr_itr->GetCommonDebugOpcode() == CommonDebugInfoDebugInfoNone) { debug_info_none_inst_ = &*dbg_instr_itr; break; } } } if (empty_debug_expr_inst_ == instr) { empty_debug_expr_inst_ = nullptr; for (auto dbg_instr_itr = context()->module()->ext_inst_debuginfo_begin(); dbg_instr_itr != context()->module()->ext_inst_debuginfo_end(); ++dbg_instr_itr) { if (instr != &*dbg_instr_itr && IsEmptyDebugExpression(&*dbg_instr_itr)) { empty_debug_expr_inst_ = &*dbg_instr_itr; break; } } } } } // namespace analysis } // namespace opt } // namespace spvtools
[ "branimirkaradzic@gmail.com" ]
branimirkaradzic@gmail.com
751c7110ac408eca54ac84908ce8f50cb6d4aee6
c0a96ec9a2266951872a56fb1b48c9af34ddcefc
/opencv-3.1.0/build/modules/imgproc/opencv_test_imgproc_pch_dephelp.cxx
0ae69b231bbe06ff59c453f71aecd3ecdfbb6364
[ "BSD-3-Clause", "Apache-2.0", "MIT" ]
permissive
fagan2888/LPReader
15692a6811ef0a9b395eea33db91e25b3a7c5cef
6841c3f5ef29ecbebfff1b20bcd43809d113f39e
refs/heads/master
2021-05-31T04:42:23.192340
2016-03-28T03:49:06
2016-03-28T03:49:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
142
cxx
#include "/home/gloria/Downloads/opencv-3.1.0/modules/imgproc/test/test_precomp.hpp" int testfunction(); int testfunction() { return 0; }
[ "gloria.leung@rutgers.edu" ]
gloria.leung@rutgers.edu
b32a6a0f15f7a25297a6983b1fa22690282946fd
ea401c3e792a50364fe11f7cea0f35f99e8f4bde
/released_plugins/v3d_plugins/neurontracing_neutube/src_neutube/neurolabi/gui/ext/boost/geometry/strategies/distance.hpp
4179f8250f659f6df46dbf55836b715f74cf925f
[ "BSD-2-Clause", "BSL-1.0", "MIT", "GPL-1.0-or-later", "LicenseRef-scancode-unknown-license-reference", "GPL-2.0-only" ]
permissive
Vaa3D/vaa3d_tools
edb696aa3b9b59acaf83d6d27c6ae0a14bf75fe9
e6974d5223ae70474efaa85e1253f5df1814fae8
refs/heads/master
2023-08-03T06:12:01.013752
2023-08-02T07:26:01
2023-08-02T07:26:01
50,527,925
107
86
MIT
2023-05-22T23:43:48
2016-01-27T18:19:17
C++
UTF-8
C++
false
false
2,700
hpp
// Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_STRATEGIES_DISTANCE_HPP #define BOOST_GEOMETRY_STRATEGIES_DISTANCE_HPP #include <boost/mpl/assert.hpp> #include <boost/geometry/core/cs.hpp> #include <boost/geometry/strategies/tags.hpp> namespace boost { namespace geometry { namespace strategy { namespace distance { namespace services { template <typename Strategy> struct tag {}; template <typename Strategy, typename P1, typename P2> struct return_type { BOOST_MPL_ASSERT_MSG ( false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY, (types<Strategy, P1, P2>) ); }; template <typename Strategy> struct comparable_type { BOOST_MPL_ASSERT_MSG ( false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY, (types<Strategy>) ); }; template <typename Strategy> struct get_comparable { BOOST_MPL_ASSERT_MSG ( false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY, (types<Strategy>) ); }; template <typename Strategy, typename P1, typename P2> struct result_from_distance {}; // For point-segment only: template <typename Strategy> struct strategy_point_point {}; // Default strategy /*! \brief Traits class binding a default strategy for distance to one (or possibly two) coordinate system(s) \ingroup distance \tparam GeometryTag tag (point/segment) for which this strategy is the default \tparam Point1 first point-type \tparam Point2 second point-type \tparam CsTag1 tag of coordinate system of first point type \tparam CsTag2 tag of coordinate system of second point type */ template < typename GeometryTag, typename Point1, typename Point2 = Point1, typename CsTag1 = typename cs_tag<Point1>::type, typename CsTag2 = typename cs_tag<Point2>::type, typename UnderlyingStrategy = void > struct default_strategy { BOOST_MPL_ASSERT_MSG ( false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE_COMBINATION , (types<Point1, Point2, CsTag1, CsTag2>) ); }; }}} // namespace strategy::distance::services }} // namespace boost::geometry #endif // BOOST_GEOMETRY_STRATEGIES_DISTANCE_HPP
[ "hanchuan.peng@gmail.com" ]
hanchuan.peng@gmail.com
7cbf52f509813c622341bde38c4d2c50e585824b
a2e04e4eac1cf93bb4c1d429e266197152536a87
/Cpp/SDK/BP_TreasureArtifact_box_02_a_Desc_classes.h
468c18e02c83e27a9bea4ed13d16dfb46a9a2a6a
[]
no_license
zH4x-SDK/zSoT-SDK
83a4b9fcdf628637613197cf644b7f4d101bb0cb
61af221bee23701a5df5f60091f96f2cf929846e
refs/heads/main
2023-07-16T18:23:41.914014
2021-08-27T15:44:23
2021-08-27T15:44:23
400,555,804
1
0
null
null
null
null
UTF-8
C++
false
false
810
h
#pragma once // Name: SoT, Version: 2.2.1.1 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_TreasureArtifact_box_02_a_Desc.BP_TreasureArtifact_box_02_a_Desc_C // 0x0000 (FullSize[0x0130] - InheritedSize[0x0130]) class UBP_TreasureArtifact_box_02_a_Desc_C : public UBootyItemDesc { public: static UClass* StaticClass() { static UClass* ptr = UObject::FindClass("BlueprintGeneratedClass BP_TreasureArtifact_box_02_a_Desc.BP_TreasureArtifact_box_02_a_Desc_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "zp2kshield@gmail.com" ]
zp2kshield@gmail.com
ce6e2e30400bc213e743e4a8669c7ae13c310b37
8642c2865a417d402f12ff38e417874dac4ed0f5
/export_eps.cpp
d0c81e0dfa6f511878b0a9e9983ae88e2de43492
[]
no_license
Neplex/symmetrical-guacamole
23fcac0b0ce407600a22fc5fd39d5117cc85832f
f5cf165f15ae3897172c78dc2e3fcdeba479cacf
refs/heads/master
2021-05-01T01:00:27.297999
2016-12-02T14:33:18
2016-12-02T14:33:18
75,391,197
0
0
null
null
null
null
UTF-8
C++
false
false
1,278
cpp
#include "export_eps.hpp" #include <assert.h> #define NDEBUG 1 using namespace std; Export_Eps::Export_Eps(char const *const _file_name, unsigned int const _x_max, unsigned int const _y_max, unsigned int const _res) : x_max(_x_max), y_max(_y_max), res(_res), output(_file_name, std::ofstream::out) { output << "%!PS-Adobe-2.0 EPSF-2.0" << endl; output << "%%BoundingBox: 0.0 0.0 " << ((x_max + 1) * res) << " " << ((y_max + 1) * res) << endl; output << "%%Pages: 1" << endl << "%%EndComments" << endl << "%%EndProlog" << endl; output << "/res { " << res << " } def" << endl; output << "/p { gsave newpath moveto 0 res rlineto res 0 rlineto 0 res neg " "rlineto closepath fill grestore } def" << endl; } Export_Eps::~Export_Eps() { output << "%%EOF" << endl; // file will be destroyed and thus the stream closed } void Export_Eps::plot(unsigned int const x, unsigned int const y) { output << (res * x) << " " << (res * y) << " p" << endl; } void Export_Eps::plot(Shape const *const sh) { assert(NULL != sh); for (unsigned int i = 0; i <= x_max; i++) { for (unsigned int j = 0; j <= y_max; j++) { if (sh->contains(i, j)) { plot(i, j); } } } }
[ "nicolas.hiot@etu.univ-orleans.fr" ]
nicolas.hiot@etu.univ-orleans.fr
ec24abebb2d45c2f25836511e77fd4719b935ee0
0570750c6d8e28d837f9e4f7dc825c968c874fb4
/build/Android/Preview1/app/src/main/include/Fuse.Scripting.BoolChangedArgs.h
136b4ebc552807b85fde92cca44fa5b97e53de6b
[]
no_license
theaustinthompson/maryjane
b3671d950aad58fd2ed490bda8aa1113aedf5a97
b4ddf76aa2a2caae77765435d0315cf9111d6626
refs/heads/master
2021-04-12T08:37:47.311922
2018-03-27T23:06:47
2018-03-27T23:06:47
126,034,050
0
0
null
null
null
null
UTF-8
C++
false
false
1,036
h
// This file was generated based on C:/Users/borde_000/AppData/Local/Fusetools/Packages/Fuse.Scripting/1.8.1/IScriptEvent.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Fuse.Scripting.IScriptEvent.h> #include <Uno.Bool.h> #include <Uno.UX.ValueChangedArgs-1.h> namespace g{namespace Fuse{namespace Scripting{struct BoolChangedArgs;}}} namespace g{ namespace Fuse{ namespace Scripting{ // public sealed class BoolChangedArgs :64 // { struct BoolChangedArgs_type : uType { ::g::Fuse::Scripting::IScriptEvent interface0; }; BoolChangedArgs_type* BoolChangedArgs_typeof(); void BoolChangedArgs__ctor_2_fn(BoolChangedArgs* __this, bool* value); void BoolChangedArgs__FuseScriptingIScriptEventSerialize_fn(BoolChangedArgs* __this, uObject* s); void BoolChangedArgs__New3_fn(bool* value, BoolChangedArgs** __retval); struct BoolChangedArgs : ::g::Uno::UX::ValueChangedArgs { void ctor_2(bool value); static BoolChangedArgs* New3(bool value); }; // } }}} // ::g::Fuse::Scripting
[ "austin@believeinthompson.com" ]
austin@believeinthompson.com
bb97b07590c520cce091ac175cc290772288f95c
f80f0f71b9f3b6b186484446188411c263cd0728
/9095.cpp
5b1af2e60d1fb019217709ae459616f3ea278816
[]
no_license
Kimuksung/algorithm
082c160a4ae27017ad01be2554e6eb47f28fb668
431ddb3807a9a4d55521919a43b9f43000300dbb
refs/heads/master
2021-06-26T01:54:04.759187
2021-01-08T15:23:29
2021-01-08T15:23:29
200,968,559
0
0
null
null
null
null
UTF-8
C++
false
false
417
cpp
#include <iostream> using namespace std; #include <vector> int arr[100]; int answer(int temp2) { int answer2; vector<int> temp; arr[1] = 1; arr[2] = 2; arr[3] = 4; for (int i = 4;i <= temp2;i++) { arr[i] = arr[i - 1] + arr[i - 2] + arr[i - 3]; } return arr[temp2]; } int main() { int n; cin >> n; for (int i = 0;i < n;i++) { int temp; cin >> temp; cout<<answer(temp)<<endl; } return 0; }
[ "kimuksung2@gmail.com" ]
kimuksung2@gmail.com
0cf50ffd84b8ab6a560332413e1f3978b2849e5a
3b1d08997d0dc9c444f2bdaaab55a8606c60d332
/IOCMain/CMXWrap/RTC.h
8eaf67606d737f41795edd461c346266bac36f1d
[]
no_license
zjsaisi/sm2000
8303ece373516c871694d382bb3daef9f5129d1a
0fa74cdb7566621162e1845dd4558723182a49ac
refs/heads/master
2020-04-16T09:22:12.797424
2019-01-23T10:31:07
2019-01-23T10:31:07
165,461,667
0
1
null
null
null
null
UTF-8
C++
false
false
1,310
h
// RTC.h: interface for the CRTC class. // ////////////////////////////////////////////////////////////////////// /* * $Header: RTC.h 1.2 2009/04/29 18:52:02PDT Zheng Miao (zmiao) Exp $ * $Revision: 1.2 $ */ #if !defined(AFX_RTC_H__F598CDC0_6174_42DB_A593_48450BF914F3__INCLUDED_) #define AFX_RTC_H__F598CDC0_6174_42DB_A593_48450BF914F3__INCLUDED_ #include "DataType.h" #ifdef __cplusplus class CRTC { public: uint32 GetMjd(void); void SetGpsLocal(int32 seconds); void SetComputerSeconds(uint32 seconds); unsigned long GetComputerSeconds(void); uint32 GetAbsoluteSecond(void); void SetGPSSeconds(uint32 seconds); int SetDateTime(int year, int month, int day, int hour, int minute, int second); void GetDateTime(int *year, int *month, int *day, int *hour, int *minute, int *second); unsigned long GetGPSSeconds(void); void SetTime(uint32 seconds); void TickOfOneSecond(void); CRTC(); virtual ~CRTC(); static int DaysOfMonth(int year, int month); private: static int IsLeapYear(int year); int DaysOfYear(int year); volatile uint32 m_seconds_1970; // seconds since 1/1/1970 uint32 volatile m_absoluteSecond; }; extern CRTC *g_pRTC; #endif EXTERN void RTOS_TICK(void); EXTERN uint32 GetRawTick(void); #endif // !defined(AFX_RTC_H__F598CDC0_6174_42DB_A593_48450BF914F3__INCLUDED_)
[ "you@example.com" ]
you@example.com
4160b9fb7dd0b97ef0fcc0e285234ef767ae28ad
9becd9b6722f4c0273625cc5803ac3f820cb9a3d
/Heavy Light Bruteforce/KALTSUM - k Alternating Sum.cpp
4f9e4a28051bb0acc54a4824f80b6127d93e9e65
[]
no_license
debsourav33/Category-Wise-Oonline-Judge-Solutions
b16566d3c2a0506f7c0c9f90956d0a7d1e61aa38
c69a1d35dd43c9265f7f804064b51f1ec16764be
refs/heads/master
2021-07-14T16:56:33.084844
2020-11-08T18:26:57
2020-11-08T18:26:57
219,268,909
0
0
null
null
null
null
UTF-8
C++
false
false
2,129
cpp
#include<bits/stdc++.h> using namespace std; //{ #define si(a) scanf("%d",&a) #define sii(a,b) scanf("%d %d",&a,&b); #define siii(a,b,c) scanf("%d %d %d",&a,&b,&c); #define sl(a) scanf("%lld",&a) #define sll(a,b) scanf("%lld %lld",&a,&b); #define slll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define outi(a) printf("%d\n",a) #define outii(a,b) printf("%d %d\n",a,b) #define outis(a) printf(" %d",a) #define outl(a) printf("%lld\n",a) #define outll(a,b) printf("%lld %lld\n",a,b) #define outls(a) printf(" %lld",a) #define cel(n,k) ((n-1)/k+1) #define sets(a) memset(a, -1, sizeof(a)) #define clr(a) memset(a, 0, sizeof(a)) #define fr(n) for(int i=0;i<n;i++) #define fr1(n) for(int i=1;i<=n;i++) #define frj(n) for(int j=0;j<n;j++) #define frj1(n) for(int j=1;j<=n;j++) #define pb push_back #define all(v) v.begin(),v.end() #define mp make_pair #define ff first #define ss second #define INF 10000007 #define fastIO() ios_base::sync_with_stdio(false); cin.tie(NULL); typedef long long i64; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<long long,long long> pll; //} const int N= 1e5+5; i64 n, q, a[N], presum[N][320], pre[N], sqroot; void preprocess(){ fr1(sqroot) { frj1(i) { i64 sum= 0, turn=1; for(int l=j; l<=n;l+=i) { int r= l+i-1; if(r>n) break; sum+= (pre[r]-pre[l-1]) * turn; presum[r][i]= sum; turn*=-1; } } } } void query1(int l, int r, int k){ i64 ans= presum[r][k]- presum[l-1][k]; int odd= (l-1)/k; if(odd%2) ans*=-1; outl(ans); } void query2(int l, int r, int k){ i64 ans= 0, turn= 1; int st= l+k-1; for(int i=st; i<=r;i+=k){ ans+= (pre[i]- pre[i-k]) * turn; turn*= -1; } outl(ans); } main(){ sll(n,q); fr1(n){ sl(a[i]); pre[i]= pre[i-1]+a[i]; } sqroot= (i64) sqrt(n); preprocess(); int l, r, k; while(q--){ siii(l,r,k); if(k>=sqroot) query2(l,r,k); else query1(l,r,k); } }
[ "debsourav33@gmail.com" ]
debsourav33@gmail.com
3b97087b4460988e52c950f2590c4f3e1272e3c1
62c4079409e7fc6bfa18fb4667d0e288f240d8d8
/obj_detect/include/detectors/ClassifierConfig.h
753d6104c2b20d7226a244c714e14769e4814040
[]
no_license
RoboticsLabURJC/2017-tfm-jorge_vela
e91e5fd6e4a9406cdff8cfde99c2d9687abe873f
b72283723d3549d05d5a438dfda4afc84931c8fc
refs/heads/master
2021-03-19T14:41:07.285716
2021-02-22T11:30:19
2021-02-22T11:30:19
111,129,118
4
0
null
null
null
null
UTF-8
C++
false
false
1,210
h
/** ------------------------------------------------------------------------ * * @brief DetectionRectangle. * @author Jorge Vela * @author Jose M. Buenaposada (josemiguel.buenaposada@urjc.es) * @date 2020/09/29 * * ------------------------------------------------------------------------ */ #ifndef CLASSIFIER_CONFIG_HPP #define CLASSIFIER_CONFIG_HPP #include <opencv2/opencv.hpp> struct channelsLUV{ int smooth_kernel_size; int smooth; }; struct gradientMag{ int normRad; float normConst; }; struct gradientHist{ int binSize; int nOrients; int softBin; int full; }; /** ------------------------------------------------------------------------ * * @brief Struct whit the classifier values to extract data LUV, MAG, HIST. * * ------------------------------------------------------------------------ */ struct ClassifierConfig { cv::Size padding; int nOctUp; int nPerOct; int nApprox; int shrink; //int stride; channelsLUV luv; gradientMag gradMag; gradientHist gradHist; std::vector<float> lambdas; cv::Size minDs; cv::Size modelDsPad; cv::Size modelDs; float cascThr; int stride; }; #endif // DETECTION_HPP
[ "velajorge.93@gmail.com" ]
velajorge.93@gmail.com
f108229355fce2f9c5fa25ed7d378679087111c0
ba4c240c04e9cdca87b50114845bbf4f51fe9f4c
/Packages/Packages.cc
9d9c499a8ce6b01b8ba0e7dca69f6d7af0c36ae8
[]
no_license
dparnell/newton-framework
a04044c41ae0eeee2e21e6816960cc27a9d50c74
8955e8d138b4755c0ac9024829b31a1538dd54f8
refs/heads/master
2021-01-22T20:54:42.855698
2017-03-14T13:33:43
2017-03-14T13:33:43
85,375,138
0
0
null
2017-03-18T04:16:43
2017-03-18T04:16:42
null
UTF-8
C++
false
false
7,841
cc
/* File: Packages.cc Contains: Package loaders etc. Written by: Newton Research Group. */ #include "Objects.h" #include "ROMResources.h" #include "PackageTypes.h" #include "PackageParts.h" #include "LargeBinaries.h" #include "NewtonScript.h" #include "MemoryPipe.h" #include "EndpointPipe.h" #include "EndpointClient.h" /* ----------------------------------------------------------------------------- D a t a ----------------------------------------------------------------------------- */ const char * const kPackageMagicNumber = "package01"; extern "C" { Ref FObjectPkgRef(RefArg inRcvr, RefArg inPkg); Ref FGetPkgRefInfo(RefArg inRcvr, RefArg inPkg); Ref FIsValid(RefArg inRcvr, RefArg inPkg); } Ref FObjectPkgRef(RefArg inRcvr, RefArg inPkg) { return NILREF; } Ref FGetPkgRefInfo(RefArg inRcvr, RefArg inPkg) { return NILREF; } Ref FIsValid(RefArg inRcvr, RefArg inPkg) { return NILREF; } /* ----------------------------------------------------------------------------- Determine whether block of data is a package header. Args: inData pointer to data inSize size of data Return: true => is a package header ----------------------------------------------------------------------------- */ bool IsPackageHeader(Ptr inData, size_t inSize) { bool isOK = false; if (inSize >= sizeof(PackageDirectory)) { PackageDirectory * directory = (PackageDirectory *)inData; newton_try { ArrayIndex i; for (i = 0, isOK = true; i < kPackageMagicLen && isOK; ++i) { if (directory->signature[i] != kPackageMagicNumber[i]) isOK = false; } if (isOK) { for (isOK = false; i < kPackageMagicLen+kPackageMagicVersionCount && !isOK; ++i) { if (directory->signature[kPackageMagicLen] == kPackageMagicNumber[i]) isOK = true; } } } newton_catch(exBusError) isOK = false; newton_catch(exPermissionViolation) isOK = false; end_try; } return isOK; } #pragma mark - /* ------------------------------------------------------------------------------- Allocate a package on a store, providing feedback. Args: inPipe the piped package inStore the store on which to store the package inCallback a callback frame for providing progress feedback inFreq number of bytes after which we should callback inActivate activate package after storing it? Return: a package frame ------------------------------------------------------------------------------- */ Ref AllocatePackage(CPipe * inPipe, RefArg inStore, RefArg inCallback, size_t inFreq, bool inActivate) { NewtonErr err; CLOCallback callback; callback.setFunc(inCallback); callback.setChunk(inFreq); callback.setInfo(RA(NILREF)); PSSId id; RefVar storeObject = NOTNIL(inStore) ? (Ref)inStore : NSCallGlobalFn(SYMA(GetDefaultStore)); CStoreWrapper * storeWrapper = (CStoreWrapper *)GetFrameSlot(storeObject, SYMA(store)); GC(); if ((err = StorePackage(inPipe, storeWrapper->store(), &callback, &id)) != noErr) ThrowErr(exFrames, err); return NSCallGlobalFn(SYMA(RegisterNewPackage), WrapPackage(storeWrapper->store(), id), storeObject, MAKEBOOLEAN(inActivate)); } /* ------------------------------------------------------------------------------- Allocate a package. Args: inPipe the piped package inStore the store on which to store the package inParms installation parameter frame Return: a package frame ------------------------------------------------------------------------------- */ Ref AllocatePackage(CPipe * inPipe, RefArg inStore, RefArg inParms) { RefVar cbFrame; Ref cbFreq; size_t freq = 4*KByte; bool doActivate = true; if (NOTNIL(inParms)) { // create AllocatePackage args from parms frame cbFrame = GetFrameSlot(inParms, SYMA(callback)); doActivate = ISNIL(GetFrameSlot(inParms, SYMA(don_27tActivate))); cbFreq = GetFrameSlot(inParms, SYMA(callbackFreq)); if (NOTNIL(cbFreq)) freq = RINT(cbFreq); } return AllocatePackage(inPipe, inStore, cbFrame, freq, doActivate); } /* ------------------------------------------------------------------------------- Create a new package. NTK calls in here to download a package. Args: inPipe the piped package inStore the store on which to store the package inCallback a callback frame for providing progress feedback inFreq number of bytes after which we should callback Return: a package frame ------------------------------------------------------------------------------- */ NewtonErr NewPackage(CPipe * inPipe, RefArg inStore, RefArg inCallback, size_t inFreq) { NewtonErr err = noErr; RefVar pkg; newton_try { pkg = AllocatePackage(inPipe, inStore, inCallback, inFreq, true); } newton_catch_all { err = (NewtonErr)(long)CurrentException()->data;; } end_try; return err; } /* ------------------------------------------------------------------------------- Suck a package through a pipe, providing feedback. Args: inPipe the piped package inStore the store on which to store the package inCallback a callback frame for providing progress feedback inFreq number of bytes after which we should callback inActivate activate package after storing it? Return: a package frame ------------------------------------------------------------------------------- */ Ref SuckPackageThruPipe(CPipe * inPipe, RefArg inStore, RefArg inCallback, size_t inFreq, bool inActivate) { return AllocatePackage(inPipe, inStore, inCallback, inFreq, inActivate); } /* ------------------------------------------------------------------------------- Suck a package through a pipe. Args: inPipe the piped package inStore the store on which to store the package inParms installation parameters Return: a package frame ------------------------------------------------------------------------------- */ Ref SuckPackageThruPipe(CPipe * inPipe, RefArg inStore, RefArg inParms) { return AllocatePackage(inPipe, inStore, inParms); } #pragma mark - /* ----------------------------------------------------------------------------- P l a i n C I n t e r f a c e ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------- Suck a package from a binary object. We do this by creating a memory pipe so we can SuckPackageThruPipe() Args: inRcvr a store frame inBinary the binary object containing the package inParms params frame Return: a package frame ------------------------------------------------------------------------------- */ Ref StoreSuckPackageFromBinary(RefArg inRcvr, RefArg inBinary, RefArg inParms) { RefVar pkg; #if !defined(forFramework) size_t binSize = Length(inBinary); CDataPtr binData(inBinary); CBufferSegment * buf = CBufferSegment::make(); buf->init((char *)binData, binSize); CMemoryPipe pipe; pipe.init(buf, NULL, false); pkg = SuckPackageThruPipe(&pipe, inRcvr, inParms); buf->destroy(); #endif return pkg; } /* ------------------------------------------------------------------------------- Suck a package from an endpoint. Args: inRcvr a store frame inBinary the binary object containing the package inParms params frame Return: a package frame ------------------------------------------------------------------------------- */ Ref StoreSuckPackageFromEndpoint(RefArg inRcvr, RefArg inEndpoint, RefArg inParms) { NewtonErr err = noErr; RefVar pkg; #if 0 /* endpoints don’t work yet */ CEndpoint * ep = GetClientEndpoint(inEndpoint); if (ep) { CEndpointPipe epp; newton_try { epp.init(ep, 2*KByte, 0, 0, false, NULL); pkg = AllocatePackage(&epp, inRcvr, inParms); } newton_catch_all { err = (NewtonErr)(long)CurrentException()data; } end_try; } #endif if (err) ThrowErr(exFrames, err); return pkg; }
[ "simon@newtonresearch.org" ]
simon@newtonresearch.org
d328d24824a78131daf085dd55fe664e2612a69e
0b3bd3ceaed3ecc7bebe89a84fd134ce00b3d600
/dvdwaala/dvdwaala/dvdwaala.cpp
2e841346ffa3e7633fd0b0eb901e172f5e467bc6
[]
no_license
ashar-sarwar/Object-oriented-programming-uni-work
5eb668f4131bba4a38ba0a8ebbc5a7d3928859b3
4bea74409db8dddeb6ffa7623e66a172f3242a7a
refs/heads/master
2020-03-11T03:45:41.142241
2018-06-01T11:00:09
2018-06-01T11:00:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
709
cpp
// dvdwaala.cpp : Defines the entry point for the console application. #include <stdafx.h> #include <iostream> #include <string> using namespace std; //#include "dvd.h" #include "DVDCollection.h" int main() { DvdCollection mycollection; Dvd d1; Dvd d2("Windows10","Microsoft",150); Dvd d3("Windows8","Microsoft",120); Dvd d4("Mac11","Apple",150); Dvd d5("GTA 5","Rockstar",150); Dvd d6("CS","Ubisoft",150); mycollection.add_Dvd(d1); mycollection.add_Dvd(d2); mycollection.add_Dvd(d3); mycollection.add_Dvd(d4); mycollection.add_Dvd(d5); //mycollection.add_Dvd(d6); // mycollection.show(); system("pause"); }
[ "“asharsarwar186@gmail.com”" ]
“asharsarwar186@gmail.com”
ac5731dedfd0ed70a0d7632dfa29e2e98f35949e
6cd33a276282fef63940f49dabc6fdcffc00623a
/include/nana/gui/widgets/treebox.hpp
2616cc1eed36e6f2a521a79cb6c98395a40ef895
[ "BSL-1.0" ]
permissive
qPCR4vir/nana.cygwin
a32ea24d7d6cee4f2545724d488c975b11ce76c2
3e289bf4ff7861953e912a8f058e21b665be7f4a
refs/heads/master
2021-05-01T20:06:46.648597
2015-03-28T20:00:13
2015-03-28T20:00:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,828
hpp
/* * A Tree Box Implementation * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.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) * * @file: nana/gui/widgets/treebox.hpp * @brief: * The treebox organizes the nodes by a key string. * The treebox would have a vertical scrollbar if the node * is too many to display. And it does not have a horizontal scrollbar, * the widget will adjust the node's displaying position for fitting. */ #ifndef NANA_GUI_WIDGETS_TREEBOX_HPP #define NANA_GUI_WIDGETS_TREEBOX_HPP #include "widget.hpp" #include "scroll.hpp" #include <nana/paint/gadget.hpp> #include "detail/tree_cont.hpp" #include <nana/gui/timer.hpp> #include <nana/any.hpp> namespace nana { namespace gui { namespace drawerbase { namespace treebox { class tooltip_window; template<typename NodeType> struct extra_events { typedef NodeType node_type; nana::fn_group<void(nana::gui::window, node_type, bool)> expand; nana::fn_group<void(nana::gui::window, node_type, bool)> selected; }; struct node_image_tag { nana::paint::image normal; nana::paint::image highlighted; nana::paint::image expanded; }; class trigger :public drawer_trigger { public: struct treebox_node_type { treebox_node_type(); treebox_node_type(const nana::any&); treebox_node_type(const nana::string& text, const nana::any&); treebox_node_type& operator=(const treebox_node_type&); nana::string text; nana::any value; bool expanded; nana::string img_idstr; }; struct pseudo_node_type{}; typedef nana::gui::widgets::detail::tree_cont<treebox_node_type> tree_cont_type; typedef tree_cont_type::node_type node_type; typedef extra_events<pseudo_node_type*> ext_event_type; trigger(); void auto_draw(bool); bool check(const node_type*) const; nana::any & value(node_type*) const; node_type* find(const nana::string& key_path); node_type* get_owner(const node_type*) const; node_type* get_root() const; node_type* insert(node_type* node, const nana::string& key, const nana::string& title, const nana::any& v); node_type* insert(const nana::string& path, const nana::string& title, const nana::any& v); bool check(node_type* parent, node_type* child) const; void remove(node_type*); node_type * selected() const; void selected(node_type*); void set_expand(node_type* node, bool); void set_expand(const nana::string& path, bool); unsigned visual_item_size() const; void image(const nana::string& id, const node_image_tag&); node_image_tag& image(const nana::string&) const; void image_erase(const nana::string&); void node_image(node_type* node, const nana::string& id); unsigned long node_width(const node_type *node) const; bool rename(node_type *node, const nana::char_t* key, const nana::char_t* name); ext_event_type& ext_event() const; private: void bind_window(widget_reference); void attached(graph_reference); void detached(); void refresh(graph_reference); void dbl_click(graph_reference, const eventinfo&); void mouse_down(graph_reference, const eventinfo&); void mouse_up(graph_reference, const eventinfo&); void mouse_move(graph_reference, const eventinfo&); void mouse_wheel(graph_reference, const eventinfo&); void resize(graph_reference, const eventinfo&); void key_down(graph_reference, const eventinfo&); void key_char(graph_reference, const eventinfo&); private: void _m_find_first(unsigned long offset); unsigned _m_node_height() const; unsigned _m_max_allow() const; private: const node_type* _m_find_track_node(nana::char_t); nana::paint::image* _m_image(const node_type*); bool _m_track_mouse(int x, int y); void _m_tooltip_window(node_type* node, const nana::point& pos, const nana::size& size); void _m_close_tooltip_window(); void _m_mouse_move_tooltip_window(); void _m_click_tooltip_window(const eventinfo&); bool _m_draw(bool scrollbar_react); void _m_draw_tree(); unsigned _m_visible_width() const; void _m_show_scrollbar(); void _m_event_scrollbar(const eventinfo&); bool _m_adjust(node_type * node, int reason); bool _m_set_selected(node_type * node); bool _m_set_expanded(node_type* node, bool value); void _m_deal_adjust(); private: //Functor class item_renderer { public: typedef tree_cont_type::node_type node_type; item_renderer(trigger&, const nana::point&); //affect //0 = Sibling, the last is a sibling of node //1 = Owner, the last is the owner of node //>=2 = Children, the last is a child of a node that before this node. int operator()(const node_type& node, int affect); unsigned width(const node_type &node) const; private: void _m_draw_arrow(const node_type& node, unsigned item_height, bool expand); void _m_background(const node_type& node, bool has_child, bool expand); private: trigger& drawer_; nana::point pos_; }; class item_locator { public: struct object { enum{none, item, arrow};}; item_locator(trigger& drawer, int item_pos, int x, int y); int operator()(tree_cont_type::node_type &node, int affect); tree_cont_type::node_type * node() const; unsigned what() const; nana::point pos() const; nana::size size() const; private: trigger& drawer_; int item_pos_; int item_ypos_; nana::point pos_; unsigned object_; tree_cont_type::node_type * node_; }; struct pred_allow_child { bool operator()(const tree_cont_type::node_type& node); }; private: nana::paint::graphics *graph_; widget *widget_; struct drawing_flags { drawing_flags(); bool pause; //It is a drawing flag, if it is true, the draw function dose nothing. }dwflags_; struct shape_data_type { shape_data_type(); nana::upoint border; nana::gui::scroll<true> scrollbar; unsigned long prev_first_value; // mutable std::map<nana::string, node_image_tag> image_table; }shape_; struct attribute_type { attribute_type(); bool auto_draw; mutable ext_event_type ext_event; std::size_t mutable visual_item_size; uint32_t button_width; tree_cont_type tree_cont; }attr_; struct node_desc_type { node_desc_type(); tree_cont_type::node_type * first; unsigned indent_size; int offset_x; int item_offset; //the offset of item to the start pos int text_offset; //the offset of text to the item unsigned long image_width; }node_desc_; struct node_state { node_state(); tooltip_window *tooltip; tree_cont_type::node_type * highlight; unsigned highlight_object; tree_cont_type::node_type * selected; tree_cont_type::node_type * event_node; }node_state_; struct track_node_tag { track_node_tag(); nana::string key_buf; unsigned long key_time; }track_node_; struct adjust_desc_type { adjust_desc_type(); int offset_x_adjust; //It is a new value of offset_x, and offset_x will be adjusted to the new value. tree_cont_type::node_type * node; unsigned long scroll_timestamp; nana::gui::timer timer; }adjust_; }; //end class trigger }//end namespace treebox }//end namespace drawerbase template<typename UserData> class treebox :public widget_object<category::widget_tag, drawerbase::treebox::trigger> { public: typedef UserData value_type; typedef typename drawer_trigger_t::pseudo_node_type* node_type; typedef typename drawer_trigger_t::ext_event_type ext_event_type; typedef drawerbase::treebox::node_image_tag node_image_type; treebox(){} treebox(window wd, bool visible) { create(wd, rectangle(), visible); } treebox(window wd, const rectangle& r, bool visible) { create(wd, r, visible); } void auto_draw(bool ad) { get_drawer_trigger().auto_draw(ad); } ext_event_type& ext_event() const { return get_drawer_trigger().ext_event(); } value_type& value(node_type node) const { return get_drawer_trigger().value(reinterpret_cast<drawer_trigger_t::node_type*>(node)); } treebox& image(const nana::string& id, const nana::paint::image& img) { node_image_type node_img; node_img.normal = img; get_drawer_trigger().image(id, node_img); return *this; } treebox& image(const nana::string& id, const node_image_type& node_img) { get_drawer_trigger().image(id, node_img); return *this; } node_image_type& image(const nana::string& id) const { return get_drawer_trigger().image(id); } void image_erase(const nana::string& id) { get_drawer_trigger().image_erase(id); } void node_image(node_type node, const nana::string& id) { get_drawer_trigger().node_image(reinterpret_cast<drawer_trigger_t::node_type*>(node), id); } node_type insert(const nana::string& path_key, const nana::string& title, value_type value) { return reinterpret_cast<node_type>(get_drawer_trigger().insert(path_key, title, value)); } node_type insert(node_type node, const nana::string& key, const nana::string& title, value_type value) { return reinterpret_cast<node_type>(get_drawer_trigger().insert(reinterpret_cast<drawer_trigger_t::node_type*>(node), key, title, value)); } void remove(node_type node) { get_drawer_trigger().remove(reinterpret_cast<drawer_trigger_t::node_type*>(node)); } void remove(const nana::string& key_path) { get_drawer_trigger().remove( get_drawer_trigger().find(key_path) ); } void expand(node_type node, bool exp) { get_drawer_trigger().set_expand(reinterpret_cast<drawer_trigger_t::node_type*>(node), exp); } void expand(const nana::string& path_key, bool exp) { get_drawer_trigger().set_expand(path_key, exp); } bool expend(node_type node) const { if(get_drawer_trigger().check(reinterpret_cast<drawer_trigger_t::node_type*>(node))) return reinterpret_cast<drawer_trigger_t::node_type*>(node)->value.second.expanded; return false; } node_type node(const nana::string& keypath) { return reinterpret_cast<node_type>(get_drawer_trigger().find(keypath)); } nana::string key(node_type node) const { if(get_drawer_trigger().check(reinterpret_cast<drawer_trigger_t::node_type*>(node))) return reinterpret_cast<drawer_trigger_t::node_type*>(node)->value.first; return nana::string(); } bool key(node_type node, const nana::string& key) { return (get_drawer_trigger().rename(reinterpret_cast<drawer_trigger_t::node_type*>(node), key.c_str(), 0)); } bool text(node_type node, const nana::string& str) { return (get_drawer_trigger().rename(reinterpret_cast<drawer_trigger_t::node_type*>(node), 0, str.c_str())); } nana::string text(node_type node) const { if(get_drawer_trigger().check(reinterpret_cast<drawer_trigger_t::node_type*>(node))) return reinterpret_cast<drawer_trigger_t::node_type*>(node)->value.second.text; return nana::string(); } node_type selected() const { return reinterpret_cast<node_type>(get_drawer_trigger().selected()); } void selected(node_type node) { get_drawer_trigger().selected(reinterpret_cast<drawer_trigger_t::node_type*>(node)); } unsigned children_size(node_type node) const { if(get_drawer_trigger().check(reinterpret_cast<drawer_trigger_t::node_type*>(node))) { drawer_trigger_t::node_type* child = reinterpret_cast<drawer_trigger_t::node_type*>(node)->child; unsigned n = 0; for(; child; child = child->next) ++n; return n; } return 0; } node_type get_sibling(node_type node) const { if(get_drawer_trigger().check(reinterpret_cast<drawer_trigger_t::node_type*>(node))) return reinterpret_cast<node_type>( reinterpret_cast<drawer_trigger_t::node_type*>(node)->next ); return 0; } node_type get_child(node_type node) const { if(get_drawer_trigger().check(reinterpret_cast<drawer_trigger_t::node_type*>(node))) return reinterpret_cast<node_type>( reinterpret_cast<drawer_trigger_t::node_type*>(node)->child ); return 0; } node_type get_owner(node_type node) const { return reinterpret_cast<node_type>( get_drawer_trigger().get_owner(reinterpret_cast<drawer_trigger_t::node_type*>(node)) ); } nana::string make_key_path(node_type node, const nana::string& splitter) const { const typename drawer_trigger_t::node_type *pnode = reinterpret_cast<drawer_trigger_t::node_type*>(node); if(get_drawer_trigger().check(pnode)) { const typename drawer_trigger_t::node_type* root = get_drawer_trigger().get_root(); nana::string path; nana::string temp; while(pnode->owner != root) { temp = splitter; temp += pnode->value.first; path.insert(0, temp); pnode = pnode->owner; } path.insert(0, pnode->value.first); return path; } return STR(""); } }; }//end namespace gui }//end namespace nana #endif
[ "lzbgt@126.com" ]
lzbgt@126.com
d3f231c3926414001b0da7a34c9b21ac615cf94d
3601d7521b88d22b7e8afef8f031c64f5f075d91
/Interfaces/UserGetQuestion.cpp
fad17e993517e06e5d855e779bea076bb01c11c6
[]
no_license
GDUTSZH/AccountManagement
1d27ac34b4b64c5510ab4526564bdb2588adcba7
6cf1bc6d5e0c257fe9ebf023de0df4ec2b1eb0f5
refs/heads/master
2021-05-15T16:55:50.388098
2017-11-21T08:49:29
2017-11-21T08:49:29
107,562,902
1
1
null
null
null
null
UTF-8
C++
false
false
2,535
cpp
#include "UserGetQuestion.h" #define USER_GET_QUESTION_STR(sName) \ "SELECT * FROM \ ( \ SELECT user_question1 AS QUESTIONS \ FROM AccountManagement_User WHERE \ user_name=\'"+(sName)+"\' \ UNION ALL \ SELECT user_question2 AS QUESTIONS \ FROM AccountManagement_User WHERE \ user_name=\'"+(sName)+"\' \ UNION ALL \ SELECT user_question3 AS QUESTIONS \ FROM AccountManagement_User WHERE \ user_name=\'"+(sName)+"\' \ ) TempList;" CUserGetQuestion::CUserGetQuestion(PREQ pReq) : CHttpCommon(pReq) { } CUserGetQuestion::~CUserGetQuestion() { } void CUserGetQuestion::Handle() { Json::Value jData; if(!ParseParam(jData)) return; if(!jData.isMember("name")) { Send_Error(404, Error_Data_Param_Miss); return; } string sValues = USER_GET_QUESTION_STR(jData["name"].asString()); Json::Value jRoot = CMySQL_Client::GetInstance()->Select(sValues); if(jRoot.isMember("error")) { Send_Fail(502, Error_Operation_Rrror(2, "User Login Failure")); return; } int ret = jRoot["array"].size(); //问题个数小于 if(ret < 3) { Json::Value jContant; jContant["data"] = "用户名不存在"; Json::Value jRet; jRet["code"] = 2; jRet["contant"] = jContant; Send(504, jRet.toStyledString()); return; } Json::Value jContant; jContant["question"] = jRoot["array"]; jContant["data"] = "Get Password Success"; Json::Value jRet; jRet["code"] = 1; jRet["contant"] = jContant; Send(200, jRet.toStyledString()); }
[ "gdut_szh@163.com" ]
gdut_szh@163.com
2647a73f2e240df3c73a16960c90e0063c725162
948f4e13af6b3014582909cc6d762606f2a43365
/testcases/juliet_test_suite/testcases/CWE124_Buffer_Underwrite/s03/CWE124_Buffer_Underwrite__new_char_memcpy_83_goodG2B.cpp
c86a905a08b21ed1f9820db603a76df14f4159dd
[]
no_license
junxzm1990/ASAN--
0056a341b8537142e10373c8417f27d7825ad89b
ca96e46422407a55bed4aa551a6ad28ec1eeef4e
refs/heads/master
2022-08-02T15:38:56.286555
2022-06-16T22:19:54
2022-06-16T22:19:54
408,238,453
74
13
null
2022-06-16T22:19:55
2021-09-19T21:14:59
null
UTF-8
C++
false
false
1,866
cpp
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE124_Buffer_Underwrite__new_char_memcpy_83_goodG2B.cpp Label Definition File: CWE124_Buffer_Underwrite__new.label.xml Template File: sources-sink-83_goodG2B.tmpl.cpp */ /* * @description * CWE: 124 Buffer Underwrite * BadSource: Set data pointer to before the allocated memory buffer * GoodSource: Set data pointer to the allocated memory buffer * Sinks: memcpy * BadSink : Copy string to data using memcpy * Flow Variant: 83 Data flow: data passed to class constructor and destructor by declaring the class object on the stack * * */ #ifndef OMITGOOD #include "std_testcase.h" #include "CWE124_Buffer_Underwrite__new_char_memcpy_83.h" namespace CWE124_Buffer_Underwrite__new_char_memcpy_83 { CWE124_Buffer_Underwrite__new_char_memcpy_83_goodG2B::CWE124_Buffer_Underwrite__new_char_memcpy_83_goodG2B(char * dataCopy) { data = dataCopy; { char * dataBuffer = new char[100]; memset(dataBuffer, 'A', 100-1); dataBuffer[100-1] = '\0'; /* FIX: Set data pointer to the allocated memory buffer */ data = dataBuffer; } } CWE124_Buffer_Underwrite__new_char_memcpy_83_goodG2B::~CWE124_Buffer_Underwrite__new_char_memcpy_83_goodG2B() { { char source[100]; memset(source, 'C', 100-1); /* fill with 'C's */ source[100-1] = '\0'; /* null terminate */ /* POTENTIAL FLAW: Possibly copying data to memory before the destination buffer */ memcpy(data, source, 100*sizeof(char)); /* Ensure the destination buffer is null terminated */ data[100-1] = '\0'; printLine(data); /* INCIDENTAL CWE-401: Memory Leak - data may not point to location * returned by new [] so can't safely call delete [] on it */ } } } #endif /* OMITGOOD */
[ "yzhang0701@gmail.com" ]
yzhang0701@gmail.com
ea122a20d7ec4109638a0637e230b04b5fe9e4b6
e464f1343cfe35bac84abf63f7ce08bff041c24c
/src/base/VulkanCommandBuffer.cpp
06fc431720ba71e6936336cdd8752bea50cd69e6
[]
no_license
brioche1703/VulkanLearning
08b8202d8bc1caee456a24c99a33fc4663674621
9b1ef41ddf439d8a2ba96bb6600d63b787ffeeed
refs/heads/master
2023-05-18T04:26:57.957553
2021-06-11T12:48:18
2021-06-11T12:48:18
275,235,534
2
0
null
null
null
null
UTF-8
C++
false
false
3,688
cpp
#include "VulkanCommandBuffer.hpp" #include <vulkan/vulkan_core.h> namespace VulkanLearning { VulkanCommandBuffer::VulkanCommandBuffer() {} VulkanCommandBuffer::~VulkanCommandBuffer() {} void VulkanCommandBuffer::create(VulkanDevice* device, VkCommandBufferLevel level, bool begin) { VkCommandBufferAllocateInfo allocInfo{}; allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; allocInfo.level = level; allocInfo.commandPool = device->getCommandPool(); allocInfo.commandBufferCount = 1; vkAllocateCommandBuffers(device->getLogicalDevice(), &allocInfo, &m_commandBuffer); VkCommandBufferBeginInfo beginInfo{}; beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; //beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; vkBeginCommandBuffer(m_commandBuffer, &beginInfo); } void VulkanCommandBuffer::flushCommandBuffer(VulkanDevice* device, bool free) { if (m_commandBuffer == VK_NULL_HANDLE) { return; } if (vkEndCommandBuffer(m_commandBuffer) != VK_SUCCESS) { throw std::runtime_error("Command buffer end failed!"); } VkSubmitInfo submitInfo = {}; submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &m_commandBuffer; VkFenceCreateInfo fenceInfo = {}; fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; VkFence fence; if (vkCreateFence(device->getLogicalDevice(), &fenceInfo, nullptr, &fence) != VK_SUCCESS) { throw std::runtime_error("Fence creation failed!"); } if (vkQueueSubmit(device->getGraphicsQueue(), 1, &submitInfo, fence) != VK_SUCCESS) { throw std::runtime_error("Fence submition to queue failed!"); } if (vkWaitForFences(device->getLogicalDevice(), 1, &fence, VK_TRUE, UINT64_MAX) != VK_SUCCESS) { throw std::runtime_error("Waiting for fence failed!"); } vkDestroyFence(device->getLogicalDevice(), fence, nullptr); if (free) { vkFreeCommandBuffers(device->getLogicalDevice(), device->getCommandPool(), 1, &m_commandBuffer); } } void VulkanCommandBuffer::flushCommandBuffer(VulkanDevice* device, VkQueue queue, bool free) { if (m_commandBuffer == VK_NULL_HANDLE) { return; } if (vkEndCommandBuffer(m_commandBuffer) != VK_SUCCESS) { throw std::runtime_error("Command buffer end failed!"); } VkSubmitInfo submitInfo = {}; submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &m_commandBuffer; VkFenceCreateInfo fenceInfo = {}; fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; VkFence fence; if (vkCreateFence(device->getLogicalDevice(), &fenceInfo, nullptr, &fence) != VK_SUCCESS) { throw std::runtime_error("Fence creation failed!"); } if (vkQueueSubmit(queue, 1, &submitInfo, fence) != VK_SUCCESS) { throw std::runtime_error("Fence submition to queue failed!"); } if (vkWaitForFences(device->getLogicalDevice(), 1, &fence, VK_TRUE, UINT64_MAX) != VK_SUCCESS) { throw std::runtime_error("Waiting for fence failed!"); } vkDestroyFence(device->getLogicalDevice(), fence, nullptr); if (free) { vkFreeCommandBuffers(device->getLogicalDevice(), device->getCommandPool(), 1, &m_commandBuffer); } } }
[ "kevin.meniel@gmail.com" ]
kevin.meniel@gmail.com
228982fc60359b21b4d969008a0930565700fbc2
6a2d1800e25e3624b315c21f9598b4442c8d80b6
/sdk/core/azure-core/src/context.cpp
20d456716faabc3d7198bd5448b6b4a6edbcab8b
[ "MIT", "BSD-3-Clause", "curl", "LGPL-2.1-or-later", "LicenseRef-scancode-generic-cla" ]
permissive
katmsft/azure-sdk-for-cpp
e3f76ebe9c1a176050f64b9fb0658031b95ec02b
d99f3ab8e62fff5c65c49aea91aba3c2a422a7d1
refs/heads/master
2021-09-11T14:52:51.875720
2021-01-28T09:21:59
2021-01-28T09:21:59
248,464,376
0
0
MIT
2020-08-27T05:37:44
2020-03-19T09:41:59
C++
UTF-8
C++
false
false
638
cpp
// Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT #include "azure/core/context.hpp" using namespace Azure::Core; using time_point = std::chrono::system_clock::time_point; Context& Azure::Core::GetApplicationContext() { static Context ctx; return ctx; } time_point Azure::Core::Context::CancelWhen() const { auto result = time_point::max(); for (auto ptr = m_contextSharedState; ptr; ptr = ptr->Parent) { auto cancelAt = ContextSharedState::FromMsecSinceEpoch(ptr->CancelAtMsecSinceEpoch); if (result > cancelAt) { result = cancelAt; } } return result; }
[ "noreply@github.com" ]
katmsft.noreply@github.com
1c5acf49becbe5d98c5509a3fc63b7ae0e10815b
ca99bc050dbc58be61a92e04f2a80a4b83cb6000
/Game/src/Entities/Tux.cpp
150fd862b5c7e381ea3cbf05b110ecb526a79f82
[]
no_license
NicolasBeaudrot/angry-tux
e26c619346c63a468ad3711de786e94f5b78a2f1
5a8259f57ba59db9071158a775948d06e424a9a8
refs/heads/master
2021-01-06T20:41:23.705460
2011-04-14T18:28:04
2011-04-14T18:28:04
32,141,181
0
0
null
null
null
null
UTF-8
C++
false
false
2,196
cpp
#include "Tux.h" Tux::Tux(sf::RenderWindow* app ,sf::Vector2i& position ,std::string& path ,int type ,b2World* world) : Entity(app, position, path = "tuxs/" + path, 0){ _type = type; _fire = false; //Physics definition b2BodyDef bd; bd.position.Set(_position.x, _position.y); bd.type = b2_dynamicBody; bd.angularDamping = 0.01f; b2CircleShape circle; circle.m_radius = _image->GetWidth() / 2.0f; b2FixtureDef fixtureDef; fixtureDef.shape = &circle; fixtureDef.density = 1.0f; fixtureDef.friction = 0.3f; fixtureDef.restitution = 0.3f; fixtureDef.filter.groupIndex = -type; _tuxBody = world->CreateBody(&bd); _tuxBody->CreateFixture(&fixtureDef); b2MassData mass_data; mass_data.center = b2Vec2(0,0); mass_data.mass = 250.0f; mass_data.I = 600.0f; _tuxBody->SetMassData(&mass_data); _sprite.SetCenter(_image->GetWidth()/2, _image->GetHeight()/2); } Tux::~Tux() { } void Tux::mouseReleased(sf::Vector2f firstPosition, sf::Vector2f secondPosition, float time_elapse) { firstPosition = Conversion::to_sfmlcoord(firstPosition); secondPosition = Conversion::to_sfmlcoord(secondPosition); int K = 1000000; float angle = Algorithm::getAngle(firstPosition, secondPosition); std::cout << "Angle: " << angle << std::endl; _force = b2Vec2(cos(Conversion::to_radian(angle)) * K, sin(Conversion::to_radian(angle)) * K); _tuxBody->ApplyForce(_force, _tuxBody->GetWorldCenter()); _fire = true; cpt=0; } void Tux::render() { if (_fire) { if (_timer.GetElapsedTime() > 0.5) { if (cpt < 3) { _tuxBody->ApplyForce(_force, _tuxBody->GetWorldCenter()); cpt++; } else { _fire = false; } _timer.Reset(); } } sf::Vector2i position_sfml = Conversion::to_sfmlcoord(_tuxBody->GetPosition().x, _tuxBody->GetPosition().y); _sprite.SetPosition(position_sfml.x, position_sfml.y); _sprite.SetRotation(Conversion::to_degres(_tuxBody->GetAngle())); _app->Draw(_sprite); }
[ "nicolas.beaudrot@43db0318-7ac6-f280-19a0-2e79116859ad" ]
nicolas.beaudrot@43db0318-7ac6-f280-19a0-2e79116859ad
5e0e4ca486de5053a9dff1dad629ada4339deb1c
210b2d9c0da7de96bd50ca31219741e3bc897770
/KnockOut/Source.h
79f74255d6a5d4c88548dbe7201ba319a8ceaa65
[]
no_license
acesaspa/KnockOut
c896e906289b3ac3483318422a8b90787ab00794
c8e027b5ccf405ffe9daa1676f8a8ec5a0925cf3
refs/heads/main
2023-04-10T20:14:28.564392
2021-03-31T23:13:00
2021-03-31T23:13:00
365,092,532
1
0
null
2021-05-07T02:30:00
2021-05-07T02:29:59
null
UTF-8
C++
false
false
131
h
#ifndef SOURCE_H #define SOURCE_H #include "PowerUp.h" class Source { public: void passValue(PowerUp& a); private: }; #endif
[ "noahbensler@gmail.com" ]
noahbensler@gmail.com
f19eb7be4ca8a27b2915157598f842a4ec83e476
43523509ac3324883943b52c7d3e0e92cc46ef70
/renderer/platform/plugins/plugin_list_builder.cc
26d6f01a055cd7fef0969ea2627f9c52d5b2c71b
[]
no_license
JDenghui/blink
d935ab9a906c9f95c890549b254b4dec80d93765
6732fc88d110451aebda75b8822ba5d9b4f9de04
refs/heads/master
2020-03-23T15:55:33.238563
2018-07-21T05:26:31
2018-07-21T05:26:31
141,783,126
1
1
null
null
null
null
UTF-8
C++
false
false
2,640
cc
/* * Copyright (C) 2009 Google 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: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "third_party/blink/renderer/platform/plugins/plugin_list_builder.h" #include "third_party/blink/public/platform/web_string.h" namespace blink { void PluginListBuilder::AddPlugin(const WebString& name, const WebString& description, const WebString& file_name, WebColor background_color) { if (results_) { results_->push_back( new PluginInfo(name, file_name, description, background_color)); } } void PluginListBuilder::AddMediaTypeToLastPlugin(const WebString& name, const WebString& description) { if (results_) { MimeClassInfo* info = new MimeClassInfo(name, description, *results_->back()); results_->back()->AddMimeType(info); } } void PluginListBuilder::AddFileExtensionToLastMediaType( const WebString& extension) { if (results_) { MimeClassInfo& info = *results_->back()->mimes_.back(); info.extensions_.push_back(extension); } } } // namespace blink
[ "Denghui_Jia@Dell.com" ]
Denghui_Jia@Dell.com
34a6c446b10448ec95de61250f6e9e11e2483bc2
8f65befc68236104caf52026badb87270a2c4cfa
/Exam 1/Exam 1/Song.h
9eff603512578fc9c50d5fdc64148b0b0c9f9590
[]
no_license
lindseymoon/EXAM1-FINAL
79f8d6309d82e856e472d7577bbf103ff8710a32
018ae8100d000a882197f05795bb8ee824d5a3c9
refs/heads/master
2021-01-19T20:37:39.429948
2017-03-03T05:37:40
2017-03-03T05:37:40
83,761,540
0
0
null
null
null
null
UTF-8
C++
false
false
558
h
#ifndef SONG_H_ #define SONG_H_ #include <string> using namespace std; class Song { private: string title; string artist; string genre; public: Song(); //default song Song(string title, string artist, string genre); //allow caller to set up the song, valid genres const string getTitle(); //return the song title const string getArtist(); //return the artist who performed the song const string getGenre(); //return the genre of the song bool isOfGenre(string genre); //return true if song is of the genre }; #endif
[ "noreply@github.com" ]
lindseymoon.noreply@github.com
38b197e7fa49cab79323d39b2824f66e8579a336
c18b548e82bbc234eb3d01fdf6fab9464c37e845
/old_demo/opencv_camera_test1.cpp
f59e2e2ec9033ff4aa909b5cc73e578d48a97e51
[]
no_license
xiehuapeng/xiehuapeng
026bec0d7a25ed65789fd624ab352f1cf84f70ba
8b5752e4af6de88c85c8dcf76c6a5b5542279df8
refs/heads/master
2023-02-17T11:54:52.981706
2020-06-06T02:49:00
2020-06-06T02:49:00
155,349,681
0
0
null
2018-10-30T14:22:27
2018-10-30T08:25:35
null
UTF-8
C++
false
false
2,943
cpp
// // Created by caesar kekxv on 2020/3/12. // http://scientistengineer.blogspot.com/2015/09/trying-to-generate-hdr-picture-from.html // #include "opencv2/opencv.hpp" #include <vector> #include <iostream> #include <fstream> using namespace cv; using namespace std; int main(int argc, char ** argv) { setenv("DISPLAY", "localhost:10.0", 1); vector< Mat> images; vector< float> times; //float times[5]; VideoCapture camera; camera.open(0); // camera.set(CAP_PROP_FRAME_WIDTH,640); // camera.set(CAP_PROP_FRAME_HEIGHT,480); //for(;;) //{ Mat defaultPic[5]; camera.set(CAP_PROP_EXPOSURE,-1); //times[0] = 1; camera >> defaultPic[0]; times.push_back(1); images.push_back(defaultPic[0]); namedWindow( "picture -1", WINDOW_AUTOSIZE ); imshow("picture -1", defaultPic[0]); camera.set(CAP_PROP_EXPOSURE,2); //times[1] = 0.2; camera >> defaultPic[1]; times.push_back(2); images.push_back(defaultPic[1]); namedWindow( "picture -5", WINDOW_AUTOSIZE ); imshow("picture -5", defaultPic[1]); camera.set(CAP_PROP_EXPOSURE,3); //times[2] = 0.143; camera >> defaultPic[2]; times.push_back(3); images.push_back(defaultPic[2]); namedWindow( "picture -7", WINDOW_AUTOSIZE ); imshow("picture -7", defaultPic[2]); camera.set(CAP_PROP_EXPOSURE,4); //times[3] = 0.11; camera >> defaultPic[3]; times.push_back(4); images.push_back(defaultPic[3]); namedWindow( "picture -9", WINDOW_AUTOSIZE ); imshow("picture -9", defaultPic[3]); camera.set(CAP_PROP_EXPOSURE,5); //times[4] = 0.083; camera >> defaultPic[4]; times.push_back(5); images.push_back(defaultPic[4]); imshow("img12.png",defaultPic[4]); camera.set(CAP_PROP_EXPOSURE,7); //times[4] = 0.083; camera >> defaultPic[4]; times.push_back(7); images.push_back(defaultPic[4]); imshow("img13.png",defaultPic[4]); camera.set(CAP_PROP_EXPOSURE,9); //times[4] = 0.083; camera >> defaultPic[4]; times.push_back(9); images.push_back(defaultPic[4]); namedWindow( "picture -12", WINDOW_AUTOSIZE ); imshow("picture -12", defaultPic[4]); Mat response; Ptr< CalibrateDebevec> calibrate = createCalibrateDebevec(); calibrate->process(images, response, times); Mat hdr; Ptr< MergeDebevec > merge_debevec = createMergeDebevec(); merge_debevec->process(images, hdr, times, response); Mat ldr; auto tonemap = cv::createTonemapDrago(2.2f); tonemap->process(hdr, ldr); Mat fusion; // createTonemapDurand auto merge_mertens = createMergeMertens(); merge_mertens->process(images, fusion); imshow("fusion.png", fusion * 255); imshow("ldr.png", ldr * 255); imshow("hdr.hdr", hdr); waitKey(0); //} return 0; }
[ "1812412957@qq.com" ]
1812412957@qq.com
33ff034c896b7376ffddb10d69f0971ebd839dcd
1c42215c5558211f02557ef1edd711d067ec78b6
/src/Union_AlterDamage/ZenGin/Gothic_II_Classic/API/oInventory.h
0795bc0a1c9954073e4cf3bf5d0556310cc57d9a
[]
no_license
UnresolvedExternal/Union_AlterDamage
fd5891c3a62896a3e2049e9fea2b3da9721c57c9
88b1ae773ea8e5c3762d2a5fd23b3ca7fae5c3b2
refs/heads/master
2023-07-26T13:52:00.230498
2023-07-11T17:49:13
2023-07-11T17:49:13
200,260,609
5
1
null
null
null
null
UTF-8
C++
false
false
11,857
h
// Supported with union (c) 2018 Union team #ifndef __OINVENTORY_H__VER2__ #define __OINVENTORY_H__VER2__ #include "zViewBase.h" #include "zArchiver.h" namespace Gothic_II_Classic { const int INV_MAX_SLOTS_COL = 8; const int INV_MAX_SLOTS_ROW = 2; enum { INV_NONE, INV_COMBAT, INV_ARMOR, INV_RUNE, INV_MAGIC, INV_FOOD, INV_POTION, INV_DOCS, INV_OTHER, INV_MAX }; enum { INV_MODE_DEFAULT, INV_MODE_CONTAINER, INV_MODE_PLUNDER, INV_MODE_STEAL, INV_MODE_BUY, INV_MODE_SELL, INV_MODE_MAX }; class oCItemContainer : public zCInputCallback { public: zCListSort<oCItem>* contents; oCNpc* npc; zSTRING titleText; int invMode; int selectedItem; int offset; int maxSlotsCol; int maxSlotsColScr; int maxSlotsRow; int maxSlotsRowScr; int maxSlots; int marginTop; int marginLeft; int frame; int right; int ownList; int prepared; int passive; short TransferCount; zCView* viewTitle; zCView* viewBack; zCView* viewItem; zCView* viewItemActive; zCView* viewItemHightlighted; zCView* viewItemActiveHighlighted; zCView* viewItemInfo; zCView* viewItemInfoItem; zCView* textView; zCView* viewArrowAtTop; zCView* viewArrowAtBottom; zCWorld* rndWorld; int posx; int posy; int m_bManipulateItemsDisabled; int m_bCanTransferMoreThanOneItem; void oCItemContainer_OnInit() zCall( 0x006A7270 ); oCItemContainer* GetNextContainerLeft( oCItemContainer* ) zCall( 0x006A7130 ); oCItemContainer* GetNextContainerRight( oCItemContainer* ) zCall( 0x006A71D0 ); oCItemContainer() zInit( oCItemContainer_OnInit() ); zCListSort<oCItem>* JumpOffset( int&, int& ) zCall( 0x006A8FC0 ); int ActivateNextContainer( int ) zCall( 0x006AC660 ); static int GetInvSplitScreen() zCall( 0x006A6B50 ); static short GetInvMaxColumns() zCall( 0x006A6B80 ); static short GetInvMaxRows() zCall( 0x006A6BD0 ); static short TransferCountToAmount( short ) zCall( 0x006A6C20 ); static float GetValueMultiplier() zCall( 0x006A6C60 ); static zSTRING GetCurrencyInstanceName() zCall( 0x006A6D80 ); static int GetCurrencyInstance() zCall( 0x006A6F70 ); static oCItem* CreateCurrencyItem( short ) zCall( 0x006A7010 ); static void RemoveCurrencyItem( oCItem* ) zCall( 0x006A70C0 ); static void Container_PrepareDraw() zCall( 0x006A70F0 ); static void Container_Draw() zCall( 0x006A7100 ); virtual int HandleEvent( int ) zCall( 0x006ACB50 ); virtual ~oCItemContainer() zCall( 0x006A87F0 ); virtual void Open( int, int, int ) zCall( 0x006AAA60 ); virtual void OpenPassive( int, int, int ) zCall( 0x006AABE0 ); virtual zSTRING GetName() zCall( 0x006A7480 ); virtual void SetName( zSTRING& ) zCall( 0x006A74D0 ); virtual int GetMode() zCall( 0x006A7610 ); virtual void SetMode( int ) zCall( 0x006A7620 ); virtual void Close() zCall( 0x006AB440 ); virtual void Activate() zCall( 0x006AB740 ); virtual void Deactivate() zCall( 0x006AB7A0 ); virtual int IsOpen() zCall( 0x006AB710 ); virtual int IsActive() zCall( 0x006A7640 ); virtual int IsEmpty() zCall( 0x006AC320 ); virtual int IsSplitScreen() zCall( 0x006AC350 ); virtual void SetContents( zCListSort<oCItem>* ) zCall( 0x006AAA00 ); virtual zCListSort<oCItem>* GetContents() zCall( 0x006AAA50 ); virtual oCItem* Insert( oCItem* ) zCall( 0x006AB870 ); virtual void Remove( oCItem* ) zCall( 0x006AB940 ); virtual oCItem* Remove( oCItem*, int ) zCall( 0x006AB9F0 ); virtual oCItem* RemoveByPtr( oCItem*, int ) zCall( 0x006AB9E0 ); virtual oCItem* GetSelectedItem() zCall( 0x006AB7D0 ); virtual int GetSelectedItemCount() zCall( 0x006AB800 ); virtual void GetSize( int&, int& ) zCall( 0x006A8F80 ); virtual void DisableManipulateItems( int ) zCall( 0x006A7650 ); virtual int CanManipulateItems() zCall( 0x006A7660 ); virtual void DisableTransferMoreThanOneItem( int ) zCall( 0x006A7670 ); virtual int CanTransferMoreThanOneItem() zCall( 0x006A7690 ); virtual int IsPassive() zCall( 0x006AB430 ); virtual short GetTransferCount() zCall( 0x006A76A0 ); virtual void SetTransferCount( short ) zCall( 0x006A76B0 ); virtual void IncTransferCount( short ) zCall( 0x006A76C0 ); virtual void Archive( zCArchiver& ) zCall( 0x006AC780 ); virtual void Unarchive( zCArchiver& ) zCall( 0x006AC970 ); virtual void Init( int, int, int ) zCall( 0x006A8D80 ); virtual void GetPosition( int&, int& ) zCall( 0x006A8FA0 ); virtual void LoadGrafix() zCall( 0x006A8940 ); virtual void DeleteContents() zCall( 0x006ABAA0 ); virtual void NextItem() zCall( 0x006ABC50 ); virtual void NextItemLine() zCall( 0x006ABEB0 ); virtual void PrevItem() zCall( 0x006AC010 ); virtual void PrevItemLine() zCall( 0x006AC240 ); virtual void CheckSelectedItem() zCall( 0x006ABB70 ); virtual int TransferItem( int, int ) zCall( 0x006AC450 ); virtual void Draw() zCall( 0x006A9BC0 ); virtual void DrawCategory() zCall( 0x006A9070 ); virtual void DrawItemInfo( oCItem*, zCWorld* ) zCall( 0x006A9350 ); // static properties static zCList<oCItemContainer>& contList; static int& gfx_loaded; static zCGfx*& gfx_cat; static zCGfx*& gfx_equip; static zCGfx*& gfx_cursor; static zCGfx*& gfx_cursor_equip; static zCGfx**& gfx_arrow; }; class oCStealContainer : public oCItemContainer { public: oCNpc* owner; void oCStealContainer_OnInit() zCall( 0x006AD100 ); oCStealContainer() zInit( oCStealContainer_OnInit() ); virtual int HandleEvent( int ) zCall( 0x006AD5A0 ); virtual ~oCStealContainer() zCall( 0x006AD140 ); virtual void SetOwner( oCNpc* ) zCall( 0x006AD2C0 ); virtual oCNpc* GetOwner() zCall( 0x006AD2E0 ); virtual void CreateList() zCall( 0x006AD2F0 ); }; class oCNpcContainer : public oCStealContainer { public: void oCNpcContainer_OnInit() zCall( 0x006AD8D0 ); oCNpcContainer() zInit( oCNpcContainer_OnInit() ); virtual int HandleEvent( int ) zCall( 0x006ADC00 ); virtual ~oCNpcContainer() zCall( 0x006AD910 ); virtual oCItem* Insert( oCItem* ) zCall( 0x006ADF00 ); virtual void Remove( oCItem* ) zCall( 0x006ADF40 ); virtual void CreateList() zCall( 0x006ADA80 ); }; class oCNpcInventory : public oCItemContainer { public: oCNpc* owner; int packAbility; zCListSort<oCItem> inventory; zSTRING packString; int maxSlots; void oCNpcInventory_OnInit() zCall( 0x0081FEC2 ); oCNpcInventory() zInit( oCNpcInventory_OnInit() ); void ClearInventory() zCall( 0x006AE2C0 ); void SetOwner( oCNpc* ) zCall( 0x006AE840 ); oCNpc* GetOwner() zCall( 0x006AE850 ); int GetNumItemsInCategory() zCall( 0x006AE860 ); oCItem* GetItem( int ) zCall( 0x006AE970 ); int GetCategory( oCItem* ) zCall( 0x006AEBB0 ); int GetAmount( int ) zCall( 0x006AEE80 ); int HandleTrade( int ) zCall( 0x006B02E0 ); void CheckForEquippedItems( int ) zCall( 0x006B1800 ); int CanCarry( oCItem* ) zCall( 0x006B1940 ); void SetPackAbility( int ) zCall( 0x006B1A70 ); void UnpackCategory() zCall( 0x006B1A90 ); int GetNumItemsInPackString() zCall( 0x006B1AA0 ); int GetPackedItemBySlot( int, zSTRING& ) zCall( 0x006B1B90 ); oCItem* CreateFromPackString( zSTRING const& ) zCall( 0x006B1CD0 ); int GetPackedItemInfo( zSTRING const&, int, int&, int& ) zCall( 0x006B1D60 ); int PackSingleItem( oCItem* ) zCall( 0x006B2010 ); void PackAllItems( int ) zCall( 0x006B2380 ); void UnpackAllItems() zCall( 0x006B2390 ); void PackItemsInCategory( int ) zCall( 0x006B23A0 ); void UnpackItemsInCategory() zCall( 0x006B2D80 ); virtual int HandleEvent( int ) zCall( 0x006B0520 ); virtual ~oCNpcInventory() zCall( 0x006AE110 ); virtual void Open( int, int, int ) zCall( 0x006AE420 ); virtual void Close() zCall( 0x006AE810 ); virtual oCItem* Insert( oCItem* ) zCall( 0x006AEC50 ); virtual oCItem* Remove( int, int ) zCall( 0x006AF590 ); virtual oCItem* Remove( zSTRING const&, int ) zCall( 0x006AF680 ); virtual oCItem* RemoveByPtr( oCItem*, int ) zCall( 0x006AF180 ); virtual void Archive( zCArchiver& ) zCall( 0x006AF6F0 ); virtual void Unarchive( zCArchiver& ) zCall( 0x006AFA30 ); virtual void Draw() zCall( 0x006AE830 ); virtual void DrawCategory() zCall( 0x006B00B0 ); virtual void Remove( oCItem* ) zCall( 0x006AF0F0 ); virtual oCItem* Remove( oCItem*, int ) zCall( 0x006AF330 ); virtual oCItem* IsIn( oCItem*, int ) zCall( 0x006AEF90 ); virtual oCItem* IsIn( int, int ) zCall( 0x006AF000 ); virtual oCItem* IsIn( zSTRING const&, int ) zCall( 0x006AEFD0 ); virtual int IsEmpty() zCall( 0x006AC320 ); virtual int IsEmpty( int ) zCall( 0x006AF6B0 ); // static properties static zCGfx*& gfx_title; }; } // namespace Gothic_II_Classic #endif // __OINVENTORY_H__VER2__
[ "vmi1401bsv04@gmail.com" ]
vmi1401bsv04@gmail.com
9b59ceff4b65bdd9b2efce59f3126fdac5c3cde5
19e2519b62e11d8cb5bc901836ce3a47f0906188
/tests/src/small_string_tests.cpp
81fb41102dde2ea7eb225c9e4bd5d1d2cd48e0c6
[ "BSL-1.0" ]
permissive
DebugOfTheRoad/jsoncons
69010e824a4865a10112cf81abf22fd8f0b1a7a7
31c5779565c3731f1cbd882f44186371eea3d0cc
refs/heads/master
2021-07-04T07:24:25.075667
2017-09-26T03:43:55
2017-09-26T03:43:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
978
cpp
// Copyright 2013 Daniel Parker // Distributed under Boost license #ifdef __linux__ #define BOOST_TEST_DYN_LINK #endif #include <boost/test/unit_test.hpp> #include <jsoncons/json.hpp> #include <jsoncons/json_serializer.hpp> #include <jsoncons/json_filter.hpp> #include <sstream> #include <vector> #include <utility> #include <ctime> #include <new> #include <boost/optional.hpp> using namespace jsoncons; BOOST_AUTO_TEST_SUITE(small_string_tests) BOOST_AUTO_TEST_CASE(test_small_string) { json s("ABCD"); BOOST_CHECK(s.type_id() == jsoncons::value_type::small_string_t); BOOST_CHECK(s.as<std::string>() == std::string("ABCD")); json t(s); BOOST_CHECK(t.type_id() == jsoncons::value_type::small_string_t); BOOST_CHECK(t.as<std::string>() == std::string("ABCD")); json q; q = s; BOOST_CHECK(q.type_id() == jsoncons::value_type::small_string_t); BOOST_CHECK(q.as<std::string>() == std::string("ABCD")); } BOOST_AUTO_TEST_SUITE_END()
[ "danielaparker@yahoo.com" ]
danielaparker@yahoo.com
2d7e02b16530bbd60ea563d5682c1e2081711672
8e37565d1f9d0f2ccce02a2ae760da13e5410ad1
/bubblebutton.h
6635c5dc561c4b2bc21f74c781da0658d6d79d4b
[]
no_license
YashGovindani/DrawOver
54599a19496a1f910be269aee57383868f101e5f
46f09744e1e90043e4acf81dea3dc3076f04ba1c
refs/heads/main
2023-08-06T19:28:22.730526
2021-09-26T12:36:29
2021-09-26T12:36:29
406,796,133
0
0
null
null
null
null
UTF-8
C++
false
false
1,068
h
#ifndef BUBBLEBUTTON_H #define BUBBLEBUTTON_H #include "minibubblebutton.h" #include <QPushButton> #include <QGraphicsDropShadowEffect> #include <QPaintEvent> #include <QMouseEvent> #include <QApplication> class BubbleButton:public QPushButton { private: BubbleButton(QWidget *loadingView = nullptr); static BubbleButton *bubbleButton; int startX; int startY; int buttonX; int buttonY; bool moved; bool expanded; QString cornerRadius; MiniBubbleButton penButton; MiniBubbleButton highLighterButton; MiniBubbleButton backToWorkButton; MiniBubbleButton clearButton; MiniBubbleButton eraserButton; MiniBubbleButton expandButton; QApplication *a; public: static BubbleButton * get(QWidget *loadingView = nullptr); void mousePressEvent(QMouseEvent*); void mouseMoveEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); void onClick(); ~BubbleButton(); QApplication *getA() const; void setA(QApplication *value); void compressAction(); }; #endif // BUBBLEBUTTON_H
[ "yashgovindani222@gmail.com" ]
yashgovindani222@gmail.com
395a07d327962c499e8d2fd99fe72d831ab1f3c1
6e5303b1f5492b84f6ab911920975b78d0fe1982
/BRAINSConstellationDetector/src/itkHoughTransformRadialVotingImageFilter.h
373be68b5723eda87fa38a681a6a527a3cb8f95a
[]
no_license
aghayoor/BRAINSTools
ac247f73f6e874fa80094928ba68c1c2230f070d
0da25be92227840b7290a83268f876e1d844c9ad
refs/heads/master
2020-04-05T23:03:35.789313
2013-08-20T20:04:01
2013-08-20T20:04:01
9,104,769
0
2
null
null
null
null
UTF-8
C++
false
false
12,748
h
/*========================================================================= Author: $Author: krm15 $ // Author of last commit Version: $Rev: 585 $ // Revision of last commit Date: $Date: 2009-08-20 21:25:19 -0400 (Thu, 20 Aug 2009) $ // Date of last commit =========================================================================*/ /*========================================================================= Authors: The GoFigure Dev. Team. at Megason Lab, Systems biology, Harvard Medical school, 2009 Copyright (c) 2009, President and Fellows of Harvard College. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the President and Fellows of Harvard College nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. =========================================================================*/ #ifndef __itkHoughTransformRadialVotingImageFilter_h #define __itkHoughTransformRadialVotingImageFilter_h #include "itkImageToImageFilter.h" #include "itkImage.h" #include "itkEllipseSpatialObject.h" #include "itkImageRegionIteratorWithIndex.h" #include "itkDiscreteGaussianImageFilter.h" #include "itkGaussianDerivativeImageFunction.h" #include "itkMinimumMaximumImageCalculator.h" #include "itkCastImageFilter.h" #include <itkGaussianDistribution.h> #include "itkAddImageFilter.h" #include "itkImageRegionIterator.h" #if ITK_VERSION_MAJOR < 4 && !defined(ITKv3_THREAD_ID_TYPE_DEFINED) #define ITKv3_THREAD_ID_TYPE_DEFINED 1 typedef int ThreadIdType; #endif namespace itk { /** * \class HoughTransformRadialVotingImageFilter * \brief Performs the Hough Transform to find circles in a 2D image. * * This filter derives from the base class ImageToImageFilter * The input is an image, and all pixels above some threshold are those * we want to consider during the process. * * This filter produces two output: * 1) The accumulator array, which represents probability of centers. * 2) The array or radii, which has the radius value at each coordinate point. * * When the filter found a "correct" point, it computes the gradient at this * point and votes on a small region defined using the minimum and maximum * radius given by the user, and fill in the array of radii. * * \ingroup ImageFeatureExtraction * \todo Update the doxygen documentation!!! * */ template <class TInputImage, class TOutputImage> class HoughTransformRadialVotingImageFilter : public ImageToImageFilter<TInputImage, TOutputImage> { public: /** Standard "Self" typedef. */ typedef HoughTransformRadialVotingImageFilter Self; /** Standard "Superclass" typedef. */ typedef ImageToImageFilter<TInputImage, TOutputImage> Superclass; /** Smart pointer typedef support. */ typedef SmartPointer<Self> Pointer; typedef SmartPointer<const Self> ConstPointer; itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension); /** Input Image typedef */ typedef TInputImage InputImageType; typedef typename InputImageType::Pointer InputImagePointer; typedef typename InputImageType::ConstPointer InputImageConstPointer; typedef typename InputImageType::IndexType InputIndexType; typedef typename InputIndexType::IndexValueType InputIndexValueType; typedef typename InputImageType::PixelType InputPixelType; typedef typename InputImageType::SizeType InputSizeType; typedef typename InputSizeType::SizeValueType InputSizeValueType; typedef typename InputImageType::RegionType InputRegionType; typedef typename InputImageType::SpacingType InputSpacingType; typedef typename InputImageType::PointType InputPointType; typedef typename InputPointType::CoordRepType InputCoordType; /** Output Image typedef */ typedef TOutputImage OutputImageType; typedef typename OutputImageType::Pointer OutputImagePointer; typedef typename OutputImageType::PixelType OutputPixelType; typedef typename OutputImageType::RegionType OutputImageRegionType; typedef Image<InputCoordType, ImageDimension> InternalImageType; typedef typename InternalImageType::Pointer InternalImagePointer; typedef typename InternalImageType::IndexType InternalIndexType; typedef typename InternalIndexType::IndexValueType InternalIndexValueType; typedef typename InternalImageType::PixelType InternalPixelType; typedef typename InternalImageType::RegionType InternalRegionType; typedef typename InternalImageType::SizeType InternalSizeType; typedef typename InternalSizeType::SizeValueType InternalSizeValueType; typedef typename InternalImageType::SpacingType InternalSpacingType; /** Sphere typedef */ typedef EllipseSpatialObject<ImageDimension> SphereType; typedef typename SphereType::Pointer SpherePointer; typedef typename SphereType::VectorType SphereVectorType; typedef std::list<SpherePointer> SpheresListType; typedef ImageRegionIterator<InternalImageType> InternalIteratorType; typedef ImageRegionIterator<OutputImageType> OutputIteratorType; typedef DiscreteGaussianImageFilter<OutputImageType, InternalImageType> GaussianFilterType; typedef typename GaussianFilterType::Pointer GaussianFilterPointer; typedef itk::Statistics::GaussianDistribution GaussianFunctionType; typedef typename GaussianFunctionType::Pointer GaussianFunctionPointer; typedef GaussianDerivativeImageFunction<InputImageType, InputCoordType> DoGFunctionType; typedef typename DoGFunctionType::Pointer DoGFunctionPointer; typedef typename DoGFunctionType::VectorType DoGVectorType; typedef MinimumMaximumImageCalculator<InternalImageType> MinMaxCalculatorType; typedef typename MinMaxCalculatorType::Pointer MinMaxCalculatorPointer; typedef CastImageFilter<InternalImageType, OutputImageType> CastFilterType; typedef typename CastFilterType::Pointer CastFilterPointer; /** Run-time type information (and related methods). */ itkTypeMacro(HoughTransformRadialVotingImageFilter, ImageToImageFilter); /** Method for creation through the object factory. */ itkNewMacro(Self); /** Set both Minimum and Maximum radius values */ void SetRadius(InputCoordType radius); /** Set the minimum radiu value the filter should look for */ itkSetMacro(MinimumRadius, InputCoordType); /** Set the maximum radius value the filter should look for */ itkSetMacro(MaximumRadius, InputCoordType); /** Set the threshold above which the filter should consider the point as a valid point */ itkSetMacro(Threshold, double); /** Get the threshold value */ itkGetConstMacro(Threshold, double); /** Set the threshold above which the filter should consider the point as a valid point */ itkSetMacro(OutputThreshold, InternalPixelType); /** Get the threshold value */ itkGetConstMacro(OutputThreshold, InternalPixelType); /** Set the threshold above which the filter should consider the point as a valid point */ itkSetMacro(GradientThreshold, InputCoordType); /** Get the threshold value */ itkGetConstMacro(GradientThreshold, InputCoordType); /** Get the radius image */ itkGetConstObjectMacro(RadiusImage, InternalImageType); /** Get the accumulator image */ itkGetConstObjectMacro(AccumulatorImage, InternalImageType); /** Set the scale of the derivative function (using DoG) */ itkSetMacro(SigmaGradient, double); /** Get the scale value */ itkGetConstMacro(SigmaGradient, double); /** Get the list of circles. This recomputes the circles */ SpheresListType & GetSpheres(); /** Set/Get the number of circles to extract */ itkSetMacro(NumberOfSpheres, unsigned int); itkGetConstMacro(NumberOfSpheres, unsigned int); /** Set/Get the radius of the disc to remove from the accumulator * for each circle found */ itkSetMacro(SphereRadiusRatio, InputCoordType); itkGetConstMacro(SphereRadiusRatio, InputCoordType); itkSetMacro(VotingRadiusRatio, InputCoordType); itkGetConstMacro(VotingRadiusRatio, InputCoordType); /** Set the variance of the gaussian bluring for the accumulator */ itkSetMacro(Variance, double); itkGetConstMacro(Variance, double); /** Set the number of threads */ itkSetMacro(NbOfThreads, unsigned int); itkGetConstMacro(NbOfThreads, unsigned int); /** Set the number of threads */ itkSetMacro(SamplingRatio, double); itkGetConstMacro(SamplingRatio, double); /** Set the mode of the algorithm */ /** HoughEyeDetectorMode = 0: Detecting bright spheres in a dark environment. */ /** HoughEyeDetectorMode = 1: Detecting dark spheres in a bright environment. */ itkSetMacro(HoughEyeDetectorMode, int); /** Get the mode of the algorithm */ itkGetConstMacro(HoughEyeDetectorMode, int); #ifdef ITK_USE_CONCEPT_CHECKING /** Begin concept checking */ itkConceptMacro( IntConvertibleToOutputCheck, ( Concept::Convertible<int, OutputPixelType> ) ); itkConceptMacro( InputGreaterThanDoubleCheck, ( Concept::GreaterThanComparable<InputPixelType, double> ) ); itkConceptMacro( OutputPlusIntCheck, ( Concept::AdditiveOperators<OutputPixelType, int> ) ); itkConceptMacro( OutputDividedByIntCheck, ( Concept::DivisionOperators<OutputPixelType, int> ) ); /** End concept checking */ #endif protected: HoughTransformRadialVotingImageFilter(); virtual ~HoughTransformRadialVotingImageFilter(); InputCoordType m_MinimumRadius; InputCoordType m_MaximumRadius; double m_Threshold; InputCoordType m_GradientThreshold; InternalPixelType m_OutputThreshold; double m_SigmaGradient; double m_Variance; InputCoordType m_VotingRadiusRatio; InputCoordType m_SphereRadiusRatio; double m_SamplingRatio; InternalImagePointer m_RadiusImage; InternalImagePointer m_AccumulatorImage; SpheresListType m_SpheresList; unsigned int m_NumberOfSpheres; unsigned long m_OldModifiedTime; unsigned int m_NbOfThreads; bool m_AllSeedsProcessed; // -- Add by Wei Lu int m_HoughEyeDetectorMode; /** Method for evaluating the implicit function over the image. */ virtual void BeforeThreadedGenerateData(); virtual void AfterThreadedGenerateData(); virtual void ThreadedGenerateData(const OutputImageRegionType & windowRegion, ThreadIdType threadId); void PrintSelf(std::ostream & os, Indent indent) const; /** HoughTransformRadialVotingImageFilter needs the entire input. Therefore * it must provide an implementation GenerateInputRequestedRegion(). * \sa ProcessObject::GenerateInputRequestedRegion(). */ void GenerateInputRequestedRegion(); /** HoughTransformRadialVotingImageFilter's produces all the output. * Therefore, it must provide an implementation of * EnlargeOutputRequestedRegion. * \sa ProcessObject::EnlargeOutputRequestedRegion() */ void EnlargeOutputRequestedRegion( DataObject * itkNotUsed(output) ); void ComputeMeanRadiusImage(); private: HoughTransformRadialVotingImageFilter(const Self &) { } void operator=(const Self &) { } }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkHoughTransformRadialVotingImageFilter.hxx" #endif #endif
[ "hans-johnson@uiowa.edu" ]
hans-johnson@uiowa.edu
de1fc52ad2829ab563403e348c1edc9263fd0123
4fc43da9da433ed8c94e27138c43f2a7e66a1111
/cs215/Lab1/brewereL1.cpp
aaed1953de4a522fd2cad66576bfaedd59c7359a
[]
no_license
EricRobertBrewer/SonomaState
59520fd93ceefe09b1d435e3034e88c354d78c60
c991d2394261ece81535dd5e9056c90a8de55d98
refs/heads/master
2021-01-16T18:06:17.457213
2012-11-28T08:46:58
2012-11-28T08:46:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,018
cpp
/* Eric Brewer 1/28/08 CS215 Lab1 */ #include <iostream> #include <fstream> using namespace std; int main() { ifstream fin; int consonantCount = 0; int vowelCount = 0; int wordCount = 0; int digitCount = 0; int specialCharCount = 0; fin.open("words.txt"); string word; while (fin >> word) { wordCount++; for (int i = 0; i < word.length(); i++) { if (isalpha(word[i])) { if (word[i] == 'A' || word[i] =='a' || word[i] =='E' || word[i] =='e' || word[i] =='I' || word[i] =='i' || word[i] =='O' || word[i] =='o' || word[i] =='U' || word[i] =='u') vowelCount++; else consonantCount++; } else { if (isdigit(word[i])) digitCount++; else specialCharCount++; } } } fin.close(); cout << "Words: " << wordCount << "\n" << "Vowels: " << vowelCount << "\n" << "Consonants: " << consonantCount << "\n" << "Digits: " << digitCount << "\n" << "Special Characters: " << specialCharCount << "\n"; return 0; }
[ "eric.r.brewer@gmail.com" ]
eric.r.brewer@gmail.com
f3f4c3e82a8b42e50582a1bb800ab45436bcff7d
3510a32a7c24394f0fb722989259b3ca39ead5df
/Monster.hpp
f7821cf1b30b46b1fd687e582e7c79a3ee091298
[]
no_license
realshooky/MMSearch
ac55d812165240b0603263c839d3fbb7f65d6e0d
9fe4a286dac228d28194f8a8e4d92b4bd8401501
refs/heads/master
2020-07-03T08:11:53.025521
2019-08-15T03:06:24
2019-08-15T03:06:24
201,848,442
0
0
null
null
null
null
UTF-8
C++
false
false
1,268
hpp
#include <string> class Monster { public: Monster(); // setters void setName(char *); void setName(std::string&); void setSize(char *); void setSize(std::string&); void setType(char *); void setType(std::string&); void setAlignment(char *); void setAlignment(std::string&); void setHP_Dice(char *); void setHP_Dice(std::string&); void setSpeeds(char *); void setSpeeds(std::string&); void setHP(int&); void setAC(int&); void setCR(double&); void setXP(int&); void setArmors(char *); void setArmors(std::string&); //getters const char * getName() const; const char * getSize() const; const char * getType() const; const char * getAlignment() const; const char * getHP_Dice() const; const char * getSpeeds() const; std::string getNameString() const; int getHP() const; int getAC() const; double getCR() const; int getXP() const; const char * getArmors() const; friend bool operator<(const Monster&, const Monster&); friend bool operator==(const Monster&, const Monster&); private: std::string name, size, type, armors; std::string alignment, HP_Dice, speeds; // Armor Class, Challenge Rating, Experience Points int HP, AC, XP; double CR; // Natural Armor? };
[ "realshooky" ]
realshooky
7c6b50176cf19d0a442737166862ac48e9e0d812
c8c6ad39945d24173b257dd8954b475c1d31f47f
/Embedded/Projects/March 2/main.cpp
33a1a5188ffcb23e76b5bbe95af820742b7f5e5f
[]
no_license
BaiLiping/BLP
5e75827292c206f1874fae825ad39d8c4bd2c746
38d3b60da6d4d0683e9683e556ed05e16484dba4
refs/heads/master
2023-08-04T23:22:07.920071
2023-07-19T07:16:28
2023-07-19T07:16:28
173,741,943
0
0
null
null
null
null
UTF-8
C++
false
false
259
cpp
#include <iostream> //#include <cintstd> #include <vector> using namespace std; int main() { vector<uint64_t> lookuptable; std::vector<uint64_t>::iterator p; p=lookuptable.begin(); *p=1; *(p+1)=2; *(p+2)=3; cout<<*(p+2)<<endl; return 0; }
[ "blp_engineer@outlook.com" ]
blp_engineer@outlook.com
f6415cd281f75068aea364ce8ff0cbd20bc007ad
a9636f0d96503b890f0f80d52de6fa7beb3ffe29
/visual_widgets/dual_state_diagram/dualstatediagram.h
64f5b0cafcdd87be6eeddbd595792f4aab974b4f
[]
no_license
grigp/a-analyser
5d14e8f91e2104fbc8ffbf47a28d20fd95eb667e
026badde88531b13a788140f8a3e13f08d4a5371
refs/heads/master
2023-09-01T08:09:35.475413
2023-06-14T11:37:22
2023-06-14T11:37:22
244,710,881
0
0
null
null
null
null
UTF-8
C++
false
false
711
h
#ifndef DUALSTATEDIAGRAM_H #define DUALSTATEDIAGRAM_H #include <QWidget> #include "dualstatediagrampainter.h" namespace Ui { class DualStateDiagram; } /*! * \brief Класс визуальной диаграммы двунаправленного отображения состояния относительно нуля DualStateDiagram class */ class DualStateDiagram : public QWidget, public DualStateDiagramPainter { Q_OBJECT public: explicit DualStateDiagram(QWidget *parent = nullptr); ~DualStateDiagram() override; protected: void paintEvent(QPaintEvent *event) override; void doUpdate() override; private: Ui::DualStateDiagram *ui; }; #endif // DUALSTATEDIAGRAM_H
[ "grig_p@mail.ru" ]
grig_p@mail.ru
5922dbee24415a34ec9c93771fec1e7763f9684f
1b712a2a6ccdd5a8fd9070749205d2dd97e78299
/算法结构/sap(精).cpp
8ff3ec2341166160c9ad0d09c64e4f6aa273ea1b
[]
no_license
xsy1996/C_algorithm_codes
b12eff717bbbf19f6872b2da35b532abc8392f37
2e9b8ad99d330de39bc000b8c0fa3dc9242b3147
refs/heads/master
2020-04-13T12:26:46.975699
2018-12-26T17:24:54
2018-12-26T17:24:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
773
cpp
#include<cstdio> #define min(a,b) ((a)<(b)?(a):(b)) const int MAX=2100000000,MAXn=200+9; int n,answer,g[MAXn][MAXn],d[MAXn],gap[MAXn],st=1,ed=n; int sap(int u,int flow) { if(u==ed) return flow; int ans=0,i,t; for(i=1;i<=n;++i) if(g[u][i] && d[u]==d[i]+1) { t=sap(i,min(flow-ans,g[u][i])); g[u][i]-=t,g[i][u]+=t,ans+=t; if(ans==flow) return ans; } if(d[st]>=n) return ans; if(!--gap[d[u]]) d[st]=n; ++gap[++d[u]]; return ans; } int main() { int m,i,t1,t2,t3; freopen("ditch.in","r",stdin);freopen("ditch.out","w",stdout); scanf("%d%d",&m,&n); for(i=1;i<=m;++i) { scanf("%d%d%d",&t1,&t2,&t3); g[t1][t2]+=t3; } for(gap[0]=n;d[st]<n;) answer+=sap(st,MAX); printf("%d\n",answer); return 0; }
[ "Xushiyu1996@gmail.com" ]
Xushiyu1996@gmail.com
589c1434061776b85d65f578be882d96ecf7ddcb
40587fed2ea28867795686fe5445ed9e57ef4af8
/src/utils/solvers/Linear.tcc
afe746b98c9332bb3f82420fc85710166176599a
[]
no_license
JamesZFS/Pharosa
b1a6e84647a40bb0954a08014e027bb1f77d5d2c
c6d550789335b3c33d2c7affc7e776d3e737fdb6
refs/heads/master
2020-05-09T18:30:53.371797
2020-04-18T07:01:20
2020-04-18T07:01:20
181,339,719
3
0
null
null
null
null
UTF-8
C++
false
false
4,087
tcc
// // Created by James on 2019/4/2. // // Linear solvers solver // Solve2D A b == x (n_dim == n, A: matrix) template<int n> bool Linear::Solve(real (&A)[n][n], real (&b)[n], real (&x)[n]) { real M[n][n + 1]; // expand to (n+1) cols for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { M[i][j] = A[i][j]; } M[i][n] = b[i]; } for (int k = 0; k < n; ++k) { // n principle component real col_max = fabsf(M[k][k]), fm; int maxi = k; for (int i = k + 1; i < n; ++i) { // find the max in k-th col if ((fm = fabsf(M[i][k])) > col_max) { col_max = fm; maxi = i; } } if (col_max < EPS) { // singular matrix return false; // solving failed } // swap k-th and maxi-th row for (int j = k; j < n + 1; ++j) { std::swap(M[k][j], M[maxi][j]); } // perform reduction for (int i = k + 1; i < n; ++i) { real r = -M[i][k] / M[k][k]; for (int j = k + 1; j < n + 1; ++j) { M[i][j] += r * M[k][j]; } } } // regressive solving for (int k = n - 1; k >= 0; --k) { for (int i = 0; i < k; ++i) { M[i][n] += -M[i][k] / M[k][k] * M[k][n]; } x[k] = M[k][n] / M[k][k]; } return true; // solving success } // Solve2D A b == x (n_dim == n, A: matrix) for debuging use template<int n> bool Linear::SolveDebug(real (&A)[n][n], real (&b)[n], real (&x)[n]) { real M[n][n + 1]; // expand to (n+1) cols for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { M[i][j] = A[i][j]; } M[i][n] = b[i]; } printf("before reduction:\n"); for (int i = 0; i < n; ++i) { for (int j = 0; j < n + 1; ++j) { printf("%.2f ", M[i][j]); } printf("\n"); } printf("\n"); for (int k = 0; k < n; ++k) { // n principle component real col_max = fabsf(M[k][k]), fm; int maxi = k; for (int i = k + 1; i < n; ++i) { // find the max in k-th col if ((fm = fabsf(M[i][k])) > col_max) { col_max = fm; maxi = i; } } if (col_max < EPS) { // singular matrix return false; // solving failed } // swap k-th and maxi-th row for (int j = k; j < n + 1; ++j) { std::swap(M[k][j], M[maxi][j]); } // perform reduction for (int i = k + 1; i < n; ++i) { real r = -M[i][k] / M[k][k]; M[i][k] = 0; for (int j = k + 1; j < n + 1; ++j) { M[i][j] += r * M[k][j]; } } } printf("after reduction:\n"); for (int i = 0; i < n; ++i) { for (int j = 0; j < n + 1; ++j) { printf("%.2f ", M[i][j]); } printf("\n"); } printf("\n"); // regressive solving for (int k = n - 1; k >= 0; --k) { for (int i = 0; i < k; ++i) { M[i][n] += -M[i][k] / M[k][k] * M[k][n]; M[i][k] = 0; } M[k][n] /= M[k][k]; M[k][k] = 1; x[k] = M[k][n]; } printf("after solving:\n"); for (int i = 0; i < n; ++i) { for (int j = 0; j < n + 1; ++j) { printf("%.2f ", M[i][j]); } printf("\n"); } printf("\n"); return true; // solving success } // M: expanded Matrix (n x n+1) template<int n> bool Linear::SolveInPlace(real (&M)[n][n + 1]) { for (int k = 0; k < n; ++k) { // n principle component real col_max = fabsf(M[k][k]), fm; int maxi = k; for (int i = k + 1; i < n; ++i) { // find the max in k-th col if ((fm = fabsf(M[i][k])) > col_max) { col_max = fm; maxi = i; } } if (col_max < EPS) { // singular matrix return false; // solving failed } // swap k-th and maxi-th row for (int j = k; j < n + 1; ++j) { std::swap(M[k][j], M[maxi][j]); } // perform reduction for (int i = k + 1; i < n; ++i) { real r = -M[i][k] / M[k][k]; for (int j = k + 1; j < n + 1; ++j) { M[i][j] += r * M[k][j]; } } } // regressive solving for (int k = n - 1; k >= 0; --k) { for (int i = 0; i < k; ++i) { M[i][n] += -M[i][k] / M[k][k] * M[k][n]; } M[k][n] /= M[k][k]; } return true; } bool Linear::Solve2D(real A00, real A01, real A10, real A11, real b0, real b1, real &x0, real &x1) { real det = A00 * A11 - A01 * A10; if (fabsf(det) < EPS) return false; // singular x0 = (A11 * b0 - A01 * b1) / det; x1 = (A00 * b1 - A10 * b0) / det; return true; }
[ "962907278@qq.com" ]
962907278@qq.com
616715b35fbdd0b0aa0460ac20ad0f81d15b292e
8476ceb52232150ef5359b631b942a417acc46e0
/libs/ofxMapper/src/Vertices.h
da0e318a03cd1042b56a057e33772e10b540867f
[]
no_license
tobiasebsen/ofxMapper
7b6835e08b2079de8fda58d47a89ab90b8ad9c2a
09a5c55c32f06aed489897e27af5fe43f5562ea7
refs/heads/master
2020-08-28T00:30:38.212153
2020-06-24T11:28:20
2020-06-24T11:28:20
217,534,728
3
0
null
null
null
null
UTF-8
C++
false
false
324
h
#pragma once #include "ofMain.h" class Vertices { public: Vertices(size_t w, size_t h) : width(w), height(h) { data = new glm::vec2[w*h]; } ~Vertices() { delete data; } glm::vec2 * data = NULL; size_t width = 0; size_t height = 0; }; typedef shared_ptr<Vertices> VerticesPtr;
[ "tobiasebsen@gmail.com" ]
tobiasebsen@gmail.com
72c70e3daabfeae53aef611896d670b66cbdfb7b
74af5be7e79b5fe789e90c6f64ebbdbe2cf7543d
/SimpleDriver.cpp
7992a291e702435832932caefce80b66bcd7a473
[]
no_license
bartek1912/torcs_bot_uwr
ff472d750047fb0491266ef45d1c1e71ac7e6593
aac21d095182ba3e59bafe80602afd28b882ef41
refs/heads/master
2021-01-11T21:55:54.575265
2017-01-05T21:07:18
2017-01-05T21:07:18
78,879,268
0
0
null
null
null
null
UTF-8
C++
false
false
2,647
cpp
/*************************************************************************** file : SimpleDriver.cpp copyright : (C) 2007 Daniele Loiacono ***************************************************************************/ /*************************************************************************** * * * 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 "SimpleDriver.h" const double mnoznik_kier = 8.5711/2; CarControl SimpleDriver::wDrive(CarState cs) { double dir; int id_mx = TRACK_SENSORS_NUM/2; for(int i = 0; i < TRACK_SENSORS_NUM; i++) if(cs.getTrack(i) > cs.getTrack(id_mx)) id_mx = i; dir = -(id_mx - TRACK_SENSORS_NUM/2)/static_cast<double>(TRACK_SENSORS_NUM) * mnoznik_kier; double acc = 1, br = 0; //100 - 30 //200 - 60 //300 - 270 if((cs.getTrack(id_mx) < 150 && cs.getTotalSpeed() > 260) || (cs.getTrack(id_mx) < 100 && cs.getTotalSpeed() > 220) || (cs.getTrack(id_mx) < 60 && cs.getTotalSpeed() > 150) || (cs.getTrack(id_mx) < 50 && cs.getTotalSpeed() > 120) || (cs.getTrack(id_mx) < 40 && cs.getTotalSpeed() > 100) || (cs.getTrack(id_mx) < 30 && cs.getTotalSpeed() > 85) || (cs.getTrack(id_mx) < 20 && cs.getTotalSpeed() > 70)) { br = 1; acc = 0; } filterABS(cs, br); return CarControl(acc, br, cs.getGear(), dir, 0.00); } float SimpleDriver::filterABS(CarState &cs,float brake) const { float speed = cs.getSpeedX() / 3.6; if (speed < absMinSpeed) return brake; float slip = 0.0f; for (int i = 0; i < 4; i++){ slip += cs.getWheelSpinVel(i) * wheelRadius[i];} slip = speed - slip/4.0f; if (slip > absSlip){ brake = brake - (slip - absSlip)/absRange; } if (brake<0) return 0; else return brake; } void SimpleDriver::onShutdown() { // cout << "Bye bye!" << endl; } void SimpleDriver::onRestart() { } /* ABS Filter Constants */ const float SimpleDriver::wheelRadius[4]={0.3179,0.3179,0.3276,0.3276}; const float SimpleDriver::absSlip=2.0; const float SimpleDriver::absRange=3.0; const float SimpleDriver::absMinSpeed=3.0;
[ "bnajdecki@gmail.com" ]
bnajdecki@gmail.com
60e8e8c09ee24609eb359bd8fb72be63c15f09b0
f91ad86483e866f8ce7e2fdc962153fd303dda68
/Source/Game/Game_Accessor.h
792b009c8547c3120fc91db5ae68666fb00599c6
[]
no_license
VictorPetersson3/Spelprojekt3_Shmup
4a3a01ea7df40e089778e448cac0ea56fc32df7c
51ec519ca16861438c843eb9d6f6abfd321f0e21
refs/heads/main
2023-03-07T11:36:37.506543
2021-02-28T15:43:28
2021-02-28T15:43:28
326,771,200
0
2
null
null
null
null
UTF-8
C++
false
false
452
h
#pragma once #include "Game.h" class CGame; namespace Studio { class GameAccessor { public: static GameAccessor& GetInstance(); private: GameAccessor() = default; static GameAccessor ourInstance; CGame* myGame; public: GameAccessor(GameAccessor const&) = delete; void operator=(GameAccessor const&) = delete; CGame* GetGame(); void SetGame(CGame* aGame); }; }
[ "victor.petersson@studerande.thegameassembly.se" ]
victor.petersson@studerande.thegameassembly.se
a2d4e0aa7e7da79efed8f9181bc802ff1f3f3892
66330f7a1ff0b8447b4245474ab4de48727fd1c5
/libs/marshalling/core/include/nil/marshalling/types/no_value/basic_type.hpp
7d294e46d470395825327ea8771bf19b2a49f959
[ "MIT" ]
permissive
everscalecodes/knapsack-snark
fd3cc6155125ae6ff0fc56aa979f84ba6a8c49c7
633515a13906407338a81b9874d964869ddec624
refs/heads/main
2023-07-18T06:05:22.319230
2021-08-31T16:10:16
2021-08-31T16:10:16
447,180,824
0
1
MIT
2022-01-12T10:53:21
2022-01-12T10:53:20
null
UTF-8
C++
false
false
4,374
hpp
//---------------------------------------------------------------------------// // Copyright (c) 2017-2021 Mikhail Komarov <nemo@nil.foundation> // Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation> // // MIT License // // 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 MARSHALLING_BASIC_NO_VALUE_HPP #define MARSHALLING_BASIC_NO_VALUE_HPP #include <type_traits> #include <nil/marshalling/status_type.hpp> namespace nil { namespace marshalling { namespace types { namespace detail { template<typename TFieldBase> class basic_no_value : public TFieldBase { using base_impl_type = TFieldBase; public: using value_type = unsigned; using serialized_type = value_type; basic_no_value() = default; basic_no_value(const basic_no_value &) = default; basic_no_value(basic_no_value &&) = default; ~basic_no_value() noexcept = default; basic_no_value &operator=(const basic_no_value &) = default; basic_no_value &operator=(basic_no_value &&) = default; static value_type &value() { static value_type value = value_type(); return value; } static constexpr std::size_t length() { return 0U; } static constexpr std::size_t min_length() { return length(); } static constexpr std::size_t max_length() { return length(); } static constexpr serialized_type to_serialized(value_type val) { return static_cast<serialized_type>(val); } static constexpr value_type from_serialized(serialized_type val) { return static_cast<value_type>(val); } template<typename TIter> static status_type read(TIter &iter, std::size_t size) { static_cast<void>(iter); static_cast<void>(size); return status_type::success; } template<typename TIter> static void read_no_status(TIter &iter) { static_cast<void>(iter); } template<typename TIter> static status_type write(TIter &iter, std::size_t size) { static_cast<void>(iter); static_cast<void>(size); return status_type::success; } template<typename TIter> static void write_no_status(TIter &iter) { static_cast<void>(iter); } }; } // namespace detail } // namespace types } // namespace marshalling } // namespace nil #endif // MARSHALLING_BASIC_NO_VALUE_HPP
[ "curryrasul@gmail.com" ]
curryrasul@gmail.com
fa801c65b682a44280459aa78214741d23a16c6a
be5e2f6c52805f40d6108288a851dbb214eef4f1
/src/muparser/muParserDef.h
52c676c2c2d5e1530055d70f9c43d8bcc94ba9af
[ "BSD-3-Clause", "MIT" ]
permissive
ismailqau/isymtecai-chrono-parser
c17e1b769845eab66243f396b3ae259d0bff322e
9f6f0d1d0493de8332af6885a9ccde95c7d809b2
refs/heads/master
2020-03-29T23:42:17.199121
2018-09-04T14:47:46
2018-09-04T14:47:46
150,484,953
0
0
BSD-3-Clause
2018-09-26T20:17:14
2018-09-26T20:17:13
null
UTF-8
C++
false
false
14,249
h
/* __________ _____ __ __\______ \_____ _______ ______ ____ _______ / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \ | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/ |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__| \/ \/ \/ \/ Copyright (C) 2014 Ingo Berg 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 MUP_DEF_H #define MUP_DEF_H #include <iostream> #include <string> #include <sstream> #include <map> #include "muParserFixes.h" /** \file \brief This file contains standard definitions used by the parser. */ #define MUP_VERSION _T("2.2.5") #define MUP_VERSION_DATE _T("20150427; GC") #define MUP_CHARS _T("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") /** \brief If this macro is defined mathematical exceptions (div by zero) will be thrown as exceptions. */ //#define MUP_MATH_EXCEPTIONS /** \brief Define the base datatype for values. This datatype must be a built in value type. You can not use custom classes. It should be working with all types except "int"! */ #define MUP_BASETYPE double /** \brief Activate this option in order to compile with OpenMP support. OpenMP is used only in the bulk mode it may increase the performance a bit. */ //#define MUP_USE_OPENMP #if defined(_UNICODE) /** \brief Definition of the basic parser string type. */ #define MUP_STRING_TYPE std::wstring #if !defined(_T) #define _T(x) L##x #endif // not defined _T #else #ifndef _T #define _T(x) x #endif /** \brief Definition of the basic parser string type. */ #define MUP_STRING_TYPE std::string #endif #if defined(_DEBUG) /** \brief Debug macro to force an abortion of the programm with a certain message. */ #define MUP_FAIL(MSG) \ { \ bool MSG=false; \ assert(MSG); \ } /** \brief An assertion that does not kill the program. This macro is neutralised in UNICODE builds. It's too difficult to translate. */ #define MUP_ASSERT(COND) \ if (!(COND)) \ { \ stringstream_type ss; \ ss << _T("Assertion \"") _T(#COND) _T("\" failed: ") \ << __FILE__ << _T(" line ") \ << __LINE__ << _T("."); \ throw ParserError( ss.str() ); \ } #else #define MUP_FAIL(MSG) #define MUP_ASSERT(COND) #endif namespace mu { #if defined(_UNICODE) //------------------------------------------------------------------------------ /** \brief Encapsulate wcout. */ inline std::wostream& console() { return std::wcout; } /** \brief Encapsulate cin. */ inline std::wistream& console_in() { return std::wcin; } #else /** \brief Encapsulate cout. Used for supporting UNICODE more easily. */ inline std::ostream& console() { return std::cout; } /** \brief Encapsulate cin. Used for supporting UNICODE more easily. */ inline std::istream& console_in() { return std::cin; } #endif //------------------------------------------------------------------------------ /** \brief Bytecode values. \attention The order of the operator entries must match the order in ParserBase::c_DefaultOprt! */ enum ECmdCode { // The following are codes for built in binary operators // apart from built in operators the user has the opportunity to // add user defined operators. cmLE = 0, ///< Operator item: less or equal cmGE = 1, ///< Operator item: greater or equal cmNEQ = 2, ///< Operator item: not equal cmEQ = 3, ///< Operator item: equals cmLT = 4, ///< Operator item: less than cmGT = 5, ///< Operator item: greater than cmADD = 6, ///< Operator item: add cmSUB = 7, ///< Operator item: subtract cmMUL = 8, ///< Operator item: multiply cmDIV = 9, ///< Operator item: division cmPOW = 10, ///< Operator item: y to the power of ... cmLAND = 11, cmLOR = 12, cmASSIGN = 13, ///< Operator item: Assignment operator cmBO = 14, ///< Operator item: opening bracket cmBC = 15, ///< Operator item: closing bracket cmIF = 16, ///< For use in the ternary if-then-else operator cmELSE = 17, ///< For use in the ternary if-then-else operator cmENDIF = 18, ///< For use in the ternary if-then-else operator cmARG_SEP = 19, ///< function argument separator cmVAR = 20, ///< variable item cmVAL = 21, ///< value item // For optimization purposes cmVARPOW2, cmVARPOW3, cmVARPOW4, cmVARMUL, cmPOW2, // operators and functions cmFUNC, ///< Code for a generic function item cmFUNC_STR, ///< Code for a function with a string parameter cmFUNC_BULK, ///< Special callbacks for Bulk mode with an additional parameter for the bulk index cmSTRING, ///< Code for a string token cmOPRT_BIN, ///< user defined binary operator cmOPRT_POSTFIX, ///< code for postfix operators cmOPRT_INFIX, ///< code for infix operators cmEND, ///< end of formula cmUNKNOWN ///< uninitialized item }; //------------------------------------------------------------------------------ /** \brief Types internally used by the parser. */ enum ETypeCode { tpSTR = 0, ///< String type (Function arguments and constants only, no string variables) tpDBL = 1, ///< Floating point variables tpVOID = 2 ///< Undefined type. }; //------------------------------------------------------------------------------ enum EParserVersionInfo { pviBRIEF, pviFULL }; //------------------------------------------------------------------------------ /** \brief Parser operator precedence values. */ enum EOprtAssociativity { oaLEFT = 0, oaRIGHT = 1, oaNONE = 2 }; //------------------------------------------------------------------------------ /** \brief Parser operator precedence values. */ enum EOprtPrecedence { // binary operators prLOR = 1, prLAND = 2, prLOGIC = 3, ///< logic operators prCMP = 4, ///< comparsion operators prADD_SUB = 5, ///< addition prMUL_DIV = 6, ///< multiplication/division prPOW = 7, ///< power operator priority (highest) // infix operators prINFIX = 6, ///< Signs have a higher priority than ADD_SUB, but lower than power operator prPOSTFIX = 6 ///< Postfix operator priority (currently unused) }; //------------------------------------------------------------------------------ // basic types /** \brief The numeric datatype used by the parser. Normally this is a floating point type either single or double precision. */ typedef MUP_BASETYPE value_type; /** \brief The stringtype used by the parser. Depends on whether UNICODE is used or not. */ typedef MUP_STRING_TYPE string_type; /** \brief The character type used by the parser. Depends on whether UNICODE is used or not. */ typedef string_type::value_type char_type; /** \brief Typedef for easily using stringstream that respect the parser stringtype. */ typedef std::basic_stringstream<char_type, std::char_traits<char_type>, std::allocator<char_type> > stringstream_type; // Data container types /** \brief Type used for storing variables. */ typedef std::map<string_type, value_type*> varmap_type; /** \brief Type used for storing constants. */ typedef std::map<string_type, value_type> valmap_type; /** \brief Type for assigning a string name to an index in the internal string table. */ typedef std::map<string_type, std::size_t> strmap_type; // Parser callbacks /** \brief Callback type used for functions without arguments. */ typedef value_type (*generic_fun_type)(); /** \brief Callback type used for functions without arguments. */ typedef value_type (*fun_type0)(); /** \brief Callback type used for functions with a single arguments. */ typedef value_type (*fun_type1)(value_type); /** \brief Callback type used for functions with two arguments. */ typedef value_type (*fun_type2)(value_type, value_type); /** \brief Callback type used for functions with three arguments. */ typedef value_type (*fun_type3)(value_type, value_type, value_type); /** \brief Callback type used for functions with four arguments. */ typedef value_type (*fun_type4)(value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with five arguments. */ typedef value_type (*fun_type5)(value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with six arguments. */ typedef value_type (*fun_type6)(value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with seven arguments. */ typedef value_type (*fun_type7)(value_type, value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with eight arguments. */ typedef value_type (*fun_type8)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with nine arguments. */ typedef value_type (*fun_type9)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with ten arguments. */ typedef value_type (*fun_type10)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions without arguments. */ typedef value_type (*bulkfun_type0)(int, int); /** \brief Callback type used for functions with a single arguments. */ typedef value_type (*bulkfun_type1)(int, int, value_type); /** \brief Callback type used for functions with two arguments. */ typedef value_type (*bulkfun_type2)(int, int, value_type, value_type); /** \brief Callback type used for functions with three arguments. */ typedef value_type (*bulkfun_type3)(int, int, value_type, value_type, value_type); /** \brief Callback type used for functions with four arguments. */ typedef value_type (*bulkfun_type4)(int, int, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with five arguments. */ typedef value_type (*bulkfun_type5)(int, int, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with six arguments. */ typedef value_type (*bulkfun_type6)(int, int, value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with seven arguments. */ typedef value_type (*bulkfun_type7)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with eight arguments. */ typedef value_type (*bulkfun_type8)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with nine arguments. */ typedef value_type (*bulkfun_type9)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with ten arguments. */ typedef value_type (*bulkfun_type10)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type); /** \brief Callback type used for functions with a variable argument list. */ typedef value_type (*multfun_type)(const value_type*, int); /** \brief Callback type used for functions taking a string as an argument. */ typedef value_type (*strfun_type1)(const char_type*); /** \brief Callback type used for functions taking a string and a value as arguments. */ typedef value_type (*strfun_type2)(const char_type*, value_type); /** \brief Callback type used for functions taking a string and two values as arguments. */ typedef value_type (*strfun_type3)(const char_type*, value_type, value_type); /** \brief Callback used for functions that identify values in a string. */ typedef int (*identfun_type)(const char_type *sExpr, int *nPos, value_type *fVal); /** \brief Callback used for variable creation factory functions. */ typedef value_type* (*facfun_type)(const char_type*, void*); } // end of namespace #endif
[ "dmvlas77@googlemail.com" ]
dmvlas77@googlemail.com
8d00b074cfb27b4b5020f56dface31d213234e95
fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd
/ui/ozone/platform/wayland/xdg_surface_wrapper.h
3aa7240f8dcd4e0d636247eb7214e8ca8ebce57c
[ "BSD-3-Clause" ]
permissive
wzyy2/chromium-browser
2644b0daf58f8b3caee8a6c09a2b448b2dfe059c
eb905f00a0f7e141e8d6c89be8fb26192a88c4b7
refs/heads/master
2022-11-23T20:25:08.120045
2018-01-16T06:41:26
2018-01-16T06:41:26
117,618,467
3
2
BSD-3-Clause
2022-11-20T22:03:57
2018-01-16T02:09:10
null
UTF-8
C++
false
false
1,831
h
// Copyright 2017 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. #ifndef UI_OZONE_PLATFORM_WAYLAND_XDG_SURFACE_WRAPPER_H_ #define UI_OZONE_PLATFORM_WAYLAND_XDG_SURFACE_WRAPPER_H_ #include "base/strings/string16.h" #include "ui/ozone/platform/wayland/wayland_object.h" namespace gfx { class Rect; } namespace ui { class WaylandConnection; // Wrapper interface for different xdg shell versions. class XDGSurfaceWrapper { public: virtual ~XDGSurfaceWrapper() {} // Initializes the surface. virtual bool Initialize(WaylandConnection* connection, wl_surface* surface) = 0; // Sets a native window to maximized state. virtual void SetMaximized() = 0; // Unsets a native window from maximized state. virtual void UnSetMaximized() = 0; // Sets a native window to fullscreen state. virtual void SetFullScreen() = 0; // Unsets a native window from fullscreen state. virtual void UnSetFullScreen() = 0; // Sets a native window to minimized state. virtual void SetMinimized() = 0; // Tells wayland to start interactive window drag. virtual void SurfaceMove(WaylandConnection* connection) = 0; // Tells wayland to start interactive window resize. virtual void SurfaceResize(WaylandConnection* connection, uint32_t hittest) = 0; // Sets a title of a native window. virtual void SetTitle(const base::string16& title) = 0; // Sends acknowledge configure event back to wayland. virtual void AckConfigure() = 0; // Sets a desired window geometry once wayland requests client to do so. virtual void SetWindowGeometry(const gfx::Rect& bounds) = 0; }; } // namespace ui #endif // UI_OZONE_PLATFORM_WAYLAND_XDG_SURFACE_WRAPPER_H_
[ "jacob-chen@iotwrt.com" ]
jacob-chen@iotwrt.com
98fbb6700ba03db0449b5ed1f1f6460e813fb107
4b975bf8af05dee544c09f8fa59418269e8a22fe
/circular_LL.cpp
ed9e8e547a0b01d304e7569eae16d97711514b5b
[]
no_license
shivangisareen/data_structures_algorithms
a93aff1248ce74de39712e9f0a9c008e6ba62f30
6b2ab97c892e7b2ff719604334cb52048c8cf37f
refs/heads/master
2021-08-24T02:16:26.446954
2017-12-07T16:15:41
2017-12-07T16:15:41
111,838,762
1
0
null
null
null
null
UTF-8
C++
false
false
1,847
cpp
#include <stdio.h> #include <iostream> using namespace std; struct node { int data; node* next; }; node* head= new node; node* curr= new node; void addNodeEnd(int num) { node* n= new node; n->data=num; if(head!=NULL) { curr=head; while(curr->next!=head) { curr=curr->next; } curr->next=n; n->next=head; } else { head=n; curr=head; n->next=head; } } void addNodeStart(int num) { node* n = new node; n->data=num; curr=head; if(head!=NULL) { while(curr->next!=head) { curr=curr->next; } n->next=head; curr->next=n; head=n; } else { head=n; n->next=head; } } void printList() { curr=head; while(curr->next!=head) { cout<<curr->data<<" "; curr=curr->next; } cout<<curr->data<<" "; } void addNodeInBetween(int num) { node* n= new node; node* temp= new node; n->data=num; int position, count=1; cout<<"Enter position(index) of the element"<<endl; cin>>position; curr=head; while(count<position) { curr=curr->next; count++; } temp=curr->next; curr->next=n; n->next=temp; } void search(int num) { node* temp=new node; temp=head; int count=1; int flag=0; if(temp->data==num) { cout<<"Element found at position:"<<count<<endl; flag=1; } else { while(temp->data!=num) { temp=temp->next; count++; flag=1; if(temp->data!=num && temp->next==NULL) { flag=0; break; } } if(flag!=0) { cout<<"Element found at position:"<<count<<endl; } else { cout<<"Element not found"<<endl; } } } int main(){ head=NULL; addNodeStart(1); addNodeStart(3); addNodeStart(5); addNodeStart(6); addNodeStart(4); addNodeEnd(7); addNodeEnd(9); printList(); search(9); }
[ "noreply@github.com" ]
shivangisareen.noreply@github.com
c544026f945597d27e49989d33389eaaa5b12084
6b0ca4ece69cb52c30228395d8201137028605eb
/cpp/831-840/Sum of Distances in Tree.cpp
073b8fa574acb6301d790384fad5088a3f964ce5
[ "MIT" ]
permissive
gzc/leetcode
d8245071199e1b6321856ba0ddbdef5acfb5b2ac
1a604df1e86c9775b8db364bfb3a5462ed96e9d0
refs/heads/master
2022-02-04T00:12:19.448204
2022-01-30T03:08:14
2022-01-30T03:08:14
32,258,529
178
68
MIT
2021-03-28T16:50:18
2015-03-15T12:04:59
C++
UTF-8
C++
false
false
1,596
cpp
class Solution { int dfs(int start, vector<int>& myNodes, vector<bool>& visited, map<int, vector<int>>& graph, int level, int& res) { visited[start] = true; int nodeNum = 1; for (int neig : graph[start]) { if (visited[neig]) continue; nodeNum += dfs(neig, myNodes, visited, graph, level+1, res); } myNodes[start] = nodeNum; res += level; return nodeNum; } void dfs2(int start, vector<int>& myNodes, map<int, vector<int>>& graph, vector<int>& ans, int distanceOfStart) { if (ans[start] < 0) { int mine = myNodes[start] - 1; int other =myNodes.size() - mine - 2; ans[start] = distanceOfStart + (other - mine); } for (int neig : graph[start]) { if (ans[neig] > 0) continue; dfs2(neig, myNodes, graph, ans, ans[start]); } } public: vector<int> sumOfDistancesInTree(int N, vector<vector<int>>& edges) { map<int, vector<int>> graph; for (auto& edge : edges) { int u = edge[0]; int v = edge[1]; graph[u].push_back(v); graph[v].push_back(u); } int distanceOfStart = 0; vector<int> myNodes(N, 0); vector<bool> visited(N, false); dfs(0, myNodes, visited, graph, 0, distanceOfStart); vector<int> ans(N, -1); ans[0] =distanceOfStart; dfs2(0, myNodes, graph, ans, distanceOfStart); return ans; } };
[ "noreply@github.com" ]
gzc.noreply@github.com
b788e1003bf2749b3ec34a1259e324dcb635c1d3
397403cb1e7fc66e2a849859a9c66ac915b3f9d6
/Plugins/OSSShading/Intermediate/Build/Win64/UE4Editor/Inc/OSSShading/MaterialExpressionOSSMad.generated.h
8ab023267696c8eba93538fef911ea5ac7fbaf6f
[]
no_license
seanssoh/HenryAlone
cdc0fb62bbc49f965ab255a5add598dd44501ebb
3555bbac6823749338682c280161db99fd1e6080
refs/heads/master
2021-01-11T03:12:30.710772
2016-10-17T16:51:59
2016-10-17T16:51:59
71,038,724
0
0
null
null
null
null
UTF-8
C++
false
false
4,713
h
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. /*=========================================================================== C++ class header boilerplate exported from UnrealHeaderTool. This is automatically generated by the tools. DO NOT modify this manually! Edit the corresponding .h files instead! ===========================================================================*/ #include "ObjectBase.h" PRAGMA_DISABLE_DEPRECATION_WARNINGS #ifdef OSSSHADING_MaterialExpressionOSSMad_generated_h #error "MaterialExpressionOSSMad.generated.h already included, missing '#pragma once' in MaterialExpressionOSSMad.h" #endif #define OSSSHADING_MaterialExpressionOSSMad_generated_h #define HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_RPC_WRAPPERS #define HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_RPC_WRAPPERS_NO_PURE_DECLS #define HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_INCLASS_NO_PURE_DECLS \ private: \ static void StaticRegisterNativesUMaterialExpressionOSSMad(); \ friend OSSSHADING_API class UClass* Z_Construct_UClass_UMaterialExpressionOSSMad(); \ public: \ DECLARE_CLASS(UMaterialExpressionOSSMad, UMaterialExpression, COMPILED_IN_FLAGS(0), 0, TEXT("/Script/OSSShading"), NO_API) \ DECLARE_SERIALIZER(UMaterialExpressionOSSMad) \ /** Indicates whether the class is compiled into the engine */ \ enum {IsIntrinsic=COMPILED_IN_INTRINSIC}; #define HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_INCLASS \ private: \ static void StaticRegisterNativesUMaterialExpressionOSSMad(); \ friend OSSSHADING_API class UClass* Z_Construct_UClass_UMaterialExpressionOSSMad(); \ public: \ DECLARE_CLASS(UMaterialExpressionOSSMad, UMaterialExpression, COMPILED_IN_FLAGS(0), 0, TEXT("/Script/OSSShading"), NO_API) \ DECLARE_SERIALIZER(UMaterialExpressionOSSMad) \ /** Indicates whether the class is compiled into the engine */ \ enum {IsIntrinsic=COMPILED_IN_INTRINSIC}; #define HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_STANDARD_CONSTRUCTORS \ /** Standard constructor, called after all reflected properties have been initialized */ \ NO_API UMaterialExpressionOSSMad(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); \ DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UMaterialExpressionOSSMad) \ DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UMaterialExpressionOSSMad); \ DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UMaterialExpressionOSSMad); \ private: \ /** Private move- and copy-constructors, should never be used */ \ NO_API UMaterialExpressionOSSMad(UMaterialExpressionOSSMad&&); \ NO_API UMaterialExpressionOSSMad(const UMaterialExpressionOSSMad&); \ public: #define HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_ENHANCED_CONSTRUCTORS \ private: \ /** Private move- and copy-constructors, should never be used */ \ NO_API UMaterialExpressionOSSMad(UMaterialExpressionOSSMad&&); \ NO_API UMaterialExpressionOSSMad(const UMaterialExpressionOSSMad&); \ public: \ DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, UMaterialExpressionOSSMad); \ DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(UMaterialExpressionOSSMad); \ DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(UMaterialExpressionOSSMad) #define HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_12_PROLOG #define HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_GENERATED_BODY_LEGACY \ PRAGMA_DISABLE_DEPRECATION_WARNINGS \ public: \ HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_RPC_WRAPPERS \ HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_INCLASS \ HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_STANDARD_CONSTRUCTORS \ public: \ PRAGMA_ENABLE_DEPRECATION_WARNINGS #define HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_GENERATED_BODY \ PRAGMA_DISABLE_DEPRECATION_WARNINGS \ public: \ HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_RPC_WRAPPERS_NO_PURE_DECLS \ HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_INCLASS_NO_PURE_DECLS \ HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h_15_ENHANCED_CONSTRUCTORS \ private: \ PRAGMA_ENABLE_DEPRECATION_WARNINGS #undef CURRENT_FILE_ID #define CURRENT_FILE_ID HenryAlone_Plugins_OSSShading_Source_OSSShading_Public_MaterialExpressionOSSMad_h PRAGMA_ENABLE_DEPRECATION_WARNINGS
[ "seanssoh@gmail.com" ]
seanssoh@gmail.com
1126ac9d458cd999ea6dcf580c55e5803385803a
2c55f75c7b671eb4132818d2950b6439ff75464d
/程序设计实验/实验一/输入3组坐标,按指定格式输出.cpp
846d7b4cfeb32cb73c73968fe7257b4799dac538
[]
no_license
Monkeyman520/CPP
fb8fcbbcd55f51b3dd945aac180c614b884b1780
a07df1456e52cbd44579e5e199cd209b3ae23a4c
refs/heads/master
2020-09-27T12:06:29.300846
2018-09-16T03:26:09
2018-09-16T03:26:09
null
0
0
null
null
null
null
GB18030
C++
false
false
396
cpp
//输入3组坐标,按指定格式输出 #include <iostream> using namespace std; int main() { char z; int x1, x2, x3, y1, y2, y3; cin >> z >> x1 >> z >> y1 >> z >> z >> z >> x2 >> z >> y2 >> z >> z >> z >> x3 >> z >> y3 >>z; cout << '[' << x1 << ',' << y1 <<']' << endl; cout << '[' << x2 << ',' << y2 <<']' << endl; cout << '[' << x3 << ',' << y3 <<']' << endl; return 0; }
[ "1637894214@qq.com" ]
1637894214@qq.com
90e14f9d004453124383df7afe4f818387c6c68a
8f514ed747ffd1f62919074d3091d4028e0cd349
/wkb.cpp
754409bd01b08d069409fbf626fc98cf0160e0cc
[]
no_license
darkserj/wkb_wrapper
e0e8d5f1adb0ecee5ff113780a011a7a655ad0f0
76c6d904b08e67a29664d0d2ecf2e1b2de67f788
refs/heads/master
2020-04-04T19:12:42.811426
2013-02-04T15:12:49
2013-02-04T15:12:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,119
cpp
// // wkb.cpp // #include "wkb.h" void ml::make_wkb_point(std::vector<char> &wkb, ml::point_d const &pt) { wkb.resize(21); wkb[0] = 1; *((unsigned int *)&wkb[1]) = 1; // wkb_point *((double *)&wkb[5]) = pt.x; *((double *)&wkb[13]) = pt.y; } ml::rect_d ml::wkb::bounds() const { struct bounds_counter { ml::rect_d r; bounds_counter() : r(ml::rect_d::void_rect()) {} void operator()(ml::point_d const *begin, ml::point_d const *end) { r.bounds(begin,end); } ml::rect_d bounds() const { return r; } }; bounds_counter b; return apply(b).bounds(); } std::string ml::wkb::to_geo_json() const { struct point_formatter { std::stringstream &ss; unsigned int counter; bool parts; point_formatter(std::stringstream &s) : ss(s),counter(0), parts(false) {} void operator() (ml::point_d const *begin, ml::point_d const *end) { if (parts) ss << (counter ? ",[" : "["); ss << "[" << begin->x << "," << begin->y << "]"; for(++begin;begin != end;++begin){ ss << ",[" << begin->x << "," << begin->y << "]"; } if (parts) ss << "]"; ++counter; } point_formatter & make_parts(bool p) {parts = p; counter = 0; return *this;} }; std::stringstream ss; point_formatter fmt(ss); ss << std::fixed << std::showpoint << std::setprecision(6); ss << "{"; switch(type()) { case wkb_point: { ss << "\"type\":\"Point\",\"coordinates\":"; apply(fmt); } break; case wkb_line_string: { ss << "\"type\":\"LineString\",\"coordinates\": ["; apply(fmt); ss << "]"; } break; case wkb_multi_line_string: { ss << "\"type\":\"MultiLineString\",\"coordinates\": ["; apply(fmt.make_parts(true)); ss << "]"; } break; case wkb_polygon: { ss << "\"type\":\"Polygon\",\"coordinates\": ["; apply(fmt.make_parts(true)); ss << "]"; } break; case wkb_multi_polygon: { ss << "\"type\":\"MultiPolygon\",\"coordinates\": ["; for(size_t i=0; i < size(); ++i) { ss << (i ? ",[" : "["); polygon(i).apply(fmt.make_parts(true)); ss << "]"; } ss << "]"; } break; default: break; } ss << "}"; return ss.str(); }
[ "yershov@corp.mail.ru" ]
yershov@corp.mail.ru
a0ef254c0cc50088befe4daa5a4a78bc5f018a25
ff6c94371e939656c2beb21307630446e3b8ccf7
/CaseGenerator.cpp
833d3449d028f38ae156d989573eaa52cc5ffaf3
[]
no_license
competitiveprogramming/Sadia_apu_code_library_DS_and_algorithm
32217fb3ecdfbc2c1992f5bb07dcf708c2299f8c
0b9347bc9542ba24432bb9ebee20934c4f3457cf
refs/heads/master
2021-10-18T22:11:06.243725
2019-02-14T18:40:11
2019-02-14T18:40:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
740
cpp
#include<stdio.h> #include<iostream> #include<string.h> #include<stdlib.h> #include<math.h> #include<algorithm> #include<set> #include<map> #include<utility> #include<vector> #include<string> #include<stack> #include<queue> using namespace std; int main() { freopen("data.txt", "w", stdout); srand(time(NULL)); int T = rand()%50 + 1; int R,C,K,r,c,n; printf("%d\n", T); while(T--) { R = rand()%200 + 1, C = rand()%200 + 1; K = rand()%112500+1; printf("%d %d %d\n", R,C,K); for (r=1; r<=R; ++r) { for (c=1; c<=C; ++c) { n = rand()%20 + 1; printf("%d ", n); } puts(""); } } return 0; }
[ "s.i.r.computerengineer24@gmail.com" ]
s.i.r.computerengineer24@gmail.com
46effb3436023cf959a0f5963ce426d612f7f0c5
138a353006eb1376668037fcdfbafc05450aa413
/source/ArenaCamera.cpp
48b047fa6f49144f1cdf706b0241410033d51e0e
[]
no_license
sonicma7/choreopower
107ed0a5f2eb5fa9e47378702469b77554e44746
1480a8f9512531665695b46dcfdde3f689888053
refs/heads/master
2020-05-16T20:53:11.590126
2009-11-18T03:10:12
2009-11-18T03:10:12
32,246,184
0
0
null
null
null
null
UTF-8
C++
false
false
1,002
cpp
#include "ArenaCamera.h" ArenaCamera::ArenaCamera(Ogre::SceneNode *target1, Ogre::SceneNode *target2, Ogre::Camera *cam) { mTarget1 = target1; mTarget2 = target2; mCamera = cam; mMinDist = 0.0f; } ArenaCamera::~ArenaCamera() { } void ArenaCamera::setMinDistanceAway(float dist) { mMinDist = dist; } void ArenaCamera::update() { Ogre::Vector3 lookAt; Ogre::Vector3 camPos(mCamera->getPosition()); float distance; float idealDistance; float fov = mCamera->getFOVy().valueRadians(); float xDist; float otherAngle = 90 - fov; lookAt = (mTarget1->getPosition() + mTarget2->getPosition()) * 0.5f; xDist = fabs(mTarget1->getPosition().x - mTarget2->getPosition().x); distance = camPos.z - lookAt.z; idealDistance = 0.5f * xDist * Ogre::Math::Sin(otherAngle) / Ogre::Math::Sin(0.5f * fov); if(idealDistance > mMinDist) { camPos.z = idealDistance; } else { camPos.z = mMinDist; } mCamera->setPosition(camPos); mCamera->lookAt(lookAt); }
[ "Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e" ]
Sonicma7@0822fb10-d3c0-11de-a505-35228575a32e
7609df037106a2d77844a03e8e0d6c2a8d6cc8fe
e0504349fceb190be0988b2f2532826b90fa3d16
/rtos/ConditionVariable.h
dd091ec3d4ee30f2c52ad2c650fccd6c4114378e
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
CalSol/mbed
741e84f2dd2343a2088c3a4b68ddc24088e871d9
da4f23f00bdf450697c735f4b99b77ba04a93314
refs/heads/master
2021-06-07T15:27:24.357365
2019-06-24T02:06:22
2019-06-24T02:06:22
31,633,506
1
2
Apache-2.0
2019-12-05T01:38:21
2015-03-04T02:24:28
C
UTF-8
C++
false
false
6,598
h
/* mbed Microcontroller Library * Copyright (c) 2017-2017 ARM Limited * * 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 CONDITIONVARIABLE_H #define CONDITIONVARIABLE_H #include <stdint.h> #include "cmsis_os.h" #include "rtos/Mutex.h" #include "rtos/Semaphore.h" #include "platform/NonCopyable.h" namespace rtos { /** \addtogroup rtos */ /** @{*/ struct Waiter; /** This class provides a safe way to wait for or send notifications of condition changes * * This class is used in conjunction with a mutex to safely wait for or * notify waiters of condition changes to a resource accessible by multiple * threads. * * # Defined behavior * - All threads waiting on the condition variable wake when * ConditionVariable::notify_all is called. * - If one or more threads are waiting on the condition variable at least * one of them wakes when ConditionVariable::notify is called. * * # Undefined behavior * - The thread which is unblocked on ConditionVariable::notify_one is * undefined if there are multiple waiters. * - The order which in which waiting threads acquire the condition variable's * mutex after ConditionVariable::notify_all is called is undefined. * - When ConditionVariable::notify_one or ConditionVariable::notify_all is * called and there are one or more waiters and one or more threads attempting * to acquire the condition variable's mutex the order in which the mutex is * acquired is undefined. * - The behavior of ConditionVariable::wait and ConditionVariable::wait_for * is undefined if the condition variable's mutex is locked more than once by * the calling thread. * - Spurious notifications (not triggered by the application) can occur * and it is not defined when these occur. * * @note Synchronization level: Thread safe * * Example: * @code * #include "mbed.h" * * Mutex mutex; * ConditionVariable cond(mutex); * * // These variables are protected by locking mutex * uint32_t count = 0; * bool done = false; * * void worker_thread() * { * mutex.lock(); * do { * printf("Worker: Count %lu\r\n", count); * * // Wait for a condition to change * cond.wait(); * * } while (!done); * printf("Worker: Exiting\r\n"); * mutex.unlock(); * } * * int main() { * Thread thread; * thread.start(worker_thread); * * for (int i = 0; i < 5; i++) { * * mutex.lock(); * // Change count and notify waiters of this * count++; * printf("Main: Set count to %lu\r\n", count); * cond.notify_all(); * mutex.unlock(); * * wait(1.0); * } * * mutex.lock(); * // Change done and notify waiters of this * done = true; * printf("Main: Set done\r\n"); * cond.notify_all(); * mutex.unlock(); * * thread.join(); * } * @endcode */ class ConditionVariable : private mbed::NonCopyable<ConditionVariable> { public: /** Create and Initialize a ConditionVariable object */ ConditionVariable(Mutex &mutex); /** Wait for a notification * * Wait until a notification occurs. * * @note - The thread calling this function must be the owner of the * ConditionVariable's mutex and it must be locked exactly once * @note - Spurious notifications can occur so the caller of this API * should check to make sure the condition they are waiting on has * been met * * Example: * @code * mutex.lock(); * while (!condition_met) { * cond.wait(); * } * * function_to_handle_condition(); * * mutex.unlock(); * @endcode */ void wait(); /** Wait for a notification or timeout * * @param millisec timeout value or osWaitForever in case of no time-out. * @return true if a timeout occurred, false otherwise. * * @note - The thread calling this function must be the owner of the * ConditionVariable's mutex and it must be locked exactly once * @note - Spurious notifications can occur so the caller of this API * should check to make sure the condition they are waiting on has * been met * * Example: * @code * mutex.lock(); * Timer timer; * timer.start(); * * bool timed_out = false; * uint32_t time_left = TIMEOUT; * while (!condition_met && !timed_out) { * timed_out = cond.wait_for(time_left); * uint32_t elapsed = timer.read_ms(); * time_left = elapsed > TIMEOUT ? 0 : TIMEOUT - elapsed; * } * * if (condition_met) { * function_to_handle_condition(); * } * * mutex.unlock(); * @endcode */ bool wait_for(uint32_t millisec); /** Notify one waiter on this condition variable that a condition changed. * * @note - The thread calling this function must be the owner of the ConditionVariable's mutex */ void notify_one(); /** Notify all waiters on this condition variable that a condition changed. * * @note - The thread calling this function must be the owner of the ConditionVariable's mutex */ void notify_all(); ~ConditionVariable(); protected: struct Waiter { Waiter(); Semaphore sem; Waiter *prev; Waiter *next; bool in_list; }; static void _add_wait_list(Waiter **wait_list, Waiter *waiter); static void _remove_wait_list(Waiter **wait_list, Waiter *waiter); Mutex &_mutex; Waiter *_wait_list; }; } #endif /** @}*/
[ "russ.butler@arm.com" ]
russ.butler@arm.com
a21c81cad764d1eaebaf3ff923a13b6f2b740f58
1b17cb868c571920dadeeab0295d60783a496fc8
/HealthMods/SensorsMod/AurigaHL7/2.4/datatype/PIP.h
5629ba5a3f4888f45a97c38697b8426050882fce
[]
no_license
afmartins85/olamed-modules-src
dc86e2dce4d5c54a450bca95c4775715167cecb9
ec673ef154ef218f3b7c6593914212b125600ebd
refs/heads/master
2023-01-07T16:25:29.437031
2020-11-05T22:30:07
2020-11-05T22:30:07
287,022,753
0
0
null
null
null
null
UTF-8
C++
false
false
4,643
h
/* * This file is part of Auriga HL7 library. * * Auriga HL7 library 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. * * Auriga HL7 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Auriga HL7 library. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __PIP_v24_H__ #define __PIP_v24_H__ #include "../../common/Util.h" #include "../datatype/CE.h" #include "../datatype/DT.h" #include "../datatype/EI.h" namespace HL7_24 { /* Privileges */ class PIP : public HL7Data { public: PIP() { this->init(); } private: /* Field ID */ enum FIELD_ID { PIP_1, /* privilege */ PIP_2, /* privilege class */ PIP_3, /* expiration date */ PIP_4, /* activation date */ PIP_5, /* facility (EI) */ FIELD_ID_MAX }; public: const char *className() const { return "PIP"; } PIP *create() const { return new PIP(); } private: void init() { // setName("PIP"); /* Init members */ addObject<CE>(PIP_1, "PIP.1", HL7::initialized, HL7::repetition_off); addObject<CE>(PIP_2, "PIP.2", HL7::initialized, HL7::repetition_off); addObject<DT>(PIP_3, "PIP.3", HL7::initialized, HL7::repetition_off); addObject<DT>(PIP_4, "PIP.4", HL7::initialized, HL7::repetition_off); addObject<EI>(PIP_5, "PIP.5", HL7::initialized, HL7::repetition_off); } public: /* Getters */ /**************************************** * privilege */ CE *getPIP_1(size_t index = 0) { return (CE *)this->getObjectSafe(index, PIP_1); } CE *getPrivilege(size_t index = 0) { return (CE *)this->getObjectSafe(index, PIP_1); } bool isPIP_1(size_t index = 0) { try { return this->getObject(index, PIP_1) != NULL; } catch (...) { } return false; } bool isPrivilege(size_t index = 0) { try { return this->getObject(index, PIP_1) != NULL; } catch (...) { } return false; } /**************************************** * privilege class */ CE *getPIP_2(size_t index = 0) { return (CE *)this->getObjectSafe(index, PIP_2); } CE *getPrivilegeClass(size_t index = 0) { return (CE *)this->getObjectSafe(index, PIP_2); } bool isPIP_2(size_t index = 0) { try { return this->getObject(index, PIP_2) != NULL; } catch (...) { } return false; } bool isPrivilegeClass(size_t index = 0) { try { return this->getObject(index, PIP_2) != NULL; } catch (...) { } return false; } /**************************************** * expiration date */ DT *getPIP_3(size_t index = 0) { return (DT *)this->getObjectSafe(index, PIP_3); } DT *getExpirationDate(size_t index = 0) { return (DT *)this->getObjectSafe(index, PIP_3); } bool isPIP_3(size_t index = 0) { try { return this->getObject(index, PIP_3) != NULL; } catch (...) { } return false; } bool isExpirationDate(size_t index = 0) { try { return this->getObject(index, PIP_3) != NULL; } catch (...) { } return false; } /**************************************** * activation date */ DT *getPIP_4(size_t index = 0) { return (DT *)this->getObjectSafe(index, PIP_4); } DT *getActivationDate(size_t index = 0) { return (DT *)this->getObjectSafe(index, PIP_4); } bool isPIP_4(size_t index = 0) { try { return this->getObject(index, PIP_4) != NULL; } catch (...) { } return false; } bool isActivationDate(size_t index = 0) { try { return this->getObject(index, PIP_4) != NULL; } catch (...) { } return false; } /**************************************** * facility (EI) */ EI *getPIP_5(size_t index = 0) { return (EI *)this->getObjectSafe(index, PIP_5); } EI *getFacility(size_t index = 0) { return (EI *)this->getObjectSafe(index, PIP_5); } bool isPIP_5(size_t index = 0) { try { return this->getObject(index, PIP_5) != NULL; } catch (...) { } return false; } bool isFacility(size_t index = 0) { try { return this->getObject(index, PIP_5) != NULL; } catch (...) { } return false; } }; /* End PIP */ } /* End HL7_24 */ #endif /*__PIP_v24_H__ */
[ "anderson.fagundes@gmail.com" ]
anderson.fagundes@gmail.com
f2cb40c8f05487c2a9f3b316da6c4676c174cc2f
39d3402b196870be091d71dd466bae7d9a980a34
/chef and the choclate.cpp
66db3212c60e17f30663f550953b12f8f18d152d
[]
no_license
adibyte95/codechef_problems
ab8e743c217e365d634994525bc776c611a03a9a
46c367b6c43db20fd097c1a137a513e895786370
refs/heads/master
2021-01-22T05:50:32.211741
2018-04-12T11:56:13
2018-04-12T11:56:13
81,713,726
0
0
null
null
null
null
UTF-8
C++
false
false
453
cpp
#include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t>0) { long long int n,m; cin>>n>>m; if(n==1 && m%2!=0) cout<<"No"<<endl; else if(n==1 && m%2==0) cout<<"Yes"<<endl; else if(m==1 && n%2==0) cout<<"Yes"<<endl; else if(m==1 && n%2!=0) cout<<"No"<<endl; else { if(n%2==0 || m%2==0) cout<<"Yes"<<endl; else cout<<"No"<<endl; } t--; } return 0; }
[ "noreply@github.com" ]
adibyte95.noreply@github.com
cbd3c900068b4bbc2ccdc006afff00ec5d3b2551
896a24277984903b4edb89def90d959945eb7ea2
/examples/Linalg/Linalg3/include/linalg3/Analysis.h
813fc37b73e020287347dd14207a03303ede3da0
[ "Apache-2.0" ]
permissive
leonid3000/mlir
70af93154d76a012ba17b8d79213089864c54e8a
8c7180e2c37985945c178a8337e8728a605842c3
refs/heads/master
2020-07-24T10:24:05.550955
2019-09-11T17:18:01
2019-09-11T17:18:29
207,893,124
1
0
Apache-2.0
2019-09-11T19:42:35
2019-09-11T19:42:33
null
UTF-8
C++
false
false
1,272
h
//===- Analysis.h - Linalg dialect Analysis function definitions ----------===// // // Copyright 2019 The MLIR Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // ============================================================================= #ifndef LINALG3_ANALYSIS_H_ #define LINALG3_ANALYSIS_H_ #include "linalg2/Analysis.h" namespace mlir { class AffineMap; } // namespace mlir namespace linalg { /// Given a `map` specification and a subset of its results /// `[beginResult, endResult)`, returns the inverse map that maps result /// positions to dim positions. mlir::AffineMap inverseSubMap(mlir::AffineMap map, unsigned beginResult = 0, unsigned endResult = 0); } // namespace linalg #endif // LINALG3_ANALYSIS_H_
[ "joker.eph@gmail.com" ]
joker.eph@gmail.com
eac8cef4f41242e89e0d61bd5333fbb42b4b293e
673cac8e6d3594c6f8f60c4a5be7c843f97c4f38
/Assistente virtual/04 - Assitente Virtual com Python II/Aula extra com Arduino/CodigoMorseFuncao/CodigoMorseFuncao.ino
df1c06697dfb9406c3073a4d5d36b4daa299fb6b
[ "MIT" ]
permissive
Ivoneideduarte/assistente-virtual-com-python
eb5e924487291f6d5077a92e0500fadaca4b7679
7c7e39be5bcdc811a2694d757fd5d0c3817fb55c
refs/heads/master
2022-11-24T12:41:09.592871
2020-08-03T22:12:37
2020-08-03T22:12:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
932
ino
//byte led = 10; int y = 0; void setup() { pinMode(10, OUTPUT); pinMode(13, OUTPUT); Serial.begin(9600); } void loop() { piscaLed(150, 100, 10, 3); //Argumentos Serial.println("Escrevendo S."); piscaLed(400, 100, 10, 3); Serial.println("0."); piscaLed(150, 100, 10, 3); Serial.println("S"); Serial.println("Enviado S.O.S "+String(y)+" vez."); //Concatenando variáveis /*piscaLed(150, 100, 13, 10); Serial.println("Escrevendo S."); piscaLed(400, 100, 13, 10); Serial.println("0."); piscaLed(150, 100, 13, 10); Serial.println("S"); Serial.println("Enviado S.O.S");*/ } //Void é uma função vazia, não retorna nada int piscaLed(int tempLig, int tempDesl, byte porta, int qtd) //Argumentos { for (int x = 0; x < qtd; x++) { digitalWrite(porta, HIGH); delay(tempLig); digitalWrite(porta, LOW); delay(tempDesl); } y++; return y; //Retorna o valor do incremento do y }
[ "contato.ivoneideduarte@gmail.com" ]
contato.ivoneideduarte@gmail.com
603de64f7c84de637fdaea7a4b3ed83397cf9c63
8d15c78f8badb266818cdf67368249148cea46f0
/AngryBirds/OpenGL/Sprite.h
4f7f76a07d2a1fc23f9ee1bf77035017bbde6191
[]
no_license
James81919/AngryBirds
6470670608f4f0cbc8b7e37811f1fdd70ba2a474
e5b0c343023da6d9e0ecf3f2e1575089d501c1a0
refs/heads/master
2020-03-28T20:24:45.820643
2018-09-25T05:08:28
2018-09-25T05:08:28
148,976,368
0
0
null
null
null
null
UTF-8
C++
false
false
972
h
#ifndef __SPRITE_H__ #define __SPRITE_H__ #include "ShaderLoader.h" #include "Utilities.h" class CSprite { public: CSprite(); CSprite(std::string _filepath, GLuint& _shader); ~CSprite(); virtual void Init(); virtual void Update(glm::mat4 _model, glm::mat4 _view, glm::mat4 _projection, glm::vec3 _cameraPos); virtual void Render(); void SetSprite(std::string _sFilePath); protected: std::string m_sFilePath; GLuint m_vbo, m_vao, m_ebo, m_tex, m_index, m_shader; glm::mat4 m_model, m_view, m_projection, m_mvp; glm::vec3 m_cameraPos; GLfloat m_vertices[32] = { // Position // Colour // Tex Coords -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f }; GLuint m_indices[6] = { 0, 1, 2, // First Triangle 0, 2, 3 // Second Triangle }; }; #endif // !__SPRITE_H__
[ "jjohnstone2520@gmail.com" ]
jjohnstone2520@gmail.com
17ade16381180229de4f261f6095b1cc9160de05
64a5bf4e81d354068bfe396dfd93e3c63d3b2294
/samples/snippets/cpp/VS_Snippets_CLR_Classic/classic ArrayList.Add Example/CPP/source.cpp
d460d8e5b5cfbf8aee29a71904382efe0ecf7547
[ "CC-BY-4.0", "MIT" ]
permissive
avatarbuss/dotnet-api-docs
7b14f1a0a71e4a4d3c85523ce5894aea7a125022
f3030b44600c2de2df63995d96a2a6c7e66f4749
refs/heads/master
2022-09-17T19:15:29.173244
2020-04-03T14:38:00
2020-04-03T14:38:00
252,750,128
1
3
NOASSERTION
2020-04-03T14:06:04
2020-04-03T14:06:03
null
UTF-8
C++
false
false
1,751
cpp
// <Snippet1> using namespace System; using namespace System::Collections; void PrintValues( IEnumerable^ myList, char mySeparator ); int main() { // Creates and initializes a new ArrayList. ArrayList^ myAL = gcnew ArrayList; myAL->Add( "The" ); myAL->Add( "quick" ); myAL->Add( "brown" ); myAL->Add( "fox" ); // Creates and initializes a new Queue. Queue^ myQueue = gcnew Queue; myQueue->Enqueue( "jumps" ); myQueue->Enqueue( "over" ); myQueue->Enqueue( "the" ); myQueue->Enqueue( "lazy" ); myQueue->Enqueue( "dog" ); // Displays the ArrayList and the Queue. Console::WriteLine( "The ArrayList initially contains the following:" ); PrintValues( myAL, '\t' ); Console::WriteLine( "The Queue initially contains the following:" ); PrintValues( myQueue, '\t' ); // Copies the Queue elements to the end of the ArrayList. myAL->AddRange( myQueue ); // Displays the ArrayList. Console::WriteLine( "The ArrayList now contains the following:" ); PrintValues( myAL, '\t' ); } void PrintValues( IEnumerable^ myList, char mySeparator ) { IEnumerator^ myEnum = myList->GetEnumerator(); while ( myEnum->MoveNext() ) { Object^ obj = safe_cast<Object^>(myEnum->Current); Console::Write( "{0}{1}", mySeparator, obj ); } Console::WriteLine(); } /* This code produces the following output. The ArrayList initially contains the following: The quick brown fox The Queue initially contains the following: jumps over the lazy dog The ArrayList now contains the following: The quick brown fox jumps over the lazy dog */ // </Snippet1>
[ "noreply@github.com" ]
avatarbuss.noreply@github.com
de68b5976f403f24076b29c8a1e0600a2c3411d6
5012f1a7f9d746c117f04ff56f7ebe6d5fc9128f
/1.Server/2.Midware/KFContrib/KFPlugin/KFInterface.h
b92f4397c236b859145d849755ef30b9fa3f2724
[ "Apache-2.0" ]
permissive
hw233/KFrame
c9badd576ab7c75f4e5aea2cfb3b20f6f102177f
a7e300c301225d0ba3241abcf81e871d8932f326
refs/heads/master
2023-05-11T07:50:30.349114
2019-01-25T08:20:11
2019-01-25T08:20:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
973
h
#ifndef __KF_INTERFACE_H__ #define __KF_INTERFACE_H__ #include "KFInclude.h" namespace KFrame { class KFPluginManage; class KFInterface { public: KFInterface() { _kf_plugin_manage = nullptr; } virtual ~KFInterface() {}; // 释放 virtual void Release() {}; // 初始化 virtual void InitModule() = 0; // 加载配置 virtual void LoadConfig() = 0; virtual void AfterLoad() = 0; // 开始初始化 virtual void BeforeRun() = 0; // 执行一次 virtual void OnceRun() = 0; // 关闭 virtual void BeforeShut() = 0; virtual void ShutDown() = 0; virtual void AfterShut() = 0; public: // 类名字 std::string _class_name; // 插件名字 std::string _plugin_name; // 插件管理 KFPluginManage* _kf_plugin_manage; }; } #endif
[ "lori227@qq.com" ]
lori227@qq.com
74b6d146a6408b89b685f8db465ddb3061bcf377
19194c2f2c07ab3537f994acfbf6b34ea9b55ae7
/android-33/android/text/style/TtsSpan_MoneyBuilder.hpp
cb518b40589fa155dc820850d117a0fe6d007f72
[ "GPL-3.0-only" ]
permissive
YJBeetle/QtAndroidAPI
e372609e9db0f96602da31b8417c9f5972315cae
ace3f0ea2678967393b5eb8e4edba7fa2ca6a50c
refs/heads/Qt6
2023-08-05T03:14:11.842336
2023-07-24T08:35:31
2023-07-24T08:35:31
249,539,770
19
4
Apache-2.0
2022-03-14T12:15:32
2020-03-23T20:42:54
C++
UTF-8
C++
false
false
1,813
hpp
#pragma once #include "../../../JString.hpp" #include "./TtsSpan_MoneyBuilder.def.hpp" namespace android::text::style { // Fields // Constructors inline TtsSpan_MoneyBuilder::TtsSpan_MoneyBuilder() : android::text::style::TtsSpan_SemioticClassBuilder( "android.text.style.TtsSpan$MoneyBuilder", "()V" ) {} // Methods inline android::text::style::TtsSpan_MoneyBuilder TtsSpan_MoneyBuilder::setCurrency(JString arg0) const { return callObjectMethod( "setCurrency", "(Ljava/lang/String;)Landroid/text/style/TtsSpan$MoneyBuilder;", arg0.object<jstring>() ); } inline android::text::style::TtsSpan_MoneyBuilder TtsSpan_MoneyBuilder::setFractionalPart(JString arg0) const { return callObjectMethod( "setFractionalPart", "(Ljava/lang/String;)Landroid/text/style/TtsSpan$MoneyBuilder;", arg0.object<jstring>() ); } inline android::text::style::TtsSpan_MoneyBuilder TtsSpan_MoneyBuilder::setIntegerPart(JString arg0) const { return callObjectMethod( "setIntegerPart", "(Ljava/lang/String;)Landroid/text/style/TtsSpan$MoneyBuilder;", arg0.object<jstring>() ); } inline android::text::style::TtsSpan_MoneyBuilder TtsSpan_MoneyBuilder::setIntegerPart(jlong arg0) const { return callObjectMethod( "setIntegerPart", "(J)Landroid/text/style/TtsSpan$MoneyBuilder;", arg0 ); } inline android::text::style::TtsSpan_MoneyBuilder TtsSpan_MoneyBuilder::setQuantity(JString arg0) const { return callObjectMethod( "setQuantity", "(Ljava/lang/String;)Landroid/text/style/TtsSpan$MoneyBuilder;", arg0.object<jstring>() ); } } // namespace android::text::style // Base class headers #include "./TtsSpan_Builder.hpp" #include "./TtsSpan_SemioticClassBuilder.hpp" #ifdef QT_ANDROID_API_AUTOUSE using namespace android::text::style; #endif
[ "YJBeetle@gmail.com" ]
YJBeetle@gmail.com
dcae953085f64c856b18d1055c3c99f6d4a6bb71
bcdd4c17ee83923d4696d35e00c5bf32e8794860
/src/libraries/CVK_2/CVK_ShaderMinimal.cpp
fe61e9f7643d9879593591534ae2acb443a8241f
[]
no_license
marcelpohl/EZR
fa332802e57c104fba70b08f3f16f346e86aa5bf
a84961eef2caad3771482f5bf6c988871e8e2440
refs/heads/master
2021-07-17T20:10:19.930722
2018-07-11T12:34:59
2018-07-11T12:34:59
134,305,054
0
0
null
null
null
null
UTF-8
C++
false
false
1,055
cpp
#include "CVK_ShaderMinimal.h" CVK::ShaderMinimal::ShaderMinimal( GLuint shader_mask, const char** shaderPaths) { // generate shader program GenerateShaderProgramm(shader_mask, shaderPaths); // matrices m_modelMatrixID = glGetUniformLocation(m_ProgramID, "modelMatrix"); m_viewMatrixID = glGetUniformLocation(m_ProgramID, "viewMatrix"); m_projectionMatrixID = glGetUniformLocation(m_ProgramID, "projectionMatrix"); } void CVK::ShaderMinimal::updateModelMatrix(glm::mat4 modelmatrix) const { glUniformMatrix4fv(m_modelMatrixID, 1, GL_FALSE, glm::value_ptr(modelmatrix)); } void CVK::ShaderMinimal::update() { CVK::Camera* cam = CVK::State::getInstance()->getCamera(); glm::mat4 projection, viewmatrix; if (cam != nullptr) { viewmatrix = *cam->getView(); projection = *cam->getProjection()->getProjMatrix(); } glUniformMatrix4fv(m_viewMatrixID, 1, GL_FALSE, glm::value_ptr(viewmatrix)); glUniformMatrix4fv(m_projectionMatrixID, 1, GL_FALSE, glm::value_ptr(projection)); } void CVK::ShaderMinimal::update( CVK::Node* node) { }
[ "senshi86@gmail.com" ]
senshi86@gmail.com
4020aad18c0c0ec683c070575c725d6a2ada2e4f
0dc20516079aaae4756d28e67db7cae9c0d33708
/jxy/jxy_src/jxysvr/src/dll/sdu/algorithm/sdmd5.cpp
82fb050e2dc91d5035af5e434941ea18208fa67e
[]
no_license
psymicgit/dummy
149365d586f0d4083a7a5719ad7c7268e7dc4bc3
483f2d410f353ae4c42abdfe4c606ed542186053
refs/heads/master
2020-12-24T07:48:56.132871
2017-08-05T07:20:18
2017-08-05T07:20:18
32,851,013
3
8
null
null
null
null
UTF-8
C++
false
false
12,527
cpp
#include "sdmd5.h" #include "sdfile.h" #include "sdfilemapping.h" #include "sdstring.h" namespace SGDP { #define S11 7 #define S12 12 #define S13 17 #define S14 22 #define S21 5 #define S22 9 #define S23 14 #define S24 20 #define S31 4 #define S32 11 #define S33 16 #define S34 23 #define S41 6 #define S42 10 #define S43 15 #define S44 21 const static int ChunkSize = 4096; static VOID MD5Transform(UINT32 [4], UCHAR [64]); static VOID Encode(UCHAR *, UINT32 *, unsigned int); static VOID Decode(UINT32 *, UCHAR *, unsigned int); static VOID MD5_memcpy(UINT8*, UINT8*, unsigned int); static VOID MD5_memset(UINT8*, int, unsigned int); static UCHAR PADDING[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* F, G, H and I are basic MD5 functions. */ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | (~z))) /* ROTATE_LEFT rotates x left n bits. */ #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. Rotation is separate from addition to prevent recomputation. */ #define FF(a, b, c, d, x, s, ac) { \ (a) += F ((b), (c), (d)) + (x) + (UINT32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) { \ (a) += G ((b), (c), (d)) + (x) + (UINT32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) { \ (a) += H ((b), (c), (d)) + (x) + (UINT32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) { \ (a) += I ((b), (c), (d)) + (x) + (UINT32)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } /* MD5 initialization. Begins an MD5 operation, writing a SDNew context. */ VOID SDMD5Init(SMD5Context *context) /* context */ { context->count[0] = context->count[1] = 0; /* Load magic initialization constants. */ context->state[0] = 0x67452301; context->state[1] = 0xefcdab89; context->state[2] = 0x98badcfe; context->state[3] = 0x10325476; } /* MD5 block update operation. Continues an MD5 message-digest operation, processing another message block, and updating the context. */ VOID SDMD5Update(SMD5Context *context, /* context */ UCHAR *input, /* input block */ unsigned int inputLen) /* length of input block */ { unsigned int i, index, partLen; /* Compute number of bytes mod 64 */ index = (unsigned int)((context->count[0] >> 3) & 0x3F); /* Update number of bits */ if ((context->count[0] += ((UINT32)inputLen << 3)) < ((UINT32)inputLen << 3)) context->count[1]++; context->count[1] += ((UINT32)inputLen >> 29); partLen = 64 - index; /* Transform as many times as possible. */ if (inputLen >= partLen) { MD5_memcpy ((UINT8*)&context->buffer[index], (UINT8*)input, partLen); MD5Transform (context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) MD5Transform (context->state, &input[i]); index = 0; } else i = 0; /* Buffer remaining input */ MD5_memcpy((UINT8*)&context->buffer[index], (UINT8*)&input[i], inputLen-i); } /* MD5 finalization. Ends an MD5 message-digest operation, writing the the message digest and zeroizing the context. */ VOID SDMD5Final (UCHAR digest[16], /* message digest */ SMD5Context *context) /* context */ { UCHAR bits[8]; unsigned int index, padLen; /* Save number of bits */ Encode (bits, context->count, 8); /* Pad out to 56 mod 64. */ index = (unsigned int)((context->count[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); SDMD5Update (context, PADDING, padLen); /* Append length (before padding) */ SDMD5Update (context, bits, 8); /* Store state in digest */ Encode (digest, context->state, 16); /* Zeroize sensitive information. */ MD5_memset ((UINT8*)context, 0, sizeof (*context)); } /* MD5 basic transformation. Transforms state based on block. */ static VOID MD5Transform(UINT32 state[4],UCHAR block[64]) { UINT32 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; Decode (x, block, 64); /* Round 1 */ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ /* Round 2 */ GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ /* Round 3 */ HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ /* Round 4 */ II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ state[0] += a; state[1] += b; state[2] += c; state[3] += d; /* Zeroize sensitive information. */ MD5_memset((UINT8*)x, 0, sizeof (x)); } /* Encodes input (UINT32) into output (UCHAR). Assumes len is a multiple of 4. */ static VOID Encode (UCHAR *output,UINT32 *input,unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) { output[j] = (UCHAR)(input[i] & 0xff); output[j+1] = (UCHAR)((input[i] >> 8) & 0xff); output[j+2] = (UCHAR)((input[i] >> 16) & 0xff); output[j+3] = (UCHAR)((input[i] >> 24) & 0xff); } } /* Decodes input (UCHAR) into output (UINT32). Assumes len is a multiple of 4. */ static VOID Decode(UINT32 *output, UCHAR *input, unsigned int len) { unsigned int i, j; for (i = 0, j = 0; j < len; i++, j += 4) { output[i] = ((UINT32)input[j]) | (((UINT32)input[j+1]) << 8) | (((UINT32)input[j+2]) << 16) | (((UINT32)input[j+3]) << 24); } } /* Note: Replace "for loop" with standard memcpy if possible. */ static VOID MD5_memcpy(UINT8* output, UINT8* input, unsigned int len) { unsigned int i; for (i = 0; i < len; i++) { output[i] = input[i]; } } /* Note: Replace "for loop" with standard memset if possible. */ static VOID MD5_memset(UINT8* output, int value, unsigned int len) { unsigned int i; for (i = 0; i < len; i++) { ((char *)output)[i] = (char)value; } } VOID SDMD5(UCHAR acDigest[16], UCHAR* pInput, UINT32 dwInLen) { SMD5Context mCtx; SDMD5Init(&mCtx); ULONG lastPos = 0; while(lastPos < dwInLen) { if(dwInLen - lastPos < ChunkSize) { SDMD5Update(&mCtx, pInput + lastPos, dwInLen - lastPos); lastPos = dwInLen; } else { SDMD5Update(&mCtx, pInput + lastPos, ChunkSize); lastPos += ChunkSize; } } SDMD5Final(acDigest, &mCtx); } BOOL SDFileMD5(UCHAR acDigest[16], const TCHAR* pszFileName, BOOL bFileMapping) { if (bFileMapping) { SFileMapping fileMap; if(!SDFileMapping(fileMap, pszFileName)) { return FALSE; } SMD5Context mCtx; SDMD5Init(&mCtx); ULONG lastPos = 0; while(lastPos < fileMap.size) { if(fileMap.size - lastPos < ChunkSize) { SDMD5Update(&mCtx, ((UCHAR*)fileMap.mem) + lastPos, fileMap.size - lastPos); lastPos = fileMap.size; } else { SDMD5Update(&mCtx, ((UCHAR*)fileMap.mem) + lastPos, ChunkSize); lastPos += ChunkSize; } } SDMD5Final(acDigest, &mCtx); SDFileUnMapping(fileMap); return TRUE; } else { if (!SDFileExists(pszFileName)) { return FALSE; } CSDFile file; #ifdef UNICODE file.Open((pszFileName), _SDT("rb")); #else file.Open(pszFileName, "rb"); #endif SMD5Context mCtx; SDMD5Init(&mCtx); UCHAR buf[ChunkSize]; while(!file.Eof()) { UINT32 size = file.Read(buf, sizeof(buf)); SDMD5Update(&mCtx, buf, size); } SDMD5Final(acDigest, &mCtx); file.Close(); return TRUE; } } }
[ "wuzili1234@gmail.com" ]
wuzili1234@gmail.com
e798cb21eee4cac59f058fdaf83824bd00147cb1
cd33de81cbe9f94e9f32bd46f184cdd4ce8b81a1
/DecathectEngine/src/dcthctpch.h
3ad27d251f85e1515d2ae733fc939c3b854a39f2
[ "Apache-2.0" ]
permissive
jharvs97/DecathectEngine
713133c66b66bb95845a15c09b632c43516c34f2
b6e6e840843d0de5ebd8a38194a01e53fdd19e03
refs/heads/master
2022-03-31T14:25:30.663747
2019-11-21T03:07:30
2019-11-21T03:07:30
219,495,084
0
0
null
null
null
null
UTF-8
C++
false
false
280
h
#pragma once #include <iostream> #include <memory> #include <utility> #include <algorithm> #include <functional> #include <sstream> #include <string> #include <vector> #include <unordered_map> #include <unordered_set> #ifdef DCTHCT_PLATFORM WINDOWS #include <Windows.h> #endif
[ "34911082+jharvs97@users.noreply.github.com" ]
34911082+jharvs97@users.noreply.github.com
270c34e612ea2e42d3ab0e88d535f43fc0675810
d1cee40adee73afdbce5b3582bbe4761b595c4e1
/back/RtmpLivePushSDK/boost/boost/mpl/bool_fwd.hpp
79e918103e7bad709afead8741d5a7d58977ce38
[ "BSL-1.0" ]
permissive
RickyJun/live_plugin
de6fb4fa8ef9f76fffd51e2e51262fb63cea44cb
e4472570eac0d9f388ccac6ee513935488d9577e
refs/heads/master
2023-05-08T01:49:52.951207
2021-05-30T14:09:38
2021-05-30T14:09:38
345,919,594
2
0
null
null
null
null
UTF-8
C++
false
false
858
hpp
#ifndef BOOST_MPL_BOOL_FWD_HPP_INCLUDED #define BOOST_MPL_BOOL_FWD_HPP_INCLUDED // Copyright Aleksey Gurtovoy 2000-2004 // // 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) // // See http://www.boost.org/libs/mpl for documentation. // $Id: bool_fwd.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ // $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $ // $Revision: 49267 $ #include "adl_barrier.hpp" BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_OPEN template< bool C_ > struct bool_; // shorcuts typedef bool_<true> true_; typedef bool_<false> false_; BOOST_MPL_AUX_ADL_BARRIER_NAMESPACE_CLOSE BOOST_MPL_AUX_ADL_BARRIER_DECL(bool_) BOOST_MPL_AUX_ADL_BARRIER_DECL(true_) BOOST_MPL_AUX_ADL_BARRIER_DECL(false_) #endif // BOOST_MPL_BOOL_FWD_HPP_INCLUDED
[ "wenwenjun@weeget.cn" ]
wenwenjun@weeget.cn
64b0960ad5cea0ad7b9876ae634a3c2daf7b9ceb
2c62385f15b1f8e6072138d5175d7a70dd236b98
/blazetest/src/mathtest/hybridmatrix/ClassTest.cpp
175fee35beef88f5ce6ea7f8976784cfa6d7ef40
[ "BSD-3-Clause" ]
permissive
lyxm/blaze
665e4c6f6e1a717973d2d98e148c720030843266
10dbaa368790316b5e044cfe9b92f5534f60a2dc
refs/heads/master
2021-01-12T20:31:45.197297
2015-10-15T21:39:17
2015-10-15T21:39:17
null
0
0
null
null
null
null
UTF-8
C++
false
false
235,735
cpp
//================================================================================================= /*! // \file src/mathtest/hybridmatrix/ClassTest.cpp // \brief Source file for the HybridMatrix class test // // Copyright (C) 2013 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. 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. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/CompressedMatrix.h> #include <blaze/math/DiagonalMatrix.h> #include <blaze/math/DynamicMatrix.h> #include <blaze/math/LowerMatrix.h> #include <blaze/math/UpperMatrix.h> #include <blaze/util/Complex.h> #include <blaze/util/Random.h> #include <blaze/util/UniqueArray.h> #include <blazetest/mathtest/hybridmatrix/ClassTest.h> #include <blazetest/mathtest/RandomMaximum.h> #include <blazetest/mathtest/RandomMinimum.h> namespace blazetest { namespace mathtest { namespace hybridmatrix { //================================================================================================= // // CONSTRUCTORS // //================================================================================================= //************************************************************************************************* /*!\brief Constructor for the HybridMatrix class test. // // \exception std::runtime_error Operation error detected. */ ClassTest::ClassTest() { testAlignment< char >( "char" ); testAlignment< signed char >( "signed char" ); testAlignment< unsigned char >( "unsigned char" ); testAlignment< wchar_t >( "wchar_t" ); testAlignment< short >( "short" ); testAlignment< unsigned short >( "unsigned short" ); testAlignment< int >( "int" ); testAlignment< unsigned int >( "unsigned int" ); testAlignment< long >( "long" ); testAlignment< unsigned long >( "unsigned long" ); testAlignment< float >( "float" ); testAlignment< double >( "double" ); testAlignment< complex<char> >( "complex<char>" ); testAlignment< complex<signed char> >( "complex<signed char>" ); testAlignment< complex<unsigned char> >( "complex<unsigned char>" ); testAlignment< complex<wchar_t> >( "complex<wchar_t>" ); testAlignment< complex<short> >( "complex<short>" ); testAlignment< complex<unsigned short> >( "complex<unsigned short>" ); testAlignment< complex<int> >( "complex<int>" ); testAlignment< complex<unsigned int> >( "complex<unsigned int>" ); testAlignment< complex<float> >( "complex<float>" ); testAlignment< complex<double> >( "complex<double>" ); testConstructors(); testAssignment(); testAddAssign(); testSubAssign(); testMultAssign(); testScaling(); testFunctionCall(); testIterator(); testNonZeros(); testReset(); testClear(); testResize(); testExtend(); testTranspose(); testSwap(); testIsDefault(); } //************************************************************************************************* //================================================================================================= // // TEST FUNCTIONS // //================================================================================================= //************************************************************************************************* /*!\brief Test of the HybridMatrix constructors. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of all constructors of the HybridMatrix class template. // In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testConstructors() { //===================================================================================== // Row-major default constructor //===================================================================================== // Default constructor { test_ = "Row-major HybridMatrix default constructor"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat; checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } //===================================================================================== // Row-major size constructor //===================================================================================== { test_ = "Row-major HybridMatrix size constructor (0x0)"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat( 0UL, 0UL ); checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } { test_ = "Row-major HybridMatrix size constructor (0x4)"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat( 0UL, 4UL ); checkRows ( mat, 0UL ); checkColumns ( mat, 4UL ); checkNonZeros( mat, 0UL ); } { test_ = "Row-major HybridMatrix size constructor (3x0)"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat( 3UL, 0UL ); checkRows ( mat, 3UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } { test_ = "Row-major HybridMatrix size constructor (3x4)"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat( 3UL, 4UL ); checkRows ( mat, 3UL ); checkColumns ( mat, 4UL ); checkCapacity( mat, 12UL ); } //===================================================================================== // Row-major homogeneous initialization //===================================================================================== { test_ = "Row-major HybridMatrix homogeneous initialization constructor (0x0)"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat( 0UL, 0UL, 2 ); checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } { test_ = "Row-major HybridMatrix homogeneous initialization constructor (0x4)"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat( 0UL, 4UL, 2 ); checkRows ( mat, 0UL ); checkColumns ( mat, 4UL ); checkNonZeros( mat, 0UL ); } { test_ = "Row-major HybridMatrix homogeneous initialization constructor (3x0)"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat( 3UL, 0UL, 2 ); checkRows ( mat, 3UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } { test_ = "Row-major HybridMatrix homogeneous initialization constructor (3x4)"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat( 3UL, 4UL, 2 ); checkRows ( mat, 3UL ); checkColumns ( mat, 4UL ); checkCapacity( mat, 12UL ); checkNonZeros( mat, 12UL ); checkNonZeros( mat, 0UL, 4UL ); checkNonZeros( mat, 1UL, 4UL ); checkNonZeros( mat, 2UL, 4UL ); if( mat(0,0) != 2 || mat(0,1) != 2 || mat(0,2) != 2 || mat(0,3) != 2 || mat(1,0) != 2 || mat(1,1) != 2 || mat(1,2) != 2 || mat(1,3) != 2 || mat(2,0) != 2 || mat(2,1) != 2 || mat(2,2) != 2 || mat(2,3) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Construction failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 2 2 2 2 )\n( 2 2 2 2 )\n( 2 2 2 2 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major array initialization //===================================================================================== { test_ = "Row-major HybridMatrix dynamic array initialization constructor"; blaze::UniqueArray<int> array( new int[6] ); array[0] = 1; array[1] = 2; array[2] = 3; array[3] = 4; array[4] = 5; array[5] = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat( 2UL, 3UL, array.get() ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 3 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Construction failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major HybridMatrix static array initialization constructor"; const int array[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat( array ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 3 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Construction failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major copy constructor //===================================================================================== { test_ = "Row-major HybridMatrix copy constructor (0x0)"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 0UL, 0UL ); blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( mat1 ); checkRows ( mat2, 0UL ); checkColumns ( mat2, 0UL ); checkNonZeros( mat2, 0UL ); } { test_ = "Row-major HybridMatrix copy constructor (0x3)"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 0UL, 3UL ); blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( mat1 ); checkRows ( mat2, 0UL ); checkColumns ( mat2, 3UL ); checkNonZeros( mat2, 0UL ); } { test_ = "Row-major HybridMatrix copy constructor (2x0)"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 2UL, 0UL ); blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( mat1 ); checkRows ( mat2, 2UL ); checkColumns ( mat2, 0UL ); checkNonZeros( mat2, 0UL ); } { test_ = "Row-major HybridMatrix copy constructor (2x3)"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(0,2) = 3; mat1(1,0) = 4; mat1(1,1) = 5; mat1(1,2) = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( mat1 ); checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 6UL ); checkNonZeros( mat2, 0UL, 3UL ); checkNonZeros( mat2, 1UL, 3UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 3 || mat2(1,0) != 4 || mat2(1,1) != 5 || mat2(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Construction failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major default constructor //===================================================================================== { test_ = "Column-major HybridMatrix default constructor"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat; checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } //===================================================================================== // Column-major size constructor //===================================================================================== { test_ = "Column-major HybridMatrix size constructor (0x0)"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat( 0UL, 0UL ); checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } { test_ = "Column-major HybridMatrix size constructor (0x4)"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat( 0UL, 4UL ); checkRows ( mat, 0UL ); checkColumns ( mat, 4UL ); checkNonZeros( mat, 0UL ); } { test_ = "Column-major HybridMatrix size constructor (3x0)"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat( 3UL, 0UL ); checkRows ( mat, 3UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } { test_ = "Column-major HybridMatrix size constructor (3x4)"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat( 3UL, 4UL ); checkRows ( mat, 3UL ); checkColumns ( mat, 4UL ); checkCapacity( mat, 12UL ); } //===================================================================================== // Column-major homogeneous initialization //===================================================================================== { test_ = "Column-major HybridMatrix homogeneous initialization constructor (0x0)"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat( 0UL, 0UL, 2 ); checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } { test_ = "Column-major HybridMatrix homogeneous initialization constructor (0x4)"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat( 0UL, 4UL, 2 ); checkRows ( mat, 0UL ); checkColumns ( mat, 4UL ); checkNonZeros( mat, 0UL ); } { test_ = "Column-major HybridMatrix homogeneous initialization constructor (3x0)"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat( 3UL, 0UL, 2 ); checkRows ( mat, 3UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } { test_ = "Column-major HybridMatrix homogeneous initialization constructor (3x4)"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat( 3UL, 4UL, 2 ); checkRows ( mat, 3UL ); checkColumns ( mat, 4UL ); checkCapacity( mat, 12UL ); checkNonZeros( mat, 12UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); checkNonZeros( mat, 2UL, 3UL ); checkNonZeros( mat, 3UL, 3UL ); if( mat(0,0) != 2 || mat(0,1) != 2 || mat(0,2) != 2 || mat(0,3) != 2 || mat(1,0) != 2 || mat(1,1) != 2 || mat(1,2) != 2 || mat(1,3) != 2 || mat(2,0) != 2 || mat(2,1) != 2 || mat(2,2) != 2 || mat(2,3) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Construction failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 2 2 2 2 )\n( 2 2 2 2 )\n( 2 2 2 2 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major array initialization //===================================================================================== { test_ = "Column-major HybridMatrix dynamic array initialization constructor"; blaze::UniqueArray<int> array( new int[6] ); array[0] = 1; array[1] = 2; array[2] = 3; array[3] = 4; array[4] = 5; array[5] = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat( 2UL, 3UL, array.get() ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 3 || mat(0,2) != 5 || mat(1,0) != 2 || mat(1,1) != 4 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Construction failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 3 5 )\n( 2 4 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major HybridMatrix static array initialization constructor"; const int array[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat( array ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 3 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Construction failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major copy constructor //===================================================================================== { test_ = "Column-major HybridMatrix copy constructor (0x0)"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 0UL, 0UL ); blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( mat1 ); checkRows ( mat2, 0UL ); checkColumns ( mat2, 0UL ); checkNonZeros( mat2, 0UL ); } { test_ = "Column-major HybridMatrix copy constructor (0x3)"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 0UL, 3UL ); blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( mat1 ); checkRows ( mat2, 0UL ); checkColumns ( mat2, 3UL ); checkNonZeros( mat2, 0UL ); } { test_ = "Column-major HybridMatrix copy constructor (2x0)"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 2UL, 0UL ); blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( mat1 ); checkRows ( mat2, 2UL ); checkColumns ( mat2, 0UL ); checkNonZeros( mat2, 0UL ); } { test_ = "Column-major HybridMatrix copy constructor (2x3)"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(0,2) = 3; mat1(1,0) = 4; mat1(1,1) = 5; mat1(1,2) = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( mat1 ); checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 6UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 3 || mat2(1,0) != 4 || mat2(1,1) != 5 || mat2(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Construction failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the HybridMatrix assignment operators. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of all assignment operators of the HybridMatrix class template. // In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testAssignment() { //===================================================================================== // Row-major homogeneous assignment //===================================================================================== { test_ = "Row-major HybridMatrix homogeneous assignment"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat( 3UL, 4UL ); mat = 2; checkRows ( mat, 3UL ); checkColumns ( mat, 4UL ); checkCapacity( mat, 12UL ); checkNonZeros( mat, 12UL ); checkNonZeros( mat, 0UL, 4UL ); checkNonZeros( mat, 1UL, 4UL ); checkNonZeros( mat, 2UL, 4UL ); if( mat(0,0) != 2 || mat(0,1) != 2 || mat(0,2) != 2 || mat(0,3) != 2 || mat(1,0) != 2 || mat(1,1) != 2 || mat(1,2) != 2 || mat(1,3) != 2 || mat(2,0) != 2 || mat(2,1) != 2 || mat(2,2) != 2 || mat(2,3) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 2 2 2 2 )\n( 2 2 2 2 )\n( 2 2 2 2 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major array assignment //===================================================================================== { test_ = "Row-major HybridMatrix array assignment"; const int array[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat; mat = array; checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 3 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major copy assignment //===================================================================================== { test_ = "Row-major HybridMatrix copy assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(0,2) = 3; mat1(1,0) = 4; mat1(1,1) = 5; mat1(1,2) = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 6UL ); checkNonZeros( mat2, 0UL, 3UL ); checkNonZeros( mat2, 1UL, 3UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 3 || mat2(1,0) != 4 || mat2(1,1) != 5 || mat2(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major HybridMatrix copy assignment stress test"; typedef blaze::HybridMatrix<int,10UL,10UL,blaze::rowMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::rowMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } //===================================================================================== // Row-major dense matrix assignment //===================================================================================== { test_ = "Row-major/row-major HybridMatrix dense matrix assignment"; blaze::DynamicMatrix<int,blaze::rowMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(0,2) = 3; mat1(1,0) = 4; mat1(1,1) = 5; mat1(1,2) = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 6UL ); checkNonZeros( mat2, 0UL, 3UL ); checkNonZeros( mat2, 1UL, 3UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 3 || mat2(1,0) != 4 || mat2(1,1) != 5 || mat2(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix dense matrix assignment stress test"; typedef blaze::DynamicMatrix<int,blaze::rowMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::rowMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Row-major/column-major HybridMatrix dense matrix assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(0,2) = 3; mat1(1,0) = 4; mat1(1,1) = 5; mat1(1,2) = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 6UL ); checkNonZeros( mat2, 0UL, 3UL ); checkNonZeros( mat2, 1UL, 3UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 3 || mat2(1,0) != 4 || mat2(1,1) != 5 || mat2(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix assignment stress test"; typedef blaze::DynamicMatrix<int,blaze::columnMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::rowMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Row-major/row-major HybridMatrix dense matrix assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix dense matrix assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix dense matrix assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major sparse matrix assignment //===================================================================================== { test_ = "Row-major/row-major HybridMatrix sparse matrix assignment"; blaze::CompressedMatrix<int,blaze::rowMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = 3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(1,0) != 3 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 0 )\n( 3 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix sparse matrix assignment stress test"; typedef blaze::CompressedMatrix<int,blaze::rowMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::rowMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Row-major/column-major HybridMatrix sparse matrix assignment"; blaze::CompressedMatrix<int,blaze::columnMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = 3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(1,0) != 3 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 0 )\n( 3 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix assignment stress test"; typedef blaze::CompressedMatrix<int,blaze::columnMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::rowMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Row-major/row-major HybridMatrix sparse matrix assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix sparse matrix assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix sparse matrix assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major homogeneous assignment //===================================================================================== { test_ = "Column-major HybridMatrix homogeneous assigment"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat( 3UL, 4UL ); mat = 2; checkRows ( mat, 3UL ); checkColumns ( mat, 4UL ); checkCapacity( mat, 12UL ); checkNonZeros( mat, 12UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); checkNonZeros( mat, 2UL, 3UL ); checkNonZeros( mat, 3UL, 3UL ); if( mat(0,0) != 2 || mat(0,1) != 2 || mat(0,2) != 2 || mat(0,3) != 2 || mat(1,0) != 2 || mat(1,1) != 2 || mat(1,2) != 2 || mat(1,3) != 2 || mat(2,0) != 2 || mat(2,1) != 2 || mat(2,2) != 2 || mat(2,3) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 2 2 2 2 )\n( 2 2 2 2 )\n( 2 2 2 2 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major array assignment //===================================================================================== { test_ = "Column-major HybridMatrix array initialization constructor"; const int array[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } }; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat; mat = array; checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 3 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major copy assignment //===================================================================================== { test_ = "Column-major HybridMatrix copy assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(0,2) = 3; mat1(1,0) = 4; mat1(1,1) = 5; mat1(1,2) = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 6UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 3 || mat2(1,0) != 4 || mat2(1,1) != 5 || mat2(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major HybridMatrix copy assignment stress test"; typedef blaze::HybridMatrix<int,10UL,10UL,blaze::columnMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::columnMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } //===================================================================================== // Column-major dense matrix assignment //===================================================================================== { test_ = "Column-major/row-major HybridMatrix dense matrix assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(0,2) = 3; mat1(1,0) = 4; mat1(1,1) = 5; mat1(1,2) = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 6UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 3 || mat2(1,0) != 4 || mat2(1,1) != 5 || mat2(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix dense matrix assignment stress test"; typedef blaze::DynamicMatrix<int,blaze::rowMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::columnMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Column-major/column-major HybridMatrix dense matrix assignment"; blaze::DynamicMatrix<int,blaze::columnMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(0,2) = 3; mat1(1,0) = 4; mat1(1,1) = 5; mat1(1,2) = 6; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 6UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 3 || mat2(1,0) != 4 || mat2(1,1) != 5 || mat2(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix assignment stress test"; typedef blaze::DynamicMatrix<int,blaze::columnMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::columnMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Column-major/row-major HybridMatrix dense matrix assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix dense matrix assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix dense matrix assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major sparse matrix assignment //===================================================================================== { test_ = "Column-major/row-major HybridMatrix sparse matrix assignment"; blaze::CompressedMatrix<int,blaze::rowMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = 3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 1UL ); checkNonZeros( mat2, 2UL, 1UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(1,0) != 3 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 0 )\n( 3 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix sparse matrix assignment stress test"; typedef blaze::CompressedMatrix<int,blaze::rowMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::columnMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Column-major/column-major HybridMatrix sparse matrix assignment"; blaze::CompressedMatrix<int,blaze::columnMajor> mat1( 2UL, 3UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = 3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2; mat2 = mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 1UL ); checkNonZeros( mat2, 2UL, 1UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(1,0) != 3 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 0 )\n( 3 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix assignment stress test"; typedef blaze::CompressedMatrix<int,blaze::columnMajor> RandomMatrixType; blaze::HybridMatrix<int,10UL,10UL,blaze::columnMajor> mat1; const int min( randmin ); const int max( randmax ); for( size_t i=0UL; i<100UL; ++i ) { const size_t rows ( blaze::rand<size_t>( 0UL, 10UL ) ); const size_t columns( blaze::rand<size_t>( 0UL, 10UL ) ); const RandomMatrixType mat2( blaze::rand<RandomMatrixType>( rows, columns, min, max ) ); mat1 = mat2; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Column-major/row-major HybridMatrix sparse matrix assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix sparse matrix assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix sparse matrix assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL ); randomize( mat2 ); mat2 = mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the HybridMatrix addition assignment operators. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the addition assignment operators of the HybridMatrix class // template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testAddAssign() { //===================================================================================== // Row-major dense matrix addition assignment //===================================================================================== { test_ = "Row-major/row-major HybridMatrix dense matrix addition assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 2UL, 3UL, 0 ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix addition assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 2UL, 3UL, 0 ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix dense matrix addition assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix addition assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix dense matrix addition assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix addition assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix dense matrix addition assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix addition assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major sparse matrix addition assignment //===================================================================================== { test_ = "Row-major/row-major HybridMatrix sparse matrix addition assignment"; blaze::CompressedMatrix<int,blaze::rowMajor> mat1( 2UL, 3UL, 4UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix addition assignment"; blaze::CompressedMatrix<int,blaze::columnMajor> mat1( 2UL, 3UL, 4UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix sparse matrix addition assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix addition assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix sparse matrix addition assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix addition assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix sparse matrix addition assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix addition assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major dense matrix addition assignment //===================================================================================== { test_ = "Column-major/row-major HybridMatrix dense matrix addition assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 2UL, 3UL, 0 ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 0UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix addition assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 2UL, 3UL, 0 ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 0UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix dense matrix addition assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix addition assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix dense matrix addition assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix addition assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix dense matrix addition assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix addition assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major sparse matrix addition assignment //===================================================================================== { test_ = "Column-major/row-major HybridMatrix sparse matrix addition assignment"; blaze::CompressedMatrix<int,blaze::rowMajor> mat1( 2UL, 3UL, 4UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 0UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix addition assignment"; blaze::CompressedMatrix<int,blaze::columnMajor> mat1( 2UL, 3UL, 4UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 0UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix sparse matrix addition assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix addition assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix sparse matrix addition assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix addition assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix sparse matrix addition assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix addition assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 += mat1; if( mat1 != mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the HybridMatrix subtraction assignment operators. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the subtraction assignment operators of the HybridMatrix // class template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testSubAssign() { //===================================================================================== // Row-major dense matrix subtraction assignment //===================================================================================== { test_ = "Row-major/row-major HybridMatrix dense matrix subtraction assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 2UL, 3UL, 0 ); mat1(0,0) = -1; mat1(0,1) = -2; mat1(1,0) = 3; mat1(1,2) = -4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 -= mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix subtraction assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 2UL, 3UL, 0 ); mat1(0,0) = -1; mat1(0,1) = -2; mat1(1,0) = 3; mat1(1,2) = -4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 -= mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix dense matrix subtraction assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix subtraction assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix dense matrix subtraction assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix subtraction assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix dense matrix subtraction assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix subtraction assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major sparse matrix subtraction assignment //===================================================================================== { test_ = "Row-major/row-major HybridMatrix sparse matrix subtraction assignment"; blaze::CompressedMatrix<int,blaze::rowMajor> mat1( 2UL, 3UL, 4UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix subtraction assignment"; blaze::CompressedMatrix<int,blaze::columnMajor> mat1( 2UL, 3UL, 4UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = -3; mat1(1,2) = 4; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 += mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix sparse matrix subtraction assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix subtraction assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix sparse matrix subtraction assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix subtraction assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/row-major HybridMatrix sparse matrix subtraction assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix subtraction assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major dense matrix subtraction assignment //===================================================================================== { test_ = "Column-major/row-major HybridMatrix dense matrix subtraction assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat1( 2UL, 3UL, 0 ); mat1(0,0) = -1; mat1(0,1) = -2; mat1(1,0) = 3; mat1(1,2) = -4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 -= mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 0UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix subtraction assignment"; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat1( 2UL, 3UL, 0 ); mat1(0,0) = -1; mat1(0,1) = -2; mat1(1,0) = 3; mat1(1,2) = -4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 -= mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 0UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix dense matrix subtraction assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix subtraction assignment (lower)"; blaze::LowerMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix dense matrix subtraction assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix subtraction assignment (upper)"; blaze::UpperMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix dense matrix subtraction assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix dense matrix subtraction assignment (diagonal)"; blaze::DiagonalMatrix< blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major sparse matrix subtraction assignment //===================================================================================== { test_ = "Column-major/row-major HybridMatrix sparse matrix subtraction assignment"; blaze::CompressedMatrix<int,blaze::rowMajor> mat1( 2UL, 3UL, 4UL ); mat1(0,0) = -1; mat1(0,1) = -2; mat1(1,0) = 3; mat1(1,2) = -4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 -= mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 0UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix subtraction assignment"; blaze::CompressedMatrix<int,blaze::columnMajor> mat1( 2UL, 3UL, 4UL ); mat1(0,0) = -1; mat1(0,1) = -2; mat1(1,0) = 3; mat1(1,2) = -4; blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat2( 2UL, 3UL, 0 ); mat2(0,1) = -2; mat2(0,2) = 6; mat2(1,0) = 5; mat2 -= mat1; checkRows ( mat2, 2UL ); checkColumns ( mat2, 3UL ); checkCapacity( mat2, 6UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 0UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 0 || mat2(0,2) != 6 || mat2(1,0) != 2 || mat2(1,1) != 0 || mat2(1,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 0 6 )\n( 2 0 4 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix sparse matrix subtraction assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix subtraction assignment (lower)"; blaze::LowerMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix sparse matrix subtraction assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix subtraction assignment (upper)"; blaze::UpperMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/row-major HybridMatrix sparse matrix subtraction assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::rowMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major/column-major HybridMatrix sparse matrix subtraction assignment (diagonal)"; blaze::DiagonalMatrix< blaze::CompressedMatrix<int,blaze::columnMajor> > mat1( 3UL ); randomize( mat1 ); blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2 -= mat1; if( mat1 != -mat2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n" << mat2 << "\n"; throw std::runtime_error( oss.str() ); } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the HybridMatrix multiplication assignment operators. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the multiplication assignment operators of the HybridMatrix // class template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testMultAssign() { //===================================================================================== // Row-major dense matrix multiplication assignment //===================================================================================== { test_ = "Row-major/row-major HybridMatrix dense matrix multiplication assignment"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat1( 3UL, 4UL, 0 ); mat1(0,1) = 2; mat1(1,0) = 1; mat1(1,1) = 3; mat1(1,3) = 4; mat1(2,3) = 5; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2(0,0) = 1; mat2(0,2) = 2; mat2(1,1) = 3; mat2(2,0) = 4; mat2(2,2) = 5; mat2 *= mat1; checkRows ( mat2, 3UL ); checkColumns ( mat2, 4UL ); checkNonZeros( mat2, 7UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 3UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 0 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(0,3) != 10 || mat2(1,0) != 3 || mat2(1,1) != 9 || mat2(1,2) != 0 || mat2(1,3) != 12 || mat2(2,0) != 0 || mat2(2,1) != 8 || mat2(2,2) != 0 || mat2(2,3) != 25 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 0 2 0 10 )\n( 3 9 0 12 )\n( 0 8 0 25 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix multiplication assignment"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat1( 3UL, 4UL, 0 ); mat1(0,1) = 2; mat1(1,0) = 1; mat1(1,1) = 3; mat1(1,3) = 4; mat1(2,3) = 5; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2(0,0) = 1; mat2(0,2) = 2; mat2(1,1) = 3; mat2(2,0) = 4; mat2(2,2) = 5; mat2 *= mat1; checkRows ( mat2, 3UL ); checkColumns ( mat2, 4UL ); checkNonZeros( mat2, 7UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 3UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 0 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(0,3) != 10 || mat2(1,0) != 3 || mat2(1,1) != 9 || mat2(1,2) != 0 || mat2(1,3) != 12 || mat2(2,0) != 0 || mat2(2,1) != 8 || mat2(2,2) != 0 || mat2(2,3) != 25 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 0 2 0 10 )\n( 3 9 0 12 )\n( 0 8 0 25 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major sparse matrix multiplication assignment //===================================================================================== { test_ = "Row-major/row-major HybridMatrix sparse matrix multiplication assignment"; blaze::CompressedMatrix<int,blaze::rowMajor> mat1( 3UL, 4UL, 5UL ); mat1(0,1) = 2; mat1(1,0) = 1; mat1(1,1) = 3; mat1(1,3) = 4; mat1(2,3) = 5; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2(0,0) = 1; mat2(0,2) = 2; mat2(1,1) = 3; mat2(2,0) = 4; mat2(2,2) = 5; mat2 *= mat1; checkRows ( mat2, 3UL ); checkColumns ( mat2, 4UL ); checkNonZeros( mat2, 7UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 3UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 0 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(0,3) != 10 || mat2(1,0) != 3 || mat2(1,1) != 9 || mat2(1,2) != 0 || mat2(1,3) != 12 || mat2(2,0) != 0 || mat2(2,1) != 8 || mat2(2,2) != 0 || mat2(2,3) != 25 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 0 2 0 10 )\n( 3 9 0 12 )\n( 0 8 0 25 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix multiplication assignment"; blaze::CompressedMatrix<int,blaze::columnMajor> mat1( 3UL, 4UL, 5UL ); mat1(0,1) = 2; mat1(1,0) = 1; mat1(1,1) = 3; mat1(1,3) = 4; mat1(2,3) = 5; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat2( 3UL, 3UL, 0 ); mat2(0,0) = 1; mat2(0,2) = 2; mat2(1,1) = 3; mat2(2,0) = 4; mat2(2,2) = 5; mat2 *= mat1; checkRows ( mat2, 3UL ); checkColumns ( mat2, 4UL ); checkNonZeros( mat2, 7UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 3UL ); checkNonZeros( mat2, 2UL, 2UL ); if( mat2(0,0) != 0 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(0,3) != 10 || mat2(1,0) != 3 || mat2(1,1) != 9 || mat2(1,2) != 0 || mat2(1,3) != 12 || mat2(2,0) != 0 || mat2(2,1) != 8 || mat2(2,2) != 0 || mat2(2,3) != 25 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 0 2 0 10 )\n( 3 9 0 12 )\n( 0 8 0 25 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major dense matrix multiplication assignment //===================================================================================== { test_ = "Column-major/row-major HybridMatrix dense matrix multiplication assignment"; blaze::HybridMatrix<int,3UL,4UL,blaze::rowMajor> mat1( 3UL, 4UL, 0 ); mat1(0,1) = 2; mat1(1,0) = 1; mat1(1,1) = 3; mat1(1,3) = 4; mat1(2,3) = 5; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2(0,0) = 1; mat2(0,2) = 2; mat2(1,1) = 3; mat2(2,0) = 4; mat2(2,2) = 5; mat2 *= mat1; checkRows ( mat2, 3UL ); checkColumns ( mat2, 4UL ); checkNonZeros( mat2, 7UL ); checkNonZeros( mat2, 0UL, 1UL ); checkNonZeros( mat2, 1UL, 3UL ); checkNonZeros( mat2, 2UL, 0UL ); checkNonZeros( mat2, 3UL, 3UL ); if( mat2(0,0) != 0 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(0,3) != 10 || mat2(1,0) != 3 || mat2(1,1) != 9 || mat2(1,2) != 0 || mat2(1,3) != 12 || mat2(2,0) != 0 || mat2(2,1) != 8 || mat2(2,2) != 0 || mat2(2,3) != 25 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 0 2 0 10 )\n( 3 9 0 12 )\n( 0 8 0 25 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix dense matrix multiplication assignment"; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat1( 3UL, 4UL, 0 ); mat1(0,1) = 2; mat1(1,0) = 1; mat1(1,1) = 3; mat1(1,3) = 4; mat1(2,3) = 5; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2(0,0) = 1; mat2(0,2) = 2; mat2(1,1) = 3; mat2(2,0) = 4; mat2(2,2) = 5; mat2 *= mat1; checkRows ( mat2, 3UL ); checkColumns ( mat2, 4UL ); checkNonZeros( mat2, 7UL ); checkNonZeros( mat2, 0UL, 1UL ); checkNonZeros( mat2, 1UL, 3UL ); checkNonZeros( mat2, 2UL, 0UL ); checkNonZeros( mat2, 3UL, 3UL ); if( mat2(0,0) != 0 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(0,3) != 10 || mat2(1,0) != 3 || mat2(1,1) != 9 || mat2(1,2) != 0 || mat2(1,3) != 12 || mat2(2,0) != 0 || mat2(2,1) != 8 || mat2(2,2) != 0 || mat2(2,3) != 25 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 0 2 0 10 )\n( 3 9 0 12 )\n( 0 8 0 25 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major sparse matrix multiplication assignment //===================================================================================== { test_ = "Column-major/row-major HybridMatrix sparse matrix multiplication assignment"; blaze::CompressedMatrix<int,blaze::rowMajor> mat1( 3UL, 4UL, 5UL ); mat1(0,1) = 2; mat1(1,0) = 1; mat1(1,1) = 3; mat1(1,3) = 4; mat1(2,3) = 5; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2(0,0) = 1; mat2(0,2) = 2; mat2(1,1) = 3; mat2(2,0) = 4; mat2(2,2) = 5; mat2 *= mat1; checkRows ( mat2, 3UL ); checkColumns ( mat2, 4UL ); checkNonZeros( mat2, 7UL ); checkNonZeros( mat2, 0UL, 1UL ); checkNonZeros( mat2, 1UL, 3UL ); checkNonZeros( mat2, 2UL, 0UL ); checkNonZeros( mat2, 3UL, 3UL ); if( mat2(0,0) != 0 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(0,3) != 10 || mat2(1,0) != 3 || mat2(1,1) != 9 || mat2(1,2) != 0 || mat2(1,3) != 12 || mat2(2,0) != 0 || mat2(2,1) != 8 || mat2(2,2) != 0 || mat2(2,3) != 25 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 0 2 0 10 )\n( 3 9 0 12 )\n( 0 8 0 25 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major/column-major HybridMatrix sparse matrix multiplication assignment"; blaze::CompressedMatrix<int,blaze::columnMajor> mat1( 3UL, 4UL, 5UL ); mat1(0,1) = 2; mat1(1,0) = 1; mat1(1,1) = 3; mat1(1,3) = 4; mat1(2,3) = 5; blaze::HybridMatrix<int,3UL,4UL,blaze::columnMajor> mat2( 3UL, 3UL, 0 ); mat2(0,0) = 1; mat2(0,2) = 2; mat2(1,1) = 3; mat2(2,0) = 4; mat2(2,2) = 5; mat2 *= mat1; checkRows ( mat2, 3UL ); checkColumns ( mat2, 4UL ); checkNonZeros( mat2, 7UL ); checkNonZeros( mat2, 0UL, 1UL ); checkNonZeros( mat2, 1UL, 3UL ); checkNonZeros( mat2, 2UL, 0UL ); checkNonZeros( mat2, 3UL, 3UL ); if( mat2(0,0) != 0 || mat2(0,1) != 2 || mat2(0,2) != 0 || mat2(0,3) != 10 || mat2(1,0) != 3 || mat2(1,1) != 9 || mat2(1,2) != 0 || mat2(1,3) != 12 || mat2(2,0) != 0 || mat2(2,1) != 8 || mat2(2,2) != 0 || mat2(2,3) != 25 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 0 2 0 10 )\n( 3 9 0 12 )\n( 0 8 0 25 )\n"; throw std::runtime_error( oss.str() ); } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of all HybridMatrix (self-)scaling operations. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of all available ways to scale an instance of the HybridMatrix // class template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testScaling() { //===================================================================================== // Row-major self-scaling (M*=s) //===================================================================================== { test_ = "Row-major self-scaling (M*=s)"; blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 1; mat(2,0) = -2; mat(2,2) = 3; mat *= 2; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 2 || mat(2,0) != -4 || mat(2,1) != 0 || mat(2,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 2 )\n( -4 0 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major self-scaling (M=M*s) //===================================================================================== { test_ = "Row-major self-scaling (M=M*s)"; blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 1; mat(2,0) = -2; mat(2,2) = 3; mat = mat * 2; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 2 || mat(2,0) != -4 || mat(2,1) != 0 || mat(2,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 2 )\n( -4 0 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major self-scaling (M=s*M) //===================================================================================== { test_ = "Row-major self-scaling (M=s*M)"; blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 1; mat(2,0) = -2; mat(2,2) = 3; mat = 2 * mat; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 2 || mat(2,0) != -4 || mat(2,1) != 0 || mat(2,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 2 )\n( -4 0 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major self-scaling (M/=s) //===================================================================================== { test_ = "Row-major self-scaling (M/=s)"; blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 2; mat(2,0) = -4; mat(2,2) = 6; mat /= 2; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 1 || mat(2,0) != -2 || mat(2,1) != 0 || mat(2,2) != 3 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 1 )\n( -2 0 3 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major self-scaling (M=M/s) //===================================================================================== { test_ = "Row-major self-scaling (M=M/s)"; blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 2; mat(2,0) = -4; mat(2,2) = 6; mat = mat / 2; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 1 || mat(2,0) != -2 || mat(2,1) != 0 || mat(2,2) != 3 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 1 )\n( -2 0 3 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Row-major HybridMatrix::scale() //===================================================================================== { test_ = "Row-major HybridMatrix::scale() (int)"; // Initialization check blaze::HybridMatrix<int,3UL,2UL,blaze::rowMajor> mat( 3UL, 2UL ); mat(0,0) = 1; mat(0,1) = 2; mat(1,0) = 3; mat(1,1) = 4; mat(2,0) = 5; mat(2,1) = 6; checkRows ( mat, 3UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(1,0) != 3 || mat(1,1) != 4 || mat(2,0) != 5 || mat(2,1) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 )\n( 3 4 )\n( 5 6 )\n"; throw std::runtime_error( oss.str() ); } // Integral scaling of the matrix mat.scale( 2 ); checkRows ( mat, 3UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 2 || mat(0,1) != 4 || mat(1,0) != 6 || mat(1,1) != 8 || mat(2,0) != 10 || mat(2,1) != 12 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Scale operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 2 4 )\n( 6 8 )\n( 10 12 )\n"; throw std::runtime_error( oss.str() ); } // Floating point scaling of the matrix mat.scale( 0.5 ); checkRows ( mat, 3UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(1,0) != 3 || mat(1,1) != 4 || mat(2,0) != 5 || mat(2,1) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Scale operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 )\n( 3 4 )\n( 5 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Row-major HybridMatrix::scale() (complex)"; using blaze::complex; blaze::HybridMatrix<complex<float>,2UL,2UL,blaze::rowMajor> mat( 2UL, 2UL ); mat(0,0) = complex<float>( 1.0F, 0.0F ); mat(0,1) = complex<float>( 2.0F, 0.0F ); mat(1,0) = complex<float>( 3.0F, 0.0F ); mat(1,1) = complex<float>( 4.0F, 0.0F ); mat.scale( complex<float>( 3.0F, 0.0F ) ); checkRows ( mat, 2UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 4UL ); checkNonZeros( mat, 4UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); if( mat(0,0) != complex<float>( 3.0F, 0.0F ) || mat(0,1) != complex<float>( 6.0F, 0.0F ) || mat(1,0) != complex<float>( 9.0F, 0.0F ) || mat(1,1) != complex<float>( 12.0F, 0.0F ) ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Scale operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( ( 3,0) ( 6,0)\n( 9,0) (12,0) )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major self-scaling (M*=s) //===================================================================================== { test_ = "Column-major self-scaling (M*=s)"; blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 1; mat(2,0) = -2; mat(2,2) = 3; mat *= 2; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 0UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 2 || mat(2,0) != -4 || mat(2,1) != 0 || mat(2,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 2 )\n( -4 0 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major self-scaling (M=M*s) //===================================================================================== { test_ = "Column-major self-scaling (M=M*s)"; blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 1; mat(2,0) = -2; mat(2,2) = 3; mat = mat * 2; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 0UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 2 || mat(2,0) != -4 || mat(2,1) != 0 || mat(2,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 2 )\n( -4 0 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major self-scaling (M=s*M) //===================================================================================== { test_ = "Column-major self-scaling (M=s*M)"; blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 1; mat(2,0) = -2; mat(2,2) = 3; mat = 2 * mat; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 0UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 2 || mat(2,0) != -4 || mat(2,1) != 0 || mat(2,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 2 )\n( -4 0 6 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major self-scaling (M/=s) //===================================================================================== { test_ = "Column-major self-scaling (M/=s)"; blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 2; mat(2,0) = -4; mat(2,2) = 6; mat /= 2; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 0UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 1 || mat(2,0) != -2 || mat(2,1) != 0 || mat(2,2) != 3 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 1 )\n( -2 0 3 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major self-scaling (M=M/s) //===================================================================================== { test_ = "Column-major self-scaling (M=M/s)"; blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat( 3UL, 3UL, 0 ); mat(1,2) = 2; mat(2,0) = -4; mat(2,2) = 6; mat = mat / 2; checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 0UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 1 || mat(2,0) != -2 || mat(2,1) != 0 || mat(2,2) != 3 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed self-scaling operation\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 1 )\n( -2 0 3 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major HybridMatrix::scale() //===================================================================================== { test_ = "Column-major HybridMatrix::scale() (int)"; // Initialization check blaze::HybridMatrix<int,3UL,2UL,blaze::columnMajor> mat( 3UL, 2UL ); mat(0,0) = 1; mat(0,1) = 4; mat(1,0) = 2; mat(1,1) = 5; mat(2,0) = 3; mat(2,1) = 6; checkRows ( mat, 3UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 4 || mat(1,0) != 2 || mat(1,1) != 5 || mat(2,0) != 3 || mat(2,1) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 4 )\n( 2 5 )\n( 3 6 )\n"; throw std::runtime_error( oss.str() ); } // Integral scaling of the matrix mat.scale( 2 ); checkRows ( mat, 3UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 2 || mat(0,1) != 8 || mat(1,0) != 4 || mat(1,1) != 10 || mat(2,0) != 6 || mat(2,1) != 12 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Scale operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 2 8 )\n( 4 10 )\n( 6 12 )\n"; throw std::runtime_error( oss.str() ); } // Floating point scaling of the matrix mat.scale( 0.5 ); checkRows ( mat, 3UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 4 || mat(1,0) != 2 || mat(1,1) != 5 || mat(2,0) != 3 || mat(2,1) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Scale operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 4 )\n( 2 5 )\n( 3 6 )\n"; throw std::runtime_error( oss.str() ); } } { test_ = "Column-major HybridMatrix::scale() (complex)"; using blaze::complex; blaze::HybridMatrix<complex<float>,2UL,2UL,blaze::columnMajor> mat( 2UL, 2UL ); mat(0,0) = complex<float>( 1.0F, 0.0F ); mat(0,1) = complex<float>( 2.0F, 0.0F ); mat(1,0) = complex<float>( 3.0F, 0.0F ); mat(1,1) = complex<float>( 4.0F, 0.0F ); mat.scale( complex<float>( 3.0F, 0.0F ) ); checkRows ( mat, 2UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 4UL ); checkNonZeros( mat, 4UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); if( mat(0,0) != complex<float>( 3.0F, 0.0F ) || mat(0,1) != complex<float>( 6.0F, 0.0F ) || mat(1,0) != complex<float>( 9.0F, 0.0F ) || mat(1,1) != complex<float>( 12.0F, 0.0F ) ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Scale operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( ( 3,0) ( 6,0)\n( 9,0) (12,0) )\n"; throw std::runtime_error( oss.str() ); } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the HybridMatrix function call operator. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of adding and accessing elements via the function call operator // of the HybridMatrix class template. In case an error is detected, a \a std::runtime_error // exception is thrown. */ void ClassTest::testFunctionCall() { //===================================================================================== // Row-major matrix tests //===================================================================================== { test_ = "Row-major HybridMatrix::operator()"; // Assignment to the element (2,1) blaze::HybridMatrix<int,3UL,5UL,blaze::rowMajor> mat( 3UL, 5UL, 0 ); mat(2,1) = 1; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 1UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 0UL ); checkNonZeros( mat, 2UL, 1UL ); if( mat(2,1) != 1 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 0 0 )\n( 0 0 0 0 0 )\n( 0 1 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Assignment to the element (1,4) mat(1,4) = 2; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 2UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 1UL ); if( mat(1,4) != 2 || mat(2,1) != 1 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 0 0 )\n( 0 0 0 0 2 )\n( 0 1 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Assignment to the element (0,3) mat(0,3) = 3; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 1UL ); if( mat(0,3) != 3 || mat(1,4) != 2 || mat(2,1) != 1 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 3 0 )\n( 0 0 0 0 2 )\n( 0 1 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Assignment to the element (2,2) mat(2,2) = 4; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 4UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,3) != 3 || mat(1,4) != 2 || mat(2,1) != 1 || mat(2,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 3 0 )\n( 0 0 0 0 2 )\n( 0 1 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Addition assignment to the element (2,1) mat(2,1) += mat(0,3); checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 4UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,3) != 3 || mat(1,4) != 2 || mat(2,1) != 4 || mat(2,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 3 0 )\n( 0 0 0 0 2 )\n( 0 4 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Subtraction assignment to the element (1,0) mat(1,0) -= mat(1,4); checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,3) != 3 || mat(1,0) != -2 || mat(1,4) != 2 || mat(2,1) != 4 || mat(2,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 3 0 )\n( -2 0 0 0 2 )\n( 0 4 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Multiplication assignment to the element (0,3) mat(0,3) *= -3; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,3) != -9 || mat(1,0) != -2 || mat(1,4) != 2 || mat(2,1) != 4 || mat(2,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 -3 0 )\n( -2 0 0 0 2 )\n( 0 4 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Division assignment to the element (2,1) mat(2,1) /= 2; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,3) != -9 || mat(1,0) != -2 || mat(1,4) != 2 || mat(2,1) != 2 || mat(2,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 -3 0 )\n( -2 0 0 0 2 )\n( 0 2 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major matrix tests //===================================================================================== { test_ = "Column-major HybridMatrix::operator()"; // Assignment to the element (2,1) blaze::HybridMatrix<int,3UL,5UL,blaze::columnMajor> mat( 3UL, 5UL, 0 ); mat(2,1) = 1; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 1UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 0UL ); checkNonZeros( mat, 3UL, 0UL ); checkNonZeros( mat, 4UL, 0UL ); if( mat(2,1) != 1 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 0 0 )\n( 0 0 0 0 0 )\n( 0 1 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Assignment to the element (1,4) mat(1,4) = 2; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 2UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 0UL ); checkNonZeros( mat, 3UL, 0UL ); checkNonZeros( mat, 4UL, 1UL ); if( mat(1,4) != 2 || mat(2,1) != 1 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 0 0 )\n( 0 0 0 0 2 )\n( 0 1 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Assignment to the element (0,3) mat(0,3) = 3; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 0UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 1UL ); if( mat(0,3) != 3 || mat(1,4) != 2 || mat(2,1) != 1 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 3 0 )\n( 0 0 0 0 2 )\n( 0 1 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Assignment to the element (2,2) mat(2,2) = 4; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 4UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 1UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 1UL ); if( mat(0,3) != 3 || mat(1,4) != 2 || mat(2,1) != 1 || mat(2,2) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 3 0 )\n( 0 0 0 0 2 )\n( 0 1 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Addition assignment to the element (2,1) mat(2,1) += mat(0,3); checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 4UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 1UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 1UL ); if( mat(2,1) != 4 || mat(2,2) != 4 || mat(0,3) != 3 || mat(1,4) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 3 0 )\n( 0 0 0 0 2 )\n( 0 4 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Subtraction assignment to the element (1,0) mat(1,0) -= mat(1,4); checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 1UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 1UL ); if( mat(1,0) != -2 || mat(2,1) != 4 || mat(2,2) != 4 || mat(0,3) != 3 || mat(1,4) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 3 0 )\n( -2 0 0 0 2 )\n( 0 4 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Multiplication assignment to the element (0,3) mat(0,3) *= -3; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 1UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 1UL ); if( mat(1,0) != -2 || mat(2,1) != 4 || mat(2,2) != 4 || mat(0,3) != -9 || mat(1,4) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 -9 0 )\n( -2 0 0 0 2 )\n( 0 4 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Division assignment to the element (2,1) mat(2,1) /= 2; checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 1UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 1UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 1UL ); if( mat(1,0) != -2 || mat(2,1) != 2 || mat(2,2) != 4 || mat(0,3) != -9 || mat(1,4) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Function call operator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 -9 0 )\n( -2 0 0 0 2 )\n( 0 2 4 0 0 )\n"; throw std::runtime_error( oss.str() ); } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the HybridMatrix iterator implementation. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the iterator implementation of the HybridMatrix class // template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testIterator() { //===================================================================================== // Row-major matrix tests //===================================================================================== { typedef blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> MatrixType; typedef MatrixType::Iterator Iterator; typedef MatrixType::ConstIterator ConstIterator; MatrixType mat( 3UL, 3UL, 0 ); mat(0,1) = 1; mat(1,0) = -2; mat(1,2) = -3; mat(2,1) = 4; mat(2,2) = 5; // Testing the Iterator default constructor { test_ = "Row-major Iterator default constructor"; Iterator it = Iterator(); if( it != Iterator() ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed iterator default constructor\n"; throw std::runtime_error( oss.str() ); } } // Testing the ConstIterator default constructor { test_ = "Row-major ConstIterator default constructor"; ConstIterator it = ConstIterator(); if( it != ConstIterator() ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed iterator default constructor\n"; throw std::runtime_error( oss.str() ); } } // Testing conversion from Iterator to ConstIterator { test_ = "Row-major Iterator/ConstIterator conversion"; ConstIterator it( begin( mat, 1UL ) ); if( it == end( mat, 1UL ) || *it != -2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed iterator conversion detected\n"; throw std::runtime_error( oss.str() ); } } // Counting the number of elements in 0th row via Iterator { test_ = "Row-major Iterator subtraction"; const size_t number( end( mat, 0UL ) - begin( mat, 0UL ) ); if( number != 3UL ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid number of elements detected\n" << " Details:\n" << " Number of elements : " << number << "\n" << " Expected number of elements: 3\n"; throw std::runtime_error( oss.str() ); } } // Counting the number of elements in 1st row via ConstIterator { test_ = "Row-major ConstIterator subtraction"; const size_t number( cend( mat, 1UL ) - cbegin( mat, 1UL ) ); if( number != 3UL ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid number of elements detected\n" << " Details:\n" << " Number of elements : " << number << "\n" << " Expected number of elements: 3\n"; throw std::runtime_error( oss.str() ); } } // Testing read-only access via ConstIterator { test_ = "Row-major read-only access via ConstIterator"; ConstIterator it ( cbegin( mat, 2UL ) ); ConstIterator end( cend( mat, 2UL ) ); if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid initial iterator detected\n"; throw std::runtime_error( oss.str() ); } ++it; if( it == end || *it != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator pre-increment failed\n"; throw std::runtime_error( oss.str() ); } --it; if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator pre-decrement failed\n"; throw std::runtime_error( oss.str() ); } it++; if( it == end || *it != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator post-increment failed\n"; throw std::runtime_error( oss.str() ); } it--; if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator post-decrement failed\n"; throw std::runtime_error( oss.str() ); } it += 2UL; if( it == end || *it != 5 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator addition assignment failed\n"; throw std::runtime_error( oss.str() ); } it -= 2UL; if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator subtraction assignment failed\n"; throw std::runtime_error( oss.str() ); } it = it + 2UL; if( it == end || *it != 5 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator/scalar addition failed\n"; throw std::runtime_error( oss.str() ); } it = it - 2UL; if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator/scalar subtraction failed\n"; throw std::runtime_error( oss.str() ); } it = 3UL + it; if( it != end ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Scalar/iterator addition failed\n"; throw std::runtime_error( oss.str() ); } } // Testing assignment via Iterator { test_ = "Row-major assignment via Iterator"; int value = 7; for( Iterator it=begin( mat, 2UL ); it!=end( mat, 2UL ); ++it ) { *it = value++; } if( mat(0,0) != 0 || mat(0,1) != 1 || mat(0,2) != 0 || mat(1,0) != -2 || mat(1,1) != 0 || mat(1,2) != -3 || mat(2,0) != 7 || mat(2,1) != 8 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 1 0 )\n( -2 0 -3 )\n( 7 8 9 )\n"; throw std::runtime_error( oss.str() ); } } // Testing addition assignment via Iterator { test_ = "Row-major addition assignment via Iterator"; int value = 4; for( Iterator it=begin( mat, 1UL ); it!=end( mat, 1UL ); ++it ) { *it += value++; } if( mat(0,0) != 0 || mat(0,1) != 1 || mat(0,2) != 0 || mat(1,0) != 2 || mat(1,1) != 5 || mat(1,2) != 3 || mat(2,0) != 7 || mat(2,1) != 8 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 1 0 )\n( 2 5 3 )\n( 7 8 9 )\n"; throw std::runtime_error( oss.str() ); } } // Testing subtraction assignment via Iterator { test_ = "Row-major subtraction assignment via Iterator"; int value = 4; for( Iterator it=begin( mat, 1UL ); it!=end( mat, 1UL ); ++it ) { *it -= value++; } if( mat(0,0) != 0 || mat(0,1) != 1 || mat(0,2) != 0 || mat(1,0) != -2 || mat(1,1) != 0 || mat(1,2) != -3 || mat(2,0) != 7 || mat(2,1) != 8 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 1 0 )\n( -2 0 -3 )\n( 7 8 9 )\n"; throw std::runtime_error( oss.str() ); } } // Testing multiplication assignment via Iterator { test_ = "Row-major multiplication assignment via Iterator"; int value = 2; for( Iterator it=begin( mat, 1UL ); it!=end( mat, 1UL ); ++it ) { *it *= value++; } if( mat(0,0) != 0 || mat(0,1) != 1 || mat(0,2) != 0 || mat(1,0) != -4 || mat(1,1) != 0 || mat(1,2) != -12 || mat(2,0) != 7 || mat(2,1) != 8 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 1 0 )\n( -4 0 -12 )\n( 7 8 9 )\n"; throw std::runtime_error( oss.str() ); } } // Testing division assignment via Iterator { test_ = "Row-major division assignment via Iterator"; for( Iterator it=begin( mat, 1UL ); it!=end( mat, 1UL ); ++it ) { *it /= 2; } if( mat(0,0) != 0 || mat(0,1) != 1 || mat(0,2) != 0 || mat(1,0) != -2 || mat(1,1) != 0 || mat(1,2) != -6 || mat(2,0) != 7 || mat(2,1) != 8 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Division assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 1 0 )\n( -2 0 -6 )\n( 7 8 9 )\n"; throw std::runtime_error( oss.str() ); } } } //===================================================================================== // Column-major matrix tests //===================================================================================== { typedef blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> MatrixType; typedef MatrixType::Iterator Iterator; typedef MatrixType::ConstIterator ConstIterator; MatrixType mat( 3UL, 3UL, 0 ); mat(1,0) = 1; mat(0,1) = -2; mat(2,1) = -3; mat(1,2) = 4; mat(2,2) = 5; // Testing the Iterator default constructor { test_ = "Column-major Iterator default constructor"; Iterator it = Iterator(); if( it != Iterator() ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed iterator default constructor\n"; throw std::runtime_error( oss.str() ); } } // Testing the ConstIterator default constructor { test_ = "Column-major ConstIterator default constructor"; ConstIterator it = ConstIterator(); if( it != ConstIterator() ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed iterator default constructor\n"; throw std::runtime_error( oss.str() ); } } // Testing conversion from Iterator to ConstIterator { test_ = "Column-major Iterator/ConstIterator conversion"; ConstIterator it( begin( mat, 1UL ) ); if( it == end( mat, 1UL ) || *it != -2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Failed iterator conversion detected\n"; throw std::runtime_error( oss.str() ); } } // Counting the number of elements in 0th column via Iterator { test_ = "Column-major Iterator subtraction"; const size_t number( end( mat, 0UL ) - begin( mat, 0UL ) ); if( number != 3UL ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid number of elements detected\n" << " Details:\n" << " Number of elements : " << number << "\n" << " Expected number of elements: 3\n"; throw std::runtime_error( oss.str() ); } } // Counting the number of elements in 1st row via ConstIterator { test_ = "Column-major ConstIterator subtraction"; const size_t number( cend( mat, 1UL ) - cbegin( mat, 1UL ) ); if( number != 3UL ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid number of elements detected\n" << " Details:\n" << " Number of elements : " << number << "\n" << " Expected number of elements: 3\n"; throw std::runtime_error( oss.str() ); } } // Counting the number of elements in 2nd row { test_ = "Column-major iterator subtraction"; const size_t number( end( mat, 2UL ) - begin( mat, 2UL ) ); if( number != 3UL ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid number of elements detected\n" << " Details:\n" << " Number of elements : " << number << "\n" << " Expected number of elements: 3\n"; throw std::runtime_error( oss.str() ); } } // Testing read-only access via ConstIterator { test_ = "Column-major read-only access via ConstIterator"; ConstIterator it ( cbegin( mat, 2UL ) ); ConstIterator end( cend( mat, 2UL ) ); if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid initial iterator detected\n"; throw std::runtime_error( oss.str() ); } ++it; if( it == end || *it != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator pre-increment failed\n"; throw std::runtime_error( oss.str() ); } --it; if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator pre-decrement failed\n"; throw std::runtime_error( oss.str() ); } it++; if( it == end || *it != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator post-increment failed\n"; throw std::runtime_error( oss.str() ); } it--; if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator post-decrement failed\n"; throw std::runtime_error( oss.str() ); } it += 2UL; if( it == end || *it != 5 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator addition assignment failed\n"; throw std::runtime_error( oss.str() ); } it -= 2UL; if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator subtraction assignment failed\n"; throw std::runtime_error( oss.str() ); } it = it + 2UL; if( it == end || *it != 5 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator/scalar addition failed\n"; throw std::runtime_error( oss.str() ); } it = it - 2UL; if( it == end || *it != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Iterator/scalar subtraction failed\n"; throw std::runtime_error( oss.str() ); } it = 3UL + it; if( it != end ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Scalar/iterator addition failed\n"; throw std::runtime_error( oss.str() ); } } // Testing assignment via Iterator { test_ = "Column-major assignment via Iterator"; int value = 7; for( Iterator it=begin( mat, 2UL ); it!=end( mat, 2UL ); ++it ) { *it = value++; } if( mat(0,0) != 0 || mat(0,1) != -2 || mat(0,2) != 7 || mat(1,0) != 1 || mat(1,1) != 0 || mat(1,2) != 8 || mat(2,0) != 0 || mat(2,1) != -3 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 -2 7 )\n( 1 0 8 )\n( 0 -3 9 )\n"; throw std::runtime_error( oss.str() ); } } // Testing addition assignment via Iterator { test_ = "Column-major addition assignment via Iterator"; int value = 4; for( Iterator it=begin( mat, 1UL ); it!=end( mat, 1UL ); ++it ) { *it += value++; } if( mat(0,0) != 0 || mat(0,1) != 2 || mat(0,2) != 7 || mat(1,0) != 1 || mat(1,1) != 5 || mat(1,2) != 8 || mat(2,0) != 0 || mat(2,1) != 3 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Addition assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 2 7 )\n( 1 5 8 )\n( 0 3 9 )\n"; throw std::runtime_error( oss.str() ); } } // Testing subtraction assignment via Iterator { test_ = "Column-major subtraction assignment via Iterator"; int value = 4; for( Iterator it=begin( mat, 1UL ); it!=end( mat, 1UL ); ++it ) { *it -= value++; } if( mat(0,0) != 0 || mat(0,1) != -2 || mat(0,2) != 7 || mat(1,0) != 1 || mat(1,1) != 0 || mat(1,2) != 8 || mat(2,0) != 0 || mat(2,1) != -3 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Subtraction assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 -2 7 )\n( 1 0 8 )\n( 0 -3 9 )\n"; throw std::runtime_error( oss.str() ); } } // Testing multiplication assignment via Iterator { test_ = "Column-major multiplication assignment via Iterator"; int value = 2; for( Iterator it=begin( mat, 1UL ); it!=end( mat, 1UL ); ++it ) { *it *= value++; } if( mat(0,0) != 0 || mat(0,1) != -4 || mat(0,2) != 7 || mat(1,0) != 1 || mat(1,1) != 0 || mat(1,2) != 8 || mat(2,0) != 0 || mat(2,1) != -12 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Multiplication assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 -2 7 )\n( 1 0 8 )\n( 0 -6 9 )\n"; throw std::runtime_error( oss.str() ); } } // Testing division assignment via Iterator { test_ = "Column-major division assignment via Iterator"; for( Iterator it=begin( mat, 1UL ); it!=end( mat, 1UL ); ++it ) { *it /= 2; } if( mat(0,0) != 0 || mat(0,1) != -2 || mat(0,2) != 7 || mat(1,0) != 1 || mat(1,1) != 0 || mat(1,2) != 8 || mat(2,0) != 0 || mat(2,1) != -6 || mat(2,2) != 9 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Division assignment via iterator failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 -2 7 )\n( 1 0 8 )\n( 0 -6 9 )\n"; throw std::runtime_error( oss.str() ); } } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the \c nonZeros() member function of the HybridMatrix class template. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the \c nonZeros() member function of the HybridMatrix class // template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testNonZeros() { //===================================================================================== // Row-major matrix tests //===================================================================================== { test_ = "Row-major HybridMatrix::nonZeros()"; { blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat( 2UL, 3UL, 0 ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 0UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 0UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } } { blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat( 2UL, 3UL, 0 ); mat(0,1) = 1; mat(0,2) = 2; mat(1,1) = 3; mat(1,2) = 0; checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 1UL ); if( mat(0,0) != 0 || mat(0,1) != 1 || mat(0,2) != 2 || mat(1,0) != 0 || mat(1,1) != 3 || mat(1,2) != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 1 2 )\n( 0 3 0 )\n"; throw std::runtime_error( oss.str() ); } } } //===================================================================================== // Column-major matrix tests //===================================================================================== { test_ = "Column-major HybridMatrix::nonZeros()"; { blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat( 2UL, 3UL, 0 ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 0UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 0UL ); checkNonZeros( mat, 2UL, 0UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } } { blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat( 2UL, 3UL, 0 ); mat(0,1) = 1; mat(0,2) = 2; mat(1,1) = 3; mat(1,2) = 0; checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 1UL ); if( mat(0,0) != 0 || mat(0,1) != 1 || mat(0,2) != 2 || mat(1,0) != 0 || mat(1,1) != 3 || mat(1,2) != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 1 2 )\n( 0 3 0 )\n"; throw std::runtime_error( oss.str() ); } } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the \c reset() member function of the HybridMatrix class template. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the \c reset() member function of the HybridMatrix class // template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testReset() { using blaze::reset; //===================================================================================== // Row-major matrix tests //===================================================================================== { test_ = "Row-major HybridMatrix::reset()"; // Initialization check blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat( 2UL, 3UL ); mat(0,0) = 1; mat(0,1) = 2; mat(0,2) = 3; mat(1,0) = 4; mat(1,1) = 5; mat(1,2) = 6; checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 3 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } // Resetting a single element reset( mat(0,2) ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 0 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Reset operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 0 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } // Resetting row 1 reset( mat, 1UL ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 2UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 0UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Reset operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 0 )\n( 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } // Resetting the entire matrix reset( mat ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 0UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 0UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Reset operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major matrix tests //===================================================================================== { test_ = "Column-major HybridMatrix::reset()"; // Initialization check blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat( 2UL, 3UL ); mat(0,0) = 1; mat(0,1) = 2; mat(0,2) = 3; mat(1,0) = 4; mat(1,1) = 5; mat(1,2) = 6; checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 3 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } // Resetting a single element reset( mat(0,2) ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 1UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 0 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Reset operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 0 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } // Resetting column 1 reset( mat, 1UL ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 3UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 0UL ); checkNonZeros( mat, 2UL, 1UL ); if( mat(0,0) != 1 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 4 || mat(1,1) != 0 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Reset operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 0 0 )\n( 4 0 6 )\n"; throw std::runtime_error( oss.str() ); } // Resetting the entire matrix reset( mat ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 0UL ); checkNonZeros( mat, 0UL, 0UL ); checkNonZeros( mat, 1UL, 0UL ); checkNonZeros( mat, 2UL, 0UL ); if( mat(0,0) != 0 || mat(0,1) != 0 || mat(0,2) != 0 || mat(1,0) != 0 || mat(1,1) != 0 || mat(1,2) != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Reset operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 0 0 0 )\n( 0 0 0 )\n"; throw std::runtime_error( oss.str() ); } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the \c clear() member function of the HybridMatrix class template. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the \c clear() member function of the HybridMatrix class // template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testClear() { using blaze::clear; //===================================================================================== // Row-major matrix tests //===================================================================================== { test_ = "Row-major HybridMatrix::clear()"; // Initialization check blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat( 2UL, 3UL ); mat(0,0) = 1; mat(0,1) = 2; mat(0,2) = 3; mat(1,0) = 4; mat(1,1) = 5; mat(1,2) = 6; checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 3 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } // Clearing a single element clear( mat(0,2) ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 0 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Clear operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 0 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } // Clearing the matrix clear( mat ); checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } //===================================================================================== // Column-major matrix tests //===================================================================================== { test_ = "Column-major HybridMatrix::clear()"; // Initialization check blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat( 2UL, 3UL ); mat(0,0) = 1; mat(0,1) = 2; mat(0,2) = 3; mat(1,0) = 4; mat(1,1) = 5; mat(1,2) = 6; checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 6UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 3 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 3 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } // Clearing a single element clear( mat(0,2) ); checkRows ( mat, 2UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 6UL ); checkNonZeros( mat, 5UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 1UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(0,2) != 0 || mat(1,0) != 4 || mat(1,1) != 5 || mat(1,2) != 6 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Clear operation failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 0 )\n( 4 5 6 )\n"; throw std::runtime_error( oss.str() ); } // Clearing the matrix clear( mat ); checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the \c resize() member function of the HybridMatrix class template. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the \c resize() member function of the HybridMatrix class // template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testResize() { //===================================================================================== // Row-major matrix tests //===================================================================================== { test_ = "Row-major HybridMatrix::resize()"; // Initialization check blaze::HybridMatrix<int,5UL,3UL,blaze::rowMajor> mat; checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); // Resizing to 0x3 mat.resize( 0UL, 3UL ); checkRows ( mat, 0UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 0UL ); // Resizing to 5x0 mat.resize( 5UL, 0UL ); checkRows ( mat, 5UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); // Resizing to 2x1 mat.resize( 2UL, 1UL ); checkRows ( mat, 2UL ); checkColumns ( mat, 1UL ); checkCapacity( mat, 2UL ); // Resizing to 3x2 and preserving the elements mat(0,0) = 1; mat(1,0) = 2; mat.resize( 3UL, 2UL, true ); checkRows ( mat, 3UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 6UL ); if( mat(0,0) != 1 || mat(1,0) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Resizing the matrix failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 x )\n( 2 x )\n( x x )\n"; throw std::runtime_error( oss.str() ); } // Resizing to 2x2 and preserving the elements mat(0,1) = 3; mat(1,1) = 4; mat.resize( 2UL, 2UL, true ); checkRows ( mat, 2UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 4UL ); checkNonZeros( mat, 4UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 3 || mat(1,0) != 2 || mat(1,1) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Resizing the matrix failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 3 )\n( 2 4 )\n"; throw std::runtime_error( oss.str() ); } // Resizing to 1x1 mat.resize( 1UL, 1UL ); checkRows ( mat, 1UL ); checkColumns ( mat, 1UL ); checkCapacity( mat, 1UL ); // Resizing to 0x0 mat.resize( 0UL, 0UL ); checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } //===================================================================================== // Column-major matrix tests //===================================================================================== { test_ = "Column-major HybridMatrix::resize()"; // Initialization check blaze::HybridMatrix<int,5UL,3UL,blaze::columnMajor> mat; checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); // Resizing to 0x3 mat.resize( 0UL, 3UL ); checkRows ( mat, 0UL ); checkColumns ( mat, 3UL ); checkNonZeros( mat, 0UL ); // Resizing to 5x0 mat.resize( 5UL, 0UL ); checkRows ( mat, 5UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); // Resizing to 2x1 mat.resize( 2UL, 1UL ); checkRows ( mat, 2UL ); checkColumns ( mat, 1UL ); checkCapacity( mat, 2UL ); // Resizing to 3x2 and preserving the elements mat(0,0) = 1; mat(1,0) = 2; mat.resize( 3UL, 2UL, true ); checkRows ( mat, 3UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 6UL ); if( mat(0,0) != 1 || mat(1,0) != 2 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Resizing the matrix failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 x )\n( 2 x )\n( x x )\n"; throw std::runtime_error( oss.str() ); } // Resizing to 2x2 and preserving the elements mat(0,1) = 3; mat(1,1) = 4; mat.resize( 2UL, 2UL, true ); checkRows ( mat, 2UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 4UL ); checkNonZeros( mat, 4UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 3 || mat(1,0) != 2 || mat(1,1) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Resizing the matrix failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 3 )\n( 2 4 )\n"; throw std::runtime_error( oss.str() ); } // Resizing to 1x1 mat.resize( 1UL, 1UL ); checkRows ( mat, 1UL ); checkColumns ( mat, 1UL ); checkCapacity( mat, 1UL ); // Resizing to 0x0 mat.resize( 0UL, 0UL ); checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the \c extend() member function of the HybridMatrix class template. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the \c extend() member function of the HybridMatrix class // template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testExtend() { //===================================================================================== // Row-major matrix tests //===================================================================================== { test_ = "Row-major HybridMatrix::extend()"; // Initialization check blaze::HybridMatrix<int,7UL,13UL,blaze::rowMajor> mat; checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); // Increasing the size of the matrix mat.extend( 2UL, 2UL ); checkRows ( mat, 2UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 3UL ); // Further increasing the size of the matrix and preserving the elements mat(0,0) = 1; mat(0,1) = 2; mat(1,0) = 3; mat(1,1) = 4; mat.extend( 1UL, 1UL, true ); checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 9UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(1,0) != 3 || mat(1,1) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Extending the matrix failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 x )\n( 3 4 x )\n( x x x )\n"; throw std::runtime_error( oss.str() ); } // Further increasing the size of the matrix mat.extend( 4UL, 10UL, false ); checkRows ( mat, 7UL ); checkColumns ( mat, 13UL ); checkCapacity( mat, 91UL ); } //===================================================================================== // Column-major matrix tests //===================================================================================== { test_ = "Column-major HybridMatrix::extend()"; // Initialization check blaze::HybridMatrix<int,7UL,13UL,blaze::columnMajor> mat; checkRows ( mat, 0UL ); checkColumns ( mat, 0UL ); checkNonZeros( mat, 0UL ); // Increasing the size of the matrix mat.extend( 2UL, 2UL ); checkRows ( mat, 2UL ); checkColumns ( mat, 2UL ); checkCapacity( mat, 3UL ); // Further increasing the size of the matrix and preserving the elements mat(0,0) = 1; mat(0,1) = 2; mat(1,0) = 3; mat(1,1) = 4; mat.extend( 1UL, 1UL, true ); checkRows ( mat, 3UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 9UL ); if( mat(0,0) != 1 || mat(0,1) != 2 || mat(1,0) != 3 || mat(1,1) != 4 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Extending the matrix failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 2 x )\n( 3 4 x )\n( x x x )\n"; throw std::runtime_error( oss.str() ); } // Further increasing the size of the matrix mat.extend( 4UL, 10UL, false ); checkRows ( mat, 7UL ); checkColumns ( mat, 13UL ); checkCapacity( mat, 91UL ); } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the \c transpose() member function of the HybridMatrix class template. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the \c transpose() member function of the HybridMatrix // class template. Additionally, it performs a test of self-transpose via the \c trans() // function. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testTranspose() { //===================================================================================== // Row-major matrix tests //===================================================================================== { test_ = "Row-major self-transpose via HybridMatrix::transpose()"; // Self-transpose of a 3x5 matrix { blaze::HybridMatrix<int,5UL,5UL,blaze::rowMajor> mat( 3UL, 5UL, 0 ); mat(0,0) = 1; mat(0,2) = 2; mat(0,4) = 3; mat(1,1) = 4; mat(1,3) = 5; mat(2,0) = 6; mat(2,2) = 7; mat(2,4) = 8; mat.transpose(); checkRows ( mat, 5UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 8UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 0 || mat(0,2) != 6 || mat(1,0) != 0 || mat(1,1) != 4 || mat(1,2) != 0 || mat(2,0) != 2 || mat(2,1) != 0 || mat(2,2) != 7 || mat(3,0) != 0 || mat(3,1) != 5 || mat(3,2) != 0 || mat(4,0) != 3 || mat(4,1) != 0 || mat(4,2) != 8 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 0 6 )\n( 0 4 0 )\n( 2 0 7 )\n( 0 5 0 )\n( 3 0 8 )\n"; throw std::runtime_error( oss.str() ); } } // Self-transpose of a 5x3 matrix { blaze::HybridMatrix<int,5UL,5UL,blaze::rowMajor> mat( 5UL, 3UL, 0 ); mat(0,0) = 1; mat(0,2) = 6; mat(1,1) = 4; mat(2,0) = 2; mat(2,2) = 7; mat(3,1) = 5; mat(4,0) = 3; mat(4,2) = 8; mat.transpose(); checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 8UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 0 || mat(0,2) != 2 || mat(0,3) != 0 || mat(0,4) != 3 || mat(1,0) != 0 || mat(1,1) != 4 || mat(1,2) != 0 || mat(1,3) != 5 || mat(1,4) != 0 || mat(2,0) != 6 || mat(2,1) != 0 || mat(2,2) != 7 || mat(2,3) != 0 || mat(2,4) != 8 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 0 2 0 3 )\n( 0 4 0 5 0 )\n( 6 0 7 0 8 )\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Row-major self-transpose via trans()"; // Self-transpose of a 3x5 matrix { blaze::HybridMatrix<int,5UL,5UL,blaze::rowMajor> mat( 3UL, 5UL, 0 ); mat(0,0) = 1; mat(0,2) = 2; mat(0,4) = 3; mat(1,1) = 4; mat(1,3) = 5; mat(2,0) = 6; mat(2,2) = 7; mat(2,4) = 8; mat = trans( mat ); checkRows ( mat, 5UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 8UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 0 || mat(0,2) != 6 || mat(1,0) != 0 || mat(1,1) != 4 || mat(1,2) != 0 || mat(2,0) != 2 || mat(2,1) != 0 || mat(2,2) != 7 || mat(3,0) != 0 || mat(3,1) != 5 || mat(3,2) != 0 || mat(4,0) != 3 || mat(4,1) != 0 || mat(4,2) != 8 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 0 6 )\n( 0 4 0 )\n( 2 0 7 )\n( 0 5 0 )\n( 3 0 8 )\n"; throw std::runtime_error( oss.str() ); } } // Self-transpose of a 5x3 matrix { blaze::HybridMatrix<int,5UL,5UL,blaze::rowMajor> mat( 5UL, 3UL, 0 ); mat(0,0) = 1; mat(0,2) = 6; mat(1,1) = 4; mat(2,0) = 2; mat(2,2) = 7; mat(3,1) = 5; mat(4,0) = 3; mat(4,2) = 8; mat = trans( mat ); checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 8UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 0 || mat(0,2) != 2 || mat(0,3) != 0 || mat(0,4) != 3 || mat(1,0) != 0 || mat(1,1) != 4 || mat(1,2) != 0 || mat(1,3) != 5 || mat(1,4) != 0 || mat(2,0) != 6 || mat(2,1) != 0 || mat(2,2) != 7 || mat(2,3) != 0 || mat(2,4) != 8 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 0 2 0 3 )\n( 0 4 0 5 0 )\n( 6 0 7 0 8 )\n"; throw std::runtime_error( oss.str() ); } } } //===================================================================================== // Column-major matrix tests //===================================================================================== { test_ = "Column-major self-transpose via HybridMatrix::transpose()"; // Self-transpose of a 3x5 matrix { blaze::HybridMatrix<int,5UL,5UL,blaze::columnMajor> mat( 3UL, 5UL, 0 ); mat(0,0) = 1; mat(0,2) = 2; mat(0,4) = 3; mat(1,1) = 4; mat(1,3) = 5; mat(2,0) = 6; mat(2,2) = 7; mat(2,4) = 8; mat.transpose(); checkRows ( mat, 5UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 8UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 0 || mat(0,2) != 6 || mat(1,0) != 0 || mat(1,1) != 4 || mat(1,2) != 0 || mat(2,0) != 2 || mat(2,1) != 0 || mat(2,2) != 7 || mat(3,0) != 0 || mat(3,1) != 5 || mat(3,2) != 0 || mat(4,0) != 3 || mat(4,1) != 0 || mat(4,2) != 8 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 0 6 )\n( 0 4 0 )\n( 2 0 7 )\n( 0 5 0 )\n( 3 0 8 )\n"; throw std::runtime_error( oss.str() ); } } // Self-transpose of a 5x3 matrix { blaze::HybridMatrix<int,5UL,5UL,blaze::columnMajor> mat( 5UL, 3UL, 0 ); mat(0,0) = 1; mat(0,2) = 6; mat(1,1) = 4; mat(2,0) = 2; mat(2,2) = 7; mat(3,1) = 5; mat(4,0) = 3; mat(4,2) = 8; mat.transpose(); checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 8UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 0 || mat(0,2) != 2 || mat(0,3) != 0 || mat(0,4) != 3 || mat(1,0) != 0 || mat(1,1) != 4 || mat(1,2) != 0 || mat(1,3) != 5 || mat(1,4) != 0 || mat(2,0) != 6 || mat(2,1) != 0 || mat(2,2) != 7 || mat(2,3) != 0 || mat(2,4) != 8 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 0 2 0 3 )\n( 0 4 0 5 0 )\n( 6 0 7 0 8 )\n"; throw std::runtime_error( oss.str() ); } } } { test_ = "Column-major self-transpose via trans()"; // Self-transpose of a 3x5 matrix { blaze::HybridMatrix<int,5UL,5UL,blaze::columnMajor> mat( 3UL, 5UL, 0 ); mat(0,0) = 1; mat(0,2) = 2; mat(0,4) = 3; mat(1,1) = 4; mat(1,3) = 5; mat(2,0) = 6; mat(2,2) = 7; mat(2,4) = 8; mat = trans( mat ); checkRows ( mat, 5UL ); checkColumns ( mat, 3UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 8UL ); checkNonZeros( mat, 0UL, 3UL ); checkNonZeros( mat, 1UL, 2UL ); checkNonZeros( mat, 2UL, 3UL ); if( mat(0,0) != 1 || mat(0,1) != 0 || mat(0,2) != 6 || mat(1,0) != 0 || mat(1,1) != 4 || mat(1,2) != 0 || mat(2,0) != 2 || mat(2,1) != 0 || mat(2,2) != 7 || mat(3,0) != 0 || mat(3,1) != 5 || mat(3,2) != 0 || mat(4,0) != 3 || mat(4,1) != 0 || mat(4,2) != 8 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 0 6 )\n( 0 4 0 )\n( 2 0 7 )\n( 0 5 0 )\n( 3 0 8 )\n"; throw std::runtime_error( oss.str() ); } } // Self-transpose of a 5x3 matrix { blaze::HybridMatrix<int,5UL,5UL,blaze::columnMajor> mat( 5UL, 3UL, 0 ); mat(0,0) = 1; mat(0,2) = 6; mat(1,1) = 4; mat(2,0) = 2; mat(2,2) = 7; mat(3,1) = 5; mat(4,0) = 3; mat(4,2) = 8; mat = trans( mat ); checkRows ( mat, 3UL ); checkColumns ( mat, 5UL ); checkCapacity( mat, 15UL ); checkNonZeros( mat, 8UL ); checkNonZeros( mat, 0UL, 2UL ); checkNonZeros( mat, 1UL, 1UL ); checkNonZeros( mat, 2UL, 2UL ); checkNonZeros( mat, 3UL, 1UL ); checkNonZeros( mat, 4UL, 2UL ); if( mat(0,0) != 1 || mat(0,1) != 0 || mat(0,2) != 2 || mat(0,3) != 0 || mat(0,4) != 3 || mat(1,0) != 0 || mat(1,1) != 4 || mat(1,2) != 0 || mat(1,3) != 5 || mat(1,4) != 0 || mat(2,0) != 6 || mat(2,1) != 0 || mat(2,2) != 7 || mat(2,3) != 0 || mat(2,4) != 8 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Initialization failed\n" << " Details:\n" << " Result:\n" << mat << "\n" << " Expected result:\n( 1 0 2 0 3 )\n( 0 4 0 5 0 )\n( 6 0 7 0 8 )\n"; throw std::runtime_error( oss.str() ); } } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the \c swap() functionality of the HybridMatrix class template. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the \c swap() function of the HybridMatrix class template. // In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testSwap() { //===================================================================================== // Row-major matrix tests //===================================================================================== { test_ = "Row-major HybridMatrix swap"; blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat1( 3UL, 2UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = 0; mat1(1,1) = 3; mat1(2,0) = 4; mat1(2,1) = 0; blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat2( 2UL, 3UL ); mat2(0,0) = 6; mat2(0,1) = 5; mat2(0,2) = 4; mat2(1,0) = 3; mat2(1,1) = 2; mat2(1,2) = 1; swap( mat1, mat2 ); checkRows ( mat1, 2UL ); checkColumns ( mat1, 3UL ); checkCapacity( mat1, 6UL ); checkNonZeros( mat1, 6UL ); checkNonZeros( mat1, 0UL, 3UL ); checkNonZeros( mat1, 1UL, 3UL ); if( mat1(0,0) != 6 || mat1(0,1) != 5 || mat1(0,2) != 4 || mat1(1,0) != 3 || mat1(1,1) != 2 || mat1(1,2) != 1 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Swapping the first matrix failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n( 6 5 4 )\n( 3 2 1 )\n"; throw std::runtime_error( oss.str() ); } checkRows ( mat2, 3UL ); checkColumns ( mat2, 2UL ); checkCapacity( mat2, 4UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 1UL ); checkNonZeros( mat2, 2UL, 1UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(1,0) != 0 || mat2(1,1) != 3 || mat2(2,0) != 4 || mat2(2,1) != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Swapping the second matrix failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 )\n( 0 3 )\n( 4 0 )\n"; throw std::runtime_error( oss.str() ); } } //===================================================================================== // Column-major matrix tests //===================================================================================== { test_ = "Column-major HybridMatrix swap"; blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat1( 3UL, 2UL ); mat1(0,0) = 1; mat1(0,1) = 2; mat1(1,0) = 0; mat1(1,1) = 3; mat1(2,0) = 4; mat1(2,1) = 0; blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat2( 2UL, 3UL ); mat2(0,0) = 6; mat2(0,1) = 5; mat2(0,2) = 4; mat2(1,0) = 3; mat2(1,1) = 2; mat2(1,2) = 1; swap( mat1, mat2 ); checkRows ( mat1, 2UL ); checkColumns ( mat1, 3UL ); checkCapacity( mat1, 6UL ); checkNonZeros( mat1, 6UL ); checkNonZeros( mat1, 0UL, 2UL ); checkNonZeros( mat1, 1UL, 2UL ); checkNonZeros( mat1, 2UL, 2UL ); if( mat1(0,0) != 6 || mat1(0,1) != 5 || mat1(0,2) != 4 || mat1(1,0) != 3 || mat1(1,1) != 2 || mat1(1,2) != 1 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Swapping the first matrix failed\n" << " Details:\n" << " Result:\n" << mat1 << "\n" << " Expected result:\n( 6 5 4 )\n( 3 2 1 )\n"; throw std::runtime_error( oss.str() ); } checkRows ( mat2, 3UL ); checkColumns ( mat2, 2UL ); checkCapacity( mat2, 4UL ); checkNonZeros( mat2, 4UL ); checkNonZeros( mat2, 0UL, 2UL ); checkNonZeros( mat2, 1UL, 2UL ); if( mat2(0,0) != 1 || mat2(0,1) != 2 || mat2(1,0) != 0 || mat2(1,1) != 3 || mat2(2,0) != 4 || mat2(2,1) != 0 ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Swapping the second matrix failed\n" << " Details:\n" << " Result:\n" << mat2 << "\n" << " Expected result:\n( 1 2 )\n( 0 3 )\n( 4 0 )\n"; throw std::runtime_error( oss.str() ); } } } //************************************************************************************************* //************************************************************************************************* /*!\brief Test of the \c isDefault() function with the HybridMatrix class template. // // \return void // \exception std::runtime_error Error detected. // // This function performs a test of the \c isDefault() function with the HybridMatrix class // template. In case an error is detected, a \a std::runtime_error exception is thrown. */ void ClassTest::testIsDefault() { using blaze::isDefault; //===================================================================================== // Row-major matrix tests //===================================================================================== { test_ = "Row-major isDefault() function"; // isDefault with 0x0 matrix { blaze::HybridMatrix<int,3UL,3UL,blaze::rowMajor> mat; if( isDefault( mat ) != true ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix:\n" << mat << "\n"; throw std::runtime_error( oss.str() ); } } // isDefault with default matrix { blaze::HybridMatrix<int,2UL,3UL,blaze::rowMajor> mat( 2UL, 3UL, 0 ); if( isDefault( mat(0,1) ) != true ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix element: " << mat(0,1) << "\n"; throw std::runtime_error( oss.str() ); } if( isDefault( mat ) != false ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix:\n" << mat << "\n"; throw std::runtime_error( oss.str() ); } } // isDefault with non-default matrix { blaze::HybridMatrix<int,3UL,2UL,blaze::rowMajor> mat( 3UL, 2UL, 0 ); mat(0,1) = 1; if( isDefault( mat(0,1) ) != false ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix element: " << mat(0,1) << "\n"; throw std::runtime_error( oss.str() ); } if( isDefault( mat ) != false ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix:\n" << mat << "\n"; throw std::runtime_error( oss.str() ); } } } //===================================================================================== // Column-major matrix tests //===================================================================================== { test_ = "Column-major isDefault() function"; // isDefault with 0x0 matrix { blaze::HybridMatrix<int,3UL,3UL,blaze::columnMajor> mat; if( isDefault( mat ) != true ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix:\n" << mat << "\n"; throw std::runtime_error( oss.str() ); } } // isDefault with default matrix { blaze::HybridMatrix<int,2UL,3UL,blaze::columnMajor> mat( 2UL, 3UL, 0 ); if( isDefault( mat(0,1) ) != true ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix element: " << mat(0,1) << "\n"; throw std::runtime_error( oss.str() ); } if( isDefault( mat ) != false ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix:\n" << mat << "\n"; throw std::runtime_error( oss.str() ); } } // isDefault with non-default matrix { blaze::HybridMatrix<int,3UL,2UL,blaze::columnMajor> mat( 3UL, 2UL, 0 ); mat(1,0) = 1; if( isDefault( mat(1,0) ) != false ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix element: " << mat(1,0) << "\n"; throw std::runtime_error( oss.str() ); } if( isDefault( mat ) != false ) { std::ostringstream oss; oss << " Test: " << test_ << "\n" << " Error: Invalid isDefault evaluation\n" << " Details:\n" << " Matrix:\n" << mat << "\n"; throw std::runtime_error( oss.str() ); } } } } //************************************************************************************************* } // namespace hybridmatrix } // namespace mathtest } // namespace blazetest //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running HybridMatrix class test..." << std::endl; try { RUN_HYBRIDMATRIX_CLASS_TEST; } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during HybridMatrix class test:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
[ "klaus.iglberger@gmail.com" ]
klaus.iglberger@gmail.com