blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
c630574f57080c2a052a902e79acb61787d90dcf
9e78c44549c47c60302aebfd662dd481620dfb1e
/shoppingtask.cpp
d75ac2c7d4101957739fc4e256c095905eb51475
[]
no_license
yujiejiang/todolistapp
f68b777c0231fcdf4225cb0c235498a15cd15db4
b9d30ce9a73668bdee2766637f8ed524a39b4a7a
refs/heads/master
2020-03-14T01:05:23.963618
2018-04-28T04:13:20
2018-04-28T04:13:20
131,370,492
0
0
null
2018-04-28T04:39:46
2018-04-28T03:51:03
C++
UTF-8
C++
false
false
974
cpp
shoppingtask.cpp
// // shoppingtask.cpp // todolist // // Created by YuJie Jiang on 4/13/18. // Copyright © 2018 YuJie Jiang. All rights reserved. // //using vector for shooping task is because there might be many items in the shopping task, vector should holds better. #ifndef shoppingtask_cpp #define shoppingtask_cpp #include "shoppingtask.hpp" #include<iostream> #include<fstream> #include<vector> using namespace std; /* void shoppingtask::outputdetail(std::ostream &out){ out<<" items to purchase: "; for(int i=0;i<d_items.size();++i){ out<<" "<<d_items[i]<<" "; } } void shoppingtask::fileoutput(std::ofstream& out){ for(int i=0; i<d_items.size();++i){ out << "|" << d_items[i]; } out<<" "; }*/ void shoppingtask::itemlist(std::ostream &out){ for(int i = 0; i < d_items.size(); ++i){ out << " " << d_items[i]; } } #endif
0fddf3100e84be4f607da2f2189b6edde01e8ed9
776f5892f1395bb8d30731a60466e4c756a44c8c
/contests/abc219/abc219_g/main.cc
a3a0267bf3a7e6309d4a252d91063a14ca1b78d7
[]
no_license
kkishi/atcoder
fae494af4b47a9f39f05e7536e93d5c4dd21555b
f21d22095699dbf064c0d084a5ce5a09a252dc6b
refs/heads/master
2023-08-31T18:37:13.293499
2023-08-27T21:33:43
2023-08-27T21:33:43
264,760,383
0
0
null
2023-03-10T05:24:07
2020-05-17T21:30:14
C++
UTF-8
C++
false
false
763
cc
main.cc
#include <bits/stdc++.h> #include "atcoder.h" #include "graph.h" void Main() { ints(n, m, q); Graph g(n); g.Read(m); V<bool> hi(n); rep(i, n) hi[i] = sz(g[i]) * sz(g[i]) > n; VV<int> G(n); rep(i, n) each(e, g[i]) if (hi[e]) G[i].pb(e); V<tuple<int, int>> eager(n), lazy(n); rep(i, n) { eager[i] = {-1, i + 1}; lazy[i] = {-2, i + 1}; } rep(i, q) { ints(x); --x; tuple<int, int> c = eager[x]; each(e, G[x]) chmax(c, lazy[e]); int y = get<1>(c); eager[x] = {i + 1, y}; lazy[x] = {i + 1, y}; if (!hi[x]) each(e, g[x]) eager[e] = {i + 1, y}; } V<int> ans(n); rep(i, n) { int x = i; tuple<int, int> c = eager[x]; each(e, G[x]) chmax(c, lazy[e]); ans[i] = get<1>(c); } wt(ans); }
05c0843addeec700712043d2fd7b6c1d60f4cac6
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/third_party/blink/renderer/core/frame/remote_frame.h
9585ac3d50210b8c3e4ffb0280b489dd72e7044f
[ "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0", "LGPL-2.0-only", "BSD-2-Clause", "LGPL-2.1-only", "LicenseRef-scancode-warranty-disclaimer", "GPL-2.0-only", "LicenseRef-scancode-other-copyleft", "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
13,983
h
remote_frame.h
// Copyright 2014 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REMOTE_FRAME_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REMOTE_FRAME_H_ #include "base/task/single_thread_task_runner.h" #include "components/viz/common/surfaces/parent_local_surface_id_allocator.h" #include "services/network/public/mojom/web_sandbox_flags.mojom-blink-forward.h" #include "third_party/blink/public/common/frame/frame_visual_properties.h" #include "third_party/blink/public/mojom/frame/frame_owner_properties.mojom-blink-forward.h" #include "third_party/blink/public/mojom/frame/remote_frame.mojom-blink.h" #include "third_party/blink/public/mojom/input/focus_type.mojom-blink-forward.h" #include "third_party/blink/public/mojom/scroll/scroll_into_view_params.mojom-blink.h" #include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom-blink-forward.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/execution_context/remote_security_context.h" #include "third_party/blink/renderer/core/frame/child_frame_compositor.h" #include "third_party/blink/renderer/core/frame/frame.h" #include "third_party/blink/renderer/core/frame/remote_frame_view.h" #include "third_party/blink/renderer/platform/mojo/heap_mojo_associated_receiver.h" #include "third_party/blink/renderer/platform/mojo/heap_mojo_associated_remote.h" #include "third_party/blink/renderer/platform/wtf/casting.h" namespace cc { class Layer; } namespace viz { class FrameSinkId; } namespace blink { class ChildFrameCompositingHelper; class LocalFrame; class RemoteFrameClient; class WebFrameWidget; struct BlinkTransferableMessage; struct FrameLoadRequest; // A RemoteFrame is a frame that is possibly hosted outside this process. class CORE_EXPORT RemoteFrame final : public Frame, public ChildFrameCompositor, public mojom::blink::RemoteMainFrame, public mojom::blink::RemoteFrame { public: // Returns the RemoteFrame for the given |frame_token|. static RemoteFrame* FromFrameToken(const RemoteFrameToken& frame_token); // For a description of |inheriting_agent_factory| go see the comment on the // Frame constructor. RemoteFrame( RemoteFrameClient*, Page&, FrameOwner*, Frame* parent, Frame* previous_sibling, FrameInsertType insert_type, const RemoteFrameToken& frame_token, WindowAgentFactory* inheriting_agent_factory, WebFrameWidget* ancestor_widget, const base::UnguessableToken& devtools_frame_token, mojo::PendingAssociatedRemote<mojom::blink::RemoteFrameHost> remote_frame_host, mojo::PendingAssociatedReceiver<mojom::blink::RemoteFrame> receiver); ~RemoteFrame() override; // Frame overrides: void Trace(Visitor*) const override; void Navigate(FrameLoadRequest&, WebFrameLoadType) override; const RemoteSecurityContext* GetSecurityContext() const override; bool DetachDocument() override; void CheckCompleted() override; bool ShouldClose() override; void HookBackForwardCacheEviction() override {} void RemoveBackForwardCacheEviction() override {} void SetTextDirection(base::i18n::TextDirection) override {} void SetIsInert(bool) override; void SetInheritedEffectiveTouchAction(TouchAction) override; void DidFocus() override; void AddResourceTimingFromChild( mojom::blink::ResourceTimingInfoPtr timing) override; bool IsAdFrame() const override; // ChildFrameCompositor: const scoped_refptr<cc::Layer>& GetCcLayer() override; void AdvanceFocus(mojom::blink::FocusType, LocalFrame* source); void SetView(RemoteFrameView*); void CreateView(); void ForwardPostMessage( BlinkTransferableMessage, LocalFrame* source_frame, scoped_refptr<const SecurityOrigin> source_security_origin, scoped_refptr<const SecurityOrigin> target_security_origin); // Whether the RemoteFrame is bound to a browser-side counterpart or not. // It's possible for a RemoteFrame to be a placeholder main frame for a new // Page, to be replaced by a provisional main LocalFrame that will do a // LocalFrame <-> LocalFrame swap with the previous Page's main frame. See // comments in `AgentSchedulingGroup::CreateWebView()` for more details. // For those placeholder RemoteFrame, there won't be a browser-side // counterpart, so we shouldn't try to use the RemoteFrameHost. Method calls // that might trigger on a Page that hasn't committed yet (e.g. Detach()) // should gate calls `GetRemoteFrameHostRemote()` with this function first. bool IsRemoteFrameHostRemoteBound(); mojom::blink::RemoteFrameHost& GetRemoteFrameHostRemote(); RemoteFrameView* View() const override; RemoteFrameClient* Client() const; bool IsIgnoredForHitTest() const; void DidChangeVisibleToHitTesting() override; void SetReplicatedPermissionsPolicyHeader( const ParsedPermissionsPolicy& parsed_header); void SetReplicatedSandboxFlags(network::mojom::blink::WebSandboxFlags); void SetInsecureRequestPolicy(mojom::blink::InsecureRequestPolicy); void FrameRectsChanged(const gfx::Size& local_frame_size, const gfx::Rect& screen_space_rect); void InitializeFrameVisualProperties(const FrameVisualProperties& properties); // If 'propagate' is true, updated properties will be sent to the browser. // Returns true if visual properties have changed. bool SynchronizeVisualProperties(bool propagate = true); void ResendVisualProperties(); void SetViewportIntersection(const mojom::blink::ViewportIntersectionState&); void UpdateCompositedLayerBounds(); // Called when the local root's screen infos change. void DidChangeScreenInfos(const display::ScreenInfos& screen_info); // Called when the main frame's zoom level is changed and should be propagated // to the remote's associated view. void ZoomLevelChanged(double zoom_level); // Called when the local root's window segments change. void DidChangeRootWindowSegments( const std::vector<gfx::Rect>& root_widget_window_segments); // Called when the local page scale factor changed. void PageScaleFactorChanged(float page_scale_factor, bool is_pinch_gesture_active); // Called when the local root's visible viewport changes size. void DidChangeVisibleViewportSize(const gfx::Size& visible_viewport_size); // Called when the local root's capture sequence number has changed. void UpdateCaptureSequenceNumber(uint32_t sequence_number); // Called when the cursor accessibility scale factor changed. void CursorAccessibilityScaleFactorChanged(float scale_factor); const String& UniqueName() const { return unique_name_; } const FrameVisualProperties& GetPendingVisualPropertiesForTesting() const { return pending_visual_properties_; } // blink::mojom::RemoteFrame overrides: void WillEnterFullscreen(mojom::blink::FullscreenOptionsPtr) override; void EnforceInsecureNavigationsSet(const WTF::Vector<uint32_t>& set) override; void SetFrameOwnerProperties( mojom::blink::FrameOwnerPropertiesPtr properties) override; void EnforceInsecureRequestPolicy( mojom::blink::InsecureRequestPolicy policy) override; void SetReplicatedOrigin( const scoped_refptr<const SecurityOrigin>& origin, bool is_potentially_trustworthy_unique_origin) override; void SetReplicatedIsAdFrame(bool is_ad_frame) override; void SetReplicatedName(const String& name, const String& unique_name) override; void DispatchLoadEventForFrameOwner() override; void Collapse(bool collapsed) final; void Focus() override; void SetHadStickyUserActivationBeforeNavigation(bool value) override; void SetNeedsOcclusionTracking(bool needs_tracking) override; void BubbleLogicalScroll(mojom::blink::ScrollDirection direction, ui::ScrollGranularity granularity) override; void UpdateUserActivationState( mojom::blink::UserActivationUpdateType update_type, mojom::blink::UserActivationNotificationType notification_type) override; void SetEmbeddingToken( const base::UnguessableToken& embedding_token) override; void SetPageFocus(bool is_focused) override; void RenderFallbackContent() override; void ScrollRectToVisible( const gfx::RectF& rect_to_scroll, mojom::blink::ScrollIntoViewParamsPtr params) override; void DidStartLoading() override; void DidStopLoading() override; void IntrinsicSizingInfoOfChildChanged( mojom::blink::IntrinsicSizingInfoPtr sizing_info) override; void DidSetFramePolicyHeaders( network::mojom::blink::WebSandboxFlags, const WTF::Vector<ParsedPermissionsPolicyDeclaration>&) override; // Updates the snapshotted policy attributes (sandbox flags and permissions // policy container policy) in the frame's FrameOwner. This is used when this // frame's parent is in another process and it dynamically updates this // frame's sandbox flags or container policy. The new policy won't take effect // until the next navigation. void DidUpdateFramePolicy(const FramePolicy& frame_policy) override; void UpdateOpener( const absl::optional<blink::FrameToken>& opener_frame_token) override; void DetachAndDispose() override; void EnableAutoResize(const gfx::Size& min_size, const gfx::Size& max_size) override; void DisableAutoResize() override; void DidUpdateVisualProperties( const cc::RenderFrameMetadata& metadata) override; void SetFrameSinkId(const viz::FrameSinkId& frame_sink_id) override; void ChildProcessGone() override; void CreateRemoteChild( const RemoteFrameToken& token, const absl::optional<FrameToken>& opener_frame_token, mojom::blink::TreeScopeType tree_scope_type, mojom::blink::FrameReplicationStatePtr replication_state, mojom::blink::FrameOwnerPropertiesPtr owner_properties, bool is_loading, const base::UnguessableToken& devtools_frame_token, mojom::blink::RemoteFrameInterfacesFromBrowserPtr remote_frame_interfaces) override; void CreateRemoteChildren( Vector<mojom::blink::CreateRemoteChildParamsPtr> params) override; // Called only when this frame has a local frame owner. gfx::Size GetOutermostMainFrameSize() const override; gfx::Point GetOutermostMainFrameScrollPosition() const override; void SetOpener(Frame* opener) override; // blink::mojom::RemoteMainFrame overrides: // // Use to transfer TextAutosizer state from the local main frame renderer to // remote main frame renderers. void UpdateTextAutosizerPageInfo( mojom::blink::TextAutosizerPageInfoPtr page_info) override; // Indicate that this frame was attached as a MainFrame. void WasAttachedAsRemoteMainFrame( mojo::PendingAssociatedReceiver<mojom::blink::RemoteMainFrame> main_frame); RemoteFrameToken GetRemoteFrameToken() const { return GetFrameToken().GetAs<RemoteFrameToken>(); } const viz::LocalSurfaceId& GetLocalSurfaceId() const; viz::FrameSinkId GetFrameSinkId(); void SetCcLayerForTesting(scoped_refptr<cc::Layer>, bool is_surface_layer); // Whether a navigation should replace the current history entry or not. bool NavigationShouldReplaceCurrentHistoryEntry( WebFrameLoadType frame_load_type) const; private: // Frame protected overrides: bool DetachImpl(FrameDetachType type) override; // ChildFrameCompositor: void SetCcLayer(scoped_refptr<cc::Layer> layer, bool is_surface_layer) override; SkBitmap* GetSadPageBitmap() override; // Intentionally private to prevent redundant checks when the type is // already RemoteFrame. bool IsLocalFrame() const override { return false; } bool IsRemoteFrame() const override { return true; } // Returns false if detaching child frames reentrantly detached `this`. bool DetachChildren(); void ApplyReplicatedPermissionsPolicyHeader(); void RecordSentVisualProperties(); Member<RemoteFrameView> view_; RemoteSecurityContext security_context_; absl::optional<blink::FrameVisualProperties> sent_visual_properties_; blink::FrameVisualProperties pending_visual_properties_; scoped_refptr<cc::Layer> cc_layer_; bool is_surface_layer_ = false; ParsedPermissionsPolicy permissions_policy_header_; String unique_name_; viz::FrameSinkId frame_sink_id_; std::unique_ptr<viz::ParentLocalSurfaceIdAllocator> parent_local_surface_id_allocator_; // The WebFrameWidget of the nearest ancestor local root. If the proxy has no // local root ancestor (eg it is a proxy of the root frame) then the pointer // is null. WebFrameWidget* ancestor_widget_; // True when the process rendering the child's frame contents has terminated // and ChildProcessGone() is called. bool remote_process_gone_ = false; // Will be nullptr when this RemoteFrame's parent is not a LocalFrame. std::unique_ptr<ChildFrameCompositingHelper> compositing_helper_; // Whether the frame is considered to be an ad frame by Ad Tagging. bool is_ad_frame_; HeapMojoAssociatedRemote<mojom::blink::RemoteFrameHost> remote_frame_host_remote_{nullptr}; HeapMojoAssociatedReceiver<mojom::blink::RemoteFrame, RemoteFrame> receiver_{ this, nullptr}; HeapMojoAssociatedReceiver<mojom::blink::RemoteMainFrame, RemoteFrame> main_frame_receiver_{this, nullptr}; scoped_refptr<base::SingleThreadTaskRunner> task_runner_; }; inline RemoteFrameView* RemoteFrame::View() const { return view_.Get(); } template <> struct DowncastTraits<RemoteFrame> { static bool AllowFrom(const Frame& frame) { return frame.IsRemoteFrame(); } }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_FRAME_REMOTE_FRAME_H_
4cb73f8ba5252056558d2440083372a1db3834a4
a3d6556180e74af7b555f8d47d3fea55b94bcbda
/chrome/browser/chromeos/extensions/login_screen/login_state/session_state_changed_event_dispatcher.h
38fa57b7d18982f02c56205ba047485cfb4ea713
[ "BSD-3-Clause" ]
permissive
chromium/chromium
aaa9eda10115b50b0616d2f1aed5ef35d1d779d6
a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c
refs/heads/main
2023-08-24T00:35:12.585945
2023-08-23T22:01:11
2023-08-23T22:01:11
120,360,765
17,408
7,102
BSD-3-Clause
2023-09-10T23:44:27
2018-02-05T20:55:32
null
UTF-8
C++
false
false
2,874
h
session_state_changed_event_dispatcher.h
// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_LOGIN_SCREEN_LOGIN_STATE_SESSION_STATE_CHANGED_EVENT_DISPATCHER_H_ #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_LOGIN_SCREEN_LOGIN_STATE_SESSION_STATE_CHANGED_EVENT_DISPATCHER_H_ #include "base/memory/raw_ptr.h" #include "chromeos/crosapi/mojom/login_state.mojom.h" #include "extensions/browser/browser_context_keyed_api_factory.h" #include "extensions/browser/event_router_factory.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" namespace content { class BrowserContext; } // namespace content namespace extensions { class EventRouter; // |SessionStateChangedEventDispatcher| dispatches changes in the session state // to extensions listening on the |loginState.onSessionStateChanged| event. class SessionStateChangedEventDispatcher : public crosapi::mojom::SessionStateChangedEventObserver, public BrowserContextKeyedAPI { public: // BrowserContextKeyedAPI implementation. static BrowserContextKeyedAPIFactory<SessionStateChangedEventDispatcher>* GetFactoryInstance(); void Shutdown() override; explicit SessionStateChangedEventDispatcher( content::BrowserContext* browser_context_); SessionStateChangedEventDispatcher( const SessionStateChangedEventDispatcher&) = delete; SessionStateChangedEventDispatcher& operator=( const SessionStateChangedEventDispatcher&) = delete; ~SessionStateChangedEventDispatcher() override; bool IsBoundForTesting(); void SetEventRouterForTesting(EventRouter* event_router); // crosapi::mojom::SessionStateChangedEventObserver: void OnSessionStateChanged(crosapi::mojom::SessionState state) override; private: // Needed for BrowserContextKeyedAPI implementation. friend class BrowserContextKeyedAPIFactory< SessionStateChangedEventDispatcher>; // BrowserContextKeyedAPI implementation. static const char* service_name() { return "SessionStateChangedEventDispatcher"; } static const bool kServiceIsNULLWhileTesting = true; raw_ptr<content::BrowserContext, DanglingUntriaged> browser_context_; raw_ptr<EventRouter, DanglingUntriaged> event_router_; // Receives mojo messages from ash. mojo::Receiver<crosapi::mojom::SessionStateChangedEventObserver> receiver_{ this}; }; template <> struct BrowserContextFactoryDependencies<SessionStateChangedEventDispatcher> { static void DeclareFactoryDependencies( BrowserContextKeyedAPIFactory<SessionStateChangedEventDispatcher>* factory) { factory->DependsOn(EventRouterFactory::GetInstance()); } }; } // namespace extensions #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_LOGIN_SCREEN_LOGIN_STATE_SESSION_STATE_CHANGED_EVENT_DISPATCHER_H_
022fa74a2b34f766e7b72d8a3d88a8269afb8114
0c50afa0160eefe851d199e6d35ee86a474fe43e
/1095.cpp
7cb88f99cc45d1f4f49e187d15427e3ad68657c8
[]
no_license
Disposrestfully/BZOJ
11199e322232c2ab54735fc6d7e5031e266bfc9e
07f17f7f78cff02a95d201ea5d3768d5cc48bbc5
refs/heads/master
2020-04-13T04:13:34.813219
2019-06-16T02:26:59
2019-06-16T02:26:59
162,955,126
0
0
null
null
null
null
UTF-8
C++
false
false
3,577
cpp
1095.cpp
#include<cstdio> #include<algorithm> #include<cstring> #include<vector> #include<map> #include<queue> #include<cmath> #define y1 Y1 #define read() Re.Read() #define lowbit(i) i&(-i) using namespace std; const int N=5e5+5; const int inf=1e9; struct Readint{ char buffer[1<<15],*S,*T; inline char Get_Char(){ if(S==T){ T=(S=buffer)+fread(buffer,1,1<<15,stdin); if(S==T) return EOF; } return *S++; } int Read(){ char c; int re=0; for (c=Get_Char();c<'0'||c>'9';c=Get_Char()){ if (c==EOF) return -1; } while(c>='0'&&c<='9') re=(re<<1)+(re<<3)+(c-'0'),c=Get_Char(); return re; } }Re; namespace print{ static const int BUF=50000000; char buf[BUF],*h=buf; inline void put(char ch){ h==buf+BUF?(fwrite(buf,1,BUF,stdout),h=buf):0; *h++=ch; } inline void putint(int num){ static char _buf[30]; sprintf(_buf,"%d",num); for (char *s=_buf;*s;s++)put(*s); } inline void finish(){ fwrite(buf,1,h-buf,stdout); } }; int p[N]; struct node{ int l1,l2,r1,r2,c1,c2,dis; void val(int x){ c1=c2=0; l1=l2=r1=r2=dis=-inf; if(x==-1) c2=1; else if(x==-2) c1=1; else if(p[x]==1) l1=l2=r1=r2=0; } void pushup(node &a,node &b){ c1=a.c1+max(0,b.c1-a.c2); c2=b.c2+max(0,a.c2-b.c1); dis=max(max(a.dis,b.dis),max(a.r1+b.l2,a.r2+b.l1)); l1=max(a.l1,max(b.l1-a.c2+a.c1,b.l2+a.c2+a.c1)); l2=max(a.l2,b.l2+a.c2-a.c1); r1=max(b.r1,max(a.r1-b.c1+b.c2,a.r2+b.c1+b.c2)); r2=max(b.r2,a.r2+b.c1-b.c2); } }s[N*3<<2]; int n,T,C=0; struct edge{ int next,to; }e[N<<1]; int head[N],cnt; void add(int u,int v){ e[++cnt].to=v; e[cnt].next=head[u]; head[u]=cnt; } int val[N*3],tot; int sz[N],f[N],pos[N],size[N],tim; void dfs(int x,int fa){ val[++tot]=-1; sz[x]=3; size[x]=1; val[++tot]=x; f[x]=tot; pos[x]=++tim; for (int i=head[x];i;i=e[i].next){ int y=e[i].to; if (y==fa) continue; dfs(y,x); sz[x]+=sz[y]; size[x]+=size[y]; } val[++tot]=-2; } void build(int x,int l,int r){ if (l==r){ s[x].val(val[l]); return; } int mid=(l+r)>>1; build(x<<1,l,mid); build((x<<1)|1,mid+1,r); s[x].pushup(s[x<<1],s[(x<<1)|1]); } int ans; vector<int>mer; void query(int x,int l,int r,int L,int R){ if (l>=L && r<=R){ mer.push_back(x); return; } int mid=(l+r)>>1; if (L<=mid) query(x<<1,l,mid,L,R); if (R>mid) query((x<<1)|1,mid+1,r,L,R); } void update(int x,int l,int r,int k){ if(l==r){ s[x].val(val[k]); return; } int mid=(l+r)>>1; if (k<=mid) update(x<<1,l,mid,k); else update((x<<1)|1,mid+1,r,k); s[x].pushup(s[x<<1],s[(x<<1)|1]); } int S[N]; void Add(int x,int k){ for (int i=x;i<=n;i+=lowbit(i)) S[i]+=k; } int sum(int x){ int res=0; for (int i=x;i>=1;i-=lowbit(i)) res+=S[i]; return res; } int Cnt; int main(){ //freopen("practice.in","r",stdin); //freopen("practice.out","w",stdout); n=read(); for (int i=1;i<n;++i){ int u=read(),v=read(); add(u,v);add(v,u); } for (int i=1;i<=n;++i) p[i]=1; dfs(1,0); build(1,1,tot); T=read(); while (T--){ char opt=0; while (opt!='C' && opt!='G') opt=Re.Get_Char(); if (opt=='G'){ //++C; // printf("%d\n",c); if (Cnt==0) print::putint(-1); else if (Cnt==1) print::put('0'); else print::putint(s[1].dis); print::put('\n'); }else{ int u=read(); if (p[u]==1) Add(pos[u],-1); else Add(pos[u],1); p[u]*=-1; Cnt+=p[u]; update(1,1,tot,f[u]); } } print::finish(); return 0; }
1edf1020a4909746cd8798e51c6bb542e8b58a89
6af8c27c35b601bb853e2502a438bf4e9b4e5175
/myZinx/stdout_channel.h
78f5af721aaf197d1d890508de96654f2296135b
[]
no_license
Czeslaw20/MyGameServer
c65ff523b801dfb113f48ffa66dd64bc157f8aa4
d80c7b8abaecbd591d33dc84d3872a3660159d3e
refs/heads/master
2022-12-17T23:49:40.055845
2020-09-26T15:50:53
2020-09-26T15:50:53
294,658,722
0
0
null
null
null
null
UTF-8
C++
false
false
426
h
stdout_channel.h
#pragma once #include "Ichannel.h" class stdout_channel : public Ichannel { public: stdout_channel(); virtual ~stdout_channel(); //继承 virtual std::string ReadFd() override; virtual void WriteFd(std::string _output) override; virtual int GetFd() override; virtual bool init() override; virtual void fini() override; virtual ZinxHandler *GetInputNextStage(ByteMsg *_byte) override; };
c84dda22525e258505a68a3afde0c49003588a00
69f640edd32d9b9e34b68a4dedcc0c9f97389825
/Code/main.cpp
ed21e37163caef54a64d7601e0a9fcc31d00da95
[]
no_license
VortexAstra/MMCRP
6e0920858833af6993511a1a55eb74454aceb4be
f3bc4a457478582331f3abf593ad8ba1fda70ef1
refs/heads/main
2023-03-19T02:06:48.709968
2021-03-17T15:16:08
2021-03-17T15:16:08
348,752,329
0
0
null
null
null
null
UTF-8
C++
false
false
3,398
cpp
main.cpp
#include <iostream> #include "mmsystem.hpp" int test = 1; double xl = 0, xr = 2, yl = 0, yr = 2; double k1(double x, double y) { switch (test) { case 1: return 1; case 2: return x + y; case 3: return x * x + y * y; case 4: return x * x + y * y; default: return 1; } } double k2(double x, double y) { switch (test) { case 1: return 1; case 2: return x + y; case 3: return x * x + y * y; case 4: return x * x + y * y; default: return 1; } } double f(double x, double y) { switch (test) { case 1: return 0; case 2: return -2; case 3: return -8 * x * x - 8 * y * y; case 4: return -12 * x * x * y * y - 2 * pow(y, 4) - 2 * pow(x, 4); default: return 1; } } double u(double x, double y) { switch (test) { case 1: return 1; case 2: return x + y; case 3: return x * x + y * y; case 4: return x * x * y * y; default: return 1; } } double xi1(double y) { switch (test) { case 1: return 1; case 2: return 2; case 3: return 3; case 4: return 4; default: return 1; } } double xi4(double x) { switch (test) { case 1: return 1; case 2: return 2; case 3: return 3; case 4: return 4; default: return 1; } } double mu1(double y) { switch (test) { case 1: return xi1(y) * u(xl, y); case 2: return xi1(y) * u(xl, y) - k1(xl, y); case 3: return xi1(y) * u(xl, y) - k1(xl, y) * 2 * xl; case 4: return xi1(y) * u(xl, y) - k1(xl, y) * 2 * xl * y * y; default: return 1; } } double mu2(double y) { switch (test) { case 1: return u(xr, y); case 2: return u(xr, y); case 3: return u(xr, y); case 4: return u(xr, y); default: return 1; } } double mu3(double x) { switch (test) { case 1: return u(x, yl); case 2: return u(x, yl); case 3: return u(x, yl); case 4: return u(x, yl); default: return 1; } } double mu4(double x) { switch (test) { case 1: return xi4(x) * u(x, yr); case 2: return xi4(x) * u(x, yr) + k2(x, yr); case 3: return xi4(x) * u(x, yr) + k2(x, yr) * 2 * yr; case 4: return xi4(x) * u(x, yr) + k2(x, yr) * 2 * yr * x * x; default: return 1; } } int main() { bool bools[2] = { true, false }; MainSystem mainSystem; double lastErr[2], currErr[2]; for (test = 1; test < 5; test++) { int Nr = 4, Nz = 4; for (int i = 0; i < 7; i++) { printf("%d\t%d\t%d\t", Nr, Nz, Nr * Nz); for (int b = 0; b < 2; b++) { mainSystem.init(xl, xr, yl, yr, Nr, Nz, k1, k2, f, mu1, mu2, mu3, mu4, xi1, xi4); mainSystem.printInfo = false; mainSystem.build(); mainSystem.build_L(); printf("%d\t", mainSystem.solve(10e-7, bools[b])); mainSystem.finish(); currErr[b] = mainSystem.compare(u); printf("%10.4e\t", currErr[b]); if (test > 2) { if (i > 0) printf("%5.4f\t", lastErr[b] / currErr[b]); else printf("-\t"); lastErr[b] = currErr[b]; } } printf("\n"); Nr *= 2; Nz *= 2; } printf("\n\n"); } return 0; }
3680f361b289251f46bcba65aae5efd6e1aef9c3
29c07f21a2ea2aa1a912207a6ac5fbf8396df2ec
/cnn/error_layer_test.cc
81777feefe55897a5d60b7143d98a9b1d68f1e39
[]
no_license
gaborfeher/imgrec
900871a6ebfae878a5fe7acd0ffe59c83297b61f
7917a4bea0effb392a29e7adb1ff2d97db2c7e54
refs/heads/master
2021-08-22T14:30:46.007207
2017-11-30T11:27:50
2017-11-30T11:27:50
104,206,572
0
0
null
null
null
null
UTF-8
C++
false
false
1,628
cc
error_layer_test.cc
#include <functional> #include <iostream> #include <vector> #include "cnn/l2_error_layer.h" #include "cnn/layer_stack.h" #include "cnn/layer_test_base.h" #include "cnn/softmax_error_layer.h" #include "linalg/matrix.h" #include "linalg/matrix_test_util.h" #include "gtest/gtest.h" TEST(ErrorLayerTest, L2GradientAt0) { L2ErrorLayer error_layer; error_layer.SetExpectedValue(Matrix(1, 3, 1, {-0.5f, 4.2f, -1.0f})); // Get gradient with a forward+backward pass (expecting zero gradient here): error_layer.Forward(Matrix(1, 3, 1, {-0.5f, 4.2f, -1.0f})); error_layer.Backward(Matrix()); ExpectMatrixEquals( Matrix(1, 3, 1, { 0.0f, 0.0f, 0.0f }), error_layer.input_gradient()); } TEST(ErrorLayerTest, L2Gradient) { std::shared_ptr<L2ErrorLayer> error_layer = std::make_shared<L2ErrorLayer>(); error_layer->SetExpectedValue(Matrix(1, 3, 1, {-0.5f, 4.2f, -1.0f})); std::shared_ptr<LayerStack> stack = std::make_shared<LayerStack>(); stack->AddLayer(error_layer); Matrix input(1, 3, 1, {1.0f, 4.0f, 0.0f}); InputGradientCheck( stack, input, 0.001f, 0.1f); } TEST(ErrorLayerTest, SoftmaxGradient) { std::shared_ptr<SoftmaxErrorLayer> error_layer = std::make_shared<SoftmaxErrorLayer>(); error_layer->SetExpectedValue(Matrix(1, 3, 1, { 0.0f, 1.0f, 2.0f})); std::shared_ptr<LayerStack> stack = std::make_shared<LayerStack>(); stack->AddLayer(error_layer); Matrix input(3, 3, 1, { -2.0f, 1.0f, 1.0f, 1.0f, -1.0f, 2.0f, 0.5f, -2.0f, 3.0f }); InputGradientCheck( stack, input, 0.001f, 1.0f); }
468b3a83e771aa4f0115cd6ffa8ab63f89fd6b2d
a9e224a95e42a9a5eddddfada7843e518d75408f
/1020/main.cpp
92240511026110f6929a0c3bf0611ed10b62ae23
[]
no_license
WoodJohn/Algorithm-Practice
6b39619ce34faf34be48d8e928a729f8739c6e9a
4e7f6e3b090d3492ed53d479d0672830912eca5f
refs/heads/master
2020-04-27T21:39:30.288108
2012-11-11T12:03:22
2012-11-11T12:03:22
4,083,583
1
0
null
null
null
null
UTF-8
C++
false
false
1,403
cpp
main.cpp
#include <iostream> #include <string.h> using namespace std; int t; int w[41]; int c[11]; int n; int s; bool dfs(int a) { if (a == n) { return true; } int p; for (int i = 0; i < s; ++i) { if (w[i] < s) { p = i; break; } } for (int i = 10; i > 0; --i) { if (c[i] > 0 && p + i <= s && w[p] + i <= s) { int k; for (k = 0; k < i && w[p + k] + i <= s; ++k) { w[p + k] += i; } if (k == i) { --c[i]; if (dfs(a + 1)) return true; ++c[i]; } for (int pp = 0; pp < k; ++pp) { w[p + pp] -= i; } } } return false; } int main() { cin >> t; while (t--) { cin >> s >> n; int sum = 0; memset(c, 0, sizeof(c)); int a; for (int i = 0; i < n; ++i) { cin >> a; sum += a * a; ++c[a]; } bool ans = true; if (sum != s * s) { ans = false; } if (ans) { memset(w, 0, sizeof(w)); ans = dfs(0); } ans ? cout << "KHOOOOB!" << endl : cout << "HUTUTU!" << endl; } return 0; }
3593954c821ad457fa3d923664d89db74ac3f6c3
1ec64d7db5e2743fce201c87b3eb1e4feb5728be
/backup_till_6_5_21/3_5_21/FiFanZero2_22_4_21/ImpTimer.cpp
fb2797cf7cad7cca576c45aba92049a11f34decd
[]
no_license
Silverbullet069/TheMageRunner
8ff2764594fcd0746c551e4638a4aa0d67b36df9
65e279dc8306ffed867f7d3cb4f64bffd4db115a
refs/heads/master
2023-04-21T01:18:12.994871
2021-05-12T11:23:55
2021-05-12T11:23:55
361,590,266
0
0
null
null
null
null
UTF-8
C++
false
false
2,095
cpp
ImpTimer.cpp
#include "ImpTimer.h" #include "CommonFunction.h" ImpTimer::ImpTimer() { start_tick_ = 0; paused_tick_ = 0; is_paused_ = false; is_started_ = false; } ImpTimer::~ImpTimer() { } void ImpTimer::start() { //Set trang thai chay = true is_started_ = true; //Set trang thai tam dung = false is_paused_ = false; //Luu lai thoi gian chay start_tick_ = SDL_GetTicks(); } void ImpTimer::stop() { //Set trang thai chay = false is_started_ = false; //Set trang thai tam dung = false is_paused_ = false; //Set lai cac bien thoi gian start_tick_ = 0; paused_tick_ = 0; } //Tam dung dong ho void ImpTimer::paused() { //Neu dong ho dang chay va khong bi tam dung if(is_started_ == true && is_paused_ == false) { //Set trang thai tam dung = true is_paused_ = true; //Thoi gian tam dung dong ho //Bang thoi diem chuong trinh dang chay //Tru di thoi diem dong ho bat dau chay paused_tick_ = SDL_GetTicks() - start_tick_; //Reset lai start time start_tick_ = 0; } } //Huy tam dung dong ho void ImpTimer::unpaused() { //Neu dong ho dang chay va bi tam dung if(is_started_ == true && is_paused_ == true) { //Set trang thai tam dung = false is_paused_ = false; //Thoi gian huy tam dung dong ho, coi nhu thoi gian chay dong ho //Bang thoi diem chuong trinh hien tai dang chay //Tru di thoi diem ke tu luc dong ho bat dau tam dung start_tick_ = SDL_GetTicks() - paused_tick_; //Reset lai pause time paused_tick_ = 0; } } int ImpTimer::get_ticks() { //Neu dong ho dang chay if(is_started_ == true) { //Neu dong ho dang chay va bi tam dung if(is_paused_ == true) { //Lay gia tri thoi gian ke tu khi bi tam dung return paused_tick_; } else { //Lay gia tri thoi diem chuong trinh hien tai dang chay //Tru di thoi diem chay dong ho return SDL_GetTicks() - start_tick_; } } //Con khong, 0 return 0; }
6cd3f36184569613c97ee2eaee4c08ac4b5450f9
b99e3109c4f1830e7755f2e8029a713eef9d3978
/src/configuration/KlondikeConfiguration.hpp
fb60c54d9afbe4bb22599c89ea32ed7925cc904d
[]
no_license
vrcordoba/Klondike
01d632c0681cbd675ce965be1fd0035074ee2dc6
108d2b4232c0106b824adba3f70aab635b403d2a
refs/heads/master
2021-01-11T02:14:45.289106
2016-05-07T14:29:14
2016-05-07T14:29:14
71,004,256
0
0
null
null
null
null
UTF-8
C++
false
false
1,275
hpp
KlondikeConfiguration.hpp
#ifndef CONFIGURATION_KLONDIKECONFIGURATION_HPP_ #define CONFIGURATION_KLONDIKECONFIGURATION_HPP_ #include <list> #include <string> #include "DeckType.hpp" #include "ViewType.hpp" #include "PermanentMedium.hpp" namespace Configuration { class KlondikeConfiguration final { public: ~KlondikeConfiguration(); static KlondikeConfiguration& getInstance() { static KlondikeConfiguration instance; return instance; } KlondikeConfiguration(const KlondikeConfiguration&) = delete; KlondikeConfiguration& operator=(const KlondikeConfiguration&) = delete; DeckType::Type getDeckType() const; void setDeckType(DeckType::Type type); std::list<std::string> getDeckDescriptions() const; ViewType getViewType() const; Utils::PermanentMedium::Type getPermanentMediumType() const; private: KlondikeConfiguration(); std::list<std::string> readConfiguration() const; void interpretReadConfiguration(const std::list<std::string>& configurations); void setViewType(const std::string& configuration); void setSaverType(const std::string& configuration); const std::string CONFIGURATION_FILE = "klondikeConf"; DeckType deckTypeM; ViewType viewTypeM; Utils::PermanentMedium::Type permanentMediumTypeM; }; } #endif
87ff8893a783e428fa5634e4e7eedf44a3a8041d
b3e7da4b6c4e29bd7ab1544ea935e3e433f7d1c5
/DynamicPlugin/Plugins_Ui/interface/ITaihoServiceCore.h
5b38c6d5fad19505ff6d4d6bcb267f742be9591f
[]
no_license
yu-yang-halo/basePlugin
7e4c11713d87aa65bd5ad55c6ed3ea7fcca42592
b2569317eae7a6981e08dceb784ad3b464567c3e
refs/heads/master
2020-07-07T12:38:37.369377
2019-10-16T08:15:27
2019-10-16T08:15:27
203,350,238
0
0
null
null
null
null
UTF-8
C++
false
false
806
h
ITaihoServiceCore.h
#ifndef ITAIHOSERVICECORE_H #define ITAIHOSERVICECORE_H #include <QObject> #include "TaihoPluginInterface.h" /** * @brief The ITaohoServiceCore class * 平台系统接口 插件化接口 */ class ITaohoServiceCore :public QObject, public TaihoPluginInterface { Q_OBJECT Q_INTERFACES(TaihoPluginInterface) public: virtual ~ITaohoServiceCore(){} virtual neb::CJsonObject& GetMetaData() = 0; virtual void recMsgFromManager(TaihoPluginData data) = 0; virtual void sendMsgToManager(TaihoPluginData data) = 0; virtual void onPluginsDidLoaded() = 0; virtual void onPluginsWillUnLoad() = 0; }; #define ITaihoServiceCore_iid "com.taiho.core.ITaohoServiceCore" // 唯一标识符 Q_DECLARE_INTERFACE(ITaohoServiceCore,ITaihoServiceCore_iid) #endif // ITAIHOSERVICECORE_H
ccb4d9bc8c69d5acc381c5a9c0b5825fe1d019a2
2c8e6a2df865d1750512879a0bac0347faf3c79f
/A. Road To Zero.cpp
f6bfc54d526bd2105fba6e1f7c2f948a19ee942e
[]
no_license
Daydreamer008/Codeforces
ba1683b0943763a7664588fb6b25e5a45b8f425b
43f77bd1f1c8e78fc57f7024e33cad30f4fbb3af
refs/heads/main
2023-08-22T14:00:57.083432
2021-09-26T21:58:57
2021-09-26T21:58:57
322,061,524
0
1
null
2021-01-29T10:49:49
2020-12-16T17:58:09
C++
UTF-8
C++
false
false
1,019
cpp
A. Road To Zero.cpp
#include <bits/stdc++.h> using namespace std; #define endl "\n" #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector < vi > #define pii pair<int,int> #define pll pair<long long, long long> #define mod 1000000007 #define inf 1000000000000000001; #define mp(x,y) make_pair(x,y) #define mem(a,val) memset(a,val,sizeof(a)) #define asc(c) c.begin(),c.end() #define des(c) c.begin(),c.end(),greater<int>() #define pb push_back #define eb emplace_back #define f first #define s second void solve() { int t; cin>>t; while(t--) { ll x , y , a ,b; cin>>x>>y>>a>>b; if(x > y) { swap(x,y); } ll ans1 = 0, ans2 = 0; ans1 = x*a + y*a; ll z = y - x; ans2 = z*a + x * b; cout<<min(ans1,ans2)<<endl; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); solve(); return 0; }
0d9fdff1fae09c3baf3bfdf2c782148a686967cf
e926bede54cbddf08870036ae478124e0a6cec77
/include/jet/plane2.h
0c5572bb3a3a68cd359bfb41b2b7f3d0b5eec288
[ "MIT" ]
permissive
doyubkim/fluid-engine-dev
2d1228c78690191fba8ff2c107af1dd06212ca44
94c300ff5ad8a2f588e5e27e8e9746a424b29863
refs/heads/main
2023-08-14T08:04:43.513360
2022-07-09T06:24:41
2022-07-09T06:24:41
58,299,041
1,725
275
MIT
2022-07-09T06:24:41
2016-05-08T06:05:38
C++
UTF-8
C++
false
false
2,368
h
plane2.h
// Copyright (c) 2018 Doyub Kim // // I am making my contributions/submissions to this project solely in my // personal capacity and am not conveying any rights to any intellectual // property of any third parties. #ifndef INCLUDE_JET_PLANE2_H_ #define INCLUDE_JET_PLANE2_H_ #include <jet/surface2.h> namespace jet { //! //! \brief 2-D plane geometry. //! //! This class represents 2-D plane geometry which extends Surface2 by //! overriding surface-related queries. //! class Plane2 final : public Surface2 { public: class Builder; //! Plane normal. Vector2D normal = Vector2D(0, 1); //! Point that lies on the plane. Vector2D point; //! Constructs a plane that crosses (0, 0) with surface normal (0, 1). Plane2( const Transform2& transform = Transform2(), bool isNormalFlipped = false); //! Constructs a plane that cross \p point with surface normal \p normal. Plane2( const Vector2D& normal, const Vector2D& point, const Transform2& transform = Transform2(), bool isNormalFlipped = false); //! Copy constructor. Plane2(const Plane2& other); //! Returns true if bounding box can be defined. bool isBounded() const override; //! Returns builder fox Plane2. static Builder builder(); private: Vector2D closestPointLocal(const Vector2D& otherPoint) const override; bool intersectsLocal(const Ray2D& ray) const override; BoundingBox2D boundingBoxLocal() const override; Vector2D closestNormalLocal(const Vector2D& otherPoint) const override; SurfaceRayIntersection2 closestIntersectionLocal( const Ray2D& ray) const override; }; //! Shared pointer for the Plane2 type. typedef std::shared_ptr<Plane2> Plane2Ptr; //! //! \brief Front-end to create Plane2 objects step by step. //! class Plane2::Builder final : public SurfaceBuilderBase2<Plane2::Builder> { public: //! Returns builder with plane normal. Builder& withNormal(const Vector2D& normal); //! Returns builder with point on the plane. Builder& withPoint(const Vector2D& point); //! Builds Plane2. Plane2 build() const; //! Builds shared pointer of Plane2 instance. Plane2Ptr makeShared() const; private: Vector2D _normal{0, 1}; Vector2D _point{0, 0}; }; } // namespace jet #endif // INCLUDE_JET_PLANE2_H_
8acad3bcce2aae8bd04fcfa053d98ff0da11e239
565b0a88c0d6f8a71d42f919613a1d166889c8bb
/Code/Dynamic Programming/Codeforces 607A Chain Reaction (DP).cpp
dbb977b6853b4649cb6e33925e1d2a0a240409bc
[]
no_license
DaDaMrX/ACM
71d7347640e745ea30518762588f6a698722295b
603cff542027db7875bfc57d92c9cdaba1f82c80
refs/heads/master
2020-04-12T06:23:25.442550
2017-07-30T11:01:48
2017-07-30T11:01:48
62,130,184
3
0
null
null
null
null
UTF-8
C++
false
false
600
cpp
Codeforces 607A Chain Reaction (DP).cpp
#include <cstdio> #include <cstring> const int N = 1e6 + 1; bool pos[N]; int pow[N], dp[N]; int n, ans; int main() { scanf("%d", &n); memset(pos, false, sizeof(pos)); memset(pow, 0, sizeof(pow)); memset(dp, 0, sizeof(dp)); for (int i = 1; i <= n; i++) { int a, b; scanf("%d%d", &a, &b); pos[a] = true; pow[a] = b; } int ans = dp[0] = pos[0] ? 1 : 0; for (int i = 1; i < N; i++) { if (pos[i]) { if (i - pow[i] - 1 < 0) dp[i] = 1; else dp[i] = dp[i - pow[i] - 1] + 1; } else dp[i] = dp[i - 1]; if (dp[i] > ans) ans = dp[i]; } printf("%d\n", n - ans); return 0; }
34eec9cf00628d3e2ad0b2063ce9aed7a64724d1
678328ff5e7d80e31af75bcf9a29c061117a5208
/Scarab-Engine/Source/Lib/Math/Geometry/BoundingShapes/3D/BVAABox.inl
4ad352f69086ae87b74469c37336409e27fc8149
[]
no_license
SyGame-Engine-Team/SyGame-Engine
48ead0234e92ddae5096e0b00edfbbd0bb484291
1e2e9f174ca6a19394d50b03eb54a3d2bc2066b7
refs/heads/master
2021-01-10T15:05:24.457349
2015-09-29T21:55:15
2015-09-29T21:55:15
43,390,724
4
1
null
null
null
null
UTF-8
C++
false
false
15,626
inl
BVAABox.inl
///////////////////////////////////////////////////////////////////////////////// // File : Lib/Math/Geometry/BoundingShapes/3D/BVAABox.inl ///////////////////////////////////////////////////////////////////////////////// // Version : 1.0a // Began Code : 29/05/2010 // Status : Alpha // Portability : Any ///////////////////////////////////////////////////////////////////////////////// // Description : Bounding Volumes : Axis-Aligned Box ///////////////////////////////////////////////////////////////////////////////// // Part of Scarab-Engine, licensed under the // Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License // http://creativecommons.org/licenses/by-nc-nd/3.0/ ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // Known Bugs : ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // TBVAABox implementation template<typename Real> TBVAABox<Real>::TBVAABox(): TBoundingVolume<Real>(), m_vCenter(), m_vExtents() { m_vCenter = TVertex3<Real>::Null; m_vExtents = TVector3<Real>::Null; } template<typename Real> TBVAABox<Real>::TBVAABox( const TVertex3<Real> & vCenter, Real fRadius ): TBoundingVolume<Real>(), m_vCenter(), m_vExtents() { m_vCenter = vCenter; m_vExtents = TVector3<Real>( fRadius, fRadius, fRadius ); } template<typename Real> TBVAABox<Real>::TBVAABox( const TVertex3<Real> & vCenter, const TVector3<Real> & vExtents ): TBoundingVolume<Real>(), m_vCenter(), m_vExtents() { m_vCenter = vCenter; m_vExtents = vExtents; } template<typename Real> TBVAABox<Real>::TBVAABox( const TVertex3<Real> & vMin, const TVertex3<Real> & vMax ): TBoundingVolume<Real>(), m_vCenter(), m_vExtents() { m_vCenter.X = ( vMin.X + vMax.X ) * (Real)0.5f; m_vCenter.Y = ( vMin.Y + vMax.Y ) * (Real)0.5f; m_vCenter.Z = ( vMin.Z + vMax.Z ) * (Real)0.5f; m_vExtents = ( vMax - vMin ) * (Real)0.5f; } template<typename Real> TBVAABox<Real>::TBVAABox( const TVertex3<Real> * arrVertices, UInt iVertexCount ): TBoundingVolume<Real>(), m_vCenter(), m_vExtents() { m_vCenter = TVertex3<Real>::Null; m_vExtents = TVector3<Real>::Null; Compute( (const Byte *)arrVertices, iVertexCount, sizeof(TVertex3<Real>) ); } template<typename Real> TBVAABox<Real>::TBVAABox( const TBVAABox<Real> & rhs ): TBoundingVolume<Real>(), m_vCenter(), m_vExtents() { m_vCenter = rhs.m_vCenter; m_vExtents = rhs.m_vExtents; } template<typename Real> TBVAABox<Real>::~TBVAABox() { // nothing to do } template<typename Real> inline TBVAABox<Real> & TBVAABox<Real>::operator=( const TBVAABox<Real> & rhs ) { m_vCenter = rhs.m_vCenter; m_vExtents = rhs.m_vExtents; return (*this); } template<typename Real> inline Bool TBVAABox<Real>::operator==( const TBVAABox<Real> & rhs ) const { return ( (m_vCenter == rhs.m_vCenter) && (m_vExtents == rhs.m_vExtents) ); } template<typename Real> inline Bool TBVAABox<Real>::operator!=( const TBVAABox<Real> & rhs ) const { return ( (m_vCenter != rhs.m_vCenter) || (m_vExtents != rhs.m_vExtents) ); } template<typename Real> inline BoundingVolumeShape TBVAABox<Real>::GetShape() const { return BVSHAPE_AABOX; } template<typename Real> inline Bool TBVAABox<Real>::IsEmpty() const { return ( m_vExtents == TVector3<Real>::Null ); } template<typename Real> inline Real TBVAABox<Real>::GetVolume() const { return ( m_vExtents.X * m_vExtents.Y * m_vExtents.Z ) * (Real)8.0f; } template<typename Real> inline Real TBVAABox<Real>::GetSizeEstimation() const { TVector3<Real> vLengths = GetLengths(); return ( ( vLengths.X * vLengths.Y * vLengths.Z ) + ( vLengths.X + vLengths.Y + vLengths.Z ) ); } template<typename Real> inline const TVertex3<Real> & TBVAABox<Real>::GetCenter() const { return m_vCenter; } template<typename Real> inline const TVector3<Real> & TBVAABox<Real>::GetExtents() const { return m_vExtents; } template<typename Real> inline TVector3<Real> TBVAABox<Real>::GetLengths() const { return ( m_vExtents * (Real)2.0f ); } template<typename Real> inline TVertex3<Real> TBVAABox<Real>::GetMin() const { return ( m_vCenter - m_vExtents ); } template<typename Real> inline TVertex3<Real> TBVAABox<Real>::GetMax() const { return ( m_vCenter + m_vExtents ); } template<typename Real> Void TBVAABox<Real>::Compute( const Byte * pVertices, UInt iVertexCount, UInt iStride ) { TVector3<Real> vMin( (Real)SCALAR_INFINITE, (Real)SCALAR_INFINITE, (Real)SCALAR_INFINITE ); TVector3<Real> vMax( (Real)(-SCALAR_INFINITE), (Real)(-SCALAR_INFINITE), (Real)(-SCALAR_INFINITE) ); // Compute Min-Max along axes const TVertex3<Real> * pPosition; const Byte * pVertex = pVertices; for( UInt i = 0; i < iVertexCount; ++i ) { pPosition = (const TVertex3<Real> *)pVertex; if ( pPosition->X < vMin.X ) vMin.X = pPosition->X; if ( pPosition->X > vMax.X ) vMax.X = pPosition->X; if ( pPosition->Y < vMin.Y ) vMin.Y = pPosition->Y; if ( pPosition->Y > vMax.Y ) vMax.Y = pPosition->Y; if ( pPosition->Z < vMin.Z ) vMin.Z = pPosition->Z; if ( pPosition->Z > vMax.Z ) vMax.Z = pPosition->Z; pVertex += iStride; } // Convert to Center-Extent m_vCenter.X = ( vMin.X + vMax.X ) * (Real)0.5f; m_vCenter.Y = ( vMin.Y + vMax.Y ) * (Real)0.5f; m_vCenter.Z = ( vMin.Z + vMax.Z ) * (Real)0.5f; m_vExtents = ( vMax - vMin ) * (Real)0.5f; } template<typename Real> Void TBVAABox<Real>::Reset( const TVertex3<Real> & vCenter ) { m_vCenter = vCenter; m_vExtents = TVector3<Real>::Null; } template<typename Real> Void TBVAABox<Real>::Grow( const TVertex3<Real> & vVertex ) { // Update along each axis Real fMin, fMax; for( UInt i = 0; i < 3; ++i ) { fMin = ( m_vCenter[i] - m_vExtents[i] ); fMax = ( m_vCenter[i] + m_vExtents[i] ); if ( vVertex[i] < fMin ) { m_vCenter[i] = ( vVertex[i] + fMax ) * (Real)0.5f; m_vExtents[i] = ( m_vCenter[i] - vVertex[i] ); } if ( vVertex[i] > fMax ) { m_vCenter[i] = ( fMin + vVertex[i] ) * (Real)0.5f; m_vExtents[i] = ( vVertex[i] - m_vCenter[i] ); } } } template<typename Real> Void TBVAABox<Real>::Grow( const TBoundingVolume<Real> & newBV ) { const TBVAABox<Real> & bvAABox = (const TBVAABox<Real> &)newBV; // Update along each axis Real fMinA, fMaxA, fMinB, fMaxB; for( UInt i = 0; i < 3; ++i ) { fMinA = ( m_vCenter[i] - m_vExtents[i] ); fMaxA = ( m_vCenter[i] + m_vExtents[i] ); fMinB = ( bvAABox.m_vCenter[i] - bvAABox.m_vExtents[i] ); fMaxB = ( bvAABox.m_vCenter[i] + bvAABox.m_vExtents[i] ); if ( fMinB < fMinA ) fMinA = fMinB; if ( fMaxB > fMaxA ) fMaxA = fMaxB; m_vCenter[i] = ( fMinA + fMaxA ) * (Real)0.5f; m_vExtents[i] = ( fMaxA - m_vCenter[i] ); } } template<typename Real> inline Void TBVAABox<Real>::AddMargin( Real fMargin ) { m_vExtents += Vector3( fMargin, fMargin, fMargin ); } template<typename Real> inline Void TBVAABox<Real>::Expand( const TVector3<Real> & vExtent ) { m_vExtents += vExtent; } template<typename Real> Void TBVAABox<Real>::ExpandMinMax( const TVector3<Real> & vExtent ) { TVertex3<Real> vMin = GetMin(); TVertex3<Real> vMax = GetMax(); if ( vExtent.X > (Real)0 ) vMax.X += vExtent.X; else vMin.X += vExtent.X; if ( vExtent.Y > (Real)0 ) vMax.Y += vExtent.Y; else vMin.Y += vExtent.Y; if ( vExtent.Z > (Real)0 ) vMax.Z += vExtent.Z; else vMin.Z += vExtent.Z; // Convert to Center-Extent m_vCenter.X = ( vMin.X + vMax.X ) * (Real)0.5f; m_vCenter.Y = ( vMin.Y + vMax.Y ) * (Real)0.5f; m_vCenter.Z = ( vMin.Z + vMax.Z ) * (Real)0.5f; m_vExtents = ( vMax - vMin ) * (Real)0.5f; } template<typename Real> Void TBVAABox<Real>::Transform( TBoundingVolume<Real> & outBV, const TTransform3<Real> & bvTransform ) const { TBVAABox<Real> & outAABox = (TBVAABox<Real> &)outBV; const TVector3<Real> & vTranslate = bvTransform.GetTranslate(); TMatrix3<Real> matTransform( bvTransform.GetHMatrix() ); // Abolute-transform trick for( UInt i = 0; i < 3; ++i ) { outAABox.m_vCenter[i] = vTranslate[i]; outAABox.m_vExtents[i] = (Real)0; for( UInt j = 0; j < 3; ++j ) { outAABox.m_vCenter[i] += ( matTransform(i,j) * m_vCenter[j] ); outAABox.m_vExtents[i] += ( MathRealFn->Abs( matTransform(i,j) ) * m_vExtents[j] ); } } } template<typename Real> Real TBVAABox<Real>::Distance( const TVertex3<Real> & vPoint ) const { // Compute closest point on the box to vPoint, handle penetration case Vector3 vAxis[3] = { Vector3::eI, Vector3::eJ, Vector3::eK }; Vector3 vU = ( vPoint - m_vCenter ); Scalar fDist, fMinPenetration; UInt iMinAxis; UInt iPenetrationCount = 0; Scalar fMinAbsPenetration = SCALAR_INFINITE; Scalar fAbsPenetration; Vertex3 vClosestPoint = m_vCenter; for( UInt i = 0; i < 3; ++i ) { fDist = ( vU * vAxis[i] ); if ( fDist > m_vExtents[i] ) fDist = m_vExtents[i]; else if ( fDist < -m_vExtents[i] ) fDist = -m_vExtents[i]; else { ++iPenetrationCount; fAbsPenetration = ( m_vExtents[i] - MathFn->Abs(fDist) ); if ( fAbsPenetration < fMinAbsPenetration ) { fMinAbsPenetration = fAbsPenetration; fMinPenetration = (fDist < 0.0f) ? -fAbsPenetration : fAbsPenetration; iMinAxis = i; } } vClosestPoint += ( vAxis[i] * fDist ); } if ( iPenetrationCount == 3 ) vClosestPoint += ( vAxis[iMinAxis] * fMinPenetration ); // Compute distance Vector3 vW = ( vClosestPoint - vPoint ); return ( iPenetrationCount == 3 ) ? -(vW.Norm()) : vW.Norm(); } template<typename Real> Bool TBVAABox<Real>::Contains( const TVertex3<Real> & vPoint ) const { TVector3<Real> W = ( vPoint - m_vCenter ); if ( MathRealFn->Abs( W.X ) > m_vExtents.X ) return false; if ( MathRealFn->Abs( W.Y ) > m_vExtents.Y ) return false; if ( MathRealFn->Abs( W.Z ) > m_vExtents.Z ) return false; return true; } template<typename Real> Bool TBVAABox<Real>::Contains( const TBoundingVolume<Real> & vBV ) const { const TBVAABox<Real> & vBVAABox = (const TBVAABox<Real> &)vBV; TVertex3<Real> vMin = GetMin(); TVertex3<Real> vMax = GetMax(); TVertex3<Real> vBVMin = vBVAABox.GetMin(); TVertex3<Real> vBVMax = vBVAABox.GetMax(); if ( vBVMin.X < vMin.X ) return false; if ( vBVMin.Y < vMin.Y ) return false; if ( vBVMin.Z < vMin.Z ) return false; if ( vBVMax.X > vMax.X ) return false; if ( vBVMax.Y > vMax.Y ) return false; if ( vBVMax.Z > vMax.Z ) return false; return true; } template<typename Real> Int TBVAABox<Real>::WhichSide( const TPlane<Real> & vPlane ) const { Real fProj = ( ( m_vExtents.X * MathRealFn->Abs( vPlane.Normal.X ) ) + ( m_vExtents.Y * MathRealFn->Abs( vPlane.Normal.Y ) ) + ( m_vExtents.Z * MathRealFn->Abs( vPlane.Normal.Z ) ) ); Real fDist = ( m_vCenter.ToVector() * vPlane.Normal ) - vPlane.Constant; if ( fDist < -fProj ) return -1; if ( fDist > fProj ) return +1; return 0; } template<typename Real> Bool TBVAABox<Real>::RayCast( const TLine3<Real> & vRay, Real * outMinDistance, Real * outMaxDistance ) const { // Ray bounds Real fMinDist = (Real)(-SCALAR_INFINITE); Real fMaxDist = (Real)SCALAR_INFINITE; // Test each axis (3-Slab approach) Real fMin, fMax; Real fInvDist, fNear, fFar, fTmp; for( UInt i = 0; i < 3; ++i ) { fMin = ( m_vCenter[i] - m_vExtents[i] ); fMax = ( m_vCenter[i] + m_vExtents[i] ); // Parallel ray if ( MathRealFn->Abs( vRay.Direction[i] ) < (Real)SCALAR_ERROR ) { if ( vRay.Position[i] < fMin || vRay.Position[i] > fMax ) return false; continue; } // Compute Slab intersection fInvDist = MathRealFn->Invert( vRay.Direction[i] ); fNear = ( fMin - vRay.Position[i] ) * fInvDist; fFar = ( fMax - vRay.Position[i] ) * fInvDist; if ( fNear > fFar ) { fTmp = fNear; fNear = fFar; fFar = fTmp; } // Update bounds if ( fNear > fMinDist ) fMinDist = fNear; if ( fFar < fMaxDist ) fMaxDist = fFar; // Empty slab intersection if ( fMinDist > fMaxDist ) return false; } // Done if ( outMinDistance != NULL ) *outMinDistance = fMinDist; if ( outMaxDistance != NULL ) *outMaxDistance = fMaxDist; return true; } template<typename Real> Bool TBVAABox<Real>::Intersect( const TBoundingVolume<Real> & vBV ) const { const TBVAABox<Real> & bvAABox = (const TBVAABox<Real> &)vBV; if ( MathRealFn->Abs(bvAABox.m_vCenter.X - m_vCenter.X) > (bvAABox.m_vExtents.X + m_vExtents.X) ) return false; if ( MathRealFn->Abs(bvAABox.m_vCenter.Y - m_vCenter.Y) > (bvAABox.m_vExtents.Y + m_vExtents.Y) ) return false; if ( MathRealFn->Abs(bvAABox.m_vCenter.Z - m_vCenter.Z) > (bvAABox.m_vExtents.Z + m_vExtents.Z) ) return false; return true; } template<typename Real> Bool TBVAABox<Real>::Collide( const TVector3<Real> & vThisSpeed, const TBoundingVolume<Real> & vBV, const TVector3<Real> & vBVSpeed, Real * outTimeOfImpact ) const { const TBVAABox<Real> & bvAABox = (const TBVAABox<Real> &)vBV; // Already intersecting if ( Intersect(vBV) ) { if ( outTimeOfImpact != NULL ) *outTimeOfImpact = (Real)0; return true; } // Relative speed TVector3<Real> vRelSpeed = ( vBVSpeed - vThisSpeed ); // Compute first TOI Real fFirstTOI = (Real)0; Real fLastTOI = (Real)SCALAR_INFINITE; // Test each axis Real fMinA, fMaxA, fMinB, fMaxB; for( UInt i = 0; i < 3; ++i ) { fMinA = ( m_vCenter[i] - m_vExtents[i] ); fMinB = ( bvAABox.m_vCenter[i] - bvAABox.m_vExtents[i] ); fMaxA = ( m_vCenter[i] + m_vExtents[i] ); fMaxB = ( bvAABox.m_vCenter[i] + bvAABox.m_vExtents[i] ); if ( vRelSpeed[i] < (Real)0 ) { if ( fMaxB < fMinA ) return false; if ( fMaxA < fMinB ) fFirstTOI = Max<Real>( (fMaxA - fMinB) / vRelSpeed[i], fFirstTOI ); if ( fMinA < fMaxB ) fLastTOI = Min<Real>( (fMinA - fMaxB) / vRelSpeed[i], fLastTOI ); } if ( vRelSpeed[i] > (Real)0 ) { if ( fMaxA < fMinB ) return false; if ( fMaxB < fMinA ) fFirstTOI = Max<Real>( (fMinA - fMaxB) / vRelSpeed[i], fFirstTOI ); if ( fMinB < fMaxA ) fLastTOI = Min<Real>( (fMaxA - fMinB) / vRelSpeed[i], fLastTOI ); } if ( fFirstTOI > fLastTOI ) return false; } // Done if ( outTimeOfImpact != NULL ) *outTimeOfImpact = fFirstTOI; return true; }
778c7b96a3e8047474b55f2372853491edf44513
88ae8695987ada722184307301e221e1ba3cc2fa
/buildtools/third_party/libc++/trunk/test/std/containers/associative/set/contains_transparent.pass.cpp
e4caa0b7128b467f053262af401180fd0fe7aaca
[ "NCSA", "LLVM-exception", "MIT", "Apache-2.0", "BSD-3-Clause" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
1,238
cpp
contains_transparent.pass.cpp
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17 // <set> // class set // template<typename K> bool contains(const K& x) const; // C++20 #include <cassert> #include <set> #include <utility> struct Comp { using is_transparent = void; bool operator()(const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const { return lhs < rhs; } bool operator()(const std::pair<int, int>& lhs, int rhs) const { return lhs.first < rhs; } bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; } }; template <typename Container> void test() { Container s{{2, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}}; assert(s.contains(1)); assert(!s.contains(-1)); } int main(int, char**) { test<std::set<std::pair<int, int>, Comp> >(); test<std::multiset<std::pair<int, int>, Comp> >(); return 0; }
30d2901b3b2ed8c14cea3e89991e4cc5ceb53b57
c68b7a64bbde73984df1518deb9373e4f075525b
/025 - AVL Tree Deletion.cpp
12d5b0044336cc1a33d88901b413affd99362764
[]
no_license
sauravstark/Preparations
c959ff1739dba4ebbdef8b5f6d75950e76bfc2a7
0268cadffb78aef3152d3f6ae927ada2b97ad99e
refs/heads/master
2022-07-08T10:04:04.526120
2020-05-08T23:43:39
2020-05-08T23:43:39
256,969,307
1
0
null
null
null
null
UTF-8
C++
false
false
4,163
cpp
025 - AVL Tree Deletion.cpp
#include <stack> #include <algorithm> struct Node { int data; Node *left; Node *right; int height; }; int height(Node* node) { if(node == nullptr) return 0; return node->height; } Node* rotateL(Node *root); Node* rotateR(Node *root); Node* deleteNode(Node* root, int data) { Node *del_node = root; std::stack<Node*> visited_parents; while (del_node != nullptr) { visited_parents.push(del_node); if (data > del_node->data) { del_node = del_node->right; } else if (data < del_node->data) { del_node = del_node->left; } else { break; } } if (del_node == nullptr) return root; visited_parents.pop(); Node *del_parent = (visited_parents.empty() ? nullptr : visited_parents.top()); bool is_left_child = (del_parent != nullptr) && (data < del_parent->data); if ((del_node->left == nullptr) && (del_node->right == nullptr)) { if (del_parent != nullptr) { if (is_left_child) del_parent->left = nullptr; else del_parent->right = nullptr; } else { delete del_node; return nullptr; } delete del_node; } else if ((del_node->left == nullptr) || (del_node->right == nullptr)) { Node *child = (del_node->left == nullptr ? del_node->right : del_node->left); if (del_parent != nullptr) { if (is_left_child) del_parent->left = child; else del_parent->right = child; } else { delete del_node; return child; } delete del_node; } else { Node *successor = del_node->right; while(successor->left != nullptr) successor = successor->left; del_node->data = successor->data; del_node->right = deleteNode(del_node->right, successor->data); visited_parents.push(del_node); } while(!visited_parents.empty()) { Node *parent = visited_parents.top(); visited_parents.pop(); int l_height = height(parent->left); int r_height = height(parent->right); if (std::abs(l_height - r_height) > 1) { if (l_height > r_height) { if (height(parent->left->left) < height(parent->left->right)) parent->left = rotateL(parent->left); parent = rotateR(parent); } else { if (height(parent->right->right) < height(parent->right->left)) parent->right = rotateR(parent->right); parent = rotateL(parent); } } parent->height = std::max(height(parent->left), height(parent->right)) + 1; if (visited_parents.empty()) { return parent; } else { Node *grand_parent = visited_parents.top(); if (parent->data > grand_parent->data) grand_parent->right = parent; else grand_parent->left = parent; } } } Node* rotateL(Node* root) { if (root->right == nullptr) return root; Node *new_root = root->right; Node *temp_node = new_root->left; new_root->left = root; root->right = temp_node; root->height = std::max(height(root->left), height(root->right)) + 1; new_root->height = std::max(height(new_root->left), height(new_root->right)) + 1; return new_root; } Node* rotateR(Node* root) { if (root->left == nullptr) return root; Node *new_root = root->left; Node *temp_node = new_root->right; new_root->right = root; root->left = temp_node; root->height = std::max(height(root->left), height(root->right)) + 1; new_root->height = std::max(height(new_root->left), height(new_root->right)) + 1; return new_root; }
d18abb0848a6260c9333fc3ba53f60e9ecc7821a
7ccad228a6002be014a3f3517f512b24a6a26370
/satelite.cpp
3142b8ca10971e706c852ab6edba10b929eaa500
[]
no_license
luissiqueira/qxd-0153
c076260bbc1fd88e2357c64491b445fffc24db51
c214c19650480a22e9c0d2a1f8a10fbd171ea11d
refs/heads/master
2021-01-10T07:43:57.986379
2016-01-25T18:02:43
2016-01-25T18:02:43
49,870,893
1
0
null
null
null
null
UTF-8
C++
false
false
1,616
cpp
satelite.cpp
// http://olimpiada.ic.unicamp.br/passadas/OBI1999/pdf/provas/ProvaOBI1999.pdf // Imagens de Satélite // Luis Siqueira - 338975 // Desafios de programação #include<stdio.h> #include<stdlib.h> #include<string.h> char matriz[82][52]; void show(char matriz[][52], int m, int n) { int l; for (l = 0; l <= m + 1; l++) { printf("%s\n", matriz[l]); } printf("\n"); } void init_matriz(char matriz[][52], int m, int n) { int i; for (i = 1; i <= m; i++) { scanf("%s", &matriz[i][1]); } for (i = 0; i <= m + 1; i++) { matriz[0][i] = '0'; matriz[m + 1][i] = '0'; matriz[i][0] = '0'; matriz[i][n + 1] = '0'; } } void destroy(char matriz[][52], int l, int c) { int x[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int y[] = {-1, 0, 1, -1, 1, -1, 0, 1}; if (matriz[l][c] != '0') { matriz[l][c] = '0'; int i, j; for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) { if (matriz[l + x[i]][c + y[j]] != '0') { destroy(matriz, l + x[i], c + y[j]); } } } } } int count(char matriz[][52], int m, int n) { int l, c; int total = 0; for (l = 1; l <= m; l++) { for (c = 1; c <= n; c++) { if (matriz[l][c] != '0') { ++total; destroy(matriz, l, c); } } } return total; } int main() { int m, n; int loop = 0; scanf("%d %d", &m, &n); if (m != 0 && n != 0) { do { init_matriz(matriz, m, n); printf("Teste %d\n", ++loop); printf("Numero de contrucoes: %d\n\n", count(matriz, m, n)); scanf("%d %d", &m, &n); } while (m != 0 && n != 0); } return 0; }
d85fb8fd6817fc8f3653f4ad9e2b5162830a7902
0930e77acdd7d614485c5725c467848c0b623824
/dietg/diet-sched-example/server.hh
8a407d48f0790ecb8f423b0406e4ba41b47e9f74
[]
no_license
chocoyaki/diet-green-g5k
77cf6f66fd7cefe8bffa9217ac345e08eab21f3b
3235d2869f256056cfb76f6d9c14bb681ce887ee
refs/heads/master
2020-07-01T01:24:46.387523
2013-11-13T14:35:31
2013-11-13T14:35:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
822
hh
server.hh
// Filename: server.hh // Description: // Author: Daniel Balouek #include <iostream> #include "common.hh" #include "server_metrics.hh" #include "server_utils.hh" #include "DIET_server.h" #include "scheduler/est_internal.hh" #include <fstream> #include <cmath> #include <stdio.h> #include <iostream> #include <fstream> #include <istream> #include <cstdlib> #include <string> using namespace std; const char *lockfile ="/root/dietg/log/lockfile.lock"; inline bool exists_test (const char* name) { ifstream f(name); if (f.good()) { f.close(); return true; } else { f.close(); return false; } } void my_lock(){ while (exists_test(lockfile) == true){ sleep(1); } ofstream lock; lock.open(lockfile); lock << "lock!\n"; lock.close(); } void my_unlock(){ remove(lockfile); }
f8d0ca7df3ba975d3dfebbb66f3cfcab16738b47
949ed189824eafe130bffb739f708a1692171a12
/imxipu.cpp
565e397bfd865da74ea82b07850829cc48b6c060
[]
no_license
vscroll/surroundpark2
6c9c2a9ae79c4c329195ef448995a74a76f37f53
6f7e34e2ae1f5ccd52cfc116144970c2644a2a7f
refs/heads/master
2021-01-19T14:24:13.099157
2017-04-14T04:34:40
2017-04-14T04:34:40
88,157,473
0
0
null
null
null
null
UTF-8
C++
false
false
1,034
cpp
imxipu.cpp
#include "imxipu.h" #include <linux/ipu.h> #include <sys/ioctl.h> #include <fcntl.h> #include <sys/mman.h> #include <QDebug> IMXIPU::IMXIPU() { } int IMXIPU::allocIpuBuf(int fd, struct buffer* ipu_buf, unsigned int frame_size) { //unsigned int page_size = getpagesize(); unsigned int buf_size = frame_size; // buf_size = (buf_size + page_size - 1) & ~(page_size - 1); ipu_buf->length = ipu_buf->offset = buf_size; if (-1 == ioctl(fd, IPU_ALLOC, &ipu_buf->offset)) { qDebug() << "IMXIPU::initV4l2Buf" << " IPU_ALLOC failed"; return -1; } ipu_buf->start = mmap(0, buf_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, ipu_buf->offset); if (NULL == ipu_buf->start) { qDebug() << "IMXIPU::initV4l2Buf" << " ipu map failed"; return -1; } } int IMXIPU::freeIpuBuf(int fd, struct buffer* ipu_buf) { } int IMXIPU::IpuTask(int fd, struct ipu_task* task) { return ioctl(fd, IPU_QUEUE_TASK, task); }
031776834807d5e72b44f0dbf34208cb4fbf6a92
bf8be94a04ada0fbf79a1dc3508c468febd2710c
/src/lullaby/script/script_engine.h
8db6bc511eaf7fb0d0baf932f2a4a45842343e27
[ "Apache-2.0" ]
permissive
xinfushe/lullaby
de4809c03e150e2a15cc0ab77794bfd9440e36f6
b38c3ad6218f858b94ec17101ea82663536f604c
refs/heads/master
2020-07-12T04:41:02.302129
2017-06-12T21:33:59
2017-06-12T21:33:59
94,276,048
1
0
null
2017-06-14T01:45:00
2017-06-14T01:45:00
null
UTF-8
C++
false
false
4,644
h
script_engine.h
/* Copyright 2017 Google Inc. 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 LULLABY_SCRIPT_SCRIPT_ENGINE_H_ #define LULLABY_SCRIPT_SCRIPT_ENGINE_H_ #include <string> #include "lullaby/generated/script_def_generated.h" #include "lullaby/base/registry.h" #include "lullaby/util/logging.h" #ifdef LULLABY_SCRIPT_LUA #include "lullaby/script/lua/engine.h" #endif #ifdef LULLABY_SCRIPT_JS #include "lullaby/script/javascript/engine.h" #endif namespace lull { // A ScriptId is an opaque id that the ScriptEngine uses to manage scripts. class ScriptId { public: ScriptId(); // Returns whether the script is valid. bool IsValid() const; private: friend class ScriptEngine; ScriptId(Language lang, uint64_t id); Language lang_; uint64_t id_; }; // The ScriptEngine loads and runs scripts by delegating to language specific // engines. class ScriptEngine { public: explicit ScriptEngine(Registry* registry) : registry_(registry) {} // Loads a script from a file, and infer the language from the filename. ScriptId LoadScript(const std::string& filename); // Loads a script from a file, and infer the language from the filename. The // debug_name is used when reporting error messages. ScriptId LoadScript(const std::string& filename, const std::string& debug_name); // Loads a script from a file, with the given language. The debug_name is used // when reporting error messages. ScriptId LoadScript(const std::string& filename, const std::string& debug_name, Language lang); // Loads a script from a string containing inline code for the given language. // The debug_name is used when reporting error messages. ScriptId LoadInlineScript(const std::string& code, const std::string& debug_name, Language lang); // Reloads a script, swapping out its code, but retaining its environment. void ReloadScript(ScriptId id, const std::string& code); // Runs a loaded script. void RunScript(ScriptId id); // Register a function with all language specific engines. template <typename Fn> void RegisterFunction(const std::string& name, const Fn& function); // Unregister a function with all language specific engines. void UnregisterFunction(const std::string& name); // Set a value in the script's environment. template <typename T> void SetValue(ScriptId id, const std::string& name, const T& value); // Get a value from the script's environment. template <typename T> bool GetValue(ScriptId id, const std::string& name, T* t); private: Registry* registry_; #ifdef LULLABY_SCRIPT_LUA script::lua::Engine lua_engine_; #endif #ifdef LULLABY_SCRIPT_JS script::javascript::Engine js_engine_; #endif }; template <typename Fn> void ScriptEngine::RegisterFunction(const std::string& name, const Fn& function) { #ifdef LULLABY_SCRIPT_LUA lua_engine_.RegisterFunction(name, function); #endif #ifdef LULLABY_SCRIPT_JS js_engine_.RegisterFunction(name, function); #endif } template <typename T> void ScriptEngine::SetValue(ScriptId id, const std::string& name, const T& value) { switch (id.lang_) { #ifdef LULLABY_SCRIPT_LUA case Language_Lua5_2: lua_engine_.SetValue(id.id_, name, value); return; #endif #ifdef LULLABY_SCRIPT_JS case Language_JavaScript: js_engine_.SetValue(id.id_, name, value); return; #endif default: LOG(ERROR) << "Unsupported language enum: " << static_cast<int>(id.lang_); } } template <typename T> bool ScriptEngine::GetValue(ScriptId id, const std::string& name, T* t) { switch (id.lang_) { #ifdef LULLABY_SCRIPT_LUA case Language_Lua5_2: return lua_engine_.GetValue<T>(id.id_, name, t); #endif #ifdef LULLABY_SCRIPT_JS case Language_JavaScript: return js_engine_.GetValue<T>(id.id_, name, t); #endif default: LOG(ERROR) << "Unsupported language enum: " << static_cast<int>(id.lang_); } return false; } } // namespace lull LULLABY_SETUP_TYPEID(lull::ScriptEngine); #endif // LULLABY_SCRIPT_SCRIPT_ENGINE_H_
2819a69d1c2b35e883f59d7345758ff9bd5707b4
7d6e81d77da55dce2e895d7d787f9a529039995b
/18FEB/func3.cpp
b6758b839939e939a39cb093fec7d716b675b196
[]
no_license
andyanidas/TeachingMgl
65dc88088ecc2ad6529b96c674fcdd09f42801f5
1305923c9e43789db09b1ec520139db21811cc3a
refs/heads/main
2023-04-24T19:08:04.587445
2021-05-20T16:14:59
2021-05-20T16:14:59
331,643,983
0
1
null
null
null
null
UTF-8
C++
false
false
957
cpp
func3.cpp
#include<iostream> using namespace std; //function prototype bool anhdagch(int); bool arms(int); //main function int main(){ int num; cout<<"Enter an integer: "; cin>>num; /* if(anhdagch(num)){ cout<<"ogogdson too anhdagch bainaa!!"; }else{ cout<<"ogogdson too anhdagch bish bainaa!!"; } cout<<endl;*/ if(arms(num)){ cout<<"ogogdson too armstrong bainaa!!"; }else{ cout<<"ogogdson too armstrong bish bainaa!!"; } /* reference ugNem(arr[], nemehUg) */ return 0; } bool anhdagch(int number){ for(int i = 2; i<number;i++){ if(number%i==0){ cout<<"huvaagdsan too: "<<i<<endl; return false; } } return true; } bool arms(int number){//153 if(anhdagch(number)){ cout<<"anhdagch\n"; }else{ cout<<"anhdagch bish\n"; } int num = number,total = 0; for(;num>0 ; num = num/10){ total = total +(num%10)*(num%10)*(num%10); } return total == number; }
827304653c12984049df3093eebb5ce8fe490e2c
155d7dc8ec0f820885ff0c1c94dacde12bbb1d20
/solved/C++/11984_A Change in Thermal Unit.cpp
163aec73649158b44cf2ad2fe173ed730e43aa6c
[ "Apache-2.0" ]
permissive
Ahmad-Fahad/UVA
c658edde930c335fb5a9ba8f4db51813bcf15c2f
5b5154377a0a6e6f41fa3960382944234e57aedc
refs/heads/master
2021-01-25T13:57:34.130929
2020-05-11T06:01:25
2020-05-11T06:01:25
123,626,477
0
0
null
null
null
null
UTF-8
C++
false
false
327
cpp
11984_A Change in Thermal Unit.cpp
#include<bits/stdc++.h> using namespace std; int main() { int testCase = 0, Case = 0; scanf("%d",&testCase); while(testCase--) { double tempC, changeInF, finalTempC; scanf("%lf %lf", &tempC, &changeInF); finalTempC = tempC + (5.0/9)*changeInF; printf("Case %d: %.2lf\n", ++Case, finalTempC); } return 0; }
5c3042638e6f8a3764d0836db41ba6022c5540d2
1d089afd1134bc8c9214b5016f17a0b0569d44b8
/Firmware/FFBoard/Src/PersistentStorage.cpp
165fbc173a7aaf115fd2a16e111c6e531f4b1cd1
[ "MIT" ]
permissive
billydragon/OpenFFBoard
46b9599cf7bfffbd779e7af526b612dad96c9049
e0fdc80971d84b711f4cdc235693f45a4bc5a748
refs/heads/master
2023-03-12T16:26:32.692278
2021-02-03T21:06:18
2021-02-03T21:06:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
520
cpp
PersistentStorage.cpp
/* * PersistentStorage.cpp * * Created on: 26.02.2020 * Author: Yannick */ #include "PersistentStorage.h" #include "global_callbacks.h" PersistentStorage::PersistentStorage() { extern std::vector<PersistentStorage*> flashHandlers; addCallbackHandler(&flashHandlers, this); } PersistentStorage::~PersistentStorage() { extern std::vector<PersistentStorage*> flashHandlers; removeCallbackHandler(&flashHandlers, this); } void PersistentStorage::saveFlash(){ } void PersistentStorage::restoreFlash(){ }
1bb175fa78f643fddb7d3a41a184d72945cc04b2
16e7752576a3218334e6ed0a4947e02863c2c52a
/modify_global_variable.cpp
82d2fc61fbb9d158dbc873ea05fd5fac85b2835e
[]
no_license
zanzaney/CPP-Data-Structures
5aaac9501b3ca3d592555d3a108732fccb481301
d2fcd2efa7e42b565fdb7965be36af8ddfae5c6d
refs/heads/master
2023-01-27T16:06:00.695152
2020-12-08T15:22:39
2020-12-08T15:22:39
298,610,428
0
0
null
null
null
null
UTF-8
C++
false
false
241
cpp
modify_global_variable.cpp
#include<iostream> using namespace std; int x= 670; int main(){ int x = 60; cout<<"in local scope x = "<<x<<" and in global scope "<<::x<<endl; ::x=240; cout<<"in local scope x = "<<x<<" and in global scope "<<::x<<endl; }
923e089cf18a15c4db092308a1c2b29141f36f0d
af7b1239a92ebb6c709be5ed43e7c677909897c7
/ga-lib/ga-lib/nullmutation.cpp
50d0a1c517aed1802f2880b9f820aa43784f15b7
[ "MIT" ]
permissive
terratenff/ga-lib
d0eedef28af40d35b715e61bda87fad3faec2d8b
393b323e071bd69978d5652f70637b35bcedbdc4
refs/heads/main
2023-06-21T20:33:00.509610
2021-07-25T16:40:41
2021-07-25T16:40:41
374,421,844
0
0
null
null
null
null
UTF-8
C++
false
false
433
cpp
nullmutation.cpp
#include "pch.h" #include "nullmutation.h" #include <iostream> #include <string> NullMutation::NullMutation(ProblemData* data, Evaluator* evaluator, unsigned int useWeight): MutationOperator(data, evaluator, useWeight) { } void NullMutation::run(Solution* offspring, RNG* rng) { } void NullMutation::print() { std::string text = "No Mutation (Weight: " + std::to_string(getUseWeight()) + ")"; std::cout << text << std::endl; }
51c4a5c84823c71d8bf756a2c3d775de0247c8fb
47af7da76df378ca8acd890c13f9fa998ad5a50b
/ParamUsageFinder.cpp
90b16b1f13ba88dad63b2a6c666f8fd34b51be83
[]
no_license
aktaylor08/clang-pass
3ed20a0b3ec5f11d9db505397b53bc7f3c9062df
c8ead1d3a10d9f331917eab2f993152af756992b
refs/heads/master
2021-01-22T03:13:27.565363
2015-05-04T18:31:55
2015-05-04T18:31:55
31,042,849
3
0
null
2015-04-07T23:38:51
2015-02-19T23:39:23
LLVM
UTF-8
C++
false
false
7,629
cpp
ParamUsageFinder.cpp
#include "llvm/Transforms/RosThresholds/ParamUsageFinder.h" #include "llvm/InitializePasses.h" #include "llvm-c/Initialization.h" #include <iostream> #include <fstream> #define DEBUG_TYPE "param_usage_finder" namespace llvm{ ParamUsageFinder::ParamUsageFinder() : ModulePass(ID){ initializeRosThresholds(*PassRegistry::getPassRegistry()); back_prop_res = nullptr; param_use_count = 0; param_branch_count = 0; } void ParamUsageFinder::getAnalysisUsage(AnalysisUsage &AU) const{ AU.setPreservesAll(); AU.addRequiredTransitive<ParamCallFinder>(); AU.addRequiredTransitive<BackwardPropigate>(); } Type* getPointerElementType(GetElementPtrInst* gepi){ if(LoadInst * load = dyn_cast<LoadInst>(gepi -> getPointerOperand())){ if(AllocaInst * alloc = dyn_cast<AllocaInst>(load -> getPointerOperand())){ return alloc ->getAllocatedType(); } } return gepi ->getPointerOperandType(); } bool pointToSameStruct(GetElementPtrInst* p1, GetElementPtrInst* p2){ if(getPointerElementType(p1) == getPointerElementType(p2)){ return true; } return false; } void ParamUsageFinder::add_to_result(BranchInst* branch, Instruction* threshold){ if(results.count(branch) == 0){ instruction_vect v; v.push_back(threshold); branch_thresh_pair to_add(branch, v); results.insert(to_add); }else{ for(Instruction* i: results.at(branch)){ if (i == threshold){ errs() << "Ignoring duplicate"; return; } i -> dump(); threshold -> dump(); errs() << "\n\n"; } results.at(branch).push_back(threshold); } } int ParamUsageFinder::matches_setup_param(GetElementPtrInst* ptr_inst){ //Otherwise is it a call to the param from somewhere else? for(unsigned long i=0; i < result_list.size(); i++){ bool matched = false; if(pointToSameStruct(ptr_inst, result_list[i])){ GetElementPtrInst* pos_match = result_list[i]; if(pos_match ->getNumIndices() == ptr_inst -> getNumIndices()){ matched = true; User::op_iterator PMI,PME, II; PMI = pos_match -> idx_begin(); PME = pos_match -> idx_end(); II = ptr_inst -> idx_begin(); for(;PMI != PME;++II, ++PMI){ matched = matched && (II -> get() == PMI -> get()); } } if(matched){ return i; } } } return -1; } std::vector<Instruction*> iter_on_uses(Instruction * I){ std::vector<Instruction*> ret; std::deque<Instruction*> to_process; to_process.push_back(I); while(!to_process.empty()){ I = to_process.front(); to_process.pop_back(); for(User *U : I -> users()){ if(Instruction* next_i = dyn_cast<Instruction>(U)){ ret.push_back(next_i); to_process.push_back(next_i); } } } return ret; } instruction_set get_usage_sinks(Instruction* I){ instruction_set ret_val; std::deque<Instruction*> to_process; instruction_set visited; to_process.push_back(I); while(!to_process.empty()){ I = to_process.front(); to_process.pop_back(); if(visited.count(I) == 0){ if(I -> getNumUses() == 0){ ret_val.insert(I); } for(User *U : I -> users()){ if(Instruction* next_i = dyn_cast<Instruction>(U)){ if(visited.count(next_i) == 0){ to_process.push_back(next_i); } } } } visited.insert(I); } return ret_val; } bool ParamUsageFinder::runOnFunction(Function &F) { //Iterate through all of the instructions for(Function::iterator block = F.begin(), E=F.end(); block != E; ++block){ for(BasicBlock::iterator inst = block->begin(), ie = block -> end(); inst != ie; ++inst){ //Are we getting a pointer address for one of the param objects we set up? if(GetElementPtrInst* ptr_inst = dyn_cast<GetElementPtrInst>(&*inst)){ //Check to make sure it is not one of the original setup calls identified if (result_set.count(ptr_inst) == 0){ //Does it reference a setup parameter though? int idx = matches_setup_param(ptr_inst); if(idx > -1){ param_use_count++; params.push_back(ptr_inst); //Check to see if it ends with a break statement.. instruction_set sinks = get_usage_sinks(ptr_inst); //See if it ends on a br statement -> We have a loop or if or something BranchInst * B; //Does it end at a branch? for(instruction_set::iterator s=sinks.begin(); s!=sinks.end(); ++s){ Instruction* I = *s; if((B = dyn_cast<BranchInst>(&*I))){ bool good = true; for(Instruction* x : iter_on_uses(ptr_inst)){ if(BinaryOperator * bin = dyn_cast<BinaryOperator>(&*x)){ //for now any addition invalidates the constant from the global parameter //TODO account for constant values added to the thing good = false; } } if(!good){ errs() << "Disregarding due to operation on parameter\n"; } param_branch_count++; branch_params.push_back(ptr_inst); int dist = back_prop_res -> branch_marked(B); if((dist >= 0) && (good)){ thresh_branches.insert(B); std::pair<BranchInst*, int> val(B, dist); dist_map.insert(val); add_to_result(B, ptr_inst); std::pair<Instruction*, GetElementPtrInst*> insert_pair; insert_pair.first = B; insert_pair.second= result_list[idx]; map_to_setup.insert(insert_pair); } } } }//end it is a param call } } //end possible pointer } //End ITER through isntructions } //End iter through blocks return false; } branch_set ParamUsageFinder::getBranches(){ branch_set ret_val; for(BranchInst* b: thresh_branches){ ret_val.insert(b); } return ret_val; } thresh_result_type ParamUsageFinder::getResults(){ return results; } std::map<Instruction*, int> ParamUsageFinder::getDistance(){ return dist_map; } std::map<Instruction*, Instruction*> ParamUsageFinder::getSetups(){ return map_to_setup; } bool ParamUsageFinder::runOnModule(Module& M) { DEBUG(errs() << "\n\nStarting parameter usage finder:\n"); result_set = *(getAnalysis<ParamCallFinder>().getParamPtrSet()); result_list = *(getAnalysis<ParamCallFinder>().getParamPtrList()); back_prop_res = &getAnalysis<BackwardPropigate>(); for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) { runOnFunction(*MI); } DEBUG(errs() << "Found: " << params.size() << " Param uses\n\n"); DEBUG(errs() << "Found: " << branch_params.size() << " Branch Parameter uses\n"); outputParamPreds(); for(GetElementPtrInst* gepi : branch_params){ DEBUG(dump_instruction(gepi, 1, "param: ")); } errs() << "Found: " << branch_params.size() << " Branch Parameter uses\n"; errs() << "Found: " << thresh_branches.size() << " Dependent Branches\n"; for(BranchInst* b: thresh_branches){ dump_instruction(b, 2, "Param in Branch: "); } return false; } void ParamUsageFinder::outputParamPreds(){ std::ofstream myfile; std::string fname = "/home/ataylor/clang_results/param_preds.txt"; myfile.open(fname, std::ios::out | std::ios::app ); for(GetElementPtrInst* gepi : branch_params){ std::pair<std::string, int> val =get_file_lineno(gepi); myfile << val.first << "\t" << val.second << "\n"; } myfile.close(); } char ParamUsageFinder::ID = 0; //RegisterPass<ParamUsageFinder> Y("ros-param-uses", "Finding Used Ros Params", false, false); ModulePass * createParamUsageFinderPass(){return new ParamUsageFinder();} } INITIALIZE_PASS_BEGIN(ParamUsageFinder, "ros-param-uses", "Finding Used Ros Params", false, false) INITIALIZE_PASS_DEPENDENCY(ParamCallFinder) INITIALIZE_PASS_DEPENDENCY(BackwardPropigate) INITIALIZE_PASS_END(ParamUsageFinder, "ros-param-uses", "Finding Used Ros Params", false, false)
09686b2268dba7efc853eeaa0f9707dcb210a135
a638064947d82966b3a5e4057336acc5efc0edb1
/forwardlist.h
eb656f40a6a41b441c50f01a11601031a71600ef
[]
no_license
AndreyKharkovsky/TermBook
207a9e018e14186ed40eaeb649fbf4d2fddda657
9057c823b732d884a85a4bd8569213f211a2b735
refs/heads/master
2020-07-13T22:40:09.811138
2019-11-07T17:57:56
2019-11-07T17:57:56
205,171,017
0
0
null
null
null
null
UTF-8
C++
false
false
1,708
h
forwardlist.h
#ifndef FORWARDLIST_H #define FORWARDLIST_H #include <memory> template <typename T> class ForwardList { // typedefs public: using value_type = T; using reference = T &; using const_reference = const T &; using pointer = T *; // Other public: ForwardList(): link_{nullptr}, size_{0} {} ForwardList(std::initializer_list<T> lst) { for (const T & elem: lst) { push_front(elem); } } ~ForwardList() noexcept = default; void push_front(const T & data) { link_ = std::make_unique<Node>(data, std::move(link_)); ++size_; } void push_front(T && data) { link_ = std::make_unique<Node>(std::forward<T>(data), std::move(link_)); ++size_; } [[nodiscard]] const_reference top() const noexcept { return link_->data_; } [[nodiscard]] reference top() noexcept { return link_->data_;} void pop() { if (link_) { link_ = std::move(link_->next_); --size_; } } [[nodiscard]] bool empty() const noexcept { return link_ == nullptr; } [[nodiscard]] std::size_t size() const noexcept { return size_; } private: struct Node { T data_{}; std::unique_ptr<Node> next_; Node (T && data, std::unique_ptr<Node> next): data_{std::forward<T>(data)}, next_{std::move(next)} {} Node (const T & data, std::unique_ptr<Node> next): data_{data}, next_{std::move(next)} {} // Delegate Node(): Node{T{}, nullptr} {} ~Node() { std::cout << "Dtor for " << data_ << '\n'; } }; using Link = std::unique_ptr<Node>; Link link_; std::size_t size_{}; }; #endif // FORWARDLIST_H
4a93ef67defbd48f9befe600826bb7130a758394
1f73158506abcd2de2541e7f622a6b1013117c4b
/자료구조_Project01/Product.h
e7d30da350cf3bfb6a882d92bb9f27dce0534c6e
[]
no_license
siosio34/Data_Structure
95d330beee1677c8514afbb5ecfa9f17e86f52d2
3a2c3773701899253ceaf8f372a230b0f07d18aa
refs/heads/master
2021-01-10T03:22:57.325733
2016-02-25T07:00:31
2016-02-25T07:00:31
48,945,697
0
0
null
null
null
null
UHC
C++
false
false
12,901
h
Product.h
#pragma once #include <iostream> #include <string> #include <string.h> #include <iomanip> #include <Windows.h> #include <stdio.h> using namespace std; /**============================================ Product 클래스 ======================================================================== * @author 조영제 * @date 2014/10/14 * @brief DoublySortedLinkedList의 상위 클래스로 상품의 정보를 가지고 있는 클래스이다. * @details 프로그램의 주축이 되는 상품 정보를 set,get 해주는 함수 Product 타입을 비교하기 위한 연산자 오버로딩등의 함수가 출력되어 있다. =========================================================================================================================================*/ class Product { private: int product_ID; ///< 상품 ID int product_presentCount;///< 상품 재고량 int product_orderCount; ///< 상품 주문량 int product_price; ///< 상품 가격 string product_name; ///< 상품 이름 string Manufacture_name; ///< 상품 제조업자 int sum_money; ///< 총 수익 public: /**========================================================================================================================= * @brief Product의 생성자 *=========================================================================================================================*/ Product();/// Product 생성자 /**========================================================================================================================= * @brief 매개변수가 있는 Product의 생성자 ============================================================================================================================*/ Product(int _product_ID,string _product_Name,string _Manufacture_name,int _product_price,int _product_presentCount,int _product_orderCount): product_ID(_product_ID),product_name(_product_Name),Manufacture_name(_Manufacture_name),product_price(_product_price), product_presentCount(_product_presentCount),product_orderCount(_product_orderCount){};///매개변수를 둔 프로젝트 생성자 /**========================================================================================================================= * @brief Product의 소멸자 *==========================================================================================================================*/ ~Product();/// Product 소멸자 /***========================================================================================================================== * @brief 상품의 ID를 설정한다. * @pre 없다. * @post 상품의 ID가 설정된다. * @param _product_id 상품의 id *==========================================================================================================================*/ void set_product_ID(int _product_id){product_ID=_product_id;}; /// Product id 설정. /***========================================================================================================================== * @brief 상품의 가격을 설정한다. * @pre 없다. * @post 상품의 가격이 설정된다. * @param _product_price 상품의 가격 *==========================================================================================================================*/ void set_product_price(int _product_price){product_price=_product_price;}; /// Product 가격 설정 /***========================================================================================================================== * @brief 상품의 입고량을 설정한다. * @pre 없다. * @post 상품의 입고량이 설정된다. * @param _product_count 상품의 입고량 *==========================================================================================================================*/ void set_presentproduct_count(int _product_count){product_presentCount=_product_count;}; /// Product 잔고량 설정 /***========================================================================================================================== * @brief 상품의 주문량을 설정한다. * @pre 없다. * @post 상품의 주문량이 설정된다. * @param _product_count1 상품의 주문량 *==========================================================================================================================*/ void set_orderproduct_count(int _product_count1){product_orderCount=_product_count1;}; /// Product 주문량 설정 /***========================================================================================================================== * @brief 상품의 이름을 설정한다. * @pre 없다. * @post 상품의 이름이 설정된다. * @param _product_name 상품의 이름 *==========================================================================================================================*/ void set_product_name(string _product_name){product_name=_product_name;}; /// Product 이름 설정 /***========================================================================================================================== * @brief 상품의 제조업자을 설정한다. * @pre 없다. * @post 상품의 제조업자가 설정된다. * @param _Manufacture_name 상품의 제조업자 이름 *==========================================================================================================================*/ void set_Manufacturet_name(string _Manufacture_name){Manufacture_name=_Manufacture_name;}; /// Product 제조업자 설정 /***========================================================================================================================== * @brief 상품의 판매금액을 설정한다. * @pre 없다. * @post 상품의 판매금액이 설정된다. * @param number,price 상품의 가격, 상품의 판매량 *============================================================================================================================*/ void set_Sum_money(int number,int price){sum_money=number*price;} /***========================================================================================================================== * @brief 상품의 제조업자을 리턴한다. * @pre 없다. * @post 상품의 제조업자가 리턴된다. * @return Manufacture_name 상품의 제조업자 *============================================================================================================================*/ string get_Manufacturet_name(){return Manufacture_name;}; /// Product 제조업자 리턴 /***========================================================================================================================== * @brief 상품의 이름을 리턴한다. * @pre 없다. * @post 상품의 이름이 리턴된다. * @return product_name 상품의 이름 *============================================================================================================================*/ string get_product_name(){return product_name;}; /// Product 이름 리턴 /***========================================================================================================================== * @brief 상품의 아이디를 리턴한다. * @pre 없다. * @post 상품의 아이디가 리턴된다. * @return product_ID 상품의 아이디 *============================================================================================================================*/ int get_product_ID(){return product_ID;}; /// Product id 리턴 /***========================================================================================================================== * @brief 상품의 아이디를 리턴한다. * @pre 없다. * @post 상품의 아이디가 리턴된다. * @return product_ID 상품의 아이디 *============================================================================================================================*/ int get_product_price(){return product_price;}; /// Product 가격 리턴 /***========================================================================================================================== * @brief 상품의 입고량을 리턴한다. * @pre 없다. * @post 상품의 입고량이 리턴된다. * @return product_presentCount 상품의 입고량 *============================================================================================================================*/ int get_presentproduct_count(){return product_presentCount;}; /// Product 잔고량 리턴 /***========================================================================================================================== * @brief 상품의 주문량을 리턴한다. * @pre 없다. * @post 상품의 주문량이 리턴된다. * @return product_orderCount 상품의 주문량 *============================================================================================================================*/ int get_orderproduct_count(){return product_orderCount;}; /// Product 주문량 리턴 /***========================================================================================================================== * @brief 상품의 수익을 리턴한다. * @pre 없다. * @post 상품의 수익이 리턴된다. * @return sum_money 상품의 수익 *============================================================================================================================*/ int get_money(){return sum_money;} /// Product 상품의 총금액 리턴 /***========================================================================================================================== * @brief 특정 아이템이 가지고 있는 정보(검색한 정보)를 출력한다. * @pre 없다. * @post Product 가 가지고 있는 정보가 보여진다. *============================================================================================================================*/ void search_product_info(); /// 특정 아이템이 가지고 있는 정보를 출력한다. /**=========================================================================================================================== * 두개의 itemType(Product)을 대소를 비교한다 * @brief id로 두개의 itemType(Product) 을 비교한다.( > 연산자 오버로딩을 이용한다.) * @pre 두개의 아이템은 초기화 되어 있어야한다. * @post 타겟 파일의 비교한뒤 그에 다른 리턴값을 출력하게 된다. * @param &item 타겟 아이템을 비교하기 위해서 사용된다 * @return this 포인터의 아이디가 더 클시 true를 리턴 아니면 false를 리턴한다 *============================================================================================================================*/ void print_preProduct(); bool operator > (const Product &item); /// > 연산자오버로딩 /**============================================================================================================================ * 두개의 itemType(Product)을 비교한다 * @brief id로 두개의 itemType(Product) 을 비교한다.( == 연산자 오버로딩을 이용한다.) * @pre 두개의 아이템은 초기화 되어 있어야한다. * @post 타겟 파일의 비교한뒤 그에 다른 리턴값을 출력하게 된다. * @param &item 타겟 아이템을 비교하기 위해서 사용된다 * @return this 포인터의 아이디가 같거나 이름이 같으면 true를 리턴 아니면 false를 리턴한다 *============================================================================================================================*/ bool operator == (const Product &item); /// == 연산자 오버로딩 /**=========================================================================================================================== * @brief item1에 잇는 정보를 this로 옮긴다..(= 연산자 오버로딩을 이용한다.) * @pre 없다. * @post 없다. * @param &item1 타겟 아이템의 정보를 옮기기 위해서 사용한다. * @return 없다. *============================================================================================================================*/ void operator = (Product &item); /// = 연산자 오버로딩 /**============================================================================================================================ * @brief item에 있는 정보를 출력한다(<< 연산자 오버로딩을 이용한다.) * @pre 아이템에 정보가 들어가 있어야한다. * @post 해당 아이템의 정보를 출력하게 한다. * @param &item 타겟 아이템의 정보를 보여주기 위해서사용된다. * @return &ostream 객체를 리턴한다. *============================================================================================================================*/ friend ostream& operator << (ostream&os, Product &item); // << 연산자 오버로딩 };
05ef12002f8bbc5fa5eae0857d184e3d448b62be
e289b0e1b80a7bd890053324eb6e48a2c576988e
/tests/test_PinLink.cpp
95a233b82028871ec4da30c7358100c0a954ef77
[ "MIT" ]
permissive
aimbot31/nanotekspices
5aab70ba7be23dee251a2e7aefc2161fcde5a24a
975862af8e9442c8dba145616f178503b3518ef7
refs/heads/master
2020-04-19T03:27:55.781221
2019-02-24T21:25:58
2019-02-24T21:25:58
167,935,196
0
0
null
null
null
null
UTF-8
C++
false
false
681
cpp
test_PinLink.cpp
/* ** EPITECH PROJECT, 2017 ** Test_criterion ** File description: ** Test de PinLink */ #include <criterion/criterion.h> #include <criterion/redirect.h> #include "PinLink.hpp" #include "Input.hpp" using namespace nts; TestSuite(PinLink, .init = NULL, .fini = NULL, .signal = 0, .exit_code = 0, .disabled = 0, .description = "Test the function: PinLink", .timeout = 0); Test(PinLink, LinkCorrectly) { Input a1("a1"); PinLink toto(&a1, 1); cr_assert_eq(toto(), nts::Tristate::UNDEFINED); } Test(PinLink, BoolComparaison) { PinLink toto; if (!toto) cr_assert(1); else cr_assert(0); cr_assert_eq(toto(), nts::Tristate::UNDEFINED); }
c1ad2766f7a6fb68d75f93d3c033064446b5e4ac
bd0c14d0b39968e677c7eaef658594afc9f46ae9
/src/policy/browser/ctp/tdapi.cc
dbce238fb0c55fc0004c0e2faa11f3a0a84597bd
[]
no_license
alexfordc/p528
ca701193d4e8e6d0cf0b330d06e1c1ac23d9e481
42536561e8e2920c92305ed88aa0b50e7b81c0d0
refs/heads/master
2021-05-29T20:13:04.123698
2015-06-28T11:25:47
2015-06-28T11:25:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
90
cc
tdapi.cc
// Copyright by wangtianping. All rights reserved. #include "chrome/browser/ctp/tdapi.h"
4a93cf6cac865ed0993d417e395bd3d8f6e07d9c
1572de76809bb23247b17e63ba923eeb68bbc19d
/src/seedlink/sproc.cc
d30c231b4ebc95ce8c988aa0d8b17aed86edc5a2
[]
no_license
paride/seiscomp-2.1-phenix
9edfcd9ce37dca6acbb8855f5414997f80d32497
501da5fcaf71d8db7c297c7a15902e63ef1b951b
refs/heads/master
2021-07-06T07:24:29.972365
2017-10-01T18:18:11
2017-10-01T18:18:11
104,362,155
0
1
null
null
null
null
UTF-8
C++
false
false
20,049
cc
sproc.cc
/***************************************************************************** * sproc.cc * * Stream Processor * * (c) 2000 Andres Heinloo, GFZ Potsdam * * 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, or (at your option) any later * version. For more information, see http://www.gnu.org/ *****************************************************************************/ #include <iostream> #include <string> #include <list> #include <map> #include "utils.h" #include "conf_xml.h" #include "confattr.h" #include "sproc.h" #include "cbuf.h" #include "filterimpl.h" #include "encoder.h" #include "spclock.h" #include "diag.h" namespace SProc_private { using namespace std; using namespace Utilities; using namespace CfgParser; const int MAX_CBSIZE = 14; const int SPS_RANGE = 65535; // 1/65535...65535 sps //***************************************************************************** // Node //***************************************************************************** class Node: public Input { private: list<rc_ptr<Node> > children; rc_ptr<Encoder> encoder; rc_ptr<Filter> filter; CircularBuffer<double> cbuf; CircularBuffer<double>::iterator inp; SPClock clk; void sync_time(const Node &parent); void process_data(const Node &parent); public: Node(rc_ptr<Filter> filter_init, int cbsize, int freqn, int freqd): filter(filter_init), cbuf(cbsize), clk(freqn, freqd) {} void set_time(const INT_TIME &it, int usec_correction, int timing_quality); void add_ticks(int n, int usec_correction, int timing_quality); void send_data(const int32_t *data, int len); void flush(); void attach_node(rc_ptr<Node> node); void attach_encoder(rc_ptr<Encoder> enc); double time_gap() { return clk.time_gap(); } }; void Node::sync_time(const Node &parent) { clk.sync_time(parent.clk, parent.cbuf.used(inp), filter->shift()); if(encoder != NULL) encoder->sync_time(clk); list<rc_ptr<Node> >::iterator p; for(p = children.begin(); p != children.end(); ++p) (*p)->sync_time(*this); } void Node::process_data(const Node &parent) { if(parent.cbuf.used(inp) < filter->length()) return; double val = filter->apply(inp); inp += filter->decimation(); if(encoder != NULL) encoder->send_data(static_cast<int32_t>(val)); cbuf.write(val); clk.tick(); list<rc_ptr<Node> >::iterator p; for(p = children.begin(); p != children.end(); ++p) (*p)->process_data(*this); } void Node::set_time(const INT_TIME &it, int usec_correction, int timing_quality) { clk.set_time(it, usec_correction, timing_quality); if(encoder != NULL) encoder->sync_time(clk); list<rc_ptr<Node> >::iterator p; for(p = children.begin(); p != children.end(); ++p) (*p)->sync_time(*this); } void Node::add_ticks(int n, int usec_correction, int timing_quality) { clk.add_ticks(n, usec_correction, timing_quality); if(encoder != NULL) encoder->sync_time(clk); list<rc_ptr<Node> >::iterator p; for(p = children.begin(); p != children.end(); ++p) (*p)->sync_time(*this); } void Node::send_data(const int32_t *data, int len) { list<rc_ptr<Node> >::iterator p; for(int i = 0; i < len; ++i) { if(encoder != NULL) encoder->send_data(data[i]); cbuf.write(data[i]); clk.tick(); for(p = children.begin(); p != children.end(); ++p) (*p)->process_data(*this); } } void Node::flush() { if(encoder != NULL) encoder->flush(); list<rc_ptr<Node> >::iterator p; for(p = children.begin(); p != children.end(); ++p) (*p)->flush(); } void Node::attach_node(rc_ptr<Node> node) { node->inp = cbuf.read_ptr(); children.push_back(node); } void Node::attach_encoder(rc_ptr<Encoder> enc) { encoder = enc; } //***************************************************************************** // DummyFilter //***************************************************************************** class DummyFilter: public Filter { public: DummyFilter(): Filter("(none)", 1) { len = 1; } double apply(CircularBuffer<double>::iterator p) { return *p; } double shift() { return 0; } }; //***************************************************************************** // NodeSpec, InputSpec -- helper classes to construct stream tree according to // configuration description //***************************************************************************** class NodeSpec { private: list<rc_ptr<NodeSpec> > children; const string stream_name; const rc_ptr<Filter> filter; int cbsize; int n_streams; void normalize_freq(int &freqn, int &freqd) const; public: NodeSpec(const string &stream, rc_ptr<Filter> filter_init): stream_name(stream), filter(filter_init), cbsize(1), n_streams(-1) {} rc_ptr<Node> instance(rc_ptr<EncoderSpec> encoder_spec, const string &channel_name, const string &location_id, int freqn, int freqd) const; void attach(rc_ptr<NodeSpec> child); int cbsize_required() const; bool remove_unused_child_nodes(); int number_of_streams() const { return n_streams; } }; void NodeSpec::normalize_freq(int &freqn, int &freqd) const { int a, b; if(freqn > freqd) { a = freqn; b = freqd; } else { a = freqd; b = freqn; } while(b > 1) { int tmp = b; b = a % b; a = tmp; } if(b == 0) { freqn /= a; freqd /= a; } } rc_ptr<Node> NodeSpec::instance(rc_ptr<EncoderSpec> encoder_spec, const string &channel_name, const string &location_id, int freqn, int freqd) const { rc_ptr<Filter> myfilter; if(filter == NULL) myfilter = new DummyFilter; else myfilter = filter; rc_ptr<Node> node = new Node(myfilter, cbsize, freqn, freqd); int cfreqn = freqn; int cfreqd = freqd * myfilter->decimation(); normalize_freq(cfreqn, cfreqd); list<rc_ptr<NodeSpec> >::const_iterator p; for(p = children.begin(); p != children.end(); ++p) node->attach_node((*p)->instance(encoder_spec, channel_name, location_id, cfreqn, cfreqd)); if(stream_name.length() != 0) node->attach_encoder(encoder_spec->instance(stream_name + channel_name, location_id, cfreqn, cfreqd)); return node; } void NodeSpec::attach(rc_ptr<NodeSpec> child) { if(child->cbsize_required() > cbsize) cbsize = child->cbsize_required(); children.push_back(child); } int NodeSpec::cbsize_required() const { if(filter == NULL) return 0; int b, n = filter->length(); for(b = 1; b <= MAX_CBSIZE && n >= (1 << b); ++b); internal_check(b <= MAX_CBSIZE); return b; } bool NodeSpec::remove_unused_child_nodes() { list<rc_ptr<NodeSpec> >::iterator p = children.begin(); if(n_streams < 0) { n_streams = 0; while(p != children.end()) { if((*p)->remove_unused_child_nodes()) { children.erase(p++); } else { n_streams += (*p)->number_of_streams(); ++p; } } if(stream_name.length() != 0) ++n_streams; } return (n_streams == 0); } class InputSpec { private: const string channel_name; const string location_id; const int freqn; const int freqd; rc_ptr<NodeSpec> node_spec; public: const string name; InputSpec(const string &name_init, const string &channel_name_init, const string &location_id_init, int freqn_init, int freqd_init, rc_ptr<NodeSpec> node_spec_init): channel_name(channel_name_init), location_id(location_id_init), freqn(freqn_init), freqd(freqd_init), node_spec(node_spec_init), name(name_init) {} bool remove_unused_child_nodes() { return node_spec->remove_unused_child_nodes(); } int number_of_streams() const { return node_spec->number_of_streams(); } rc_ptr<Node> instance(rc_ptr<EncoderSpec> encoder_spec) const { return node_spec->instance(encoder_spec, channel_name, location_id, freqn, freqd); } }; //***************************************************************************** // StreamProcesorImpl //***************************************************************************** class StreamProcessorImpl: public StreamProcessor { private: map<string, rc_ptr<Node> > input_nodes; public: StreamProcessorImpl(const string &name, const map<string, rc_ptr<InputSpec> > input_specs, rc_ptr<EncoderSpec> encoder_spec); rc_ptr<Input> get_input(const string &channel_name); void flush(); }; StreamProcessorImpl::StreamProcessorImpl(const string &name, const map<string, rc_ptr<InputSpec> > input_specs, rc_ptr<EncoderSpec> encoder_spec): StreamProcessor(name) { map<string, rc_ptr<InputSpec> >::const_iterator p; for(p = input_specs.begin(); p != input_specs.end(); ++p) input_nodes.insert(make_pair(p->first, p->second->instance(encoder_spec))); } rc_ptr<Input> StreamProcessorImpl::get_input(const string &channel_name) { return get_object(input_nodes, channel_name); } void StreamProcessorImpl::flush() { map<string, rc_ptr<Node> >::iterator p; for(p = input_nodes.begin(); p != input_nodes.end(); ++p) p->second->flush(); } //***************************************************************************** // StreamProcessorSpecImpl -- helper class to make stream processors according // to configuration description //***************************************************************************** class StreamProcessorSpecImpl: public StreamProcessorSpec { private: map<string, rc_ptr<InputSpec> > input_specs; public: StreamProcessorSpecImpl(const string &name, const map<string, rc_ptr<InputSpec> > &input_specs_init, const list<rc_ptr<StreamProcessorSpecImpl> > &merge); int number_of_streams() const; rc_ptr<StreamProcessor> instance(rc_ptr<EncoderSpec> encoder_spec) const { return new StreamProcessorImpl(name, input_specs, encoder_spec); } }; StreamProcessorSpecImpl::StreamProcessorSpecImpl(const string &name, const map<string, rc_ptr<InputSpec> > &input_specs_init, const list<rc_ptr<StreamProcessorSpecImpl> > &merge): StreamProcessorSpec(name), input_specs(input_specs_init) { list<rc_ptr<StreamProcessorSpecImpl> >::const_iterator i; map<string, rc_ptr<InputSpec> >::const_iterator j; for(i = merge.begin(); i != merge.end(); ++i) for(j = (*i)->input_specs.begin(); j != (*i)->input_specs.end(); ++j) insert_object(input_specs, j->second); } int StreamProcessorSpecImpl::number_of_streams() const { int n_streams = 0; map<string, rc_ptr<InputSpec> >::const_iterator p; for(p = input_specs.begin(); p != input_specs.end(); ++p) n_streams += p->second->number_of_streams(); return n_streams; } //***************************************************************************** // FreqAttribute -- config parameter for sample rate //***************************************************************************** class FreqAttribute: public CfgAttribute { private: int &freqn, &freqd; int range; public: FreqAttribute(const string &name, int &freqn_init, int &freqd_init, int range_init): CfgAttribute(name), freqn(freqn_init), freqd(freqd_init), range(range_init) {} bool assign(ostream &cfglog, const string &value); }; bool FreqAttribute::assign(ostream &cfglog, const string &value) { int arg; char *tail; arg = strtoul(value.c_str(), &tail, 0); if(*tail == 0) { freqn = arg; freqd = 1; } else if(*tail == '/') { freqn = arg; arg = strtoul(tail + 1, &tail, 0); if(*tail == 0) freqd = arg; } if(*tail || freqn == 0 || freqn > range || freqd == 0 || freqd > range) { cfglog << "[" << item_name << "] " << value << " is not a valid sample rate" << endl; return false; } return true; } //***************************************************************************** // XML elements //***************************************************************************** class InputElement: public CfgElement { private: string input_name; string channel_name; string location_id; int freqn, freqd; map<string, rc_ptr<InputSpec> > &input_specs; rc_ptr<NodeSpec> root_node; public: InputElement(map<string, rc_ptr<InputSpec> > &input_specs_init, rc_ptr<NodeSpec> node): CfgElement("input"), input_specs(input_specs_init), root_node(node) {} rc_ptr<CfgAttributeMap> start_attributes(ostream &cfglog, const string &) { input_name = ""; channel_name = ""; location_id = ""; freqn = 0; freqd = 0; rc_ptr<CfgAttributeMap> atts = new CfgAttributeMap; atts->add_item(StringAttribute("name", input_name)); atts->add_item(StringAttribute("channel", channel_name)); atts->add_item(StringAttribute("location", location_id)); atts->add_item(FreqAttribute("rate", freqn, freqd, SPS_RANGE)); return atts; } void end_attributes(ostream &cfglog) { if(input_name.length() == 0) { cfglog << "input name is not specified" << endl; return; } if(freqn == 0) { cfglog << "input sample rate is not specified" << endl; return; } insert_object(input_specs, new InputSpec(input_name, channel_name, location_id, freqn, freqd, root_node)); } }; class NodeElement: public CfgElement { private: string filter_name; string stream_name; const map<string, rc_ptr<Filter> > &filters; rc_ptr<NodeSpec> parent_node; rc_ptr<NodeSpec> this_node; public: NodeElement(rc_ptr<NodeSpec> node, const map<string, rc_ptr<Filter> > &filters_init): CfgElement("node"), filters(filters_init), parent_node(node) {} rc_ptr<CfgAttributeMap> start_attributes(ostream &cfglog, const string &) { filter_name = ""; stream_name = ""; rc_ptr<CfgAttributeMap> atts = new CfgAttributeMap; atts->add_item(StringAttribute("filter", filter_name)); atts->add_item(StringAttribute("stream", stream_name)); return atts; } rc_ptr<CfgElementMap> start_children(ostream &cfglog, const string &) { rc_ptr<Filter> filter; if((filter_name.length() != 0) && (filter = get_object(filters, filter_name)) == NULL) { cfglog << "filter '" << filter_name << "' is not defined" << endl; return NULL; } this_node = new NodeSpec(stream_name, filter); rc_ptr<CfgElementMap> elms = new CfgElementMap; elms->add_item(NodeElement(this_node, filters)); return elms; } void end_children(ostream &cfglog) { parent_node->attach(this_node); } }; class TreeElement: public CfgElement { private: rc_ptr<NodeSpec> root_node; const map<string, rc_ptr<Filter> > &filters; map<string, rc_ptr<InputSpec> > &input_specs; public: TreeElement(const map<string, rc_ptr<Filter> > &filters_init, map<string, rc_ptr<InputSpec> > &input_specs_init): CfgElement("tree"), filters(filters_init), input_specs(input_specs_init) {} rc_ptr<CfgElementMap> start_children(ostream &cfglog, const string &) { root_node = new NodeSpec(string(), NULL); rc_ptr<CfgElementMap> elms = new CfgElementMap; elms->add_item(InputElement(input_specs, root_node)); elms->add_item(NodeElement(root_node, filters)); return elms; } }; class UsingElement: public CfgElement { private: string proc_name; const map<string, rc_ptr<StreamProcessorSpec> > &proc_specs; list<rc_ptr<StreamProcessorSpecImpl> > &merge; public: UsingElement(const map<string, rc_ptr<StreamProcessorSpec> > &proc_specs_init, list<rc_ptr<StreamProcessorSpecImpl> > &merge_init): CfgElement("using"), proc_specs(proc_specs_init), merge(merge_init) {} rc_ptr<CfgAttributeMap> start_attributes(ostream &cfglog, const string &) { proc_name = ""; rc_ptr<CfgAttributeMap> atts = new CfgAttributeMap; atts->add_item(StringAttribute("proc", proc_name)); return atts; } void end_attributes(ostream &cfglog) { if(proc_name.length() == 0) { cfglog << "proc name is not specified" << endl; return; } rc_ptr<StreamProcessorSpecImpl> spec; if((spec = rc_ptr_cast<StreamProcessorSpecImpl>(get_object(proc_specs, proc_name))) == NULL) { cfglog << "proc '" << proc_name << "' is not defined" << endl; return; } merge.push_front(spec); } }; class ProcElement: public CfgElement { private: string proc_name; list<rc_ptr<StreamProcessorSpecImpl> > merge; map<string, rc_ptr<InputSpec> > input_specs; const map<string, rc_ptr<Filter> > &filters; map<string, rc_ptr<StreamProcessorSpec> > &proc_specs; public: ProcElement(const map<string, rc_ptr<Filter> > &filters_init, map<string, rc_ptr<StreamProcessorSpec> > &proc_specs_init): CfgElement("proc"), filters(filters_init), proc_specs(proc_specs_init) {} rc_ptr<CfgAttributeMap> start_attributes(ostream &cfglog, const string &) { proc_name = ""; merge.clear(); input_specs.clear(); rc_ptr<CfgAttributeMap> atts = new CfgAttributeMap; atts->add_item(StringAttribute("name", proc_name)); return atts; } rc_ptr<CfgElementMap> start_children(ostream &cfglog, const string &) { if(proc_name.length() == 0) { cfglog << "proc name is not specified" << endl; return NULL; } if(has_object(proc_specs, proc_name)) { cfglog << "proc '" << proc_name << "' is already defined" << endl; return NULL; } rc_ptr<CfgElementMap> elms = new CfgElementMap; elms->add_item(UsingElement(proc_specs, merge)); elms->add_item(TreeElement(filters, input_specs)); return elms; } void end_children(ostream &cfglog) { map<string, rc_ptr<InputSpec> >::iterator p = input_specs.begin(); while(p != input_specs.end()) { if(p->second->remove_unused_child_nodes()) input_specs.erase(p++); else ++p; } insert_object<StreamProcessorSpec>(proc_specs, new StreamProcessorSpecImpl(proc_name, input_specs, merge)); } }; //***************************************************************************** // Entry point //***************************************************************************** rc_ptr<CfgElement> make_stream_proc_cfg(const map<string, rc_ptr<Filter> > &filters, map<string, rc_ptr<StreamProcessorSpec> > &specs) { return new ProcElement(filters, specs); } } // namespace SProc_private;
17a6b109ac3fa0b1e1a588b336fc0455f1096d21
b2bc218b284193c331e8366e93f14f96f250b4ac
/test-array.cpp
99f1a134453491e098eb8a99b2b383284215a483
[]
no_license
Buntry/swdev-array-spec
4841faab5487a6bf81dd7915fc3b09ff2dbc5f5d
32533e65e7bb00cd4c8129686831f66f9af2db72
refs/heads/master
2020-12-21T21:48:24.858376
2020-01-29T03:58:39
2020-01-29T03:58:39
236,573,932
0
0
null
null
null
null
UTF-8
C++
false
false
8,539
cpp
test-array.cpp
#include <stdlib.h> #include "object.h" // File with the CwC declaration of Object #include "string.h" // File with the String class #include "array.h" // File with the two list classes #include <iostream> void FAIL() { exit(1); } void OK(const char* m) { std::cout << m << std::endl; } void t_true(bool p) { if (!p) FAIL(); } void t_false(bool p) { if (p) FAIL(); } // test Object equals void test_obj_equal() { Object * s = new Object(); size_t hash = s->hash_me_(); Object * t = new Object(); size_t same = t->hash_me_(); t_false(s->equals(t)); t_false(hash == same); t_false(s->hash() == t->hash()); OK("test objects equal"); delete s; delete t; } // test String equals void test_str_equal() { String * s = new String("Hello"); size_t hash = s->hash_me_(); String * t = new String("Hello"); size_t same = t->hash_me_(); t_true(s->equals(t)); t_true(hash == same); t_true(s->compare(t) == 0); OK("test string equal"); delete s; delete t; } // test String concat void test_str_concat() { String * s = new String("Hello"); String * t = new String("World"); String * u = s->concat(t); t_true(s->equals(s)); t_false(s->equals(t)); t_false(s->equals(u)); t_false(s->compare(t) == 0); OK("test string concat"); delete s; delete t; delete u; } // test void_back void test_void_back() { String * s = new String("Hello"); Array * l = new Array(); l->push_back(s); t_true(l->get(0)->equals(s)); t_true(l->length() == 1); OK("test void_back"); delete s; delete l; } // test add void test_add() { String * s = new String("Hello"); String * t = new String("World"); String * u = new String("Hi"); Array * l = new Array(); l->push_back(s); l->push_back(t); l->add(1, u); Array * l_expect = new Array(); l_expect->push_back(s); l_expect->push_back(u); l_expect->push_back(t); t_true(l->length() == 3); t_true(l->equals(l_expect)); OK("test add"); delete s; delete t; delete u; delete l; delete l_expect; } // test add at pos 0 void test_add_zero() { String * s = new String("Hello"); String * t = new String("World"); Array * l = new Array(); l->push_back(t); l->add(0, s); Array * l_expect = new Array(); l_expect->push_back(s); l_expect->push_back(t); t_true(l->length() == 2); t_true(l->equals(l_expect)); OK("test add zero"); delete s; delete t; delete l; delete l_expect; } // test add all void test_add_all() { String * s = new String("Hello"); String * t = new String("World"); Array * original = new Array(); original->push_back(s); original->push_back(t); String * u = new String("my"); String * v = new String("beautiful"); Array * add = new Array(); add->push_back(u); add->push_back(v); original->add_all(1, add); Object * expected0 = original->get(0); Object * expected1 = original->get(1); Object * expected2 = original->get(2); Object * expected3 = original->get(3); t_true(expected0->equals(s)); t_true(expected1->equals(u)); t_true(expected2->equals(v)); t_true(expected3->equals(t)); t_true(original->length() == 4); OK("test add all"); delete s; delete t; delete original; delete u; delete v; delete add; } // test add all at pos 0 void test_add_all_zero() { String * s = new String("Hello"); String * t = new String("World"); Array * original = new Array(); original->push_back(s); original->push_back(t); String * u = new String("my"); String * v = new String("beautiful"); Array * add = new Array(); add->push_back(u); add->push_back(v); original->add_all(0, add); Object * expected0 = original->get(0); Object * expected1 = original->get(1); Object * expected2 = original->get(2); Object * expected3 = original->get(3); t_true(expected0->equals(u)); t_true(expected1->equals(v)); t_true(expected2->equals(s)); t_true(expected3->equals(t)); t_true(original->length() == 4); OK("test add all 0"); delete s; delete t; delete original; delete u; delete v; delete add; } // test clear void test_clear() { String * s = new String("Hello"); String * t = new String("World"); Array * original = new Array(); original->push_back(s); original->push_back(t); t_true(original->length() == 2); original->clear(); t_true(original->length() == 0); OK("test clear"); delete s; delete t; delete original; } // test equals void test_arr_equals() { String * s = new String("Hello"); String * t = new String("World"); Array * original = new Array(); Array * copy = new Array(); t_true(original->get(0) == nullptr); t_true(original->equals(copy)); original->push_back(s); t_false(original->equals(copy)); original->push_back(t); copy->push_back(s); copy->push_back(t); t_true(original->equals(copy)); t_true(copy->equals(original)); OK("test arrays equal"); delete s; delete t; delete original; delete copy; } // test get void test_get() { String * s = new String("Hello"); String * t = new String("World"); Array * original = new Array(); original->push_back(s); original->push_back(t); Object * expected0 = original->get(0); Object * expected1 = original->get(1); t_true(expected0->equals(s)); t_true(expected1->equals(t)); OK("test get"); delete s; delete t; delete original; } // test hash void test_hash() { String * s = new String("Hello"); String * t = new String("World"); Array * original = new Array(); original->push_back(s); original->push_back(t); Array * other = new Array(); other->push_back(s); t_false(original->hash() == other->hash()); other->push_back(t); size_t hash = original->hash(); size_t hash_other = other->hash(); t_true(hash == hash_other); OK("test hash"); delete s; delete t; delete original; delete other; } // test index of void test_idx() { String * s = new String("Hello"); String * t = new String("World"); Array * original = new Array(); original->push_back(s); original->push_back(t); size_t index_hello = original->index_of(s); t_true(index_hello == 0); size_t index_world = original->index_of(t); t_true(index_world == 1); String * u = new String("Hi"); size_t not_exist = original->index_of(u); t_true(not_exist >= original->length()); OK("test index of"); delete s; delete t; delete original; delete u; } // test remove void test_remove() { String * s = new String("Hello"); String * t = new String("My"); String * u = new String("World"); Array * original = new Array(); original->push_back(s); original->push_back(t); original->push_back(u); size_t original_size = original->length(); t_true(original_size == 3); Object * removed = original->remove(1); t_true(removed->equals(t)); t_true(original->length() == 2); t_true((original->get(1))->equals(u)); OK("test remove"); delete s; delete t; delete u; delete original; } // test set void test_set() { String * s = new String("Hello"); String * t = new String("World"); String * u = new String("Goodbye"); Array * original = new Array(); original->push_back(s); original->push_back(t); t_true((original->get(0))->equals(s)); original->set(0, u); t_true((original->get(0))->equals(u)); OK("test set"); delete s; delete t; delete u; delete original; } // test size void test_size() { String * s = new String("Hello"); String * t = new String("World"); Array * original = new Array(); t_true(original->length() == 0); original->push_back(s); t_true(original->length() == 1); original->push_back(t); t_true(original->length() == 2); OK("test size"); delete s; delete t; delete original; } int main() { test_obj_equal(); test_str_equal(); test_str_concat(); test_void_back(); test_add(); test_add_zero(); test_add_all(); test_add_all_zero(); test_clear(); test_arr_equals(); test_get(); test_hash(); test_idx(); test_remove(); test_set(); test_size(); return 0; }
d8869f3d719f605389fa1ed7b9d5d0d416418c8d
1c0ceecf0a50ef95c3ee1412b64e8ebbb992d418
/FAKEEDGEBOYS/CMoveData.h
6528d6416d6e634272fb0d4f8235b56c1f90449c
[ "MIT" ]
permissive
younasiqw/parallax-csgo-leak
0ec03c2b0a27148219fcce34ffb4eab38020b4e7
6cce3fe4b1343e3c17434c14c37a7cdd1c150dc0
refs/heads/master
2021-04-30T04:46:50.138962
2017-10-25T06:40:54
2017-10-25T06:40:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,632
h
CMoveData.h
class CMoveData { public: bool m_bFirstRunOfFunctions : 1; bool m_bGameCodeMovedPlayer : 1; int m_nPlayerHandle; // edict index on server, client entity handle on client int m_nImpulseCommand; // Impulse command issued. Vector m_vecViewAngles; // Command view angles (local space) Vector m_vecAbsViewAngles; // Command view angles (world space) int m_nButtons; // Attack buttons. int m_nOldButtons; // From host_client->oldbuttons; float m_flForwardMove; float m_flSideMove; float m_flUpMove; float m_flMaxSpeed; float m_flClientMaxSpeed; // Variables from the player edict (sv_player) or entvars on the client. // These are copied in here before calling and copied out after calling. Vector m_vecVelocity; // edict::velocity // Current movement direction. Vector m_vecAngles; // edict::angles Vector m_vecOldAngles; // Output only float m_outStepHeight; // how much you climbed this move Vector m_outWishVel; // This is where you tried Vector m_outJumpVel; // This is your jump velocity // Movement constraints (radius 0 means no constraint) Vector m_vecConstraintCenter; float m_flConstraintRadius; float m_flConstraintWidth; float m_flConstraintSpeedFactor; float m_flUnknown[5]; Vector m_vecAbsOrigin; // edict::origin };
df9be3749878b11a38dbb8cd9e013c261ac7db14
a2d4a2fdbe9a9b94d226c7cc49220b960cfffb80
/leetcode/87_ScrambleString.cpp
0c813a9fe74ce672b1936284a4b1a51004a43a18
[]
no_license
maxtang2013/Algorithms
a056d567d157b2605138ffa06632021bf6370d9b
95b1064de11b4d1190e2695c6d98e729c434f547
refs/heads/master
2020-05-22T00:03:41.180869
2016-10-08T12:41:33
2016-10-08T12:41:33
65,724,232
0
0
null
null
null
null
UTF-8
C++
false
false
3,452
cpp
87_ScrambleString.cpp
#include <iostream> #include <vector> #include <bitset> #include <queue> #include <map> using namespace std; class Solution { public: bool isScramble(string s1, string s2) { int n = (int) s1.size(); bool*** match = new bool**[n+1]; for (int i = 0; i <= n; ++i) { match[i] = new bool*[n]; for (int j = 0; j < n; ++j) { match[i][j] = new bool[n]; memset(match[i][j], 0, sizeof(bool)*n); } } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { match[1][i][j] = s1[i] == s2[j]; } } for (int len = 2; len <= n; ++len) { for (int i = 0; i + len <= n; ++i) { for (int j = 0; j + len <= n; ++j) { for (int k = 1; k < len; ++k) { match[len][i][j] = match[len][i][j] || (match[k][i][j] && match[len-k][i+k][j+k]) || (match[len-k][i][j+k] && match[k][i+len-k][j]); } } } } bool ans = match[n][0][0]; for (int i = 0; i <= n; ++i) { for (int j = 0; j < n; ++j) { delete[] match[i][j]; } delete[] match[i]; } delete[] match; return ans; } bool isScramble1(string s1, string s2) { int m = (int) s1.length(); if (m == 1) return s1 == s2; string s = s1 + s2; if (mIsScramble.count(s) > 0) { return mIsScramble[s]; } bool ans = false; // Counting character helps. // For the largest test case, it reduces the runtime from 430ms to 6ms. int cnt1[26] = {0}, cnt2[26] = {0}, cnt3[26] = {0}; for (int leftLen = 1; leftLen < m; ++leftLen) { string x1 = s1.substr(0, leftLen); string x2 = s1.substr(leftLen, m - leftLen); cnt1[s1[leftLen-1]-'a']++; cnt2[s2[leftLen-1]-'a']++; cnt3[s2[m-leftLen]-'a']++; int i = 0; for (i = 0; i < 26; ++i) { if (cnt1[i] != cnt2[i]) { break; } } if (i == 26 && isScramble(x1, s2.substr(0, leftLen)) && isScramble(x2, s2.substr(leftLen, m-leftLen))) { ans = true; break; } for (i = 0; i < 26; ++i) { if (cnt1[i] != cnt3[i]) { break; } } if (i == 26 && isScramble(x1, s2.substr(m-leftLen, leftLen)) && isScramble(x2, s2.substr(0, m-leftLen))) { ans = true; break; } } return mIsScramble[s] = ans; } private: map<string, bool> mIsScramble; }; void Test0() { Solution sln; cout << sln.isScramble("great", "rgtae") << endl; cout << sln.isScramble("great", "rgtea") << endl; cout << sln.isScramble("great", "tearg") << endl; cout << sln.isScramble("great", "rtgea") << endl; cout << sln.isScramble("great", "rtega") << endl; } int main() { Test0(); return 0; }
f72ed99c4ea189258ef11f66208bb255f3fdee90
2aed63d9aa027419b797e56b508417789a604a8b
/injector2degHex/case_interPhaseChangeFoam_waxman/processor3/0.55/alpha.water
8f27098cf4388b9bfe2c993dca53b1e767669a8f
[]
no_license
icl-rocketry/injectorCFDModelling
70137f1c6574240c7202638c3713102a3e1e9fd8
96591cf2cf3cd4cbd64536d8ae47ed8080ed9016
refs/heads/main
2023-08-25T03:30:59.244137
2021-10-09T21:04:45
2021-10-09T21:04:45
322,369,673
3
5
null
null
null
null
UTF-8
C++
false
false
34,174
water
alpha.water
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v2012 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.55"; object alpha.water; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField nonuniform List<scalar> 2619 ( 8.69377e-43 4.4696e-40 2.20724e-37 5.93632e-36 5.67532e-34 1.33499e-32 1.29144e-30 1.08374e-28 2.00939e-27 3.99496e-26 5.78519e-25 2.69068e-24 7.5145e-24 1.4116e-23 1.9336e-23 1.69995e-23 6.88146e-41 3.28797e-37 4.70934e-35 3.62059e-33 1.34546e-31 3.3137e-29 2.32104e-27 2.3752e-25 5.02278e-24 4.07477e-23 1.9423e-22 6.23732e-22 1.46828e-21 2.66183e-21 3.85375e-21 4.58003e-21 4.22957e-21 3.31772e-21 8.52138e-36 3.69123e-34 8.71821e-32 5.52275e-29 8.14009e-27 1.99389e-24 4.4907e-23 4.14646e-22 2.19178e-21 7.76611e-21 2.02503e-20 4.1311e-20 6.92104e-20 9.83986e-20 1.22078e-19 1.3318e-19 1.26706e-19 1.08866e-19 8.24048e-20 1.42932e-32 2.55688e-30 5.13403e-27 3.07659e-24 1.17403e-22 1.42484e-21 8.83028e-21 3.43057e-20 9.41434e-20 1.99569e-19 3.47372e-19 5.18438e-19 6.86403e-19 8.25601e-19 9.20192e-19 9.49462e-19 9.18862e-19 8.37369e-19 7.1013e-19 3.77738e-28 3.75383e-25 9.00187e-23 2.0277e-21 1.72193e-20 7.82437e-20 2.31466e-19 5.05387e-19 8.85657e-19 1.32471e-18 1.76224e-18 2.14648e-18 2.448e-18 2.65312e-18 2.76364e-18 2.76324e-18 2.68844e-18 2.52937e-18 2.29243e-18 1.51783e-23 8.46435e-22 1.6042e-20 1.04741e-19 3.69132e-19 8.6818e-19 1.55988e-18 2.33658e-18 3.0888e-18 3.74049e-18 4.25369e-18 4.61925e-18 4.85152e-18 4.9665e-18 4.98e-18 4.90359e-18 4.75368e-18 4.52977e-18 4.23532e-18 6.44643e-21 6.82619e-20 3.82705e-19 1.10324e-18 2.16781e-18 3.35097e-18 4.45899e-18 5.3895e-18 6.11238e-18 6.62508e-18 6.95413e-18 7.1314e-18 7.19153e-18 7.15402e-18 7.03965e-18 6.85481e-18 6.60677e-18 6.30381e-18 5.95158e-18 2.49665e-19 9.45918e-19 2.388e-18 4.10798e-18 5.71597e-18 7.01349e-18 7.99149e-18 8.68881e-18 9.15391e-18 9.41479e-18 9.52425e-18 9.51799e-18 9.42438e-18 9.25095e-18 9.00429e-18 8.69245e-18 8.32392e-18 7.90806e-18 7.45484e-18 2.09338e-18 4.12362e-18 6.50039e-18 8.43451e-18 9.85181e-18 1.08311e-17 1.15033e-17 1.19341e-17 1.21718e-17 1.22402e-17 1.21994e-17 1.20722e-17 1.18549e-17 1.15506e-17 1.11658e-17 1.07085e-17 1.01889e-17 9.61842e-18 9.0103e-18 6.65906e-18 9.16779e-18 1.13985e-17 1.29468e-17 1.39961e-17 1.46952e-17 1.5174e-17 1.54428e-17 1.55378e-17 1.54962e-17 1.53675e-17 1.51308e-17 1.4784e-17 1.43312e-17 1.37819e-17 1.31469e-17 1.24388e-17 1.16717e-17 1.08606e-17 1.25217e-17 1.46235e-17 1.63961e-17 1.7627e-17 1.84943e-17 1.90867e-17 1.94941e-17 1.96611e-17 1.9662e-17 1.95524e-17 1.93133e-17 1.89323e-17 1.84131e-17 1.77656e-17 1.7004e-17 1.61433e-17 1.51991e-17 1.41891e-17 1.31307e-17 1.85632e-17 2.03323e-17 2.19225e-17 2.3096e-17 2.39604e-17 2.45418e-17 2.48898e-17 2.49466e-17 2.48773e-17 2.46499e-17 2.42427e-17 2.36539e-17 2.28994e-17 2.1995e-17 2.09584e-17 1.98081e-17 1.85634e-17 1.72467e-17 1.58807e-17 1.44893e-17 1.30963e-17 1.17253e-17 1.04017e-17 2.52232e-17 2.70304e-17 2.87222e-17 2.9982e-17 3.0886e-17 3.14462e-17 3.16722e-17 3.16232e-17 3.14462e-17 3.10319e-17 3.0384e-17 2.95156e-17 2.84522e-17 2.72152e-17 2.58249e-17 2.43035e-17 2.26743e-17 2.09653e-17 1.9206e-17 1.74284e-17 1.56644e-17 1.39433e-17 1.22904e-17 3.34534e-17 3.54979e-17 3.7376e-17 3.87312e-17 3.9642e-17 4.01315e-17 4.02062e-17 4.00674e-17 3.96982e-17 3.90174e-17 3.80548e-17 3.68265e-17 3.53632e-17 3.36942e-17 3.18451e-17 2.98442e-17 2.77215e-17 2.55122e-17 2.32528e-17 2.0983e-17 1.87446e-17 1.65782e-17 1.45184e-17 4.40125e-17 4.63158e-17 4.83772e-17 4.98224e-17 5.07201e-17 5.10877e-17 5.10467e-17 5.07556e-17 5.01062e-17 4.90674e-17 4.76918e-17 4.59978e-17 4.40144e-17 4.17794e-17 3.93278e-17 3.66988e-17 3.39347e-17 3.10823e-17 2.81882e-17 2.52996e-17 2.24648e-17 1.97342e-17 1.7156e-17 5.75912e-17 6.01861e-17 6.24762e-17 6.4035e-17 6.49086e-17 6.51136e-17 6.49674e-17 6.44077e-17 6.33626e-17 6.18398e-17 5.99032e-17 5.75851e-17 5.49132e-17 5.19292e-17 4.86812e-17 4.52241e-17 4.16167e-17 3.79243e-17 3.42111e-17 3.05375e-17 2.69588e-17 2.35289e-17 2.0303e-17 7.52641e-17 7.82529e-17 8.08661e-17 8.256e-17 8.33682e-17 8.34128e-17 8.30682e-17 8.20976e-17 8.04893e-17 7.82955e-17 7.5582e-17 7.2395e-17 6.87737e-17 6.4772e-17 6.04546e-17 5.5896e-17 5.11743e-17 4.63764e-17 4.15905e-17 3.69001e-17 3.23769e-17 2.80792e-17 2.40592e-17 9.87178e-17 1.02237e-16 1.05276e-16 1.07086e-16 1.07743e-16 1.0762e-16 1.06874e-16 1.05272e-16 1.02861e-16 9.97222e-17 9.59236e-17 9.15254e-17 8.65849e-17 8.11795e-17 7.54021e-17 6.93553e-17 6.31451e-17 5.6885e-17 5.06892e-17 4.46686e-17 3.89216e-17 3.35233e-17 2.85241e-17 1.30479e-16 1.34677e-16 1.38194e-16 1.39982e-16 1.40354e-16 1.39873e-16 1.3838e-16 1.35784e-16 1.32197e-16 1.27721e-16 1.22408e-16 1.16339e-16 1.09594e-16 1.02278e-16 9.45214e-17 8.64623e-17 7.82486e-17 7.00369e-17 6.19784e-17 5.42142e-17 4.68718e-17 4.00521e-17 3.38171e-17 1.74028e-16 1.78968e-16 1.82853e-16 1.84315e-16 1.84236e-16 1.82943e-16 1.80217e-16 1.76112e-16 1.70786e-16 1.64374e-16 1.56918e-16 1.48525e-16 1.39307e-16 1.29412e-16 1.19011e-16 1.08279e-16 9.74049e-17 8.66008e-17 7.60755e-17 6.60188e-17 5.65933e-17 4.79284e-17 4.01063e-17 2.32936e-16 2.38505e-16 2.425e-16 2.43354e-16 2.42703e-16 2.40078e-16 2.35647e-16 2.29467e-16 2.21706e-16 2.12562e-16 2.02077e-16 1.90408e-16 1.77738e-16 1.64287e-16 1.50304e-16 1.36022e-16 1.21667e-16 1.07487e-16 9.37442e-17 8.06922e-17 6.85517e-17 5.74924e-17 4.76219e-17 3.10288e-16 3.16417e-16 3.2038e-16 3.20675e-16 3.19256e-16 3.15018e-16 3.08515e-16 2.99702e-16 2.88776e-16 2.75976e-16 2.61383e-16 2.45219e-16 2.27763e-16 2.09356e-16 1.90399e-16 1.7126e-16 1.52259e-16 1.33687e-16 1.15819e-16 9.89358e-17 8.3308e-17 6.91646e-17 5.6658e-17 4.11828e-16 4.18745e-16 4.22725e-16 4.22565e-16 4.1992e-16 4.13618e-16 4.0436e-16 3.92016e-16 3.76859e-16 3.59171e-16 3.39108e-16 3.16956e-16 2.93093e-16 2.67968e-16 2.42176e-16 2.1631e-16 1.90913e-16 1.66437e-16 1.43202e-16 1.21459e-16 1.0145e-16 8.34162e-17 6.75611e-17 5.50678e-16 5.58656e-16 5.6251e-16 5.61481e-16 5.56563e-16 5.46889e-16 5.33213e-16 5.15381e-16 4.93855e-16 4.69003e-16 4.41159e-16 4.10727e-16 3.78208e-16 3.44147e-16 3.09263e-16 2.74332e-16 2.40181e-16 2.07594e-16 1.7712e-16 1.49055e-16 1.23538e-16 1.00694e-16 8.06878e-17 7.45764e-16 7.54855e-16 7.58254e-16 7.55603e-16 7.46803e-16 7.31624e-16 7.10857e-16 6.84429e-16 6.53014e-16 6.17182e-16 5.77536e-16 5.34754e-16 4.8967e-16 4.43095e-16 3.95938e-16 3.49029e-16 3.03282e-16 2.59763e-16 2.19435e-16 1.82876e-16 1.50224e-16 1.21399e-16 9.634e-17 1.01697e-15 1.02817e-15 1.03134e-15 1.02623e-15 1.0116e-15 9.88199e-16 9.57005e-16 9.18052e-16 8.72288e-16 8.20444e-16 7.63469e-16 7.0237e-16 6.38506e-16 5.73314e-16 5.08401e-16 4.44963e-16 3.83857e-16 3.26022e-16 2.72607e-16 2.2463e-16 1.82493e-16 1.46004e-16 1.14755e-16 1.40097e-15 1.4155e-15 1.41783e-15 1.40727e-15 1.38258e-15 1.34582e-15 1.29845e-15 1.24069e-15 1.174e-15 1.0992e-15 1.01769e-15 9.30801e-16 8.40251e-16 7.48056e-16 6.56928e-16 5.693e-16 4.86699e-16 4.09847e-16 3.39415e-16 2.76453e-16 2.21745e-16 1.75234e-16 1.36207e-16 1.98485e-15 1.99591e-15 1.98934e-15 1.9632e-15 1.9185e-15 1.8577e-15 1.78268e-15 1.69388e-15 1.5938e-15 1.4834e-15 1.36504e-15 1.24073e-15 1.11272e-15 9.83252e-16 8.55524e-16 7.33162e-16 6.1942e-16 5.15988e-16 4.2302e-16 3.40694e-16 2.69654e-16 2.10074e-16 1.61103e-16 2.89541e-15 2.88091e-15 2.84616e-15 2.78775e-15 2.70848e-15 2.60822e-15 2.48794e-15 2.34831e-15 2.19352e-15 2.0253e-15 1.84796e-15 1.66507e-15 1.4805e-15 1.29747e-15 1.11948e-15 9.49953e-16 7.92836e-16 6.51709e-16 5.27689e-16 4.19975e-16 3.27988e-16 2.51628e-16 1.8997e-16 4.20328e-15 4.15441e-15 4.08354e-15 3.98608e-15 3.86265e-15 3.70872e-15 3.52307e-15 3.30676e-15 3.06646e-15 2.80669e-15 2.53551e-15 2.25988e-15 1.9866e-15 1.72125e-15 1.46928e-15 1.23435e-15 1.01903e-15 8.26537e-16 6.59519e-16 5.17618e-16 3.98605e-16 3.0097e-16 2.23318e-16 5.91528e-15 5.87175e-15 5.79709e-15 5.67683e-15 5.51104e-15 5.29305e-15 5.02207e-15 4.70062e-15 4.33743e-15 3.9415e-15 3.52689e-15 3.10792e-15 2.69781e-15 2.30625e-15 1.94137e-15 1.60918e-15 1.31223e-15 1.05087e-15 8.26014e-16 6.37921e-16 4.83547e-16 3.59044e-16 2.6151e-16 8.24397e-15 8.24775e-15 8.19462e-15 8.05386e-15 7.83319e-15 7.52623e-15 7.13768e-15 6.67401e-15 6.14625e-15 5.56513e-15 4.94874e-15 4.3199e-15 3.70436e-15 3.12319e-15 2.59017e-15 2.11284e-15 1.69545e-15 1.33746e-15 1.03515e-15 7.85717e-16 5.84993e-16 4.2655e-16 3.04631e-16 1.20388e-14 1.20084e-14 1.18727e-14 1.16071e-14 1.12361e-14 1.07477e-14 1.01496e-14 9.4533e-15 8.67452e-15 7.82885e-15 6.93721e-15 6.02346e-15 5.11952e-15 4.26197e-15 3.48251e-15 2.79528e-15 2.20332e-15 1.70587e-15 1.29641e-15 9.65722e-16 7.04873e-16 5.0374e-16 3.5232e-16 1.91715e-14 1.87737e-14 1.82145e-14 1.7523e-14 1.67408e-14 1.58253e-14 1.47784e-14 1.36142e-14 1.23577e-14 1.10392e-14 9.6978e-15 8.36506e-15 7.06598e-15 5.82943e-15 4.69974e-15 3.71205e-15 2.87468e-15 2.18142e-15 1.62239e-15 1.18257e-15 8.44273e-16 5.90069e-16 4.03548e-16 3.21922e-14 3.09895e-14 2.95486e-14 2.79762e-14 2.6328e-14 2.4511e-14 2.25283e-14 2.04042e-14 1.81908e-14 1.59484e-14 1.37508e-14 1.16638e-14 9.7293e-15 7.95188e-15 6.34148e-15 4.93227e-15 3.75044e-15 2.78889e-15 2.02669e-15 1.44088e-15 1.0031e-15 6.83842e-16 4.56419e-16 5.24282e-14 5.03715e-14 4.79772e-14 4.53045e-14 4.24148e-14 3.91722e-14 3.56144e-14 3.17802e-14 2.78062e-14 2.38619e-14 2.01025e-14 1.66331e-14 1.35431e-14 1.08576e-14 8.53665e-15 6.54197e-15 4.88022e-15 3.55044e-15 2.51852e-15 1.74274e-15 1.17928e-15 7.8181e-16 5.08017e-16 7.88532e-14 7.64447e-14 7.3761e-14 7.04177e-14 6.6415e-14 6.15869e-14 5.60455e-14 4.9852e-14 4.32311e-14 3.65249e-14 3.01497e-14 2.4368e-14 1.93127e-14 1.504e-14 1.15293e-14 8.6581e-15 6.32517e-15 4.4898e-15 3.10073e-15 2.08433e-15 1.3673e-15 8.78772e-16 5.54445e-16 1.1446e-13 1.12315e-13 1.09932e-13 1.06189e-13 1.0099e-13 9.41332e-14 8.58524e-14 7.64137e-14 6.62739e-14 5.58018e-14 4.55674e-14 3.61768e-14 2.8039e-14 2.12335e-14 1.575e-14 1.14645e-14 8.14927e-15 5.62371e-15 3.7667e-15 2.45238e-15 1.55607e-15 9.67117e-16 5.9126e-16 1.88976e-13 1.84969e-13 1.79513e-13 1.71476e-13 1.61043e-13 1.4819e-13 1.33417e-13 1.17104e-13 1.00378e-13 8.40167e-14 6.84057e-14 5.38393e-14 4.09936e-14 3.02905e-14 2.17551e-14 1.52337e-14 1.04266e-14 6.9489e-15 4.49369e-15 2.82304e-15 1.72873e-15 1.03763e-15 6.14941e-16 4.01522e-13 3.79493e-13 3.53825e-13 3.24597e-13 2.92387e-13 2.57816e-13 2.23669e-13 1.90103e-13 1.57814e-13 1.28183e-13 1.02375e-13 7.97984e-14 5.99667e-14 4.32576e-14 3.00655e-14 2.02043e-14 1.32038e-14 8.42105e-15 5.22899e-15 3.15972e-15 1.86482e-15 1.08231e-15 6.25246e-16 8.27332e-13 7.68457e-13 7.07717e-13 6.40843e-13 5.66187e-13 4.83408e-13 4.02442e-13 3.29368e-13 2.65031e-13 2.07608e-13 1.58713e-13 1.1931e-13 8.75491e-14 6.15555e-14 4.12482e-14 2.64936e-14 1.64406e-14 9.94733e-15 5.89362e-15 3.42009e-15 1.94821e-15 1.10034e-15 6.26991e-16 1.42009e-12 1.33957e-12 1.25788e-12 1.15724e-12 1.03397e-12 8.85017e-13 7.2655e-13 5.78013e-13 4.52972e-13 3.47929e-13 2.5776e-13 1.83711e-13 1.2777e-13 8.6222e-14 5.54691e-14 3.39131e-14 1.98901e-14 1.135e-14 6.39222e-15 3.57036e-15 1.97788e-15 1.10213e-15 6.11699e-16 2.32276e-12 2.26837e-12 2.186e-12 2.04348e-12 1.84086e-12 1.57748e-12 1.28824e-12 1.00811e-12 7.68337e-13 5.7498e-13 4.17979e-13 2.87605e-13 1.87419e-13 1.18186e-13 7.20497e-14 4.18341e-14 2.31334e-14 1.24235e-14 6.6685e-15 3.61882e-15 1.97807e-15 1.06658e-15 5.68726e-16 4.52558e-12 4.34479e-12 4.14584e-12 3.80899e-12 3.39675e-12 2.89184e-12 2.33674e-12 1.79331e-12 1.3232e-12 9.44177e-13 6.54945e-13 4.34256e-13 2.68646e-13 1.56767e-13 8.88855e-14 4.87778e-14 2.55213e-14 1.30018e-14 6.74584e-15 3.58287e-15 1.88381e-15 9.718e-16 4.97621e-16 1.14653e-11 9.837e-12 8.99783e-12 7.82832e-12 6.57517e-12 5.42125e-12 4.37628e-12 3.35282e-12 2.40221e-12 1.60361e-12 1.01678e-12 6.23017e-13 3.63697e-13 1.98162e-13 1.03718e-13 5.34376e-14 2.66905e-14 1.31735e-14 6.61616e-15 3.35723e-15 1.67983e-15 8.27032e-16 4.07472e-16 2.54284e-11 2.16188e-11 1.9649e-11 1.7584e-11 1.44899e-11 1.10417e-11 8.36868e-12 6.29499e-12 4.43346e-12 2.77196e-12 1.56205e-12 8.43379e-13 4.51463e-13 2.31124e-13 1.13151e-13 5.5139e-14 2.68317e-14 1.27076e-14 6.02002e-15 2.88417e-15 1.37045e-15 6.46892e-16 3.0854e-16 4.97866e-11 5.42166e-11 4.40357e-11 3.73104e-11 3.25298e-11 2.5868e-11 1.81908e-11 1.20304e-11 7.79059e-12 4.55112e-12 2.29977e-12 1.07484e-12 5.15906e-13 2.48865e-13 1.16984e-13 5.53249e-14 2.54774e-14 1.12159e-14 4.95788e-15 2.243e-15 1.01638e-15 4.62797e-16 2.14227e-16 1.58434e-10 2.72173e-10 1.9861e-10 1.0894e-10 7.06373e-11 5.44292e-11 4.01767e-11 2.41456e-11 1.27901e-11 6.48853e-12 2.96831e-12 1.23808e-12 5.40537e-13 2.50544e-13 1.13095e-13 4.96288e-14 2.09373e-14 8.51819e-15 3.56157e-15 1.53996e-15 6.70703e-16 2.96416e-16 1.32873e-16 7.94311e-10 1.04465e-09 9.18849e-10 6.13413e-10 3.075e-10 1.27433e-10 7.35169e-11 4.37641e-11 2.01165e-11 8.19419e-12 3.33198e-12 1.31466e-12 5.47005e-13 2.38211e-13 9.92431e-14 3.96298e-14 1.51003e-14 5.67006e-15 2.2509e-15 9.29017e-16 3.89118e-16 1.66235e-16 7.11678e-17 3.57371e-09 2.4138e-09 2.1895e-09 1.85564e-09 1.3495e-09 5.56446e-10 1.45515e-10 6.09644e-11 2.62259e-11 9.10018e-12 3.30482e-12 1.21256e-12 4.55186e-13 1.77632e-13 6.69192e-14 2.4222e-14 8.36696e-15 2.9836e-15 1.14771e-15 4.56019e-16 1.85164e-16 7.58848e-17 3.10131e-17 3.32313e-08 5.47388e-09 4.3268e-09 3.40654e-09 2.683e-09 1.45475e-09 3.71176e-10 7.77813e-11 2.84772e-11 9.48636e-12 3.02768e-12 9.86392e-13 3.29613e-13 1.15498e-13 3.89657e-14 1.23529e-14 3.83559e-15 1.31233e-15 4.82219e-16 1.81536e-16 6.94156e-17 2.68447e-17 1.16345e-17 4.62571e-07 1.97813e-08 1.22114e-08 6.31545e-09 3.3429e-09 1.80385e-09 5.34096e-10 8.63421e-11 2.26058e-11 5.95403e-12 1.56997e-12 4.51057e-13 1.36339e-13 4.22927e-14 1.21797e-14 3.22665e-15 9.62605e-16 3.31717e-16 1.1833e-16 4.21303e-17 1.58022e-17 7.86866e-18 5.72625e-18 7.65878e-06 4.61868e-07 7.2086e-08 1.48163e-08 2.98096e-09 1.4223e-09 5.28217e-10 8.11828e-11 1.54222e-11 3.51912e-12 8.20826e-13 2.13073e-13 5.60429e-14 1.44645e-14 3.21108e-15 7.55709e-16 2.15975e-16 6.48695e-17 1.94686e-17 7.85882e-18 5.31908e-18 5.03804e-18 5.07113e-18 0.000422272 7.65614e-06 4.57345e-07 2.89383e-08 6.76053e-11 4.32431e-11 4.30191e-11 7.58002e-12 8.8331e-13 1.42391e-13 1.95377e-14 1.53396e-15 2.3172e-16 7.59505e-17 2.41924e-17 9.22982e-18 5.92856e-18 5.35701e-18 5.20915e-18 4.94178e-18 4.11824e-18 2.90603e-18 1.68318e-18 0.00800729 3.32112e-05 2.33555e-06 3.1914e-07 8.2558e-09 0.0216333 4.29703e-05 1.46387e-05 3.01198e-06 6.94527e-07 0.0332352 0.000565901 0.000283291 2.61838e-05 1.56073e-05 0.0467898 0.0338005 0.0203926 0.00301364 0.00605482 0.133284 0.15111 0.172398 0.213974 0.321849 0.494707 0.510246 0.533857 0.60489 0.73433 0.858825 0.881387 0.918808 0.97272 0.999895 0.988634 0.998006 0.998088 1 1 0.999967 0.999993 0.993171 0.998659 0.982587 0.997129 0.983711 1 1 1 0.99507 0.966124 0.979931 1 1 0.998918 0.995836 1 1 1 0.917525 1 0.981516 1 1 0.898051 1 1 1 1 0.999152 0.997715 1 0.977251 1 0.975764 0.990002 1 1 0.999999 0.665336 0.621428 0.999984 0.99999 0.680362 0.26965 0.383986 0.712761 0.679366 0.609803 0.0333454 0.58561 0.994518 0.979792 0.81708 0.999771 0.999999 1 1 0.994559 0.453257 0.937407 0.996957 0.999989 1 0.167891 0.0681859 0.160656 0.925766 0.797742 0.0818643 0.030735 0.0352289 0.50163 0.982397 1.31954e-44 8.6162e-43 4.46656e-40 2.20687e-37 5.93665e-36 5.67353e-34 1.33462e-32 1.2907e-30 1.08337e-28 2.00907e-27 3.99386e-26 5.78428e-25 2.6909e-24 7.51599e-24 1.41182e-23 1.93392e-23 1.70025e-23 2.24109e-39 3.28702e-37 4.70884e-35 3.62069e-33 1.34512e-31 3.31325e-29 2.32066e-27 2.37442e-25 5.02164e-24 4.07426e-23 1.94214e-22 6.23715e-22 1.46831e-21 2.66199e-21 3.85414e-21 4.58054e-21 4.23e-21 3.31803e-21 8.53623e-36 3.69098e-34 8.7181e-32 5.52275e-29 8.1396e-27 1.99368e-24 4.49017e-23 4.14594e-22 2.19154e-21 7.76542e-21 2.02491e-20 4.13101e-20 6.92109e-20 9.84016e-20 1.22085e-19 1.33189e-19 1.26714e-19 1.08873e-19 8.24087e-20 1.42931e-32 2.55684e-30 5.13404e-27 3.07655e-24 1.17398e-22 1.42476e-21 8.82965e-21 3.43031e-20 9.41373e-20 1.99559e-19 3.47361e-19 5.1843e-19 6.86405e-19 8.25614e-19 9.20219e-19 9.49494e-19 9.1889e-19 8.37394e-19 7.10149e-19 3.77737e-28 3.75383e-25 9.00189e-23 2.02768e-21 1.72189e-20 7.82411e-20 2.31457e-19 5.05366e-19 8.85626e-19 1.32467e-18 1.76221e-18 2.14646e-18 2.448e-18 2.65314e-18 2.76367e-18 2.76328e-18 2.68848e-18 2.5294e-18 2.29246e-18 1.51783e-23 8.46436e-22 1.6042e-20 1.0474e-19 3.69127e-19 8.68164e-19 1.55985e-18 2.33654e-18 3.08875e-18 3.74044e-18 4.25365e-18 4.61923e-18 4.85152e-18 4.96652e-18 4.98002e-18 4.90362e-18 4.7537e-18 4.52979e-18 4.23534e-18 6.44643e-21 6.82619e-20 3.82705e-19 1.10324e-18 2.16779e-18 3.35094e-18 4.45896e-18 5.38947e-18 6.11234e-18 6.62505e-18 6.95411e-18 7.13139e-18 7.19153e-18 7.15402e-18 7.03966e-18 6.85481e-18 6.60678e-18 6.30382e-18 5.95159e-18 2.49665e-19 9.45918e-19 2.388e-18 4.10798e-18 5.71596e-18 7.01348e-18 7.99148e-18 8.68879e-18 9.15389e-18 9.41478e-18 9.52424e-18 9.51798e-18 9.42438e-18 9.25095e-18 9.00429e-18 8.69245e-18 8.32392e-18 7.90807e-18 7.45484e-18 2.09338e-18 4.12362e-18 6.50038e-18 8.4345e-18 9.8518e-18 1.08311e-17 1.15033e-17 1.19341e-17 1.21718e-17 1.22402e-17 1.21994e-17 1.20722e-17 1.18549e-17 1.15506e-17 1.11658e-17 1.07085e-17 1.01889e-17 9.61842e-18 9.0103e-18 6.65906e-18 9.16779e-18 1.13985e-17 1.29467e-17 1.39961e-17 1.46952e-17 1.5174e-17 1.54428e-17 1.55378e-17 1.54962e-17 1.53675e-17 1.51308e-17 1.4784e-17 1.43312e-17 1.37819e-17 1.31469e-17 1.24388e-17 1.16717e-17 1.08606e-17 1.25217e-17 1.46235e-17 1.63961e-17 1.7627e-17 1.84943e-17 1.90867e-17 1.94941e-17 1.96612e-17 1.9662e-17 1.95524e-17 1.93133e-17 1.89323e-17 1.84131e-17 1.77656e-17 1.7004e-17 1.61433e-17 1.51991e-17 1.41891e-17 1.31307e-17 1.85632e-17 2.03323e-17 2.19225e-17 2.3096e-17 2.39604e-17 2.45418e-17 2.48898e-17 2.49466e-17 2.48773e-17 2.46499e-17 2.42427e-17 2.36539e-17 2.28994e-17 2.1995e-17 2.09584e-17 1.98081e-17 1.85634e-17 1.72467e-17 1.58807e-17 1.44893e-17 1.30963e-17 1.17253e-17 1.04017e-17 2.52232e-17 2.70304e-17 2.87222e-17 2.9982e-17 3.0886e-17 3.14462e-17 3.16722e-17 3.16232e-17 3.14462e-17 3.10319e-17 3.0384e-17 2.95156e-17 2.84522e-17 2.72152e-17 2.58249e-17 2.43035e-17 2.26743e-17 2.09653e-17 1.9206e-17 1.74284e-17 1.56644e-17 1.39433e-17 1.22904e-17 3.34534e-17 3.54979e-17 3.7376e-17 3.87312e-17 3.9642e-17 4.01315e-17 4.02062e-17 4.00674e-17 3.96982e-17 3.90174e-17 3.80548e-17 3.68265e-17 3.53632e-17 3.36942e-17 3.18451e-17 2.98442e-17 2.77215e-17 2.55122e-17 2.32528e-17 2.0983e-17 1.87446e-17 1.65782e-17 1.45183e-17 4.40125e-17 4.63158e-17 4.83772e-17 4.98224e-17 5.07201e-17 5.10877e-17 5.10467e-17 5.07556e-17 5.01062e-17 4.90674e-17 4.76918e-17 4.59978e-17 4.40144e-17 4.17794e-17 3.93278e-17 3.66988e-17 3.39347e-17 3.10823e-17 2.81882e-17 2.52996e-17 2.24648e-17 1.97342e-17 1.7156e-17 5.75912e-17 6.01861e-17 6.24762e-17 6.4035e-17 6.49086e-17 6.51136e-17 6.49674e-17 6.44077e-17 6.33626e-17 6.18398e-17 5.99032e-17 5.75851e-17 5.49132e-17 5.19292e-17 4.86812e-17 4.52241e-17 4.16167e-17 3.79243e-17 3.42111e-17 3.05375e-17 2.69588e-17 2.35289e-17 2.0303e-17 7.52641e-17 7.82529e-17 8.08661e-17 8.25599e-17 8.33682e-17 8.34128e-17 8.30682e-17 8.20976e-17 8.04893e-17 7.82955e-17 7.5582e-17 7.2395e-17 6.87737e-17 6.4772e-17 6.04546e-17 5.5896e-17 5.11743e-17 4.63764e-17 4.15905e-17 3.69001e-17 3.23769e-17 2.80792e-17 2.40592e-17 9.87178e-17 1.02237e-16 1.05276e-16 1.07086e-16 1.07743e-16 1.0762e-16 1.06874e-16 1.05272e-16 1.02861e-16 9.97222e-17 9.59237e-17 9.15254e-17 8.65849e-17 8.11795e-17 7.54021e-17 6.93553e-17 6.31451e-17 5.6885e-17 5.06892e-17 4.46686e-17 3.89216e-17 3.35233e-17 2.85241e-17 1.30479e-16 1.34677e-16 1.38194e-16 1.39982e-16 1.40354e-16 1.39873e-16 1.3838e-16 1.35784e-16 1.32197e-16 1.2772e-16 1.22408e-16 1.16339e-16 1.09594e-16 1.02278e-16 9.45214e-17 8.64623e-17 7.82486e-17 7.00369e-17 6.19784e-17 5.42142e-17 4.68718e-17 4.00521e-17 3.38171e-17 1.74028e-16 1.78968e-16 1.82853e-16 1.84315e-16 1.84236e-16 1.82943e-16 1.80217e-16 1.76112e-16 1.70786e-16 1.64374e-16 1.56918e-16 1.48525e-16 1.39307e-16 1.29412e-16 1.19011e-16 1.08279e-16 9.74049e-17 8.66008e-17 7.60755e-17 6.60187e-17 5.65933e-17 4.79284e-17 4.01063e-17 2.32936e-16 2.38505e-16 2.425e-16 2.43354e-16 2.42703e-16 2.40078e-16 2.35647e-16 2.29467e-16 2.21706e-16 2.12562e-16 2.02077e-16 1.90408e-16 1.77738e-16 1.64287e-16 1.50304e-16 1.36022e-16 1.21667e-16 1.07487e-16 9.37442e-17 8.06922e-17 6.85517e-17 5.74924e-17 4.76219e-17 3.10288e-16 3.16417e-16 3.2038e-16 3.20675e-16 3.19256e-16 3.15018e-16 3.08515e-16 2.99702e-16 2.88776e-16 2.75976e-16 2.61383e-16 2.45219e-16 2.27763e-16 2.09356e-16 1.90399e-16 1.7126e-16 1.52259e-16 1.33687e-16 1.15819e-16 9.89358e-17 8.3308e-17 6.91646e-17 5.6658e-17 4.11828e-16 4.18745e-16 4.22725e-16 4.22565e-16 4.1992e-16 4.13618e-16 4.0436e-16 3.92016e-16 3.76859e-16 3.5917e-16 3.39108e-16 3.16956e-16 2.93093e-16 2.67968e-16 2.42176e-16 2.1631e-16 1.90913e-16 1.66437e-16 1.43202e-16 1.21459e-16 1.0145e-16 8.34162e-17 6.75611e-17 5.50678e-16 5.58656e-16 5.6251e-16 5.61481e-16 5.56563e-16 5.46889e-16 5.33212e-16 5.15381e-16 4.93855e-16 4.69003e-16 4.41159e-16 4.10727e-16 3.78208e-16 3.44147e-16 3.09263e-16 2.74332e-16 2.40181e-16 2.07594e-16 1.7712e-16 1.49055e-16 1.23538e-16 1.00694e-16 8.06878e-17 7.45764e-16 7.54855e-16 7.58254e-16 7.55603e-16 7.46803e-16 7.31624e-16 7.10856e-16 6.8443e-16 6.53014e-16 6.17182e-16 5.77536e-16 5.34754e-16 4.8967e-16 4.43096e-16 3.95938e-16 3.49029e-16 3.03282e-16 2.59763e-16 2.19435e-16 1.82876e-16 1.50224e-16 1.21399e-16 9.634e-17 1.01697e-15 1.02817e-15 1.03134e-15 1.02623e-15 1.0116e-15 9.88199e-16 9.57005e-16 9.18052e-16 8.72288e-16 8.20444e-16 7.63468e-16 7.0237e-16 6.38505e-16 5.73314e-16 5.08401e-16 4.44963e-16 3.83857e-16 3.26022e-16 2.72607e-16 2.2463e-16 1.82493e-16 1.46004e-16 1.14755e-16 1.40097e-15 1.4155e-15 1.41783e-15 1.40727e-15 1.38258e-15 1.34582e-15 1.29845e-15 1.24069e-15 1.174e-15 1.0992e-15 1.01769e-15 9.30801e-16 8.4025e-16 7.48056e-16 6.56928e-16 5.693e-16 4.86699e-16 4.09847e-16 3.39415e-16 2.76453e-16 2.21745e-16 1.75234e-16 1.36207e-16 1.98485e-15 1.99591e-15 1.98934e-15 1.9632e-15 1.9185e-15 1.8577e-15 1.78268e-15 1.69388e-15 1.5938e-15 1.4834e-15 1.36504e-15 1.24073e-15 1.11272e-15 9.83252e-16 8.55524e-16 7.33162e-16 6.1942e-16 5.15988e-16 4.2302e-16 3.40693e-16 2.69653e-16 2.10074e-16 1.61103e-16 2.89541e-15 2.8809e-15 2.84616e-15 2.78775e-15 2.70848e-15 2.60821e-15 2.48794e-15 2.3483e-15 2.19352e-15 2.0253e-15 1.84796e-15 1.66507e-15 1.4805e-15 1.29747e-15 1.11948e-15 9.49953e-16 7.92836e-16 6.51709e-16 5.27689e-16 4.19975e-16 3.27988e-16 2.51628e-16 1.8997e-16 4.20328e-15 4.15441e-15 4.08354e-15 3.98608e-15 3.86264e-15 3.70872e-15 3.52307e-15 3.30675e-15 3.06646e-15 2.80669e-15 2.53551e-15 2.25988e-15 1.98659e-15 1.72125e-15 1.46928e-15 1.23435e-15 1.01903e-15 8.26537e-16 6.59519e-16 5.17618e-16 3.98605e-16 3.0097e-16 2.23318e-16 5.91528e-15 5.87175e-15 5.79709e-15 5.67684e-15 5.51104e-15 5.29305e-15 5.02207e-15 4.70063e-15 4.33742e-15 3.9415e-15 3.52689e-15 3.10792e-15 2.69781e-15 2.30625e-15 1.94137e-15 1.60918e-15 1.31223e-15 1.05087e-15 8.26014e-16 6.37921e-16 4.83547e-16 3.59044e-16 2.6151e-16 8.24397e-15 8.24775e-15 8.19462e-15 8.05387e-15 7.8332e-15 7.52623e-15 7.13768e-15 6.67402e-15 6.14626e-15 5.56513e-15 4.94874e-15 4.3199e-15 3.70436e-15 3.12319e-15 2.59017e-15 2.11284e-15 1.69545e-15 1.33746e-15 1.03515e-15 7.85717e-16 5.84993e-16 4.2655e-16 3.04631e-16 1.20388e-14 1.20084e-14 1.18727e-14 1.16071e-14 1.12361e-14 1.07477e-14 1.01496e-14 9.45331e-15 8.67453e-15 7.82885e-15 6.93722e-15 6.02347e-15 5.11952e-15 4.26198e-15 3.48251e-15 2.79528e-15 2.20332e-15 1.70587e-15 1.29641e-15 9.65722e-16 7.04873e-16 5.0374e-16 3.5232e-16 1.91715e-14 1.87736e-14 1.82145e-14 1.7523e-14 1.67407e-14 1.58253e-14 1.47784e-14 1.36141e-14 1.23577e-14 1.10391e-14 9.6978e-15 8.36506e-15 7.06597e-15 5.82943e-15 4.69974e-15 3.71205e-15 2.87468e-15 2.18141e-15 1.62239e-15 1.18257e-15 8.44273e-16 5.90069e-16 4.03548e-16 3.21922e-14 3.09894e-14 2.95485e-14 2.79761e-14 2.6328e-14 2.4511e-14 2.25283e-14 2.04042e-14 1.81907e-14 1.59484e-14 1.37508e-14 1.16638e-14 9.7293e-15 7.95187e-15 6.34148e-15 4.93227e-15 3.75044e-15 2.78889e-15 2.02669e-15 1.44088e-15 1.0031e-15 6.83842e-16 4.56419e-16 5.24282e-14 5.03714e-14 4.79772e-14 4.53045e-14 4.24147e-14 3.91721e-14 3.56144e-14 3.17801e-14 2.78062e-14 2.38619e-14 2.01025e-14 1.66331e-14 1.35431e-14 1.08576e-14 8.53665e-15 6.54198e-15 4.88022e-15 3.55044e-15 2.51852e-15 1.74274e-15 1.17928e-15 7.8181e-16 5.08017e-16 7.88532e-14 7.64447e-14 7.3761e-14 7.04177e-14 6.6415e-14 6.15869e-14 5.60455e-14 4.98519e-14 4.32311e-14 3.65249e-14 3.01497e-14 2.4368e-14 1.93127e-14 1.504e-14 1.15293e-14 8.6581e-15 6.32517e-15 4.4898e-15 3.10073e-15 2.08433e-15 1.3673e-15 8.78772e-16 5.54445e-16 1.1446e-13 1.12315e-13 1.09932e-13 1.06189e-13 1.0099e-13 9.41331e-14 8.58524e-14 7.64137e-14 6.62739e-14 5.58018e-14 4.55674e-14 3.61768e-14 2.8039e-14 2.12336e-14 1.575e-14 1.14645e-14 8.14927e-15 5.6237e-15 3.7667e-15 2.45238e-15 1.55607e-15 9.67117e-16 5.9126e-16 1.88976e-13 1.84969e-13 1.79513e-13 1.71476e-13 1.61043e-13 1.4819e-13 1.33417e-13 1.17104e-13 1.00378e-13 8.40166e-14 6.84056e-14 5.38393e-14 4.09936e-14 3.02906e-14 2.17552e-14 1.52338e-14 1.04266e-14 6.9489e-15 4.49369e-15 2.82304e-15 1.72873e-15 1.03763e-15 6.14941e-16 4.01522e-13 3.79493e-13 3.53825e-13 3.24597e-13 2.92387e-13 2.57816e-13 2.23669e-13 1.90103e-13 1.57814e-13 1.28183e-13 1.02375e-13 7.97984e-14 5.99667e-14 4.32576e-14 3.00656e-14 2.02043e-14 1.32038e-14 8.42104e-15 5.22898e-15 3.15972e-15 1.86482e-15 1.08231e-15 6.25246e-16 8.27332e-13 7.68456e-13 7.07717e-13 6.40843e-13 5.66187e-13 4.83408e-13 4.02442e-13 3.29368e-13 2.65031e-13 2.07608e-13 1.58713e-13 1.1931e-13 8.7549e-14 6.15556e-14 4.12483e-14 2.64935e-14 1.64406e-14 9.94732e-15 5.89361e-15 3.42009e-15 1.94821e-15 1.10034e-15 6.26991e-16 1.42009e-12 1.33957e-12 1.25788e-12 1.15724e-12 1.03397e-12 8.85017e-13 7.2655e-13 5.78013e-13 4.52972e-13 3.47929e-13 2.5776e-13 1.83712e-13 1.2777e-13 8.6222e-14 5.54691e-14 3.39131e-14 1.98901e-14 1.135e-14 6.39221e-15 3.57036e-15 1.97788e-15 1.10213e-15 6.11699e-16 2.32276e-12 2.26837e-12 2.186e-12 2.04348e-12 1.84086e-12 1.57748e-12 1.28824e-12 1.00811e-12 7.68337e-13 5.7498e-13 4.17979e-13 2.87605e-13 1.87419e-13 1.18186e-13 7.20497e-14 4.18341e-14 2.31334e-14 1.24235e-14 6.6685e-15 3.61882e-15 1.97807e-15 1.06658e-15 5.68726e-16 4.52558e-12 4.34479e-12 4.14584e-12 3.80899e-12 3.39675e-12 2.89184e-12 2.33674e-12 1.79331e-12 1.32319e-12 9.44177e-13 6.54945e-13 4.34256e-13 2.68646e-13 1.56767e-13 8.88855e-14 4.87778e-14 2.55213e-14 1.30017e-14 6.74584e-15 3.58287e-15 1.88381e-15 9.71799e-16 4.97621e-16 1.14653e-11 9.83701e-12 8.99783e-12 7.82832e-12 6.57517e-12 5.42125e-12 4.37628e-12 3.35282e-12 2.40221e-12 1.60361e-12 1.01678e-12 6.23017e-13 3.63697e-13 1.98162e-13 1.03718e-13 5.34376e-14 2.66905e-14 1.31735e-14 6.61616e-15 3.35723e-15 1.67983e-15 8.27032e-16 4.07472e-16 2.54284e-11 2.16189e-11 1.96491e-11 1.7584e-11 1.44899e-11 1.10417e-11 8.36869e-12 6.29499e-12 4.43346e-12 2.77196e-12 1.56205e-12 8.43379e-13 4.51462e-13 2.31124e-13 1.13151e-13 5.5139e-14 2.68317e-14 1.27076e-14 6.02002e-15 2.88417e-15 1.37045e-15 6.46892e-16 3.0854e-16 4.97867e-11 5.42167e-11 4.40358e-11 3.73104e-11 3.25299e-11 2.5868e-11 1.81908e-11 1.20304e-11 7.79059e-12 4.55112e-12 2.29977e-12 1.07484e-12 5.15905e-13 2.48865e-13 1.16984e-13 5.53249e-14 2.54774e-14 1.12159e-14 4.95788e-15 2.243e-15 1.01638e-15 4.62797e-16 2.14227e-16 1.58432e-10 2.72173e-10 1.98611e-10 1.0894e-10 7.06371e-11 5.44292e-11 4.01768e-11 2.41457e-11 1.27901e-11 6.48853e-12 2.96831e-12 1.23808e-12 5.40536e-13 2.50544e-13 1.13095e-13 4.96288e-14 2.09373e-14 8.51819e-15 3.56157e-15 1.53996e-15 6.70703e-16 2.96416e-16 1.32873e-16 7.94307e-10 1.04464e-09 9.18848e-10 6.13409e-10 3.07496e-10 1.27432e-10 7.35168e-11 4.37641e-11 2.01165e-11 8.19419e-12 3.33198e-12 1.31466e-12 5.47004e-13 2.38211e-13 9.92431e-14 3.96299e-14 1.51003e-14 5.67007e-15 2.2509e-15 9.29017e-16 3.89118e-16 1.66235e-16 7.11678e-17 3.57383e-09 2.41379e-09 2.18948e-09 1.85563e-09 1.34949e-09 5.56442e-10 1.45515e-10 6.09644e-11 2.62258e-11 9.10018e-12 3.30482e-12 1.21256e-12 4.55185e-13 1.77631e-13 6.69193e-14 2.4222e-14 8.36698e-15 2.9836e-15 1.14771e-15 4.56019e-16 1.85164e-16 7.58849e-17 3.10131e-17 3.32347e-08 5.47466e-09 4.32679e-09 3.4065e-09 2.683e-09 1.45476e-09 3.71179e-10 7.77815e-11 2.84772e-11 9.48636e-12 3.02768e-12 9.86391e-13 3.29612e-13 1.15498e-13 3.89658e-14 1.2353e-14 3.8356e-15 1.31233e-15 4.82219e-16 1.81536e-16 6.94156e-17 2.68447e-17 1.16345e-17 4.62624e-07 1.98005e-08 1.22123e-08 6.31523e-09 3.34286e-09 1.80387e-09 5.34105e-10 8.63429e-11 2.26058e-11 5.95402e-12 1.56997e-12 4.51056e-13 1.36339e-13 4.22928e-14 1.21798e-14 3.22665e-15 9.62606e-16 3.31717e-16 1.1833e-16 4.21303e-17 1.58022e-17 7.86866e-18 5.72625e-18 7.65986e-06 4.62243e-07 7.21023e-08 1.48151e-08 2.98076e-09 1.42231e-09 5.28229e-10 8.11842e-11 1.54222e-11 3.51911e-12 8.20825e-13 2.13073e-13 5.60429e-14 1.44646e-14 3.2111e-15 7.55707e-16 2.15976e-16 6.48695e-17 1.94687e-17 7.85882e-18 5.31903e-18 5.03802e-18 5.07112e-18 0.000422392 7.66083e-06 4.57426e-07 2.89334e-08 6.76044e-11 4.32429e-11 4.30189e-11 7.58014e-12 8.83308e-13 1.42392e-13 1.95378e-14 1.53396e-15 2.317e-16 7.59466e-17 2.41926e-17 9.22995e-18 5.92854e-18 5.357e-18 5.20913e-18 4.94169e-18 4.11804e-18 2.90586e-18 1.68305e-18 0.00800988 3.32278e-05 2.33564e-06 3.19126e-07 8.25525e-09 0.0216381 4.29804e-05 1.4639e-05 3.01198e-06 6.94527e-07 0.0332366 0.000565828 0.000283305 2.61838e-05 1.56074e-05 0.0467899 0.0338013 0.0203935 0.00301365 0.00605487 0.133281 0.151108 0.172398 0.213974 0.321848 0.494705 0.510246 0.533857 0.60489 0.73433 0.858825 0.881387 0.918808 0.97272 0.999895 0.988634 0.998006 0.998088 1 1 0.999967 0.999993 0.993172 0.998659 0.982587 0.997128 0.983712 1 1 1 0.995071 0.966124 0.979931 1 1 0.998918 0.995836 1 1 1 0.917523 1 0.981516 1 1 0.898051 1 1 1 1 0.999152 0.997715 1 0.977251 1 0.975766 0.990002 1 1 0.999999 0.665338 0.621429 0.999984 0.99999 0.680365 0.269654 0.383987 0.712746 0.67937 0.609803 0.0333709 0.585645 0.994508 0.979786 0.817093 0.99977 0.999999 1 1 0.994559 0.454969 0.937179 0.996962 0.999989 1 0.172798 0.0715795 0.16123 0.925817 0.797696 0.0853363 0.0295827 0.0358399 0.501676 0.98239 ) ; boundaryField { inlet { type fixedValue; value nonuniform List<scalar> 0(); } outlet { type inletOutlet; inletValue nonuniform List<scalar> 0(); value nonuniform List<scalar> 0(); } walls { type zeroGradient; } side1 { type cyclic; } side2 { type cyclic; } procBoundary3to0 { type processor; value nonuniform List<scalar> 70 ( 5.6489e-50 3.40622e-47 1.16272e-44 4.17276e-43 3.29922e-41 8.77315e-40 7.54528e-38 5.46837e-36 1.09264e-34 2.13996e-33 2.86943e-32 1.39567e-31 3.89629e-31 7.25932e-31 9.81398e-31 8.36862e-31 4.52494e-48 4.52494e-48 4.52494e-48 4.42352e-24 4.42352e-24 2.01331e-21 2.01331e-21 5.32899e-20 5.51094e-19 1.98456e-18 3.87145e-18 5.55335e-18 6.97365e-18 8.37957e-18 1.00231e-17 1.20431e-17 1.20431e-17 1.09474e-17 9.86776e-18 8.8336e-18 9.56403e-52 4.42362e-50 3.40166e-47 1.16281e-44 4.16737e-43 3.29496e-41 8.75282e-40 7.5437e-38 5.4659e-36 1.09243e-34 2.13934e-33 2.86896e-32 1.39577e-31 3.89706e-31 7.26045e-31 9.81566e-31 8.37006e-31 4.42459e-24 4.42459e-24 2.01347e-21 2.01347e-21 5.32918e-20 5.51105e-19 1.98458e-18 3.87147e-18 5.55336e-18 6.97365e-18 8.37957e-18 1.00231e-17 1.20431e-17 1.20431e-17 1.09474e-17 9.86776e-18 8.8336e-18 ) ; } procBoundary3to0throughside1 { type processorCyclic; value uniform 4.52494e-48; } procBoundary3to1 { type processor; value nonuniform List<scalar> 72 ( 2.81915e-17 3.31487e-17 3.89689e-17 4.58348e-17 5.39744e-17 6.36416e-17 7.50735e-17 8.84374e-17 1.03825e-16 1.21311e-16 1.41006e-16 1.63018e-16 1.87358e-16 2.13826e-16 2.4192e-16 2.70703e-16 2.98696e-16 3.23852e-16 3.43833e-16 3.56803e-16 3.62687e-16 3.63895e-16 3.56972e-16 3.36724e-16 3.0157e-16 2.54879e-16 2.01985e-16 1.48269e-16 9.93584e-17 5.90726e-17 3.03769e-17 1.36677e-17 6.83933e-18 5.30151e-18 4.96208e-18 4.97491e-19 2.81915e-17 3.31487e-17 3.89689e-17 4.58348e-17 5.39744e-17 6.36416e-17 7.50735e-17 8.84374e-17 1.03825e-16 1.21311e-16 1.41006e-16 1.63018e-16 1.87358e-16 2.13827e-16 2.41921e-16 2.70704e-16 2.98697e-16 3.23852e-16 3.43833e-16 3.56803e-16 3.62687e-16 3.63895e-16 3.56972e-16 3.36724e-16 3.0157e-16 2.54879e-16 2.01985e-16 1.48269e-16 9.93584e-17 5.90726e-17 3.03769e-17 1.36677e-17 6.83933e-18 5.30151e-18 4.96206e-18 4.97392e-19 ) ; } procBoundary3to2 { type processor; value nonuniform List<scalar> 14 ( 9.15724e-18 1.07293e-17 1.25895e-17 1.47666e-17 1.73318e-17 2.03702e-17 2.39636e-17 9.15724e-18 1.07293e-17 1.25895e-17 1.47666e-17 1.73318e-17 2.03702e-17 2.39636e-17 ) ; } procBoundary3to4 { type processor; value nonuniform List<scalar> 10(0.0687231 0.0274327 0.0348993 0.230463 0.839168 0.071794 0.0274327 0.035566 0.230478 0.83919); } } // ************************************************************************* //
11aeca1cee3b1eea5bf3edf0b3ef9ef0bb3cee32
e013471b5943830c98168aebc3b0439dcef8ad31
/Source/LD48-26/LD48-26/engine.cpp
d7644c249c70a0e44f6020352711866e3b3c1eb6
[ "MIT" ]
permissive
PhaZ90771/Cave-Runner
493ec0f5c681e50ba2e220ab62bd62946e465951
19d2f8875ab3c1cb7092c8742e8693d7b1709e10
refs/heads/master
2021-03-22T00:11:13.226041
2018-11-23T23:22:54
2018-11-23T23:22:54
118,711,657
0
0
null
null
null
null
UTF-8
C++
false
false
4,347
cpp
engine.cpp
#pragma region define #define _USE_MATH_DEFINES #pragma endregion #include "SDL.h" #include "SDL_image.h" #include "SDL_ttf.h" #include "SDL_opengl.h" #include "freeglut.h" #include <stdlib.h> #include <time.h> #include <math.h> #include <string> #include "utilities.h" #include "level.h" #include "engine.h" #include "player.h" Engine::Engine(int width, int height, int bpp) { srand((unsigned int)time(NULL)); // Set Window Attributes mScreenWidth = width; mScreenHeight = height; mScreenBPP = bpp; mFPS = 60; // Window Caption mCaption = "Cave Runner -- Ludum Dare 26: Minimalism [PhaZ90771]"; // Set State mQuit = false; // Initialize Window Init(); // Initialize OpenGL InitOpenGL(); GenerateLevel(); CreatePlayer(); } Engine::~Engine() { delete mLevel; delete mPlayer; // Quit SDL SDL_Quit(); } void Engine::Init() { // Init SDL if(SDL_Init(SDL_INIT_VIDEO) == -1) { exit(1); } // Set up OpenGL attribures SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); // Setup Screen if((mScreen = SDL_SetVideoMode(mScreenWidth, mScreenHeight, mScreenBPP, SDL_OPENGL)) == NULL) { exit(2); } // Set Window Caption SDL_WM_SetCaption(mCaption.c_str(), NULL); InitOpenGL(); } void Engine::InitOpenGL() { glEnable(GL_LINE_SMOOTH); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glViewport((GLint)0.f, (GLint)0.f, mScreenWidth, mScreenHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, mScreenWidth * 2, 0, mScreenHeight * 2); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glClearColor((float)0.6, (float)0.6, (float)0.6, 1.f); GLenum error = glGetError(); if(error != GL_NO_ERROR) { exit(error); } } void Engine::GenerateLevel() { mLevel = new Level(40, 0.f, 0.f, 20, 60, 400.f, 180, 300, mScreenWidth, mScreenHeight, 0.40f); } void Engine::CreatePlayer() { mPlayer = new Player(0.f, (float)mScreenHeight, mScreenWidth, mScreenHeight); CollisionType c; while((c = mLevel->CheckCollision(mPlayer->GetPosition())) != NOCOLLISION) { if(c == LEFTWALL) mPlayer->Bump(1.f); else if(c == RIGHTWALL) mPlayer->Bump(-1.f); } } void Engine::Update() { if(SDL_PollEvent(&mEvent)) { if((mEvent.type == SDL_QUIT) || ((mEvent.type == SDL_KEYDOWN) && (mEvent.key.keysym.sym == SDLK_ESCAPE))) { mQuit = true; } else if(mEvent.type == SDL_KEYDOWN) { if(mEvent.key.keysym.sym == SDLK_LEFT) mPlayer->SetLeft(true); if(mEvent.key.keysym.sym == SDLK_RIGHT) mPlayer->SetRight(true); if(mEvent.key.keysym.sym == SDLK_UP) mPlayer->SetUp(true); if(mEvent.key.keysym.sym == SDLK_DOWN) mPlayer->SetDown(true); } else if(mEvent.type == SDL_KEYUP) { if(mEvent.key.keysym.sym == SDLK_LEFT) mPlayer->SetLeft(false); if(mEvent.key.keysym.sym == SDLK_RIGHT) mPlayer->SetRight(false); if(mEvent.key.keysym.sym == SDLK_UP) mPlayer->SetUp(false); if(mEvent.key.keysym.sym == SDLK_DOWN) mPlayer->SetDown(false); } } mLevel->Update(); if(mPlayer->Update()) mQuit = true; CollisionType c; bool d = false; while((c = mLevel->CheckCollision(mPlayer->GetPosition())) != NOCOLLISION) { d = true; if(c == LEFTWALL) mPlayer->Bump(1.f); else if(c == RIGHTWALL) mPlayer->Bump(-1.f); } if(d) mPlayer->Hit(); } void Engine::RenderGUI() { // Health GUI glColor3f( 1.f, 0.f, 0.f ); int offset = 10; int w = 20; int h = 30; int x = (-mScreenWidth) + (2 * offset); int y = (2 * mScreenHeight) - (2 * offset) - h; for(int i = 0; i < mPlayer->GetHP(); i++) { glBegin(GL_QUADS); glVertex2f( (GLfloat)x , (GLfloat)y); glVertex2f( (GLfloat)x+w, (GLfloat)y); glVertex2f( (GLfloat)x+w, (GLfloat)y+h); glVertex2f( (GLfloat)x , (GLfloat)y+h); glEnd(); x += w + offset; } } void Engine::Render() { // Setup glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef( (GLfloat)mScreenWidth, (GLint)0.f, (GLint)-1.f ); mPlayer->Render(); mLevel->Render(); RenderGUI(); // Swap Screen SDL_GL_SwapBuffers(); } void Engine::FPS() { if(mFPSTimer.getTicks() < 1000 / mFPS) { SDL_Delay((1000 / mFPS) - mFPSTimer.getTicks()); } } void Engine::Run() { mFPSTimer.start(); while(!mQuit) { Update(); Render(); FPS(); } }
2df0d20298fe4ba9f17dec0eb365f937957354da
a5f9c197762cf4339bc279af80caf07a69c3d963
/MathLib/Matrix3.cpp
aeb193277ac69507044013eed767ca2187b5a4ab
[]
no_license
alexkitching/MathLibrary
af3d6c84281979d432cbc90fa6a3d1a7626c1489
b34aa54a99ce6464a42a5f44b5e1d6da5cbfecb9
refs/heads/master
2021-09-01T12:00:04.457850
2017-12-26T21:42:25
2017-12-26T21:42:25
108,608,560
0
0
null
null
null
null
UTF-8
C++
false
false
8,156
cpp
Matrix3.cpp
//////////////////////////////////////////////////////////////////// // File: <Matrix3.cpp> // Author: <Alex Kitching> // Date Created: <16/02/17> // Brief: <Source file for the Matrix 3x3 Class.> //////////////////////////////////////////////////////////////////// #include "Matrix3.h" #include "Vector2.h" #include <math.h> const Matrix3 Matrix3::Identity = { Vector3::Right , Vector3::Up, Vector3::Forward }; Matrix3::Matrix3() { } Matrix3::Matrix3(const float a_m11, const float a_m12, const float a_m13, const float a_m21, const float a_m22, const float a_m23, const float a_m31, const float a_m32, const float a_m33) { m11 = a_m11, m12 = a_m12, m13 = a_m13; m21 = a_m21, m22 = a_m22, m23 = a_m23; m31 = a_m31, m32 = a_m32, m33 = a_m33; } Matrix3::Matrix3(const Vector3 x, const Vector3 y, const Vector3 z) { xAxis = x; yAxis = y; zAxis = z; } Matrix3::Matrix3(const Matrix3 & a_mat) { m11 = a_mat.m11; m12 = a_mat.m12; m13 = a_mat.m13; m21 = a_mat.m21; m22 = a_mat.m22; m23 = a_mat.m23; m31 = a_mat.m31; m32 = a_mat.m32; m33 = a_mat.m33; } Matrix3::~Matrix3() { } float Matrix3::GetValue(const unsigned int row, const unsigned int col) const { return m[row][col]; } Vector3 Matrix3::GetRow(const unsigned int row) const { return Vector3(m[row][0], m[row][1], m[row][2]); } void Matrix3::GetRow(const unsigned int row, Vector3 a_vector) const { a_vector = Vector3(m[row][0], m[row][1], m[row][2]); } Vector3 Matrix3::GetCol(const unsigned int col) const { return Vector3(m[0][col], m[1][col], m[2][col]); } void Matrix3::GetCol(const unsigned int col, Vector3 a_vector) const { a_vector = Vector3(m[0][col], m[1][col], m[2][col]); } void Matrix3::SetValue(const unsigned int row, const unsigned int col, const float a_value) { m[row][col] = a_value; } void Matrix3::SetRow(const unsigned int row, const float a_value) { m[row][0] = a_value, m[row][1] = a_value, m[row][2] = a_value; } void Matrix3::SetRow(const unsigned int row, const Vector3 a_vector) { float x = 0.f, y = 0.f, z = 0.f; a_vector.GetX(x); a_vector.GetY(y); a_vector.GetZ(z); m[row][0] = x, m[row][1] = y, m[row][2] = z; } void Matrix3::SetCol(const unsigned int col, const float value) { m[0][col] = value, m[1][col] = value, m[2][col] = value; } void Matrix3::SetCol(const unsigned int col, const Vector3 a_vector) { float x = 0.f, y = 0.f, z = 0.f; a_vector.GetX(x); a_vector.GetY(y); a_vector.GetZ(z); m[0][col] = x, m[1][col] = y, m[2][col] = z; } Matrix3::operator float*() { return i; } Matrix3::operator const float*() const { return i; } float Matrix3::operator[](const unsigned int index) const { return i[index]; } bool Matrix3::operator==(const Matrix3 & a_mat) const { m11 == a_mat.m11; m12 == a_mat.m12; m13 == a_mat.m13; m21 == a_mat.m21; m22 == a_mat.m22; m23 == a_mat.m23; m31 == a_mat.m31; m32 == a_mat.m32; m33 == a_mat.m33; return this; } bool Matrix3::operator!=(const Matrix3 & a_mat) const { m11 != a_mat.m11; m12 != a_mat.m12; m13 != a_mat.m13; m21 != a_mat.m21; m22 != a_mat.m22; m23 != a_mat.m23; m31 != a_mat.m31; m32 != a_mat.m32; m33 != a_mat.m33; return this; } Matrix3 Matrix3::operator+(const Matrix3 & a_mat) { return Matrix3(m11 + a_mat.m11, m12 + a_mat.m12, m13 + a_mat.m13, m21 + a_mat.m21, m22 + a_mat.m22, m23 + a_mat.m23, m31 + a_mat.m31, m32 + a_mat.m32, m33 + a_mat.m33); } Matrix3 Matrix3::operator+(const float & a_value) { return Matrix3(m11 + a_value, m12 + a_value, m13 + a_value, m21 + a_value, m22 + a_value, m23 + a_value, m31 + a_value, m32 + a_value, m33 + a_value); } Matrix3 Matrix3::operator-(const Matrix3 & a_mat) { return Matrix3(m11 - a_mat.m11, m12 - a_mat.m12, m13 - a_mat.m13, m21 - a_mat.m21, m22 - a_mat.m22, m23 - a_mat.m23, m31 - a_mat.m31, m32 - a_mat.m32, m33 - a_mat.m33); } Matrix3 Matrix3::operator-(const float & a_value) { return Matrix3(m11 - a_value, m12 - a_value, m13 - a_value, m21 - a_value, m22 - a_value, m23 - a_value, m31 - a_value, m32 - a_value, m33 - a_value); } Matrix3 Matrix3::operator*(const Matrix3 & a_mat) { Matrix3 mResult; mResult.m11 = (m11 * a_mat.m11) + (m12 * a_mat.m21) + (m13 * a_mat.m31); mResult.m12 = (m11 * a_mat.m12) + (m12 * a_mat.m22) + (m13 * a_mat.m32); mResult.m13 = (m11 * a_mat.m13) + (m12 * a_mat.m23) + (m13 * a_mat.m33); mResult.m21 = (m21 * a_mat.m11) + (m22 * a_mat.m21) + (m23 * a_mat.m31); mResult.m22 = (m21 * a_mat.m12) + (m22 * a_mat.m22) + (m23 * a_mat.m32); mResult.m23 = (m21 * a_mat.m13) + (m22 * a_mat.m23) + (m23 * a_mat.m33); mResult.m31 = (m31 * a_mat.m11) + (m32 * a_mat.m21) + (m33 * a_mat.m31); mResult.m32 = (m31 * a_mat.m12) + (m32 * a_mat.m22) + (m33 * a_mat.m32); mResult.m33 = (m31 * a_mat.m13) + (m32 * a_mat.m23) + (m33 * a_mat.m33); return mResult; } Matrix3 Matrix3::operator*(const float & a_value) { Matrix3 mResult; mResult.m11 = (m11 * a_value) + (m12 * a_value) + (m13 * a_value); mResult.m12 = (m11 * a_value) + (m12 * a_value) + (m13 * a_value); mResult.m13 = (m11 * a_value) + (m12 * a_value) + (m13 * a_value); mResult.m21 = (m21 * a_value) + (m22 * a_value) + (m23 * a_value); mResult.m22 = (m21 * a_value) + (m22 * a_value) + (m23 * a_value); mResult.m23 = (m21 * a_value) + (m22 * a_value) + (m23 * a_value); mResult.m31 = (m31 * a_value) + (m32 * a_value) + (m33 * a_value); mResult.m32 = (m31 * a_value) + (m32 * a_value) + (m33 * a_value); mResult.m33 = (m31 * a_value) + (m32 * a_value) + (m33 * a_value); return mResult; } Vector3 Matrix3::operator*(const Vector3 & a_vec) { float fX = ( m11 * a_vec.GetX() ) + ( m12 * a_vec.GetY() ) + ( m13 * a_vec.GetZ() ); float fY = ( m21 * a_vec.GetX() ) + ( m22 * a_vec.GetY() ) + ( m23 * a_vec.GetZ() ); float fZ = ( m31 * a_vec.GetX() ) + ( m32 * a_vec.GetY() ) + ( m33 * a_vec.GetZ() ); return Vector3(fX, fY, fZ); } Vector3 Matrix3::operator*(const Vector3* a_vec) { float fX = (m11 * a_vec->GetX()) + (m12 * a_vec->GetY()) + (m13 * a_vec->GetZ()); float fY = (m21 * a_vec->GetX()) + (m22 * a_vec->GetY()) + (m23 * a_vec->GetZ()); float fZ = (m31 * a_vec->GetX()) + (m32 * a_vec->GetY()) + (m33 * a_vec->GetZ()); return Vector3(fX, fY, fZ); } void Matrix3::Transpose() { Matrix3 mat = *this; m11 = mat.m11; m12 = mat.m21; m13 = mat.m31; m21 = mat.m12; m22 = mat.m22; m23 = mat.m32; m31 = mat.m13; m32 = mat.m23; m33 = mat.m33; } float Matrix3::Determinant() const { return (m11 * ((m22 * m33) - (m23 * m32)) //1st Col - m12 * ((m21 * m33) - (m23 * m31)) //2nd Col + m13 * ((m21 * m32) - (m22 * m31)));//3rd Col } bool Matrix3::Inverse() { float fDeter = Determinant(); if (fDeter != 0.0f) { const float fInvDeter = 1 / fDeter; Matrix3 mat = *this; m11 = ((mat.m22 * mat.m33) - (mat.m32 * mat.m23)) * fInvDeter; m12 = ((mat.m13 * mat.m32) - (mat.m12 * mat.m33)) * fInvDeter; m13 = ((mat.m12 * mat.m23) - (mat.m13 * mat.m22)) * fInvDeter; m21 = ((mat.m23 * mat.m31) - (mat.m21 * mat.m33)) * fInvDeter; m22 = ((mat.m22 * mat.m33) - (mat.m13 * mat.m31)) * fInvDeter; m23 = ((mat.m21 * mat.m13) - (mat.m11 * mat.m23)) * fInvDeter; m31 = ((mat.m21 * mat.m32) - (mat.m31 * mat.m22)) * fInvDeter; m32 = ((mat.m31 * mat.m12) - (mat.m11 * mat.m32)) * fInvDeter; m33 = ((mat.m11 * mat.m22) - (mat.m21 * mat.m12)) * fInvDeter; return true; } else { return false; } } void Matrix3::Rotate(const float fAngle) { const float co = cosf(fAngle); const float si = sinf(fAngle); m11 = co; m12 = si; m13 = 0.0f; m21 = -si; m22 = co; m23 = 0.0f; m31 = 0.0f; m32 = 0.0f; m33 = 1.0f; } void Matrix3::Scale(const float fXScalar, const float fYScalar) { m11 = m11 * fXScalar; m12 = 0.0f; m13 = 0.0f; m21 = 0.0f; m22 = m22 * fYScalar; m23 = 0.0f; m31 = 0.0f; m32 = 0.0f; m33 = 1.0f; }
3032c7f9b475f6bd04a08b62e0e674c3190b22be
7e0c7486672b94752d0f311d6ec09c1e378c3fdb
/1-1链表/1-1链表/main.cpp
57de0952d47ef731035e54e44273c4af33a56bf0
[ "Apache-2.0" ]
permissive
jianlong108/grammar-of-C-plus-plus
48bba81e5e363a3c2cc8e4546f66e0c380bf61fe
8eda24baf6bb7c1df9af63287b6c45debf54bc6e
refs/heads/master
2020-04-08T13:05:28.553501
2019-09-15T05:07:09
2019-09-15T05:07:09
159,374,989
0
0
null
null
null
null
UTF-8
C++
false
false
1,541
cpp
main.cpp
// // main.cpp // 1-1链表 // // Created by Wangjianlong on 2019/2/17. // Copyright © 2019 JL.Com. All rights reserved. // #include <iostream> #include "SingleLinkList.hpp" #include "Stack.hpp" #include "string.hpp" #include "Tree.hpp" using namespace std; int main(int argc, const char * argv[]) { LinkList head; creatLinkListTail(&head, 3); LinkList p = head->next; while (p) { cout << p->val << endl; p = p->next; } int value= 108; int i = 2; // int status = getElement(head, i, &value); // cout << "状态"<< status << ";" <<i << "位置处的值为" << value << endl; // deleteLinkList(&head); cout << "---------------------"<< endl; p = head->next; //在第i==2个结点之前插入数据108 insertList(&head, i, value); while (p) { cout << p->val << endl; p = p->next; } cout << "---------------------"<< endl; p = head->next; //删除第i==3个结点之前插入数据 deletEleList(&head, 3, &value); while (p) { cout << p->val << endl; p = p->next; } cout << "---------------------"<< endl; // string s = getTmpString(string("123abc4")); // cout << s << endl; string s = string("123abc4acd"); string t = string("abc"); cout << t << "在主串:"<<s <<"中的位置:" << indexSubString(s, t, 0) << endl; cout << "---------------------"<< endl; BiTree tree = BiTree(); creatBigTree(&tree); preOrderTraverse(tree); return 0; }
58650d46b7df8a25b2a7e0bce87984a589aeca31
d1398aa7a872f2873cf3c1b5f064cb567ae844f9
/libraries/http_backend/tests/serve_directory.cc
7e40af2ed6d1e632a713c4e1f74fd858022b620e
[ "MIT" ]
permissive
iodcpp/iod
25880f5b01159780b185eba789567042c7776db0
c2dbb1d28b5d0e98f287a55422db270812125d1e
refs/heads/master
2020-02-26T15:05:35.205622
2019-12-03T17:33:35
2019-12-03T17:33:35
83,549,866
4
1
null
null
null
null
UTF-8
C++
false
false
788
cc
serve_directory.cc
#include <boost/filesystem.hpp> #include <li/http_client/http_client.hh> #include <li/http_backend/http_backend.hh> #include "test.hh" using namespace li; int main() { namespace fs = boost::filesystem; fs::path root = fs::unique_path(); fs::create_directories(root / "subdir"); { std::ofstream o((root / "subdir" / "hello.txt").string()); o << "hello world."; } api<http_request, http_response> my_api; my_api.add_subapi("/test", serve_directory(root.string())); auto ctx = http_serve(my_api, 12352, s::non_blocking); CHECK_EQUAL("serve_file not found", http_get("http://localhost:12352/test/subdir/xxx").status, 404); CHECK_EQUAL("serve_file", http_get("http://localhost:12352/test/subdir/hello.txt").body, "hello world."); fs::remove_all(root); }
2bb8b57f826c37ae3ba54b6dbab03b3b092e989e
cfcbd8e85b532de969e921bc132098d9d237dccc
/src/HF/Breit.hpp
630e0a6ff7b6e3daaa86dedd011eb3b73e031680
[]
no_license
hf6391964/ampsci
eb892af7daea947708548cffe72defc342bc944f
726d60825553c055eb8d266e2f742bbaecc92ac9
refs/heads/main
2023-02-13T16:48:45.240984
2020-12-11T07:49:05
2020-12-11T07:49:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,884
hpp
Breit.hpp
#pragma once #include "Wavefunction/DiracSpinor.hpp" #include <utility> #include <vector> namespace HF { namespace hidden { struct Breit_Bk_ba; // forward decl } //****************************************************************************** //! Breit (Hartree-Fock Breit) interaction potential class Breit { public: //! Contains ptr to core: careful if updating core (e.g., in HF) Breit(const std::vector<DiracSpinor> &in_core, double in_scale = 1.0) : p_core(&in_core), m_scale(in_scale) {} // nb: During HF, must update orbitals each time //! () operator: returns VbrFa(Fa) DiracSpinor operator()(const DiracSpinor &Fa) const { return VbrFa(Fa); } //! Calculates V_br*Fa = \sum_b\sum_k B^k_ba F_b [Breit part of HF-Breit pot.] DiracSpinor VbrFa(const DiracSpinor &Fa) const; //! dV_b*Fa, dV_b is the exchange RPA correction arising due to Fb -> Fb + dFb //! @details //! K is multipolarity of RPA operator, Fb is core state, with Xbeta and Ybeta //! perturbations. "reduced rhs" DiracSpinor dVbrX_Fa(int kappa, int K, const DiracSpinor &Fa, const DiracSpinor &Fb, const DiracSpinor &Xbeta, const DiracSpinor &Ybeta) const; //! Direct RPA correction arising due to Fb -> Fb + dFb DiracSpinor dVbrD_Fa(int kappa, int K, const DiracSpinor &Fa, const DiracSpinor &Fb, const DiracSpinor &Xbeta, const DiracSpinor &Ybeta) const; private: const std::vector<DiracSpinor> *const p_core; const double m_scale; // Calculates \sum_k B^k_ba F_b (single core contr. to V_brFa) void BkbaFb(DiracSpinor *BFb, const DiracSpinor &Fa, const DiracSpinor &Fb) const; void MOPk_ij_Fc(DiracSpinor *BFc, const double Cang, const hidden::Breit_Bk_ba &Bkab, int k, int ki, int kj, const DiracSpinor &Fc) const; void Nk_ij_Fc(DiracSpinor *BFc, const double Cang, const hidden::Breit_Bk_ba &Bkij, int k, int ki, int kj, const DiracSpinor &Fc) const; // Internal angular coefs double eta(int k, int ka, int kb) const; std::pair<double, double> Mk(int k) const; double Nkba(int k, int kb, int ka) const; std::pair<double, double> Ok(int k) const; double Pk(int k) const; public: Breit &operator=(const Breit &) = delete; Breit(const Breit &) = delete; ~Breit() = default; }; //****************************************************************************** namespace hidden { struct Breit_Bk_ba { // Class to hold the Breit-Coulomb integrals public: Breit_Bk_ba(const DiracSpinor &Fb, const DiracSpinor &Fa); const std::size_t max_k; std::vector<std::vector<double>> bk_0{}; std::vector<std::vector<double>> bk_inf{}; std::vector<std::vector<double>> gk_0{}; std::vector<std::vector<double>> gk_inf{}; }; } // namespace hidden } // namespace HF
490ff3ea7787db114f9fa3c7768a481157bc8605
1005f450818900b923e345b73d77628f20d1875e
/thirdparty/msgpack-c/include/msgpack/preprocessor/iteration/detail/bounds/upper1.hpp
f1f8091e287066357da435b02cb734780c275d5d
[ "MIT" ]
permissive
qicosmos/rest_rpc
c7ad37547a9dcb616832b32bc110a237977b8c74
93088a7e0f0ddb3786de40ed7b6311852644edbf
refs/heads/master
2023-08-23T06:56:42.464323
2023-07-04T02:57:13
2023-07-04T02:57:13
162,215,656
1,504
354
MIT
2023-07-05T03:37:24
2018-12-18T02:01:52
C++
UTF-8
C++
false
false
4,301
hpp
upper1.hpp
# /* ************************************************************************** # * * # * (C) Copyright Paul Mensonides 2002. # * 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 for most recent version. */ # # include <msgpack/preprocessor/slot/detail/shared.hpp> # # undef MSGPACK_PP_ITERATION_FINISH_1 # # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_4 # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_5 # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_6 # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_7 # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_8 # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_9 # undef MSGPACK_PP_ITERATION_FINISH_1_DIGIT_10 # # if MSGPACK_PP_SLOT_TEMP_3 == 0 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 0 # elif MSGPACK_PP_SLOT_TEMP_3 == 1 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 1 # elif MSGPACK_PP_SLOT_TEMP_3 == 2 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 2 # elif MSGPACK_PP_SLOT_TEMP_3 == 3 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 3 # elif MSGPACK_PP_SLOT_TEMP_3 == 4 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 4 # elif MSGPACK_PP_SLOT_TEMP_3 == 5 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 5 # elif MSGPACK_PP_SLOT_TEMP_3 == 6 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 6 # elif MSGPACK_PP_SLOT_TEMP_3 == 7 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 7 # elif MSGPACK_PP_SLOT_TEMP_3 == 8 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 8 # elif MSGPACK_PP_SLOT_TEMP_3 == 9 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 9 # endif # # if MSGPACK_PP_SLOT_TEMP_2 == 0 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 0 # elif MSGPACK_PP_SLOT_TEMP_2 == 1 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 1 # elif MSGPACK_PP_SLOT_TEMP_2 == 2 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 2 # elif MSGPACK_PP_SLOT_TEMP_2 == 3 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 3 # elif MSGPACK_PP_SLOT_TEMP_2 == 4 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 4 # elif MSGPACK_PP_SLOT_TEMP_2 == 5 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 5 # elif MSGPACK_PP_SLOT_TEMP_2 == 6 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 6 # elif MSGPACK_PP_SLOT_TEMP_2 == 7 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 7 # elif MSGPACK_PP_SLOT_TEMP_2 == 8 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 8 # elif MSGPACK_PP_SLOT_TEMP_2 == 9 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 9 # endif # # if MSGPACK_PP_SLOT_TEMP_1 == 0 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 0 # elif MSGPACK_PP_SLOT_TEMP_1 == 1 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 1 # elif MSGPACK_PP_SLOT_TEMP_1 == 2 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 2 # elif MSGPACK_PP_SLOT_TEMP_1 == 3 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 3 # elif MSGPACK_PP_SLOT_TEMP_1 == 4 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 4 # elif MSGPACK_PP_SLOT_TEMP_1 == 5 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 5 # elif MSGPACK_PP_SLOT_TEMP_1 == 6 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 6 # elif MSGPACK_PP_SLOT_TEMP_1 == 7 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 7 # elif MSGPACK_PP_SLOT_TEMP_1 == 8 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 8 # elif MSGPACK_PP_SLOT_TEMP_1 == 9 # define MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 9 # endif # # if MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3 # define MSGPACK_PP_ITERATION_FINISH_1 MSGPACK_PP_SLOT_CC_3(MSGPACK_PP_ITERATION_FINISH_1_DIGIT_3, MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2, MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1) # elif MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2 # define MSGPACK_PP_ITERATION_FINISH_1 MSGPACK_PP_SLOT_CC_2(MSGPACK_PP_ITERATION_FINISH_1_DIGIT_2, MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1) # else # define MSGPACK_PP_ITERATION_FINISH_1 MSGPACK_PP_ITERATION_FINISH_1_DIGIT_1 # endif
9b5115e60e19acb6009614ad447f4bbb8aa5c914
8fb6c4dd7a60ac559ae8155f053a5c289fdd3718
/6-Polymorphism/2-8-VirtualTablePointer/main.cpp
118b01938cf214d2da247cb8f436184f09abcfb8
[ "Apache-2.0" ]
permissive
marklove5102/CPlusPlusCode
e83ed02a78a899253356701d9c151ed6e5696424
61403af90c7c73faec1959d9d63238b8bfddaf87
refs/heads/master
2022-01-20T17:10:42.985193
2018-07-27T18:14:08
2018-07-27T18:14:08
null
0
0
null
null
null
null
GB18030
C++
false
false
375
cpp
main.cpp
#include <iostream> #include "Circle.h" #include <stdlib.h> using namespace std; int main() { Shape shape; int *p = (int *)&shape; cout << (unsigned int)(*p) << endl; // 虚函数表地址 Circle circle(100); int *q = (int *)&circle; q++; cout << (unsigned int)(*q) << endl; // 打印出的还是虚函数表地址 system("pause"); return 0; }
690e9eb1363267710c80a5d0643671eea56482c6
9b1639af63f7fc82f0e488b452dee0cb7ae22a3b
/atomic/retail/SOURCE/LOADMGR/SRC/LOADMGMT.CPP
ff97907db2dbb80d224cc49fe9a269eaa3224e0a
[]
no_license
ExpLife/Norton_AntiVirus_SourceCode
af7cd446efb2f3a10bba04db8e7438092c7299c0
b90225233fa7930d2ef7922080ed975b7abfae8c
refs/heads/master
2017-12-19T09:15:25.150463
2016-10-03T02:33:34
2016-10-03T02:33:34
76,859,815
2
4
null
2016-12-19T12:21:02
2016-12-19T12:21:01
null
UTF-8
C++
false
false
17,104
cpp
LOADMGMT.CPP
// Copyright 1996 Symantec Corporation //********************************************************************** // // $Header: S:/LOADMGR/VCS/loadmgmt.cpv 1.1 18 Apr 1997 13:54:28 DSACKIN $ // // Description: Server load management routines // //********************************************************************** // // $Log: S:/LOADMGR/VCS/loadmgmt.cpv $ // // Rev 1.1 18 Apr 1997 13:54:28 DSACKIN // Ported from Tesla // // Rev 1.0 13 Mar 1997 15:11:40 RFULLER // Initial revision // // Rev 1.0 08 Nov 1996 11:52:50 DKEEFER // Initial revision // // Rev 1.2 10 May 1996 19:02:28 TSmith // Added flag to prevent access to uninitialized // load management structure. // // Rev 1.1 24 Apr 1996 18:32:24 TSmith // Added some OutputDebugString calls. // // Rev 1.0 16 Apr 1996 19:22:14 TSmith // Initial revision. // // Rev 1.0 10 Aug 1994 10:09:12 GDZIECI // Baseline Mario from Vishnu with Win32 awk changes applied // // Rev 1.7 04 Dec 1993 14:15:52 JMILLARD // return error from InitServerLoadManagement // // Rev 1.6 16 Sep 1993 23:46:02 JMILLARD // fix check of no tables and not initialized // // Rev 1.5 16 Sep 1993 22:20:22 JMILLARD // check for tables initialized OK // // Rev 1.4 25 May 1993 00:34:24 EHU // Added symalog.h for log.h. // // Rev 1.3 16 Apr 1993 17:48:42 JMILLARD // add log.h for DEFAULT_COLOR // // Rev 1.2 13 Apr 1993 22:25:36 JMILLARD // fix ifdef DEBUG problem // // Rev 1.1 13 Apr 1993 22:20:24 JMILLARD // change load management stuff // // Rev 1.0 09 Apr 1993 17:07:44 JMILLARD // Initial revision. // //********************************************************************** #define FUZZY 1 // // Common includes // #include "platform.h" // cross-platform type definitions #include "loadmgmt.h" // local prototypes and typedefs #include "errcode.h" // OK, FAILED #include "comstr.h" // COM_NO_MEMORY #include <iostream.h> // // Netware specific includes // #if defined( SYM_NLM ) #include "servutil.h" // GetServerLoad #include "cfgfile.h" // for backlist.h #include "backlist.h" // background event struct #include "thrdmgmt.h" // RelinquishControl #if defined( SYM_DEBUG ) #undef EOF // for stdio.h #include <stdio.h> // sprintf #include "intrcept.h" // for monitor.h #include "nfevlist.h" // for monitor.h #include "pipe.h" // for navpipe.h #include "navpipe.h" // for monitor.h #include "monitor.h" // PostString #include "symalog.h" // for log.h #include "log.h" // Log and DEFAULT_COLOR #include <conio.h> // ConsolePrintf #endif // SYM_DEBUG #endif // SYM_NLM // // Win32 specific includes // #if defined( SYM_WIN32 ) #include "ntsrvutl.h" #endif // SYM_WIN32 #if defined( FUZZY ) #include "fuzzy.h" // fuzzy structures, typedefs, etc. #include "fuzyload.h" // fuzzy routines and tables for server load // management #endif // FUZZY #define TRACE ( ERR_TRACE_ID( LOADMGMT_CPP ) ) //********************************************************************** // // local static data // //********************************************************************** #if defined( FUZZY ) BOOL bTablesNotInitialized = TRUE; DWORD dwUseCount = 0; #endif // FUZZY //********************************************************************** // // local prototypes // //********************************************************************** WORD UpdateServerLoadManagement( LPLOADMANAGEMENT lpLoad, WORD wServerLoad, SWORD swServerLoadChange ); //********************************************************************** // // Main functions // //********************************************************************** //********************************************************************** // InitServerLoadManagement() // // Description: Initialize server load management // // Parameters: // // Return Value: // // See Also: // //********************************************************************** // 04/15/1996 TSMITH Added Windows NT performance counter inits // // 03/31/1993 JMILLARD Function Created. //********************************************************************** BOOL InitServerLoadManagement( LPLOADMANAGEMENT lpLoadManagement, DWORD dwTargetServerLoad ) { SYM_ASSERT( lpLoadManagement != NULL ); #if defined( FUZZY ) // keep track of load management users dwUseCount += 1; // initialize all the static fuzzy control tables if ( bTablesNotInitialized ) { if ( InitializeFuzzyTables( ) != FAILED ) { bTablesNotInitialized = FALSE; } else { // free any partial tables FreeFuzzyTables( ); SetLastError( ERROR_NOT_ENOUGH_MEMORY ); return FALSE; } } #endif // FUZZY #if defined( SYM_WIN32 ) // Init performance counters for processor time if ( ! InitPerfCounter( COUNTER_OBJECT_NAME, COUNTER_NAME ) ) { DWORD dwErrorCode = GetLastError(); SetLastError( dwErrorCode ); return FALSE; } #endif // SYM_WIN32 lpLoadManagement->dwTargetLoad = dwTargetServerLoad; lpLoadManagement->dwCurrentDelay = NO_DELAY; lpLoadManagement->wTick1DelayCount = 0; lpLoadManagement->wTick2DelayCount = 0; lpLoadManagement->wThreadSwitch1Count = 0; lpLoadManagement->wThreadSwitch1 = 0; lpLoadManagement->wThreadSwitch2 = 1; lpLoadManagement->bLoadManagementInitialized = TRUE; return TRUE; } //*************************************************************************** // DeInitServerLoadManagement() // // Description: DeInitialize server load management // // Parameters: // // Return Value: // // See Also: // //*************************************************************************** // 04/15/1996 TSMITH Added WinNT performance counter cleanup call // // 03/31/1993 JMILLARD Function Created. //*************************************************************************** VOID DeInitServerLoadManagement( LPLOADMANAGEMENT lpLoadManagement ) { lpLoadManagement->bLoadManagementInitialized = FALSE; #if defined(FUZZY) if (dwUseCount > 0) { dwUseCount -= 1; // keep track of load management users } // free the static fuzzy control tables if (dwUseCount == 0) { if (!bTablesNotInitialized) { bTablesNotInitialized = TRUE; FreeFuzzyTables( ); } } #endif // FUZZY #if defined( SYM_WIN32 ) ClosePerfCounter(); #endif } //*************************************************************************** // ServerLoadManagementDelay() // // Description: delay based on server load and target load // // Parameters: // // Return Value: // // See Also: // //*************************************************************************** // 03/31/1993 JMILLARD Function Created. //*************************************************************************** VOID ServerLoadManagementDelay( LPLOADMANAGEMENT lpLoad ) { WORD wLoop; #if defined( SYM_DEBUG ) TCHAR szDebugMsg[ 256 ]; memset( szDebugMsg, 0xFF, sizeof( szDebugMsg ) ); DWORD dwDelay = lpLoad->dwCurrentDelay; SPRINTF( szDebugMsg, _T( "Load management delay is %d\nTarget load is %d\n" ), dwDelay, lpLoad->dwTargetLoad ); #if defined(SYM_NLM) PostString( szDebugMsg, DEFAULT_COLOR ); #elif defined(SYM_WIN32) OutputDebugString( szDebugMsg ); #endif #endif // SYM_DEBUG // run any coarse delays first if (lpLoad->wTick1DelayCount != 0) { DelayThreadTicks( lpLoad->wTick1Delay ); goto AllDone; } if (lpLoad->wTick2DelayCount != 0) { DelayThreadTicks( lpLoad->wTick2Delay ); goto AllDone; } // no coarse? - then run the fine delays if (lpLoad->wThreadSwitch1Count != 0) { wLoop = lpLoad->wThreadSwitch1; while (wLoop > 0) { RelinquishControl( ); wLoop -= 1; } goto AllDone; } // this is the default delay if all the others have run out wLoop = lpLoad->wThreadSwitch2; while (wLoop > 0) { RelinquishControl( ); wLoop -= 1; } AllDone: return; // required because of preceding label } //*************************************************************************** // UpdateServerLoad( ) // // Description: Updates all server load management based on the current // server load // // Parameters: None // // Return Value: // // See Also: // //*************************************************************************** // 04/15/1996 TSMITH Added #ifdef to support WinNT performance counter use. // Supports update of a single LPLOADMANAGEMENT struct // passed to the function rather than an array of them // as in NAVNLM. // // 03/31/1993 JMILLARD Function Created. //*************************************************************************** WORD UpdateServerLoad( #if defined( SYM_WIN32 ) LPLOADMANAGEMENT lpLoad #else VOID #endif ) { #if defined( SYM_NLM ) LPBACKEVENT lpBackEvent; WORD wErr = OK; #elif defined( SYM_WIN32 ) BOOL fResult; DWORD dwServerLoad; #endif WORD wServerLoad; SWORD swLoadChange; STATIC WORD wLastLoad = 0; #if defined( SYM_DEBUG ) TCHAR szDebugMsg[ 256 ]; #endif #if defined( SYM_NLM ) wServerLoad = wGetServerLoad( ) / LOAD_SCALE; // get the current load // calculate change in load since last time swLoadChange = wServerLoad - wLastLoad; #elif defined( SYM_WIN32 ) fResult = GetCpuLoad( &dwServerLoad ); #if defined( SYM_DEBUG ) SPRINTF( szDebugMsg, _T( "dwServerLoad=%d\n" ), dwServerLoad ); OutputDebugString( szDebugMsg ); #endif wServerLoad = ( WORD )dwServerLoad; swLoadChange = wServerLoad - wLastLoad; #endif #if defined( SYM_NLM ) // loop through all scheduled events, and update server load management // information lpBackEvent = pGetFirstBackEventList( ); while (lpBackEvent) { UpdateServerLoadManagement( &lpBackEvent->LoadManage, wServerLoad, swLoadChange); lpBackEvent = lpBackEvent->lpNextBackList; } // update the server load for next time; wLastLoad = wServerLoad; return (wErr); #elif defined( SYM_WIN32 ) UpdateServerLoadManagement( lpLoad, wServerLoad, swLoadChange ); wLastLoad = wServerLoad; return fResult; #endif } //*************************************************************************** // UpdateServerLoadManagement( ) // // Description: Updates server load management structure based on the current // server load // // Parameters: // // Return Value: // // See Also: // //*************************************************************************** // 03/31/1993 JMILLARD Function Created. //*************************************************************************** WORD UpdateServerLoadManagement( LPLOADMANAGEMENT lpLoad, WORD wServerLoad, SWORD swServerLoadChange) { WORD wErr = OK; SDWORD sdwDelayChange; DWORD dwDelay; #if defined( SYM_DEBUG ) TCHAR szDebugMsg[ 256 ]; memset( szDebugMsg, 0xFF, sizeof( szDebugMsg ) ); SPRINTF( szDebugMsg, _T( "wServerLoad=%d\nswServerLoadChange=%d\n" ), wServerLoad, swServerLoadChange ); OutputDebugString( szDebugMsg ); #endif // SYM_DEBUG // do nothing until the load management is set up. This entry gets // queued shortly before the load management is set up. if (lpLoad->bLoadManagementInitialized && !bTablesNotInitialized) { #if defined(FUZZY) sdwDelayChange = GetNewDelay( &lpLoad->dwCurrentDelay, lpLoad->dwTargetLoad, wServerLoad, swServerLoadChange ); #if defined( SYM_DEBUG ) SPRINTF( szDebugMsg, _T( "sdwDelayChange=%d\n" ), sdwDelayChange ); OutputDebugString( szDebugMsg ); #endif #else // ifdef FUZZY if ( lpLoad->dwTargetLoad > wServerLoad ) { // spare server capacity available, use some more, if not already // max'ed out sdwDelayChange = -LOAD_INCREMENT; } else if ( lpLoad->dwTargetLoad < wServerLoad ) { // server too busy - back off a bit if not already doing nothing sdwDelayChange = LOAD_INCREMENT; } else { // things are just right sdwDelayChange = 0; } #endif // ifdef FUZZY (void) swServerLoadChange; // currently unused // adjust my delay, clamping to NO_DELAY and INFINITY if (sdwDelayChange < 0) { if (lpLoad->dwCurrentDelay > (NO_DELAY - sdwDelayChange) ) { lpLoad->dwCurrentDelay += sdwDelayChange; } else { lpLoad->dwCurrentDelay = NO_DELAY; } } else if ( sdwDelayChange > 0 ) { if (lpLoad->dwCurrentDelay < (INFINITY - sdwDelayChange) ) { lpLoad->dwCurrentDelay += sdwDelayChange; } else { lpLoad->dwCurrentDelay = INFINITY; } } } // set the load management delays based on the current load setting dwDelay = lpLoad->dwCurrentDelay; dwDelay = (dwDelay + 2) / 3; // stretch the scale out a bit #if defined( SYM_DEBUG ) SPRINTF( szDebugMsg, _T( "dwDelay=%d\n" ), dwDelay ); OutputDebugString( szDebugMsg ); #endif if (dwDelay == 1) // minimum delay { lpLoad->wTick1DelayCount = 0; lpLoad->wTick2DelayCount = 0; lpLoad->wThreadSwitch1Count = 0; lpLoad->wThreadSwitch2 = 1; } // thread switch loops else if (dwDelay <= MAX_SPIN_BREAKPOINT) { lpLoad->wTick1DelayCount = 0; lpLoad->wTick2DelayCount = 0; // // Typecast the following assignments // to avoid compiler warning C4244 // lpLoad->wThreadSwitch1Count = (WORD)((dwDelay - 2) % DELAY_CYCLE) + 1; lpLoad->wThreadSwitch1 = (WORD)(dwDelay - 2) / DELAY_CYCLE + 2; lpLoad->wThreadSwitch2 = (WORD)(dwDelay - 2) / DELAY_CYCLE + 1; } // timed delays, with thread switches as necessary else { // // Typecast the following assignments // to avoid compiler warning C4244 // lpLoad->wTick1DelayCount = (WORD)((dwDelay - 2) % DELAY_CYCLE) + 1; lpLoad->wTick1Delay = (WORD)(dwDelay - 2) / DELAY_CYCLE + 2 - MAX_SPIN; // whatever is left of DELAY_CYCLE, but 1 less tick delay lpLoad->wTick2DelayCount = DELAY_CYCLE - lpLoad->wTick1DelayCount; lpLoad->wTick2Delay = (WORD)(dwDelay - 2) / DELAY_CYCLE + 1 - MAX_SPIN; if (lpLoad->wTick2Delay == 0) { lpLoad->wTick2DelayCount = 0; } lpLoad->wThreadSwitch1Count = 0; // in case I run out of tick delays lpLoad->wThreadSwitch2 = MAX_SPIN; } /* #if defined( SYM_DEBUG ) SPRINTF( szDebugMsg, _T( "Delay t1 %d %d t2 %d %d ts1 %d %d ts2 %d\n" ), lpLoad->wTick1DelayCount, lpLoad->wTick1Delay, lpLoad->wTick2DelayCount, lpLoad->wTick2Delay, lpLoad->wThreadSwitch1Count, lpLoad->wThreadSwitch1, lpLoad->wThreadSwitch2 ); #if defined( SYM_NLM ) ConsolePrintf( szDebugMsg ); #elif defined( SYM_WIN32 ) OutputDebugString( szDebugMsg ); #endif #endif // SYM_DEBUG */ return (wErr); }
266029a38e3a33306627f5f0366518a095052fad
3717a5a904fb09cb06c6997e7514b1ce250c02f4
/YoutubeCPlusPlus/YoutubeCPlusPlus/Form1.h
9d51ddf8d3108e20507fa5bbcb2dcfdb905c7646
[]
no_license
alexarwady/RSA
a726e98331d0aacad540eacf2bd4dbb75869f8b8
7e39cddd6d66acc6b9227a7daa33ef884d625cab
refs/heads/master
2020-08-27T11:32:50.498307
2019-10-24T17:17:32
2019-10-24T17:17:32
217,352,058
0
0
null
null
null
null
UTF-8
C++
false
false
27,087
h
Form1.h
#pragma once #include<cmath> #include <string> #include "bigint-2010.04.30\BigIntegerLibrary.hh" //include the BigInteger Library #include <fstream> #include <cstdlib> using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace std; using System::Runtime::InteropServices::Marshal; static int count=0; static int count1=0; // Function to find modulo inverse of a BigInteger modInverse(BigInteger a, BigInteger m) { BigInteger m0 = m; BigInteger y = 0, x = 1; if (m == 1) return 0; while (a > 1) { // q is quotient BigInteger q = a / m; BigInteger t = m; // m is remainder now, process same as // Euclid's algo m = a % m, a = t; t = y; // Update y and x y = x - q * y; x = t; } // Make x positive if (x < 0) x += m0; return x; } namespace YoutubeCPlusPlus { /// <summary> /// Summary for Form1 /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Label^ label1; protected: private: System::Windows::Forms::Label^ label2; private: System::Windows::Forms::Label^ label3; private: System::Windows::Forms::Label^ label4; private: System::Windows::Forms::Label^ label5; private: System::Windows::Forms::Label^ label7; private: System::Windows::Forms::Label^ label8; private: System::Windows::Forms::TextBox^ textBox1; private: System::Windows::Forms::TextBox^ textBox2; private: System::Windows::Forms::TextBox^ textBox3; private: System::Windows::Forms::Label^ label9; private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::Label^ label15; private: System::Windows::Forms::TextBox^ textBox4; private: System::Windows::Forms::Label^ label16; private: System::Windows::Forms::TextBox^ textBox5; private: System::Windows::Forms::Button^ button3; private: System::Windows::Forms::Button^ button4; private: System::Windows::Forms::PictureBox^ pictureBox1; private: System::Windows::Forms::Label^ label19; private: System::Windows::Forms::TextBox^ textBox6; private: System::Windows::Forms::TextBox^ textBox7; private: System::Windows::Forms::TextBox^ textBox8; private: System::Windows::Forms::Button^ button5; private: System::Windows::Forms::Button^ button6; private: System::Windows::Forms::TextBox^ textBox9; private: System::Windows::Forms::TextBox^ textBox10; private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); this->label1 = (gcnew System::Windows::Forms::Label()); this->label2 = (gcnew System::Windows::Forms::Label()); this->label3 = (gcnew System::Windows::Forms::Label()); this->label4 = (gcnew System::Windows::Forms::Label()); this->label5 = (gcnew System::Windows::Forms::Label()); this->label7 = (gcnew System::Windows::Forms::Label()); this->label8 = (gcnew System::Windows::Forms::Label()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->textBox2 = (gcnew System::Windows::Forms::TextBox()); this->textBox3 = (gcnew System::Windows::Forms::TextBox()); this->label9 = (gcnew System::Windows::Forms::Label()); this->button1 = (gcnew System::Windows::Forms::Button()); this->button2 = (gcnew System::Windows::Forms::Button()); this->label15 = (gcnew System::Windows::Forms::Label()); this->textBox4 = (gcnew System::Windows::Forms::TextBox()); this->label16 = (gcnew System::Windows::Forms::Label()); this->textBox5 = (gcnew System::Windows::Forms::TextBox()); this->button3 = (gcnew System::Windows::Forms::Button()); this->button4 = (gcnew System::Windows::Forms::Button()); this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox()); this->label19 = (gcnew System::Windows::Forms::Label()); this->textBox6 = (gcnew System::Windows::Forms::TextBox()); this->textBox7 = (gcnew System::Windows::Forms::TextBox()); this->textBox8 = (gcnew System::Windows::Forms::TextBox()); this->button5 = (gcnew System::Windows::Forms::Button()); this->button6 = (gcnew System::Windows::Forms::Button()); this->textBox9 = (gcnew System::Windows::Forms::TextBox()); this->textBox10 = (gcnew System::Windows::Forms::TextBox()); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->BeginInit(); this->SuspendLayout(); // // label1 // this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(309, 37); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(49, 13); this->label1->TabIndex = 0; this->label1->Text = L"Message"; this->label1->Click += gcnew System::EventHandler(this, &Form1::label1_Click); // // label2 // this->label2->AutoSize = true; this->label2->Location = System::Drawing::Point(26, 34); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(21, 13); this->label2->TabIndex = 1; this->label2->Text = L"p="; // // label3 // this->label3->AutoSize = true; this->label3->Location = System::Drawing::Point(26, 61); this->label3->Name = L"label3"; this->label3->Size = System::Drawing::Size(21, 13); this->label3->TabIndex = 2; this->label3->Text = L"q="; // // label4 // this->label4->AutoSize = true; this->label4->Location = System::Drawing::Point(26, 98); this->label4->Name = L"label4"; this->label4->Size = System::Drawing::Size(21, 13); this->label4->TabIndex = 3; this->label4->Text = L"n="; // // label5 // this->label5->AutoSize = true; this->label5->Location = System::Drawing::Point(25, 128); this->label5->Name = L"label5"; this->label5->Size = System::Drawing::Size(49, 13); this->label5->TabIndex = 4; this->label5->Text = L"Totient="; // // label7 // this->label7->AutoSize = true; this->label7->Location = System::Drawing::Point(26, 157); this->label7->Name = L"label7"; this->label7->Size = System::Drawing::Size(21, 13); this->label7->TabIndex = 6; this->label7->Text = L"e="; // // label8 // this->label8->AutoSize = true; this->label8->Location = System::Drawing::Point(26, 183); this->label8->Name = L"label8"; this->label8->Size = System::Drawing::Size(21, 13); this->label8->TabIndex = 7; this->label8->Text = L"d="; // // textBox1 // this->textBox1->Location = System::Drawing::Point(385, 35); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(100, 20); this->textBox1->TabIndex = 8; // // textBox2 // this->textBox2->Location = System::Drawing::Point(102, 34); this->textBox2->MaxLength = 999999999; this->textBox2->Name = L"textBox2"; this->textBox2->Size = System::Drawing::Size(100, 20); this->textBox2->TabIndex = 9; // // textBox3 // this->textBox3->Location = System::Drawing::Point(102, 62); this->textBox3->Name = L"textBox3"; this->textBox3->Size = System::Drawing::Size(100, 20); this->textBox3->TabIndex = 10; // // label9 // this->label9->AutoSize = true; this->label9->Location = System::Drawing::Point(309, 69); this->label9->Name = L"label9"; this->label9->Size = System::Drawing::Size(58, 13); this->label9->TabIndex = 16; this->label9->Text = L"Ciphertext"; // // button1 // this->button1->Location = System::Drawing::Point(385, 96); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(63, 23); this->button1->TabIndex = 18; this->button1->Text = L"Encrypt"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click); // // button2 // this->button2->Location = System::Drawing::Point(385, 215); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(63, 23); this->button2->TabIndex = 27; this->button2->Text = L"Decrypt"; this->button2->UseVisualStyleBackColor = true; this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click); // // label15 // this->label15->AutoSize = true; this->label15->Location = System::Drawing::Point(309, 188); this->label15->Name = L"label15"; this->label15->Size = System::Drawing::Size(49, 13); this->label15->TabIndex = 26; this->label15->Text = L"Message"; // // textBox4 // this->textBox4->Location = System::Drawing::Point(385, 154); this->textBox4->Name = L"textBox4"; this->textBox4->Size = System::Drawing::Size(100, 20); this->textBox4->TabIndex = 25; // // label16 // this->label16->AutoSize = true; this->label16->Location = System::Drawing::Point(309, 156); this->label16->Name = L"label16"; this->label16->Size = System::Drawing::Size(58, 13); this->label16->TabIndex = 24; this->label16->Text = L"Ciphertext"; // // textBox5 // this->textBox5->Location = System::Drawing::Point(102, 150); this->textBox5->MaxLength = 32000; this->textBox5->Name = L"textBox5"; this->textBox5->Size = System::Drawing::Size(100, 20); this->textBox5->TabIndex = 29; this->textBox5->TextChanged += gcnew System::EventHandler(this, &Form1::textBox5_TextChanged); // // button3 // this->button3->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(192)), static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(0))); this->button3->Location = System::Drawing::Point(210, 150); this->button3->Name = L"button3"; this->button3->Size = System::Drawing::Size(67, 23); this->button3->TabIndex = 33; this->button3->Text = L"Import e"; this->button3->UseVisualStyleBackColor = true; this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click); // // button4 // this->button4->Location = System::Drawing::Point(102, 242); this->button4->Name = L"button4"; this->button4->Size = System::Drawing::Size(100, 28); this->button4->TabIndex = 34; this->button4->Text = L"Generate All"; this->button4->UseVisualStyleBackColor = true; this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click); // // pictureBox1 // this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"pictureBox1.Image"))); this->pictureBox1->Location = System::Drawing::Point(517, 43); this->pictureBox1->Name = L"pictureBox1"; this->pictureBox1->Size = System::Drawing::Size(49, 50); this->pictureBox1->TabIndex = 35; this->pictureBox1->TabStop = false; // // label19 // this->label19->AutoSize = true; this->label19->Location = System::Drawing::Point(514, 96); this->label19->Name = L"label19"; this->label19->Size = System::Drawing::Size(92, 52); this->label19->TabIndex = 36; this->label19->Text = L"Done by:\r\nAlexander Arwadi\r\nKarl Chahine\r\nCesar Bou Merhi"; // // textBox6 // this->textBox6->Location = System::Drawing::Point(102, 93); this->textBox6->Name = L"textBox6"; this->textBox6->Size = System::Drawing::Size(100, 20); this->textBox6->TabIndex = 37; // // textBox7 // this->textBox7->Location = System::Drawing::Point(102, 121); this->textBox7->Name = L"textBox7"; this->textBox7->ReadOnly = true; this->textBox7->Size = System::Drawing::Size(100, 20); this->textBox7->TabIndex = 38; // // textBox8 // this->textBox8->Location = System::Drawing::Point(102, 180); this->textBox8->Name = L"textBox8"; this->textBox8->Size = System::Drawing::Size(100, 20); this->textBox8->TabIndex = 39; // // button5 // this->button5->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(192)), static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(0))); this->button5->Location = System::Drawing::Point(210, 180); this->button5->Name = L"button5"; this->button5->Size = System::Drawing::Size(67, 23); this->button5->TabIndex = 40; this->button5->Text = L"Import d"; this->button5->UseVisualStyleBackColor = true; this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click); // // button6 // this->button6->ForeColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(192)), static_cast<System::Int32>(static_cast<System::Byte>(0)), static_cast<System::Int32>(static_cast<System::Byte>(0))); this->button6->Location = System::Drawing::Point(210, 93); this->button6->Name = L"button6"; this->button6->Size = System::Drawing::Size(67, 23); this->button6->TabIndex = 41; this->button6->Text = L"Import n"; this->button6->UseVisualStyleBackColor = true; this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click); // // textBox9 // this->textBox9->Location = System::Drawing::Point(385, 62); this->textBox9->Name = L"textBox9"; this->textBox9->ReadOnly = true; this->textBox9->Size = System::Drawing::Size(100, 20); this->textBox9->TabIndex = 42; // // textBox10 // this->textBox10->Location = System::Drawing::Point(385, 183); this->textBox10->Name = L"textBox10"; this->textBox10->ReadOnly = true; this->textBox10->Size = System::Drawing::Size(100, 20); this->textBox10->TabIndex = 43; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->AutoSize = true; this->ClientSize = System::Drawing::Size(618, 306); this->Controls->Add(this->textBox10); this->Controls->Add(this->textBox9); this->Controls->Add(this->button6); this->Controls->Add(this->button5); this->Controls->Add(this->textBox8); this->Controls->Add(this->textBox7); this->Controls->Add(this->textBox6); this->Controls->Add(this->label19); this->Controls->Add(this->pictureBox1); this->Controls->Add(this->button4); this->Controls->Add(this->button3); this->Controls->Add(this->textBox5); this->Controls->Add(this->button2); this->Controls->Add(this->label15); this->Controls->Add(this->textBox4); this->Controls->Add(this->label16); this->Controls->Add(this->button1); this->Controls->Add(this->label9); this->Controls->Add(this->textBox3); this->Controls->Add(this->textBox2); this->Controls->Add(this->textBox1); this->Controls->Add(this->label8); this->Controls->Add(this->label7); this->Controls->Add(this->label5); this->Controls->Add(this->label4); this->Controls->Add(this->label3); this->Controls->Add(this->label2); this->Controls->Add(this->label1); this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle; this->Icon = (cli::safe_cast<System::Drawing::Icon^ >(resources->GetObject(L"$this.Icon"))); this->MaximumSize = System::Drawing::Size(624, 335); this->Name = L"Form1"; this->Text = L"RSA Algorithm"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); (cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->pictureBox1))->EndInit(); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { } private: System::Void label1_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { String ^ in=textBox2 ->Text; //Input p String ^ in1=textBox3 ->Text; //Input q String ^ in3; String ^ in4; String ^ in5=textBox1->Text; //Input message String ^ in6=textBox5->Text; //Input e System::IntPtr pointer = Marshal::StringToHGlobalAnsi(in6); char* charPointer = reinterpret_cast<char*>(pointer.ToPointer()); std::string in66(charPointer, in6->Length); Marshal::FreeHGlobal(pointer); //This code converts e from System::string to std::string System::IntPtr pointer1 = Marshal::StringToHGlobalAnsi(in); char* charPointer1 = reinterpret_cast<char*>(pointer1.ToPointer()); std::string in67(charPointer1, in->Length); Marshal::FreeHGlobal(pointer1); //This code converts p from System::string to std::string System::IntPtr pointer2 = Marshal::StringToHGlobalAnsi(in1); char* charPointer2 = reinterpret_cast<char*>(pointer2.ToPointer()); std::string in68(charPointer2, in1->Length); Marshal::FreeHGlobal(pointer2); //This code converts q from System::string to std::string System::IntPtr pointer3 = Marshal::StringToHGlobalAnsi(in5); char* charPointer3 = reinterpret_cast<char*>(pointer3.ToPointer()); std::string in69(charPointer3, in5->Length); Marshal::FreeHGlobal(pointer3); //This code converts msg from System::string to std::string BigInteger e1=stringToBigInteger(in66); //Convert e from string to BigInteger BigInteger p=stringToBigInteger(in67); //Convert p from string to BigInteger BigInteger q=stringToBigInteger(in68); //Convert q from string to BigInteger BigInteger msg=stringToBigInteger(in69); //Convert msg from string to BigInteger BigInteger n; String ^ n12=textBox6 ->Text; //Get value entered System::IntPtr pointer4 = Marshal::StringToHGlobalAnsi(n12); char* charPointer4 = reinterpret_cast<char*>(pointer4.ToPointer()); std::string in70(charPointer4, n12->Length); Marshal::FreeHGlobal(pointer4); n=stringToBigInteger(in70); if (p!=0 && q!=0) //if user did not enter n {n=p*q; BigInteger totient= (q-1)*(p-1); //totient(n)=(q-1)*(p-1) BigInteger temp; BigInteger gcd=2; BigInteger temp2=1; BigInteger e2(e1); BigInteger totient2(totient); BigInteger temp3; while(temp2!=0) { temp=e2%totient2; temp3=temp.toInt(); if(temp==0) { gcd=totient2; } temp2=temp3; e2=totient2; totient2=temp3; } //This while loop finds the gcd of totient(n) and e if(gcd==1) count1=1; BigInteger d=modInverse(e1, totient); BigInteger k = 2; string n1=bigIntegerToString(n); string totient1=bigIntegerToString(totient); string d1=bigIntegerToString(d); String^ n11 = gcnew String(n1.c_str()); in=System::Convert::ToString(n11); textBox6->Text=in; //Output n n11 = gcnew String(totient1.c_str()); in1=System::Convert::ToString(n11); textBox7->Text=in1; //Output totient n11 = gcnew String(d1.c_str()); in3=System::Convert::ToString(n11); textBox8->Text=in3; //Output d count=1; } if (p==0 && q==0) textBox7->Text="0"; BigInteger e3(e1); BigInteger res = 1; msg = msg % n; while (e3 > 0) { if (e3%2==1) res = (res*msg) % n; e3 = e3/2; msg = (msg*msg) % n; } //This while loop does fast exponentiation to calculate the ciphertext string res1=bigIntegerToString(res); String^ n13 = gcnew String(res1.c_str()); in4=System::Convert::ToString(n13); if(count1==1 || count==0) textBox9->Text=in4; //Output ciphertext else textBox9->Text="GCD(e,totient)!=1"; count1=0; count=0; } private: System::Void label11_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void label13_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { String ^ in=textBox2 ->Text; //Input p String ^ in1=textBox3 ->Text; //Input q String ^ in3; String ^ in4; String ^ in5=textBox4->Text; //Input message String ^ in6=textBox8->Text; //Input d System::IntPtr pointer = Marshal::StringToHGlobalAnsi(in6); char* charPointer = reinterpret_cast<char*>(pointer.ToPointer()); std::string in66(charPointer, in6->Length); Marshal::FreeHGlobal(pointer); //This code converts d from System::string to std::string System::IntPtr pointer1 = Marshal::StringToHGlobalAnsi(in); char* charPointer1 = reinterpret_cast<char*>(pointer1.ToPointer()); std::string in67(charPointer1, in->Length); Marshal::FreeHGlobal(pointer1); //This code converts p from System::string to std::string System::IntPtr pointer2 = Marshal::StringToHGlobalAnsi(in1); char* charPointer2 = reinterpret_cast<char*>(pointer2.ToPointer()); std::string in68(charPointer2, in1->Length); Marshal::FreeHGlobal(pointer2); //This code converts q from System::string to std::string System::IntPtr pointer3 = Marshal::StringToHGlobalAnsi(in5); char* charPointer3 = reinterpret_cast<char*>(pointer3.ToPointer()); std::string in69(charPointer3, in5->Length); Marshal::FreeHGlobal(pointer3); //This code converts msg from System::string to std::string BigInteger d1=stringToBigInteger(in66); //Convert e from string to BigInteger BigInteger p=stringToBigInteger(in67); BigInteger q=stringToBigInteger(in68); BigInteger msg=stringToBigInteger(in69); BigInteger n; String ^ n12=textBox6 ->Text; System::IntPtr pointer4 = Marshal::StringToHGlobalAnsi(n12); char* charPointer4 = reinterpret_cast<char*>(pointer4.ToPointer()); std::string in70(charPointer4, n12->Length); Marshal::FreeHGlobal(pointer4); n=stringToBigInteger(in70); if (p!=0 && q!=0) //if n not entered {n=p*q; BigInteger totient= (q-1)*(p-1); //totient(n)=(q-1)*(p-1) BigInteger temp; BigInteger gcd=2; BigInteger temp2=1; BigInteger d2(d1); BigInteger totient2(totient); BigInteger temp3; BigInteger e1=modInverse(d1,totient); BigInteger k = 2; string n1=bigIntegerToString(n); string totient1=bigIntegerToString(totient); string e2=bigIntegerToString(e1); String^ n11 = gcnew String(n1.c_str()); in=System::Convert::ToString(n11); textBox6->Text=in; //Output n n11 = gcnew String(totient1.c_str()); in1=System::Convert::ToString(n11); textBox7->Text=in1; //Output totient n11 = gcnew String(e2.c_str()); in3=System::Convert::ToString(n11); textBox5->Text=in3; //Output e } if (p==0 && q==0) textBox7->Text="0"; BigInteger d3(d1); BigInteger res = 1; msg = msg % n; while (d3 > 0) { if (d3%2==1) res = (res*msg) % n; d3 = d3/2; msg = (msg*msg) % n; } //This while loop does fast exponentiation to calculate the plaintext string res1=bigIntegerToString(res); String^ n13 = gcnew String(res1.c_str()); in4=System::Convert::ToString(n13); textBox10->Text=in4; //Output ciphertext } private: System::Void label11_Click_1(System::Object^ sender, System::EventArgs^ e) { } private: System::Void textBox5_TextChanged(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) { ifstream infile; infile.open("C:\\e.txt"); string ee; infile>>ee; //read number in file String^ str2 = gcnew String(ee.c_str()); Console::WriteLine(str2); //converts from std::string to System::string textBox5->Text=str2; //Outputs the key } private: System::Void textBox6_TextChanged(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { String ^ in="187"; String ^ in1="160"; String ^ in3="11"; String ^ in2="17"; String ^ in4="7"; String ^ in5="23"; textBox6->Text=in; //Output n textBox7->Text=in1; //Output totient textBox2->Text=in3; //Output p textBox3->Text=in2; //Output q textBox5->Text=in4; //Output e textBox8->Text=in5; //Output d } private: System::Void pictureBox1_Click(System::Object^ sender, System::EventArgs^ e) { } private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) { ifstream infile; infile.open("C:\\n.txt"); string n; infile>>n; //read number in file String^ str2 = gcnew String(n.c_str()); Console::WriteLine(str2); //converts from std::string to System::string textBox6->Text=str2; //Outputs n } private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) { ifstream infile; infile.open("C:\\d.txt"); string d; infile>>d; //read number in file String^ str2 = gcnew String(d.c_str()); Console::WriteLine(str2); //converts from std::string to System::string textBox8->Text=str2; //Outputs d } }; }
19a4e89ddbebaa3913a2715eaf3fb1362d052c08
70e4b24188ffff5ecafcd24bf30a48a3110e6a9a
/FurSim/Vertex.cpp
1921572a14dd2681e0a9378f0257971455b729d8
[]
no_license
PeterZhouSZ/FurSim
da28096b5ff4545566ae44a8fc0bdd75283d59d5
c7c81cb64d91712d34842af7e980bf94c60585a2
refs/heads/master
2023-03-06T14:17:05.190748
2021-02-16T04:52:42
2021-02-16T04:52:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
156
cpp
Vertex.cpp
#include "Vertex.h" float Vertex::L0; Vertex::Vertex(vec3 pos, float m) : Position(pos), tmp_Position(pos) { if (m < 0.001) m = 0.001; Mass = m; }
dd35e9bc98edcb5c1f67fad431e42fd3844b95f5
d97a9c2b090f449026ca33cbc444f108b630c882
/src/xml_process.hpp
cbb84e4dcbfba2504b628199b12144f1687e5b3b
[ "MIT" ]
permissive
Dorosoft/MALT
956fcdc27bc096a30fb0f6cc1b7268fd0d7acb9f
c2fb4ff29612666df29c7a80034ceb21e432ea12
refs/heads/master
2021-01-15T19:17:54.874216
2017-08-10T10:37:46
2017-08-10T10:37:46
99,818,189
0
0
null
null
null
null
UTF-8
C++
false
false
406
hpp
xml_process.hpp
#ifndef __XML_PROCESS_HPP #define __XML_PROCESS_HPP #include <iostream> #include <string> #include <map> #include "anime.hpp" #include "date.hpp" #include "pugixml.hpp" void load_xml_alist(std::string* s_anime_list, std::map<long int, Anime>& alist); void load_xml_search(std::string* s_anime_list, std::map<long int, searchdata> &dst); std::string add_xml_anime(const struct myanimedata* data); #endif
f942b31fbd6535d49f9c115ae990e95972916bcb
04f6684a55dc8bdab82b9524fa0982894407ce6d
/fields.h
52c3b8a0de26e5128dacc8d7241c8c6d28e0ceab
[]
no_license
asulecki/JNP6
668df29aa430b6d61d77b1b367b2d0c7431925db
5f403b4fc104603aa18f23447d1bb88cc5518f97
refs/heads/master
2021-01-22T15:42:35.347623
2014-01-24T00:05:50
2014-01-24T00:05:50
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,064
h
fields.h
#ifndef _FIELDS_H #define _FIELDS_H #include <string> #include <memory> using std::shared_ptr; class Player; class Board; class Field { public: Field(const std::string &&name); virtual void action(shared_ptr<Player> p) = 0; virtual void pass(shared_ptr<Player> p) = 0; const std::string getName(); protected: const std::string name; }; class StartField : public Field { public: StartField(int cash); virtual void action(shared_ptr<Player> p); virtual void pass(shared_ptr<Player> p); private: int cash; }; class IslandField : public Field { public: IslandField(); virtual void action(shared_ptr<Player> p); virtual void pass(shared_ptr<Player> p); }; class PrizeField : public Field { public: PrizeField(std::string name, int ammount); virtual void action(shared_ptr<Player> p); virtual void pass(shared_ptr<Player> p); private: int ammount; }; class FineField : public Field { public: FineField(std::string name, int ammount); virtual void action(shared_ptr<Player> p); virtual void pass(shared_ptr<Player> p); private: int ammount; }; class DepositField : public Field { public: DepositField(std::string name, int ammount); virtual void action(shared_ptr<Player> p); virtual void pass(shared_ptr<Player> p); private: const int ammount; int fishcoins; }; class AquariumField : public Field { public: AquariumField(int turns); virtual void action(shared_ptr<Player> p); virtual void pass(shared_ptr<Player> p); private: const int turnsToWait; }; class PropertyField : public Field { public: PropertyField(std::string name, int price, int percent); virtual void action(shared_ptr< Player > p); virtual void pass(shared_ptr< Player > p); void sold(); int getPrice(); private: std::weak_ptr < Player > owner; const std::string name; int price; int percent; virtual int getPercent(); }; class PublicPropertyField : public PropertyField { public: PublicPropertyField(std::string name, int price); }; class CoralPropertyField : public PropertyField { public: CoralPropertyField(std::string name, int price); }; #endif
9166697f0623e21ff1499419ff23696f78e55d9a
5d309f75555c9fa49cd1bb0f953c6ee73d711fe6
/garnet/bin/ui/view_manager/view_registry.h
c7366147760aff6b67e0b93810d00a32690c688d
[ "BSD-3-Clause" ]
permissive
the-locksmith/fuchsia
d2d0b7d6e011a1468cb299441494be2c9c5cae0a
2620709744ff49fe289169a8af63f8499239333b
refs/heads/master
2021-10-21T10:55:16.114376
2019-02-28T22:37:39
2019-03-04T00:05:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,154
h
view_registry.h
// Copyright 2015 The Fuchsia 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 GARNET_BIN_UI_VIEW_MANAGER_VIEW_REGISTRY_H_ #define GARNET_BIN_UI_VIEW_MANAGER_VIEW_REGISTRY_H_ #include <list> #include <string> #include <unordered_map> #include <fuchsia/ui/gfx/cpp/fidl.h> #include <fuchsia/ui/scenic/cpp/fidl.h> #include <fuchsia/ui/views/cpp/fidl.h> #include <fuchsia/ui/viewsv1/cpp/fidl.h> #include "garnet/bin/ui/view_manager/view_container_state.h" #include "garnet/bin/ui/view_manager/view_state.h" #include "garnet/bin/ui/view_manager/view_stub.h" #include "garnet/bin/ui/view_manager/view_tree_state.h" #include "garnet/lib/ui/gfx/engine/object_linker.h" #include "lib/component/cpp/startup_context.h" #include "lib/fxl/macros.h" #include "lib/fxl/memory/weak_ptr.h" #include "lib/ui/scenic/cpp/session.h" namespace view_manager { using ViewLinker = scenic_impl::gfx::ObjectLinker<ViewStub, ViewState>; // Maintains a registry of the state of all views. // All ViewState objects are owned by the registry. class ViewRegistry : public scenic_impl::ErrorReporter { public: explicit ViewRegistry(component::StartupContext* startup_context); virtual ~ViewRegistry(); // |ErrorReporter| void ReportError(fxl::LogSeverity severity, std::string error_string) override { FXL_LOG(ERROR) << error_string; } // VIEW MANAGER REQUESTS void GetScenic( fidl::InterfaceRequest<fuchsia::ui::scenic::Scenic> scenic_request); void CreateView( fidl::InterfaceRequest<::fuchsia::ui::viewsv1::View> view_request, zx::eventpair view_token, ::fuchsia::ui::viewsv1::ViewListenerPtr view_listener, zx::eventpair parent_export_token, fidl::StringPtr label); void CreateViewTree( fidl::InterfaceRequest<::fuchsia::ui::viewsv1::ViewTree> view_tree_request, ::fuchsia::ui::viewsv1::ViewTreeListenerPtr view_tree_listener, fidl::StringPtr label); // VIEW REQUESTS // Called when one of the view pipes is closed remotely. void OnViewDied(ViewState* view_state, const std::string& reason); // VIEW TREE REQUESTS // Called when one of the view tree pipes is closed remotely. void OnViewTreeDied(ViewTreeState* tree_state, const std::string& reason); // VIEW CONTAINER // Adds a child, reparenting it if necessary. // Destroys |container_state| if an error occurs. void AddChild(ViewContainerState* container_state, uint32_t child_key, zx::eventpair view_holder_token, zx::eventpair host_import_token); // Removes a child. // Destroys |container_state| if an error occurs. void RemoveChild(ViewContainerState* container_state, uint32_t child_key, zx::eventpair transferred_view_holder_token); // Sets a child's properties. // Destroys |container_state| if an error occurs. void SetChildProperties( ViewContainerState* container_state, uint32_t child_key, ::fuchsia::ui::viewsv1::ViewPropertiesPtr child_properties); // Sets a hint on changes to a child's target size. // Destroys |container_state| if an error occurs. void SendSizeChangeHintHACK(ViewContainerState* container_state, uint32_t child_key, float width_change_factor, float size_change_factor); void RequestSnapshotHACK( ViewContainerState* container_state, uint32_t child_key, fit::function<void(::fuchsia::mem::Buffer)> callback); // SERVICE PROVIDER REQUESTS // Connects to a view service. // Destroys |view_state| if an error occurs. void ConnectToViewService(ViewState* view_state, const fidl::StringPtr& service_name, zx::channel client_handle); // Connects to a view service. // Destroys |view_state| if an error occurs. void ConnectToViewTreeService(ViewTreeState* tree_state, const fidl::StringPtr& service_name, zx::channel client_handle); // SNAPSHOT void TakeSnapshot(uint64_t view_koid, fit::function<void(::fuchsia::mem::Buffer)> callback); // SIGNALING void SendChildAttached(ViewContainerState* container_state, uint32_t child_key, ::fuchsia::ui::viewsv1::ViewInfo child_view_info); void SendChildUnavailable(ViewContainerState* container_state, uint32_t child_key); // Transferring views. std::unique_ptr<ViewContainerState::ChildView> FindOrphanedView( zx_handle_t view_holder_token); void AddOrphanedView(zx::eventpair transferred_view_token, std::unique_ptr<ViewContainerState::ChildView> child); void RemoveOrphanedView(ViewContainerState::ChildView* child); private: // LIFETIME void UnregisterView(ViewState* view_state); void UnregisterViewTree(ViewTreeState* tree_state); void UnregisterViewContainer(ViewContainerState* container_state); void UnregisterViewStub(std::unique_ptr<ViewStub> view_stub); void UnregisterChildren(ViewContainerState* container_state); void ReleaseViewStubChildHost(ViewStub* view_stub); // SESSION MANAGEMENT void SchedulePresentSession(); void PresentSession(); // LOOKUP // Walk up the view tree starting at |view_token| to find a service // provider that offers a service named |service_name|. fuchsia::sys::ServiceProvider* FindViewServiceProvider( ViewState* view, std::string service_name); ViewState* FindView(uint32_t view_token); ViewTreeState* FindViewTree(uint32_t view_tree_token_value); bool IsViewStateRegisteredDebug(ViewState* view_state) { return view_state && FindView(view_state->view_token()); } bool IsViewTreeStateRegisteredDebug(ViewTreeState* tree_state) { return tree_state && FindViewTree(tree_state->view_tree_token().value); } bool IsViewContainerStateRegisteredDebug( ViewContainerState* container_state) { return container_state && (IsViewStateRegisteredDebug(container_state->AsViewState()) || IsViewTreeStateRegisteredDebug(container_state->AsViewTreeState())); } component::StartupContext* startup_context_; fuchsia::ui::scenic::ScenicPtr scenic_; scenic::Session session_; bool present_session_scheduled_ = false; uint32_t next_view_id_value_ = 1u; uint32_t next_view_tree_token_value_ = 1u; struct OrphanedView { zx::eventpair view_holder_token; std::unique_ptr<ViewContainerState::ChildView> child_view; }; std::map<zx_koid_t, OrphanedView> orphaned_views_; std::unordered_map<uint32_t, std::unique_ptr<ViewState>> views_by_token_; std::unordered_map<uint32_t, std::unique_ptr<ViewTreeState>> view_trees_by_token_; std::list<std::shared_ptr<::fuchsia::ui::gfx::SnapshotCallbackHACK>> snapshot_bindings_; fxl::WeakPtrFactory<ViewRegistry> weak_factory_; // must be last FXL_DISALLOW_COPY_AND_ASSIGN(ViewRegistry); }; } // namespace view_manager #endif // GARNET_BIN_UI_VIEW_MANAGER_VIEW_REGISTRY_H_
20f27d0dc05e413dda92314753603e0446201500
65ea2704c2b50105138384b4beaaf66a5dc1d3fc
/1/Task01/main.cpp
06c9c2976cc7f0b5c49857a4f3bc0577fdb57502
[]
no_license
ogulyukin/HWSys211101
4c3f9ed2b936e4cb78b1c35bebbc6be39c760b8a
c09131db7ad741b2dbad791f35053257a6275da7
refs/heads/master
2023-08-21T05:31:50.009198
2021-11-01T11:40:34
2021-11-01T11:40:34
423,443,014
0
0
null
null
null
null
UTF-8
C++
false
false
1,005
cpp
main.cpp
#include <QCoreApplication> #include "manager.h" int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); Manager manager; QTextStream cin(stdin); qInfo() << "Run mode: wait for command"; qInfo() << "Type START to begin"; qInfo() << "Type QUIT to quit"; qInfo() << "Type MODE to change run mode. Current mode is waiting for QUIT command mode"; QThread::currentThread()->setObjectName("Main Thread"); qInfo() << "This is main thread data: " << QThread::currentThread(); forever { QString command; cin >> command; if (command.toUpper() == "START") { manager.process(); }else if(command.toUpper() == "QUIT") { manager.quit(); }else if(command.toUpper() == "MODE") { manager.setRunMode(manager.getRunMode() ? false : true); } } return a.exec(); }
16819a6bcaa2d759f060748b85991e1412d9b093
f732dcfbc8746a9f8b09b131e4f60cd8df11fb09
/OutputParser/main.cpp
3a920f3417ae7ea4d2ccd3de6dad02c2497d5c35
[ "MIT" ]
permissive
VadimRomansky/PICpp
5359995fa42c1b3024a05f1ab81da82a2892de77
33eb8581533cb52ab1a72a0308f281899eef8e3f
refs/heads/master
2023-08-22T05:40:36.598222
2023-07-31T16:24:39
2023-07-31T16:24:39
55,867,418
5
2
null
null
null
null
UTF-8
C++
false
false
21,744
cpp
main.cpp
#include <stdio.h> #include <math.h> #include <string> void outputEfield(int timePointsCount, FILE *XFile, FILE *YFile, FILE *ZFile, int Nx, int Ny, int Nz, FILE *EFile, FILE *fluxFile, FILE *gleEFileX, FILE *gleEFileY, FILE *gleEFileZ, FILE *gleFluxFileX, FILE *gleFluxFileY, FILE *gleFluxFileZ, int Nt, int xpoint, int ypoint, int zpoint, int *timePoints, double * Xgrid, double * middleX, double * Ygrid, double * middleY, double * Zgrid, double * middleZ) ; void outputBfield(int timePointsCount, int Nx, int Ny, int Nz, int Nt, int xpoint, int ypoint, int zpoint, int *timePoints, double *middleX, double *middleY, double *middleZ, FILE *BFile, FILE *divergenceFile, FILE *gleBFileX, FILE *gleBFileY, FILE *gleBFileZ, FILE *gleDivergenceFileX, FILE *gleDivergenceFileY, FILE *gleDivergenceFileZ); int min2(int a, int b){ if(a <= b){ return a; } else { return b; } } int countNumbers(FILE* file){ int result = 0; double a; int flag = fscanf(file, "%lf", &a); while(flag > 0){ result++; flag = fscanf(file, "%lf", &a); } return result; } int countNumbersLine(FILE* file, int numbersPerLine) { int result = 0; double a; int flag = fscanf(file, "%lf", &a); for (int i = 0; i < numbersPerLine - 1; ++i) { flag = fscanf(file, "%lf", &a); } while(flag > 0){ result++; flag = fscanf(file, "%lf", &a); for (int i = 0; i < numbersPerLine - 1; ++i) { flag = fscanf(file, "%lf", &a); } } return result; } int main() { const int timePointsCount = 3; //must be >= 2 const int Np = 1000; //for MPI on cluster //std::string outputDir = "/home/uikam/romansky/PIC3d5/output/"; //std::string inputDir = "/home/uikam/romansky/PIC3d5/input/"; //std::string backupDir = "/home/uikam/romansky/PIC3d5/backup/"; //for MPI on Ubuntu std::string outputDir = "/home/vadim/PICpp/PIC++/output/"; //std::string inputDir = "/home/vadim/PIC++/trunk/PIC++/input/"; //std::string backupDir = "/home/vadim/PIC++/trunk/PIC++/backup/"; //for windowss //std::string outputDir = "C:/users/Vadik/Documents/Visual Studio 2010/Projects/v4/PIC++/output/"; //std::string inputDir = "C:/users/Vadik/Documents/Visual Studio 2010/Projects/v4/PIC++/input/"; //cstd::string backupDir = "C:/users/Vadik/Documents/Visual Studio 2010/Projects/v4/PIC++/backup/"; FILE* XFile = fopen((outputDir + "Xfile.dat").c_str(),"r"); FILE* YFile = fopen((outputDir + "Yfile.dat").c_str(),"r"); FILE* ZFile = fopen((outputDir + "Zfile.dat").c_str(),"r"); //FILE* protonsFile = fopen((inputDir + "protons.dat").c_str(), "r"); //FILE* electronsFile = fopen((inputDir + "electrons.dat").c_str(), "r"); //FILE* positronsFile = fopen((inputDir + "positrons.dat").c_str(), "r"); //FILE* alphasFile = fopen((inputDir + "alphas.dat").c_str(), "r"); //FILE* gleXFile = fopen("../output/Xfile.dat","w"); //FILE* gleYFile = fopen("../output/Yfile.dat","w"); //FILE* gleZFile = fopen("../output/Zfile.dat","w"); //FILE* gleProtonsFile = fopen("../output/protons.dat", "w"); //FILE* gleElectronsFile = fopen("../output/electrons.dat", "w"); //FILE* glePositronsFile = fopen("../output/positrons.dat", "w"); ///FILE* gleAlphasFile = fopen("../output/alphas.dat", "w"); int Nx = countNumbers(XFile); int Ny = countNumbers(YFile); int Nz = countNumbers(ZFile); FILE* EFile = fopen((outputDir + "Efield.dat").c_str(), "r"); FILE* fluxFile = fopen((outputDir + "flux.dat").c_str(), "r"); FILE* gleEFileX = fopen("../output/Efield_x.dat", "w"); FILE* gleEFileY = fopen("../output/Efield_y.dat", "w"); FILE* gleEFileZ = fopen("../output/Efield_z.dat", "w"); FILE* gleFluxFileX = fopen("../output/flux_x.dat", "w"); FILE* gleFluxFileY = fopen("../output/flux_y.dat", "w"); FILE* gleFluxFileZ = fopen("../output/flux_z.dat", "w"); int NE = countNumbersLine(EFile, 3); rewind(XFile); rewind(YFile); rewind(ZFile); rewind(EFile); int Nt = NE/(Nx*Ny*Nz); Nt = 14; //int Nt = 10; int xpoint = Nx/2 - 1; int ypoint = Ny/2 - 1; int zpoint = Nz/2 - 1; int timePoints[timePointsCount]; timePoints[0] = 0; timePoints[timePointsCount-1] = Nt - 1; int deltaNt = Nt/(timePointsCount - 1); for(int i = 1; i < timePointsCount - 1; ++i){ timePoints[i] = timePoints[i-1] + deltaNt; } /////// arrays with dimensions Nx*Ny*Nz*Nt ////// double *Xgrid; double *middleX; double *Ygrid; double *middleY; double *Zgrid; double *middleZ; Xgrid= new double[Nx]; middleX= new double[Nx - 1]; Ygrid= new double[Ny]; middleY= new double[Ny - 1]; Zgrid= new double[Nz]; middleZ= new double[Nz - 1]; /*outputEfield(timePointsCount, XFile, YFile, ZFile, Nx, Ny, Nz, EFile, fluxFile, gleEFileX, gleEFileY, gleEFileZ, gleFluxFileX, gleFluxFileY, gleFluxFileZ, Nt, xpoint, ypoint, zpoint, timePoints, Xgrid, middleX, Ygrid, middleY, Zgrid, middleZ);*/ FILE* BFile = fopen((outputDir + "Bfield.dat").c_str(),"r"); //FILE* concentrationFile = fopen((inputDir + "concentrations.dat").c_str(), "r"); //FILE* velocityElectronFile = fopen((inputDir + "velocity_electron.dat").c_str(), "r"); //FILE* velocityProtonFile = fopen((inputDir + "velocity.dat").c_str(), "r"); FILE* divergenceFile = fopen((outputDir + "divergence_error.dat").c_str(), "r"); FILE* gleBFileX = fopen("../output/Bfield_x.dat","w"); FILE* gleBFileY = fopen("../output/Bfield_y.dat","w"); FILE* gleBFileZ = fopen("../output/Bfield_z.dat","w"); //FILE* gleConcentrationFileX = fopen("../output/concentrations_x.dat", "w"); //FILE* gleConcentrationFileY = fopen("../output/concentrations_y.dat", "w"); //FILE* gleConcentrationFileZ = fopen("../output/concentrations_z.dat", "w"); //FILE* gleVelocityFileX = fopen("../output/velocity_x.dat", "w"); //FILE* gleVelocityFileY = fopen("../output/velocity_y.dat", "w"); //FILE* gleVelocityFileZ = fopen("../output/velocity_z.dat", "w"); FILE* gleDivergenceFileX = fopen("../output/divergence_error_x.dat", "w"); FILE* gleDivergenceFileY = fopen("../output/divergence_error_y.dat", "w"); FILE* gleDivergenceFileZ = fopen("../output/divergence_error_z.dat", "w"); /////// arrays with dimensions (Nx - 1)*(Ny - 1)(Nz-1)*Nt ////// /*outputBfield(timePointsCount, Nx, Ny, Nz, Nt, xpoint, ypoint, zpoint, timePoints, middleX, middleY, middleZ, BFile, divergenceFile, gleBFileX, gleBFileY, gleBFileZ, gleDivergenceFileX, gleDivergenceFileY, gleDivergenceFileZ);*/ delete[] Xgrid; delete[] middleX; delete[] Ygrid; delete[] middleY; delete[] Zgrid; delete[] middleZ; fclose(BFile); //fclose(concentrationFile); //fclose(velocityElectronFile); //fclose(velocityProtonFile); fclose(divergenceFile); fclose(gleBFileX); fclose(gleBFileY); fclose(gleBFileZ); //fclose(gleConcentrationFileX); //fclose(gleConcentrationFileY); //fclose(gleConcentrationFileZ); //fclose(gleVelocityFileX); //fclose(gleVelocityFileY); //fclose(gleVelocityFileZ); fclose(gleDivergenceFileX); fclose(gleDivergenceFileY); fclose(gleDivergenceFileZ); /////// arrays with dimensions Nt ////// FILE* generalFile = fopen((outputDir + "general.dat").c_str(), "r"); FILE* incrementFile = fopen((outputDir + "increment.dat").c_str(), "r"); //FILE* trajectoryProtonFile = fopen((inputDir + "trajectory_proton.dat").c_str(), "r"); //FILE* trajectoryElectronFile = fopen((inputDir + "trajectory_electron.dat").c_str(), "r"); FILE* gleGeneralFile = fopen("../output/general.dat", "w"); //FILE* gleTrajectoryProtonFile = fopen("../output/trajectory_proton.dat", "w"); //FILE* gleTrajectoryElectronFile = fopen("../output/trajectory_electron.dat", "w"); double** general = new double*[Nt]; double** protonTraectory = new double*[Nt]; double** electronTraectory = new double*[Nt]; for(int i = 0; i < Nt; ++i){ general[i] = new double[38]; protonTraectory[i] = new double[8]; electronTraectory[i] = new double[8]; } for(int i = 0; i < Nt; i++){ for(int j = 0; j < 38; ++j){ //for(int j = 0; j < 7; ++j){ fscanf(generalFile, "%lf", &general[i][j]); } for(int j = 0; j < 8; ++j){ //fscanf(trajectoryProtonFile, "%lf", &protonTraectory[i][j]); //fscanf(gleTrajectoryElectronFile, "%lf", &electronTraectory[i][j]); } } int NbestIncrement = min2(Nt - 1, 200); int Nsaturation = min2(NbestIncrement, 350); double gamma; fscanf(incrementFile, "%lf", &gamma); general[0][18] = general[NbestIncrement][6]/exp(2*gamma*general[NbestIncrement][1]); for(int i = 1; i < Nt; ++i){ if(i <= Nsaturation){ general[i][18] = general[0][18]*exp(2*gamma*general[i][1]); } else { general[i][18] = general[Nsaturation][18]; } } for(int i = 0; i < Nt; i++){ for(int j = 1; j < 19; ++j) { //for(int j = 1; j < 7; ++j) { fprintf(gleGeneralFile, "%20.15g", general[i][j]); } for(int j = 0; j < 8; ++j){ //fprintf(gleTrajectoryProtonFile, "%20.15g", protonTraectory[i][j]); //fprintf(gleTrajectoryElectronFile, "%20.15g", electronTraectory[i][j]); } fprintf(gleGeneralFile, "\n"); //fprintf(gleTrajectoryProtonFile, "\n"); //fprintf(gleTrajectoryElectronFile, "\n"); } for(int i = 0; i < Nt; ++i){ delete[] general[i]; delete[] protonTraectory[i]; delete[] electronTraectory[i]; } delete[] general; delete[] protonTraectory; delete[] electronTraectory; fclose(generalFile); fclose(incrementFile); //fclose(trajectoryElectronFile); //fclose(trajectoryProtonFile); fclose(gleGeneralFile); //fclose(gleTrajectoryElectronFile); //fclose(gleTrajectoryProtonFile); /////// arrays with dimensions Np*Nt ////// FILE* distributionProtonsFile = fopen((outputDir + "distribution_protons.dat").c_str(), "r"); FILE* distributionElectronsFile = fopen((outputDir + "distribution_electrons.dat").c_str(), "r"); FILE* gleDistributionProtonsFile = fopen("../output/distribution_protons.dat", "w"); FILE* gleDistributionElectronsFile = fopen("../output/distribution_electrons.dat", "w"); double** distributionProtons = new double*[Np*Nt]; double** distributionElectrons = new double*[Np*Nt]; for(int i = 0; i < Np*Nt; ++i){ distributionProtons[i] = new double[2]; distributionElectrons[i] = new double[2]; } for(int i = 0; i < Np*Nt; ++i){ for(int j = 0; j < 2; ++j) { fscanf(distributionProtonsFile, "%lf", &distributionProtons[i][j]); fscanf(distributionElectronsFile, "%lf", &distributionElectrons[i][j]); } } for(int i = 0; i < Np; ++i){ double Fp = distributionProtons[i + (Nt - 1) * Np][1] * distributionProtons[i + (Nt - 1) * Np][0] * distributionProtons[i + (Nt - 1) * Np][0]; if(fabs(Fp) < 1E-100){ Fp = 1E-100; } fprintf(gleDistributionProtonsFile, "%20.15g %20.15g\n", distributionProtons[i + (Nt-1)*Np][0], Fp); double Fe = distributionElectrons[i + (Nt - 1) * Np][1] * distributionElectrons[i + (Nt - 1) * Np][0] * distributionElectrons[i + (Nt - 1) * Np][0]; if(fabs(Fe) < 1E-100){ Fe = 1E-100; } fprintf(gleDistributionElectronsFile, "%20.15g %20.15g\n", distributionElectrons[i + (Nt - 1) * Np][0], Fe); } for(int i = 0; i < Np*Nt; ++i){ delete[] distributionProtons[i]; delete[] distributionElectrons[i]; } delete[] distributionProtons; delete[] distributionElectrons; fclose(distributionElectronsFile); fclose(distributionProtonsFile); fclose(gleDistributionProtonsFile); fclose(gleDistributionElectronsFile); //fclose(protonsFile); //fclose(electronsFile); //fclose(positronsFile); //fclose(alphasFile); //fclose(gleXFile); //fclose(gleYFile); //fclose(gleZFile); //fclose(gleProtonsFile); //fclose(gleElectronsFile); //fclose(glePositronsFile); //fclose(gleAlphasFile); return 0; } void outputBfield(int timePointsCount, int Nx, int Ny, int Nz, int Nt, int xpoint, int ypoint, int zpoint, int *timePoints, double *middleX, double *middleY, double *middleZ, FILE *BFile, FILE *divergenceFile, FILE *gleBFileX, FILE *gleBFileY, FILE *gleBFileZ, FILE *gleDivergenceFileX, FILE *gleDivergenceFileY, FILE *gleDivergenceFileZ) { double** Bfield = new double*[(Nx - 1) * (Ny - 1) * (Nz - 1) * Nt]; double** velocity = new double*[(Nx-1)*(Ny-1)*(Nz-1)*Nt]; double** concentrations = new double*[(Nx-1)*(Ny-1)*(Nz-1)*Nt]; double** divergence = new double*[(Nx-1)*(Ny-1)*(Nz-1)*Nt]; for(int i = 0; i < (Nx-1)*(Ny-1)*(Nz-1)*Nt; ++i){ Bfield[i] = new double[3]; velocity[i] = new double[6]; concentrations[i] = new double[4]; divergence[i] = new double[3]; } for(int i = 0; i < (Nx-1)*(Ny-1)*(Nz-1)*Nt; ++i){ fscanf(BFile, "%lf %lf %lf", &Bfield[i][0], &Bfield[i][1], &Bfield[i][2]); //fscanf(velocityProtonFile, "%lf %lf %lf", &velocity[i][0], &velocity[i][1], &velocity[i][2]); //fscanf(velocityElectronFile, "%lf %lf %lf", &velocity[i][3], &velocity[i][4], &velocity[i][5]); //fscanf(concentrationFile, "%lf %lf %lf %lf", &concentrations[i][0], &concentrations[i][1], &concentrations[i][2], &concentrations[i][3]); fscanf(divergenceFile, "%lf %lf %lf", &divergence[i][0], &divergence[i][1], &divergence[i][2]); } for(int i = 0; i < Nx-1; ++i) { fprintf(gleBFileX, "%20.15g", middleX[i]); //fprintf(gleVelocityFileX, "%20.15g", Xgrid[i]); //fprintf(gleConcentrationFileX, "%20.15g", middleX[i]); fprintf(gleDivergenceFileX, "%20.15g", middleX[i]); for(int j = 0; j < timePointsCount; ++j){ int number = timePoints[j]*(Nx-1)*(Ny-1)*(Nz-1) + (Nz-1)*(Ny-1)*i + (Nz-1)*ypoint + zpoint; fprintf(gleBFileX, "% 20.15g %20.15g %20.15g", Bfield[number][0], Bfield[number][1], Bfield[number][2]); //fprintf(gleVelocityFileX, "% 20.15g %20.15g %20.15g %20.15g %20.15g %20.15g", velocity[number][0], velocity[number][1],velocity[number][2], velocity[number][3], velocity[number][4],velocity[number][5]); //fprintf(gleConcentrationFileX, "%20.15g %20.15g %20.15g", concentrations[number][0], concentrations[number][1], concentrations[number][2]); fprintf(gleDivergenceFileX, "% 20.15g %20.15g %20.15g", divergence[number][0], divergence[number][1], divergence[number][2]); } fprintf(gleBFileX, "\n"); //fprintf(gleVelocityFileX, "\n"); //fprintf(gleConcentrationFileX, "\r\n"); fprintf(gleDivergenceFileX, "\n"); } for(int i = 0; i < Ny-1; ++i) { fprintf(gleBFileY, "%20.15g ", middleY[i]); //fprintf(gleVelocityFileY, "%20.15g ", Ygrid[i]); //fprintf(gleConcentrationFileY, "%20.15g ", middleY[i]); fprintf(gleDivergenceFileY, "%20.15g ", middleY[i]); for(int j = 0; j < timePointsCount; ++j){ int number = timePoints[j]*(Nx-1)*(Ny-1)*(Nz-1) + (Nz-1)*(Ny-1)*xpoint + (Nz-1)*i + zpoint; fprintf(gleBFileY, "%20.15g %20.15g %20.15g", Bfield[number][0], Bfield[number][1], Bfield[number][2]); //fprintf(gleVelocityFileY, "%20.15g %20.15g %20.15g %20.15g %20.15g %20.15g", velocity[number][0], velocity[number][1],velocity[number][2], velocity[number][3], velocity[number][4],velocity[number][5]); //fprintf(gleConcentrationFileY, "%20.15g %20.15g %20.15g", concentrations[number][0], concentrations[number][1], concentrations[number][2]); fprintf(gleDivergenceFileY, "%20.15g %20.15g %20.15g", divergence[number][0], divergence[number][1], divergence[number][2]); } fprintf(gleBFileY, "\n"); //fprintf(gleVelocityFileY, "\n"); //fprintf(gleConcentrationFileY, "\n"); fprintf(gleDivergenceFileY, "\n"); } for(int i = 0; i < Nz-1; ++i) { fprintf(gleBFileZ, "%20.15g ", middleZ[i]); //fprintf(gleVelocityFileZ, "%20.15g ", Zgrid[i]); //fprintf(gleConcentrationFileZ, "%20.15g ", middleZ[i]); fprintf(gleDivergenceFileZ, "%20.15g ", middleZ[i]); for(int j = 0; j < timePointsCount; ++j){ int number = timePoints[j]*(Nx-1)*(Ny-1)*(Nz-1) + (Nz-1)*(Ny-1)*xpoint + (Nz-1)*ypoint + i; fprintf(gleBFileZ, "%20.15g %20.15g %20.15g", Bfield[number][0], Bfield[number][1], Bfield[number][2]); //fprintf(gleVelocityFileZ, "%20.15g %20.15g %20.15g %20.15g %20.15g %20.15g", velocity[number][0], velocity[number][1],velocity[number][2], velocity[number][3], velocity[number][4],velocity[number][5]); //fprintf(gleConcentrationFileZ, "%20.15g %20.15g %20.15g", concentrations[number][0], concentrations[number][1], concentrations[number][2]); fprintf(gleDivergenceFileZ, "%20.15g %20.15g %20.15g", divergence[number][0], divergence[number][1], divergence[number][2]); } fprintf(gleBFileZ, "\n"); //fprintf(gleVelocityFileZ, "\n"); //fprintf(gleConcentrationFileZ, "\n"); fprintf(gleDivergenceFileZ, "\n"); } for(int i = 0; i < (Nx-1)*(Ny-1)*(Nz-1)*Nt; ++i){ delete[] Bfield[i]; delete[] velocity[i]; delete[] concentrations[i]; delete[] divergence[i]; } delete[] Bfield; delete[] velocity; delete[] concentrations; delete[] divergence; } void outputEfield(int timePointsCount, FILE *XFile, FILE *YFile, FILE *ZFile, int Nx, int Ny, int Nz, FILE *EFile, FILE *fluxFile, FILE *gleEFileX, FILE *gleEFileY, FILE *gleEFileZ, FILE *gleFluxFileX, FILE *gleFluxFileY, FILE *gleFluxFileZ, int Nt, int xpoint, int ypoint, int zpoint, int *timePoints, double * Xgrid, double * middleX, double * Ygrid, double * middleY, double * Zgrid, double * middleZ) { double** Efield = new double*[Nx * Ny * Nz * Nt]; double** flux = new double*[Nx*Ny*Nz*Nt]; fscanf(XFile, "%lf", &Xgrid[0]); for(int i = 1; i < Nx; ++i){ double a; fscanf(XFile, "%lf", &a); Xgrid[i] = a; middleX[i-1] = (Xgrid[i-1] + Xgrid[i])/2; } fscanf(YFile, "%lf", &Ygrid[0]); for(int i = 1; i < Ny; ++i){ double a; fscanf(YFile, "%lf", &a); Ygrid[i] = a; middleY[i-1] = (Ygrid[i-1] + Ygrid[i])/2; } fscanf(ZFile, "%lf", &Zgrid[0]); for(int i = 1; i < Nz; ++i){ double a; fscanf(ZFile, "%lf", &a); Zgrid[i] = a; middleZ[i-1] = (Zgrid[i-1] + Zgrid[i])/2; } for(int i = 0; i < Nx*Ny*Nz*Nt; ++i){ Efield[i] = new double[3]; flux[i] = new double[3]; } for(int i = 0; i < Nx*Ny*Nz*Nt; ++i){ fscanf(EFile, "%lf %lf %lf", &Efield[i][0], &Efield[i][1], &Efield[i][2]); fscanf(fluxFile, "%lf %lf %lf", &flux[i][0], &flux[i][1], &flux[i][2]); } for(int i = 0; i < Nx; ++i) { fprintf(gleEFileX, "%20.15g ", Xgrid[i]); fprintf(gleFluxFileX, "%20.15g ", Xgrid[i]); for(int j = 0; j < timePointsCount; ++j){ int number = timePoints[j]*Nx*Ny*Nz + Nz*Ny*i + Nz*ypoint + zpoint; fprintf(gleEFileX, "%20.15g %20.15g %20.15g", Efield[number][0], Efield[number][1], Efield[number][2]); fprintf(gleFluxFileX, "%20.15g %20.15g %20.15g", flux[number][0], flux[number][1], flux[number][2]); } fprintf(gleEFileX, "\n"); fprintf(gleFluxFileX, "\n"); } for(int i = 0; i < Ny; ++i) { fprintf(gleEFileY, "%20.15g ", Ygrid[i]); fprintf(gleFluxFileY, "%20.15g ", Ygrid[i]); for(int j = 0; j < timePointsCount; ++j){ int number = timePoints[j]*Nx*Ny*Nz + Nz*Ny*xpoint + Nz*i + zpoint; fprintf(gleEFileY, "%20.15g %20.15g %20.15g", Efield[number][0], Efield[number][1], Efield[number][2]); fprintf(gleFluxFileY, "%20.15g %20.15g %20.15g", flux[number][0], flux[number][1], flux[number][2]); } fprintf(gleEFileY, "\n"); fprintf(gleFluxFileY, "\n"); } for(int i = 0; i < Nz; ++i) { fprintf(gleEFileZ, "%20.15g ", Zgrid[i]); fprintf(gleFluxFileZ, "%20.15g ", Zgrid[i]); for(int j = 0; j < timePointsCount; ++j){ int number = timePoints[j]*Nx*Ny*Nz + Nz*Ny*xpoint + Nz*ypoint + i; fprintf(gleEFileZ, "%20.15g %20.15g %20.15g", Efield[number][0], Efield[number][1], Efield[number][2]); fprintf(gleFluxFileZ, "%20.15g %20.15g %20.15g", flux[number][0], flux[number][1], flux[number][2]); } fprintf(gleEFileZ, "\n"); fprintf(gleFluxFileZ, "\n"); } for(int i = 0; i < Nx*Ny*Nz*Nt; ++i){ delete[] Efield[i]; delete[] flux[i]; } delete[] Efield; delete[] flux; fclose(EFile); fclose(fluxFile); fclose(XFile); fclose(YFile); fclose(ZFile); fclose(gleEFileX); fclose(gleEFileY); fclose(gleEFileZ); fclose(gleFluxFileX); fclose(gleFluxFileY); fclose(gleFluxFileZ); }
c25329130c733fe4667bbbb6d82547be8c8260fe
ba8e87b98e591e02c4a94434315271947d57fdcd
/baekjoon_study_wook/구현/16236_dw.cpp
6aa9eb182ad2ee50e8a60f650a513242709e8f57
[]
no_license
ji-one/algorithm-study
f0e66af8748a2772796b18574586e45ff66d4db8
8931faa7a2893c19c150c61dedf0ea3c88965b69
refs/heads/main
2023-08-02T12:26:33.667856
2021-08-23T07:42:55
2021-08-23T07:42:55
326,375,577
2
1
null
2021-08-23T07:42:55
2021-01-03T10:00:37
C++
UTF-8
C++
false
false
3,119
cpp
16236_dw.cpp
// 16236 아기상어 #include <iostream> #include <queue> #include <vector> #include <cstring> using namespace std; int n,m; int level=2; int map[21][21]; int visit[21][21]; int dx[] = {-1,0,0,1}; int dy[] = {0,-1,1,0}; int a, b; bool isInside(int x, int y){ return x>=0 && x<n && y>=0 &&y<n; } int bfs(int x, int y){ map[x][y] = 0; // 이동전 지우기 visit[x][y] = 1; queue<pair<int,int>> q; q.push({x,y}); int c = 1000; // 이동할 수 있는 최소거리 a=n; // 최소거리 x 좌표 b=n; // 최소거리 y 좌표 bool flag = false; // 이동할 수 있는지 확인 while(!q.empty()){ int cx = q.front().first; int cy = q.front().second; // 아기상어보다 작은 물고기이면서 최소거리이면 if(map[cx][cy] < level && map[cx][cy]!=0 && c >=visit[cx][cy]){ if(a > cx){ // 상단에 있는 물고기 선택 flag = true; a=cx; b=cy; c = visit[cx][cy]; } if(a == cx && b > cy){ // 같은 줄에 있다면 좌측에 있는 물고기 선택 flag = true; a=cx; b=cy; c = visit[cx][cy]; } } q.pop(); for(int i=0 ;i <4 ;i++){ int nx = cx + dx[i]; int ny = cy + dy[i]; if(isInside(nx,ny) && level >= map[nx][ny] && !visit[nx][ny]){ visit[nx][ny] = visit[cx][cy]+1; q.push({nx,ny}); } } } if(flag) return c-1; else return 0; } int main(){ cin >> n; int cx, cy; for(int i=0 ;i <n; i++ ){ for(int j=0; j<n; j++){ cin >> map[i][j]; } } int ans=0; int exp=0; int cnt=0; while(1){ int t = 0; // 이동거리 초기화 memset(visit,0,sizeof(visit)); // 먹을 수 있는 물고기가 없다면 종료 bool exit =true; for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(map[i][j] != 0 &&level > map[i][j] && map[i][j] != 9 ){ exit = false; break; } } } if(exit) break; // 현재 상어 위치 저장 for(int i=0; i<n; i++){ for(int j=0; j<n; j++){ if(map[i][j] == 9) { cx = i; cy = j; } } } // 최소이동거리 t = bfs(cx, cy); // 이동할 수 없다면 종료 if(t == 0) break; // 이동한 좌표에 아기상어 배치 map[a][b] = 9; // 이동거리만큼 추가 ans+=t; // 물고기 한마리 먹음으로 경험치 상승 exp+=1; // 상어 크기와 먹은 물고기 수가 같으면 크기 증가 if(exp == level){ exp=0; level++; } } cout << ans; return 0 ; }
dd7e86b82b003aead65e3de7203f18dad116fa5a
a86078d2510ab5372f7e969e2c44a016024f5a43
/hp/main.cc
3913c63534ea5a83fc57fbe70272a26140fdb1c2
[]
no_license
peterrum/dealii-tet-application
2159826bcca27f1864b8b1c891ce529a71449bc6
66cf298714ef8259ede14121e4d8a3b7a4029b03
refs/heads/master
2022-11-15T23:21:47.888101
2020-07-15T13:39:46
2020-07-15T13:39:46
256,489,891
0
0
null
2020-07-05T05:53:11
2020-04-17T11:56:27
C++
UTF-8
C++
false
false
4,913
cc
main.cc
/* --------------------------------------------------------------------- * * Copyright (C) 1999 - 2016 by the deal.II authors * * This file is part of the deal.II library. * * The deal.II library is free software; you can use it, redistribute * it, and/or modify it under the terms of the GNU Lesser General * Public License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * The full text of the license can be found in the file LICENSE at * the top level of the deal.II distribution. * * --------------------------------------------------------------------- * */ #include <deal.II/base/convergence_table.h> #include <deal.II/base/function.h> #include <deal.II/base/logstream.h> #include <deal.II/base/quadrature_lib.h> #include <deal.II/dofs/dof_accessor.h> #include <deal.II/dofs/dof_handler.h> #include <deal.II/dofs/dof_tools.h> #include <deal.II/fe/fe_dgq.h> #include <deal.II/fe/fe_interface_values.h> #include <deal.II/fe/fe_q.h> #include <deal.II/fe/fe_values.h> #include <deal.II/fe/mapping_isoparametric.h> #include <deal.II/fe/mapping_q.h> #include <deal.II/grid/grid_generator.h> #include <deal.II/grid/grid_out.h> #include <deal.II/grid/manifold_lib.h> #include <deal.II/grid/tria.h> #include <deal.II/grid/tria_accessor.h> #include <deal.II/grid/tria_iterator.h> #include <deal.II/lac/dynamic_sparsity_pattern.h> #include <deal.II/lac/full_matrix.h> #include <deal.II/lac/precondition.h> #include <deal.II/lac/solver_cg.h> #include <deal.II/lac/sparse_matrix.h> #include <deal.II/lac/vector.h> #include <deal.II/meshworker/mesh_loop.h> #include <deal.II/numerics/data_out.h> #include <deal.II/numerics/matrix_tools.h> #include <deal.II/numerics/vector_tools.h> #include <deal.II/simplex/data_out.h> #include <deal.II/simplex/fe_lib.h> #include <deal.II/simplex/grid_generator.h> #include <deal.II/simplex/quadrature_lib.h> #include <fstream> #include <iostream> using namespace dealii; template <int dim> class RightHandSideFunction : public Function<dim> { public: RightHandSideFunction(const unsigned int n_components) : Function<dim>(n_components) {} virtual double value(const Point<dim> &p, const unsigned int component = 0) const { return p[component % dim] * p[component % dim]; } }; void test(const unsigned int degree) { const int dim = 2; const int spacedim = 2; Triangulation<dim, spacedim> tria; std::vector<Point<spacedim>> points; points.emplace_back(0, 0); points.emplace_back(1, 0); points.emplace_back(0, 1); points.emplace_back(1, 1); points.emplace_back(2, 1); points.emplace_back(1, 2); std::vector<CellData<dim>> cells; { CellData<dim> cell; cell.vertices = {3, 4, 5}; cells.emplace_back(cell); } { CellData<dim> cell; cell.vertices = {0, 1, 2, 3}; cells.emplace_back(cell); } { CellData<dim> cell; cell.vertices = {1, 4, 3}; cells.emplace_back(cell); } { CellData<dim> cell; cell.vertices = {2, 3, 5}; cells.emplace_back(cell); } tria.create_triangulation(points, cells, SubCellData()); DoFHandler<dim, spacedim> dof_handler(tria, /*hp=*/true); for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->reference_cell_type() == ReferenceCell::Type::Tri) cell->set_active_fe_index(0); else cell->set_active_fe_index(1); Simplex::FE_P<dim, spacedim> fe1(degree); FE_Q<dim, spacedim> fe2(degree); hp::FECollection<dim, spacedim> fes(fe1, fe2); MappingIsoparametric<dim> mapping1(Simplex::FE_P<dim>(1)); MappingQ<dim, spacedim> mapping2(1); hp::MappingCollection<dim, spacedim> mappings; // TODO!!! mappings.push_back(mapping1); mappings.push_back(mapping2); dof_handler.distribute_dofs(fes); std::vector<types::global_dof_index> dof_indices; for (const auto &cell : dof_handler.active_cell_iterators()) { dof_indices.resize(fes[cell->active_fe_index()].n_dofs_per_cell()); cell->get_dof_indices(dof_indices); for (const auto &i : dof_indices) std::cout << i << " "; std::cout << std::endl; } GridOut grid_out; std::ofstream out("hp-mesh.vtk"); grid_out.write_vtk(tria, out); Vector<double> solution(dof_handler.n_dofs()); // VectorTools::interpolate(mappings, // dof_handler, // RightHandSideFunction<dim>(1), // solution); DataOut<dim> data_out; data_out.attach_dof_handler(dof_handler); data_out.add_data_vector(solution, "solution"); data_out.build_patches(mappings, degree); std::ofstream output("hp-data_.vtk"); data_out.write_vtk(output); } int main() { deallog.depth_console(0); test(/*degree=*/1); std::cout << std::endl << std::endl; // if(false) test(/*degree=*/2); return 0; }
5bb9fc5558b087d24a8738822f1176304fd5f8cd
cb3b23ce33c47a37563f7c53359f2cb7cda786c0
/GameEngine/IConnectClient.h
ed37551a34678d8a73766a96445f1d9d20301549
[]
no_license
SixShoot/MMO-Framework
9712e01b77c91e9d2673ef103175c76fc83a0a65
0878735517b02e06bb1f194f45c84ab5b9a8e626
refs/heads/master
2021-05-27T15:09:35.592838
2014-08-13T17:20:55
2014-08-13T17:20:55
null
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
334
h
IConnectClient.h
/* Author: Gudakov Ramil Sergeevich a.k.a. Gauss Гудаков Рамиль Сергеевич Contacts: [ramil2085@mail.ru, ramil2085@gmail.com] See for more information License.h. */ #ifndef IConnectClientH #define IConnectClientH class IConnectClient { public: IConnectClient(){}; virtual ~IConnectClient() = 0; }; #endif
9b63f60569cf44b527dadc1035a5e60133724b4b
421a5ab08dbedfcaf81e6d89df376ad86329154b
/yhy2/EX6-1/EX6-1/Form1.h
807ffd7e32364d0864ed81000d2b096316788808
[]
no_license
yhybulider/vc-demo
b38f0d68a8316e69fc76a5217b7ae1b0840e1e2d
8b699fbd3ca478c0ce54a19932b66422158dc241
refs/heads/master
2020-07-07T10:46:07.986750
2019-12-10T07:14:40
2019-12-10T07:14:40
203,325,187
0
0
null
null
null
null
GB18030
C++
false
false
8,035
h
Form1.h
#pragma once #include "LoginForm.h" namespace EX61 { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Form1 摘要 /// </summary> public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); // //TODO: 在此处添加构造函数代码 // } protected: /// <summary> /// 清理所有正在使用的资源。 /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::LinkLabel^ linkLabel1; protected: private: System::Windows::Forms::LinkLabel^ linkLabel2; private: System::Windows::Forms::WebBrowser^ webBrowser1; private: System::Windows::Forms::Button^ button1; private: System::Windows::Forms::Button^ button2; private: System::Windows::Forms::Button^ button3; private: System::Windows::Forms::Button^ button4; private: /// <summary> /// 必需的设计器变量。 /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> void InitializeComponent(void) { this->linkLabel1 = (gcnew System::Windows::Forms::LinkLabel()); this->linkLabel2 = (gcnew System::Windows::Forms::LinkLabel()); this->webBrowser1 = (gcnew System::Windows::Forms::WebBrowser()); this->button1 = (gcnew System::Windows::Forms::Button()); this->button2 = (gcnew System::Windows::Forms::Button()); this->button3 = (gcnew System::Windows::Forms::Button()); this->button4 = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // linkLabel1 // this->linkLabel1->AutoSize = true; this->linkLabel1->Location = System::Drawing::Point(12, 22); this->linkLabel1->Name = L"linkLabel1"; this->linkLabel1->Size = System::Drawing::Size(67, 15); this->linkLabel1->TabIndex = 0; this->linkLabel1->TabStop = true; this->linkLabel1->Text = L"暨南大学"; this->linkLabel1->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &Form1::linkLabel1_LinkClicked); this->linkLabel1->Click += gcnew System::EventHandler(this, &Form1::L1_OnClicked); // // linkLabel2 // this->linkLabel2->LinkArea = System::Windows::Forms::LinkArea(0, 4); this->linkLabel2->LinkBehavior = System::Windows::Forms::LinkBehavior::HoverUnderline; this->linkLabel2->Location = System::Drawing::Point(85, 23); this->linkLabel2->Name = L"linkLabel2"; this->linkLabel2->Size = System::Drawing::Size(271, 25); this->linkLabel2->TabIndex = 1; this->linkLabel2->TabStop = true; this->linkLabel2->Text = L"珠海校区 电气工程学院 电气自动化"; this->linkLabel2->UseCompatibleTextRendering = true; this->linkLabel2->LinkClicked += gcnew System::Windows::Forms::LinkLabelLinkClickedEventHandler(this, &Form1::L2_OnClicked); // // webBrowser1 // this->webBrowser1->Location = System::Drawing::Point(32, 102); this->webBrowser1->MinimumSize = System::Drawing::Size(20, 20); this->webBrowser1->Name = L"webBrowser1"; this->webBrowser1->Size = System::Drawing::Size(1044, 441); this->webBrowser1->TabIndex = 2; // // button1 // this->button1->Location = System::Drawing::Point(375, 23); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(72, 25); this->button1->TabIndex = 3; this->button1->Text = L"刷新"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click); // // button2 // this->button2->Location = System::Drawing::Point(453, 23); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(73, 25); this->button2->TabIndex = 4; this->button2->Text = L"后退"; this->button2->UseVisualStyleBackColor = true; this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click); // // button3 // this->button3->Location = System::Drawing::Point(532, 22); this->button3->Name = L"button3"; this->button3->Size = System::Drawing::Size(71, 26); this->button3->TabIndex = 5; this->button3->Text = L"前进"; this->button3->UseVisualStyleBackColor = true; this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Onclick); // // button4 // this->button4->Location = System::Drawing::Point(609, 23); this->button4->Name = L"button4"; this->button4->Size = System::Drawing::Size(73, 25); this->button4->TabIndex = 6; this->button4->Text = L"主页"; this->button4->UseVisualStyleBackColor = true; this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(8, 15); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(1121, 577); this->Controls->Add(this->button4); this->Controls->Add(this->button3); this->Controls->Add(this->button2); this->Controls->Add(this->button1); this->Controls->Add(this->webBrowser1); this->Controls->Add(this->linkLabel2); this->Controls->Add(this->linkLabel1); this->Name = L"Form1"; this->Text = L" 网页链接"; this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load); this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion private: System::Void webBrowser1_DocumentCompleted(System::Object^ sender, System::Windows::Forms::WebBrowserDocumentCompletedEventArgs^ e) { } private: System::Void linkLabel1_LinkClicked(System::Object^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^ e) { } private: System::Void L1_OnClicked(System::Object^ sender, System::EventArgs^ e) { this->linkLabel1->LinkVisited = true; //System::Diagnostics::Process::Start("IExplore.exe" ); System::Diagnostics::Process::Start("IExplore.exe", "www.jnu.edu.cn"); } private: System::Void linkLabel2_LinkClicked(System::Object^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^ e) { } private: System::Void L2_OnClicked(System::Object^ sender, System::Windows::Forms::LinkLabelLinkClickedEventArgs^ e) { int i = this->linkLabel2->Links->IndexOf(e->Link); this->linkLabel2->Links[i]->Visited = true; // 获取当前用户点击的超级链接内容 String^ target = dynamic_cast<String^>(e->Link->LinkData); if (!String::IsNullOrEmpty(target)) { target = target->Trim(); // 如果是一个URL,则打开IE并访问它,否则弹出一个消息对话框 if (target->StartsWith(L"zh") || target->StartsWith(L"eic")){ //System::Diagnostics::Process::Start( "IExplore.exe" ); System::Diagnostics::Process::Start("IExplore.exe", target); } else { MessageBox::Show(target, target); } } } private: System::Void On_Load(System::Object^ sender, System::EventArgs^ e) { LoginForm^theform = gcnew LoginForm; if (theform->ShowDialog() != System::Windows::Forms::DialogResult::OK) { this->Close(); } this->linkLabel2->Links[0]->LinkData = "zh.jnu.edu.cn"; this->linkLabel2->Links->Add(5, 6, "zh.jnu.edu.cn"); this->linkLabel2->Links->Add(12, 5, "电气自动化"); } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { webBrowser1->GoBack(); } private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { webBrowser1->Refresh(); } private: System::Void button3_Onclick(System::Object^ sender, System::EventArgs^ e) { webBrowser1->GoForward(); } private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) { webBrowser1->GoHome(); } private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { } }; }
0b77001a453cb266e04e7ad18f06910de5f79c22
5130d9033f157a1612f287e6935f0ba7fdfd353f
/src/Modules/Strategy/Roles/DefenderRole.cpp
82f824ac15926a856c2cdcedcfd168c5a6f055ff
[ "MIT" ]
permissive
AlexanderSilvaB/Mari
5c75470760afd0729420541bb318837193f0bbb5
0a660d39ad9d987d449c7fc9b1fb6d1cec631cb6
refs/heads/master
2021-07-10T07:43:10.799212
2019-01-25T00:54:26
2019-01-25T00:54:26
145,122,528
3
9
MIT
2020-06-20T16:20:48
2018-08-17T13:16:02
C++
UTF-8
C++
false
false
4,954
cpp
DefenderRole.cpp
#include "DefenderRole.h" #include "Core/Utils/Math.h" #include "Core/Utils/RelativeCoord.h" #include "Core/Utils/RobotDefs.h" #include "Core/Utils/CartesianCoord.h" DefenderRole::DefenderRole(SpellBook *spellBook) : Role(spellBook) { onBall = false; onPosition = false; contPerdido = 0; scanPitch = 0; conta = 0; conta2 = 0; conta3 = 0; Deg = Deg2Rad(6.05); Vel = 0.1; reset = false; } DefenderRole::~DefenderRole() { } void DefenderRole::Tick(float ellapsedTime, const SensorValues &sensor) { if(spellBook->strategy.TimeSincePenalized < 5.0f && !reset) { reset = true; conta = 0; conta2 = 0; conta3 = 0; Deg = Deg2Rad(6.05); Vel = 0.1; } else if(spellBook->strategy.TimeSincePenalized >= 5.0f) { reset = false; } spellBook->strategy.MoveHead = false; CartesianCoord coord; RelativeCoord rr; if ((spellBook->strategy.GameState == STATE_READY || spellBook->strategy.GameState == STATE_PLAYING) && !onPosition) { if (spellBook->perception.vision.localization.Enabled) { contPerdido = 0; spellBook->strategy.WalkForward = true; spellBook->strategy.TargetX = 0.0f; spellBook->strategy.TargetY = 0.0f; spellBook->strategy.TargetTheta = 0; CartesianCoord current(spellBook->perception.vision.localization.X, spellBook->perception.vision.localization.Y); CartesianCoord desired(spellBook->strategy.TargetX, spellBook->strategy.TargetY); if (current.distance(desired) < 0.2f) { spellBook->strategy.WalkForward = false; onPosition = true; } } else { onPosition = true; } } if (spellBook->strategy.GameState == STATE_PLAYING) { if(!Kicking()) { if(spellBook->perception.vision.ball.BallLostCount < 8) { spellBook->motion.Vy = 0; if(abs(spellBook->perception.vision.ball.BallYaw) > Deg2Rad(10.0f)) { spellBook->motion.Vth = -spellBook->perception.vision.ball.BallYaw * 0.5f; spellBook->motion.Vx = 0; CancelKick(); } else { if(abs(spellBook->perception.vision.ball.BallYaw) > Deg2Rad(5.0f)) spellBook->motion.Vth = -spellBook->perception.vision.ball.BallYaw * 0.4f; else spellBook->motion.Vth = 0; if(spellBook->perception.vision.ball.BallDistance < 0.45f) spellBook->motion.HeadPitch = Deg2Rad(24.0f); else if(spellBook->perception.vision.ball.BallDistance > 0.5f) spellBook->motion.HeadPitch = Deg2Rad(0.0f); if(spellBook->perception.vision.ball.BallDistance > 0.25f) { spellBook->motion.Vx = min(spellBook->perception.vision.ball.BallDistance * 0.25f, 0.25f); CancelKick(); } else { spellBook->motion.Vx = 0; if(spellBook->motion.HeadPitch > 0) { PrepareKick(spellBook->perception.vision.ball.BallYaw); } else { CancelKick(); } } } } else { spellBook->motion.KickRight = false; spellBook->motion.Vth = 0; spellBook->motion.Vx = 0; if(conta<250){ spellBook->motion.Vy = Vel; spellBook->motion.Vth = Deg; } else if(conta<350) { spellBook->motion.Vy = 0; spellBook->motion.Vth = 0; } else { conta = 0; conta2++; } conta++; if(conta2 == 4){ Vel = -0.1; Deg = Deg2Rad(1.6); } if(conta2 == 9){ Vel = 0.1; Deg = Deg2Rad(6.05); conta2 = 0; } if(conta3 < 50){ spellBook->motion.HeadPitch = Deg2Rad(10); } else if (conta3 <100){ spellBook->motion.HeadPitch = Deg2Rad(20); } else if (conta3 <150){ spellBook->motion.HeadPitch = 0; } else { conta3 = 0; } conta3++; } } } }
0d4c497e9b24e3359c6ab705b7555604b309585f
6780de392f3c741e48345c65d524046dc3da02c0
/Pip-Boy 3000/Pip-Boy 3000/Pip-Boy 3000View.h
9e280f9b60d189c93715efd241f6ba7ea42e1f8a
[]
no_license
Thudcrackers/school
d29f04b8a78d2aca935483cabc07922841d769ec
4644583b92e3d0114ebde0655133ded67009151e
refs/heads/master
2021-01-10T15:22:47.005938
2018-01-23T19:19:38
2018-01-23T19:19:38
53,738,027
0
0
null
null
null
null
UTF-8
C++
false
false
2,053
h
Pip-Boy 3000View.h
// Pip-Boy 3000View.h : interface of the CPipBoy3000View class // #pragma once #include "afxwin.h" #include "image_weapons.h" class CPipBoy3000Set; class CPipBoy3000View : public CRecordView { protected: // create from serialization only CPipBoy3000View(); DECLARE_DYNCREATE(CPipBoy3000View) public: #ifdef AFX_DESIGN_TIME enum{ IDD = IDD_PIPBOY3000_FORM }; #endif CPipBoy3000Set* m_pSet; // Attributes public: CPipBoy3000Doc* GetDocument() const; // Operations public: // Overrides public: virtual CRecordset* OnGetRecordset(); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual void OnInitialUpdate(); // called first time after construct virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); // Implementation public: virtual ~CPipBoy3000View(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // Generated message map functions protected: DECLARE_MESSAGE_MAP() public: CStatic m_apparelButton; CStatic m_weaponsButton; CStatic m_aidButton; virtual void OnDraw(CDC* /*pDC*/); afx_msg void OnStnClickedStaticWeapons(); CListBox m_inventoryList; CStringA category; DECLARE_EVENTSINK_MAP() void MouseDownImageWeapons(short Button, short Shift, float X, float Y); CImage_weapons m_weapons; void MouseDownImageApparel(short Button, short Shift, float X, float Y); CImage_weapons m_apparel; CImage_weapons m_aid; void MouseDownImageAid(short Button, short Shift, float X, float Y); afx_msg void OnBnClickedButtonPickup(); afx_msg void OnBnClickedButtonDrop(); int selectedCategory; }; #ifndef _DEBUG // debug version in Pip-Boy 3000View.cpp inline CPipBoy3000Doc* CPipBoy3000View::GetDocument() const { return reinterpret_cast<CPipBoy3000Doc*>(m_pDocument); } #endif
02d25567af5c886659b94e399242b21e51e7cd39
47ab511d1e5f2418745f6319b7584221e578a705
/LamndaEx/address_book.h
50435578790cabdedc17cbb9859ab17c888bc106
[]
no_license
sdaingade/cpplabs
f460936a6e2e4d68e13a9745b6edaae9aa75ba83
fa6e644c1f83cbd73d4d6494a1d07f942915b62f
refs/heads/master
2021-05-29T23:53:37.281887
2015-10-04T16:14:06
2015-10-04T16:14:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,414
h
address_book.h
#ifndef ADDRESS_BOOK_H #define ADDRESS_BOOK_H /************************************************************** * * File: address_book.h * * Description: Declaraiton of the address book * * Author: SciSpike * * Modification History: * ***************************************************************/ /* Include Files */ #include <map> #include <string> #include <iostream> #include <list> #include <functional> /**************************************************************** * * Description: Declares the interface and data structure * for an address book * * Exceptions: None * ***************************************************************/ class AddressBook { public: // The default constructor AddressBook(); // Add an entry to the phone book void addEntry(const std::string& name, const std::string& phoneNumber); // List all entries void listEntries(std::ostream& where) const; // Remove an entry bool removeEntry(const std::string& name); // Find an entry given a client defined function // TODO: Declare the find function here (there is a corresponding TODO in the address_book.cpp file) private: std::map<std::string,std::string> content; // the map used to store the entries AddressBook(const AddressBook& rhs); // private to prevent copying AddressBook& operator=(const AddressBook& rhs); // private to prevent assignment }; #endif
79b43456b46ffe8470d147df5e1497e775a00ea8
a6e0e2de1c86964f5f9c0f9765d8d9a1b3da548b
/alg/teca_time_axis_convolution.h
44a1b2798d27a3dbfaa2666cb38fb3c5a615fce2
[ "BSD-3-Clause-LBNL" ]
permissive
LBL-EESA/TECA
056b1b7859d87f8c55d2267f90c78c548826b931
c78d39b05623fb33cc5487e038a6441ce8a44c55
refs/heads/develop
2023-08-31T13:44:45.918534
2023-07-25T15:13:03
2023-07-25T15:13:03
48,189,266
52
21
NOASSERTION
2023-09-11T23:51:12
2015-12-17T17:46:48
C++
UTF-8
C++
false
false
5,773
h
teca_time_axis_convolution.h
#ifndef teca_time_axis_convolution_h #define teca_time_axis_convolution_h #include "teca_config.h" #include "teca_shared_object.h" #include "teca_algorithm.h" #include "teca_metadata.h" #include <string> #include <vector> TECA_SHARED_OBJECT_FORWARD_DECL(teca_time_axis_convolution) /// An algorithm that applies a convolution along the time axis /** Supports constant, Gaussian, and explicitly provided convolution kernels of * arbitrary width applied over forward, backward, or centered stencils. * * A number of options are provided for specifying kernel weights. * * * User provided kernels can be explicitly specified via the combination of * ::set_kernel_weights and ::set_kernel_name. * * * The kernel can be generated at run time by providing a kernel name, width, * and flag selecting either a high or low pass filter via the combination of * ::set_kernel_name, ::set_kernel_width, and ::set_use_high_pass. In this * case default kernel parameters are used. * * * The kernel can be generated with explicitly provided kernel parameters. */ class TECA_EXPORT teca_time_axis_convolution : public teca_algorithm { public: TECA_ALGORITHM_STATIC_NEW(teca_time_axis_convolution) TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_time_axis_convolution) TECA_ALGORITHM_CLASS_NAME(teca_time_axis_convolution) ~teca_time_axis_convolution(); // report/initialize to/from Boost program options objects. TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION() TECA_SET_ALGORITHM_PROPERTIES() /** @name stencil_type * Select which time steps are convolved. The default stencil is backward. */ ///@{ enum { backward, /// convolve with time steps before the active step centered, /// convolve with time steps centered on the active step forward /// convolve with time steps after the active step }; TECA_ALGORITHM_PROPERTY(int, stencil_type) /// convolve with time steps after the active step void set_stencil_type_to_forward() { this->stencil_type = forward; } /// convolve with time steps before the active step void set_stencil_type_to_backward() { this->stencil_type = backward; } /// convolve with time steps centered on the active step void set_stencil_type_to_centered() { this->stencil_type = centered; } /// set the stencil type from a string int set_stencil_type(const std::string &type); /// get the stencil as a string std::string get_stencil_type_name(); ///@} /** @name use_high_pass * When set the internally generated weights will be converted to a * high_pass filter during weight generation. This option has no affect on * user provided kernel weights. */ ///@{ TECA_ALGORITHM_PROPERTY(int, use_high_pass) ///@} /** @name kernel_width * The number of samples to use when generating kernel weights. This option * has no affect on user provided kernel weights. */ ///@{ TECA_ALGORITHM_PROPERTY(unsigned int, kernel_width) ///@} /** @name kernel_weights * Set the kernel weights explicitly. The number of weights defines the * stencil width and must be odd for a centered stencil. */ ///@{ TECA_ALGORITHM_VECTOR_PROPERTY(double, kernel_weight) /// generate constant convolution kernel weights with the given filter width int set_constant_kernel_weights(unsigned int width); /** generate Gaussian convolution kernel weights with the given filter * width. * * @param[in] width the number of samples in the generated kernel * @param[in] high_pass transform the weights for use in a high pass filter. * @param[in] a peak height of the Gaussian * @param[in] B center of the Gaussian (note coordinates range from -1 to 1. * @param[in] c width of the Gaussian */ int set_gaussian_kernel_weights(unsigned int width, int high_pass = 0, double a = 1.0, double B = 0.0, double c = 0.55); /** set the kernel weights from a string name the kernel type. Default * kernel weight generator parameters are used. * * @param[in] name the name of the kernel to generate. (gaussian, or constant) * @param[in] width the width of the kernel. * @param[in] high_pass convert the weights for use as a high pass filter. */ int set_kernel_weights(const std::string &name, unsigned int width, int high_pass); ///@} /** @name kernel_name * set the name of the user provided kernel, or the kernel to generate. */ ///@{ TECA_ALGORITHM_PROPERTY(std::string, kernel_name) ///@} /** @name variable_postfix * a string to be appended to the name of each output variable setting this * to an empty string will result in the damped array replacing the input * array in the output. default is an empty string "" */ ///@{ TECA_ALGORITHM_PROPERTY(std::string, variable_postfix) ///@} protected: teca_time_axis_convolution(); private: using teca_algorithm::get_output_metadata; teca_metadata get_output_metadata(unsigned int port, const std::vector<teca_metadata> &input_md) override; std::vector<teca_metadata> get_upstream_request( unsigned int port, const std::vector<teca_metadata> &input_md, const teca_metadata &request) override; const_p_teca_dataset execute(unsigned int port, const std::vector<const_p_teca_dataset> &input_data, const teca_metadata &request) override; private: int stencil_type; std::vector<double> kernel_weights; std::string kernel_name; std::string variable_postfix; int use_high_pass; unsigned int kernel_width; }; #endif
2f655d7908435484b07136a504bad2d0910eb86d
cec628def1aad94ccbefa814d2a0dbd51588e9bd
/cnd.completion/test/unit/data/org/netbeans/modules/cnd/completion/cplusplus/hyperlink/LibrariesContentHyperlinkTestCase/src/bug257028.cpp
41bd3598e7a6b17af7c3518f343f9e6785127d65
[]
no_license
emilianbold/netbeans-releases
ad6e6e52a896212cb628d4522a4f8ae685d84d90
2fd6dc84c187e3c79a959b3ddb4da1a9703659c7
refs/heads/master
2021-01-12T04:58:24.877580
2017-10-17T14:38:27
2017-10-17T14:38:27
78,269,363
30
15
null
2020-10-13T08:36:08
2017-01-07T09:07:28
null
UTF-8
C++
false
false
184
cpp
bug257028.cpp
#include <bug257028_1.h> #include <bug257028_2.h> namespace bug257028 { using namespace outer257028; void foo257028() { BBB257028 b; b.boo().foo(); } }
f90fd323171e170f241c0bc07cbc47e0b0c8af03
3029f2e472efc8435684da2d281a5197a6b08d1d
/Provas/MedianaDC.cpp
0f40d413b47ab282cce8e211833806b082c54a21
[]
no_license
NoemiHonorato10/PAA
be8c684ba5eb29bc4dbd7232018222c91beca25c
452098fcac9dfea5811d2f7aa88b4ccdbb6375e2
refs/heads/main
2023-06-16T19:48:28.569447
2021-07-13T14:50:38
2021-07-13T14:50:38
351,642,441
1
0
null
null
null
null
UTF-8
C++
false
false
803
cpp
MedianaDC.cpp
//Algoritmo da Mediana Diminuir e Conquista //Teorema Mestre T(n)= aT(n/b)+f(n) //Relação de recorrência: T(n) = 2T(n/2)+1 T(1)=0 #include <bits/stdc++.h> float mediana(std::vector<int> &vetor, int inicio, int fim) { if (fim - inicio == 1) // condição para achar o valor se for Par { return (float)(vetor[inicio] + vetor[fim]) / 2; //Retorna float caso seja decimal } if (inicio == fim) //condição para chegar ao valor se for Impar { return vetor[inicio]; } mediana(vetor, inicio + 1, fim - 1); } int main() { //Posição: 0| 1| 2| 3| 4| 5| 6| 7| 8| 9 std::vector<int> vetor = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; std::cout << "Mediana:\n"; std::cout << mediana(vetor, 0, vetor.size() - 1) << std::endl; return 0; }
950ce7ff97cc60379cabe804f76c773d7b3f6c9b
e7b0d46cfd4241481f6a287867a4107b35210da8
/leetcode/104_Maximum_Depth_Of_Binary_Tree.cpp
77e4157f17f41e19aae54168f369d2c4b4e5e49b
[]
no_license
wuxun-zhang/algorithms_learning
751eacb0cbbfff971569de74bf88929faf0e1422
7c9a9ea3a0a3b9733bdecb888c5514069e09e1a0
refs/heads/master
2021-06-08T18:43:39.564527
2021-03-28T11:10:22
2021-03-28T11:10:22
136,330,554
0
0
null
null
null
null
UTF-8
C++
false
false
711
cpp
104_Maximum_Depth_Of_Binary_Tree.cpp
#include<iostream> using namespace std; // Definition for a binary tree node. struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {} }; class Solution { public: // recursive // traverse from leaf node to root node int maxDepth(TreeNode* root) { if(!root) return 0; int mx=0; int leftDepth = maxDepth(root->left); if(mx<leftDepth) mx = leftDepth; int rightDepth = maxDepth(root->right); if(mx<rightDepth) mx = rightDepth; return mx+1; } int maxDepth_opt(TreeNode* root){ if(!root) return 0; return max(maxDepth_opt(root->left)+1, maxDepth_opt(root->right)+1); } };
c18b8c7cdc19aa460aa230a6e408c98393ddef00
195a571584cc387360b75c172a75eeba687838cb
/src/board/Widget.h
e4e4f4ca578dff11b4be77151276e8041b9f2943
[]
no_license
coffeecup-winner/taptain
6c51e13e5c47f0006aa2328e995e09419a4b944f
d8e4f6f12c24b8628fb853a07f452e671b4ac1e0
refs/heads/main
2023-03-28T05:00:57.971051
2021-03-20T21:54:18
2021-03-20T21:54:18
346,132,929
0
0
null
null
null
null
UTF-8
C++
false
false
1,632
h
Widget.h
#pragma once #include <LCDWIKI_KBV.h> #include <stdint.h> #include "Message.h" class Widget { static constexpr uint16_t MAX_TEXT_LEN = 21; uint16_t m_x; uint16_t m_y; uint8_t m_width; uint8_t m_height; char m_name[MAX_TEXT_LEN]; uint8_t m_prevPercentProgress; uint8_t m_percentProgress; enum class Type : uint8_t { Display = 0, Task, COUNT, } m_type; enum class State : uint8_t { Default = 0, Active, Paused, } m_state; enum DrawFlags : uint8_t { None = 0x00, Border = 0x01, Text = 0x02, Progress = 0x04, All = 0xff, } m_drawFlags; public: Widget() : m_x() , m_y() , m_width() , m_height() , m_name() , m_prevPercentProgress() , m_percentProgress() , m_type() , m_state() , m_drawFlags() { } Widget(const uint16_t x, const uint16_t y, const uint8_t width, const uint8_t height) : m_x(x) , m_y(y) , m_width(width) , m_height(height) , m_name() , m_prevPercentProgress(0) , m_percentProgress(0) , m_type(Type::Display) , m_state(State::Default) , m_drawFlags(DrawFlags::All) { } void Reset(); void SetType(const uint8_t type); void SetName(const char* name); void SetProgress(const uint8_t percent); void Tap(Message* message); void TapElsewhere(Message *message); void Draw(const LCDWIKI_KBV& lcd); };
7d2c6f51572ccad2df5612c382938e93b84931fa
ca864a873611d482beb8eb4a1cc439153797622d
/source/CInfoDlg.h
8b01ebab1a9636b799b97fd3372cf4b2eff4ea69
[]
no_license
wtrsltnk/PSPManager
597c3e92476030ed638f1403f1c8f93d5f777d26
f6ccb9b7b9cc25a04b8896e9b449ff3fe55f3996
refs/heads/master
2021-08-18T21:01:03.112116
2017-11-23T20:08:38
2017-11-23T20:08:38
111,845,594
0
0
null
null
null
null
UTF-8
C++
false
false
306
h
CInfoDlg.h
#ifndef CINFODLG_H #define CINFODLG_H #include <windows.h> #include "..\Resource\resource.h" #include <strstream> class CInfoDlg { private: HWND m_hWnd; HINSTANCE m_hInstance; public: CInfoDlg(HINSTANCE, HWND); ~CInfoDlg(); void Show(); static BOOL DlgProc(HWND, UINT, WPARAM, LPARAM); }; #endif
2c2d3d64c261b55b4c7c6a7169b46d59209100ed
87181f6f4fad14ca81385e9a1489f5a9410b3cdb
/Colosseum.cpp
452838ebd36d5cd1a5184aade154ba3b30b07a4a
[]
no_license
Saharco/Colosseum1
c641f39c3212809b1662b06cf811bd6149a0dbc6
942110268131cd98a76efd6c211f81e4f7c9fb7f
refs/heads/master
2020-05-20T13:15:03.911136
2019-05-08T11:33:28
2019-05-08T11:33:28
185,593,229
0
0
null
null
null
null
UTF-8
C++
false
false
19,291
cpp
Colosseum.cpp
// // Created by sahar on 03/12/2017. // #include <cstdlib> #include "Colosseum.h" #include "Exceptions.h" class updateLevelsTrainers : public Procedure<Trainer*>{ public: virtual void operator()(Trainer* val) { val->getSquad()->updateMax(); } }; /* * Classic Merge: merges two sorted arrays into a third array, keeping the original sorted order. */ void merge_gladiators(Gladiator *arr1[], int size1, Gladiator *arr2[], int size2, Gladiator *arr3[]) { int i = 0, j = 0, k = 0, temp_level = 0, temp_id = 0; while (i < size1 && j < size2) { temp_level = arr2[j]->getLevel() - arr1[i]->getLevel(); if (temp_level > 0) { arr3[k++] = arr1[i++]; } else if (temp_level < 0) { arr3[k++] = arr2[j++]; } else { temp_id = arr2[j]->getID() - arr1[i]->getID(); if (temp_id > 0) { arr3[k++] = arr2[j++]; } else { arr3[k++] = arr1[i++]; } } } //Fill the leftovers from one of the arrays for (; i < size1; i++) { arr3[k++] = arr1[i]; } for (; j < size2; j++) { arr3[k++] = arr2[j]; } } /* * A functor that inherits from the abstract "Procedure" class, as defined inside the SplayTree class. * The functor counts the amount of gladiators in the tree whose IDs divide by a given number n. */ class countDividableElementsFunction : public Procedure<Gladiator *> { int n; int count; public: countDividableElementsFunction(int n) { this->n = n; count = 0; } void operator()(Gladiator *g) { if (g->getID() % n == 0) { count++; } } int getCount() { return count; } }; /* * A functor that inherits from the abstract "Procedure" class, as defined inside the SplayTree class. * The functor fills an array of pointers of gladiators from the tree, in the order of display from the scan function. */ class toArrayFunction : public Procedure<Gladiator *> { Gladiator **array; //USER FREES THIS int iterator; public: toArrayFunction(Gladiator **array) { this->array = array; iterator = 0; } void operator()(Gladiator *g) { array[iterator] = g; iterator++; } }; /* * A functor that inherits from the abstract "Procedure" class, as defined inside the SplayTree class. * The functor fills an array of IDs of gladiators from the tree, in reverse order to the display order from the scan function. */ class toReverseArrayFunction : public Procedure<Gladiator *> { int **array; //USER FREES THIS int size; int iterator; public: toReverseArrayFunction(int **array, int size) { this->array = array; this->size = size; iterator = 0; } void operator()(Gladiator *g) { iterator++; (*array)[size - iterator] = g->getID(); } }; /* * A functor that inherits from the abstract "Procedure" class, as defined inside the SplayTree class. * The functor fills two arrays of pointers of gladiators from the tree. * Every gladiator whose ID is divisible by a given number n will be stored in one array, and the others in the second one. */ class twoArrayPredicateFunction : public Procedure<Gladiator *> { Gladiator **suitables; Gladiator **not_suitables; int iterator1; int iterator2; int n; public: twoArrayPredicateFunction(Gladiator **suitables, Gladiator **not_suitables, int n) { this->suitables = suitables; this->not_suitables = not_suitables; iterator1 = 0; iterator2 = 0; this->n = n; } void operator()(Gladiator *g) { if (g->getID() % n == 0) { suitables[iterator1++] = g; } else { not_suitables[iterator2++] = g; } } }; /* * A functor that inherits from the abstract "Procedure" class, as defined inside the SplayTree class. * The functor frees the level tree of all the trainers in the tree. */ class destroyTrainersLevelTreeFunction : public Procedure<Trainer *> { public: void operator()(Trainer *t) { t->getSquad()->destroyLevelTree(); } }; /* * The class's C'tor. Allocates a new tree of trainers, and a squad of gladiators. */ Colosseum::Colosseum() { compare_trainers_tree = new compareTrainerID(); trainers = new SplayTree<Trainer *>(*compare_trainers_tree); main_squad = new Squad(); } /* * The class's D'tor. Frees all the memory stored (tree of trainers and a squad of gladiators). * The trees' D'tor do NOT free the gladiators and trainers, so the D'tor scans the trees in-order and frees them first, * before de-allocating the entire structure. */ Colosseum::~Colosseum() { trainers->inOrderDel(); main_squad->removeAll(); delete (main_squad); delete (trainers); delete (compare_trainers_tree); } /* * Adds a new trainer to the system. Allocates a new trainer and inserts it to the trainers' tree. * Parameters: * @ trainerID: the ID of the trainer we wish to add to the system. * An exception is thrown in the following cases: * - the given ID is illegal (not a positive number): INVALID_INPUT * - there already exists a trainer with the given ID: FAILURE * - allocation error. */ StatusType Colosseum::AddTrainer(int trainerID) { if(trainerID<1){ return INVALID_INPUT; } Trainer *new_trainer=NULL; try { new_trainer = new Trainer(trainerID); trainers->insert(new_trainer); } catch (const std::bad_alloc &e) { return ALLOCATION_ERROR; } catch (const failureException &e) { if(new_trainer) { delete (new_trainer); } return FAILURE; } return SUCCESS; } /* * Adds a new gladiator to the system. Allocates a new gladiator and inserts it * into the main squad, and to its corresponding trainer's squad. * Parameters: * @ gladiatorID: the ID of the gladiator we wish to add to the system. * @ trainerID: the ID of the trainer who's responsible for this gladiator. * @ level: the level of the gladiator. * An exception is thrown in the following cases: * - either gladiator's ID, the trainer's ID or the level are illegal (not positive numbers): INVALID_INPUT * - there is no trainer with the given ID: FAILURE * - there's already a gladiator with the given ID: FAILURE * - allocation error. */ StatusType Colosseum::BuyGladiator(int gladiatorID, int trainerID, int level) { try { if (gladiatorID <= 0 || trainerID <= 0 || level <= 0) { return INVALID_INPUT; } Trainer temp_trainer( trainerID); //We temporarily create a trainer with the given ID in order to search for it in the tree Trainer *desired_trainer = trainers->find(&(temp_trainer)); Gladiator *new_gladiator; new_gladiator = main_squad->addGladiator(gladiatorID, level, desired_trainer); desired_trainer->getSquad()->addGladiator(new_gladiator); } catch (const std::bad_alloc &e) { return ALLOCATION_ERROR; } catch (const invalidInputException &e) { return INVALID_INPUT; } catch (const failureException &e) { return FAILURE; } return SUCCESS; } /* * Removes a gladiator from the system. Frees all the tree nodes that took part in its storage. * Parameters: * @ gladiatorID: the ID of the gladiator we wish to remove from the system. * An exception is thrown in the following cases: * - the given ID is illegal (not a positive number): INVALID_INPUT * - there is no gladiator with the given ID in the system: FAILURE * - allocation error. */ StatusType Colosseum::FreeGladiator(int gladiatorID) { try { if (gladiatorID <= 0) { throw badLevelException(); } Gladiator *to_remove = main_squad->findGladiator(gladiatorID); main_squad->removeGladiator(to_remove); to_remove->getTrainer()->getSquad()->removeGladiator(to_remove); delete (to_remove); } catch (const invalidInputException &e) { return INVALID_INPUT; } catch (const failureException &e) { return FAILURE; } return SUCCESS; } /* * Raises the level of a given gladiator in the system. * Parameters: * @ gladiatorID: the ID of the gladiator whose level we wish to update. * @ levelIncrease: the amount of levels we wish to increase the gladiator's level by. * An exception is thrown in the following cases: * - Either the given ID is illegal or the level increase (not positive numbers): INVALID INPUT * - there is no gladiator with the given ID in the system: FAILURE * - allocation error. */ StatusType Colosseum::LevelUp(int gladiatorID, int levelIncrease) { try { if (levelIncrease <= 0) { throw badLevelException(); } Gladiator *to_update = main_squad->findGladiator(gladiatorID); main_squad->removeGladiator(to_update); to_update->getTrainer()->getSquad()->removeGladiator(to_update); to_update->increaseLevel(levelIncrease); main_squad->addGladiator(to_update); to_update->getTrainer()->getSquad()->addGladiator(to_update); } catch (const std::bad_alloc &e) { return ALLOCATION_ERROR; } catch (const invalidInputException &e) { return INVALID_INPUT; } catch (const failureException &e) { return FAILURE; } return SUCCESS; } /* * Finds the gladiator of a certain trainer who has the highest level. If multiple gladiators * share this level value - the one with the lowest ID is returned. * In the case where the trainer ID is a negative number - the same process would be * executed, but out of all the gladiators in the system instead. * The gladiator found will be stored inside a given parameter. * parameters: * @ trainerID: the ID of the trainer who owns the gladiators we want to search. * @ gladiatorID: a pointer that, at the end of this function's run, will point at * the ID of the desired gladiator. * An exception is thrown in the following cases: * - Either the trainer ID is illegal (equals zero), or the gladiator ID points to NULL: INVALID INPUT * - The trainer ID is a positive number, but the trainer does not exist: FAILURE. * - allocation error. */ StatusType Colosseum::GetTopGladiator(int trainerID, int *gladiatorID) { try { if (trainerID == 0) { throw badIdException(); } if (gladiatorID == NULL) { throw failureException(); } Squad *desired_squad = main_squad; if (trainerID > 0) { Trainer temp_trainer(trainerID); Trainer *desired_trainer = trainers->find(&(temp_trainer)); desired_squad = desired_trainer->getSquad(); } *gladiatorID = desired_squad->getBest(); } catch (const std::bad_alloc &e) { return ALLOCATION_ERROR; } catch (const invalidInputException &e) { return INVALID_INPUT; } catch (const failureException &e) { return FAILURE; } return SUCCESS; } /* * Returns all of the gladiators owned by a trainer in an array, in the following order: * the array is sorted by level (HIGHEST to SMALLEST), and then by ID (SMALLEST to HIGHEST). * If the trainer ID is negative, the array will store all of the gladiators in this order. * In addition, the number of gladiators is stored in a given parameter. * parameters: * @ trainerID: the ID of the trainer. * @ gladiators: pointer to an array that will be allocated in the function, and freed * elsewhere by the user. The array will store all of the gladiators (either in the * entire system or of a given trainer), sorted in the previously described order. * @ numOfGladiators - pointer that will store the number of gladiators for this trainer * or in the entire system. * An exception is thrown in the following cases: * - Either the trainer ID is illegal (equals zero), or one of the pointers points to NULL: INVALID INPUT * - The trainer ID is a positive number, but the trainer does not exist: FAILURE. * - allocation error. */ StatusType Colosseum::GetAllGladiatorsByLevel(int trainerID, int **gladiators, int *numOfGladiator) { try { if (trainerID == 0) { throw badIdException(); } if(gladiators == NULL || numOfGladiator == NULL) { throw invalidInputException(); } Squad *desired_squad = main_squad; if (trainerID > 0) { Trainer temp_trainer(trainerID); Trainer *desired_trainer = trainers->find(&(temp_trainer)); desired_squad = desired_trainer->getSquad(); } int num = desired_squad->getSize(); *numOfGladiator = num; *gladiators = (int *) malloc(sizeof(int) * num); //USER'S RESPONSIBILITY TO FREE THIS! toReverseArrayFunction *operation = new toReverseArrayFunction( gladiators, num); desired_squad->scanAllByLevel(*operation); delete (operation); } catch (const std::bad_alloc &e) { return ALLOCATION_ERROR; } catch (const invalidInputException &e) { return INVALID_INPUT; } catch (const failureException &e) { return FAILURE; } return SUCCESS; } /* * Changes the ID of a given gladiator in the system. * Parameters: * @ gladiatorID: the ID of the gladiator whose level we wish to update. * @ levelIncrease: the amount of levels we wish to increase the gladiator's level by. * An exception is thrown in the following cases: * - either the given ID or the new ID are illegal (not positive numbers): INVALID INPUT * - there is no gladiator with the given ID in the system: FAILURE * - the current ID and the new ID of the gladiator are both equal: FAILURE * - allocation error. */ StatusType Colosseum::UpgradeGladiator(int gladiatorID, int upgradedID) { try { if (gladiatorID == upgradedID) { throw failureException(); } if (gladiatorID <= 0) { throw badLevelException(); } Gladiator* to_update = main_squad->findGladiator(gladiatorID); try { /* * We need to check if there is already a gladiator in the system with the * desired ID - we'll simply try to find it in the main squad, and if * and exception is thrown: then it does not exist (which is good), * otherwise, if no exception is thrown, that means the gladiator already * exists in the system, so we return FAILURE as requested. */ main_squad->findGladiator(upgradedID); return FAILURE; } catch (const failureException &e) { } main_squad->removeGladiator(to_update); to_update->getTrainer()->getSquad()->removeGladiator(to_update); to_update->setID(upgradedID); main_squad->addGladiator(to_update); to_update->getTrainer()->getSquad()->addGladiator(to_update); } catch (const std::bad_alloc &e) { return ALLOCATION_ERROR; } catch (const invalidInputException &e) { return INVALID_INPUT; } catch (const failureException &e) { return FAILURE; } return SUCCESS; } /* * Updates the levels of all the gladiators in the system whose ID is dividable by a given * number. The new levels of the gladiators will be the previous level multiplied by a given factor. * Parameters: * @ stimulantCode: the predicate: the number for which we will find gladiators with ID that divide by this. * @ stimulantFactor: the factor by which we will multiply the levels of the suitable gladiators. * An exception is thrown in the following cases: * - either one of the parameters is non-positive : INVALID INPUT * - allocation error. */ StatusType Colosseum::UpdateLevels(int stimulantCode, int stimulantFactor) { try { if (stimulantCode < 1 || stimulantFactor < 1) { throw invalidInputException(); } if (stimulantFactor == 1) { return SUCCESS; //No gladiators will be changed, even those who fulfil the requirement } countDividableElementsFunction divides_by_code(stimulantCode); main_squad->scanAllByLevel(divides_by_code); int m = divides_by_code.getCount(); if (m == 0) { return SUCCESS; //No gladiators fulfil the requirement: return success. } Gladiator **suitable = new Gladiator *[m]; int n = main_squad->getSize(); if (m == n) { toArrayFunction allGladiators(suitable); main_squad->scanAllByLevel(allGladiators); for (int i = 0; i < m; i++) { suitable[i]->increaseLevel( suitable[i]->getLevel() * (stimulantFactor - 1)); } delete[] suitable; return SUCCESS; //All gladiators fulfil the requirement and have been updated. Original order is intact. Return success. } Gladiator **not_suitable = new Gladiator *[n - m]; twoArrayPredicateFunction scan_suitable(suitable, not_suitable, stimulantCode); main_squad->scanAllByLevel(scan_suitable); for (int i = 0; i < m; i++) { suitable[i]->increaseLevel( suitable[i]->getLevel() * (stimulantFactor - 1)); } Gladiator **sorted_gladiators = new Gladiator *[n]; merge_gladiators(suitable, m, not_suitable, n - m, sorted_gladiators); /* * The sorted array has been created. This array stores the values of all the * gladiators in the system AFTER the changes apply to them, sorted by level(smallest to biggest) * and then by ID(biggest to smallest). Since we've changed the fields of the gladiators directly * through the pointers stored in the array - ALL of the trees in the system that are sorted with * levels as keys are not BSTs anymore, and have to be destroyed. */ delete[] suitable; delete[] not_suitable; main_squad->destroyLevelTree(); destroyTrainersLevelTreeFunction remove_illegal_trees; trainers->inOrder(remove_illegal_trees); // All the level trees in the system have been destroyed. We'll restore them (in O(n)!!!) Squad *system_squad = main_squad; Squad *trainer_squad = NULL; for (int i = 0; i < n; i++) { trainer_squad = sorted_gladiators[i]->getTrainer()->getSquad(); system_squad->concatGladiator(sorted_gladiators[i]); trainer_squad->concatGladiator(sorted_gladiators[i]); } delete[] sorted_gladiators; system_squad->updateMax(); updateLevelsTrainers update; trainers->inOrder(update); } catch (const std::bad_alloc &e) { return ALLOCATION_ERROR; } catch (const invalidInputException &e) { return INVALID_INPUT; } catch (const failureException &e) { return FAILURE; } return SUCCESS; }
8aaa6d0e3ac815ad08db5a8ff5ebb22851ad56e4
bc1e0e56cd6cc337d4d60a1040d87c8634e4f99e
/src/map/sector-spatial-utils.hpp
ee1321a0b5310282e529eddbb96b8c3fd34d344b
[]
no_license
spacekitcat/isometric-sdl-demo
dfbda7e1806417fa7c85d030ca62939b9eaf4b10
a1e3aefb0f6dd145e4804319660bdef73a4bfc98
refs/heads/main
2023-08-13T22:35:41.421884
2021-10-09T16:41:16
2021-10-09T16:41:16
380,589,963
1
0
null
null
null
null
UTF-8
C++
false
false
528
hpp
sector-spatial-utils.hpp
#pragma once #include <boost/format.hpp> #include <iostream> #include <list> class SectorSpatialUtils { private: public: SectorSpatialUtils(); ~SectorSpatialUtils(); std::string fromIntegerPairToKey(std::pair<int, int> integerPair); std::pair<int, int> fromKeyToIntegerPair(std::string key); std::list<std::pair<int, int>> getNeighbours(std::pair<int, int> integerPair); std::list<std::pair<int, int>> getNeighbours(std::pair<int, int> integerPair, int radius); };
859974a2d6635c64e9269f12b3ad2b548b00371d
6b427f20bdf695b426257630e57d23a671458b0c
/DynamicMemoryC/DynamicMemoryC/Source.cpp
a07b5d78c7d051c58bbdfa0513de9b59ca1d65af
[]
no_license
Maxai2/DynamicMemoryC
a640836d4c541b7891cecadb65a2ae2953845dec
49a336df40000fdd78c77d88adc0eec887e67893
refs/heads/master
2021-01-23T01:17:43.861972
2017-05-30T19:26:39
2017-05-30T19:26:39
92,863,727
0
0
null
null
null
null
UTF-8
C++
false
false
8,583
cpp
Source.cpp
//#include <iostream> //#include <windows.h> //#include <math.h> //#include <conio.h> //#include "Functions.h" // //using namespace std; // //HANDLE w = GetStdHandle(STD_OUTPUT_HANDLE); // // //int main() //{ /*1. Написать функцию, которая получает указатель на мас- сив и его размер, и возвращает сумму и произведение его элементов в двух параметрах-ссылках.*/ //int size, sum = 0; //long mult = 1; //cout << "Input the size of array: "; //cin >> size; //int *arr = (int*)calloc(size, sizeof(int)); //cout << "\nArray: "; //initialShowArr(arr, size); //sumMult(arr, size, sum, mult); //cout << "\nThe sum of array: " << sum << ", the mult of array: " << mult << endl; //free(arr); /*2. Написать функцию, которая получает указатель на мас- сив и его размер, и возвращает количество отрицатель- ных, положительных и нулевых элементов массива, ис- пользуя механизм ссылок.*/ //int size, neg = 0, zero = 0, pos = 0; //cout << "Input the size of array: "; //cin >> size; //int *arr = (int*)calloc(size, sizeof(int)); //cout << "\nArray: "; //initialShowArr(arr, size); //sort(arr, size, neg, zero, pos); //cout << "\nThe count of neg: " << neg << ", the count of zero: " << zero << ", the count of pos: " << pos << endl; //free(arr); /*3. Написать функцию, которая получает указатель на дву- мерный массив и его размер, и возвращает среднее арифметическое элементов массива, а также количество чѐтных и нечѐтных элементов, используя механизм ссы- лок.*/ //int fSize, sSize, avarage = 0, even = 0, odd = 0; //cout << "Input the first size of array: "; //cin >> fSize; //cout << "Input the second size of array: "; //cin >> sSize; //int **arr = (int**)calloc(fSize, sizeof(int)); //for (int i = 0; i < fSize; i++) // arr[i] = (int*)calloc(sSize, sizeof(int)); //cout << "\nArray: "; //initialArrTwoShow(arr, fSize, sSize); //avarageEvenOdd(arr, fSize, sSize, avarage, even, odd); //cout << "\n\nThe avarage is: " << avarage; //cout << "\nThe count of even number is: " << even; //cout << "\nThe count of odd number is: " << odd << endl; //free(arr); //} //------------------------------------------------------------------------------------------- //4 example //------------------------------------------------------------------------------------------- //#include <iostream> //#include <windows.h> //#include <math.h> //#include <conio.h> //#include "Functions.h" // //using namespace std; // //HANDLE w = GetStdHandle(STD_OUTPUT_HANDLE); // //int main() //{ //4. Написать следующие функции для работы с динамиче- //ским массивом: //a. функция распределения динамической памяти //b. функция инициализации динамического массива //c. функция печати динамического массива //d. функцию удаления динамического массива //e. функцию добавления элемента в конец массива //f. функцию вставки элемента по указанному индексу //g. функцию удаления элемента по указанному индексу // cout << "Input the size of array elements: "; // int size; // cin >> size; // int *arr = (int*)calloc(size, sizeof(int)); // // cout << "\nInput the avarage"; // cout << "\nMin number: "; // int min; // cin >> min; // cout << "Max number: "; // int max; // cin >> max; // cout << endl; // fillingArr(arr, size, min, max); // show(arr, size); // // cout << "\n\nInput number for add to the end: "; // int num; // cin >> num; // addAndInsertToEnd(arr, size, num); // show(arr, size); // // cout << "\n\nInput number for add: "; // cin >> num; // cout << "\nInput link of array: "; // int lnk; // cin >> lnk; // addElementByTheLink(arr, size, num, --lnk); // show(arr, size); // // cout << "\n\nInput link of array which is delete: "; // cin >> lnk; // removeElementByTheLink(arr, size, --lnk); // show(arr, size); // cout << endl; // deleteFunc(arr); //} //------------------------------------------------------------------------------------------- //4 example with menu //------------------------------------------------------------------------------------------- #include <iostream> #include <windows.h> #include <math.h> #include <conio.h> #include "Functions.h" using namespace std; HANDLE w = GetStdHandle(STD_OUTPUT_HANDLE); int main() { //4. Написать следующие функции для работы с динамиче- //ским массивом: //a. функция распределения динамической памяти //b. функция инициализации динамического массива //c. функция печати динамического массива //d. функцию удаления динамического массива //e. функцию добавления элемента в конец массива //f. функцию вставки элемента по указанному индексу //g. функцию удаления элемента по указанному индексу while (true) { system("cls"); SetConsoleTextAttribute(w, 7); static int conti = 1; char ans; if (conti != 1) { cout << "One more?(y/n): "; cin >> ans; if (ans == 'n') { cout << "\n\nThe end!\n"; break; } } system("cls"); cout << "Input the size of array elements: "; int size; cin >> size; int *arr = (int*)calloc(size, sizeof(int)); cout << "\nInput the avarage"; cout << "\nMin number: "; int min; cin >> min; cout << "Max number: "; int max; cin >> max; cout << endl; fillingArr(arr, size, min, max); show(arr, size); cout << endl; system("pause"); int key = 0, sel = 1, num = 0, lnk = 0; while (true) { system("cls"); SetConsoleTextAttribute(w, 7); show(arr, size); switch (sel) { case 1: SetConsoleTextAttribute(w, 10); cout << "\n\nAdd to the end"; SetConsoleTextAttribute(w, 7); cout << "\nAdd from the middle by link"; cout << "\nDelete element by link"; cout << "\nDelete array"; break; case 2: SetConsoleTextAttribute(w, 7); cout << "\n\nAdd to the end"; SetConsoleTextAttribute(w, 10); cout << "\nAdd from the middle by link"; SetConsoleTextAttribute(w, 7); cout << "\nDelete element by link"; cout << "\nDelete array"; break; case 3: SetConsoleTextAttribute(w, 7); cout << "\n\nAdd to the end"; cout << "\nAdd from the middle by link"; SetConsoleTextAttribute(w, 10); cout << "\nDelete element by link"; SetConsoleTextAttribute(w, 7); cout << "\nDelete array"; break; case 4: SetConsoleTextAttribute(w, 7); cout << "\n\nAdd to the end"; cout << "\nAdd from the middle by link"; cout << "\nDelete element by link"; SetConsoleTextAttribute(w, 10); cout << "\nDelete array"; } key = getch(); if (key == 224) key = getch(); if (key == 72 && sel > 1) // Up sel--; else if (key == 80 && sel < 4) // Down sel++; else if (key == 13 && sel == 1) { system("cls"); SetConsoleTextAttribute(w, 7); show(arr, size); cout << "\n\nInput number for add to the end: "; cin >> num; addAndInsertToEnd(arr, size, num); } else if (key == 13 && sel == 2) { system("cls"); SetConsoleTextAttribute(w, 7); show(arr, size); cout << "\n\nInput number for add: "; cin >> num; cout << "\nInput link of array: "; cin >> lnk; addElementByTheLink(arr, size, num, --lnk); } else if (key == 13 && sel == 3) { system("cls"); SetConsoleTextAttribute(w, 7); show(arr, size); cout << "\n\nInput link of array which is delete: "; cin >> lnk; removeElementByTheLink(arr, size, --lnk); show(arr, size); cout << endl; } else if (key == 13 && sel == 4) { deleteArr(arr); break; } } conti++; } }
9457bc712fdd29f3562cb298eb7bff961c15da64
c042e48fb15f9f9950dfeb7fbb9c0137d7f8cc16
/Chef and the Wildcard Matching.cpp
954be6cba6ff4937aeb5b82927cc89fae30354ef
[]
no_license
Nirvan-hash/CodeChef
6eb6a0519d05683ec11691116ce654454150ef8d
69ec7e5fce9c4f28082625e5190f75c9ff1b072d
refs/heads/master
2023-06-25T19:58:52.440806
2021-08-01T05:07:35
2021-08-01T05:07:35
300,167,011
0
0
null
2020-10-01T06:12:26
2020-10-01T06:12:25
null
UTF-8
C++
false
false
479
cpp
Chef and the Wildcard Matching.cpp
//CodeChef //Beginner Practice Problem //Chef and the Wildcard Matching [TWOSTR] #include <bits/stdc++.h> using namespace std; int main() { unsigned long long t=0; cin>>t; while(t--) { string a="",b=""; cin>>a>>b; bool tf=true; for(unsigned long long i=0;i<a.length();i++) { if(a[i]!=b[i]&&a[i]!='?'&&b[i]!='?') {tf=false; break;} } if(tf==true) {cout<<"Yes\n";} else {cout<<"No\n";} } return 0; }
6841c3c38c6791522d3061fd514b4d7347e51419
7292df51527fdba64e1fde826290608c846ddd8f
/codeforces/Minimizing the String.cpp
9839a1cd912378480ef02a15a2619ea8793cec0a
[]
no_license
SatyamJindal/Competitive-Programming
568efc7da4291f38724bb051d2af2d8f7de62e3a
066a2085cb674078a09267f761ddccc5ce910020
refs/heads/master
2021-06-28T06:47:08.709886
2019-06-09T19:20:36
2019-06-09T19:20:36
107,176,715
7
0
null
null
null
null
UTF-8
C++
false
false
267
cpp
Minimizing the String.cpp
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); int n; string s; cin>>n>>s; int pos = n-1; for(int i=0;i<n-1;i++) { if(s[i]>s[i+1]) { pos=i; break; } } cout<<s.substr(0,pos) + s.substr(pos+1)<<"\n"; }
aadb43f472ee7d72c48134fe8aa1939e05c08a28
c5843992e233b92e90b53bd8a90a9e68bfc1f6d6
/code/synthesis/ImagerObjects2/SynthesisImager.cc
82abb8a03d8d2196a48818fd8a206b20805e9ff9
[]
no_license
pkgw/casa
17662807d3f9b5c6b57bf3e36de3b804e202c8d3
0f676fa7b080a9815a0b57567fd4e16cfb69782d
refs/heads/master
2021-09-25T18:06:54.510905
2017-08-16T21:53:54
2017-08-16T21:53:54
100,752,745
2
1
null
2020-02-24T18:50:59
2017-08-18T21:51:10
C++
UTF-8
C++
false
false
49,673
cc
SynthesisImager.cc
//# SynthesisImager.cc: Implementation of Imager.h //# Copyright (C) 1997-2008 //# Associated Universities, Inc. Washington DC, USA. //# //# This program is free software; you can redistribute it and/or modify it //# under the terms of the GNU General Public License as published by the Free //# Software Foundation; either version 2 of the License, or (at your option) //# any later version. //# //# This program is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for //# more details. //# //# You should have received a copy of the GNU General Public License along //# with this program; if not, write to the Free Software Foundation, Inc., //# 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id$ #include <casa/Exceptions/Error.h> #include <casa/iostream.h> #include <casa/sstream.h> #include <casa/Arrays/Matrix.h> #include <casa/Arrays/ArrayMath.h> #include <casa/Arrays/ArrayLogical.h> #include <casa/Logging.h> #include <casa/Logging/LogIO.h> #include <casa/Logging/LogMessage.h> #include <casa/Logging/LogSink.h> #include <casa/Logging/LogMessage.h> #include <casa/System/ProgressMeter.h> #include <casa/OS/DirectoryIterator.h> #include <casa/OS/File.h> #include <casa/OS/HostInfo.h> #include <casa/OS/Path.h> #include <lattices/LRegions/LCBox.h> #include <measures/Measures/MeasTable.h> #include <ms/MeasurementSets/MSHistoryHandler.h> #include <ms/MeasurementSets/MeasurementSet.h> #include <ms/MSSel/MSSelection.h> #include <synthesis/ImagerObjects/SIIterBot.h> #include <synthesis/ImagerObjects/SynthesisUtilMethods.h> #include <synthesis/ImagerObjects/SIImageStore.h> #include <synthesis/ImagerObjects/SIImageStoreMultiTerm.h> #include <synthesis/ImagerObjects2/SynthesisImager.h> #include <synthesis/MeasurementEquations/ImagerMultiMS.h> #include <msvis/MSVis/VisSetUtil.h> #include <msvis/MSVis/VisImagingWeight.h> #include <synthesis/TransformMachines2/GridFT.h> #include <synthesis/TransformMachines2/WPConvFunc.h> #include <synthesis/TransformMachines2/WProjectFT.h> #include <synthesis/TransformMachines2/VisModelData.h> //#include <synthesis/TransformMachines2/AWProjectFT.h> #include <synthesis/TransformMachines2/MultiTermFTNew.h> #include <synthesis/TransformMachines2/AWProjectWBFTNew.h> #include <synthesis/TransformMachines2/AWConvFunc.h> #include <synthesis/TransformMachines2/AWConvFuncEPJones.h> #include <synthesis/TransformMachines2/NoOpATerm.h> #include <synthesis/TransformMachines2/EVLAAperture.h> #include <casadbus/viewer/ViewerProxy.h> #include <casadbus/plotserver/PlotServerProxy.h> //#include <casadbus/utilities/BusAccess.h> //#include <casadbus/session/DBusSession.h> #include <sys/types.h> #include <unistd.h> using namespace std; using namespace casacore; namespace casa { //# NAMESPACE CASA - BEGIN namespace refim {//# namespace refactor imaging using namespace casacore; using namespace casa; using namespace casacore; using namespace casa::refim; using namespace casacore; using namespace casa::vi; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SynthesisImager::SynthesisImager() : itsMappers(SIMapperCollection()), writeAccess_p(true) { imwgt_p=VisImagingWeight("natural"); imageDefined_p=false; useScratch_p=false; readOnly_p=true; mss_p=0; vi_p=0; facetsStore_p=-1; unFacettedImStore_p=NULL; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SynthesisImager::~SynthesisImager() { LogIO os( LogOrigin("SynthesisImager","destructor",WHERE) ); os << LogIO::DEBUG1 << "SynthesisImager destroyed" << LogIO::POST; for (uInt k=0; k < mss_p.nelements(); ++k){ delete mss_p[k]; } // cerr << "IN DESTR"<< endl; // VisModelData::listModel(mss4vi_p[0]); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Bool SynthesisImager::selectData(const String& msname, const String& spw, const String& freqBeg, const String& freqEnd, const MFrequency::Types freqframe, const String& field, const String& antenna, const String& timestr, const String& scan, const String& obs, const String& state, const String& uvdist, const String& taql, const Bool usescratch, const Bool readonly, const Bool incrModel) { SynthesisParamsSelect pars; pars.msname=msname; pars.spw=spw; pars.freqbeg=freqBeg; pars.freqend=freqEnd; pars.freqframe=freqframe; pars.field=field; pars.antenna=antenna; pars.timestr=timestr; pars.scan=scan; pars.obs=obs; pars.state=state; pars.uvdist=uvdist; pars.taql=taql; pars.usescratch=usescratch; pars.readonly=readonly; pars.incrmodel=incrModel; String err = pars.verify(); if( err.length()>0 ) throw(AipsError("Invalid Selection parameters : " + err)); selectData( pars ); return true; } Bool SynthesisImager::selectData(const SynthesisParamsSelect& selpars) { LogIO os( LogOrigin("SynthesisImager","selectData",WHERE) ); try { //Respect the readonly flag...necessary for multi-process access MeasurementSet thisms(selpars.msname, TableLock(TableLock::AutoNoReadLocking), selpars.readonly ? Table::Old : Table::Update); thisms.setMemoryResidentSubtables (MrsEligibility::defaultEligible()); useScratch_p=selpars.usescratch; readOnly_p = selpars.readonly; // cout << "**************** usescr : " << useScratch_p << " readonly : " << readOnly_p << endl; //if you want to use scratch col...make sure they are there if(selpars.usescratch && !selpars.readonly){ VisSetUtil::addScrCols(thisms, true, false, true, false); VisModelData::clearModel(thisms); } if(!selpars.incrmodel && !selpars.usescratch && !selpars.readonly) VisModelData::clearModel(thisms, selpars.field, selpars.spw); os << "MS : " << selpars.msname << " | "; //Some MSSelection //If everything is empty (which is valid) it will throw an exception..below //So make sure the main defaults are not empy i.e field and spw MSSelection thisSelection; if(selpars.field != ""){ thisSelection.setFieldExpr(selpars.field); os << "Selecting on fields : " << selpars.field << " | " ;//LogIO::POST; }else thisSelection.setFieldExpr("*"); if(selpars.spw != ""){ thisSelection.setSpwExpr(selpars.spw); os << "Selecting on spw :"<< selpars.spw << " | " ;//LogIO::POST; }else thisSelection.setSpwExpr("*"); if(selpars.antenna != ""){ Vector<String> antNames(1, selpars.antenna); // thisSelection.setAntennaExpr(MSSelection::nameExprStr( antNames)); thisSelection.setAntennaExpr(selpars.antenna); os << "Selecting on antenna names : " << selpars.antenna << " | " ;//LogIO::POST; } if(selpars.timestr != ""){ thisSelection.setTimeExpr(selpars.timestr); os << "Selecting on time range : " << selpars.timestr << " | " ;//LogIO::POST; } if(selpars.uvdist != ""){ thisSelection.setUvDistExpr(selpars.uvdist); os << "Selecting on uvdist : " << selpars.uvdist << " | " ;//LogIO::POST; } if(selpars.scan != ""){ thisSelection.setScanExpr(selpars.scan); os << "Selecting on scan : " << selpars.scan << " | " ;//LogIO::POST; } if(selpars.obs != ""){ thisSelection.setObservationExpr(selpars.obs); os << "Selecting on Observation Expr : " << selpars.obs << " | " ;//LogIO::POST; } if(selpars.state != ""){ thisSelection.setStateExpr(selpars.state); os << "Selecting on Scan Intent/State : " << selpars.state << " | " ;//LogIO::POST; } if(selpars.taql != ""){ thisSelection.setTaQLExpr(selpars.taql); os << "Selecting via TaQL : " << selpars.taql << " | " ;//LogIO::POST; } os << "[Opened " << (readOnly_p?"in readonly mode":(useScratch_p?"with scratch model column":"with virtual model column")) << "]" << LogIO::POST; TableExprNode exprNode=thisSelection.toTableExprNode(&thisms); if(!(exprNode.isNull())) { mss_p.resize(mss_p.nelements()+1, false, true); mss_p[mss_p.nelements()-1]=new const MeasurementSet(thisms(exprNode)); os << " NRows selected : " << (mss_p[mss_p.nelements()-1])->nrow() << LogIO::POST; } else{ throw(AipsError("Selection for given MS "+selpars.msname+" is invalid")); } //We should do the select channel here for the VI construction later //Need a cross check between channel selection and ms // replace below if/when viFrquencySelectionUsingChannels takes in a MSSelection // rather than the following gymnastics { Matrix<Int> chanlist = thisSelection.getChanList(mss_p[mss_p.nelements()-1]); IPosition shape = chanlist.shape(); uInt nSelections = shape[0]; Int spw,chanStart,chanEnd,chanStep,nchan; if(selpars.freqbeg==""){ vi::FrequencySelectionUsingChannels channelSelector; //////////This is not implemented //channelSelector.add(thisSelection); fselections_p.add(channelSelector); } else{ Quantity freq; Quantity::read(freq, selpars.freqbeg); Double lowfreq=freq.getValue("Hz"); Quantity::read(freq, selpars.freqend); Double topfreq=freq.getValue("Hz"); vi::FrequencySelectionUsingFrame channelSelector(selpars.freqframe); for(uInt k=0; k < nSelections; ++k) channelSelector.add(chanlist(k,0), lowfreq, topfreq); fselections_p.add(channelSelector); } } writeAccess_p=writeAccess_p && !selpars.readonly; createVisSet(writeAccess_p); /////// Remove this when the new vi/vb is able to get the full freq range. //// Set the data column on which to operate // cout << "Using col : " << selpars.datacolumn << endl; if( selpars.datacolumn.contains("data") || selpars.datacolumn.contains("obs") ) {datacol_p = refim::FTMachine::OBSERVED; } else if( selpars.datacolumn.contains("corr") ) {datacol_p = refim::FTMachine::CORRECTED; } else { os << LogIO::WARN << "Invalid data column : " << datacol_p << ". Using corrected (or observed if corrected doesn't exist)" << LogIO::POST; datacol_p = refim::FTMachine::CORRECTED; } } catch(AipsError &x) { throw( AipsError("Error in selectData() : "+x.getMesg()) ); } return true; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Bool SynthesisImager::defineImage(const String& imagename, const Int nx, const Int ny, const Quantity& cellx, const Quantity& celly, const String& stokes, const MDirection& phaseCenter, const Int nchan, const Quantity&freqStart, const Quantity& freqStep, const Vector<Quantity>& restFreq, const Int facets, const String ftmachine, const Int nTaylorTerms, const Quantity& refFreq, const Projection& projection, const Quantity& distance, const MFrequency::Types& freqFrame, const Bool trackSource, const MDirection& trackDir, const Bool overwrite, const Float padding, const Bool useAutocorr, const Bool useDoublePrec, const Int wprojplanes, const String convFunc, const String startmodel, // The extra params for WB-AWP const Bool aTermOn,// = true, const Bool psTermOn,// = true, const Bool mTermOn,// = false, const Bool wbAWP,// = true, const String cfCache,// = "", const Bool doPointing,// = false, const Bool doPBCorr,// = true, const Bool conjBeams,// = true, const Float computePAStep, //=360.0 const Float rotatePAStep //=5.0 ) { String err(""); SynthesisParamsImage impars; impars.imageName=imagename; Vector<Int> ims(2);ims[0]=nx; ims[1]=ny; impars.imsize=ims; Vector<Quantity> cells(2); cells[0]=cellx, cells[1]=celly; impars.cellsize=cells; impars.stokes=stokes; impars.phaseCenter=phaseCenter; impars.nchan=nchan; impars.freqStart=freqStart; impars.freqStep=freqStep; impars.restFreq=restFreq; impars.nTaylorTerms=nTaylorTerms; impars.refFreq=refFreq; impars.projection=projection; impars.freqFrame=freqFrame; impars.overwrite=overwrite; impars.startModel=startmodel; err += impars.verify(); SynthesisParamsGrid gridpars; gridpars.ftmachine=ftmachine; gridpars.distance=distance; gridpars.trackSource=trackSource; gridpars.trackDir=trackDir; gridpars.padding=padding; gridpars.facets=facets; gridpars.useAutoCorr=useAutocorr; gridpars.useDoublePrec=useDoublePrec; gridpars.wprojplanes=wprojplanes; gridpars.convFunc=convFunc; gridpars.aTermOn=aTermOn; gridpars.psTermOn=psTermOn; gridpars.mTermOn=mTermOn; gridpars.wbAWP=wbAWP; gridpars.cfCache=cfCache; gridpars.doPointing=doPointing; gridpars.doPBCorr=doPBCorr; gridpars.conjBeams=conjBeams; gridpars.computePAStep=computePAStep; gridpars.rotatePAStep=rotatePAStep; err += gridpars.verify(); if( err.length()>0 ) throw(AipsError("Invalid Image/Gridding parameters : " + err)); defineImage( impars, gridpars ); return true; } Bool SynthesisImager::defineImage(SynthesisParamsImage& impars, const SynthesisParamsGrid& gridpars) { LogIO os( LogOrigin("SynthesisImager","defineImage",WHERE) ); if(mss_p.nelements() ==0) os << "SelectData has to be run before defineImage" << LogIO::EXCEPTION; CoordinateSystem csys; CountedPtr<refim::FTMachine> ftm, iftm; try { os << "Define image [" << impars.imageName << "]" << LogIO::POST; csys = impars.buildCoordinateSystem( vi_p ); IPosition imshape = impars.shp(); if( (itsMappers.nMappers()==0) || (impars.imsize[0]*impars.imsize[1] > itsMaxShape[0]*itsMaxShape[1])) { itsMaxShape=imshape; itsMaxCoordSys=csys; } /* os << "Define image [" << impars.imageName << "] : nchan : " << impars.nchan //<< ", freqstart:" << impars.freqStart.getValue() << impars.freqStart.getUnit() << ", start:" << impars.start << ", imsize:" << impars.imsize << ", cellsize: [" << impars.cellsize[0].getValue() << impars.cellsize[0].getUnit() << " , " << impars.cellsize[1].getValue() << impars.cellsize[1].getUnit() << LogIO::POST; */ } catch(AipsError &x) { os << "Error in building Coordinate System and Image Shape : " << x.getMesg() << LogIO::EXCEPTION; } try { createFTMachine(ftm, iftm, gridpars.ftmachine, impars.nTaylorTerms, gridpars.mType, gridpars.facets, gridpars.wprojplanes, gridpars.padding,gridpars.useAutoCorr,gridpars.useDoublePrec, gridpars.convFunc, gridpars.aTermOn,gridpars.psTermOn, gridpars.mTermOn, gridpars.wbAWP,gridpars.cfCache,gridpars.doPointing, gridpars.doPBCorr,gridpars.conjBeams, gridpars.computePAStep,gridpars.rotatePAStep, gridpars.interpolation, impars.freqFrameValid); } catch(AipsError &x) { os << "Error in setting up FTMachine() : " << x.getMesg() << LogIO::EXCEPTION; } try { appendToMapperList(impars.imageName, csys, impars.shp(), ftm, iftm, gridpars.distance, gridpars.facets, impars.overwrite, gridpars.mType, impars.nTaylorTerms); imageDefined_p=true; } catch(AipsError &x) { os << "Error in adding Mapper : "+x.getMesg() << LogIO::EXCEPTION; } // Set the model image for prediction -- Call an SIImageStore function that does the REGRIDDING. /* if( startmodel.length()>0 && !itsCurrentImages.null() ) { os << "Setting " << startmodel << " as starting model for prediction " << LogIO::POST; itsCurrentImages->setModelImage( startmodel ); } */ return true; } Bool SynthesisImager::defineImage(CountedPtr<SIImageStore> imstor, const String& ftmachine) { CountedPtr<refim::FTMachine> ftm, iftm; // The following call to createFTMachine() uses the // following defaults // // facets=1, wprojplane=1, padding=1.0, useAutocorr=false, // useDoublePrec=true, gridFunction=String("SF") // createFTMachine(ftm, iftm, ftmachine); Int id=itsMappers.nMappers(); CoordinateSystem csys =imstor->residual()->coordinates(); IPosition imshape=imstor->residual()->shape(); Int nx=imshape[0], ny=imshape[1]; if( (id==0) || (nx*ny > itsMaxShape[0]*itsMaxShape[1])) { itsMaxShape=imshape; itsMaxCoordSys=csys; } itsMappers.addMapper( createSIMapper( "default", imstor, ftm, iftm, id ) ); return true; } /////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// void SynthesisImager::setComponentList(const ComponentList& cl, Bool sdgrid){ String cft="SimpleComponentFTMachine"; if(sdgrid) cft="SimpCompGridFTMachine"; CountedPtr<SIMapper> sm=new SIMapper(cl, cft); itsMappers.addMapper(sm); ////itsMappers.addMapper( createSIMapper( mappertype, imstor, ftm, iftm, id) ); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////Reset the Mapper //////////////////// void SynthesisImager::resetMappers(){ ////reset code itsMappers=SIMapperCollection(); unFacettedImStore_p=NULL; } ////////////////////////////////////////////////////////////////// ///////////////////////////////////////////// CountedPtr<SIImageStore> SynthesisImager::imageStore(const Int id) { if(facetsStore_p >1) { if(id==0) { return unFacettedImStore_p; } else { return itsMappers.imageStore(facetsStore_p*facetsStore_p+id-1); } } return itsMappers.imageStore(id); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SynthesisImager::executeMajorCycle(Record& controlRecord) { LogIO os( LogOrigin("SynthesisImager","executeMajorCycle",WHERE) ); Bool lastcycle=false; if( controlRecord.isDefined("lastcycle") ) { controlRecord.get( "lastcycle" , lastcycle ); //cout << "lastcycle : " << lastcycle << endl; } //else {cout << "No lastcycle" << endl;} os << "----------------------------------------------------------- Run "; if (lastcycle) os << "(Last) " ; os << "Major Cycle -------------------------------------" << LogIO::POST; try { runMajorCycle(false, lastcycle); itsMappers.releaseImageLocks(); } catch(AipsError &x) { throw( AipsError("Error in running Major Cycle : "+x.getMesg()) ); } }// end of executeMajorCycle ////////////////////////////////////////////// ///////////////////////////////////////////// void SynthesisImager::makePSF() { LogIO os( LogOrigin("SynthesisImager","makePSF",WHERE) ); os << "----------------------------------------------------------- Make PSF ---------------------------------------------" << LogIO::POST; try { runMajorCycle(true, false); if(facetsStore_p >1) { setPsfFromOneFacet(); } itsMappers.releaseImageLocks(); } catch(AipsError &x) { throw( AipsError("Error in making PSF : "+x.getMesg()) ); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SynthesisImager::predictModel(){ LogIO os( LogOrigin("SynthesisImager","predictModel ",WHERE) ); { vi_p->originChunks(); vi_p->origin(); vi::VisBuffer2* vb=vi_p->getVisBuffer(); itsMappers.initializeDegrid(*vb); for (vi_p->originChunks(); vi_p->moreChunks();vi_p->nextChunk()) { for (vi_p->origin(); vi_p->more();vi_p->next()) { vb->setVisCubeModel(Cube<Complex>(vb->visCubeModel().shape(), Complex(0.0, 0.0))); itsMappers.degrid(*vb, !useScratch_p); if(vi_p->isWritable() && useScratch_p) vi_p->writeVisModel(vb->visCubeModel()); } } itsMappers.finalizeDegrid(*vb); } }// end of predictModel ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// Bool SynthesisImager::weight(const String& type, const String& rmode, const Quantity& noise, const Double robust, const Quantity& fieldofview, const Int npixels, const Bool multiField, const String& filtertype, const Quantity& filterbmaj, const Quantity& filterbmin, const Quantity& filterbpa ) { LogIO os(LogOrigin("SynthesisImager", "weight()", WHERE)); try { //Int nx=itsMaxShape[0]; //Int ny=itsMaxShape[1]; Quantity cellx=Quantity(itsMaxCoordSys.increment()[0], itsMaxCoordSys.worldAxisUnits()[0]); Quantity celly=Quantity(itsMaxCoordSys.increment()[1], itsMaxCoordSys.worldAxisUnits()[1]); os << LogIO::NORMAL // Loglevel INFO << "Set imaging weights : " ; //<< LogIO::POST; if (type=="natural") { os << LogIO::NORMAL // Loglevel INFO << "Natural weighting" << LogIO::POST; imwgt_p=VisImagingWeight("natural"); } else if (type=="radial") { os << "Radial weighting" << LogIO::POST; imwgt_p=VisImagingWeight("radial"); } else{ if(!imageDefined_p) throw(AipsError("Need to define image")); Int nx=itsMaxShape[0]; Int ny=itsMaxShape[1]; Quantity cellx=Quantity(itsMaxCoordSys.increment()[0], itsMaxCoordSys.worldAxisUnits()[0]); Quantity celly=Quantity(itsMaxCoordSys.increment()[1], itsMaxCoordSys.worldAxisUnits()[1]); if(type=="superuniform"){ if(!imageDefined_p) throw(AipsError("Please define image first")); Int actualNpix=npixels; if(actualNpix <=0) actualNpix=3; os << LogIO::NORMAL // Loglevel INFO << "SuperUniform weighting over a square cell spanning [" << -actualNpix << ", " << actualNpix << "] in the uv plane" << LogIO::POST; imwgt_p=VisImagingWeight(*vi_p, rmode, noise, robust, nx, ny, cellx, celly, actualNpix, actualNpix, multiField); } else if ((type=="robust")||(type=="uniform")||(type=="briggs")) { if(!imageDefined_p) throw(AipsError("Please define image first")); Quantity actualFieldOfView(fieldofview); Int actualNPixels(npixels); String wtype; if(type=="briggs") { wtype = "Briggs"; } else { wtype = "Uniform"; } if(actualFieldOfView.get().getValue()==0.0&&actualNPixels==0) { actualNPixels=nx; actualFieldOfView=Quantity(actualNPixels*cellx.get("rad").getValue(), "rad"); os << LogIO::NORMAL // Loglevel INFO << wtype << " weighting: sidelobes will be suppressed over full image" << LogIO::POST; } else if(actualFieldOfView.get().getValue()>0.0&&actualNPixels==0) { actualNPixels=nx; os << LogIO::NORMAL // Loglevel INFO << wtype << " weighting: sidelobes will be suppressed over specified field of view: " << actualFieldOfView.get("arcsec").getValue() << " arcsec" << LogIO::POST; } else if(actualFieldOfView.get().getValue()==0.0&&actualNPixels>0) { actualFieldOfView=Quantity(actualNPixels*cellx.get("rad").getValue(), "rad"); os << LogIO::NORMAL // Loglevel INFO << wtype << " weighting: sidelobes will be suppressed over full image field of view: " << actualFieldOfView.get("arcsec").getValue() << " arcsec" << LogIO::POST; } else { os << LogIO::NORMAL // Loglevel INFO << wtype << " weighting: sidelobes will be suppressed over specified field of view: " << actualFieldOfView.get("arcsec").getValue() << " arcsec" << LogIO::POST; } os << LogIO::DEBUG1 << "Weighting used " << actualNPixels << " uv pixels." << LogIO::POST; Quantity actualCellSize(actualFieldOfView.get("rad").getValue()/actualNPixels, "rad"); // cerr << "rmode " << rmode << " noise " << noise << " robust " << robust << " npixels " << actualNPixels << " cellsize " << actualCellSize << " multifield " << multiField << endl; // Timer timer; //timer.mark(); //Construct imwgt_p with old vi for now if old vi is in use as constructing with vi2 is slower ////This is slower by orders of magnitude as of 2014/06/25 imwgt_p=VisImagingWeight(*vi_p, rmode, noise, robust, actualNPixels, actualNPixels, actualCellSize, actualCellSize, 0, 0, multiField); /* if(rvi_p !=NULL){ imwgt_p=VisImagingWeight(*rvi_p, rmode, noise, robust, actualNPixels, actualNPixels, actualCellSize, actualCellSize, 0, 0, multiField); } else{ ////This is slower by orders of magnitude as of 2014/06/25 imwgt_p=VisImagingWeight(*vi_p, rmode, noise, robust, actualNPixels, actualNPixels, actualCellSize, actualCellSize, 0, 0, multiField); } */ //timer.show("After making visweight "); } else { //this->unlock(); os << LogIO::SEVERE << "Unknown weighting " << type << LogIO::EXCEPTION; return false; } } //// UV-Tapering //cout << "Taper type : " << filtertype << " : " << (filtertype=="gaussian") << endl; if( filtertype == "gaussian" ) { // os << "Setting uv-taper" << LogIO::POST; imwgt_p.setFilter( filtertype, filterbmaj, filterbmin, filterbpa ); } vi_p->useImagingWeight(imwgt_p); return true; } catch(AipsError &x) { throw( AipsError("Error in Weighting : "+x.getMesg()) ); } return true; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// Internal Functions start here. These are not visible to the tool layer. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////// ////////////This should be called at each defineimage CountedPtr<SIImageStore> SynthesisImager::createIMStore(String imageName, CoordinateSystem& cSys, IPosition imShape, const Bool overwrite, String mappertype, uInt ntaylorterms, Quantity distance, uInt facets, Bool useweightimage) { LogIO os( LogOrigin("SynthesisImager","createIMStore",WHERE) ); CountedPtr<SIImageStore> imstor; try { if( mappertype=="default" || mappertype=="imagemosaic" ) { imstor=new SIImageStore(imageName, cSys, imShape, overwrite, (useweightimage || (mappertype=="imagemosaic") )); // imstor=new SIImageStore(imageName, cSys, imShape, facets, overwrite, (useweightimage || (mappertype=="imagemosaic") )); } else if (mappertype == "multiterm" ) // Currently does not support imagemosaic. { //cout << "Making multiterm IS with nterms : " << ntaylorterms << endl; imstor=new SIImageStoreMultiTerm(imageName, cSys, imShape, facets, overwrite, ntaylorterms, useweightimage); } else { throw(AipsError("Internal Error : Invalid mapper type in SynthesisImager::createIMStore")); } // Fill in miscellaneous information needed by FITS ROMSColumns msc(*mss_p[0]); Record info; String objectName=msc.field().name()(msc.fieldId()(0)); String telescop=msc.observation().telescopeName()(0); info.define("OBJECT", objectName); info.define("TELESCOP", telescop); info.define("INSTRUME", telescop); info.define("distance", distance.get("m").getValue()); ////////////// Send misc info into ImageStore. imstor->setImageInfo( info ); // Get polRep from 'msc' here, and send to imstore. StokesImageUtil::PolRep polRep(StokesImageUtil::CIRCULAR); Vector<String> polType=msc.feed().polarizationType()(0); if (polType(0)!="X" && polType(0)!="Y" && polType(0)!="R" && polType(0)!="L") { os << LogIO::WARN << "Unknown stokes types in feed table: [" << polType(0) << ", " << polType(1) << "]" << endl << "Results open to question!" << LogIO::POST; } if (polType(0)=="X" || polType(0)=="Y") { polRep=StokesImageUtil::LINEAR; os << LogIO::DEBUG1 << "Preferred polarization representation is linear" << LogIO::POST; } else { polRep=StokesImageUtil::CIRCULAR; os << LogIO::DEBUG1 << "Preferred polarization representation is circular" << LogIO::POST; } /// end of reading polRep info ///////// Send this info into ImageStore. imstor->setDataPolFrame(polRep); } catch(AipsError &x) { throw(AipsError("Error in createImStore : " + x.getMesg() ) ); } return imstor; } CountedPtr<SIMapper> SynthesisImager::createSIMapper(String mappertype, CountedPtr<SIImageStore> imagestore, CountedPtr<refim::FTMachine> ftmachine, CountedPtr<refim::FTMachine> iftmachine, uInt /*ntaylorterms*/) { LogIO os( LogOrigin("SynthesisImager","createSIMapper",WHERE) ); CountedPtr<SIMapper> localMapper=NULL; try { if( mappertype == "default" || mappertype == "multiterm" ) { localMapper = new SIMapper( imagestore, ftmachine, iftmachine ); } else if( mappertype == "imagemosaic") // || mappertype == "mtimagemosaic" ) { localMapper = new SIMapperImageMosaic( imagestore, ftmachine, iftmachine ); } else { throw(AipsError("Unknown mapper type : " + mappertype)); } } catch(AipsError &x) { throw(AipsError("Error in createSIMapper : " + x.getMesg() ) ); } return localMapper; } Block<CountedPtr<SIImageStore> > SynthesisImager::createFacetImageStoreList( CountedPtr<SIImageStore> imagestore, Int facets) { Block<CountedPtr<SIImageStore> > facetList( facets*facets ); if( facets==1 ) { facetList[0] = imagestore; return facetList; } // Remember, only the FIRST field in each run can have facets. So, check for this. if( ! unFacettedImStore_p.null() ) { throw( AipsError("A facetted image has already been set. Facets are supported only for the main (first) field. Please submit a feature-request if you need multiple facets for outlier fields as well. ") ); } unFacettedImStore_p = imagestore; facetsStore_p = facets; // Note : facets : Number of facets on a side. // Note : facet : index from range(0, facets*facets) for (Int facet=0; facet< facets*facets; ++facet){ facetList[facet] = unFacettedImStore_p->getSubImageStore(facet, facets); } return facetList; } void SynthesisImager::setPsfFromOneFacet() { if( unFacettedImStore_p.null() ){ throw(AipsError("Internal Error in SynthesisImager : Setting PSF on Null unfacettedimage")); } // Copy the PSF from one facet to the center of the full image, to use for the minor cycle // // This code segment will work for single and multi-term // - for single term, the index will always be 0, and SIImageStore's access functions know this. // - for multi-term, the index will be the taylor index and SIImageStoreMultiTerm knows this. { IPosition shape=(unFacettedImStore_p->psf(0))->shape(); IPosition blc(4, 0, 0, 0, 0); IPosition trc=shape-1; for(uInt tix=0; tix<2 * unFacettedImStore_p->getNTaylorTerms() - 1; tix++) { TempImage<Float> onepsf((itsMappers.imageStore(0)->psf(tix))->shape(), (itsMappers.imageStore(0)->psf(tix))->coordinates()); onepsf.copyData(*(itsMappers.imageStore(0)->psf(tix))); //now set the original to 0 as we have a copy of one facet psf (unFacettedImStore_p->psf(tix))->set(0.0); blc[0]=(shape[0]-(onepsf.shape()[0]))/2; trc[0]=onepsf.shape()[0]+blc[0]-1; blc[1]=(shape[1]-(onepsf.shape()[1]))/2; trc[1]=onepsf.shape()[1]+blc[1]-1; Slicer sl(blc, trc, Slicer::endIsLast); SubImage<Float> sub(*(unFacettedImStore_p->psf(tix)), sl, true); sub.copyData(onepsf); } } //cout << "In setPsfFromOneFacet : sumwt : " << unFacettedImStore_p->sumwt()->get() << endl; } void SynthesisImager::appendToMapperList(String imagename, CoordinateSystem& csys, IPosition imshape, CountedPtr<FTMachine>& ftm, CountedPtr<FTMachine>& iftm, Quantity distance, Int facets, const Bool overwrite, String mappertype, uInt ntaylorterms ) { LogIO log_l(LogOrigin("SynthesisImager", "appendToMapperList(ftm)")); //--------------------------------------------- // Some checks.. if(facets > 1 && itsMappers.nMappers() > 0) log_l << "Facetted image has to be first of multifields" << LogIO::EXCEPTION; AlwaysAssert( ( ( ! (ftm->name()=="MosaicFT" && mappertype=="imagemosaic") ) && ( ! (ftm->name()=="AWProjectWBFTNew" && mappertype=="imagemosaic") )) , AipsError ); //--------------------------------------------- // Create the ImageStore object CountedPtr<SIImageStore> imstor; imstor = createIMStore(imagename, csys, imshape, overwrite,mappertype, ntaylorterms, distance,facets, iftm->useWeightImage() ); // Create the Mappers if( facets<2 ) // One facet. Just add the above imagestore to the mapper list. { itsMappers.addMapper( createSIMapper( mappertype, imstor, ftm, iftm, ntaylorterms) ); } else // This field is facetted. Make a list of reference imstores, and add all to the mapper list. { // First, make sure that full images have been allocated before trying to make references..... // if( ! imstor->checkValidity(true/*psf*/, true/*res*/,true/*wgt*/,true/*model*/,false/*image*/,false/*mask*/,true/*sumwt*/ ) ) // { throw(AipsError("Internal Error : Invalid ImageStore for " + imstor->getName())); } // Make and connect the list. Block<CountedPtr<SIImageStore> > imstorList = createFacetImageStoreList( imstor, facets ); for( uInt facet=0; facet<imstorList.nelements(); facet++) { CountedPtr<FTMachine> new_ftm, new_iftm; if(facet==0){ new_ftm = ftm; new_iftm = iftm; } else{ new_ftm=ftm->cloneFTM(); new_iftm=iftm->cloneFTM(); } itsMappers.addMapper(createSIMapper( mappertype, imstorList[facet], new_ftm, new_iftm, ntaylorterms)); } } } ///////////////////////// /* Bool SynthesisImager::toUseWeightImage(CountedPtr<FTMachine>& ftm, String mappertype) { if( (ftm->name() == "GridFT" || ftm->name() == "WProjectFT")&&(mappertype!="imagemosaic") ) { return false; } else { return true; } } */ // Make the FT-Machine and related objects (cfcache, etc.) void SynthesisImager::createFTMachine(CountedPtr<FTMachine>& theFT, CountedPtr<FTMachine>& theIFT, const String& ftname, const uInt nTaylorTerms, const String mType, const Int facets, //=1 //------------------------------ const Int wprojplane, //=1, const Float padding, //=1.0, const Bool useAutocorr, //=false, const Bool useDoublePrec, //=true, const String gridFunction, //=String("SF"), //------------------------------ const Bool aTermOn, //= true, const Bool psTermOn, //= true, const Bool mTermOn, //= false, const Bool wbAWP, //= true, const String cfCache, //= "", const Bool doPointing, //= false, const Bool doPBCorr, //= true, const Bool conjBeams, //= true, const Float computePAStep, //=360.0 const Float rotatePAStep, //=5.0 const String interpolation, //="linear" const Bool freqFrameValid, //=true const Int cache, //=1000000000, const Int tile //=16 ) { LogIO os( LogOrigin("SynthesisImager","createFTMachine",WHERE)); if(ftname=="gridft"){ if(facets >1){ theFT=new refim::GridFT(cache, tile, gridFunction, mLocation_p, phaseCenter_p, padding, useAutocorr, useDoublePrec); theIFT=new refim::GridFT(cache, tile, gridFunction, mLocation_p, phaseCenter_p, padding, useAutocorr, useDoublePrec); } else{ theFT=new refim::GridFT(cache, tile, gridFunction, mLocation_p, padding, useAutocorr, useDoublePrec); theIFT=new refim::GridFT(cache, tile, gridFunction, mLocation_p, padding, useAutocorr, useDoublePrec); } } else if(ftname== "wprojectft"){ theFT=new refim::WProjectFT(wprojplane, mLocation_p, cache/2, tile, useAutocorr, padding, useDoublePrec); theIFT=new refim::WProjectFT(wprojplane, mLocation_p, cache/2, tile, useAutocorr, padding, useDoublePrec); CountedPtr<WPConvFunc> sharedconvFunc= new WPConvFunc(); static_cast<refim::WProjectFT &>(*theFT).setConvFunc(sharedconvFunc); static_cast<refim::WProjectFT &>(*theFT).setConvFunc(sharedconvFunc); } else if ((ftname == "awprojectft") || (ftname== "mawprojectft") || (ftname == "protoft")) { createAWPFTMachine(theFT, theIFT, ftname, facets, wprojplane, padding, useAutocorr, useDoublePrec, gridFunction, aTermOn, psTermOn, mTermOn, wbAWP, cfCache, doPointing, doPBCorr, conjBeams, computePAStep, rotatePAStep, cache,tile); } else { throw( AipsError( "Invalid FTMachine name : " + ftname ) ); } /* else if(ftname== "MosaicFT"){ }*/ ///////// Now, clone and pack the chosen FT into a MultiTermFT if needed. if( mType=="multiterm" ) { AlwaysAssert( nTaylorTerms>=1 , AipsError ); CountedPtr<refim::FTMachine> theMTFT = new refim::MultiTermFTNew( theFT , nTaylorTerms, true/*forward*/ ); CountedPtr<refim::FTMachine> theMTIFT = new refim::MultiTermFTNew( theIFT , nTaylorTerms, false/*forward*/ ); theFT = theMTFT; theIFT = theMTIFT; } ////// Now, set the SkyJones if needed, and if not internally generated. if( mType=="imagemosaic" && (ftname != "awprojectft" && ftname != "mawprojectft" && ftname != "proroft") ) { CountedPtr<SkyJones> vp = NULL; ROMSColumns msc(*mss_p[0]); Quantity parang(0.0,"deg"); Quantity skyposthreshold(0.0,"deg"); vp = new VPSkyJones(msc, true, parang, BeamSquint::NONE,skyposthreshold); Vector<CountedPtr<SkyJones> > skyJonesList(1); skyJonesList(0) = vp; theFT->setSkyJones( skyJonesList ); theIFT->setSkyJones( skyJonesList ); } //// For mode=cubedata, set the freq frame to invalid.. // get this info from buildCoordSystem Vector<Int> tspws(0); //theFT->setSpw( tspws, false ); //theIFT->setSpw( tspws, false ); theFT->setSpw( tspws, freqFrameValid ); theIFT->setSpw( tspws, freqFrameValid ); //// Set interpolation mode theFT->setFreqInterpolation( interpolation ); theIFT->setFreqInterpolation( interpolation ); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SynthesisImager::createAWPFTMachine(CountedPtr<FTMachine>& theFT, CountedPtr<FTMachine>& theIFT, const String& ftmName, const Int,// facets, //=1 //------------------------------ const Int wprojPlane, //=1, const Float,// padding, //=1.0, const Bool,// useAutocorr, //=false, const Bool useDoublePrec, //=true, const String,// gridFunction, //=String("SF"), //------------------------------ const Bool aTermOn, //= true, const Bool psTermOn, //= true, const Bool mTermOn, //= false, const Bool wbAWP, //= true, const String cfCache, //= "", const Bool doPointing, //= false, const Bool doPBCorr, //= true, const Bool conjBeams, //= true, const Float computePAStep, //=360.0 const Float rotatePAStep, //=5.0 const Int cache, //=1000000000, const Int tile //=16 ) { LogIO os( LogOrigin("SynthesisImager2","createAWPFTMachine",WHERE)); if (wprojPlane<=1) { os << LogIO::NORMAL << "You are using wprojplanes=1. Doing co-planar imaging (no w-projection needed)" << LogIO::POST; os << LogIO::NORMAL << "Performing WBA-Projection" << LogIO::POST; // Loglevel PROGRESS } if((wprojPlane>1)&&(wprojPlane<64)) { os << LogIO::WARN << "No. of w-planes set too low for W projection - recommend at least 128" << LogIO::POST; os << LogIO::NORMAL << "Performing WBAW-Projection" << LogIO::POST; // Loglevel PROGRESS } CountedPtr<refim::ATerm> apertureFunction = createTelescopeATerm(*mss_p[0], aTermOn); CountedPtr<refim::PSTerm> psTerm = new refim::PSTerm(); CountedPtr<refim::WTerm> wTerm = new refim::WTerm(); // // Selectively switch off CFTerms. // if (aTermOn == false) {apertureFunction->setOpCode(refim::CFTerms::NOOP);} if (psTermOn == false) psTerm->setOpCode(refim::CFTerms::NOOP); // // Construct the CF object with appropriate CFTerms. // CountedPtr<refim::ConvolutionFunction> awConvFunc; // awConvFunc = new AWConvFunc(apertureFunction,psTerm,wTerm, !wbAWP); if ((ftmName=="mawprojectft") || (mTermOn)) awConvFunc = new refim::AWConvFuncEPJones(apertureFunction,psTerm,wTerm,wbAWP); else awConvFunc = new refim::AWConvFunc(apertureFunction,psTerm,wTerm,wbAWP); // // Construct the appropriate re-sampler. // CountedPtr<refim::VisibilityResamplerBase> visResampler; // if (ftmName=="protoft") visResampler = new ProtoVR(); //elsef visResampler = new refim::AWVisResampler(); // CountedPtr<VisibilityResamplerBase> visResampler = new VisibilityResampler(); // // Construct and initialize the CF cache object. // CountedPtr<refim::CFCache> cfCacheObj = new refim::CFCache(); cfCacheObj->setCacheDir(cfCache.data()); cfCacheObj->initCache2(); // // Finally construct the FTMachine with the CFCache, ConvFunc and // Re-sampler objects. // Float pbLimit_l=1e-3; theFT = new refim::AWProjectWBFTNew(wprojPlane, cache/2, cfCacheObj, awConvFunc, visResampler, /*true */doPointing, doPBCorr, tile, computePAStep, pbLimit_l, true,conjBeams, useDoublePrec); Quantity rotateOTF(rotatePAStep,"deg"); static_cast<refim::AWProjectWBFTNew &>(*theFT).setObservatoryLocation(mLocation_p); static_cast<refim::AWProjectWBFTNew &>(*theFT).setPAIncrement(Quantity(computePAStep,"deg"),rotateOTF); // theIFT = new AWProjectWBFT(wprojPlane, cache/2, // cfCacheObj, awConvFunc, // visResampler, // /*true */doPointing, doPBCorr, // tile, computePAStep, pbLimit_l, true,conjBeams, // useDoublePrec); // static_cast<AWProjectWBFT &>(*theIFT).setObservatoryLocation(mLocation_p); // static_cast<AWProjectWBFT &>(*theIFT).setPAIncrement(Quantity(computePAStep,"deg"),rotateOTF); theIFT = new refim::AWProjectWBFTNew(static_cast<refim::AWProjectWBFTNew &>(*theFT)); //// Send in Freq info. // vi_p->getFreqInSpwRange( os << "DO SOMETHING HERE for vi2/vb2 : Sending frequency selection information " << mssFreqSel_p << " to AWP FTM." << LogIO::POST; theFT->setSpwFreqSelection( mssFreqSel_p ); theIFT->setSpwFreqSelection( mssFreqSel_p ); } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// refim::ATerm* SynthesisImager::createTelescopeATerm(const MeasurementSet& ms, const Bool& isATermOn) { LogIO os(LogOrigin("SynthesisImager", "createTelescopeATerm",WHERE)); if (!isATermOn) return new refim::NoOpATerm(); ROMSObservationColumns msoc(ms.observation()); String ObsName=msoc.telescopeName()(0); if ((ObsName == "EVLA") || (ObsName == "VLA")) return new refim::EVLAAperture(); else { os << "Telescope name ('"+ ObsName+"') in the MS not recognized to create the telescope specific ATerm" << LogIO::WARN; } return NULL; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Do MS-Selection and set up vi/vb. // Only this functions needs to know anything about the MS void SynthesisImager::createVisSet(const Bool writeAccess) { LogIO os( LogOrigin("SynthesisImager","createVisSet",WHERE) ); if(mss_p.nelements() != uInt(fselections_p.size()) && (fselections_p.size() !=0)){ throw(AipsError("Discrepancy between Number of MSs and Frequency selections")); } vi_p=new vi::VisibilityIterator2(mss_p, vi::SortColumns(), writeAccess); if(fselections_p.size() !=0) vi_p->setFrequencySelection (fselections_p); //return *vi_p; }// end of createVisSet ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void SynthesisImager::runMajorCycle(const Bool dopsf, const Bool savemodel) { LogIO os( LogOrigin("SynthesisImager","runMajorCycle",WHERE) ); // cout << "Savemodel : " << savemodel << " readonly : " << readOnly_p << " usescratch : " << useScratch_p << endl; Bool savemodelcolumn = savemodel && !readOnly_p && useScratch_p; Bool savevirtualmodel = savemodel && !readOnly_p && !useScratch_p; if( savemodelcolumn ) os << "Saving model column" << LogIO::POST; if( savevirtualmodel ) os << "Saving virtual model" << LogIO::POST; itsMappers.checkOverlappingModels("blank"); { vi_p->originChunks(); vi_p->origin(); vi::VisBuffer2* vb=vi_p->getVisBuffer(); if(!dopsf) itsMappers.initializeDegrid(*vb); itsMappers.initializeGrid(*vb,dopsf); for (vi_p->originChunks(); vi_p->moreChunks();vi_p->nextChunk()) { for (vi_p->origin(); vi_p->more();vi_p->next()) { if(!dopsf){ vb->setVisCubeModel(Cube<Complex>(vb->visCubeModel().shape(), Complex(0.0, 0.0))); itsMappers.degrid(*vb, savevirtualmodel ); if( savemodelcolumn && vi_p->isWritable()) vi_p->writeVisModel(vb->visCubeModel()); } itsMappers.grid(*vb, dopsf, datacol_p); } } if(!dopsf) itsMappers.finalizeDegrid(*vb); itsMappers.finalizeGrid(*vb, dopsf); } itsMappers.checkOverlappingModels("restore"); }// end runMajorCycle ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }//# NAMESPACE refim - END } //# NAMESPACE CASA - END
840c5fe5e7fdee5953058fe4584fc9d1520819b4
5808a088f926ac899dc493f7031cdd66c794a97d
/src/ui/StatusOverlay.cpp
e3cb9929f83fb249acedb22aecc3069ace590164
[]
no_license
ViteFalcon/ecstest
5070f5c748dd4efe58ec7c5a737a1336941cd3b3
23faafbb46945848d0768d765f7b4d741bba2792
refs/heads/master
2020-04-19T02:53:42.379355
2019-02-02T21:42:39
2019-02-02T21:42:39
167,917,956
3
0
null
null
null
null
UTF-8
C++
false
false
3,628
cpp
StatusOverlay.cpp
/* ------------------------------------------------------------------------------------------------------------------------ Copyright 2019 Vite Falcon 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 "StatusOverlay.h" #include <sstream> #include <string> #include <Urho3D/Core/CoreEvents.h> #include <Urho3D/Math/Color.h> #include <Urho3D/Resource/ResourceCache.h> #include <Urho3D/UI/Font.h> #include <Urho3D/UI/Text.h> #include <Urho3D/UI/UI.h> #define STATUS_OVERLAY_FIRST_LINE \ "Keys: tab = toggle mouse, AWSD = move camera, Shift = fast mode, Esc = " \ "quit, Space = EXPLOSIONS!\n" StatusOverlay::StatusOverlay(Urho3D::Context *context) : GameUI(context), mFrameCount(0), mTime(0.0f) { Urho3D::ResourceCache *cache = GetSubsystem<Urho3D::ResourceCache>(); Urho3D::Text *text = new Urho3D::Text(context); // Text will be updated later in the E_UPDATE handler. Keep readin'. text->SetText(STATUS_OVERLAY_FIRST_LINE "Wait a bit to see FPS."); // If the engine cannot find the font, it comes with Urho3D. // Set the environment variables URHO3D_HOME, URHO3D_PREFIX_PATH or // change the engine parameter "ResourcePrefixPath" in the Setup method. text->SetFont(cache->GetResource<Urho3D::Font>("Fonts/Anonymous Pro.ttf"), 18); text->SetColor(Urho3D::Color(.3, 0, .3)); text->SetHorizontalAlignment(Urho3D::HA_CENTER); text->SetVerticalAlignment(Urho3D::VA_TOP); setNamedElement("text", text, true); SubscribeToEvent(Urho3D::E_UPDATE, URHO3D_HANDLER(StatusOverlay, HandleUpdate)); } void StatusOverlay::HandleUpdate(Urho3D::StringHash eventType, Urho3D::VariantMap &eventData) { float timeStep = eventData[Urho3D::Update::P_TIMESTEP].GetFloat(); mFrameCount++; mTime += timeStep; if (mTime < 1) { return; } std::string str; str.append(STATUS_OVERLAY_FIRST_LINE); { std::ostringstream ss; ss << mFrameCount; std::string s(ss.str()); str.append(s.substr(0, 6)); } str.append(" frames in "); { std::ostringstream ss; ss << mTime; std::string s(ss.str()); str.append(s.substr(0, 6)); } str.append(" seconds = "); { std::ostringstream ss; ss << (float)mFrameCount / mTime; std::string s(ss.str()); str.append(s.substr(0, 6)); } str.append(" fps"); Urho3D::String s(str.c_str(), str.size()); getNamedElement<Urho3D::Text>("text")->SetText(s); mFrameCount = 0; mTime = 0; }
e02eb2bf8eebe11c56e446befbebe10231b51fef
746f18b2ddcabfa296c368119a3682e8a196891f
/BattleTank/Source/BattleTank/Public/TankAimingComponent.h
f95bafe7a157121979fabe156b22dca54c326609
[]
no_license
JeffersonH44/BattleTank
e9b32f763d84b19efcdff1b24feccf67432774c5
530eab8c19478910a4fda83f82bb1c36185457bf
refs/heads/master
2020-03-25T15:37:36.787251
2018-09-04T14:41:18
2018-09-04T14:41:18
143,893,125
0
0
null
null
null
null
UTF-8
C++
false
false
1,897
h
TankAimingComponent.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #include "Runtime/Engine/Classes/Kismet/GameplayStatics.h" #include "Components/StaticMeshComponent.h" #include "TankAimingComponent.generated.h" /// Forward declaration (useful for circular dependencies) class UTankBarrel; class UTankTurret; class AProjectile; // Enum for firing status UENUM() enum class EFiringState : uint8 { Reloading, Aiming, Locked }; /** * Responsible for helping the player to aim */ UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) class BATTLETANK_API UTankAimingComponent : public UActorComponent { GENERATED_BODY() public: // Sets default values for this component's properties UTankAimingComponent(); void AimAt(FVector WorldSpaceAim); UFUNCTION(BlueprintCallable, Category = "Setup") void Initialize(UTankBarrel* Barrel, UTankTurret* Turret); UFUNCTION(BlueprintCallable, Category = "Firing") void Fire(); // BlueprinReadWrite is necessary because of the hot reloading error on UE 4.20 UPROPERTY(BlueprintReadWrite, Category = "Setup") TSubclassOf<AProjectile> ProjectileBlueprint; EFiringState GetFiringState() const; protected: UPROPERTY(BlueprintReadOnly, Category = "State") EFiringState FiringState = EFiringState::Reloading; private: virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override; virtual void BeginPlay() override; void MoveBarrelTowards(FVector AimDirection); bool IsBarrelMoving(); UPROPERTY(EditDefaultsOnly, Category = "Firing") float LaunchSpeed = 23000; UPROPERTY(EditDefaultsOnly, Category = "Firing") float ReloadTimeInSeconds = 3.0; UTankBarrel* Barrel = nullptr; UTankTurret* Turret = nullptr; FVector AimDirection; double LastFireTime = 0.0; };
10929261123b6cfafe3ae4f9eb654cdab2524dda
6c53668c25fe0019a682e370e3596ba659f6d5af
/src/MainApp.cpp
f9f762c9cb2837aa98806f0a28da4537cc5b08fb
[ "MIT" ]
permissive
wieslawsoltes/BatchEncoderWx
3b3a8291a93797d292aced7ca3dae2872b1a52c1
9249836506a5babfce6964e642971c2cfc944386
refs/heads/master
2021-07-19T05:16:18.189451
2021-07-18T16:00:25
2021-07-18T16:00:25
126,606,266
2
0
null
null
null
null
UTF-8
C++
false
false
2,947
cpp
MainApp.cpp
#include "targetver.h" #include <wx/wxprec.h> #ifndef WX_PRECOMP #include <wx/wx.h> #endif #include <wx/fileconf.h> #include <wx/stdpaths.h> #include "MainApp.h" #include "Headers.h" #include "ui/UIMainFrame.h" wxIMPLEMENT_APP(MainApp); bool MainApp::OnInit() { this->m_Config.FileSystem = std::make_unique<worker::Win32FileSystem>(); this->m_Config.m_Settings.Init(this->m_Config.FileSystem.get()); this->m_Config.Log = std::make_unique<util::FileLog>(this->m_Config.m_Settings.szLogFile); this->m_Config.Log->Open(); std::wstring szConfigMode = this->m_Config.m_Settings.IsPortable(this->m_Config.FileSystem.get()) ? L"Portable" : L"Roaming"; this->m_Config.Log->Log(L"[Info] Program started: " + szConfigMode); this->LoadConfig(); try { wxFileConfig* m_FileConfig = new wxFileConfig( wxT(""), wxT(""), this->m_Config.m_Settings.szSettingsPath + wxT("BatchEncoder.ini")); wxConfigBase::Set(m_FileConfig); auto* frame = new UIMainFrame(nullptr); frame->m_Config = &this->m_Config; frame->InitFrame(); frame->RedrawItems(); frame->Show(true); } catch (...) { this->m_Config.Log->Log(L"[Error] Main frame exception."); } this->m_Config.Log->Log(L"[Info] Program exited: " + szConfigMode); this->m_Config.Log->Close(); return true; } int MainApp::OnExit() { this->SaveConfig(); return wxApp::OnExit(); } void MainApp::LoadConfig() { try { this->m_Config.nLangId = -1; this->m_Config.LoadTools(this->m_Config.m_Settings.szToolsPath); this->m_Config.LoadFormats(this->m_Config.m_Settings.szFormatsPath); if (this->m_Config.LoadOutputs(this->m_Config.m_Settings.szOutputsFile) == false) this->m_Config.m_Outputs = config::m_OutpuPathsPresets; if (this->m_Config.LoadOptions(this->m_Config.m_Settings.szOptionsFile) == false) this->m_Config.m_Options.Defaults(); this->m_Config.LoadItems(this->m_Config.m_Settings.szItemsFile); this->m_Config.LoadLanguages(this->m_Config.m_Settings.szSettingsPath); this->m_Config.LoadLanguages(this->m_Config.m_Settings.szLanguagesPath); } catch (...) { this->m_Config.Log->Log(L"[Error] Failed to load config."); } } void MainApp::SaveConfig() { try { this->m_Config.SaveTools(this->m_Config.m_Settings.szToolsPath); this->m_Config.SaveFormats(this->m_Config.m_Settings.szFormatsPath); this->m_Config.SaveOutputs(this->m_Config.m_Settings.szOutputsFile); this->m_Config.SaveOptions(this->m_Config.m_Settings.szOptionsFile); config::CItem::SetIds(this->m_Config.m_Items); this->m_Config.SaveItems(this->m_Config.m_Settings.szItemsFile); } catch (...) { this->m_Config.Log->Log(L"[Error] Failed to save config."); } }
cd9386a6ab04b11f69ae69603b61f6700f6394ad
719ca866888053c63c4f76207f3792b0a46b5c8a
/Libraries/VortexAnimatSim/VsLinearHillStretchReceptor.cpp
2bcff2b84a2ce43c68b79bfc463f0e08800488e1
[]
no_license
silicondosa/AnimatLabPublicSource
08e71f28c221881bf8527bb95df8cf530c455ca0
c5b23f8898513582afb7891eb994a7bd40a89f08
refs/heads/master
2023-03-20T02:16:00.390767
2016-10-04T18:17:59
2016-10-04T18:17:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,016
cpp
VsLinearHillStretchReceptor.cpp
// VsLinearHillStretchReceptor.cpp: implementation of the VsLinearHillStretchReceptor class. // ////////////////////////////////////////////////////////////////////// #include "StdAfx.h" #include "VsMovableItem.h" #include "VsBody.h" #include "VsJoint.h" #include "VsMotorizedJoint.h" #include "VsRigidBody.h" #include "VsLine.h" #include "VsLinearHillStretchReceptor.h" #include "VsSimulator.h" #include "VsDragger.h" namespace VortexAnimatSim { namespace Environment { namespace Bodies { ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// VsLinearHillStretchReceptor::VsLinearHillStretchReceptor() { SetThisPointers(); } VsLinearHillStretchReceptor::~VsLinearHillStretchReceptor() { try { DeleteGraphics(); DeletePhysics(); } catch(...) {Std_TraceMsg(0, "Caught Error in desctructor of VsLinearHillStretchReceptor\r\n", "", -1, false, true);} } void VsLinearHillStretchReceptor::CreateParts() { //We do nothing in createparts because we cannot build the line until after all parts are created //so we can get a handle to the attachment points. } void VsLinearHillStretchReceptor::CreateJoints() { LinearHillStretchReceptor::CreateJoints(); VsLine::CreateParts(); m_fltIaRate = m_fltIaDischargeConstant*m_fltSeLength; m_fltIbRate = m_fltIbDischargeConstant*m_fltTension; m_fltIIRate = m_fltIIDischargeConstant*m_fltPeLength; } void VsLinearHillStretchReceptor::ResetSimulation() { LinearHillStretchReceptor::ResetSimulation(); VsLine::ResetSimulation(); } void VsLinearHillStretchReceptor::AfterResetSimulation() { LinearHillStretchReceptor::AfterResetSimulation(); VsLine::AfterResetSimulation(); } void VsLinearHillStretchReceptor::StepSimulation() { CalculateTension(); VsLine::StepSimulation(m_fltTension); } } //Bodies } // Environment } //VortexAnimatSim
ba3db7e5e1212d05127d36d7c38a086187cf1908
5ca5e4544c43aa018f3456eb32d88f5f344e2156
/qpfav/swarmedit.cpp
f984b50b3ba57f7202ccde6a116556807b4fb5e0
[]
no_license
jc-gonzalez/qpfav
10124a696419e7aaff6ae2f482a09bb3c4baeb25
e55992d61724aa3c2455f61c603643fc65ff9577
refs/heads/master
2020-04-02T18:04:30.509591
2019-02-13T14:23:47
2019-02-13T14:23:47
154,685,786
0
0
null
null
null
null
UTF-8
C++
false
false
2,481
cpp
swarmedit.cpp
/****************************************************************************** * File: swarmedit.cpp * Implementation of class SwarmEdit * * Domain: QPF.qpfgui.swarmedit * * Version: 2.0 * * Date: 2016-11-03 * * Author: J C Gonzalez * * Copyright (C) 2015-2018 Euclid SOC Team @ ESAC *_____________________________________________________________________________ * * Topic: General Information * * Purpose: * Implementation of class SwarmEdit * * Created by: * J C Gonzalez * * Status: * Prototype * * Dependencies: * none * * Files read / modified: * none * * History: * See <ChangeLog> * * About: License Conditions * See <License> * ******************************************************************************/ #include "swarmedit.h" #include "ui_swarmedit.h" #include <QListWidget> #include <QVBoxLayout> #include <QMessageBox> #include <QFileDialog> #include <QDebug> namespace QPF { SwarmEdit::SwarmEdit(QWidget *parent) : QDialog(parent), ui(new Ui::SwarmEdit) { ui->setupUi(this); } SwarmEdit::~SwarmEdit() { delete ui; } //---------------------------------------------------------------------- // Method: setSwarm // setSwarm //---------------------------------------------------------------------- void SwarmEdit::setSwarm(QString id, QString name, QString ip, QStringList wips, int scale, QString image, QString exe, QString args) { ui->edSwarmId->setText(id); ui->edSrvName->setText(name); ui->edManagerIP->setText(ip); ui->edWorkerIPs->setText(wips.join(" ")); ui->spbxScale->setValue(scale); ui->edImage->setText(image); ui->edExe->setText(exe); ui->edArgs->setText(args); } //---------------------------------------------------------------------- // Method: getSwarm // getSwarm //---------------------------------------------------------------------- void SwarmEdit::getSwarm(QString & id, QString & name, QString & ip, QStringList & wips, int & scale, QString & image, QString & exe, QString & args) { id = ui->edSwarmId->text(); name = ui->edSrvName->text(); ip = ui->edManagerIP->text(); wips = ui->edWorkerIPs->text().split(QRegExp("\\W+"), QString::SkipEmptyParts); scale = ui->spbxScale->value(); image = ui->edImage->text(); exe = ui->edExe->text(); args = ui->edArgs->text(); } }
9655233a3b49ef606343697c510725725b59f8cf
cfc3cbda5d6146e8d9b46644fad2a839ca08580d
/Assignment3/SmartStack.h
44123e6469792e90a96913e8934b40b7f0857c46
[ "MIT" ]
permissive
joonhyukchoi/myc-pocu
bbdd804167f3883ceb0aa7bb818e104473aec467
c191850e4042c17e6c238da1a3eab903d0315aa6
refs/heads/master
2022-09-09T23:41:56.318878
2019-12-01T21:04:12
2019-12-01T21:04:12
207,085,939
0
0
null
null
null
null
UTF-8
C++
false
false
2,886
h
SmartStack.h
#pragma once #include <stack> #include <limits> #include <cmath> namespace assignment3 { template<typename T> class SmartStack { public: SmartStack(); void Push(T num); T Pop(); T Peek() const; T GetMax() const; T GetMin() const; double GetAverage() const; T GetSum() const; double GetVariance() const; double GetStandardDeviation() const; unsigned int GetCount() const; private: std::stack<T> mNum; //std::stack<T> mNum2; std::stack<T> mMax; std::stack<T> mMin; T mSum; double mSum2; unsigned int mCnt; }; template<typename T> SmartStack<T>::SmartStack() : mSum(0) , mSum2(0) , mCnt(0) { } template<typename T> void SmartStack<T>::Push(T num) { //double num2 = num if (!mNum.empty()) { if (num > mMax.top()) { mMax.push(num); } else { mMax.push(mMax.top()); } if (num < mMin.top()) { mMin.push(num); } else { mMin.push(mMin.top()); } mSum += num; mSum2 += static_cast<double>(num) * static_cast<double>(num); } else { mMax.push(num); mMin.push(num); mSum = num; mSum2 = static_cast<double>(num) * static_cast<double>(num); } mNum.push(num); ++mCnt; } template<typename T> T SmartStack<T>::Pop() { T tp = mNum.top(); mSum -= mNum.top(); mSum2 -= static_cast<double>(mNum.top()) * static_cast<double>(mNum.top()); mNum.pop(); mMax.pop(); mMin.pop(); --mCnt; return tp; } template<typename T> T SmartStack<T>::Peek() const { return mNum.top(); } template<typename T> T SmartStack<T>::GetMax() const { if (!mNum.empty()) { return mMax.top(); } else { return std::numeric_limits<T>::lowest(); } } template<typename T> T SmartStack<T>::GetMin() const { if (!mNum.empty()) { return mMin.top(); } else { return std::numeric_limits<T>::max(); } } template<typename T> double SmartStack<T>::GetAverage() const { double avr; avr = static_cast<double>(mSum) / mCnt; avr = std::round(avr * 1000) / 1000; return avr; } template<typename T> T SmartStack<T>::GetSum() const { return mSum; } template<typename T> double SmartStack<T>::GetVariance() const { double avr; double var; avr = static_cast<double>(mSum) / mCnt; //avr = std::round(avr * 10000) / 10000; var = mSum2 / mCnt - avr * avr; var = static_cast<double>(std::round(var * 1000)) / 1000; return var; } template<typename T> double SmartStack<T>::GetStandardDeviation() const { double avr; double var; double var2; avr = static_cast<double>(mSum) / mCnt; //avr = std::round(avr * 10000) / 10000; var = mSum2 / mCnt - avr * avr; //var = std::round(var * 10000) / 10000; var2 = static_cast<double>(std::round(std::sqrt(var) * 1000)) / 1000; return var2; } template<typename T> unsigned int SmartStack<T>::GetCount() const { return mCnt; } }
e124718aa36c64ff44724fca2b738f714782b49b
65458ed8ca5423c5b0eabf6b88685259c7f80fda
/hw5/src/util/bst.h
e7778c0e7dc3ae32f73cc5ccbf06f4f77464939a
[]
no_license
dexterkan/2016-Fall-DSnp
ffb9c214a017af6d55643e2efba4c5fdbd27b9b1
77d465f2149474962b7f1045873fb6f5870a92fc
refs/heads/master
2020-07-23T21:39:24.310790
2017-06-15T11:16:09
2017-06-15T11:16:09
94,360,242
0
0
null
null
null
null
UTF-8
C++
false
false
17,877
h
bst.h
/**************************************************************************** FileName [ bst.h ] PackageName [ util ] Synopsis [ Define binary search tree package ] Author [ Chung-Yang (Ric) Huang ] Copyright [ Copyleft(c) 2005-present LaDs(III), GIEE, NTU, Taiwan ] ****************************************************************************/ #ifndef BST_H #define BST_H #include <cassert> int count = 0; using namespace std; template <class T> class BSTree; // BSTreeNode is supposed to be a private class. User don't need to see it. // Only BSTree and BSTree::iterator can access it. // // DO NOT add any public data member or function to this class!! // template <class T> class BSTreeNode { // TODO: design your own class!! friend class BSTree<T>; friend class BSTree<T>::iterator; BSTreeNode(const T& b, BSTreeNode<T>* p = NULL, BSTreeNode<T>* l = NULL, BSTreeNode<T>* r = NULL ): _data(b), _parent(p), _left(l), _right(r) {} T _data; BSTreeNode<T>* _parent; BSTreeNode<T>* _left; BSTreeNode<T>* _right; }; template <class T> class BSTree { // TODO: design your own class!! public: BSTree() { _dummy = new BSTreeNode<T>( T() , NULL , NULL , NULL ); _root = NULL; _lowerbound = _upperbound = _dummy; } ~BSTree() { clear();} class iterator { friend class BSTree; public: iterator(BSTreeNode<T>* n = NULL, const BSTree<T>* t = NULL ): _node(n) , tree(t) {} iterator(const iterator& i) : _node(i._node) {} ~iterator () {} const T& operator * () const { return _node->_data; } T& operator * () { return _node->_data; } iterator& operator ++ () { _node = tree->successor(_node); return *(this); } iterator operator ++ (int) { iterator i = *this; _node = tree->successor(_node); return i; } iterator& operator -- () { _node = tree->predecessor(_node); return *(this); } iterator operator -- (int) { iterator i = *this; _node = tree->predecessor(_node); return i; } iterator& operator = (const iterator& i) { _node = i._node; return *(this); } bool operator != (const iterator& i) const { return ( _node != i._node ); } bool operator == (const iterator& i) const { return ( _node == i._node ); } private: BSTreeNode<T>* _node; const BSTree<T>* tree; }; iterator begin() const { return iterator(_lowerbound, (this));} iterator end() const { return iterator(_dummy ,(this));} bool empty() const { return ( _root == NULL ); } size_t size() const { if( empty() ) return 0; else { size_t count = 0; for( iterator i = begin() ; i != end() ; ++i ) { count++; } return count; } } void pop_front() { if( !empty() ) deleteNode(_lowerbound); } void pop_back() { if( !empty() ) deleteNode(_upperbound); } bool erase(iterator pos) { if( _root != NULL ) { BSTreeNode<T>* d = pos._node; deleteNode(d); return true; } return false; } bool erase(const T& x) { if( !empty() ) { for( iterator i = begin() ; i != end() ; ++i ) { if( *i == x ) { deleteNode(i._node); return true; } } } return false; } void insert( const T& x ) { if( empty() ) { BSTreeNode<T>* add = new BSTreeNode<T>( x , NULL ,NULL , NULL ); _root = _upperbound = _lowerbound = add; add->_right = _dummy; } else { bool check = false; BSTreeNode<T>* add = new BSTreeNode<T>( x , NULL ,NULL , NULL ); if( x <= _root->_data ) { BSTreeNode<T>* now = _root; while( now->_left != NULL ) { if( now->_left->_data < x ) { now->_left->_parent = add; add->_left = now->_left; now->_left = add; add->_parent = now; check = true; break; } now = now->_left; } if( !check ) { now->_left = add; add->_parent = now; _lowerbound = add; } } else { BSTreeNode<T>* now = _root; while( now->_right != NULL && now->_right != _dummy ) { if( now->_right->_data >= x ) { now->_right->_parent = add; add->_right = now->_right; now->_right = add; add->_parent = now; check = true; break; } now = now->_right; } if( !check ) { now->_right = add; add->_parent = now; _upperbound = add; add->_right = _dummy; } } } } void clear() { while( !empty() ) { pop_back(); } } BSTreeNode<T>* successor(const BSTreeNode<T>* n) const{ if( n == _dummy || n == _upperbound ) { return _dummy; } else { if( n->_right ) { BSTreeNode<T>* find = n->_right; while( find->_left != NULL ) { find = find->_left; } return find; } else { if( n->_parent ) { if( isRight(n) ) { BSTreeNode<T> * find = n->_parent; while( isRight(find) ) { find = find->_parent; } return find->_parent; } else return n->_parent; } else return _dummy; } } } BSTreeNode<T>* predecessor (const BSTreeNode<T>* n) const{ if( n == _dummy ) return _upperbound; else if( n == _lowerbound ) return _lowerbound; else { if( n->_left ) { BSTreeNode<T>* find = n->_left; while( find->_right != NULL ) { find = find->_right; } return find; } else { if( n->_parent ) { if( isRight(n) ) return n->_parent; else { BSTreeNode<T>* find = n->_parent; while( !isRight(find) ) { find = find->_parent; } return find->_parent; } } else return _lowerbound; } } } void sort() {;} void print() {;} private: BSTreeNode<T>* _root; BSTreeNode<T>* _upperbound; BSTreeNode<T>* _lowerbound; BSTreeNode<T>* _dummy; void deleteNode(BSTreeNode<T>* d){ if( NodeStyle(d) == 0 ) // no child { if( d == _root ) { _root = NULL; _upperbound = _lowerbound = _dummy; delete d; } else { if( isRight(d) ) { if( d == _upperbound ) { _upperbound = d->_parent; d->_parent->_right = _dummy; } else d->_parent->_right = NULL; delete d; } else { if( d == _lowerbound ) { _lowerbound = d->_parent; _lowerbound->_left = NULL; } else d->_parent->_left = NULL; delete d; } } } //================================================// else if( NodeStyle(d) == 1 ) // one child { if( d == _root ) { if( d->_right != NULL && d->_right != _dummy ) // 有右手 { _root = d->_right; d->_right->_parent = NULL; BSTreeNode<T>* find = d->_right; while( find->_left != NULL ) { find = find->_left; } _lowerbound = find; delete d; } else // 有左手 { _root = d->_left; d->_left->_parent = NULL; BSTreeNode<T>* find = d->_left; while( find->_right != NULL ) { find = find->_right; } _upperbound = find; find->_right = _dummy; delete d; } } else { if( isRight(d) ) // 在右邊 { if( (d->_right != NULL) && (d->_right != _dummy) ) // 有右手 { d->_parent->_right = d->_right; d->_right->_parent = d->_parent; delete d; } else // 有左手 { if( d == _upperbound ) // 是最大 { BSTreeNode<T>* find = d->_left; while( find->_right != NULL ) { find = find->_right; } _upperbound = find; find->_right = _dummy; d->_parent->_right = d->_left; d->_left->_parent = d->_parent; delete d; } else // 不是最大 { d->_parent->_right = d->_left; d->_left->_parent = d->_parent; delete d; } } } else // 在左邊 { if( d->_left ) // 有左手 { d->_parent->_left = d->_left; d->_left->_parent = d->_parent; delete d; } else // 有右手 { if( d == _lowerbound ) // 是最小 { BSTreeNode<T>* find = d->_right; while( find->_left != NULL ) { find = find->_left; } _lowerbound = find; find->_left = NULL; d->_parent->_left = d->_right; d->_right->_parent = d->_parent; delete d; } else // 不是最小 { d->_parent->_left = d->_right; d->_right->_parent = d->_parent; delete d; } } } } } //======================================================// else // two children { BSTreeNode<T>* s = successor(d); if( d == _root ) // root { if( NodeStyle(s) == 0 ) // S 沒有手 { if( s->_parent == d ) { s->_parent = NULL; s->_left = d->_left; d->_left->_parent = s; if( s == _upperbound ) s->_right = _dummy; else s->_right = NULL; } else { if( isRight(s) ) s->_parent->_right = NULL; else s->_parent->_left = NULL; s->_parent = NULL; s->_right = d->_right; s->_left = d->_left; d->_left->_parent = s; d->_right->_parent = s; } _root = s; delete d; } else // s 有手 { if( s->_parent == d ) { s->_parent = NULL; s->_left = d->_left; d->_left->_parent = s; } else { if( isRight(s) ) { s->_parent->_right = s->_right; s->_right->_parent = s->_parent; } else { s->_parent->_left = s->_right; s->_right->_parent = s->_parent; } s->_parent = NULL; s->_right = d->_right; s->_left = d->_left; d->_left->_parent = s; d->_right->_parent = s; } _root = s; delete d; } } else // not root { if( NodeStyle(s) == 0 ) // 沒有手 { if( s->_parent == d ) { s->_parent = d->_parent; s->_left = d->_left; d->_left->_parent = s; if( isRight(d) ) d->_parent->_right = s; else d->_parent->_left = s; } else { if( isRight(s) ) s->_parent->_right = NULL; else s->_parent->_left = NULL; s->_parent = d->_parent; s->_left = d->_left; s->_right = d->_right; d->_left->_parent = s; d->_right->_parent = s; if( isRight(d) ) d->_parent->_right = s; else d->_parent->_left = s; } delete d; } else // 有手 { if( s->_parent == d ) { if( isRight(d) ) d->_parent->_right = s; else d->_parent->_left = s; s->_parent = d->_parent; s->_left = d->_left; d->_left->_parent = s; } else { if( isRight(s) ) { s->_parent->_right = s->_right; s->_right->_parent = s->_parent; } else { s->_parent->_left = s->_right; s->_right->_parent = s->_parent; } if( isRight(d) ) d->_parent->_right = s; else d->_parent->_left = s; s->_parent = d->_parent; s->_left = d->_left; s->_right = d->_right; d->_left->_parent = s; d->_right->_parent = s; } delete d; } } } } int NodeStyle(const BSTreeNode<T>* n) { int count = 0; if( n->_left != NULL ) count++; if( n-> _right != NULL && ( n-> _right != _dummy ) ) count++; return count; } bool isRight(const BSTreeNode<T>* n) const{ return (n->_parent->_right == n)? true : false; } }; #endif // BST_H
df69982fa53bcce3dc31e3cf95d1e37402e37fcd
05692d2cd7590ce786eba8f0ab5fbc3a8a8b887f
/Source/DevSys/task_.h
1295db748f5cd6aed9a2a6e073f24117894e7d45
[]
no_license
fpawel/AnkatMICROSeviceApp
e639d1f0c9ed5cfc4a260fdde2a1e3d3e6978d01
24ec2a69630548a1dd03d47ac1d0a27d3997e498
refs/heads/master
2021-06-15T22:32:37.323634
2017-04-28T12:16:29
2017-04-28T12:16:29
72,271,890
1
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,170
h
task_.h
//------------------------------------------------------------------------------ #ifndef task_H #define task_H //------------------------------------------------------------------------------ //std #include <deque> //my #include "MyAbstructTransfer.hpp" #include "MyExcpt.hpp" //------------------------------------------------------------------------------ class SingleAction : public NamedTransfer { public: explicit SingleAction(const AnsiString& what) : NamedTransfer(what) {} virtual ~SingleAction() {} private: virtual bool HandleBeginTransfer() { return true; } virtual bool HandleEndTransfer() { return false; } }; class InitializeDevice : public SingleAction { public: explicit InitializeDevice(); virtual ~InitializeDevice() {} private: virtual void Perform(); }; class SyncDevDate : public SingleAction { public: explicit SyncDevDate(); virtual ~SyncDevDate() {} private: virtual void Perform(); }; class ReadArchiveTask : public SingleAction { public: explicit ReadArchiveTask(bool isHour, TDateTime dtTm1, TDateTime dtTm2); virtual ~ReadArchiveTask() {} private: const TDateTime dtTm1_, dtTm2_; const bool isHour_; virtual void Perform(); }; class FromIndex2IndexTemplate : public SingleAction { public: typedef void (__closure *FooT)(unsigned); explicit FromIndex2IndexTemplate(unsigned i0, unsigned i1, FooT foo); virtual ~FromIndex2IndexTemplate() {} private: const unsigned i0_, i1_; const FooT foo_; virtual void Perform(); }; class SetDateTimeAction : public SingleAction { public: explicit SetDateTimeAction() : SingleAction("Установка даты и времени") {} virtual ~SetDateTimeAction() {} private: virtual void Perform(); }; //--------------------------------------------------------------------------- #endif //---------------------------------------------------------------------------
e25611d2296754e965755fe9ee218b9b55c2938a
7cce0635a50e8d2db92b7b1bf4ad49fc218fb0b8
/Visual C++2005入门经典学习/Visual C++2005入门经典学习例程/Ex3/Ex3_01/Ex3_01.cpp
a1e8e78b636f315c057c636692a7cd6ab87bcee8
[]
no_license
liquanhai/cxm-hitech-matrix428
dcebcacea58123aabcd9541704b42b3491444220
d06042a3de79379a77b0e4e276de42de3c1c6d23
refs/heads/master
2021-01-20T12:06:23.622153
2013-01-24T01:05:10
2013-01-24T01:05:10
54,619,320
2
2
null
null
null
null
UTF-8
C++
false
false
668
cpp
Ex3_01.cpp
/************************************ * Ex3_01.cpp * * A nested if demonstration * ************************************/ #include <iostream> using std::cout; using std::cin; using std::endl; int main() { char letter = 0; cout << endl << "Enter a letter: "; cin >> letter; if (letter >= 'A') if (letter <= 'Z') { cout << endl << "You entered a capital letter." << endl; // letter += 'a' - 'A'; return 0; } if (letter >= 'a') if (letter <= 'z') { cout << endl << "You entered a small letter." << endl; return 0; } cout << endl << "You did not enter a letter." << endl; return 0; }
190c5f2195472aa1b53a197106c150304c503d94
36613ef91f5c678c86e04884df6fc61fd7556ebd
/Graph Theory/dijkstra_dense.cpp
7954225297e2ef414b50b5acfa0832ef09345b1b
[]
no_license
VictorXjoeY/Notebook
5723000907391bc3064a2285484c3d7fe3a8a093
5a9f8c8c9c7b4e6b1f89db63038f1ac4fa4643c3
refs/heads/master
2021-06-11T10:06:44.004989
2021-02-15T15:53:28
2021-02-15T15:53:28
100,169,996
13
4
null
2020-02-07T12:21:22
2017-08-13T10:43:52
C++
UTF-8
C++
false
false
1,175
cpp
dijkstra_dense.cpp
constexpr int N = 100000; vector<pair<int, int>> g[N + 1]; // (Input) bool in_spt[N + 1]; int dist[N + 1]; int n; // (Input) /* O(V) - Retrieves next vertex to be added to Shortest Path Tree. */ int next_to_spt() { int v = 0; for (int u = 1; u <= n; u++) { if (!in_spt[u] and (!v or dist[u] < dist[v])) { v = u; } } return v; } /* O(E + V^2). */ void dijkstra(int u) { // Initializing. memset(in_spt, false, sizeof(in_spt)); memset(dist, 0x3f, sizeof(dist)); // Initializing source vertex. Cost of adding the first vertex u to Shortest Path Tree is 0. dist[u] = 0; // While there are vertices to visit. while ((u = next_to_spt())) { // Vertex u now belongs to Shortest Path Tree. in_spt[u] = true; // For every vertex v adjacent to u. for (int i = 0; i < g[u].size(); i++) { int v = g[u][i].first; int w = g[u][i].second; // If a better path was found to add the vertex v to the Shortest Path Tree. if (!in_spt[v] and dist[u] + w < dist[v]) { dist[v] = dist[u] + w; } } } }
0ff90590b6d2c554fbca68006df35070eddb4d43
2095fdadad5af8391cdfc1b85317473150cf4986
/dataPreparation.cpp
44c5e66418a72f40f4cbd556e448a781a1349354
[]
no_license
afarasat/SerialSpareseMatrixFactorization
ac555dcb4e3f25a5a5ced482ca9650416c149ee0
dbcdac59be4feb40fcc87eed172e4e1844627274
refs/heads/master
2018-01-08T12:13:24.344528
2015-11-24T16:30:15
2015-11-24T16:30:15
44,546,034
0
1
null
null
null
null
UTF-8
C++
false
false
2,164
cpp
dataPreparation.cpp
/* * dataPreparation.cpp * * Created on: Oct 8, 2015 * Author: afarasat */ #include <iostream> #include <math.h> #include <cstdlib> #include "dataPreparation.h" #include <vector> #include <stdlib.h> /* srand, rand */ #include <ctime> using namespace std; dataPreparation::dataPreparation(int a, int b, int c) { _Q = a, _N = b, _K =c; _dataThresold = 0.5; _obsThresold = 0.5; _Y = new int *[_Q]; for (int k = 0; k < _Q; k++){ _Y[k] = new int[_N]; } _observation = new int *[_Q]; for (int k = 0; k < _Q; k++){ _observation[k] = new int[_N]; } } dataPreparation::~dataPreparation() { // TODO Auto-generated destructor stub } void dataPreparation::initialization() { std::vector<double> W(_Q*_K); std::vector<double> C(_K*_N); /*vector<vector<double> > C1( _K, std::vector<double> ( _N, 0 ) ); vector<vector<double> > W1( _Q, std::vector<double> ( _K, 0 ) ); vector<vector<int> > Y ( _Q, std::vector<int> ( _N, 0 ) );*/ srand(time(NULL)); cout<< "W: "<< '\n'; for (int i = 0; i < _Q; i++) { for (int j = 0; j < _K; j++) { W[i*_K+j]= 0.0; double randt = ((double) rand() / (RAND_MAX)); if (randt < _dataThresold) { W[i*_K+j] = 5 * ((double) rand() / (RAND_MAX)); } cout << W[i*_K+j] << " "; } cout << '\n'; } cout<<"C: "<<endl; for (int i = 0; i < _K; i++) { for (int j = 0; j < _N; j++) { C[i*_N+j] = 2 * ((double) rand() / (RAND_MAX)) - 1; cout << C[i*_N+j]<< " "; } cout << '\n'; } cout<< "Main Data: "<< '\n'; for (int i = 0; i < _Q; i++) { for (int j = 0; j < _N; j++) { double sum = 0; for (int k = 0; k < _K; k++) { sum += W[i*_K+k]*C[j+k*+_N]; } if (sum > 0){ _Y[i][j] = 1; _observation[i][j] = 1; if ((double) rand() / (RAND_MAX)<_obsThresold/5 ){ _observation[i][j] = -1; } }else{ _Y[i][j] = 0; _observation[i][j] = 0; if ((double) rand() / (RAND_MAX)<_obsThresold ){ _observation[i][j] = -1; } } cout<<_Y[i][j]<<" "; } cout << endl; } //_Y = & Y; } int ** dataPreparation::getMainData(){ return _Y; } int ** dataPreparation::getObservation(){ return _observation; }
843968fd2b6c2e31edaf42d41186b5a079097e30
05f7573db159e870fb26c847991c4cb8c407ed4c
/VBF/Source/VBF_CORE4.0/VBF_Interface/VBF_Plot/Common/IVBF_MarkModelVolumeRayCasting.h
2809ba823322dc87016026f9c6468fe3f4a6c1de
[]
no_license
riyue625/OneGIS.ModelingTool
e126ef43429ce58d22c65832d96dbd113eacbf85
daf3dc91584df7ecfed6a51130ecdf6671614ac4
refs/heads/master
2020-05-28T12:12:43.543730
2018-09-06T07:42:00
2018-09-06T07:42:00
null
0
0
null
null
null
null
GB18030
C++
false
false
1,662
h
IVBF_MarkModelVolumeRayCasting.h
//******************************************************************* // FileName:IVBF_MarkModelVolumeRayCasting.h // Function:体数据模型接口(光线投射法) // Author: 杜莹 // Date: 2018-03-31 //******************************************************************* #ifndef __IVBF_MARK_MODEL_VOLUME_RAY_CASTING_H__ #define __IVBF_MARK_MODEL_VOLUME_RAY_CASTING_H__ #include <VBF_Plot/IVBF_MarkModelPoint.h> #include <VBF_Plot/Common/VBF_3DPlotDataTypes_Common.h> #include <Types/Vec4ub> #include <map> // 定义颜色映射表(避免代码过长) typedef std::map< float, osg::Vec4ub, less<float> > CVBF_ColorMap; //-------------------------------------------------------------------- // 定义接口:IVBF_MarkModelVolumeRayCasting // 接口描述:体数据模型接口(光线投射法) //-------------------------------------------------------------------- class IVBF_MarkModelVolumeRayCasting : public IVBF_MarkModel { public: virtual ~IVBF_MarkModelVolumeRayCasting() {} // 设置/获取体数据文件名 // 说明:1)目前只支持.fld格式的体数据文件,且每个数据点的值类型为double; // 2)该路径下必须有一个同名且后缀为.inf的信息文件,格式为xml,注明该体数据的经纬度范围等信息 virtual bool SetVolumeFileName(const std::string& strFileName)=0; virtual const std::string& GetVolumeFileName()=0; // 设置/获取颜色表:key=颜色关键点数值,value=对应的颜色,关键点数值从小到大 virtual void SetColorTable(const CVBF_ColorMap& mapColorTable)=0; virtual const CVBF_ColorMap& GetColorTable()=0; }; #endif
9b6f04ab469b19ff260aea4360e66af7e5f18596
524c7b4210db30082c594f3a247299fb467505ba
/WindowsSystem/CountThreadMultiThread/CountThreadMultiThread.cpp
641f8e160ffd575b38c28d122884bc5ee67e087a
[]
no_license
juhyupLee/SystemProgramming
1254e42da20e57361b9d7975fe40dd7945cfa46e
f5fa01e411fb5fb298eb5f1daf17fa61edc78d60
refs/heads/master
2021-03-05T00:43:24.896314
2020-08-25T18:37:41
2020-08-25T18:37:41
246,080,818
0
0
null
null
null
null
UTF-8
C++
false
false
879
cpp
CountThreadMultiThread.cpp
//#include <stdio.h> //#include <tchar.h> //#include <process.h> //#include <Windows.h> // //#define MAX_THREADS (1024*10) // //unsigned int WINAPI ThreadProc(LPVOID lpParm) //{ // DWORD threadNum = (DWORD)lpParm; // // while (1) // { // _tprintf(_T("thread num: %d\n"), threadNum); // Sleep(1000); // } // return 0; //} // //DWORD cntOfThread = 0; // //int _tmain(int argc, TCHAR* argv[]) //{ // DWORD dwThreadId[MAX_THREADS]; // HANDLE hThread[MAX_THREADS]; // // while (1) // { // hThread[cntOfThread] = (HANDLE)_beginthreadex(NULL, 0, ThreadProc, (LPVOID)cntOfThread, 0, (unsigned int*)&dwThreadId[cntOfThread]); // // if (hThread[cntOfThread] == NULL) // { // _tprintf(_T("MAXIMUM THREAD SIZE:%d\n"), cntOfThread); // break; // } // cntOfThread++; // // } // // for (DWORD i = 0; i < cntOfThread; i++) // { // CloseHandle(hThread[i]); // } // // return 0; // //}
b956398cae6a2f024e181d494a176cafd3e49681
a37b2d61d28864abdfba34dc0f3666bdf3723507
/textGame/ConversationParade/main.cpp
66da6493e3a3f92e20e4599e959171c342cb94d9
[]
no_license
cakeandturtles/junkyard-of-junkyard
b1654df8a3e30a5fdd54683163e123cafd5ebe3e
376613ab23a72ed1292001d8de54f748e161d25f
refs/heads/master
2020-04-10T16:36:24.201896
2015-09-13T20:19:29
2015-09-13T20:19:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
304
cpp
main.cpp
#include <iostream> #include <string> using namespace std; int main() { string input; int whoAmITalkingTo=0; while (true) { switch (whoAmITalkingTo) { case 0: break; default: break; } } return 0; }
2168aa5fbab965ca974c12af583b54e1632006d0
9d5d63905f63d9e736486407330b440cb5006b02
/BaiTapTongHop/Bai02/QLPT.h
0de2d66be86b36c1347cd755c59d3f71f8165a8d
[]
no_license
emonno13/oop-practice
1b5ac12598b5cb0851e9d5491dfc5b260f621458
f08e3289ea4e7e01494f24f3982bfa33eb4da5e0
refs/heads/main
2023-06-11T14:52:50.871522
2021-07-03T17:53:57
2021-07-03T17:53:57
357,640,031
0
0
null
null
null
null
UTF-8
C++
false
false
408
h
QLPT.h
#pragma once #include "Shieldato.cpp" class QLPT { private: vector<PhiThuyen *> list; public: QLPT(); ~QLPT(); void Nhap(); void Xuat() const; void XuatTongNhienLieuTheoLoai(const int &) const; // by kind void XuatTongNhienLieu(const int &) const; // by all friend istream &operator>>(istream &is, QLPT &); friend ostream &operator<<(ostream &os, QLPT *); };
d7fea8598bcd72b6fe6899b8ab80c39f44a86704
1979ea87cbe6c7520abfbaa04fa93202f776210f
/shChapter8/exm2_(1).cpp
975ae85d8aa992a492c973f4e7edba2e2fa795cf
[]
no_license
qkrwjdan/PracticeCpp
92284abd9929618a80660d1bab6befcfe1e0f97d
0f0e63a0368745f6c7ae9e3d6a1b6873facc38c5
refs/heads/master
2021-05-25T17:22:48.178495
2020-06-29T15:38:00
2020-06-29T15:38:00
253,841,154
0
0
null
null
null
null
UTF-8
C++
false
false
432
cpp
exm2_(1).cpp
// // Created by macbook air on 2020-05-12. // #include <iostream> #include <iomanip> using namespace std; int main() { int height[10] = { 177, 173, 162, 164, 189, 154, 162, 170, 175, 153 }; int i; cout << "====================\n"; cout << " INDEX HEIGHT\n"; cout << "====================\n"; for (i = 0; i < 10; i++) { cout << setw(5) << i << setw(9) << height[i] << endl; } return 0; }
9771b9af20bfed7a4c0c96750960f47b83615250
84090973310d01d8fb38a391f9aa182a5886e17e
/challenge/2020/july-leetcoding-challenge/island-perimeter.cpp
4a87a894e34791823fddb3c4d79a2be925afe170
[]
no_license
VasuGoel/leetcode
29e4d7fe6654d76ae625037e6266ec9e8d25f304
2de293a5acbbe653a9e0757fea99eca37ac84e54
refs/heads/master
2023-04-14T11:19:16.995592
2021-04-30T16:35:57
2021-04-30T16:35:57
324,527,300
1
0
null
null
null
null
UTF-8
C++
false
false
909
cpp
island-perimeter.cpp
// O(m • n) time, O(1) space, where m = no. of rows, and n = no. of columns class Solution { public: int islandPerimeter(vector<vector<int>>& grid) { int m = grid.size(), n = grid[0].size(), res = 0; // lambda to count borders around cell(i, j) auto borders = [&](int i, int j) -> int { int res = 0; vector<vector<int>> dirs = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; for(auto dir: dirs) { int x = i + dir[0], y = j + dir[1]; if((x < 0 or x >= m or y < 0 or y >= n) or grid[x][y] == 0) res++; } return res; }; // count all borders for each cell(i, j) == 1 for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) if(grid[i][j]) res += borders(i, j); } return res; } };
cfb38b63a86e3f48effcc5d46c6708db969a26cd
32da723b5c759c98845249bb51332109014b4f62
/C++OOP.cpp/FirstMantadoryHomework/CreateFileOfStocks.cpp
ff74c9a2058e9f4d39617a9897c946136453e0e8
[]
no_license
IliyanKafedzhiev/FacultyOfMathematicAndInformatic
b8a810ca1100cc0f39c1460f60eb014e4c0b5ffc
a2b05a9aa7e677609447c0311ee79552464434ce
refs/heads/master
2020-07-06T04:19:30.531000
2015-03-02T21:54:42
2015-03-02T21:54:42
18,809,355
1
0
null
null
null
null
UTF-8
C++
false
false
626
cpp
CreateFileOfStocks.cpp
#include <iostream> #include <fstream> using namespace std; struct Stocks { unsigned InvID; unsigned ComID; double Count; }; int main() { Stocks stock[200]; fstream File,txtT; File.open("stocks.dat",ios::binary|ios::in); txtT.open("stocks.txt",ios::out); if(!File) { cout<<"Error"; return 0; } for (int i=0;!File.eof();i++) { File.read((char*)&stock[i],sizeof(Stocks)); txtT<<"InvID:"<<stock[i].InvID<<endl; txtT<<"ComID:"<<stock[i].ComID<<endl; txtT<<"$:"<<fixed<<stock[i].Count<<endl; } txtT.close(); File.close(); return 0; }
5028e60476abcfb997cd93656c6d49e30284fc6c
6b79b9ce4945f935044530d14ad2694cf186e8e3
/FW2017/Shared/Timer/timer.cpp
21a4f90a6c8dc756d31755851d06cfd66ea62f7c
[]
no_license
ISU-MAVRIC/MAVRIC_Firmware
541e8f6fda5d940eb29f4a84100f8b475496199b
35cf245bdf78dc5d5c7c9d47633c19f47841faa0
refs/heads/master
2020-07-04T09:13:47.962430
2017-05-17T20:54:03
2017-05-17T20:54:03
67,298,023
1
1
null
null
null
null
UTF-8
C++
false
false
6,455
cpp
timer.cpp
/* * timer.cpp * * Created on: Sep 3, 2016 * Author: James */ #include "timer.hpp" #include "msp.h" #include "clocks.h" #include <string.h> namespace Peripherials { Timer& GetTA0() { static Timer ta0(TIMER_A0, SMCLK); return ta0; } Timer& GetTA1() { static Timer ta1(TIMER_A1, SMCLK); return ta1; } Timer& GetTA2() { static Timer ta2(TIMER_A2, SMCLK); return ta2; } Timer& GetTA3() { static Timer ta3(TIMER_A3, SMCLK); return ta3; } Timer &Timer::operator=(const Peripherials::Timer & other) { regs = other.regs; timer_module = other.timer_module; memcpy(isr, other.isr, sizeof(isr)); overflow_isr = other.overflow_isr; overflow_count = other.overflow_count; return *this; } Timer::Timer(Timer_A_Type* instance, TimerClockSource source) : regs(*instance), overflow_count(0) { regs.CTL = ((source & 3) << 8) | (TACLR) | (TIMER_A_CTL_MC__UP); if (instance == TIMER_A0) { timer_module = 0; } else if (instance == TIMER_A1) { timer_module = 1; } else if (instance == TIMER_A2) { timer_module = 2; } else if (instance == TIMER_A3) { timer_module = 3; } regs.CTL |= TAIE; regs.CCTL[0] |= TIMER_A_CCTLN_CCIE; overflow_isr = 0; int i; for (i = 0; i < sizeof(isr)/sizeof(*isr); i++) { isr[i] = 0; } } void Timer::SetPeriod(uint16_t period) { switch ((TimerClockSource) (regs.CTL >> 8) & 0x3) { /* umm, this is external without a fixed period, so do nothing */ case TAxCLK: case INCLK: break; case ACLK: case SMCLK: /* set the period to the provided value */ regs.CCR[0] = period; /* Set the mode to up (to make use of the period) */ regs.CTL = (regs.CTL & ~(3 << 4)) | (MC__UP); break; } } void Timer::SetPeriod(float period) { int clock_divider_base = ((regs.CTL >> 6) & 0x03) + (regs.EX0 & 0x07); switch ((TimerClockSource) (regs.CTL >> 8) & 0x3) { /* umm, this is external without a fixed period, so do nothing */ case TAxCLK: case INCLK: break; case ACLK: /* set the period to the computed value */ regs.CCR[0] = (uint16_t) (((fACLK >> clock_divider_base) * period) + 0.5); /* Set the mode to up (to make use of the period) */ regs.CTL = (regs.CTL & ~(3 << 4)) | (MC__UP); break; case SMCLK: /* set the period to the computed value */ regs.CCR[0] = (uint16_t) (((fSMCLK >> clock_divider_base) * period) + 0.5); /* Set the mode to up (to make use of the period) */ regs.CTL = (regs.CTL & ~(3 << 4)) | (MC__UP); break; } } void Timer::StartPWM(TimerCapComUnit module, float pulse_width) { if (module == CC0) return; int clock_divider_base = ((regs.CTL >> 6) & 0x03) + (regs.EX0 & 0x07); switch ((TimerClockSource) (regs.CTL >> 8) & 0x3) { /* umm, this is external without a fixed period, so do nothing */ case TAxCLK: case INCLK: break; case ACLK: regs.CCTL[(int) module] = (regs.CCTL[(int) module] & ~OUTMOD_7 & ~CAP) | OUTMOD_7; regs.CCR[(int) module] = (uint16_t) ((pulse_width * (fACLK >> clock_divider_base)) + 0.5); break; case SMCLK: regs.CCTL[(int) module] = (regs.CCTL[(int) module] & ~OUTMOD_7 & ~CAP) | OUTMOD_7; regs.CCR[(int) module] = (uint16_t) ((pulse_width * (fSMCLK >> clock_divider_base)) + 0.5); break; } } void Timer::StartPWM(TimerCapComUnit module, uint16_t pulse_width) { switch ((TimerClockSource) (regs.CTL >> 8) & 0x3) { /* umm, this is external without a fixed period, so do nothing */ case TAxCLK: case INCLK: break; case ACLK: case SMCLK: regs.CCTL[(int) module] = (regs.CCTL[(int) module] & ~OUTMOD_7 & ~CAP) | OUTMOD_7; regs.CCR[(int) module] = pulse_width; break; } } void Timer::SetPWM(TimerCapComUnit module, float pulse_width) { if (module == CC0) return; switch ((TimerClockSource) (regs.CTL >> 8) & 0x3) { /* umm, this is external without a fixed period, so do nothing */ case TAxCLK: case INCLK: break; case ACLK: regs.CCR[(int) module] = (uint16_t) ((pulse_width * fACLK) + 0.5); break; case SMCLK: regs.CCR[(int) module] = (uint16_t) ((pulse_width * fSMCLK) + 0.5); break; } } void Timer::SetPWM(TimerCapComUnit module, uint16_t pulse_width) { switch ((TimerClockSource) (regs.CTL >> 8) & 0x3) { /* umm, this is external without a fixed period, so do nothing */ case TAxCLK: case INCLK: break; case ACLK: case SMCLK: regs.CCR[(int) module] = pulse_width; break; } } void Timer::DisablePWM(TimerCapComUnit module) { regs.CCTL[(int) module] = (regs.CCTL[(int) module] & ~OUTMOD_7) | OUTMOD_5; } void Timer::EnablePWM(TimerCapComUnit module) { regs.CCTL[(int) module] = (regs.CCTL[(int) module] & ~OUTMOD_7 & ~CAP & ~CM_3) | OUTMOD_7; } void Timer::AttachOverflowInterrupt(void (*new_interrupt)(void)) { overflow_isr = new_interrupt; if (new_interrupt != 0) { regs.CTL |= TAIE; NVIC_EnableIRQ((IRQn_Type) (TA0_0_IRQn + (timer_module * 2))); } else { regs.CTL &= ~TAIE; } } void Timer::AttachInterrupt(TimerCapComUnit module, void (*new_interrupt)(void)) { isr[(int) module] = new_interrupt; if (new_interrupt != 0) { regs.CCTL[(int) module] |= CCIE; if (module == CC0) { NVIC_EnableIRQ((IRQn_Type) (TA0_0_IRQn + (timer_module * 2))); } else { NVIC_EnableIRQ((IRQn_Type) (TA0_N_IRQn + (timer_module * 2))); } } else { regs.CCTL[(int) module] &= ~CCIE; } } unsigned int Timer::GetOverflowCount() { return overflow_count; } void Timer::_CCR0_ISR(void) { if ((regs.CTL & TAIE) && (regs.CTL & TAIFG)) { if (overflow_isr != 0) { overflow_isr(); } overflow_count++; regs.CTL &= ~TAIFG; } if ((regs.CCTL[0] & CCIE) && (regs.CCTL[0] & CCIFG)) { if (isr[0] != 0) { isr[0](); } regs.CCTL[0] &= ~CCIFG; } } void Timer::_CCRn_ISR(void) { int n = regs.IV / 2; if (n == 7) { if (overflow_isr != 0) { overflow_isr(); } overflow_count++; } if (n <= 0 || n > 4) { return; } if (isr[n] != 0) { isr[n](); } } } extern "C" { void TA0_0_IRQHandler() { Peripherials::GetTA0()._CCR0_ISR(); } void TA0_N_IRQHandler() { Peripherials::GetTA0()._CCRn_ISR(); } ///////////////////////// void TA1_0_IRQHandler() { Peripherials::GetTA1()._CCR0_ISR(); } void TA1_N_IRQHandler() { Peripherials::GetTA1()._CCRn_ISR(); } ///////////////////////// void TA2_0_IRQHandler() { Peripherials::GetTA2()._CCR0_ISR(); } void TA2_N_IRQHandler() { Peripherials::GetTA2()._CCRn_ISR(); } ///////////////////////// void TA3_0_IRQHandler() { Peripherials::GetTA3()._CCR0_ISR(); } void TA3_N_IRQHandler() { Peripherials::GetTA3()._CCRn_ISR(); } }
6228fefa7be4ce357ab141a2dc436a4c916ac418
d90cc5b23233e1a6f48bc2de2d8831370d953a9f
/HACKEDGame/Source/HACKED/InGame/Phase/PhaseBoss.h
1a8a9c484185e0d7d0511bd11fc88b9f927fecd8
[]
no_license
LJH960101/JHNet_HACKED
d1389fd9303932eda57b9742d75fc82a5543035a
13962fc4dc16ad4d852c09bec7a85be6a8b0f9a0
refs/heads/main
2023-06-15T00:43:43.398914
2021-07-04T08:22:38
2021-07-04T08:22:38
326,329,710
0
0
null
null
null
null
UTF-8
C++
false
false
1,430
h
PhaseBoss.h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "HACKED.h" #include "GameFramework/Actor.h" #include "PhaseBoss.generated.h" UCLASS() class HACKED_API APhaseBoss : public AActor { GENERATED_BODY() public: APhaseBoss(); virtual void BeginPlay() override; virtual void Tick(float DeltaTime) override; public: UFUNCTION() void StartBossPhase(); UFUNCTION() void RunningBossPhase(); UFUNCTION() void PlayLoopSound(); UPROPERTY(EditAnywhere) class USoundWave* GoToDoorAgain; private: class AHACKEDInGameManager* HACKEDInGameManager; UPROPERTY(EditAnywhere) class AInGameNetworkProcessor* InGameNetwork; UPROPERTY(EditAnywhere) class AMilitaryBossAI* boss; UPROPERTY(EditAnywhere) class AEmptyZoneFinder* aiCheckZone; UPROPERTY(EditAnywhere) float toCreditMaxTime = 3.0f; UPROPERTY(EditAnywhere) float toLobbyMaxTime = 25.0f; UPROPERTY(EditAnywhere) float soundFadeInTime = 5.0f; UPROPERTY(EditAnywhere) float soundFadeOutTime = 5.0f; UPROPERTY(EditAnywhere) class UAudioComponent* bossSoundComp; UPROPERTY(EditAnywhere) class USoundWave* bossSoundIntro; UPROPERTY(EditAnywhere) class USoundWave* bossSoundLoop; float toLobbyTimer = 0.0f; bool bBossAlive = false; bool doOnce = false; FTimerHandle endTimer; public: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = BossPhase) bool bIsBossPhaseRunning = false; };
627e1e3259c0e9b12f5f72770ff1cc424c1a46e0
e6c9adcd71fb805e09c91d9e1e07f6e7cf0a321a
/headers/mist-v1.6.0/test/iterator_test.cpp
46cf19d1a25c5b7acf221ed13d2ee597c91984bf
[ "Apache-2.0", "BSD-2-Clause" ]
permissive
simizlab/atlas-guided-em-algorithm
a1c0f522c2daa0a7e53d0eb02eb7f7a8d73e19b0
54dd2df19f65724b1ac6957c06faca39d5b40215
refs/heads/master
2020-05-24T08:25:14.742300
2019-05-24T06:37:03
2019-05-24T06:37:03
187,184,512
4
0
null
2019-05-18T09:10:21
2019-05-17T09:07:52
C++
UTF-8
C++
false
false
10,174
cpp
iterator_test.cpp
// // Copyright (c) 2003-2010, MIST Project, Nagoya University // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // 3. Neither the name of the Nagoya University 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 <iostream> #include <mist/mist.h> #include <mist/matrix.h> #include <mist/vector.h> #include <algorithm> int main( int argc, char *argv[] ) { using namespace std; { { cout << "Forward Iterator Test row axis" << endl; mist::matrix< double > a( 3, 3 ); mist::matrix< double >::iterator ite = a.row_begin( 1 ); for( int i = 1 ; ite != a.row_end( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.row_rbegin( 1 ), a.row_rend( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test row axis" << endl; mist::matrix< double > a( 3, 3 ); mist::matrix< double >::reverse_iterator ite = a.row_rbegin( 1 ); for( int i = 1 ; ite != a.row_rend( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.row_begin( 1 ), a.row_end( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Forward Iterator Test col axis" << endl; mist::matrix< double > a( 3, 3 ); mist::matrix< double >::iterator ite = a.col_begin( 1 ); for( int i = 1 ; ite != a.col_end( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.col_rbegin( 1 ), a.col_rend( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test col axis" << endl; mist::matrix< double > a( 3, 3 ); mist::matrix< double >::reverse_iterator ite = a.col_rbegin( 1 ); for( int i = 1 ; ite != a.col_rend( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.col_begin( 1 ), a.col_end( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } } { cout << endl << endl << "MIST Vector Part." << endl; { cout << "Forward Iterator Test row axis" << endl; mist::matrix< mist::vector2< double > > a( 3, 3 ); mist::matrix< mist::vector2< double > >::iterator ite = a.row_begin( 1 ); for( int i = 1 ; ite != a.row_end( 1 ) ; ite++, i++ ) { ite->x = i; ite->y = i; } cout << a << endl << endl; sort( a.row_rbegin( 1 ), a.row_rend( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test row axis" << endl; mist::matrix< mist::vector2< double > > a( 3, 3 ); mist::matrix< mist::vector2< double > >::reverse_iterator ite = a.row_rbegin( 1 ); for( int i = 1 ; ite != a.row_rend( 1 ) ; ite++, i++ ) { ite->x = i; ite->y = i; } cout << a << endl << endl; sort( a.row_begin( 1 ), a.row_end( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Forward Iterator Test col axis" << endl; mist::matrix< mist::vector2< double > > a( 3, 3 ); mist::matrix< mist::vector2< double > >::iterator ite = a.col_begin( 1 ); for( int i = 1 ; ite != a.col_end( 1 ) ; ite++, i++ ) { ite->x = i; ite->y = i; } cout << a << endl << endl; sort( a.col_rbegin( 1 ), a.col_rend( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test col axis" << endl; mist::matrix< mist::vector2< double > > a( 3, 3 ); mist::matrix< mist::vector2< double > >::reverse_iterator ite = a.col_rbegin( 1 ); for( int i = 1 ; ite != a.col_rend( 1 ) ; ite++, i++ ) { ite->x = i; ite->y = i; } cout << a << endl << endl; sort( a.col_begin( 1 ), a.col_end( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } } { { cout << "Forward Iterator Test all element" << endl; mist::array2< int > a( 3, 3 ); mist::array2< int >::iterator ite = a.begin( ); for( int i = 1 ; ite != a.end( ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.rbegin( ), a.rend( ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test all element" << endl; mist::array2< int > a( 3, 3 ); mist::array2< int >::reverse_iterator ite = a.rbegin( ); for( int i = 1 ; ite != a.rend( ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.begin( ), a.end( ) ); cout << "sorted result" << endl << a << endl << endl; } } { cout << "Forward Iterator Test X axis" << endl; mist::array2< int > a( 3, 3, 0 ); mist::array2< int >::iterator ite = a.x_begin( 1 ); for( int i = 1 ; ite != a.x_end( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.x_rbegin( 1 ), a.x_rend( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Forward Iterator Test Y axis" << endl; mist::array2< int > a( 3, 3, 0 ); mist::array2< int >::iterator ite = a.y_begin( 1 ); for( int i = 1 ; ite != a.y_end( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.y_rbegin( 1 ), a.y_rend( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test X axis" << endl; mist::array2< int > a( 3, 3, 0 ); mist::array2< int >::reverse_iterator ite = a.x_rbegin( 1 ); for( int i = 1 ; ite != a.x_rend( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.x_begin( 1 ), a.x_end( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test Y axis" << endl; mist::array2< int > a( 3, 3, 0 ); mist::array2< int >::reverse_iterator ite = a.y_rbegin( 1 ); for( int i = 1 ; ite != a.y_rend( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.y_begin( 1 ), a.y_end( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { { cout << "Forward Iterator Test all element 3D" << endl; mist::array3< int > a( 3, 3, 3 ); mist::array3< int >::iterator ite = a.begin( ); for( int i = 1 ; ite != a.end( ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.rbegin( ), a.rend( ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test all element 3D" << endl; mist::array3< int > a( 3, 3, 3 ); mist::array3< int >::reverse_iterator ite = a.rbegin( ); for( int i = 1 ; ite != a.rend( ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.begin( ), a.end( ) ); cout << "sorted result" << endl << a << endl << endl; } } { cout << "Forward Iterator Test X axis" << endl; mist::array3< int > a( 3, 3, 3, 0 ); mist::array3< int >::iterator ite = a.x_begin( 1 ); for( int i = 1 ; ite != a.x_end( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.x_rbegin( 1 ), a.x_rend( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Forward Iterator Test Y axis" << endl; mist::array3< int > a( 3, 3, 3, 0 ); mist::array3< int >::iterator ite = a.y_begin( 1 ); for( int i = 1 ; ite != a.y_end( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.y_rbegin( 1 ), a.y_rend( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Forward Iterator Test Z axis" << endl; mist::array3< int > a( 3, 3, 3, 0 ); mist::array3< int >::iterator ite = a.z_begin( 1 ); for( int i = 1 ; ite != a.z_end( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.z_rbegin( 1 ), a.z_rend( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test X axis" << endl; mist::array3< int > a( 3, 3, 3, 0 ); mist::array3< int >::reverse_iterator ite = a.x_rbegin( 1 ); for( int i = 1 ; ite != a.x_rend( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.x_begin( 1 ), a.x_end( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test Y axis" << endl; mist::array3< int > a( 3, 3, 3, 0 ); mist::array3< int >::reverse_iterator ite = a.y_rbegin( 1 ); for( int i = 1 ; ite != a.y_rend( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.y_begin( 1 ), a.y_end( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } { cout << "Reverse Iterator Test Z axis" << endl; mist::array3< int > a( 3, 3, 3, 0 ); mist::array3< int >::reverse_iterator ite = a.z_rbegin( 1 ); for( int i = 1 ; ite != a.z_rend( 1 ) ; ite++, i++ ) { *ite = i; } cout << a << endl << endl; sort( a.z_begin( 1 ), a.z_end( 1 ) ); cout << "sorted result" << endl << a << endl << endl; } return( 0 ); }
61acc809b668c8002d3fab6cdc26b996d74efc34
9c8715f9d5c4f9ef2fa0262b4d9b15221a6bca26
/src/networklayer/icmpv6/IPv6NeighbourCache.cc
f166d4402881c45e8cc2123df0783d59a1236f6a
[]
no_license
kyeongsoo/inet-hnrl
8f424d4b077a855a24a2ba682ea1109b78902f41
857ae37cd233914fd7271584afc4be10bcf75a61
refs/heads/master
2020-04-05T22:43:00.771178
2017-02-27T08:59:31
2017-02-27T08:59:31
193,740
5
4
null
null
null
null
UTF-8
C++
false
false
5,579
cc
IPv6NeighbourCache.cc
/** * Copyright (C) 2005 Andras Varga * Copyright (C) 2005 Wei Yang, Ng * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ #include "IPv6NeighbourCache.h" std::ostream& operator<<(std::ostream& os, const IPv6NeighbourCache::Key& e) { return os << "if=" << e.interfaceID << " " << e.address; //FIXME try printing interface name } std::ostream& operator<<(std::ostream& os, const IPv6NeighbourCache::Neighbour& e) { os << e.macAddress; if (e.isRouter) os << " ROUTER"; if (e.isDefaultRouter) os << " defaultRtr"; os << " " << IPv6NeighbourCache::stateName(e.reachabilityState); os << " reachabilityExp:" << e.reachabilityExpires; if (e.numProbesSent) os << " probesSent:" << e.numProbesSent; if (e.isRouter) os << " rtrExp:" << e.routerExpiryTime; return os; } IPv6NeighbourCache::IPv6NeighbourCache() { WATCH_MAP(neighbourMap); } IPv6NeighbourCache::Neighbour *IPv6NeighbourCache::lookup(const IPv6Address& addr, int interfaceID) { Key key(addr, interfaceID); NeighbourMap::iterator i = neighbourMap.find(key); return i==neighbourMap.end() ? NULL : &(i->second); } const IPv6NeighbourCache::Key *IPv6NeighbourCache::lookupKeyAddr(Key& key) { NeighbourMap::iterator i = neighbourMap.find(key); return &(i->first); } IPv6NeighbourCache::Neighbour *IPv6NeighbourCache::addNeighbour(const IPv6Address& addr, int interfaceID) { Key key(addr, interfaceID); ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet Neighbour& nbor = neighbourMap[key]; nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience. nbor.isRouter = false; nbor.isDefaultRouter = false; nbor.reachabilityState = INCOMPLETE; nbor.reachabilityExpires = 0; nbor.numProbesSent = 0; nbor.nudTimeoutEvent = NULL; nbor.numOfARNSSent = 0; nbor.routerExpiryTime = 0; return &nbor; } IPv6NeighbourCache::Neighbour *IPv6NeighbourCache::addNeighbour(const IPv6Address& addr, int interfaceID, MACAddress macAddress) { Key key(addr, interfaceID); ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet Neighbour& nbor = neighbourMap[key]; nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience. nbor.macAddress = macAddress; nbor.isRouter = false; nbor.isDefaultRouter = false; nbor.reachabilityState = STALE; nbor.reachabilityExpires = 0; nbor.numProbesSent = 0; nbor.nudTimeoutEvent = NULL; nbor.routerExpiryTime = 0; return &nbor; } /** Creates and initializes a router entry (isRouter=isDefaultRouter=true), state=INCOMPLETE. */ IPv6NeighbourCache::Neighbour *IPv6NeighbourCache::addRouter(const IPv6Address& addr, int interfaceID, simtime_t expiryTime) { Key key(addr, interfaceID); ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet Neighbour& nbor = neighbourMap[key]; nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience. nbor.isRouter = true; nbor.isDefaultRouter = true;//FIXME: a router may advertise itself it self as a router but not as a default one.-WEI nbor.reachabilityState = INCOMPLETE; nbor.reachabilityExpires = 0; nbor.numProbesSent = 0; nbor.nudTimeoutEvent = NULL; nbor.routerExpiryTime = expiryTime; return &nbor; } /** Creates and initializes a router entry (isRouter=isDefaultRouter=true), MAC address and state=STALE. */ IPv6NeighbourCache::Neighbour *IPv6NeighbourCache::addRouter(const IPv6Address& addr, int interfaceID, MACAddress macAddress, simtime_t expiryTime) { Key key(addr, interfaceID); ASSERT(neighbourMap.find(key)==neighbourMap.end()); // entry must not exist yet Neighbour& nbor = neighbourMap[key]; nbor.nceKey = lookupKeyAddr(key);//a ptr that links to the key.-WEI for convenience. nbor.macAddress = macAddress; nbor.isRouter = true; nbor.isDefaultRouter = true; nbor.reachabilityState = STALE; nbor.reachabilityExpires = 0; nbor.numProbesSent = 0; nbor.nudTimeoutEvent = NULL; nbor.routerExpiryTime = expiryTime; return &nbor; } void IPv6NeighbourCache::remove(const IPv6Address& addr, int interfaceID) { Key key(addr, interfaceID); NeighbourMap::iterator it = neighbourMap.find(key); ASSERT(it!=neighbourMap.end()); // entry must exist delete it->second.nudTimeoutEvent; neighbourMap.erase(it); } void IPv6NeighbourCache::remove(NeighbourMap::iterator it) { delete it->second.nudTimeoutEvent; neighbourMap.erase(it); } const char *IPv6NeighbourCache::stateName(ReachabilityState state) { switch (state) { case INCOMPLETE: return "INCOMPLETE"; case REACHABLE: return "REACHABLE"; case STALE: return "STALE"; case DELAY: return "DELAY"; case PROBE: return "PROBE"; default: return "???"; } }
4c734dacf667c85c3a88c02bce9ba9e480f9b60f
7b00c6e83083727e455e40cbfc00b2fc035f6f86
/shaka/src/media/audio_renderer_common.cc
01a4e1be5d4afdba701baf208074bab90b4c04f8
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
nextsux/shaka-player-embedded
150ad30ce2dda8c1552027022cd185f2d0c78c40
dccd0bbe7f326e73ef4841700b9a65ded6353564
refs/heads/master
2023-01-08T05:17:09.681606
2020-10-23T21:49:30
2020-10-23T21:59:03
310,596,930
0
0
NOASSERTION
2020-11-06T12:53:50
2020-11-06T12:53:50
null
UTF-8
C++
false
false
10,363
cc
audio_renderer_common.cc
// Copyright 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 // // https://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 "src/media/audio_renderer_common.h" #include <algorithm> #include <cstring> #include <functional> #include <vector> namespace shaka { namespace media { namespace { /** The number of seconds to buffer ahead of the current time. */ const double kBufferTarget = 2; /** The minimum difference, in seconds, to introduce silence or drop frames. */ const double kSyncLimit = 0.1; /** A buffer that contains silence. */ const uint8_t kSilenceBuffer[4096] = {0}; uint8_t BytesPerSample(std::shared_ptr<DecodedFrame> frame) { switch (get<SampleFormat>(frame->format)) { case SampleFormat::PackedU8: case SampleFormat::PlanarU8: return 1; case SampleFormat::PackedS16: case SampleFormat::PlanarS16: return 2; case SampleFormat::PackedS32: case SampleFormat::PlanarS32: return 4; case SampleFormat::PackedS64: case SampleFormat::PlanarS64: return 8; case SampleFormat::PackedFloat: case SampleFormat::PlanarFloat: return 4; case SampleFormat::PackedDouble: case SampleFormat::PlanarDouble: return 8; default: LOG(DFATAL) << "Unsupported sample format: " << frame->format; return 0; } } size_t BytesToSamples(std::shared_ptr<DecodedFrame> frame, size_t bytes) { size_t bytes_per_sample = BytesPerSample(frame) * frame->stream_info->channel_count; return bytes / bytes_per_sample; } double BytesToSeconds(std::shared_ptr<DecodedFrame> frame, size_t bytes) { return static_cast<double>(BytesToSamples(frame, bytes)) / frame->stream_info->sample_rate; } /** * Calculates the byte sync needed to play the next frame. * * @param prev_time The previous synchronized time. * @param bytes_written The number of bytes written since |prev_time|. * @param next The next frame to be played. * @return If positive, the number of bytes to skip in |next|; if negative, the * number of bytes of silence to play. */ int64_t GetSyncBytes(double prev_time, size_t bytes_written, std::shared_ptr<DecodedFrame> next) { const int64_t bytes_per_sample = BytesPerSample(next); const double buffer_end = prev_time + BytesToSeconds(next, bytes_written); // If the difference is small, just ignore for now. if (std::abs(buffer_end - next->pts) < kSyncLimit) return 0; // Round to whole samples before converting to bytes. const int64_t sample_delta = static_cast<int64_t>( (buffer_end - next->pts) * next->stream_info->sample_rate); return sample_delta * next->stream_info->channel_count * bytes_per_sample; } } // namespace AudioRendererCommon::AudioRendererCommon() : mutex_("AudioRendererCommon"), on_play_("AudioRendererCommon"), clock_(&util::Clock::Instance), player_(nullptr), input_(nullptr), volume_(1), muted_(false), needs_resync_(true), shutdown_(false), thread_("AudioRenderer", std::bind(&AudioRendererCommon::ThreadMain, this)) {} AudioRendererCommon::~AudioRendererCommon() { CHECK(shutdown_) << "Must call Stop before destroying"; thread_.join(); if (player_) player_->RemoveClient(this); } void AudioRendererCommon::SetPlayer(const MediaPlayer* player) { std::unique_lock<Mutex> lock(mutex_); if (player_) player_->RemoveClient(this); player_ = player; needs_resync_ = true; if (player) { player->AddClient(this); on_play_.SignalAllIfNotSet(); } } void AudioRendererCommon::Attach(const DecodedStream* stream) { std::unique_lock<Mutex> lock(mutex_); input_ = stream; needs_resync_ = true; if (stream) on_play_.SignalAllIfNotSet(); } void AudioRendererCommon::Detach() { std::unique_lock<Mutex> lock(mutex_); input_ = nullptr; SetDeviceState(/* is_playing= */ false); } double AudioRendererCommon::Volume() const { std::unique_lock<Mutex> lock(mutex_); return volume_; } void AudioRendererCommon::SetVolume(double volume) { std::unique_lock<Mutex> lock(mutex_); volume_ = volume; UpdateVolume(muted_ ? 0 : volume_); } bool AudioRendererCommon::Muted() const { std::unique_lock<Mutex> lock(mutex_); return muted_; } void AudioRendererCommon::SetMuted(bool muted) { std::unique_lock<Mutex> lock(mutex_); muted_ = muted; UpdateVolume(muted ? 0 : volume_); } void AudioRendererCommon::Stop() { { std::unique_lock<Mutex> lock(mutex_); shutdown_ = true; } on_play_.SignalAllIfNotSet(); } bool AudioRendererCommon::FillSilence(size_t bytes) { while (bytes > 0) { const size_t to_write = std::min(bytes, sizeof(kSilenceBuffer)); if (!AppendBuffer(kSilenceBuffer, to_write)) return false; bytes_written_ += to_write; bytes -= to_write; } return true; } bool AudioRendererCommon::IsFrameSimilar( std::shared_ptr<DecodedFrame> frame1, std::shared_ptr<DecodedFrame> frame2) const { return frame1 && frame2 && frame1->stream_info == frame2->stream_info && frame1->format == frame2->format; } bool AudioRendererCommon::WriteFrame(std::shared_ptr<DecodedFrame> frame, size_t sync_bytes) { if (IsPlanarFormat(frame->format)) { // We need to pack the samples into a single array. // Before: // data[0] -> | 1A | 1B | 1C | // data[1] -> | 2A | 2B | 2C | // After: // data -> | 1A | 2A | 1B | 2B | 1C | 2C | const size_t channel_count = frame->stream_info->channel_count; const size_t sample_size = BytesPerSample(frame); const size_t sample_count = frame->linesize[0] / sample_size; const size_t per_channel_sync = sync_bytes / channel_count; const size_t skipped_samples = per_channel_sync / sample_size; if (sample_count > skipped_samples) { std::vector<uint8_t> temp(frame->linesize[0] * channel_count - sync_bytes); uint8_t* output = temp.data(); for (size_t sample = skipped_samples; sample < sample_count; sample++) { for (size_t channel = 0; channel < channel_count; channel++) { std::memcpy(output, frame->data[channel] + sample * sample_size, sample_size); output += sample_size; } } if (!AppendBuffer(temp.data(), temp.size())) return false; bytes_written_ += temp.size(); } } else { if (frame->linesize[0] > sync_bytes) { if (!AppendBuffer(frame->data[0] + sync_bytes, frame->linesize[0] - sync_bytes)) { return false; } bytes_written_ += frame->linesize[0] - sync_bytes; } } return true; } void AudioRendererCommon::SetClock(const util::Clock* clock) { clock_ = clock; } void AudioRendererCommon::ThreadMain() { std::unique_lock<Mutex> lock(mutex_); while (!shutdown_) { if (!player_ || !input_) { on_play_.ResetAndWaitWhileUnlocked(lock); continue; } // TODO(#15): Support playback rate. For the moment, mute audio. const bool is_playing = player_->PlaybackRate() == 1 && player_->PlaybackState() == VideoPlaybackState::Playing; SetDeviceState(is_playing); if (!is_playing) { on_play_.ResetAndWaitWhileUnlocked(lock); continue; } double time = player_->CurrentTime(); const size_t buffered_bytes = GetBytesBuffered(); std::shared_ptr<DecodedFrame> next; if (needs_resync_ || !cur_frame_) { ClearBuffer(); next = input_->GetFrame(time, FrameLocation::Near); } else { const double buffered_extra = BytesToSeconds(cur_frame_, buffered_bytes) - kBufferTarget; if (buffered_extra > 0) { util::Unlocker<Mutex> unlock(&lock); clock_->SleepSeconds(buffered_extra); continue; } next = input_->GetFrame(cur_frame_->pts, FrameLocation::After); } if (!next) { util::Unlocker<Mutex> unlock(&lock); clock_->SleepSeconds(0.1); continue; } if (!IsFrameSimilar(cur_frame_, next)) { // If we've changed to another stream, reset the audio device to the new // stream. if (cur_frame_) { // Try to play out the existing buffer since resetting will clear the // buffer. const double buffered = BytesToSeconds(cur_frame_, buffered_bytes); const double delay = std::max(buffered - 0.1, 0.0); util::Unlocker<Mutex> unlock(&lock); clock_->SleepSeconds(delay); if (shutdown_) return; time = player_->CurrentTime(); } if (!InitDevice(next, muted_ ? 0 : volume_)) return; SetDeviceState(/* is_playing= */ true); needs_resync_ = true; } int64_t sync_bytes; if (needs_resync_ || !cur_frame_) { sync_bytes = GetSyncBytes(time, 0, next); sync_time_ = time; bytes_written_ = 0; } else { sync_bytes = GetSyncBytes(sync_time_, bytes_written_, next); } if (sync_bytes < 0) { if (!FillSilence(-sync_bytes)) return; sync_bytes = 0; } if (!WriteFrame(next, sync_bytes)) return; cur_frame_ = next; needs_resync_ = false; } } void AudioRendererCommon::OnPlaybackStateChanged(VideoPlaybackState old_state, VideoPlaybackState new_state) { std::unique_lock<Mutex> lock(mutex_); needs_resync_ = true; on_play_.SignalAllIfNotSet(); } void AudioRendererCommon::OnPlaybackRateChanged(double old_rate, double new_rate) { std::unique_lock<Mutex> lock(mutex_); needs_resync_ = true; on_play_.SignalAllIfNotSet(); } void AudioRendererCommon::OnSeeking() { std::unique_lock<Mutex> lock(mutex_); needs_resync_ = true; on_play_.SignalAllIfNotSet(); } } // namespace media } // namespace shaka
9f2ef8e54002d3cfce40cde6d57eb7284455b582
492976adfdf031252c85de91a185bfd625738a0c
/src/Game/AI/Action/actionSandwormNavMove.cpp
22d67da6715a4d6ec3ef53b4fadf90fb25cfe957
[]
no_license
zeldaret/botw
50ccb72c6d3969c0b067168f6f9124665a7f7590
fd527f92164b8efdb746cffcf23c4f033fbffa76
refs/heads/master
2023-07-21T13:12:24.107437
2023-07-01T20:29:40
2023-07-01T20:29:40
288,736,599
1,350
117
null
2023-09-03T14:45:38
2020-08-19T13:16:30
C++
UTF-8
C++
false
false
1,045
cpp
actionSandwormNavMove.cpp
#include "Game/AI/Action/actionSandwormNavMove.h" namespace uking::action { SandwormNavMove::SandwormNavMove(const InitArg& arg) : NavMeshMoveWithAS(arg) {} SandwormNavMove::~SandwormNavMove() = default; bool SandwormNavMove::init_(sead::Heap* heap) { return NavMeshMoveWithAS::init_(heap); } void SandwormNavMove::enter_(ksys::act::ai::InlineParamPack* params) { NavMeshMoveWithAS::enter_(params); } void SandwormNavMove::leave_() { NavMeshMoveWithAS::leave_(); } void SandwormNavMove::loadParams_() { NavMeshMoveWithAS::loadParams_(); getStaticParam(&mTargetSandOffset_s, "TargetSandOffset"); getStaticParam(&mSandOffsetSpeed_s, "SandOffsetSpeed"); getStaticParam(&mVibrateStopCheck_s, "VibrateStopCheck"); getStaticParam(&mVibrateCheckFrame_s, "VibrateCheckFrame"); getStaticParam(&mVibrateMemoryStep_s, "VibrateMemoryStep"); getAITreeVariable(&mRefPosVibrateChecker_a, "RefPosVibrateChecker"); } void SandwormNavMove::calc_() { NavMeshMoveWithAS::calc_(); } } // namespace uking::action
9f6b1a4eaad702e1d9f323b0a8a76ec7967b6dbe
9f170204f6976fe59d9ee74aa78f62b10663c051
/third_party/sputnik/sputnik/sddmm/dense_to_shared.h
d59e879ced7bee68beb9be4edb0aadddb28b3e3d
[ "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause" ]
permissive
hercules261188/xformers
04132b4c94bfb59ea9917ccf29800a049f924da9
71bab94cb954e6e291ca93d3bce5dffadab4286d
refs/heads/main
2023-09-06T02:51:47.086611
2021-11-24T16:36:22
2021-11-24T16:36:22
431,593,450
1
0
NOASSERTION
2021-11-24T18:43:24
2021-11-24T18:43:23
null
UTF-8
C++
false
false
3,238
h
dense_to_shared.h
// Copyright 2020 The Sputnik 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 THIRD_PARTY_SPUTNIK_SDDMM_DENSE_TO_SHARED_H_ #define THIRD_PARTY_SPUTNIK_SDDMM_DENSE_TO_SHARED_H_ namespace sputnik { template <typename LoadType, int kBlockItemsK, int kBlockWidth> struct DenseToShared { static_assert(kBlockItemsK >= kBlockWidth, "Sparse tile K-items must be >= thread block width."); static_assert(kBlockItemsK % kBlockWidth == 0, "Sparse tile K-items must be divisible by block width."); static_assert((sizeof(LoadType) / sizeof(float)) <= (kBlockItemsK / kBlockWidth), "The number of values per load must be <= values per thread."); // /// Static members. // // The number of values that will be loaded per-thread, per-load. static constexpr int kValuesPerLoad_ = sizeof(LoadType) / sizeof(float); // The number of data items in the k-dimension that each thread owns. static constexpr int kThreadItemsK_ = kBlockItemsK / kBlockWidth / kValuesPerLoad_; // /// Member variables. // // Pointer to the dense matrix in global memory. const LoadType *matrix_; // Register file framgnet for the loaded values. LoadType *matrix_fragment_; /** * @brief Set the initial pointer offsets. */ __device__ __forceinline__ DenseToShared(int k, int m_index, const float *matrix, float *matrix_fragment) { matrix_ = reinterpret_cast<const LoadType *>(matrix + m_index * k) + threadIdx.x; matrix_fragment_ = reinterpret_cast<LoadType *>(matrix_fragment); } /** * @brief Strip-mine a 1-dimensional tile from the matrix. */ __device__ __forceinline__ void Load() { #pragma unroll for (int k_item_idx = 0; k_item_idx < kThreadItemsK_; ++k_item_idx) { // Load the values into smem. Store(sputnik::Load(matrix_), matrix_fragment_ + k_item_idx); // Increment our pointers for the next iteration. matrix_ += kBlockWidth; } } /** * @brief Loads any residual elements from the matrix. */ __device__ __forceinline__ void Residue(int residue) { const LoadType *matrix = matrix_; #pragma unroll for (int k_item_idx = 0; k_item_idx < kThreadItemsK_; ++k_item_idx) { if (residue > 0) { // Load the values into smem. Store(sputnik::Load(matrix), matrix_fragment_ + k_item_idx); } // Increment our pointer & value index for the next iteration. matrix += kBlockWidth; residue -= kBlockWidth * kValuesPerLoad_; } } }; } // namespace sputnik #endif // THIRD_PARTY_SPUTNIK_SDDMM_DENSE_TO_SHARED_H_
e4d41f7bcc7830c5715da19e30d7f69ad8d2b221
37c502120aba6e719a2977d8ce78c44846adeb63
/CG Programs/CUBE.CPP
4a6e17e59f44a45ea5b93277ff75cd6fa3b5e39a
[]
no_license
Girrajjangid/Computer-Science-Programs
66cdccb1f17bc74893614eb5e02acba7bde14885
8d8c2be72661e42aa12f78fbb6eafdce0f18fe55
refs/heads/master
2020-06-09T23:10:04.027394
2019-11-03T17:24:23
2019-11-03T17:24:23
193,525,230
3
0
null
null
null
null
UTF-8
C++
false
false
752
cpp
CUBE.CPP
#include<graphics.h> #include<conio.h> #include<dos.h> void main(){ int i,gd=DETECT,gm,x=10; initgraph(&gd,&gm,""); setcolor(WHITE); rectangle(120,120,280,280); setfillstyle(SOLID_FILL,RED); floodfill(150,200,WHITE); line(80,160,120,120); for(i=0;i<200;i+=160)line(80+i,320,120+i,280); for(i=0;i<120;i+=40)line(120,160+i,280,160+i); for(i=0;i<120;i+=40)line(160+i,120,160+i,280); line(80,160,80,320);line(80,320,240,320); setfillstyle(SOLID_FILL,BLUE); floodfill(150,300,WHITE); for(i=0;i<40;i+=10)line(120-i,280+i,280-i,280+i); for(i=0;i<120;i+=40)line(160+i,280,120+i,320); setfillstyle(SOLID_FILL,GREEN); floodfill(100,200,WHITE); for(i=0;i<120;i+=40)line(120,160+i,80,200+i); for(i=0;i<30;i+=10)line(90+i,150-i,90+i,310-i); getch(); closegraph(); }
7feb254293f8c1e2b56a0dbc8960a93d103d2419
7076aa19779731c29ef4729b89afddec2e3fc999
/src/containers/tree.test.cpp
ed35c9aa228708cafe23a146eac0387c31aa13bc
[]
no_license
MatMyfta/SistemiOperativi
8ca7266274f8bc48de5578b3c492e0f383d542f3
befb6d4ed098deea0abc8bd664790d06f5677176
refs/heads/master
2022-10-19T21:14:55.458039
2020-06-09T21:40:19
2020-06-09T21:40:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,273
cpp
tree.test.cpp
/** * \file dictionary.test.cpp * * \brief Test dictionary */ #include "tree.h" #include "catch2/catch.hpp" #include <vector> template <typename T> int compare(const void *lhs, const void *rhs, void *user_data) { const T *lhs_val = reinterpret_cast<const T *>(lhs); const T *rhs_val = reinterpret_cast<const T *>(rhs); if (*lhs_val < *rhs_val) { return -1; } else if (*lhs_val == *rhs_val) { return 0; } else { return 1; } }; TEST_CASE("Tree", "[containers][tree]") { unitnos_tree *tree = unitnos_tree_create(compare<int>, nullptr, nullptr); SECTION("Value insertion") { std::vector<int> values = {2, 1, 3}; REQUIRE(unitnos_tree_size(tree) == 0); size_t i = 0; for (auto &val : values) { unitnos_tree_insert(tree, &val); ++i; REQUIRE(unitnos_tree_size(tree) == i); } REQUIRE(unitnos_tree_size(tree) == values.size()); } GIVEN("A tree filled with values") { std::vector<int> values = {2, 1, 3}; for (auto &val : values) { unitnos_tree_insert(tree, &val); } SECTION("for each order") { std::vector<int> v; unitnos_tree_foreach( tree, [](void *val, void *v) { std::vector<int> *vec = reinterpret_cast<std::vector<int> *>(v); vec->push_back(*((int *)val)); return false; }, &v); REQUIRE(v[0] == 1); REQUIRE(v[1] == 2); REQUIRE(v[2] == 3); } SECTION("lookup") { int n = 2; void *val = unitnos_tree_lookup(tree, &n); REQUIRE(val != &n); REQUIRE(val == &values[0]); n = 5; val = unitnos_tree_lookup(tree, &n); REQUIRE(val == nullptr); } SECTION("contains") { int n = 2; bool contains = unitnos_tree_contains(tree, &n); REQUIRE(contains); n = 123; contains = unitnos_tree_contains(tree, &n); REQUIRE_FALSE(contains); } SECTION("Value removal") { unitnos_tree_remove(tree, &values[0]); REQUIRE(unitnos_tree_size(tree) == 2); unitnos_tree_remove(tree, &values[1]); REQUIRE(unitnos_tree_size(tree) == 1); unitnos_tree_remove(tree, &values[2]); REQUIRE(unitnos_tree_size(tree) == 0); } } unitnos_tree_destroy(tree); }
0a356d2ab34b6f8207b762ca099a323a9171a3c8
72ca3c783d4946c361c7adc1ee0e728a46337d5b
/configs/RscDisplayPublishMissionSelectTags.cpp
3490cb46668715628a7ba114098db7c0cee16794
[]
no_license
pennyworth12345/ContactConfigCompare
bedad3c99a097509aa2fe676a07f6e3850b62aec
e871366e36c80ad339aaab512b87b69bfe323040
refs/heads/master
2020-07-03T17:49:12.394661
2019-08-12T19:15:33
2019-08-12T19:15:33
201,992,619
2
1
null
null
null
null
UTF-8
C++
false
false
3,686
cpp
RscDisplayPublishMissionSelectTags.cpp
class RscDisplayPublishMissionSelectTags { idd = 166; onLoad = "[""onLoad"",_this,""RscDisplayPublishMissionSelectTags"",'GUI'] call (uinamespace getvariable 'BIS_fnc_initDisplay')"; onUnload = "[""onUnload"",_this,""RscDisplayPublishMissionSelectTags"",'GUI'] call (uinamespace getvariable 'BIS_fnc_initDisplay')"; scriptName = "RscDisplayPublishMissionSelectTags"; scriptPath = "GUI"; class controls { class Add: ctrlActivePictureKeepAspect { h = "( 80 - (5 * 5 - 1)) * 0.25 * (pixelH * pixelGrid * 0.50)"; idc = 103; text = "\A3\Ui_f\data\GUI\RscCommon\RscHTML\arrow_right_ca.paa"; w = "( 80 * 2/20) * (pixelW * pixelGrid * 0.50)"; x = "((getResolution select 2) * 0.5 * pixelW) - ( 80 * 1/20) * (pixelW * pixelGrid * 0.50)"; y = "0.5 - ( 80 * 0.25) * (pixelH * pixelGrid * 0.50)"; }; class Cancel: ctrlButtonCancel { h = "5 * (pixelH * pixelGrid * 0.50)"; w = "25 * (pixelW * pixelGrid * 0.50)"; x = "((getResolution select 2) * 0.5 * pixelW) + ( 80 * 0.5 - 25 - 1) * (pixelW * pixelGrid * 0.50)"; y = "0.5 + ( 80 * 0.5 - (2 * 5 + 1)) * (pixelH * pixelGrid * 0.50)"; }; class Next: Previous { idc = 105; text = "Next"; w = "( 80 * 0.5 - 1) * (pixelW * pixelGrid * 0.50)"; x = "((getResolution select 2) * 0.5 * pixelW)"; }; class OK: ctrlButtonOK { h = "5 * (pixelH * pixelGrid * 0.50)"; w = "25 * (pixelW * pixelGrid * 0.50)"; x = "((getResolution select 2) * 0.5 * pixelW) + ( 80 * 0.5 - 50 - 2) * (pixelW * pixelGrid * 0.50)"; y = "0.5 + ( 80 * 0.5 - (2 * 5 + 1)) * (pixelH * pixelGrid * 0.50)"; }; class Previous: ctrlButton { h = "5 * (pixelH * pixelGrid * 0.50)"; idc = 106; text = "Back"; w = "( 80 * 0.5 - 2) * (pixelW * pixelGrid * 0.50)"; x = "((getResolution select 2) * 0.5 * pixelW) - ( 80 * 0.5 - 1) * (pixelW * pixelGrid * 0.50)"; y = "0.5 + ( 80 * 0.5 - (3 * 5 + 2.5)) * (pixelH * pixelGrid * 0.50)"; }; class Remove: Add { idc = 104; text = "\A3\Ui_f\data\GUI\RscCommon\RscHTML\arrow_left_ca.paa"; y = 0.5; }; class TitleMain: ctrlStaticTitle { h = "5 * (pixelH * pixelGrid * 0.50)"; idc = 107; text = "Edit Tags"; w = "80 * (pixelW * pixelGrid * 0.50)"; x = "((getResolution select 2) * 0.5 * pixelW) - ( 80 * 0.5) * (pixelW * pixelGrid * 0.50)"; y = "0.5 - ( 80 * 0.5 - 5) * (pixelH * pixelGrid * 0.50)"; }; class Unused: ctrlListbox { h = "( 80 - (6 * 5 - 1)) * (pixelH * pixelGrid * 0.50)"; idc = 101; w = "( 80 * 17/40) * (pixelW * pixelGrid * 0.50)"; x = "((getResolution select 2) * 0.5 * pixelW) - ( 80 * 0.5 - 1) * (pixelW * pixelGrid * 0.50)"; y = "0.5 - ( 80 * 0.5 - 11) * (pixelH * pixelGrid * 0.50)"; }; class Used: Unused { idc = 102; x = "((getResolution select 2) * 0.5 * pixelW) + ( 80 * 3/40 - 1) * (pixelW * pixelGrid * 0.50)"; }; }; class controlsBackground { class Background: ctrlStaticBackground { h = "( 80 - (10 + 5)) * (pixelH * pixelGrid * 0.50)"; w = "80 * (pixelW * pixelGrid * 0.50)"; x = "((getResolution select 2) * 0.5 * pixelW) - ( 80 * 0.5) * (pixelW * pixelGrid * 0.50)"; y = "0.5 - ( 80 * 0.5 - 10) * (pixelH * pixelGrid * 0.50)"; }; class BackgroundButtons: ctrlStaticFooter { h = "( 5 + 2) * (pixelH * pixelGrid * 0.50)"; w = "80 * (pixelW * pixelGrid * 0.50)"; x = "((getResolution select 2) * 0.5 * pixelW) - ( 80 * 0.5) * (pixelW * pixelGrid * 0.50)"; y = "0.5 + ( 80 * 0.5 - 2 * ( 5 + 1)) * (pixelH * pixelGrid * 0.50)"; }; class BackgroundDisable: ctrlStaticBackgroundDisable {}; class BackgroundDisableTiles: ctrlStaticBackgroundDisableTiles {}; }; };
5c25800ef1e9bded074c09935eca1bb8776232c1
55e7b4fe03859a35b8e9c3fb00ae61c147b0dc9b
/Lecture_BDD/lectureprofile.h
01781098aeb15657debbe92cfb6462b4b5ea10f5
[]
no_license
brock37/Mordheim
30f6322b1dedea3ecbf4a6b280bc57c206f4a6d1
87b2325e91953ca93a3ab3acdd80801365f27867
refs/heads/master
2020-12-24T13:36:44.095129
2016-04-22T21:59:52
2016-04-22T21:59:52
39,340,041
0
0
null
null
null
null
UTF-8
C++
false
false
835
h
lectureprofile.h
#ifndef LECTUREPROFILE_H #define LECTUREPROFILE_H #include <QWidget> #include <QtSql> #include <QSqlTableModel> #include <QSqlQueryModel> #include <QSqlQuery> #include <QSqlError> #include <QMessageBox> namespace Ui { class LectureProfile; } class LectureProfile : public QWidget { Q_OBJECT public: explicit LectureProfile(QWidget *parent = 0, QSqlDatabase *dataBase=0); ~LectureProfile(); void rafraichirTableauCapa(QString currentProfil); void changementRegles(QString nom); public slots: void changementProfil(QModelIndex index); void changementRace(QString newRace); void changerTexteRegles(QModelIndex index); private: Ui::LectureProfile *ui; QSqlQueryModel *model; QSqlQueryModel *modelCapa; QSqlQueryModel *modelRegles; QSqlDatabase *db; }; #endif // LECTUREPROFILE_H