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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4416c6960b96d9d67d22a0a6be3383f989cfee6c
|
185cd525eac144f99216e2f0079163fe52ec19c9
|
/src/main/cpp/rocketmq/include/ConsumeMessageServiceBase.h
|
50173a578dde58dd93b319bb4127a824710c1785
|
[
"Apache-2.0"
] |
permissive
|
aaron-ai/rocketmq-client-cpp
|
a03d5bf509e53d2a00ea4f9ddf1b367c59e2480f
|
55bccfc35e57b9989bcba0df28414ed331f9f0ac
|
refs/heads/main
| 2023-08-20T07:14:36.935701
| 2021-10-18T05:49:41
| 2021-10-18T05:49:41
| 418,398,558
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,026
|
h
|
ConsumeMessageServiceBase.h
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <memory>
#include <mutex>
#include <string>
#include <system_error>
#include "absl/container/flat_hash_map.h"
#include "ConsumeMessageService.h"
#include "RateLimiter.h"
#include "ThreadPool.h"
#include "rocketmq/State.h"
ROCKETMQ_NAMESPACE_BEGIN
class PushConsumer;
class ConsumeMessageServiceBase : public ConsumeMessageService {
public:
ConsumeMessageServiceBase(std::weak_ptr<PushConsumer> consumer, int thread_count, MessageListener* message_listener);
~ConsumeMessageServiceBase() override = default;
/**
* Make it noncopyable.
*/
ConsumeMessageServiceBase(const ConsumeMessageServiceBase& other) = delete;
ConsumeMessageServiceBase& operator=(const ConsumeMessageServiceBase& other) = delete;
/**
* Start the dispatcher thread, which will dispatch messages in process queue to thread pool in form of runnable
* functor.
*/
void start() override;
/**
* Stop the dispatcher thread and then reset the thread pool.
*/
void shutdown() override;
/**
* Signal dispatcher thread to check new pending messages.
*/
void signalDispatcher() override;
/**
* Set throttle threshold per topic.
*
* @param topic
* @param threshold
*/
void throttle(const std::string& topic, std::uint32_t threshold) override;
bool hasConsumeRateLimiter(const std::string& topic) const LOCKS_EXCLUDED(rate_limiter_table_mtx_);
std::shared_ptr<RateLimiter<10>> rateLimiter(const std::string& topic) const LOCKS_EXCLUDED(rate_limiter_table_mtx_);
protected:
RateLimiterObserver rate_limiter_observer_;
mutable absl::flat_hash_map<std::string, std::shared_ptr<RateLimiter<10>>>
rate_limiter_table_ GUARDED_BY(rate_limiter_table_mtx_);
mutable absl::Mutex rate_limiter_table_mtx_; // Protects rate_limiter_table_
std::atomic<State> state_;
int thread_count_;
std::unique_ptr<ThreadPool> pool_;
std::weak_ptr<PushConsumer> consumer_;
absl::Mutex dispatch_mtx_;
std::thread dispatch_thread_;
absl::CondVar dispatch_cv_;
MessageListener* message_listener_;
/**
* Dispatch messages to thread pool. Implementation of this function should be sub-class specific.
*/
void dispatch();
};
ROCKETMQ_NAMESPACE_END
|
5048aea20171318b264fb2bb715d8a4aa6f952a4
|
39a60b59c69c7f2abdf6cbdc4ca9386b9ade71bb
|
/ch8/8_1/main.cpp
|
44f610d6710baae2808df67522b4221b922efbcc
|
[] |
no_license
|
RaneWouters/oop
|
7d8d26567e9c8282b20cfd07c092acfff67cf69b
|
6e58703139d607f3d121554d79db7ddf72ae8ac3
|
refs/heads/master
| 2023-04-08T05:49:54.904983
| 2021-04-29T10:59:23
| 2021-04-29T10:59:23
| 346,638,006
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 715
|
cpp
|
main.cpp
|
#include <iostream>
#include <vector>
#include "MyVector.h"
using namespace std;
int main() {
int temp[] = {1, 2, 3, 4};
MyVector<int> vec_temp(temp, sizeof(temp) / sizeof(int));
MyVector<int> vec_user(vec_temp);
vec_temp.insert(2, 20);
vec_temp.insert(2, 30);
vec_temp.erase(2);
vec_temp.clear();
vec_temp.show();
cout << vec_temp.size() << endl;
vec_user.show();
MyVector<int> vec_user2;
vec_user2 = vec_user;
vec_user2.show();
cout << vec_user2.size() << endl;
cout << endl;
cout << vec_user2.at(2) << endl;
cout << vec_user2.size() << endl;
cout << vec_user2.back() << endl;
cout << vec_user2.front() << endl;
return 0;
}
|
b44977fb5bcb3b99cf4f27d48661586f689d8ead
|
577f1e401ca4c7b13325c603e511c77dbf033589
|
/src/AlgoDPath.cpp
|
cd800ae9565f464211ffe34aa66395fd1f64de75
|
[] |
no_license
|
hdd-robot/MPAL
|
0c35adef852374a28ad79df4dd061141c118db7d
|
97a2041d823728a1dfeecc8a48eb37870fe5d14e
|
refs/heads/master
| 2023-09-03T14:24:27.093210
| 2021-11-15T10:23:32
| 2021-11-15T10:23:32
| 289,668,393
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,262
|
cpp
|
AlgoDPath.cpp
|
/*
* AlgoDPath.cpp
*
* Created on: 20 mai 2020
* Author: Halim Djerroud <hdd@ai.univ-paris8.fr>
*/
#include "AlgoDPath.h"
namespace mpal {
AlgoDPath::AlgoDPath(EnvironmentContinue *env) :
AlgoContEnvBased(env) {
algoName = AlgoType::D_PATH;
}
AlgoDPath::~AlgoDPath() {
if(lidar_ptr != nullptr){
delete lidar_ptr;
}
}
bool AlgoDPath::init() {
return (true);
}
bool AlgoDPath::step() {
return (true);
}
void AlgoDPath::add_scan_lines() {
if(lidar_ptr == nullptr){
return;
}
lst_scan_lines.clear();
for(auto elem : lidar_ptr->getLstPoints()){
int p1_x = lidar_ptr->getPosx();
int p1_y = lidar_ptr->getPosy();
int p2_x = lidar_ptr->getPosx() + elem.first ;
int p2_y = lidar_ptr->getPosy() + elem.second;
lst_scan_lines.push_back(Line(Point(p1_x,p1_y),Point(p2_x,p2_y)));
}
}
bool AlgoDPath::run() {
std::cout << " run D PATH " << std::endl;
environment->set_robot_pos(environment->getStartPosX(),environment->getStartPosY());
int r_posx = environment->getRobotPosX();
int r_posy = environment->getRobotPosY();
radius_laser_scan = 150;
sample_laser_scan = 180;
// create lidar
lidar_ptr = new Lidar(environment,r_posx,r_posy,radius_laser_scan);
lidar_ptr->setSample(sample_laser_scan);
double dx = abs(environment->getRobotPosX() - environment->getGoalPosY());
double dy = abs(environment->getRobotPosX() - environment->getGoalPosY());
graph.add_start_vtx(std::make_pair(environment->getStartPosX(),environment->getStartPosY()));
graph.add_goal_vtx(std::make_pair(environment->getGoalPosX(),environment->getGoalPosY()));
while(!(graph.goal_is_reached())){
std::cout << " -- while D_PATH"<< std::endl ;
r_posx = environment->getRobotPosX();
r_posy = environment->getRobotPosY();
lidar_ptr->move(r_posx,r_posy);
std::vector<double> datascan = lidar_ptr->scan();
std::vector<Angle>lst_angl = get_angles_obj(datascan);
std::vector<Angle>lst_path = get_angles_path(lst_angl);
std::vector<std::pair<int,int>>lst_way_point = add_waypoints(lst_path,r_posx,r_posy);
add_scan_lines();
notify();
for(auto elem: lst_way_point){
graph.add_waypoint_vertex(elem);
}
int id_next = graph.get_next_vertex();
graph.set_robot_pos(id_next);
environment->set_robot_pos(graph.get_pos_x(id_next),graph.get_pos_y(id_next));
graph.trace_graph();
// get lines to display
sleep(3);
}
notify();
std::cout << "END DPATH" << std::endl ;
// std::cout << "lst_way_point" << std::endl ;
// for(auto elem : lst_way_point){
// std::cout << elem.first << "," << elem.second << std::endl ;
// }
// std::cout << "end__lst_way_point" << std::endl ;
// std::cout << "lst_scan_lines" << std::endl ;
// for(auto elem : lst_scan_lines){
// std::cout << "("<<elem.getPointStart().getPosX() << "," << elem.getPointStart().getPosY() << "),("<< elem.getPointEnd().getPosX() << "," << elem.getPointEnd().getPosY()<<")" << std::endl ;
// }
// std::cout << "end__lst_scan_lines" << std::endl ;
std::cout << std::endl ;
sleep(1000);
return (true);
}
/**
* \brief get list of Angles Objects
* @param lst_laser_scan
* @return list of Angles
*/
std::vector<Angle> AlgoDPath::get_angles_obj(std::vector<double> lst_laser_scan) {
std::vector<Angle> list_angles;
//Interval pour dire que deux objet sont présents
double max_interval =25.0;
std::vector<double>::iterator it_m = std::min_element(lst_laser_scan.begin(),lst_laser_scan.end());
//Si aucun chemin à améliorer : escargo , labyrith
if(*(std::max_element(lst_laser_scan.begin(),lst_laser_scan.end())) != std::numeric_limits<double>::infinity()){
return (list_angles);
}
// Si y a pas d'obstacles alors on retour un seul élément
if(*it_m == std::numeric_limits<double>::infinity()){
list_angles.push_back(Angle(1,0,2*M_PI, radius_laser_scan,radius_laser_scan,2*M_PI));
return (list_angles);
}
int it_min = it_m - lst_laser_scan.begin();
int it_beg = 0 ;
int it_end = sample_laser_scan - 1 ;
int count = 0 ;
while (lst_laser_scan[it_min] != std::numeric_limits<double>::infinity()){
int it_l = it_min-1;
int it_r = it_min+1;
while (true){
if (it_l < it_beg){
break;
}
if (abs(lst_laser_scan[it_l] - lst_laser_scan[it_l + 1]) >= max_interval){
break;
}
it_l = it_l - 1;
}
while (true){
if (it_r > it_end){
break;
}
if (abs(lst_laser_scan[it_r] - lst_laser_scan[it_r - 1]) >= max_interval){
break;
}
it_r = it_r + 1;
}
count += 1;
// todo : min <--> max inversés
Angle a(count,
((it_l + 1) * 2 * M_PI) / float(sample_laser_scan),
((it_r - 1) * 2 * M_PI) / float(sample_laser_scan),
lst_laser_scan[it_l + 1],
lst_laser_scan[it_r - 1],
0);
list_angles.push_back(a);
while (it_l != it_r){
lst_laser_scan[it_l] = std::numeric_limits<double>::infinity();
it_l += 1;
}
it_min = std::min_element(lst_laser_scan.begin(),lst_laser_scan.end()) - lst_laser_scan.begin();
}
return (list_angles);
}
std::vector<Angle> AlgoDPath::get_angles_path(std::vector<Angle> lst_angles_obj) {
lst_angles_paths.clear();
if(lst_angles_obj.size()==0) {
return (lst_angles_paths);
}
std::sort(lst_angles_obj.begin(),lst_angles_obj.end());
std::vector<Angle>::iterator fst = lst_angles_obj.begin();
std::vector<Angle>::iterator lst = lst_angles_obj.end();
if (fst->id != std::next(lst, -1)->id){
if (fst->teta_min < (2 * M_PI / sample_laser_scan) and (lst->teta_max > ((2 * M_PI / sample_laser_scan) - (2 * M_PI)))){
lst->teta_max = fst->teta_max;
lst->teta_dist_max = fst->teta_dist_max;
fst = lst_angles_obj.erase(lst_angles_obj.begin());
}
}
else{
Angle a;
a.id = 1;
if (lst_angles_obj[0].teta_min < 0.1 and lst_angles_obj[0].teta_max > 6.0){
a.teta_max = lst_angles_obj[0].teta_max;
a.teta_min = lst_angles_obj[0].teta_min;
a.teta_dist_max = lst_angles_obj[0].teta_dist_max;
a.teta_dist_min = lst_angles_obj[0].teta_dist_min;
}
else {
a.teta_max = lst_angles_obj[0].teta_min;
a.teta_min = lst_angles_obj[0].teta_max;
a.teta_dist_max = lst_angles_obj[0].teta_dist_min;
a.teta_dist_min = lst_angles_obj[0].teta_dist_max;
}
lst_angles_paths.push_back(a);
return (lst_angles_paths);
}
int it_beg = 0;
int it_end = lst_angles_obj.size() ;//- 1;
int it_lst = it_beg;
int count = 0;
while (it_lst <= it_end){
Angle a;
count = count + 1;
a.id = count;
a.teta_min = lst_angles_obj[it_lst].teta_max;
a.teta_dist_min = lst_angles_obj[it_lst].teta_dist_max;
if (it_lst == it_end){
a.teta_max = lst_angles_obj[it_beg].teta_min;
a.teta_dist_max = lst_angles_obj[it_beg].teta_dist_min;
}
else{
a.teta_max = lst_angles_obj[it_lst + 1].teta_min;
a.teta_dist_max = lst_angles_obj[it_lst + 1].teta_dist_min;
}
lst_angles_paths.push_back(Angle(a.id, a.teta_min, a.teta_max, a.teta_dist_min, a.teta_dist_max, 0));
it_lst += 1;
}
return (lst_angles_paths);
}
std::vector<std::pair<int,int>> AlgoDPath::add_waypoints(std::vector<Angle>& lst_path, int posx, int posy) {
list_waypoints.clear();
double diff_teta;
int nbr_waypoints;
for (Angle& ang : lst_path){
double tmin = ang.teta_min;
double tmax = ang.teta_max;
if (ang.teta_min > ang.teta_max){
diff_teta = (2 * M_PI) - abs(ang.teta_max - ang.teta_min);
}
else{
diff_teta = abs(tmax - tmin);
}
ang.teta_diff = diff_teta;
nbr_waypoints = int(diff_teta / waypoint_interval);
if (nbr_waypoints == 0) {
nbr_waypoints = 1;
}
double point_f = tmin;
double step = (diff_teta) / (nbr_waypoints);
point_f = point_f + (step / 2);
for(int i=0 ; i< nbr_waypoints ; i++){
double p_rad = radius_laser_scan;
if((ang.teta_dist_min < radius_laser_scan - 5) || (ang.teta_dist_max < radius_laser_scan - 5)){
p_rad = ang.teta_dist_min + (ang.teta_dist_max - ang.teta_dist_min)/2;
}
std::complex<double> pointway(std::polar(static_cast<double>(p_rad), point_f));
//pointway = pointway + std::complex<double>(posx,-posy);
int px = posx + pointway.real();
int py = posy - pointway.imag();
ang.waypoints.push_back(std::make_pair(px, py));
list_waypoints.push_back(std::make_pair(px, py));
point_f = point_f + (step);
}
}
return(list_waypoints);
}
} /* namespace mpal */
|
5a0552272ddacb82f899d21b4c6651bdbbdfe4aa
|
f13d58b82ab70b42ff017432272e4e9fc3d8d99a
|
/online-judge/Luogu/Luogu 3919.cpp
|
3d2c23af5faae84e9dca5ac68a67435470444c57
|
[] |
no_license
|
WEGFan/Algorithm-Contest-Code
|
3586d6edba03165a9e243a10566fedcc6bcf1315
|
a5b53605c0ec7161d12d48335171763a2ddf12b0
|
refs/heads/master
| 2020-11-26T10:33:02.807386
| 2019-12-19T12:05:17
| 2019-12-19T12:05:17
| 229,043,842
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,903
|
cpp
|
Luogu 3919.cpp
|
#include <iostream>
using namespace std;
const int N = 1e6 + 7;
int arr[N];
int rt[N]; // root index
struct ChairmanTree
{
int tot = 0; // total nodes
struct Node
{
int l, r; // lson & rson node id
int val;
} tr[N * 24]; // (4 + logn) * n
int build(int l, int r)
{
int root = ++tot;
if (l == r)
{
tr[root].val = arr[l];
return root;
}
int mid = (l + r) >> 1;
tr[root].l = build(l, mid);
tr[root].r = build(mid + 1, r);
return root;
}
int update(int pre, int l, int r, int pos, int val)
{
int root = ++tot;
tr[root] = tr[pre];
if (l == r)
{
tr[root].val = val;
return root;
}
int mid = (l + r) >> 1;
if (pos <= mid)
tr[root].l = update(tr[pre].l, l, mid, pos, val);
else
tr[root].r = update(tr[pre].r, mid + 1, r, pos, val);
return root;
}
int query(int root, int l, int r, int pos)
{
if (l == r)
{
return tr[root].val;
}
int mid = (l + r) >> 1;
if (pos <= mid)
return query(tr[root].l, l, mid, pos);
else
return query(tr[root].r, mid + 1, r, pos);
}
} seg;
int main()
{
int n, m;
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; i++)
{
scanf("%d", &arr[i]);
}
rt[0] = seg.build(1, n);
for (int i = 1; i <= m; i++)
{
int v, op, pos;
scanf("%d %d %d", &v, &op, &pos);
if (op == 1)
{
int val;
scanf("%d", &val);
rt[i] = seg.update(rt[v], 1, n, pos, val);
}
else
{
int ans = seg.query(rt[v], 1, n, pos);
printf("%d\n", ans);
rt[i] = rt[v];
}
}
return 0;
}
|
b33d966009e285440a01f562ffa1b96a59d6afdb
|
a33aac97878b2cb15677be26e308cbc46e2862d2
|
/program_data/PKU_raw/92/218.c
|
187082842f880b0ca9da2901146c8063a6adef81
|
[] |
no_license
|
GabeOchieng/ggnn.tensorflow
|
f5d7d0bca52258336fc12c9de6ae38223f28f786
|
7c62c0e8427bea6c8bec2cebf157b6f1ea70a213
|
refs/heads/master
| 2022-05-30T11:17:42.278048
| 2020-05-02T11:33:31
| 2020-05-02T11:33:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,124
|
c
|
218.c
|
int compare(const void * elem1, const void * elem2)
{
return (*(int *)elem1 - *(int *)elem2);
}
int main()
{
int n;
int TJ[2001];
int QW[2001];
while(cin >> n && n != 0)
{
for (int i = 0; i < n; i ++)
cin >> TJ[i];
for (int i = 0; i < n; i ++)
cin >> QW[i];
qsort(TJ, n, sizeof(int), compare);
qsort(QW, n, sizeof(int), compare);
int Tslow, Tfast, Qslow, Qfast;
Tslow = Qslow = 0;
Tfast = Qfast = n - 1;
int bonus = 0;
while(Tslow <= Tfast && Qslow <= Qfast)
{
if (TJ[Tfast] > QW[Qfast])
{
Tfast --;
Qfast --;
bonus ++;
}
else if (TJ[Tfast] < QW[Qfast])
{
Tslow ++;
Qfast --;
if (TJ[Tslow - 1] < QW[Qfast + 1])
bonus --;
}
else
{
while(Tslow <= Tfast && Qslow <= Qfast)
{
if (TJ[Tslow] > QW[Qslow])
{
Tslow ++;
Qslow ++;
bonus ++;
}
else
{
Tslow ++;
Qfast --;
if (TJ[Tslow - 1] < QW[Qfast + 1])
bonus --;
break;
}
}
}
}
cout << bonus * 200 << endl;
}
return 0;
}
|
dc27e4dcd469f09c4e898b482519a0f177fae831
|
74562eccba8d1de27b6cfea66ff4ac494c4d4c42
|
/lineTable/StackAndQueue.cpp
|
83d97c5d5e1a4816f30539192379f6ba18a732e0
|
[] |
no_license
|
subicWang/data-structure
|
380d54a76aae281de9bb75ada98db1afe0331653
|
96f754c27e2b86efb06b7c6159abd9db086d42b9
|
refs/heads/master
| 2020-03-30T06:02:09.310758
| 2018-10-18T14:08:52
| 2018-10-18T14:08:52
| 150,834,749
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 817
|
cpp
|
StackAndQueue.cpp
|
#include<iostream>
#include<stack>
#define GET_ARRAY_LENGTH(array,len){len=sizeof(array)/sizeof(array[0]);}
using namespace std;
class Solution{
public:
void push(int node){
stack1.push(node);
}
int pop(){
if(stack2.empty()){
while(!stack1.empty()){
stack2.push(stack1.top());
stack1.pop();
}
}
int a = stack2.top();
stack2.pop();
return a;
}
private:
stack<int> stack1;
stack<int> stack2;
};
int main(int argc, char const *argv[]) {
Solution s;
int a[]={1,2,3,4,5};
int b[]={6,7,8,9,10};
int len;
GET_ARRAY_LENGTH(a,len);
for(int i=0; i<len; i++){
s.push(a[i]);
}
for(int i=0; i<len-1; i++){
cout<<s.pop();
}
for(int i=0; i<len; i++){
s.push(b[i]);
}
for(int i=0; i<len-1; i++){
cout<<s.pop();
}
return 0;
}
|
5d3465c3b85bb79ca405a0f12b6e4d9830465903
|
1fd7209fbef51589799619bc28ca018551c4b7b9
|
/palindromes/PalindromesMain.cpp
|
d25d70ee857b895223d4244f865c21da53971bd7
|
[] |
no_license
|
miefos/2020-bitl-workspace-cpp
|
237792a69782dc62f4161c3fc832a466d44ae313
|
e13da10e9dec55004317a5450d985709e2afd347
|
refs/heads/master
| 2023-02-09T08:17:32.809293
| 2021-01-03T18:54:32
| 2021-01-03T18:54:32
| 292,494,576
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 955
|
cpp
|
PalindromesMain.cpp
|
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include "Palindromes.h"
using namespace std;
using namespace ds_course;
int main()
{
Palindromes pal;
string mode;
cin >> mode;
string inputString;
int inputDec;
int inputHex;
//cout << '\'' << mode << '\'' << endl;
cin.ignore(10000,'\n');
string inputLine;
while (getline(cin, inputLine)) {
istringstream sstr(inputLine);
if (sstr.peek() == '#') {
continue;
}
else {
if (mode == "dec") {
sstr >> inputDec;
bool res = pal.isPalindrome(inputDec);
cout << inputDec << " " << res << endl;
} else if (mode == "str") {
sstr >> inputString;
bool res = pal.isPalindrome(inputString);
cout << inputString << " " << res << endl;
}
}
}
}
|
541b67f31f9a352f52764e9d7b6086caec697fdc
|
659306f16ef2784ce1e6b25f951d289a77eccf25
|
/ventanapeliculasrentadasporelcliente.cpp
|
88b9d493971eee1fa8b35d714798807e67191431
|
[] |
no_license
|
antonio-maldonado/movierental
|
f69a9d98b7338dfec24b764926caa9fa5b377035
|
af4c66b1bf6487e928e2d6f79b8507bb8933d779
|
refs/heads/main
| 2023-08-21T03:05:00.441310
| 2021-10-26T06:41:30
| 2021-10-26T06:41:30
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 431
|
cpp
|
ventanapeliculasrentadasporelcliente.cpp
|
#include "ventanapeliculasrentadasporelcliente.h"
#include "ui_ventanapeliculasrentadasporelcliente.h"
#include "menu_principal.h"
ventanapeliculasrentadasporelcliente::ventanapeliculasrentadasporelcliente(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ventanapeliculasrentadasporelcliente)
{
ui->setupUi(this);
}
ventanapeliculasrentadasporelcliente::~ventanapeliculasrentadasporelcliente()
{
delete ui;
}
|
9b7a3378c20b40546045df9b4ef56b4ad124260e
|
eda7f1e5c79682bf55cfa09582a82ce071ee6cee
|
/aspects/fluid/conductor/GunnsFluidSensor.cpp
|
2a3f805b7a732a824c648b07750687eea43b78b7
|
[
"LicenseRef-scancode-us-govt-public-domain",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
nasa/gunns
|
923f4f7218e2ecd0a18213fe5494c2d79a566bb3
|
d5455e3eaa8b50599bdb16e4867a880705298f62
|
refs/heads/master
| 2023-08-30T06:39:08.984844
| 2023-07-27T12:18:42
| 2023-07-27T12:18:42
| 235,422,976
| 34
| 11
|
NOASSERTION
| 2023-08-30T15:11:41
| 2020-01-21T19:21:16
|
C++
|
UTF-8
|
C++
| false
| false
| 8,854
|
cpp
|
GunnsFluidSensor.cpp
|
/************************** TRICK HEADER ***********************************************************
@copyright Copyright 2019 United States Government as represented by the Administrator of the
National Aeronautics and Space Administration. All Rights Reserved.
LIBRARY DEPENDENCY:
((core/GunnsFluidConductor.o))
***************************************************************************************************/
#include "GunnsFluidSensor.hh"
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] name (--) Name of object.
/// @param[in] nodes (--) Pointer to nodes.
/// @param[in] maxConductivity (m2) Max conductivity.
/// @param[in] expansionScaleFactor (--) Scale factor for isentropic gas cooling.
///
/// @details Default constructs this GUNNS Fluid Sensor link model configuration data.
////////////////////////////////////////////////////////////////////////////////////////////////////
GunnsFluidSensorConfigData::GunnsFluidSensorConfigData(const std::string& name,
GunnsNodeList* nodes,
const double maxConductivity,
const double expansionScaleFactor)
:
GunnsFluidConductorConfigData(name, nodes, maxConductivity, expansionScaleFactor)
{
// nothing to do
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that -- Source to copy.
///
/// @details Copy constructs this GUNNS Fluid Sensor link model configuration data.
////////////////////////////////////////////////////////////////////////////////////////////////////
GunnsFluidSensorConfigData::GunnsFluidSensorConfigData(const GunnsFluidSensorConfigData& that)
:
GunnsFluidConductorConfigData(that)
{
// nothing to do
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Default destructs this GUNNS Fluid Sensor link model configuration data.
////////////////////////////////////////////////////////////////////////////////////////////////////
GunnsFluidSensorConfigData::~GunnsFluidSensorConfigData()
{
// nothing to do
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] malfBlockageFlag (--) Blockage malfunction flag.
/// @param[in] malfBlockageValue (--) Blockage malfunction fractional value (0-1).
///
/// @details Default constructs this GUNNS Fluid Sensor link model input data.
////////////////////////////////////////////////////////////////////////////////////////////////////
GunnsFluidSensorInputData::GunnsFluidSensorInputData(const bool malfBlockageFlag,
const double malfBlockageValue)
:
GunnsFluidConductorInputData(malfBlockageFlag, malfBlockageValue)
{
// nothing to do
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] that (--) Source to copy.
///
/// @details Copy constructs this GUNNS Fluid Sensor link model input data.
////////////////////////////////////////////////////////////////////////////////////////////////////
GunnsFluidSensorInputData::GunnsFluidSensorInputData(const GunnsFluidSensorInputData& that)
:
GunnsFluidConductorInputData(that)
{
// nothing to do
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Default destructs this GUNNS Fluid Sensor link model input data.
////////////////////////////////////////////////////////////////////////////////////////////////////
GunnsFluidSensorInputData::~GunnsFluidSensorInputData()
{
// nothing to do
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @note This should be followed by a call to the initialize method before calling an update
/// method.
///
/// @details Default constructs this GUNNS Fluid Sensor link model.
////////////////////////////////////////////////////////////////////////////////////////////////////
GunnsFluidSensor::GunnsFluidSensor()
:
GunnsFluidConductor(),
mTemperature(0.0),
mPressure(0.0),
mDeltaPressure(0.0),
mMassFlowRate(0.0),
mVolumetricFlowRate(0.0),
mPartialPressure()
{
// nothing to do
}
///////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Default destructs this GUNNS Fluid Sensor link model.
///////////////////////////////////////////////////////////////////////////////////////////////////
GunnsFluidSensor::~GunnsFluidSensor()
{
// nothing to do
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] configData (--) Configuration data.
/// @param[in] inputData (--) Input data.
/// @param[in,out] links (--) Link vector.
/// @param[in] port0 (--) Nominal inlet port map index.
/// @param[in] port1 (--) Nominal outlet port map index.
///
/// @return void
///
/// @throws TsInitializationException
///
/// @details Initializes this GUNNS Fluid Sensor link model with configuration and input data.
////////////////////////////////////////////////////////////////////////////////////////////////////
void GunnsFluidSensor::initialize(const GunnsFluidSensorConfigData& configData,
const GunnsFluidSensorInputData& inputData,
std::vector<GunnsBasicLink*>& links,
const int port0,
const int port1)
{
/// - First initialize & validate parent.
GunnsFluidConductor::initialize(configData, inputData, links, port0, port1);
/// - Reset initialization status flag.
mInitFlag = false;
/// - Initialize all partial pressures to zero.
for (int i = 0; i < FluidProperties::NO_FLUID; ++i) {
mPartialPressure[i] = 0.0;
}
/// - Initialize sensor truth values.
updateSensedValues();
/// - Set initialization status flag to indicate successful initialization.
mInitFlag = true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Derived classes should call their base class implementation too.
////////////////////////////////////////////////////////////////////////////////////////////////////
void GunnsFluidSensor::restartModel()
{
/// - Reset the base class.
GunnsFluidConductor::restartModel();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @param[in] dt (s) Integration time step.
///
/// @details Calls the base class implementation for normal fluid conductor transport, then calls
/// the final sensed output values to be updated.
////////////////////////////////////////////////////////////////////////////////////////////////////
void GunnsFluidSensor::transportFlows(const double dt)
{
GunnsFluidConductor::transportFlows(dt);
updateSensedValues();
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// @details Updates this GUNNS Fluid Sensor link model temperature, pressure, delta pressure and
/// mass flow rate sensor truth values.
////////////////////////////////////////////////////////////////////////////////////////////////////
void GunnsFluidSensor::updateSensedValues()
{
/// - Temperature is from port 0 Node fluid.
mTemperature = mNodes[0]->getContent()->getTemperature();
/// - Pressure is from port 0 Node fluid.
mPressure = mNodes[0]->getContent()->getPressure();
/// - Delta pressure is port 0 Node fluid pressure - port 1 Node fluid pressure.
mDeltaPressure = mPressure - mNodes[1]->getContent()->getPressure();
/// - Mass flow rate is link mass flow rate.
mMassFlowRate = mFlowRate;
/// - Volumetric flow rate is link volumetric flow rate.
mVolumetricFlowRate = mVolFlowRate;
/// - Partial pressures are port 0 Node fluid partial pressures. Partial pressures for absent
/// constituents are not updated from initial value of 0.0.
for (int i = 0; i < mNodes[0]->getContent()->getNConstituents(); ++i) {
const FluidProperties::FluidType type = mNodes[0]->getContent()->getType(i);
mPartialPressure[type] = mNodes[0]->getContent()->getPartialPressure(type);
}
}
|
ec10c21b881eace0f82ebbdf022e2830e9657143
|
b2ddd88f5d0f70deb0bcf814733c3c0d12db4095
|
/C++4J_Assignment02/tree.h
|
dcaa7e21cbd2eeec87fc192de4cb764e29f9d056
|
[] |
no_license
|
ChristophNuetzel/CPP4J_Assignment02
|
75d9865cd7b423923d97a8a87335e072e954a11e
|
e0c8ac66b8931a370c9a2376d198f866a5eaf507
|
refs/heads/master
| 2021-01-20T11:29:53.122942
| 2012-11-26T16:32:57
| 2012-11-26T16:32:57
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,204
|
h
|
tree.h
|
#ifndef TREE_H
#define TREE_H
#include <string>
namespace CPP4JTree
{
// these typedefs are used for better readability.
typedef unsigned int KeyType;
typedef std::string ValueType;
// Declaration of a class called TreeNode.
// TreeNode contains the logic of the Tree and is an inner class, found in tree.cpp
class TreeNode;
// This class represents an iterator for the tree, to step through every single tree-element step by step.
class TreeIterator
{
public:
//constructor
TreeIterator(TreeNode* node = 0);
//copy constructor
TreeIterator(const TreeIterator& rhs);
//overloaded = operator
TreeIterator& operator=(const TreeIterator& rhs);
// getter for the value of the current iteration step
ValueType& value();
// getter for the key of the current iteration step
KeyType& key();
//overloaded ++ operator, one step through the nodes of the tree via increment.
TreeIterator& operator++();
//overloaded -- operator, one step through the nodes of the tree via decrement.
TreeIterator& operator--();
//overloaded == operator, return true if the current TreeNode* of both TreeIterators is equal
bool operator==(const TreeIterator &rhs);
//overloaded == operator, returns true if the current TreeNode* of both TreeIterators are different
bool operator!=(const TreeIterator &rhs);
private:
// the current TreeNode of the tree through which the iterator is iterating.
TreeNode* m_currentTreeNode;
};
// This class represents an unbalanced binary tree.
// The logic is hidden in the inner class called TreeNode.
class Tree
{
public:
// standard constructor
Tree();
// copy constructor
Tree(const Tree& rhs);
// This operator is used to assign another tree to the existing variable;
Tree& operator=(const Tree& rhs);
// This method returns the count of nodes in the tree
unsigned int count() const;
// This method returns the count of all nodes in the tree, which values are not an empty string.
unsigned int countCompleteNodes();
// This method deletes all nodes of the tree and sets all values to 0.
void clear();
// This method checks if the key is in the tree already.
bool contains(const KeyType& key);
// The []-operator is used to return the corresponding value.
// New values are also assigned by using this operator (eg. tree[3] = "Dummy";)
ValueType& operator[](const KeyType& key);
// This method returns a TreeIterator, which represents the first node in the tree (the one with the smallest key).
TreeIterator begin();
// This method returns a TreeIterator, which represents the last node in the tree (the one with the largest key).
TreeIterator last();
// This method returns a TreeIterator, which represents the end of a tree (not the last node, but one node AFTER the last node).
TreeIterator end();
// This method returns a TreeIterator, which represents the node corresponding the given key.
TreeIterator find(const KeyType& value);
private:
// The number of nodes in the tree.
unsigned int m_count;
// The root node of the tree.
TreeNode *m_root;
};
}
#endif // TREE_H
|
10325fb04e7e720bc47cccf4057ff1d9995bea6a
|
d6aa8e6e52c771e1baedf83de6cc4636636ce3a7
|
/IOperand.hpp
|
049eaf301346eefe1d792ad9606dec8c45704c03
|
[] |
no_license
|
zayrt/cpp_abstractVM
|
0a58985719dd732056a0cef6d0aa6e1bef4490f6
|
e39ccfae70df7191d3b0e32f656f2419d37dc355
|
refs/heads/master
| 2021-01-17T15:12:41.138006
| 2014-07-07T10:32:42
| 2014-07-07T10:32:42
| 21,568,375
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 901
|
hpp
|
IOperand.hpp
|
//
// IOperand.hpp for in /home/zellou_i/rendu/cpp_abstractvm
//
// Made by ilyas zelloufi
// Login <zellou_i@epitech.net>
//
// Started on Mon Jul 7 12:30:12 2014 ilyas zelloufi
// Last update Mon Jul 7 12:30:13 2014 ilyas zelloufi
//
#ifndef IOPERAND_HPP
#define IOPERAND_HPP
#include "Exception.hpp"
enum eOperandType
{
Int8,
Int16,
Int32,
Float,
Double
};
class IOperand
{
public:
virtual ~IOperand(void) {}
virtual String const &toString(void) const = 0;
virtual int getPrecision(void) const = 0;
virtual eOperandType getType(void) const = 0;
virtual IOperand *operator+(const IOperand &rhs) const = 0;
virtual IOperand *operator-(const IOperand &rhs) const = 0;
virtual IOperand *operator*(const IOperand &rhs) const = 0;
virtual IOperand *operator/(const IOperand &rhs) const = 0;
virtual IOperand *operator%(const IOperand &rhs) const = 0;
};
#endif
|
44b800b9a85e9f81c7b452bb4ff0f51544bacdb3
|
14248aaedfa5f77c7fc5dd8c3741604fb987de5c
|
/leetcode/P0624.cpp
|
2b89d0870f2ba607d56ad028e818fea0b01332e3
|
[] |
no_license
|
atubo/online-judge
|
fc51012465a1bd07561b921f5c7d064e336a4cd2
|
8774f6c608bb209a1ebbb721d6bbfdb5c1d1ce9b
|
refs/heads/master
| 2021-11-22T19:48:14.279016
| 2021-08-29T23:16:16
| 2021-08-29T23:16:16
| 13,290,232
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,205
|
cpp
|
P0624.cpp
|
// https://leetcode.com/problems/maximum-distance-in-arrays/#/description
// 624. Maximum Distance in Arrays
#include "BinaryTree.h"
#include "Graph.h"
#include "LinkedList.h"
#include "Util.h"
#include <bits/stdc++.h>
using namespace std;
class Solution {
using PII = pair<int, int>;
public:
int maxDistance(vector<vector<int>>& A) {
vector<PII> minmax;
for (const auto& v: A) {
if (!v.empty()) minmax.push_back(make_pair(v.front(), v.back()));
}
const int N = minmax.size();
vector<int> minelem(N+2), maxleft(N+2), maxright(N+2);
for (int i = 1; i <= N; i++) {
minelem[i] = minmax[i-1].first;
}
maxleft[0] = INT_MIN;
for (int i = 1; i <= N; i++) {
maxleft[i] = max(maxleft[i-1], minmax[i-1].second);
}
maxright[N+1] = INT_MIN;
for (int i = N; i >= 0; i--) {
maxright[i] = max(maxright[i+1], minmax[i-1].second);
}
int ret = 0;
for (int i = 1; i <= N; i++) {
ret = max(ret, max(maxleft[i-1], maxright[i+1]) - minelem[i]);
}
return ret;
}
};
int main() {
Solution solution;
return 0;
}
|
1ab1e7b93a01864f606e69164545d02ed2aa8165
|
803a33aa957a5f584a47acd564d31ec0faf0de8e
|
/RyujinCore/Profiler/PixProfiler.hpp
|
6d9cbad1997ba68b66b6949bfab3ba49d04d8f8c
|
[] |
no_license
|
yggdrasil-917/Ryujin
|
00d5758ad95290a0dd103b99d33db530b027c010
|
376f2354d13d0be40128b271ef9994a7c7f81f05
|
refs/heads/master
| 2021-05-15T20:10:44.374984
| 2017-11-14T02:03:41
| 2017-11-14T02:03:41
| 107,832,584
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 771
|
hpp
|
PixProfiler.hpp
|
#pragma once
#include "Profiler.hpp"
#if PLATFORM_WINDOWS
#ifndef PROFILE
#define PROFILE 1
#endif
#include <pix3.h>
#pragma comment(lib, "WinPixEventRuntime.lib")
#define MakePixColor(r, g, b) PIX_COLOR(r, g, b)
#else
#define MakePixColor(r, g, b)
#endif
namespace Ryujin
{
class CORE_API PixProfiler : public Profiler
{
#if PLATFORM_WINDOWS
public:
void Init() OVERRIDE FINAL;
void Shutdown() OVERRIDE FINAL;
void BeginEvent(const ProfileEvent& inEvent) OVERRIDE FINAL;
void EndEvent(const ProfileEvent& inEvent) OVERRIDE FINAL;
#else
public:
void Init() OVERRIDE FINAL {}
void Shutdown() OVERRIDE FINAL {}
void BeginEvent(const ProfileEvent& inEvent) OVERRIDE FINAL {}
void EndEvent(const ProfileEvent& inEvent) OVERRIDE FINAL {}
#endif
};
}
|
3d7e09ea85968babc5995c7d7455a6ea7e109b75
|
e47e2263ca0b60d0c8327f74b4d4078deadea430
|
/tess-two/jni/com_googlecode_tesseract_android/src/ccstruct/ratngs.h
|
2ee9c94a30ccdba5c8b4eb5ef2551998246c4e73
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
rmtheis/tess-two
|
43ed1bdcceee88df696efdee7c3965572ff2121f
|
ab4cab1bd9794aacb74162aff339daa921a68c3f
|
refs/heads/master
| 2023-03-10T08:27:42.539055
| 2022-03-17T11:21:24
| 2022-03-17T11:21:24
| 2,581,357
| 3,632
| 1,331
|
Apache-2.0
| 2019-10-20T00:51:50
| 2011-10-15T11:14:00
|
C
|
UTF-8
|
C++
| false
| false
| 23,084
|
h
|
ratngs.h
|
/**********************************************************************
* File: ratngs.h (Formerly ratings.h)
* Description: Definition of the WERD_CHOICE and BLOB_CHOICE classes.
* Author: Ray Smith
* Created: Thu Apr 23 11:40:38 BST 1992
*
* (C) Copyright 1992, Hewlett-Packard Ltd.
** 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 RATNGS_H
#define RATNGS_H
#include <assert.h>
#include "clst.h"
#include "elst.h"
#include "fontinfo.h"
#include "genericvector.h"
#include "matrix.h"
#include "unichar.h"
#include "unicharset.h"
#include "werd.h"
class MATRIX;
struct TBLOB;
struct TWERD;
// Enum to describe the source of a BLOB_CHOICE to make it possible to determine
// whether a blob has been classified by inspecting the BLOB_CHOICEs.
enum BlobChoiceClassifier {
BCC_STATIC_CLASSIFIER, // From the char_norm classifier.
BCC_ADAPTED_CLASSIFIER, // From the adaptive classifier.
BCC_SPECKLE_CLASSIFIER, // Backup for failed classification.
BCC_AMBIG, // Generated by ambiguity detection.
BCC_FAKE, // From some other process.
};
class BLOB_CHOICE: public ELIST_LINK
{
public:
BLOB_CHOICE() {
unichar_id_ = UNICHAR_SPACE;
fontinfo_id_ = -1;
fontinfo_id2_ = -1;
rating_ = 10.0;
certainty_ = -1.0;
script_id_ = -1;
xgap_before_ = 0;
xgap_after_ = 0;
min_xheight_ = 0.0f;
max_xheight_ = 0.0f;
yshift_ = 0.0f;
classifier_ = BCC_FAKE;
}
BLOB_CHOICE(UNICHAR_ID src_unichar_id, // character id
float src_rating, // rating
float src_cert, // certainty
int script_id, // script
float min_xheight, // min xheight in image pixel units
float max_xheight, // max xheight allowed by this char
float yshift, // the larger of y shift (top or bottom)
BlobChoiceClassifier c); // adapted match or other
BLOB_CHOICE(const BLOB_CHOICE &other);
~BLOB_CHOICE() {}
UNICHAR_ID unichar_id() const {
return unichar_id_;
}
float rating() const {
return rating_;
}
float certainty() const {
return certainty_;
}
inT16 fontinfo_id() const {
return fontinfo_id_;
}
inT16 fontinfo_id2() const {
return fontinfo_id2_;
}
const GenericVector<tesseract::ScoredFont>& fonts() const {
return fonts_;
}
void set_fonts(const GenericVector<tesseract::ScoredFont>& fonts) {
fonts_ = fonts;
int score1 = 0, score2 = 0;
fontinfo_id_ = -1;
fontinfo_id2_ = -1;
for (int f = 0; f < fonts_.size(); ++f) {
if (fonts_[f].score > score1) {
score2 = score1;
fontinfo_id2_ = fontinfo_id_;
score1 = fonts_[f].score;
fontinfo_id_ = fonts_[f].fontinfo_id;
} else if (fonts_[f].score > score2) {
score2 = fonts_[f].score;
fontinfo_id2_ = fonts_[f].fontinfo_id;
}
}
}
int script_id() const {
return script_id_;
}
const MATRIX_COORD& matrix_cell() {
return matrix_cell_;
}
inT16 xgap_before() const {
return xgap_before_;
}
inT16 xgap_after() const {
return xgap_after_;
}
float min_xheight() const {
return min_xheight_;
}
float max_xheight() const {
return max_xheight_;
}
float yshift() const {
return yshift_;
}
BlobChoiceClassifier classifier() const {
return classifier_;
}
bool IsAdapted() const {
return classifier_ == BCC_ADAPTED_CLASSIFIER;
}
bool IsClassified() const {
return classifier_ == BCC_STATIC_CLASSIFIER ||
classifier_ == BCC_ADAPTED_CLASSIFIER ||
classifier_ == BCC_SPECKLE_CLASSIFIER;
}
void set_unichar_id(UNICHAR_ID newunichar_id) {
unichar_id_ = newunichar_id;
}
void set_rating(float newrat) {
rating_ = newrat;
}
void set_certainty(float newrat) {
certainty_ = newrat;
}
void set_script(int newscript_id) {
script_id_ = newscript_id;
}
void set_matrix_cell(int col, int row) {
matrix_cell_.col = col;
matrix_cell_.row = row;
}
void set_xgap_before(inT16 gap) {
xgap_before_ = gap;
}
void set_xgap_after(inT16 gap) {
xgap_after_ = gap;
}
void set_classifier(BlobChoiceClassifier classifier) {
classifier_ = classifier;
}
static BLOB_CHOICE* deep_copy(const BLOB_CHOICE* src) {
BLOB_CHOICE* choice = new BLOB_CHOICE;
*choice = *src;
return choice;
}
// Returns true if *this and other agree on the baseline and x-height
// to within some tolerance based on a given estimate of the x-height.
bool PosAndSizeAgree(const BLOB_CHOICE& other, float x_height,
bool debug) const;
void print(const UNICHARSET *unicharset) const {
tprintf("r%.2f c%.2f x[%g,%g]: %d %s",
rating_, certainty_,
min_xheight_, max_xheight_, unichar_id_,
(unicharset == NULL) ? "" :
unicharset->debug_str(unichar_id_).string());
}
void print_full() const {
print(NULL);
tprintf(" script=%d, font1=%d, font2=%d, yshift=%g, classifier=%d\n",
script_id_, fontinfo_id_, fontinfo_id2_, yshift_, classifier_);
}
// Sort function for sorting BLOB_CHOICEs in increasing order of rating.
static int SortByRating(const void *p1, const void *p2) {
const BLOB_CHOICE *bc1 =
*reinterpret_cast<const BLOB_CHOICE * const *>(p1);
const BLOB_CHOICE *bc2 =
*reinterpret_cast<const BLOB_CHOICE * const *>(p2);
return (bc1->rating_ < bc2->rating_) ? -1 : 1;
}
private:
UNICHAR_ID unichar_id_; // unichar id
// Fonts and scores. Allowed to be empty.
GenericVector<tesseract::ScoredFont> fonts_;
inT16 fontinfo_id_; // char font information
inT16 fontinfo_id2_; // 2nd choice font information
// Rating is the classifier distance weighted by the length of the outline
// in the blob. In terms of probability, classifier distance is -klog p such
// that the resulting distance is in the range [0, 1] and then
// rating = w (-k log p) where w is the weight for the length of the outline.
// Sums of ratings may be compared meaningfully for words of different
// segmentation.
float rating_; // size related
// Certainty is a number in [-20, 0] indicating the classifier certainty
// of the choice. In terms of probability, certainty = 20 (k log p) where
// k is defined as above to normalize -klog p to the range [0, 1].
float certainty_; // absolute
int script_id_;
// Holds the position of this choice in the ratings matrix.
// Used to location position in the matrix during path backtracking.
MATRIX_COORD matrix_cell_;
inT16 xgap_before_;
inT16 xgap_after_;
// X-height range (in image pixels) that this classification supports.
float min_xheight_;
float max_xheight_;
// yshift_ - The vertical distance (in image pixels) the character is
// shifted (up or down) from an acceptable y position.
float yshift_;
BlobChoiceClassifier classifier_; // What generated *this.
};
// Make BLOB_CHOICE listable.
ELISTIZEH(BLOB_CHOICE)
// Return the BLOB_CHOICE in bc_list matching a given unichar_id,
// or NULL if there is no match.
BLOB_CHOICE *FindMatchingChoice(UNICHAR_ID char_id, BLOB_CHOICE_LIST *bc_list);
// Permuter codes used in WERD_CHOICEs.
enum PermuterType {
NO_PERM, // 0
PUNC_PERM, // 1
TOP_CHOICE_PERM, // 2
LOWER_CASE_PERM, // 3
UPPER_CASE_PERM, // 4
NGRAM_PERM, // 5
NUMBER_PERM, // 6
USER_PATTERN_PERM, // 7
SYSTEM_DAWG_PERM, // 8
DOC_DAWG_PERM, // 9
USER_DAWG_PERM, // 10
FREQ_DAWG_PERM, // 11
COMPOUND_PERM, // 12
NUM_PERMUTER_TYPES
};
namespace tesseract {
// ScriptPos tells whether a character is subscript, superscript or normal.
enum ScriptPos {
SP_NORMAL,
SP_SUBSCRIPT,
SP_SUPERSCRIPT,
SP_DROPCAP
};
const char *ScriptPosToString(tesseract::ScriptPos script_pos);
} // namespace tesseract.
class TESS_API WERD_CHOICE : public ELIST_LINK {
public:
static const float kBadRating;
static const char *permuter_name(uinT8 permuter);
WERD_CHOICE(const UNICHARSET *unicharset)
: unicharset_(unicharset) { this->init(8); }
WERD_CHOICE(const UNICHARSET *unicharset, int reserved)
: unicharset_(unicharset) { this->init(reserved); }
WERD_CHOICE(const char *src_string,
const char *src_lengths,
float src_rating,
float src_certainty,
uinT8 src_permuter,
const UNICHARSET &unicharset)
: unicharset_(&unicharset) {
this->init(src_string, src_lengths, src_rating,
src_certainty, src_permuter);
}
WERD_CHOICE(const char *src_string, const UNICHARSET &unicharset);
WERD_CHOICE(const WERD_CHOICE &word)
: ELIST_LINK(word), unicharset_(word.unicharset_) {
this->init(word.length());
this->operator=(word);
}
~WERD_CHOICE();
const UNICHARSET *unicharset() const {
return unicharset_;
}
inline int length() const {
return length_;
}
float adjust_factor() const {
return adjust_factor_;
}
void set_adjust_factor(float factor) {
adjust_factor_ = factor;
}
inline const UNICHAR_ID *unichar_ids() const {
return unichar_ids_;
}
inline UNICHAR_ID unichar_id(int index) const {
assert(index < length_);
return unichar_ids_[index];
}
inline int state(int index) const {
return state_[index];
}
tesseract::ScriptPos BlobPosition(int index) const {
if (index < 0 || index >= length_)
return tesseract::SP_NORMAL;
return script_pos_[index];
}
inline float rating() const {
return rating_;
}
inline float certainty() const {
return certainty_;
}
inline float certainty(int index) const {
return certainties_[index];
}
inline float min_x_height() const {
return min_x_height_;
}
inline float max_x_height() const {
return max_x_height_;
}
inline void set_x_heights(float min_height, float max_height) {
min_x_height_ = min_height;
max_x_height_ = max_height;
}
inline uinT8 permuter() const {
return permuter_;
}
const char *permuter_name() const;
// Returns the BLOB_CHOICE_LIST corresponding to the given index in the word,
// taken from the appropriate cell in the ratings MATRIX.
// Borrowed pointer, so do not delete.
BLOB_CHOICE_LIST* blob_choices(int index, MATRIX* ratings) const;
// Returns the MATRIX_COORD corresponding to the location in the ratings
// MATRIX for the given index into the word.
MATRIX_COORD MatrixCoord(int index) const;
inline void set_unichar_id(UNICHAR_ID unichar_id, int index) {
assert(index < length_);
unichar_ids_[index] = unichar_id;
}
bool dangerous_ambig_found() const {
return dangerous_ambig_found_;
}
void set_dangerous_ambig_found_(bool value) {
dangerous_ambig_found_ = value;
}
inline void set_rating(float new_val) {
rating_ = new_val;
}
inline void set_certainty(float new_val) {
certainty_ = new_val;
}
inline void set_permuter(uinT8 perm) {
permuter_ = perm;
}
// Note: this function should only be used if all the fields
// are populated manually with set_* functions (rather than
// (copy)constructors and append_* functions).
inline void set_length(int len) {
ASSERT_HOST(reserved_ >= len);
length_ = len;
}
/// Make more space in unichar_id_ and fragment_lengths_ arrays.
inline void double_the_size() {
if (reserved_ > 0) {
unichar_ids_ = GenericVector<UNICHAR_ID>::double_the_size_memcpy(
reserved_, unichar_ids_);
script_pos_ = GenericVector<tesseract::ScriptPos>::double_the_size_memcpy(
reserved_, script_pos_);
state_ = GenericVector<int>::double_the_size_memcpy(
reserved_, state_);
certainties_ = GenericVector<float>::double_the_size_memcpy(
reserved_, certainties_);
reserved_ *= 2;
} else {
unichar_ids_ = new UNICHAR_ID[1];
script_pos_ = new tesseract::ScriptPos[1];
state_ = new int[1];
certainties_ = new float[1];
reserved_ = 1;
}
}
/// Initializes WERD_CHOICE - reserves length slots in unichar_ids_ and
/// fragment_length_ arrays. Sets other values to default (blank) values.
inline void init(int reserved) {
reserved_ = reserved;
if (reserved > 0) {
unichar_ids_ = new UNICHAR_ID[reserved];
script_pos_ = new tesseract::ScriptPos[reserved];
state_ = new int[reserved];
certainties_ = new float[reserved];
} else {
unichar_ids_ = NULL;
script_pos_ = NULL;
state_ = NULL;
certainties_ = NULL;
}
length_ = 0;
adjust_factor_ = 1.0f;
rating_ = 0.0;
certainty_ = MAX_FLOAT32;
min_x_height_ = 0.0f;
max_x_height_ = MAX_FLOAT32;
permuter_ = NO_PERM;
unichars_in_script_order_ = false; // Tesseract is strict left-to-right.
dangerous_ambig_found_ = false;
}
/// Helper function to build a WERD_CHOICE from the given string,
/// fragment lengths, rating, certainty and permuter.
/// The function assumes that src_string is not NULL.
/// src_lengths argument could be NULL, in which case the unichars
/// in src_string are assumed to all be of length 1.
void init(const char *src_string, const char *src_lengths,
float src_rating, float src_certainty,
uinT8 src_permuter);
/// Set the fields in this choice to be default (bad) values.
inline void make_bad() {
length_ = 0;
rating_ = kBadRating;
certainty_ = -MAX_FLOAT32;
}
/// This function assumes that there is enough space reserved
/// in the WERD_CHOICE for adding another unichar.
/// This is an efficient alternative to append_unichar_id().
inline void append_unichar_id_space_allocated(
UNICHAR_ID unichar_id, int blob_count,
float rating, float certainty) {
assert(reserved_ > length_);
length_++;
this->set_unichar_id(unichar_id, blob_count,
rating, certainty, length_-1);
}
void append_unichar_id(UNICHAR_ID unichar_id, int blob_count,
float rating, float certainty);
inline void set_unichar_id(UNICHAR_ID unichar_id, int blob_count,
float rating, float certainty, int index) {
assert(index < length_);
unichar_ids_[index] = unichar_id;
state_[index] = blob_count;
certainties_[index] = certainty;
script_pos_[index] = tesseract::SP_NORMAL;
rating_ += rating;
if (certainty < certainty_) {
certainty_ = certainty;
}
}
// Sets the entries for the given index from the BLOB_CHOICE, assuming
// unit fragment lengths, but setting the state for this index to blob_count.
void set_blob_choice(int index, int blob_count,
const BLOB_CHOICE* blob_choice);
bool contains_unichar_id(UNICHAR_ID unichar_id) const;
void remove_unichar_ids(int index, int num);
inline void remove_last_unichar_id() { --length_; }
inline void remove_unichar_id(int index) {
this->remove_unichar_ids(index, 1);
}
bool has_rtl_unichar_id() const;
void reverse_and_mirror_unichar_ids();
// Returns the half-open interval of unichar_id indices [start, end) which
// enclose the core portion of this word -- the part after stripping
// punctuation from the left and right.
void punct_stripped(int *start_core, int *end_core) const;
// Returns the indices [start, end) containing the core of the word, stripped
// of any superscript digits on either side. (i.e., the non-footnote part
// of the word). There is no guarantee that the output range is non-empty.
void GetNonSuperscriptSpan(int *start, int *end) const;
// Return a copy of this WERD_CHOICE with the choices [start, end).
// The result is useful only for checking against a dictionary.
WERD_CHOICE shallow_copy(int start, int end) const;
void string_and_lengths(STRING *word_str, STRING *word_lengths_str) const;
const STRING debug_string() const {
STRING word_str;
for (int i = 0; i < length_; ++i) {
word_str += unicharset_->debug_str(unichar_ids_[i]);
word_str += " ";
}
return word_str;
}
// Call this to override the default (strict left to right graphemes)
// with the fact that some engine produces a "reading order" set of
// Graphemes for each word.
bool set_unichars_in_script_order(bool in_script_order) {
return unichars_in_script_order_ = in_script_order;
}
bool unichars_in_script_order() const {
return unichars_in_script_order_;
}
// Returns a UTF-8 string equivalent to the current choice
// of UNICHAR IDs.
const STRING &unichar_string() const {
this->string_and_lengths(&unichar_string_, &unichar_lengths_);
return unichar_string_;
}
// Returns the lengths, one byte each, representing the number of bytes
// required in the unichar_string for each UNICHAR_ID.
const STRING &unichar_lengths() const {
this->string_and_lengths(&unichar_string_, &unichar_lengths_);
return unichar_lengths_;
}
// Sets up the script_pos_ member using the blobs_list to get the bln
// bounding boxes, *this to get the unichars, and this->unicharset
// to get the target positions. If small_caps is true, sub/super are not
// considered, but dropcaps are.
// NOTE: blobs_list should be the chopped_word blobs. (Fully segemented.)
void SetScriptPositions(bool small_caps, TWERD* word);
// Sets the script_pos_ member from some source positions with a given length.
void SetScriptPositions(const tesseract::ScriptPos* positions, int length);
// Sets all the script_pos_ positions to the given position.
void SetAllScriptPositions(tesseract::ScriptPos position);
static tesseract::ScriptPos ScriptPositionOf(bool print_debug,
const UNICHARSET& unicharset,
const TBOX& blob_box,
UNICHAR_ID unichar_id);
// Returns the "dominant" script ID for the word. By "dominant", the script
// must account for at least half the characters. Otherwise, it returns 0.
// Note that for Japanese, Hiragana and Katakana are simply treated as Han.
int GetTopScriptID() const;
// Fixes the state_ for a chop at the given blob_posiiton.
void UpdateStateForSplit(int blob_position);
// Returns the sum of all the state elements, being the total number of blobs.
int TotalOfStates() const;
void print() const { this->print(""); }
void print(const char *msg) const;
// Prints the segmentation state with an introductory message.
void print_state(const char *msg) const;
// Displays the segmentation state of *this (if not the same as the last
// one displayed) and waits for a click in the window.
void DisplaySegmentation(TWERD* word);
WERD_CHOICE& operator+= ( // concatanate
const WERD_CHOICE & second);// second on first
WERD_CHOICE& operator= (const WERD_CHOICE& source);
private:
const UNICHARSET *unicharset_;
// TODO(rays) Perhaps replace the multiple arrays with an array of structs?
// unichar_ids_ is an array of classifier "results" that make up a word.
// For each unichar_ids_[i], script_pos_[i] has the sub/super/normal position
// of each unichar_id.
// state_[i] indicates the number of blobs in WERD_RES::chopped_word that
// were put together to make the classification results in the ith position
// in unichar_ids_, and certainties_[i] is the certainty of the choice that
// was used in this word.
// == Change from before ==
// Previously there was fragment_lengths_ that allowed a word to be
// artificially composed of multiple fragment results. Since the new
// segmentation search doesn't do fragments, treatment of fragments has
// been moved to a lower level, augmenting the ratings matrix with the
// combined fragments, and allowing the language-model/segmentation-search
// to deal with only the combined unichar_ids.
UNICHAR_ID *unichar_ids_; // unichar ids that represent the text of the word
tesseract::ScriptPos* script_pos_; // Normal/Sub/Superscript of each unichar.
int* state_; // Number of blobs in each unichar.
float* certainties_; // Certainty of each unichar.
int reserved_; // size of the above arrays
int length_; // word length
// Factor that was used to adjust the rating.
float adjust_factor_;
// Rating is the sum of the ratings of the individual blobs in the word.
float rating_; // size related
// certainty is the min (worst) certainty of the individual blobs in the word.
float certainty_; // absolute
// xheight computed from the result, or 0 if inconsistent.
float min_x_height_;
float max_x_height_;
uinT8 permuter_; // permuter code
// Normally, the ratings_ matrix represents the recognition results in order
// from left-to-right. However, some engines (say Cube) may return
// recognition results in the order of the script's major reading direction
// (for Arabic, that is right-to-left).
bool unichars_in_script_order_;
// True if NoDangerousAmbig found an ambiguity.
bool dangerous_ambig_found_;
// The following variables are populated and passed by reference any
// time unichar_string() or unichar_lengths() are called.
mutable STRING unichar_string_;
mutable STRING unichar_lengths_;
};
// Make WERD_CHOICE listable.
ELISTIZEH(WERD_CHOICE)
typedef GenericVector<BLOB_CHOICE_LIST *> BLOB_CHOICE_LIST_VECTOR;
// Utilities for comparing WERD_CHOICEs
bool EqualIgnoringCaseAndTerminalPunct(const WERD_CHOICE &word1,
const WERD_CHOICE &word2);
// Utilities for debug printing.
void print_ratings_list(
const char *msg, // intro message
BLOB_CHOICE_LIST *ratings, // list of results
const UNICHARSET ¤t_unicharset // unicharset that can be used
// for id-to-unichar conversion
);
#endif
|
bb00b6e699fdeb1edd57949c3079cec7cab5ad4f
|
01d84e7ab889959a59bf009508000ea5db031dfe
|
/backup/LongToMa.cpp
|
ffc831a52351df75bbae589a3d1408785e814b94
|
[] |
no_license
|
qanyue/code
|
6aa0c4e1ce88847eb7b2a0e68aeb829ed9db7a13
|
9dc31a373dd1f069fc29d98ab965c59e8966ac20
|
refs/heads/master
| 2023-08-30T06:01:22.219223
| 2021-10-18T11:50:58
| 2021-10-18T11:50:58
| 250,241,485
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 313
|
cpp
|
LongToMa.cpp
|
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
const int change{220};
double distance1{};
double distance2{};
cout << "please enter the disrance: ";
cin >> distance1;
distance2=distance1*change;
cout << "After change the disrance is " << distance2 << endl;
return 0;
}
|
fd1c80835ce9c1013a63a8e04fbdeffe780c38ad
|
37610cdd0be1bc86b6b9a71119bf3f3f88c3e565
|
/VC++-thread/thread.cpp
|
d19ec6f925e80ff936644ba4f2a5b8c617bbc91f
|
[] |
no_license
|
LinusWangg/OS_Expriment
|
400b66b9631be251cb36e7065aea56221cbb8dcd
|
31d96e7cd02624658db5ce4d1942c90f7a77cf26
|
refs/heads/master
| 2023-06-25T01:24:49.497040
| 2021-07-08T05:55:34
| 2021-07-08T05:55:34
| 369,985,951
| 1
| 0
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 713
|
cpp
|
thread.cpp
|
#include<iostream>
#include<windows.h>
using namespace std;
HANDLE hMutex = NULL;//»¥³âÁ¿
DWORD WINAPI Fun(LPVOID lpParamter) {
cout << "A Thread Fun Display!" << endl;
return 0L;
}
DWORD WINAPI Fun2(LPVOID lpParamter) {
cout << "Another Thread Fun Display!" << endl;
return 0L;
}
HANDLE h1[10];
HANDLE h2[10];
int main()
{
for (int i = 0; i < 10; i++)
h1[i] = CreateThread(NULL, 0, Fun, NULL, 0, NULL);
for (int i = 0; i < 10; i++)
h2[i] = CreateThread(NULL, 0, Fun2, NULL, 0, NULL);
for (int i = 0; i < 10; i++) {
WaitForSingleObject(h1[i], INFINITE);
WaitForSingleObject(h2[i], INFINITE);
}
for (int i = 0; i < 10; i++) {
CloseHandle(h1[i]);
CloseHandle(h2[i]);
}
return 0;
}
|
5e4366060e35a533fd5a3c0b6f30ecf8869e24f4
|
37ab17d6648d7493684cb2d94e5c3c7576fcf72a
|
/learning/programming_2/программирование2сем/лаб6/6.fix1.cpp
|
1904cd6f66b5e9896c7ad7449d5bcf8a53feb785
|
[] |
no_license
|
ArtyomAdov/learning_sibsutis
|
74780d96658fe23efda916047ebc857215f81fc4
|
4a55314b91f7326ff792ca4521bd8bdf96f44bce
|
refs/heads/main
| 2023-02-11T17:44:42.124067
| 2021-01-03T11:25:46
| 2021-01-03T11:25:46
| 326,384,347
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 603
|
cpp
|
6.fix1.cpp
|
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int triangle(float*,float*,float,float,float);
int main()
{
float s=0,p=0,a,b,c;
printf("vvedite stotoni treugolnika\n");
scanf("%f%f%f",&a,&b,&c);
triangle(p,s,a,b,c);
printf("perimetr=%f\nplohad=%f\n",p,s);
}
int triangle(float* p,float* s,float a,float b,float c){
float p1;
if(a+b<=c)
{
printf("error");
exit(0);
}
else
if(a+c<=b)
{
printf("error");
exit(0);
}
if(c+b<=a)
{
printf("error");
exit(0);
}
*p=a+b+c;
p1=(float)*p/2;
*s=sqrt(p1*(p1-a)*(p1-b)*(p1-c));
return 1;
}
|
ce2bca6ed92ed7db65b16fc163d7d024b0c73121
|
690786394eea6925d25618ec015d251735be2e23
|
/KU/assignments/week1b/w2p4.cpp
|
f0c4f76caecf5f3e2f0aca2ae5157f0d802343c8
|
[] |
no_license
|
kaisersakhi/data-structures-with-cpp
|
69874468f8197da13ec1c0224e71835bb070303c
|
e530cdda1682e6c3bb8a812bced1b4f675d85aea
|
refs/heads/master
| 2023-09-03T13:47:12.293247
| 2021-09-28T15:09:52
| 2021-09-28T15:09:52
| 375,353,135
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 597
|
cpp
|
w2p4.cpp
|
/*
Author : Kaiser Sakhi
Date : 07-06-2021
Environment : WSL Kali Linux
*/
// program to reverse a string
#include<iostream>
#include<cstring>
void strReverse(char *);
int main(){
char name[] = "Kaiser Sakhi Bhat";
std::cout<<"String Before Reverse : "<<name;
strReverse(name);
std::cout<<"\nString After Reverse : "<<name;
return 0;
}
void strReverse(char *str){
int len = strlen(str);
int i = 0, j = len -1;
char temp;
while(i < j){
temp = str[i];
str[i] = str[j];
str[j] = temp;
++i;
--j;
}
}
|
e17841bee9af1a93256686ea9adc8c8832dc9858
|
95cc023556e96743b1b47f4459181a81bf592be7
|
/bin/zxdb/client/symbols/dwarf_symbol_factory.h
|
42053ed383bc69ebb22f78859c4055bc1dbc65c5
|
[
"BSD-3-Clause"
] |
permissive
|
return/garnet
|
5034ae8b8083455aa66da10040098c908f3de532
|
f14e7e50a1b6b55eaa8013755201a25fc83bd389
|
refs/heads/master
| 2020-03-23T16:13:28.763852
| 2018-07-21T07:24:31
| 2018-07-21T07:24:31
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 909
|
h
|
dwarf_symbol_factory.h
|
// Copyright 2018 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.
#include "garnet/bin/zxdb/client/symbols/symbol_factory.h"
#include "lib/fxl/memory/weak_ptr.h"
namespace zxdb {
class ModuleSymbolsImpl;
// Implementation of SymbolFactory that reads from the DWARF symbols in the
// given module.
class DwarfSymbolFactory : public SymbolFactory {
public:
explicit DwarfSymbolFactory(fxl::WeakPtr<ModuleSymbolsImpl> symbols);
~DwarfSymbolFactory() override;
// SymbolFactory implementation.
fxl::RefPtr<Symbol> CreateSymbol(void* data_ptr,
uint32_t offset) const override;
private:
// This can be null if the module is unloaded but there are still some
// dangling type references to it.
fxl::WeakPtr<ModuleSymbolsImpl> symbols_;
};
} // namespace zxdb
|
8ee24646304e2e80aace0930bd5329480f46f90c
|
6c4469e0350fc0befa5b91c859cb024758fd3c0d
|
/Jam/Jam/Cat.cpp
|
7e8f4063f983764053bd904da732dd1bb5975d1e
|
[] |
no_license
|
zsebastian/Skultorp-GameJam
|
d5a70303fcbc91f5f6f046d70c2af9f1ee3686c4
|
5f88434899bbd2985f8f337004f313335a657107
|
refs/heads/master
| 2021-01-22T10:07:17.118435
| 2013-04-07T17:47:47
| 2013-04-07T17:47:47
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,105
|
cpp
|
Cat.cpp
|
#include "Cat.h"
#include "Display.h"
#include "Ball.h"
#include "Utility.h"
#include <string>
#include "LooseEnd.h"
#include <iostream>
Cat::Cat(const sf::Vector2f& position, float mass, float radius)
:mMass(mass)
,mGravityVector(0.f, 0.f)
,mPosition(position)
,mMoveSpeed(0,0)
,mWalkSpeed(3)
,mCanJump(false)
,mJumping(false)
,mMaxJumpPower(7.f)
,mCurrentJumpPower(0)
,mJumpDecelaration(0.15f)
,mAnimations("cat.png")
,mLeftDir(false)
,mSpriteDown(0.f, 1.f)
,mNextYarn(0)
,mAlive(true)
{
setRadius(40.f);
setPosition(position);
mThreadTextures.resize(10);
mThreadTextures[0].loadFromFile("data/Blue Yarn.png");
mThreadTextures[1].loadFromFile("data/Red Yarn.png");
mThreadTextures[2].loadFromFile("data/Yello Yarn.png");
mThreadTextures[3].loadFromFile("data/Green Yarn.png");
mScarfTexture.loadFromFile("data/Interface skarf.png");
mScarfSprite.setTexture(mScarfTexture);
}
Cat::~Cat()
{
}
void Cat::setPosition(const sf::Vector2f& position)
{
mPosition = position;
}
void Cat::setMass(float mass)
{
mMass = mass;
}
void Cat::setRadius(float radius)
{
mRadius = radius;
mTempShape.setRadius(radius);
mTempShape.setOrigin(sf::Vector2f(radius, radius));
}
void Cat::update()
{
mMoveSpeed = sf::Vector2f();
jump();
jumping();
walk();
move();
mTempShape.setPosition(mPosition);
mYarn.updatePosition(mPosition, !mCanJump);
if (mYarn.intersect(mPosition, mRadius))
mAlive = false;
}
void Cat::move()
{
mGravityAcc += mGravityVector;
mPosition += mGravityAcc + mMoveSpeed;
}
void Cat::walk()
{
mRightVector = Util::getNormal(mGravityVector);
mRightVector = Util::normalize(mRightVector);
mRightVector *= mWalkSpeed;
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right) && mAnimations.getCurrentAnimation() != "jump" && mAnimations.getCurrentAnimation() != "land" )
{
mLeftDir = false;
if(mCanJump && mAnimations.getCurrentAnimation() != "inair")
{
mAnimations.setCurrentAnimation("walk");
}
mMoveSpeed += mRightVector;
}
else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left) && mAnimations.getCurrentAnimation() != "jump" && mAnimations.getCurrentAnimation() != "land" )
{
mLeftDir = true;
if(mCanJump && mAnimations.getCurrentAnimation() != "inair")
{
mAnimations.setCurrentAnimation("walk");
}
mMoveSpeed -= mRightVector;
}
if(!sf::Keyboard::isKeyPressed(sf::Keyboard::Right) && !sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
{
if(mCanJump && mAnimations.getCurrentAnimation() == "walk")
{
mAnimations.setCurrentAnimation("idle");
}
}
}
void Cat::jump()
{
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space) && mCanJump)
{
mJumping = true;
mCanJump = false;
mCurrentJumpPower = mMaxJumpPower;
mJumpDirection = -mGravityVector;
mStandsOn.clear();
mAnimations.setCurrentAnimation("jump");
}
}
void Cat::jumping()
{
if(mJumping && mAnimations.getCurrentAnimation() == "inair")
{
mMoveSpeed += Util::normalize(mJumpDirection) * mCurrentJumpPower;
mCurrentJumpPower -= mJumpDecelaration;
if(mCurrentJumpPower <= 0.f)
{
mCurrentJumpPower = 0.f;
mJumping = false;
}
}
}
void Cat::rotate()
{
mTargetAngle = Util::angle(mGravityVector) - 90;
float spriteRotation = Util::angleInRange(mSprite.getRotation());
float shortestDist = Util::shortestAngleDistance(mTargetAngle, spriteRotation);
float rotateSpeed = 0.5f;
if(!mCanJump)
{
rotateSpeed = 0.1f;
}
mAnimations.setRotation(shortestDist * rotateSpeed);
}
void Cat::render(Display& display)
{
rotate();
mSprite = mAnimations.getSprite(mPosition);
if(mLeftDir)
{
mSprite.scale(-1.f, 1.f);
}
mSprite.scale(0.4f, 0.4f);
//Set camera position
sf::Vector2f camPos = mPosition - display.getCamera().getPosition();
display.getCamera().move(sf::Vector2f(camPos.x*0.05, camPos.y*0.05));
//Set camera rotation
float camRot = mSprite.getRotation() - display.getCamera().getRotation();
while(camRot < -180) camRot += 360;
while(camRot > 180) camRot -= 360;
if(mCanJump)
display.getCamera().rotate(camRot*0.03);
else
display.getCamera().rotate(camRot*0.01);
Camera oldCam = display.getCamera();
display.setToDefaultView();
mScarfSprite.setTextureRect(sf::IntRect(512 * mNextYarn, 0, 512, 256));
mScarfSprite.setScale(0.25f, 0.25f);
display.render(mScarfSprite);
display.getCamera() = oldCam;
mYarn.render(display);
display.render(mSprite);
}
void Cat::onCollision(std::shared_ptr<Entity> entity)
{
std::shared_ptr<Ball> ball = std::dynamic_pointer_cast<Ball>(entity);
std::shared_ptr<LooseEnd> loose = std::dynamic_pointer_cast<LooseEnd>(entity);
if (ball)
{
mStandsOn.push_back(ball);
sf::Vector2f dVec = mPosition - ball->getPosition();
dVec = Util::normalize(dVec);
float distance = ball->getRadius() + mRadius;
dVec = dVec * distance;
mPosition = ball->getPosition() + dVec;
mGravityAcc = sf::Vector2f(0, 0);
if(mCanJump && mAnimations.getCurrentAnimation() == "inair")
{
mAnimations.setCurrentAnimation("land");
}
if(mAnimations.getCurrentAnimation() != "jump")
{
mCanJump = true;
}
}
if (loose)
{
if(mNextYarn == loose->getIndexValue())
{
if (loose->getIndexValue() >= mThreadTextures.size())
mYarn.setTexture(&mThreadTextures.back());
else
mYarn.setTexture(&mThreadTextures[loose->getIndexValue()]);
loose->kill();
mNextYarn++;
}
}
}
void Cat::setGravityVector(const sf::Vector2f& gravityVector)
{
mGravityVector = gravityVector;
}
sf::Vector2f Cat::getPosition() const
{
return mPosition;
}
float Cat::getMass() const
{
return mMass;
}
float Cat::getRadius() const
{
return mRadius;
}
std::vector<std::shared_ptr<Ball>>& Cat::standsOnPlanets()
{
return mStandsOn;
}
void Cat::resetStandsOn()
{
for (auto iter = mStandsOn.begin(); iter != mStandsOn.end(); ++iter)
{
(*iter)->resetMass();
}
mStandsOn.clear();
}
sf::FloatRect Cat::getGlobalBounds() const
{
return sf::FloatRect(mPosition.x - mRadius, mPosition.y - mRadius, mPosition.x + mRadius, mPosition.y + mRadius);
}
int Cat::getNextYarn()const
{
return mNextYarn;
}
bool Cat::isAlive() const
{
return mAlive;
}
|
b4b4108b26c46de8d7dfff8b9bad7a316449fa74
|
21ef7fd535d85dda08dcfe1fef3aa5688ebc8603
|
/GameProj/Zombirun/NNGameFramework/NNGameFramework/NNEffectManager.cpp
|
6a38be50310071f85a792cd9f444a0e485f1b20c
|
[
"MIT"
] |
permissive
|
LeeInJae/Portfolio
|
f007986d3c734c8606655a6f769c94fefd97a534
|
63d6dc5dd7e1f4bf66b334727dcc5fb0f84a117f
|
refs/heads/master
| 2021-01-13T07:39:47.111906
| 2016-10-20T18:38:25
| 2016-10-20T18:38:25
| 71,458,884
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,700
|
cpp
|
NNEffectManager.cpp
|
#include "NNEffectManager.h"
#include "NNPlainEffect.h"
#include "PRE_DEFINE.h"
#include "NNCrashEffect.h"
NNEffectManager* NNEffectManager::m_pInstance = nullptr;
NNEffectManager::NNEffectManager(void)
{
}
NNEffectManager::~NNEffectManager(void)
{
}
NNEffectManager* NNEffectManager::GetInstance()
{
if( m_pInstance == nullptr )
{
m_pInstance = new NNEffectManager;
}
return m_pInstance;
}
void NNEffectManager::ReleaseInstance()
{
if(m_pInstance != nullptr)
{
delete m_pInstance;
m_pInstance = nullptr;
}
}
void NNEffectManager::Update(float dTime)
{
NNObject::Update( dTime );
RemoveEffectCheck();
}
void NNEffectManager::RemoveEffectCheck()
{
// Check Effect Remove, PooBulletHitEffect Remove
for( auto Effect_Iter = m_EffectList.begin(); Effect_Iter != m_EffectList.end(); )
{
if( (*Effect_Iter)->CheckLifeTime() )
{
auto pEffect = *Effect_Iter;
Effect_Iter = m_EffectList.erase( Effect_Iter );
RemoveChild( pEffect, true );
}
else
{
++Effect_Iter;
}
}
}
void NNEffectManager::MakeEffect( EFFECT_KIND kind, float position_x, float position_y )
{
switch( kind )
{
case PLAIN:
NNPlainEffect* Effect1;
Effect1= new NNPlainEffect;
Effect1->SetPosition( 648, 330 );
Effect1->SetZindex( 0 );
Effect1->SetScale( 1.8f, 1.8f );
Effect1->SetRotation( -0.4 );
m_EffectList.push_back( Effect1 );
AddChild( Effect1);
break;
case CRASH:
NNCrashEffect* Effect2;
Effect2 = new NNCrashEffect;
Effect2->SetPosition( position_x, position_y );
Effect2->SetZindex( 0 );
Effect2->SetScale( 0.5f, 0.5f );
Effect2->SetRotation( -0.4 );
m_EffectList.push_back( Effect2 );
AddChild( Effect2 );
break;
default:
break;
}
}
|
79bea3b6ccc89de0bc626b962edf4e529793bca1
|
63c637fc2773ef46cd22e08e3334121512c31074
|
/3wkSeries/Day1/ELBOW_CASES/elbow_quad_refined/31/p
|
b1c5b4a02cc2e1b9181c06c085725fa492ca7ae3
|
[] |
no_license
|
asvogel/OpenFOAMEducation
|
438f811ad47631a414f6016e643dd12792613828
|
a1cf886fb6f9759eada7ecc34e62f97037ffd0e5
|
refs/heads/main
| 2023-09-03T17:26:24.525385
| 2021-11-05T18:08:49
| 2021-11-05T18:08:49
| 425,034,654
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 75,554
|
p
|
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 9
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class volScalarField;
location "31";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
8800
(
1.55105
1.50326
1.46456
1.43556
1.41469
1.39984
1.38921
1.38169
1.37682
1.37469
1.37586
1.37997
1.38654
1.3958
1.40854
1.42625
1.45101
1.48494
1.52748
1.58618
1.38231
1.38999
1.39745
1.40076
1.39924
1.39415
1.38765
1.38154
1.37677
1.37386
1.37349
1.37589
1.3803
1.38618
1.3929
1.39914
1.40276
1.40201
1.39657
1.38787
1.36074
1.36689
1.37102
1.37395
1.37599
1.37657
1.37544
1.3733
1.37122
1.37022
1.37108
1.37336
1.37608
1.37819
1.37875
1.37751
1.37514
1.37173
1.36716
1.3634
1.35497
1.35762
1.36036
1.36276
1.36438
1.36552
1.36623
1.36631
1.36594
1.36579
1.36643
1.36749
1.36823
1.36822
1.36754
1.3664
1.36455
1.36195
1.35953
1.35802
1.34964
1.35107
1.35284
1.35487
1.35664
1.35796
1.35892
1.35967
1.3602
1.36065
1.36117
1.36153
1.36151
1.36113
1.36035
1.35904
1.35729
1.3554
1.35407
1.35324
1.34464
1.34556
1.3468
1.34837
1.34999
1.3515
1.35276
1.35377
1.35464
1.35541
1.35593
1.35609
1.35591
1.35534
1.35436
1.35307
1.35167
1.35035
1.3495
1.34896
1.33984
1.34051
1.34147
1.34278
1.34419
1.34564
1.34705
1.34832
1.34942
1.35037
1.35099
1.35115
1.35088
1.35021
1.34926
1.34819
1.34708
1.34608
1.34547
1.34507
1.33519
1.3357
1.3365
1.33764
1.33892
1.34029
1.34171
1.34313
1.34446
1.34561
1.34637
1.34659
1.34632
1.34571
1.34493
1.34404
1.34314
1.34236
1.34189
1.34158
1.33063
1.33104
1.33171
1.33274
1.33396
1.33529
1.33671
1.3382
1.3397
1.34108
1.34203
1.34237
1.34223
1.34179
1.34117
1.34045
1.3397
1.33909
1.33873
1.33848
1.32611
1.32644
1.32702
1.32798
1.32917
1.33048
1.33192
1.33348
1.33512
1.33674
1.33794
1.3385
1.33859
1.33834
1.3379
1.33734
1.33673
1.33625
1.33597
1.33577
1.32156
1.32182
1.32235
1.32328
1.32445
1.3258
1.32731
1.32899
1.33082
1.33271
1.33423
1.33509
1.33542
1.33539
1.33511
1.3347
1.33422
1.33385
1.33363
1.33347
1.31691
1.31712
1.31761
1.31853
1.31974
1.32116
1.32279
1.32464
1.32672
1.32895
1.33087
1.3321
1.33271
1.3329
1.3328
1.33254
1.33219
1.3319
1.33174
1.33161
1.31213
1.3123
1.31276
1.31371
1.31498
1.3165
1.31826
1.32034
1.32276
1.32545
1.32785
1.32948
1.33043
1.33091
1.33105
1.33093
1.3307
1.3305
1.3304
1.33029
1.30717
1.3073
1.30775
1.30871
1.31007
1.3117
1.31365
1.31598
1.31875
1.32195
1.32498
1.32719
1.32861
1.32944
1.32984
1.32995
1.32986
1.32976
1.32969
1.32961
1.30195
1.30203
1.30248
1.3035
1.30498
1.30679
1.30901
1.31174
1.31507
1.31898
1.32274
1.32556
1.32746
1.32865
1.32936
1.32968
1.32976
1.32976
1.32975
1.32968
1.29641
1.29647
1.2969
1.29794
1.29952
1.30151
1.30401
1.30715
1.31107
1.31581
1.32051
1.32417
1.32677
1.3285
1.3296
1.33025
1.33057
1.33072
1.33076
1.3307
1.29028
1.29033
1.29076
1.29184
1.29356
1.2958
1.2987
1.30244
1.30717
1.31298
1.31882
1.32345
1.32677
1.32911
1.33074
1.33179
1.33242
1.33273
1.33281
1.33275
1.28324
1.28328
1.28375
1.2849
1.28681
1.28939
1.2928
1.29729
1.30305
1.31019
1.31742
1.32322
1.32749
1.33058
1.33279
1.33429
1.33526
1.33574
1.33587
1.3358
1.27482
1.27485
1.27539
1.2767
1.27891
1.28197
1.28608
1.29155
1.29861
1.30739
1.31634
1.32356
1.32893
1.33285
1.33574
1.33778
1.33911
1.33976
1.33992
1.33984
1.26456
1.26459
1.26524
1.26682
1.26951
1.27329
1.27838
1.28515
1.29391
1.30475
1.31576
1.32465
1.33128
1.33618
1.33981
1.34238
1.34408
1.34489
1.34509
1.34499
1.25193
1.25197
1.25278
1.25478
1.25815
1.2629
1.2693
1.27778
1.28869
1.30209
1.3156
1.32646
1.33458
1.3406
1.34506
1.34826
1.35034
1.35133
1.35156
1.35145
1.23619
1.23624
1.23731
1.2399
1.24424
1.25035
1.25855
1.26933
1.28301
1.29958
1.31605
1.32921
1.33902
1.3463
1.35175
1.35566
1.35818
1.35933
1.35959
1.35946
1.21619
1.21626
1.21771
1.22121
1.22701
1.23505
1.24576
1.25962
1.27684
1.29726
1.31722
1.333
1.34474
1.35348
1.36003
1.36475
1.36774
1.36908
1.36938
1.36921
1.19016
1.19028
1.19237
1.19733
1.20542
1.21638
1.23066
1.24864
1.27033
1.29534
1.3193
1.33803
1.35192
1.36229
1.37011
1.37574
1.37921
1.38074
1.38106
1.38087
1.15522
1.15548
1.15882
1.16645
1.17834
1.19383
1.21321
1.23659
1.26375
1.29408
1.32248
1.34442
1.36067
1.37286
1.38206
1.38867
1.39266
1.39439
1.39471
1.39447
1.1058
1.10693
1.1136
1.12661
1.14502
1.16741
1.19378
1.22397
1.25755
1.29381
1.32697
1.35231
1.37105
1.38516
1.39583
1.40347
1.40807
1.40997
1.41026
1.40997
1.03317
1.04074
1.0561
1.07907
1.10703
1.13849
1.17337
1.21139
1.25214
1.29492
1.33331
1.36245
1.38405
1.40042
1.4129
1.42192
1.42739
1.42969
1.43008
1.42986
0.955556
0.973032
0.997793
1.0311
1.06888
1.10953
1.15297
1.19907
1.24748
1.29762
1.3424
1.37646
1.40188
1.42124
1.43618
1.44727
1.45402
1.45673
1.4574
1.45737
0.891742
0.912105
0.944694
0.986496
1.03277
1.08196
1.13364
1.18761
1.2435
1.30077
1.35158
1.39013
1.41889
1.44085
1.45771
1.47008
1.47787
1.48139
1.48194
1.48199
0.839794
0.861951
0.899708
0.947513
1.00047
1.05672
1.1156
1.17674
1.23962
1.30358
1.35996
1.40249
1.43405
1.45801
1.4764
1.49005
1.49901
1.50259
1.50325
1.50337
0.796703
0.819945
0.861167
0.913754
0.972019
1.03406
1.09909
1.16654
1.23574
1.30582
1.36722
1.41323
1.44715
1.47277
1.4924
1.50688
1.51636
1.52041
1.52133
1.52149
0.759875
0.783749
0.827725
0.883976
0.946657
1.01359
1.08392
1.15694
1.23181
1.30744
1.37338
1.42244
1.45833
1.48527
1.50576
1.52087
1.5307
1.53518
1.53633
1.53651
0.727357
0.751668
0.797719
0.857083
0.9235
0.994682
1.06968
1.14768
1.22769
1.30843
1.37853
1.43033
1.46792
1.49589
1.51702
1.53253
1.54259
1.54734
1.54858
1.54874
0.697725
0.722431
0.770223
0.832227
0.901874
0.976778
1.05594
1.13846
1.22321
1.30872
1.38275
1.43712
1.47625
1.50509
1.52663
1.54238
1.55251
1.55736
1.55867
1.55879
0.670114
0.695177
0.744532
0.80879
0.881282
0.959479
1.04238
1.12902
1.21819
1.30823
1.38609
1.44299
1.48362
1.51328
1.53524
1.55112
1.56131
1.56622
1.56762
1.5677
0.643807
0.669285
0.720055
0.786314
0.861354
0.942498
1.02876
1.11918
1.21249
1.3069
1.38856
1.44805
1.49026
1.52082
1.54324
1.55932
1.56952
1.57436
1.57579
1.57592
0.618535
0.644444
0.696289
0.764519
0.841834
0.925628
1.01495
1.10883
1.20602
1.30467
1.39018
1.45241
1.49636
1.52796
1.55093
1.56726
1.57752
1.5823
1.58363
1.5837
0.593935
0.620399
0.673285
0.743222
0.82257
0.908745
1.00083
1.0979
1.19871
1.30148
1.39091
1.45611
1.50202
1.53484
1.5585
1.57516
1.58549
1.5902
1.59139
1.59138
0.56993
0.596835
0.650845
0.722305
0.803481
0.891794
0.986375
1.08635
1.19055
1.29729
1.39075
1.45914
1.50728
1.54151
1.56601
1.58306
1.59345
1.59804
1.5991
1.599
0.54644
0.573888
0.628857
0.701714
0.784539
0.874761
0.971578
1.07418
1.18151
1.29207
1.38958
1.46141
1.51211
1.54803
1.5735
1.59099
1.60138
1.60577
1.60666
1.60648
0.523376
0.55142
0.607315
0.68145
0.765743
0.85767
0.956475
1.06143
1.17162
1.28577
1.38731
1.46284
1.51646
1.55438
1.581
1.59893
1.60924
1.61332
1.61402
1.61378
0.500747
0.529444
0.586246
0.661539
0.747146
0.840568
0.941126
1.04816
1.1609
1.27836
1.38388
1.46329
1.52022
1.56057
1.58857
1.60691
1.61694
1.62059
1.62106
1.62077
0.478726
0.508029
0.565691
0.642023
0.728793
0.823528
0.9256
1.03445
1.14943
1.2699
1.3792
1.46261
1.52321
1.56653
1.59636
1.61509
1.62451
1.62747
1.62767
1.62735
0.457342
0.487222
0.545683
0.622961
0.710752
0.80662
0.909998
1.02038
1.1373
1.26042
1.37323
1.46063
1.52521
1.57212
1.60449
1.6239
1.63224
1.63392
1.63371
1.6334
0.436538
0.467065
0.526262
0.604394
0.69309
0.789931
0.894411
1.00607
1.12462
1.25
1.36595
1.45721
1.52592
1.577
1.61298
1.63402
1.64111
1.64045
1.63915
1.63903
0.416487
0.447582
0.507488
0.586392
0.675869
0.773544
0.878936
0.991644
1.1115
1.23875
1.35737
1.45223
1.52504
1.5806
1.62134
1.64595
1.6532
1.6496
1.64544
1.64441
0.397102
0.428783
0.489344
0.568928
0.659059
0.757413
0.863517
0.977026
1.09789
1.2266
1.34737
1.44542
1.52224
1.58214
1.6284
1.65905
1.67023
1.66733
1.65686
1.63976
0.378455
0.410676
0.471707
0.551813
0.642366
0.741203
0.847733
0.96173
1.08321
1.21288
1.33526
1.43592
1.51681
1.58044
1.63147
1.66934
1.68546
1.67644
1.65987
1.64195
0.360718
0.393124
0.454762
0.535288
0.62609
0.725261
0.831813
0.94609
1.06781
1.1979
1.3212
1.42341
1.50827
1.57454
1.62541
1.66352
1.68259
1.66475
1.59398
1.56033
0.34454
0.374966
0.438842
0.519946
0.610943
0.710078
0.816051
0.930329
1.0519
1.1818
1.3052
1.40772
1.49555
1.56455
1.60619
1.63594
1.6386
1.58879
1.51684
1.47192
0.288638
0.35908
0.424237
0.504616
0.595483
0.694255
0.800387
0.914182
1.03514
1.16416
1.28672
1.38849
1.47538
1.55164
1.55521
1.5705
1.53561
1.4709
1.39344
1.34978
0.327442
0.343378
0.402976
0.482891
0.573038
0.671508
0.7766
0.889497
1.00909
1.13608
1.25574
1.35471
1.43296
1.50906
1.50619
1.40096
1.29705
1.22508
1.15107
1.18652
0.296424
0.325633
0.386049
0.465453
0.555582
0.653701
0.758932
0.871059
0.989381
1.11426
1.23067
1.32538
1.39602
1.43604
1.39123
1.24647
1.1173
1.02536
0.924297
0.979535
0.272537
0.304733
0.36633
0.446042
0.536223
0.63418
0.739222
0.850387
0.967133
1.08938
1.2018
1.29079
1.35164
1.36061
1.25663
1.07958
0.921849
0.799342
0.664391
0.701774
0.249234
0.282969
0.345739
0.426284
0.516632
0.614439
0.718906
0.828991
0.943983
1.06327
1.17094
1.2536
1.29972
1.27574
1.11759
0.913836
0.714455
0.534557
0.335066
0.326728
0.226673
0.260752
0.324391
0.405664
0.496214
0.593819
0.697602
0.806504
0.919513
1.03551
1.13791
1.21339
1.24212
1.1835
0.985173
0.765008
0.534552
0.329455
0.069562
-0.254994
0.203876
0.237905
0.30203
0.38379
0.474554
0.572011
0.675186
0.78289
0.893839
1.00635
1.10332
1.17053
1.18184
1.07222
0.87017
0.650087
0.431511
0.245684
0.174672
0.0761241
0.17999
0.213987
0.278343
0.360337
0.451185
0.548409
0.650889
0.757233
0.865825
0.974384
1.06551
1.12285
1.10942
0.962743
0.768676
0.567986
0.395196
0.294871
0.270594
0.252415
0.154694
0.188681
0.253176
0.335239
0.426001
0.522837
0.624396
0.729091
0.83492
0.938908
1.02371
1.06897
1.03471
0.861576
0.676928
0.50228
0.36757
0.324961
0.309903
0.307946
0.127783
0.161844
0.226482
0.308532
0.399082
0.495323
0.59573
0.698458
0.801096
0.89994
0.977732
1.00977
0.957879
0.766797
0.59201
0.435785
0.346282
0.331549
0.329579
0.329547
0.0992466
0.133491
0.198263
0.280254
0.370453
0.465925
0.564939
0.665376
0.764401
0.857588
0.927435
0.947671
0.862881
0.679902
0.512927
0.382825
0.344357
0.34007
0.339722
0.340341
0.0693975
0.103847
0.168665
0.250532
0.340249
0.434754
0.53212
0.629945
0.724922
0.811977
0.873372
0.877981
0.765871
0.598208
0.447935
0.359103
0.349921
0.347508
0.346421
0.34674
0.0388124
0.0733207
0.137978
0.219627
0.30871
0.402035
0.497505
0.592394
0.682932
0.763375
0.81656
0.802137
0.675954
0.524198
0.393404
0.36886
0.351835
0.349604
0.350339
0.350845
0.00795916
0.0423802
0.106749
0.187969
0.276234
0.36817
0.461475
0.553128
0.638879
0.712421
0.756923
0.726361
0.585012
0.456488
0.360824
0.319624
0.339401
0.349222
0.352182
0.352902
-0.0223449
0.0118116
0.0757347
0.156207
0.243407
0.333726
0.424608
0.512766
0.593446
0.659919
0.694375
0.649821
0.489968
0.391321
0.347732
0.34823
0.339377
0.339346
0.342498
0.344431
-0.050554
-0.0172603
0.0457929
0.125211
0.211096
0.299502
0.387723
0.472187
0.547647
0.606805
0.633273
0.571178
0.38882
0.279794
0.323967
0.295035
0.2847
0.28346
0.287888
0.291809
-0.075363
-0.0430714
0.0180133
0.096175
0.180348
0.266556
0.351888
0.432555
0.502876
0.554528
0.576995
0.490325
0.281157
0.07996
0.087138
0.136688
0.17532
0.189964
0.196031
0.199781
-0.0948491
-0.064382
-0.00555537
0.07045
0.152424
0.236145
0.318438
0.39531
0.460884
0.505388
0.524966
0.42181
0.207495
-0.128455
-0.322931
-0.0932803
0.0263963
0.0661798
0.0781673
0.0870426
-0.10718
-0.079287
-0.0235033
0.049691
0.128908
0.209748
0.28889
0.36219
0.423633
0.462526
0.478259
0.387631
0.260163
0.0874011
-0.128218
-0.0455033
-0.0360477
-0.031208
-0.0221254
-0.0180932
-0.110105
-0.0859562
-0.0341847
0.0354936
0.111429
0.188969
0.264952
0.33516
0.393095
0.428644
0.438642
0.385554
0.44441
0.794475
0.907714
0.429069
0.0616822
0.0112191
-0.00274974
-0.00345134
-0.102303
-0.0824545
-0.035792
0.0292339
0.101308
0.175342
0.248356
0.316235
0.371851
0.404945
0.407552
0.346296
0.326381
0.489966
0.38865
6.41063e-05
-0.169957
-0.119066
-0.0402356
-0.0609621
-0.0819883
-0.0663039
-0.0270511
0.0318551
0.0994462
0.169975
0.240556
0.307251
0.36337
0.396019
0.384762
0.179983
-0.399752
-1.38872
-2.04143
-2.38603
-2.12764
-1.62615
-1.18017
-1.01651
-0.0505704
-0.0397845
-0.00831371
0.0431602
0.105894
0.173166
0.242299
0.309727
0.370281
0.411416
0.40343
0.154156
-0.546342
-1.49214
-2.19099
-2.43805
-2.21919
-1.8483
-1.48199
-1.3029
-0.012334
-0.00592299
0.0170702
0.061076
0.119084
0.183963
0.253146
0.324319
0.39265
0.456253
0.489201
0.436232
0.23474
0.123409
0.120758
0.345971
0.658343
0.932359
1.11732
1.20085
0.0268337
0.0303814
0.0445792
0.0815386
0.136008
0.199905
0.270686
0.347498
0.429609
0.517409
0.619653
0.76575
1.02637
1.51415
2.10737
2.6663
3.07737
3.31157
3.41249
3.43926
0.0609706
0.0629936
0.0709401
0.100549
0.152105
0.217043
0.290811
0.373659
0.468033
0.576832
0.706888
0.847129
1.13087
1.70666
2.35617
2.92506
3.33045
3.55891
3.65852
3.68518
0.0943047
0.0949509
0.0976983
0.118134
0.165693
0.231955
0.308532
0.39494
0.490975
0.60152
0.716153
0.840685
1.00871
1.45889
1.98136
2.41873
2.73888
2.92467
3.00926
3.03401
0.122785
0.123919
0.124678
0.136687
0.178974
0.245607
0.32393
0.41021
0.503107
0.607981
0.71166
0.812415
0.918176
1.19939
1.58913
1.90989
2.14445
2.28192
2.34494
2.36181
0.138893
0.139433
0.138531
0.147908
0.191717
0.261741
0.341434
0.425204
0.513558
0.609658
0.699067
0.775303
0.840776
1.02034
1.28245
1.5065
1.67037
1.76363
1.80487
1.81573
0.156545
0.153454
0.150252
0.16191
0.212023
0.286548
0.365864
0.444368
0.524586
0.608962
0.685177
0.74429
0.798457
0.911235
1.08588
1.23012
1.33306
1.39239
1.41775
1.42258
0.220946
0.21566
0.21141
0.224291
0.269857
0.335246
0.403523
0.470541
0.538505
0.609355
0.674505
0.724037
0.767624
0.840615
0.955899
1.04779
1.11015
1.14513
1.15911
1.16041
0.346627
0.343034
0.340053
0.347531
0.374019
0.412781
0.457156
0.504641
0.555922
0.612388
0.665936
0.707902
0.745993
0.794831
0.865304
0.92389
0.963247
0.984623
0.993435
0.993595
0.482094
0.480648
0.478417
0.477879
0.483061
0.494991
0.514506
0.541015
0.575001
0.616693
0.659353
0.697227
0.731644
0.765297
0.804741
0.841174
0.866567
0.88181
0.887428
0.886777
0.577619
0.577117
0.574713
0.568883
0.561687
0.558313
0.561688
0.572877
0.592337
0.620338
0.651539
0.683657
0.713682
0.737911
0.761658
0.783868
0.801581
0.812489
0.816991
0.815905
0.626996
0.626609
0.62417
0.617626
0.607741
0.598937
0.594633
0.596674
0.605665
0.621557
0.641745
0.664391
0.691279
0.703518
0.717669
0.735662
0.751201
0.761218
0.76509
0.76366
0.646486
0.646005
0.643855
0.63855
0.630177
0.621474
0.615009
0.61253
0.614665
0.620923
0.628809
0.638336
0.649419
0.653951
0.66676
0.686998
0.705091
0.716658
0.721157
0.719532
0.651869
0.651349
0.649603
0.64577
0.639868
0.633061
0.626901
0.622682
0.620513
0.61898
0.614283
0.604276
0.593092
0.593962
0.613493
0.639022
0.659543
0.672001
0.676925
0.675786
0.652208
0.651737
0.650382
0.647549
0.643478
0.638634
0.633702
0.629377
0.625412
0.619016
0.603429
0.571874
0.537422
0.537809
0.571385
0.603502
0.624961
0.636161
0.640015
0.639092
0.651011
0.650682
0.649765
0.647689
0.64472
0.641353
0.637931
0.634715
0.631316
0.623952
0.605102
0.56354
0.515506
0.525252
0.563666
0.593861
0.610826
0.617742
0.619783
0.619291
0.648216
0.648094
0.647695
0.646489
0.644397
0.642321
0.640608
0.639709
0.639037
0.63585
0.62315
0.590827
0.557844
0.5742
0.601961
0.618694
0.626178
0.6287
0.630045
0.630438
0.642138
0.642208
0.642267
0.641884
0.641088
0.640559
0.641126
0.643429
0.648804
0.652636
0.654284
0.644821
0.638708
0.653459
0.666061
0.671629
0.674286
0.676794
0.677781
0.676662
0.631107
0.631378
0.631888
0.632351
0.63295
0.634466
0.637956
0.644263
0.655197
0.670509
0.688145
0.702132
0.720563
0.730656
0.726499
0.722848
0.72402
0.72686
0.726568
0.724991
0.613565
0.614015
0.614954
0.616288
0.618313
0.621974
0.628466
0.639533
0.657206
0.682565
0.712687
0.742205
0.776213
0.776916
0.764959
0.7588
0.75862
0.759151
0.758224
0.757128
0.587044
0.587883
0.589315
0.591454
0.594798
0.600407
0.609753
0.625083
0.648317
0.681358
0.718098
0.752363
0.783092
0.781079
0.774313
0.775699
0.779223
0.780683
0.777627
0.776298
0.548474
0.549568
0.551529
0.554497
0.559011
0.566024
0.576994
0.594267
0.6202
0.657182
0.69738
0.726268
0.742059
0.742484
0.751982
0.774235
0.789829
0.788377
0.783309
0.782702
0.494446
0.495823
0.498189
0.501803
0.506956
0.513989
0.523707
0.537842
0.55958
0.593474
0.639656
0.670303
0.667108
0.671074
0.717607
0.760303
0.790476
0.794184
0.788941
0.788907
0.423147
0.424604
0.42707
0.430794
0.43533
0.439694
0.442904
0.444525
0.446693
0.469155
0.533616
0.581176
0.573335
0.591444
0.674148
0.749234
0.78736
0.789437
0.78525
0.783709
0.336076
0.337291
0.339408
0.342365
0.344271
0.341827
0.330087
0.302527
0.264816
0.267202
0.370664
0.45907
0.466001
0.512593
0.609835
0.696387
0.738371
0.729592
0.723191
0.720466
0.240189
0.240755
0.242138
0.243598
0.24115
0.227929
0.191218
0.114412
0.00914603
-0.00455735
0.161974
0.299565
0.339286
0.415657
0.513986
0.580699
0.595109
0.591019
0.586373
0.583989
0.148624
0.148104
0.148595
0.148733
0.142328
0.118146
0.0537541
-0.0773951
-0.242556
-0.263184
-0.044075
0.141909
0.194455
0.304731
0.38309
0.418173
0.407139
0.404147
0.403871
0.403649
0.0728892
0.0724275
0.0735707
0.073489
0.0677318
0.0445896
-0.0259742
-0.173385
-0.329021
-0.363083
-0.147097
0.012993
0.0833836
0.197731
0.231472
0.229528
0.226369
0.224623
0.224924
0.225175
0.0210737
0.0206453
0.0215864
0.0239012
0.0251247
0.0229859
0.00620133
-0.0431794
-0.107419
-0.14112
-0.0824405
-0.00811831
-0.00723395
-0.0174256
-0.0127654
0.0549711
0.0513263
0.0467557
0.0456413
0.0451776
0.57893
0.761451
0.974386
1.15643
1.30307
1.42007
1.51772
1.60015
1.63699
1.61406
0.911313
1.04177
1.18112
1.30174
1.40389
1.4889
1.55773
1.60655
1.6313
1.64311
1.1474
1.23637
1.33106
1.41506
1.48747
1.54808
1.59622
1.63135
1.65651
1.67421
1.31866
1.38114
1.44745
1.50813
1.56095
1.60574
1.64243
1.67157
1.69523
1.71335
1.4508
1.49656
1.54476
1.59086
1.63157
1.66703
1.69727
1.72233
1.74326
1.76099
1.55908
1.59344
1.63315
1.67021
1.70413
1.73443
1.76083
1.78293
1.80114
1.81844
1.6541
1.68369
1.71878
1.75184
1.78259
1.81044
1.83473
1.85484
1.8706
1.88767
1.74428
1.77405
1.80874
1.84135
1.87146
1.89848
1.9217
1.94045
1.954
1.97104
1.8406
1.87407
1.91115
1.94511
1.97549
2.00196
2.02414
2.04159
2.05358
2.071
1.95631
1.99411
2.03307
2.0676
2.09715
2.12207
2.14258
2.15858
2.17013
2.18822
2.10172
2.14042
2.17652
2.20733
2.23312
2.25532
2.27445
2.29005
2.30253
2.32054
2.27671
2.30862
2.33488
2.35735
2.37739
2.39616
2.41393
2.43044
2.44583
2.4639
2.46545
2.48275
2.49791
2.51419
2.53013
2.5447
2.55793
2.57188
2.58945
2.60961
2.64745
2.65689
2.66845
2.67929
2.68859
2.69821
2.70903
2.72042
2.7318
2.74716
2.85458
2.85827
2.84335
2.82855
2.8223
2.828
2.8465
2.87682
2.90901
2.93567
3.16092
3.02606
2.94944
2.90712
2.88971
2.89368
2.92109
2.97751
3.08014
3.30451
1.44165
1.43951
1.43503
1.4264
1.41416
1.40202
1.39177
1.38385
1.37818
1.37485
1.3744
1.37703
1.38205
1.3892
1.39854
1.41004
1.42266
1.43368
1.43978
1.44283
1.36611
1.37196
1.37829
1.38278
1.38524
1.3849
1.38214
1.3783
1.37474
1.3724
1.37215
1.37423
1.3778
1.38202
1.38577
1.38761
1.38664
1.38314
1.37795
1.37132
1.35772
1.36002
1.36342
1.36641
1.36847
1.36995
1.37068
1.37033
1.36925
1.36828
1.36834
1.36965
1.37136
1.37258
1.37269
1.37175
1.37016
1.36779
1.36451
1.36158
1.35226
1.35334
1.35517
1.35755
1.35956
1.36097
1.36197
1.36267
1.36301
1.36314
1.3635
1.36417
1.36464
1.36461
1.36411
1.3632
1.36168
1.35955
1.35743
1.35604
1.34712
1.34778
1.34889
1.35059
1.35236
1.35398
1.35525
1.35622
1.35703
1.35771
1.35829
1.35867
1.35872
1.35842
1.35775
1.35661
1.35511
1.35351
1.35215
1.35136
1.34222
1.34268
1.34347
1.34477
1.34625
1.34776
1.3492
1.35045
1.35151
1.35244
1.35317
1.35354
1.3535
1.35306
1.35223
1.35112
1.3499
1.34869
1.34772
1.3472
1.3375
1.33784
1.33845
1.33953
1.34083
1.34221
1.34363
1.34503
1.34633
1.34747
1.34836
1.3488
1.34874
1.34825
1.34747
1.34653
1.34555
1.34458
1.34384
1.34346
1.3329
1.33317
1.33367
1.33459
1.33578
1.33708
1.33846
1.33991
1.34136
1.34271
1.3438
1.34437
1.34437
1.34398
1.34335
1.34259
1.34177
1.34099
1.34043
1.34013
1.32837
1.32858
1.32899
1.32982
1.33094
1.3322
1.33357
1.33504
1.33661
1.33817
1.3395
1.34024
1.34041
1.34021
1.33976
1.33916
1.33849
1.33787
1.33743
1.3372
1.32384
1.324
1.32436
1.32512
1.3262
1.32745
1.32885
1.33039
1.33206
1.33381
1.33541
1.33645
1.33689
1.33691
1.33664
1.33621
1.33569
1.33519
1.33485
1.33467
1.31925
1.31938
1.31969
1.32041
1.32149
1.32277
1.32423
1.3259
1.32776
1.32978
1.33172
1.33311
1.33384
1.33409
1.33401
1.33373
1.33335
1.33297
1.33272
1.33258
1.31454
1.31463
1.31491
1.31562
1.31673
1.31809
1.31965
1.32148
1.32359
1.32594
1.32831
1.33013
1.33121
1.33173
1.33188
1.33177
1.33153
1.33125
1.33106
1.33096
1.30968
1.30974
1.31
1.3107
1.31186
1.31331
1.315
1.317
1.31939
1.32218
1.32508
1.32742
1.32892
1.32982
1.33027
1.33038
1.33029
1.33012
1.33001
1.32993
1.3046
1.30463
1.30487
1.30559
1.30681
1.30838
1.31026
1.31255
1.31532
1.3186
1.32216
1.32518
1.32724
1.32853
1.32927
1.32965
1.32974
1.3297
1.32966
1.32961
1.29924
1.29924
1.29946
1.30019
1.3015
1.30321
1.30531
1.30794
1.31121
1.31519
1.31958
1.32336
1.32604
1.32786
1.329
1.32963
1.32998
1.3301
1.33014
1.33012
1.29344
1.29343
1.29364
1.29438
1.29575
1.2976
1.29997
1.30299
1.30683
1.31159
1.31699
1.32181
1.32532
1.32778
1.32942
1.33052
1.33119
1.33153
1.33167
1.33167
1.2869
1.28687
1.2871
1.28788
1.28935
1.29143
1.29417
1.29777
1.30242
1.30827
1.31493
1.3209
1.32533
1.32851
1.33077
1.33235
1.3334
1.33399
1.33422
1.33423
1.27923
1.27919
1.27944
1.2803
1.28194
1.28431
1.28754
1.29184
1.29747
1.30461
1.31283
1.32028
1.32589
1.32999
1.33296
1.33509
1.33658
1.33744
1.33777
1.33778
1.26993
1.26987
1.27018
1.2712
1.27313
1.27599
1.27992
1.28521
1.29216
1.30098
1.31111
1.32031
1.32723
1.33236
1.33613
1.3389
1.34082
1.34194
1.34236
1.34238
1.25854
1.25846
1.25886
1.26013
1.2625
1.26606
1.27096
1.27755
1.28619
1.29711
1.3096
1.32088
1.3294
1.33572
1.34039
1.34384
1.34624
1.34763
1.34814
1.34816
1.24442
1.24433
1.24487
1.2465
1.24951
1.25404
1.26027
1.26861
1.27947
1.29306
1.3084
1.32216
1.33251
1.3402
1.34592
1.35014
1.3531
1.35477
1.35536
1.35539
1.22666
1.22655
1.22732
1.2295
1.23343
1.23933
1.24742
1.25815
1.27192
1.28885
1.30764
1.32428
1.33673
1.34599
1.35289
1.35801
1.36158
1.36356
1.36424
1.36427
1.20381
1.20369
1.20482
1.20784
1.21319
1.22115
1.23193
1.24595
1.26352
1.28458
1.30745
1.32739
1.34222
1.35324
1.3615
1.36763
1.37189
1.37418
1.37496
1.37499
1.17361
1.17352
1.17529
1.17975
1.18745
1.19867
1.21343
1.232
1.25444
1.28049
1.30804
1.33166
1.34913
1.36212
1.37189
1.37916
1.38412
1.38676
1.38763
1.38763
1.13211
1.1322
1.13539
1.14278
1.15472
1.17126
1.19188
1.21654
1.24505
1.27692
1.30967
1.33727
1.35756
1.37269
1.38411
1.39262
1.39832
1.40129
1.40223
1.4022
1.07188
1.07314
1.08089
1.09469
1.11427
1.13912
1.16789
1.20027
1.23594
1.27431
1.31261
1.34435
1.36754
1.38486
1.39795
1.40767
1.41424
1.41756
1.41847
1.4184
1.00035
1.00238
1.01701
1.04073
1.07099
1.10543
1.14307
1.18372
1.22712
1.27277
1.31769
1.35476
1.38198
1.40244
1.41798
1.42952
1.43734
1.44132
1.4424
1.44238
0.926952
0.933599
0.955224
0.988847
1.02888
1.07261
1.11904
1.16796
1.21918
1.27225
1.324
1.36659
1.39791
1.42157
1.43973
1.45345
1.46267
1.46656
1.46781
1.46807
0.867932
0.876524
0.902855
0.943206
0.990753
1.04224
1.09647
1.15307
1.21171
1.27189
1.33009
1.37774
1.41267
1.43897
1.45908
1.47419
1.48425
1.4892
1.49124
1.49162
0.820025
0.829184
0.85895
0.90415
0.957428
1.0151
1.07586
1.13919
1.20455
1.27127
1.33544
1.38761
1.42561
1.45408
1.47579
1.49219
1.50346
1.5092
1.51153
1.51195
0.779877
0.789263
0.821352
0.870296
0.92817
0.990934
1.0572
1.12635
1.19768
1.27035
1.3399
1.39611
1.43675
1.467
1.48995
1.50728
1.51923
1.5256
1.5282
1.52867
0.744976
0.754459
0.788255
0.840259
0.90193
0.969005
1.04004
1.11432
1.191
1.26905
1.34353
1.40336
1.44629
1.47799
1.50188
1.51985
1.5323
1.53917
1.54191
1.54239
0.713738
0.723264
0.758401
0.812945
0.877823
0.948622
1.02386
1.10272
1.18426
1.26727
1.34633
1.40951
1.45451
1.48745
1.51205
1.53039
1.54313
1.55025
1.55303
1.55354
0.68498
0.694562
0.730822
0.787571
0.855207
0.929267
1.00823
1.09123
1.17723
1.26488
1.3483
1.41472
1.46167
1.49574
1.52094
1.53956
1.5524
1.55966
1.56241
1.56295
0.657929
0.66757
0.704825
0.763486
0.833602
0.910559
0.992851
1.0796
1.16972
1.26176
1.34942
1.41905
1.468
1.50321
1.52903
1.54795
1.5609
1.5682
1.57098
1.57134
0.632083
0.641822
0.680011
0.740289
0.812663
0.892215
0.977506
1.06768
1.16161
1.25782
1.34965
1.42257
1.47362
1.51012
1.53664
1.55591
1.569
1.57627
1.57902
1.57936
0.607041
0.616965
0.655985
0.717815
0.792172
0.87405
0.962051
1.05533
1.15281
1.25298
1.34896
1.42531
1.47868
1.51663
1.544
1.56371
1.57699
1.58426
1.5869
1.58724
0.582621
0.592786
0.632568
0.695886
0.772008
0.855969
0.946411
1.04252
1.14326
1.24722
1.34731
1.42727
1.48321
1.52283
1.55121
1.57148
1.58498
1.59222
1.59473
1.59502
0.558768
0.569155
0.609735
0.674369
0.752098
0.837933
0.93056
1.02923
1.13297
1.24048
1.34465
1.4284
1.48718
1.52874
1.55833
1.57925
1.59298
1.60013
1.60247
1.60267
0.535371
0.546074
0.587381
0.653246
0.732425
0.819932
0.914509
1.01547
1.12194
1.23277
1.34089
1.42858
1.49053
1.53436
1.56537
1.58702
1.60096
1.60797
1.61007
1.61016
0.512491
0.523485
0.56554
0.632522
0.71301
0.802004
0.89831
1.00129
1.1102
1.22407
1.33599
1.42771
1.49315
1.53966
1.57238
1.59485
1.60888
1.61559
1.61739
1.61738
0.490099
0.501404
0.544232
0.612236
0.693894
0.784197
0.882018
0.98678
1.09783
1.21442
1.32991
1.42568
1.49488
1.54452
1.5794
1.60284
1.61677
1.62293
1.62434
1.62422
0.468384
0.479928
0.523494
0.592434
0.675139
0.766594
0.865709
0.972006
1.08491
1.2039
1.32265
1.42238
1.49554
1.5488
1.58646
1.61123
1.62487
1.63
1.63078
1.63056
0.447217
0.459105
0.503365
0.573154
0.656785
0.749242
0.849484
0.957065
1.07154
1.19261
1.31422
1.4177
1.49491
1.5522
1.59344
1.6204
1.63379
1.63714
1.6367
1.63628
0.426766
0.438966
0.48388
0.554451
0.638919
0.732232
0.833429
0.942083
1.05784
1.18061
1.30469
1.41157
1.49277
1.55432
1.59997
1.63051
1.64477
1.64592
1.64272
1.64114
0.406978
0.419471
0.465093
0.536383
0.621584
0.715634
0.817628
0.927142
1.04393
1.16807
1.29417
1.40395
1.48895
1.5547
1.6052
1.64098
1.65878
1.65989
1.65269
1.64258
0.387935
0.400664
0.446904
0.518797
0.604569
0.699163
0.80174
0.91183
1.02934
1.15444
1.28206
1.39419
1.48285
1.55267
1.60783
1.65014
1.67477
1.67965
1.67105
1.66173
0.369694
0.382637
0.429312
0.501738
0.587889
0.682817
0.785787
0.896132
1.01404
1.13963
1.26821
1.38198
1.47381
1.54753
1.60532
1.6523
1.68023
1.69022
1.6543
1.6001
0.352518
0.366161
0.41242
0.485265
0.571432
0.666466
0.769727
0.880172
0.99809
1.12373
1.25261
1.36721
1.46089
1.53905
1.59581
1.63606
1.66507
1.65592
1.59856
1.53236
0.336102
0.350557
0.396418
0.469988
0.555526
0.650585
0.753341
0.864011
0.981643
1.10689
1.23528
1.34977
1.4431
1.52839
1.57837
1.63148
1.60576
1.56639
1.49651
1.42667
0.350215
0.368256
0.416822
0.49445
0.584837
0.683617
0.791621
0.905129
1.02567
1.1541
1.27598
1.37722
1.46213
1.55252
1.60336
1.52283
1.47909
1.41721
1.34357
1.29449
0.325845
0.342289
0.377844
0.445795
0.530905
0.62542
0.728271
0.838238
0.954937
1.07871
1.20485
1.31707
1.4067
1.48593
1.55685
1.55925
1.43887
1.35517
1.29223
1.20746
0.305859
0.321553
0.362865
0.43224
0.517603
0.611692
0.71334
0.822337
0.937946
1.06012
1.18424
1.29392
1.38039
1.4468
1.47369
1.40406
1.26211
1.16471
1.08841
0.997551
0.285467
0.297997
0.343809
0.414487
0.500031
0.594283
0.695844
0.804435
0.919022
1.0395
1.16054
1.26546
1.3448
1.3955
1.37343
1.24387
1.08801
0.967223
0.866959
0.726398
0.26188
0.27497
0.322808
0.394626
0.480495
0.574767
0.676176
0.784098
0.89746
1.01588
1.13333
1.23281
1.3042
1.33521
1.27666
1.09046
0.902388
0.742537
0.595105
0.393734
0.239394
0.252105
0.301173
0.374161
0.460533
0.554761
0.655768
0.762773
0.874664
0.99066
1.10415
1.19765
1.26039
1.26224
1.15165
0.945478
0.723685
0.509957
0.323558
-0.0970401
0.216958
0.229244
0.278802
0.352659
0.43944
0.533689
0.634285
0.740363
0.850672
0.964017
1.07322
1.1601
1.21235
1.17964
1.02686
0.81698
0.58823
0.362397
0.168967
-0.145357
0.193664
0.205787
0.255488
0.329877
0.416943
0.511223
0.611446
0.716619
0.825291
0.935818
1.04049
1.12031
1.1594
1.10715
0.914317
0.712692
0.503901
0.325651
0.249821
0.21348
0.16906
0.181006
0.230871
0.30553
0.392681
0.486831
0.586529
0.690572
0.797278
0.904505
1.00401
1.07607
1.10041
1.01869
0.814013
0.624975
0.453098
0.338195
0.300406
0.288535
0.142949
0.154837
0.204798
0.279615
0.366728
0.460583
0.559548
0.662206
0.766578
0.869997
0.963658
1.02779
1.03036
0.913408
0.723154
0.547868
0.401131
0.339984
0.325239
0.320406
0.115294
0.126946
0.177215
0.252145
0.339123
0.432513
0.530541
0.631529
0.7332
0.832352
0.919462
0.9753
0.950943
0.81355
0.637014
0.472819
0.365817
0.327522
0.334033
0.334562
0.0861012
0.0977293
0.148161
0.223192
0.309941
0.402711
0.499574
0.598616
0.697217
0.791612
0.871692
0.917353
0.875676
0.718862
0.558233
0.411334
0.363158
0.348287
0.343927
0.343573
0.0557863
0.0674246
0.11786
0.192961
0.279357
0.371337
0.466807
0.563622
0.65878
0.747958
0.820664
0.854571
0.804802
0.634387
0.487051
0.380128
0.331616
0.345056
0.347926
0.348379
0.0248295
0.0363997
0.0868505
0.161788
0.247711
0.338702
0.432554
0.526852
0.618222
0.701795
0.76665
0.791378
0.719207
0.554819
0.427573
0.351435
0.346727
0.348253
0.350431
0.351486
-0.00591249
0.00535685
0.0558034
0.130203
0.215501
0.305295
0.397275
0.488785
0.576074
0.653746
0.710591
0.72448
0.622297
0.476525
0.379311
0.368603
0.34617
0.345462
0.350723
0.352107
-0.0355247
-0.0246198
0.0253171
0.0992185
0.183428
0.271817
0.361663
0.45014
0.533136
0.604591
0.653721
0.649711
0.526279
0.382911
0.341316
0.327133
0.319352
0.318128
0.319473
0.322907
-0.062535
-0.0521038
-0.00316474
0.0696106
0.152561
0.239182
0.326642
0.411889
0.490487
0.555597
0.597488
0.579882
0.431742
0.253463
0.18799
0.228778
0.231637
0.236762
0.240511
0.246236
-0.0854659
-0.0757236
-0.028139
0.0429075
0.124045
0.208568
0.293389
0.375272
0.449544
0.508665
0.543126
0.518736
0.348681
0.101586
-0.126925
-0.0431267
0.0692405
0.124906
0.139875
0.145176
-0.102305
-0.093404
-0.0479906
0.0207819
0.0993455
0.181338
0.263302
0.341802
0.412002
0.466039
0.492343
0.469655
0.305962
0.0847263
-0.332501
-0.246277
-0.067858
-0.0311507
-0.00654141
0.0151293
-0.111327
-0.103222
-0.060857
0.0046869
0.0801766
0.159116
0.237921
0.313188
0.379774
0.42994
0.448224
0.440764
0.345273
0.373814
0.42137
0.309869
0.0880894
0.00253325
-0.00450523
-0.00727769
-0.1092
-0.102408
-0.0654731
-0.00365835
0.0680431
0.143409
0.218937
0.291309
0.355086
0.402183
0.416237
0.406384
0.380476
0.648345
1.21263
0.783088
0.260289
0.0199943
-0.0109801
-0.0161887
-0.0947467
-0.0900767
-0.0597299
-0.00318301
0.0641446
0.135487
0.207859
0.277901
0.340417
0.385888
0.398753
0.347071
0.140178
-0.204576
-0.69997
-1.20063
-1.35401
-0.993876
-0.526335
-0.330315
-0.0681922
-0.0646907
-0.042201
0.00661419
0.0687146
0.13599
0.205575
0.274432
0.337781
0.386704
0.399835
0.325436
-0.189833
-1.17568
-2.12399
-2.59325
-2.6513
-2.33626
-1.90537
-1.63593
-0.0326074
-0.0303581
-0.0154996
0.0244505
0.080913
0.144413
0.212108
0.281598
0.348574
0.407971
0.438619
0.426208
0.0257139
-0.506214
-1.10417
-1.31595
-1.16991
-0.845361
-0.501674
-0.252249
0.0070882
0.00834336
0.0173821
0.0471243
0.0977373
0.158814
0.225905
0.297951
0.37298
0.446884
0.522877
0.578878
0.653907
0.805928
1.14136
1.54094
1.97355
2.31338
2.51578
2.61141
0.0445416
0.0452411
0.0495762
0.0713868
0.116106
0.175704
0.243799
0.319838
0.404128
0.497533
0.608908
0.745017
0.958915
1.41932
2.07708
2.72264
3.23148
3.55746
3.72836
3.79191
0.0772803
0.0781134
0.0799064
0.0926683
0.13156
0.190529
0.261216
0.34163
0.431555
0.535989
0.651389
0.782455
0.922625
1.30205
1.88774
2.43571
2.87395
3.15074
3.29386
3.35059
0.109431
0.110027
0.11077
0.116301
0.146303
0.203581
0.276485
0.358767
0.449362
0.550029
0.659532
0.77153
0.882871
1.10779
1.55872
1.97883
2.30958
2.52759
2.64012
2.68302
0.131993
0.133236
0.134056
0.136065
0.160098
0.217268
0.291956
0.374109
0.462343
0.557792
0.658404
0.750089
0.836638
0.960275
1.26362
1.56493
1.79995
1.95668
2.03687
2.06589
0.144583
0.14511
0.142646
0.143286
0.170219
0.234089
0.312205
0.3932
0.476324
0.563335
0.652047
0.72584
0.791272
0.869696
1.06811
1.2697
1.42556
1.52769
1.57969
1.59929
0.180349
0.178386
0.172815
0.174089
0.204499
0.269655
0.345005
0.419807
0.493803
0.56938
0.645454
0.708345
0.761349
0.812596
0.946046
1.07778
1.17463
1.23778
1.26789
1.27798
0.27938
0.276165
0.270765
0.272389
0.296377
0.344082
0.400011
0.457897
0.516619
0.578288
0.641506
0.694965
0.737521
0.775749
0.862782
0.946072
1.00641
1.04515
1.06322
1.06826
0.418282
0.416155
0.413397
0.412906
0.421862
0.442061
0.470025
0.504097
0.543564
0.588912
0.638801
0.684354
0.721378
0.755837
0.806342
0.856552
0.895799
0.919869
0.93179
0.935145
0.536817
0.535771
0.534427
0.531147
0.52755
0.527354
0.533795
0.547832
0.569907
0.60001
0.637445
0.67496
0.70627
0.737671
0.76853
0.797623
0.821656
0.838671
0.847315
0.849382
0.607661
0.607099
0.60603
0.60165
0.593132
0.584203
0.579717
0.581937
0.591697
0.60915
0.634315
0.661827
0.686222
0.71312
0.73064
0.749894
0.768312
0.781802
0.788891
0.790083
0.639645
0.639212
0.638131
0.634114
0.626066
0.616273
0.608536
0.605063
0.607215
0.615325
0.628668
0.643738
0.661591
0.676429
0.686025
0.702377
0.72005
0.733404
0.740524
0.741621
0.650449
0.650041
0.649009
0.645866
0.639929
0.632124
0.624725
0.619525
0.617521
0.618625
0.621006
0.622043
0.621718
0.622363
0.630172
0.650803
0.67259
0.688748
0.697533
0.698734
0.652546
0.652156
0.65126
0.648873
0.644751
0.639271
0.633417
0.628308
0.62447
0.621058
0.614653
0.598582
0.573315
0.558424
0.574848
0.605789
0.632154
0.64913
0.657382
0.658259
0.651923
0.65158
0.650905
0.649125
0.646104
0.642288
0.638073
0.634017
0.630238
0.625149
0.613799
0.585933
0.539754
0.513361
0.541785
0.578765
0.604369
0.61814
0.623783
0.625243
0.65005
0.649804
0.64944
0.648296
0.646162
0.643482
0.640721
0.638283
0.636142
0.633587
0.623233
0.595145
0.547545
0.528503
0.561095
0.592051
0.609256
0.616968
0.61946
0.620276
0.645804
0.645678
0.645652
0.645211
0.644006
0.642525
0.641478
0.641378
0.642694
0.643387
0.642436
0.62862
0.602895
0.600851
0.622439
0.640308
0.64845
0.652356
0.653703
0.653532
0.637409
0.637395
0.637662
0.637845
0.63774
0.637701
0.639373
0.642163
0.647902
0.656047
0.667393
0.673765
0.6759
0.689214
0.696209
0.69735
0.695634
0.697641
0.699542
0.699582
0.623248
0.623361
0.62396
0.62478
0.62582
0.627647
0.63131
0.638101
0.649201
0.66606
0.689853
0.713686
0.741654
0.760949
0.755085
0.746985
0.745107
0.746462
0.747994
0.745949
0.601595
0.601897
0.602821
0.604242
0.606336
0.60985
0.616025
0.626472
0.642882
0.668024
0.700988
0.734617
0.77035
0.790466
0.778348
0.769766
0.769498
0.772261
0.770598
0.768435
0.569386
0.569915
0.571256
0.573348
0.576491
0.581509
0.589697
0.602832
0.623176
0.654146
0.692422
0.727791
0.757035
0.768292
0.765315
0.774792
0.780454
0.78359
0.782177
0.780396
0.523321
0.52416
0.525891
0.528589
0.532604
0.538567
0.547425
0.560829
0.581004
0.611765
0.651923
0.690918
0.708164
0.702993
0.718168
0.750803
0.781303
0.792159
0.786488
0.784775
0.460681
0.461768
0.463721
0.466771
0.471115
0.47667
0.483318
0.491758
0.503044
0.522323
0.56349
0.617689
0.634775
0.621959
0.660789
0.729504
0.777245
0.7988
0.794311
0.791699
0.380946
0.382116
0.383923
0.386824
0.390444
0.393204
0.392726
0.386467
0.371617
0.361557
0.413065
0.499689
0.532486
0.527117
0.597963
0.686461
0.757349
0.771316
0.765135
0.760992
0.288215
0.289134
0.290328
0.292462
0.293964
0.29089
0.276878
0.241736
0.178625
0.121785
0.19085
0.340643
0.402276
0.414267
0.519379
0.609525
0.670702
0.674552
0.667542
0.662557
0.192859
0.193124
0.193447
0.194511
0.193119
0.182733
0.15055
0.0736888
-0.0634735
-0.166529
-0.0670605
0.154661
0.250969
0.307663
0.408809
0.489916
0.50304
0.499176
0.49683
0.495507
0.108696
0.1083
0.108191
0.108237
0.106021
0.0905622
0.045689
-0.0632006
-0.24293
-0.377628
-0.258201
-0.00367686
0.114567
0.197511
0.297648
0.337107
0.321839
0.314509
0.313082
0.313283
0.020693
0.0209163
0.0227231
0.0247555
0.0247601
0.0180068
-0.0146414
-0.0770177
-0.130992
-0.123667
-0.0395794
0.00528758
0.00332348
-0.0265582
0.0494782
0.0554317
0.0481875
0.0460141
0.0454849
0.137851
-0.514686
0.222433
0.689327
0.962808
1.16246
1.31717
1.43921
1.54017
1.64469
1.73685
0.597618
0.809696
1.00173
1.16276
1.29754
1.40836
1.4993
1.57361
1.61973
1.62528
0.96011
1.08439
1.20531
1.31319
1.40626
1.48499
1.54955
1.59854
1.63023
1.64897
1.18635
1.27044
1.35306
1.42887
1.4953
1.55202
1.59862
1.63512
1.66277
1.68251
1.34989
1.40686
1.46817
1.52482
1.57401
1.61677
1.65298
1.68291
1.70725
1.72469
1.47793
1.52026
1.56835
1.6105
1.64944
1.68409
1.71434
1.74012
1.76154
1.77609
1.58408
1.61949
1.658
1.6934
1.72667
1.75713
1.78415
1.80728
1.82632
1.83827
1.67935
1.71109
1.74589
1.77921
1.81056
1.83943
1.86498
1.8866
1.90379
1.91348
1.77168
1.80464
1.84041
1.87484
1.90652
1.93514
1.95998
1.98051
1.99613
2.00445
1.87449
1.91214
1.95065
1.98723
2.01953
2.0476
2.07121
2.09034
2.10458
2.11315
2.00203
2.04447
2.08368
2.11972
2.15028
2.17606
2.19771
2.21541
2.22899
2.2392
2.1637
2.20537
2.23921
2.26868
2.29327
2.31485
2.33449
2.35196
2.36674
2.37947
2.3541
2.38496
2.40641
2.4256
2.44368
2.46094
2.47718
2.49303
2.50956
2.52651
2.55213
2.56357
2.57466
2.58879
2.60309
2.61595
2.62734
2.63822
2.65114
2.66803
2.73799
2.74791
2.75659
2.75903
2.7599
2.76418
2.77501
2.79098
2.80861
2.81322
3.03903
2.98366
2.93286
2.89262
2.87025
2.86623
2.87973
2.91353
2.96998
3.04554
1.58386
1.52517
1.48268
1.44882
1.42415
1.40658
1.39404
1.38507
1.37891
1.37536
1.37486
1.37762
1.38297
1.39084
1.40171
1.41673
1.43771
1.46679
1.50554
1.55336
1.38543
1.39418
1.3997
1.40052
1.39702
1.39095
1.38449
1.37897
1.37507
1.37331
1.37438
1.37787
1.38306
1.38948
1.3962
1.40143
1.40304
1.39979
1.39243
1.38476
1.36248
1.36451
1.36911
1.37261
1.37511
1.37652
1.3762
1.37443
1.37217
1.37051
1.37041
1.37211
1.37473
1.37728
1.37869
1.37831
1.37642
1.3736
1.36953
1.36514
1.35561
1.35648
1.35895
1.36166
1.36366
1.365
1.36595
1.36636
1.36614
1.36579
1.36601
1.36695
1.36793
1.36832
1.36794
1.36703
1.36558
1.36331
1.36065
1.35867
1.35001
1.35047
1.35187
1.35388
1.35581
1.35737
1.35848
1.35932
1.35996
1.36042
1.3609
1.36138
1.36157
1.36136
1.3608
1.35976
1.35819
1.35632
1.35464
1.35362
1.3449
1.34519
1.3461
1.34757
1.34919
1.35078
1.35217
1.35329
1.35422
1.35504
1.3557
1.35605
1.35604
1.35567
1.3549
1.35373
1.35236
1.35098
1.34985
1.34922
1.34003
1.34023
1.34092
1.3421
1.34348
1.34491
1.34636
1.34771
1.34889
1.34992
1.35073
1.35113
1.35107
1.35059
1.34976
1.34873
1.34764
1.34656
1.34572
1.34527
1.33534
1.33549
1.33604
1.33703
1.33827
1.3396
1.341
1.34243
1.34382
1.34506
1.34605
1.34654
1.3465
1.34604
1.34533
1.34449
1.34359
1.34272
1.34208
1.34174
1.33075
1.33087
1.33132
1.33219
1.33334
1.33462
1.33599
1.33745
1.33896
1.34042
1.34162
1.34227
1.34234
1.34204
1.3415
1.34082
1.34007
1.33937
1.33887
1.33861
1.3262
1.32629
1.32667
1.32746
1.32856
1.32981
1.33119
1.33269
1.3343
1.33595
1.33741
1.33829
1.33859
1.3385
1.33814
1.33763
1.33703
1.33647
1.33608
1.33588
1.32163
1.3217
1.32203
1.32277
1.32385
1.32511
1.32654
1.32813
1.3299
1.33178
1.33353
1.33474
1.33531
1.33544
1.33527
1.33491
1.33446
1.33402
1.33372
1.33356
1.31696
1.31702
1.31731
1.31802
1.31911
1.32043
1.32194
1.32369
1.32566
1.32783
1.32997
1.33157
1.33247
1.33285
1.33288
1.33269
1.33236
1.33203
1.33181
1.33169
1.31217
1.31221
1.31247
1.31318
1.31431
1.31572
1.31734
1.31926
1.32151
1.32408
1.32671
1.32876
1.33002
1.33072
1.33101
1.33102
1.33082
1.33059
1.33044
1.33035
1.30719
1.30722
1.30746
1.30817
1.30935
1.31085
1.31263
1.31476
1.31731
1.32031
1.32352
1.32619
1.32799
1.32909
1.32968
1.32994
1.32992
1.3298
1.32972
1.32966
1.30195
1.30196
1.30219
1.30292
1.30419
1.30585
1.30785
1.31031
1.31333
1.31696
1.32091
1.32428
1.32661
1.32812
1.32906
1.32957
1.32974
1.32976
1.32975
1.32972
1.2964
1.29642
1.29661
1.29734
1.29867
1.30046
1.30269
1.30549
1.30901
1.31335
1.31821
1.32249
1.32559
1.32773
1.32912
1.32998
1.33044
1.33066
1.33075
1.33074
1.29025
1.29025
1.29048
1.29121
1.29263
1.29461
1.29716
1.30046
1.30468
1.30995
1.31595
1.32131
1.32525
1.32805
1.33
1.33134
1.33215
1.3326
1.33279
1.3328
1.2832
1.28321
1.28345
1.28422
1.28577
1.28801
1.29098
1.2949
1.3
1.30646
1.31386
1.32053
1.32552
1.32916
1.33178
1.33362
1.33484
1.33556
1.33584
1.33585
1.27477
1.27477
1.27504
1.27593
1.2777
1.28033
1.28388
1.28863
1.29487
1.3028
1.31193
1.32021
1.32645
1.33104
1.33441
1.33686
1.33853
1.33951
1.33988
1.3399
1.26449
1.26449
1.26481
1.26589
1.26804
1.27126
1.27565
1.28153
1.28927
1.29909
1.31034
1.32053
1.32822
1.33392
1.33813
1.34121
1.34334
1.34458
1.34504
1.34507
1.25184
1.25184
1.25225
1.25361
1.25629
1.26035
1.26586
1.27326
1.28292
1.2951
1.30895
1.32142
1.33083
1.33781
1.343
1.3468
1.34944
1.35095
1.3515
1.35153
1.23607
1.23607
1.23662
1.23838
1.24185
1.24708
1.25416
1.2636
1.27581
1.29097
1.30797
1.32311
1.33448
1.34294
1.34924
1.35388
1.3571
1.3589
1.35953
1.35956
1.21603
1.21604
1.21677
1.21917
1.22384
1.23074
1.24004
1.25228
1.26783
1.28671
1.30746
1.3257
1.33931
1.34943
1.35701
1.3626
1.36647
1.36858
1.36931
1.36933
1.18995
1.18996
1.19101
1.19445
1.20101
1.21052
1.22309
1.23919
1.25905
1.2825
1.30763
1.32937
1.34549
1.35748
1.3665
1.37317
1.37774
1.38017
1.38099
1.38101
1.1549
1.15494
1.15667
1.16208
1.17191
1.18562
1.20303
1.22443
1.24976
1.27862
1.30871
1.33429
1.35315
1.3672
1.37781
1.38569
1.39098
1.39375
1.39465
1.39464
1.10531
1.1056
1.1095
1.11937
1.13526
1.15574
1.18014
1.20846
1.24043
1.27547
1.31097
1.34063
1.36237
1.3786
1.39089
1.40003
1.40614
1.40929
1.41022
1.41016
1.03375
1.03618
1.04737
1.06679
1.09262
1.12237
1.15557
1.19208
1.23155
1.27343
1.31484
1.34901
1.37403
1.39279
1.40711
1.41785
1.42508
1.42886
1.43002
1.43001
0.957744
0.96431
0.984189
1.01364
1.04969
1.08891
1.13099
1.17579
1.22312
1.27249
1.32085
1.36074
1.39007
1.4122
1.42921
1.44225
1.45118
1.45578
1.45722
1.45742
0.893793
0.900456
0.927007
0.964845
1.00932
1.05713
1.1076
1.16047
1.21546
1.27213
1.32716
1.37234
1.40552
1.4306
1.44986
1.46448
1.47448
1.48016
1.48181
1.48197
0.841788
0.848832
0.879093
0.922777
0.973608
1.02835
1.08597
1.14604
1.20814
1.27166
1.33291
1.38289
1.41941
1.44684
1.46782
1.48376
1.49517
1.50141
1.50304
1.50334
0.798674
0.806008
0.838691
0.886614
0.942434
1.00275
1.06636
1.1327
1.20112
1.27089
1.33781
1.39206
1.43143
1.46083
1.48325
1.50028
1.51226
1.51901
1.52102
1.52144
0.761821
0.769321
0.803631
0.854862
0.914802
0.979793
1.04851
1.1203
1.19437
1.26978
1.34185
1.39991
1.44173
1.47274
1.49622
1.51399
1.52644
1.53355
1.53596
1.53646
0.729267
0.736874
0.772407
0.826322
0.889713
0.958704
1.0319
1.10852
1.18768
1.26825
1.34506
1.40659
1.45057
1.48291
1.50718
1.52546
1.53823
1.54556
1.5482
1.54871
0.699607
0.707325
0.743889
0.800085
0.866412
0.938885
1.01603
1.09701
1.18082
1.26618
1.34744
1.41225
1.45823
1.49174
1.51665
1.5352
1.54813
1.55552
1.55829
1.55878
0.671988
0.679806
0.717266
0.77542
0.844346
0.919886
1.00056
1.08547
1.17357
1.26344
1.34899
1.417
1.46495
1.49958
1.52509
1.54389
1.55691
1.56436
1.56722
1.56772
0.645731
0.653686
0.691958
0.751813
0.823102
0.901386
0.985211
1.07371
1.16577
1.25991
1.34967
1.42093
1.4709
1.50674
1.5329
1.55202
1.56514
1.57251
1.57533
1.57595
0.620469
0.628587
0.667695
0.728995
0.802402
0.883144
0.96982
1.06158
1.15732
1.25553
1.34944
1.42405
1.47623
1.51343
1.54037
1.55986
1.57312
1.58049
1.58322
1.58376
0.595904
0.604223
0.643988
0.706815
0.78208
0.865024
0.954276
1.04901
1.14815
1.25023
1.34827
1.42641
1.48103
1.51978
1.54764
1.56763
1.58108
1.58843
1.59106
1.59146
0.571936
0.580482
0.620909
0.685098
0.762045
0.846967
0.938528
1.03595
1.13823
1.24398
1.34612
1.42797
1.48528
1.52583
1.5548
1.57539
1.58905
1.59634
1.59883
1.59911
0.548501
0.557178
0.59837
0.663774
0.742252
0.828942
0.92257
1.02242
1.12756
1.23676
1.34292
1.42863
1.48895
1.5316
1.56187
1.58316
1.59702
1.60418
1.60646
1.60663
0.525537
0.534403
0.576302
0.642842
0.7227
0.810971
0.906438
1.00844
1.11616
1.22855
1.33859
1.42829
1.49195
1.53707
1.56889
1.59095
1.60496
1.61188
1.61389
1.61395
0.503043
0.512101
0.554744
0.622329
0.703423
0.793097
0.890178
0.994085
1.10409
1.21937
1.3331
1.42686
1.49415
1.54216
1.5759
1.59883
1.61286
1.61936
1.62101
1.62096
0.481101
0.490355
0.533734
0.602277
0.684478
0.775374
0.87387
0.979424
1.09144
1.20928
1.32643
1.42421
1.49537
1.54676
1.58294
1.60698
1.6208
1.62654
1.6277
1.62754
0.459784
0.469238
0.513311
0.582725
0.665917
0.757884
0.857591
0.964555
1.07828
1.19836
1.31858
1.42022
1.49541
1.55064
1.58998
1.61571
1.62919
1.63355
1.63385
1.63356
0.439095
0.448758
0.493509
0.563725
0.647795
0.740703
0.841436
0.949582
1.06473
1.18669
1.3096
1.41482
1.49405
1.55346
1.59681
1.62536
1.63897
1.64119
1.63963
1.63899
0.41911
0.428976
0.474369
0.545328
0.630182
0.723888
0.82549
0.9346
1.05091
1.1744
1.29955
1.40796
1.49109
1.55477
1.60282
1.6358
1.65143
1.65209
1.64714
1.64453
0.399807
0.409861
0.455904
0.527535
0.613055
0.70742
0.809728
0.919575
1.03678
1.16145
1.28837
1.3994
1.48626
1.55406
1.60698
1.64594
1.66686
1.66999
1.66224
1.64469
0.381152
0.391421
0.438002
0.510177
0.596181
0.690981
0.793767
0.904033
1.02178
1.14718
1.27536
1.38841
1.47875
1.55053
1.60737
1.65243
1.68009
1.68329
1.67776
1.6316
0.36288
0.374053
0.420727
0.493392
0.579667
0.674669
0.777792
0.888202
1.00616
1.13183
1.26064
1.37493
1.46792
1.54372
1.60149
1.64669
1.67562
1.6825
1.63107
1.56743
0.343988
0.358779
0.404275
0.477286
0.563228
0.658302
0.761549
0.872091
0.989902
1.11539
1.24413
1.35881
1.45262
1.53388
1.58819
1.61756
1.64119
1.61849
1.55308
1.48521
0.325403
0.32368
0.384216
0.46428
0.549695
0.64466
0.745627
0.856349
0.973733
1.09863
1.22643
1.3404
1.4328
1.52329
1.54981
1.5489
1.55761
1.50505
1.43295
1.36049
0.349811
0.350904
0.408338
0.487411
0.577581
0.676231
0.781964
0.895206
1.0153
1.14308
1.26405
1.36446
1.44623
1.53481
1.56164
1.46839
1.38869
1.32517
1.25243
1.10327
0.308754
0.334956
0.395111
0.474798
0.564943
0.663229
0.768355
0.880892
0.999904
1.12593
1.24402
1.34105
1.41554
1.47313
1.44889
1.32729
1.20829
1.12691
1.04172
0.871812
0.284277
0.315257
0.376323
0.455776
0.545928
0.643935
0.749142
0.860804
0.978363
1.10196
1.21647
1.30844
1.37438
1.39952
1.32675
1.16328
1.02244
0.918099
0.801221
0.556361
0.260417
0.293779
0.356074
0.436211
0.52647
0.624361
0.729156
0.839793
0.95568
1.07648
1.1866
1.27248
1.32632
1.3189
1.18653
0.995498
0.818353
0.6708
0.504984
0.104737
0.23761
0.27179
0.335144
0.416117
0.506564
0.60428
0.708401
0.817905
0.931935
1.04961
1.15469
1.23385
1.27147
1.23198
1.05024
0.836132
0.613755
0.420312
0.161507
-0.463564
0.21509
0.249266
0.313298
0.394875
0.485541
0.583062
0.686527
0.794821
0.906806
1.02106
1.12074
1.19207
1.21273
1.12902
0.925114
0.702685
0.473679
0.2587
0.0766038
-0.632458
0.191738
0.225928
0.290309
0.372257
0.463095
0.560456
0.663299
0.770363
0.88018
0.990788
1.08488
1.14723
1.14669
1.01603
0.818037
0.605652
0.407844
0.27131
0.240673
0.189973
0.167143
0.201308
0.26588
0.347972
0.438813
0.535862
0.637914
0.743473
0.850728
0.957072
1.04508
1.09645
1.07211
0.911452
0.721585
0.53523
0.383594
0.31628
0.293869
0.287068
0.140963
0.175222
0.239934
0.322057
0.412748
0.509314
0.610328
0.714074
0.818365
0.919839
1.00122
1.0395
0.997598
0.813284
0.633774
0.470103
0.353235
0.322221
0.321076
0.32071
0.113137
0.147597
0.212444
0.294558
0.384968
0.480847
0.580586
0.682209
0.783093
0.879162
0.95303
0.979125
0.912369
0.722353
0.551815
0.407724
0.35245
0.337236
0.334848
0.334917
0.0837908
0.118505
0.18348
0.265527
0.35553
0.45054
0.548761
0.647936
0.744982
0.835154
0.900648
0.914632
0.812819
0.638246
0.479595
0.365925
0.340133
0.343695
0.343557
0.343846
0.0534252
0.0882735
0.153279
0.235167
0.324619
0.418558
0.515005
0.611402
0.704204
0.787994
0.845074
0.840152
0.72044
0.56023
0.419973
0.371809
0.349805
0.348259
0.348282
0.348514
0.0223986
0.0574303
0.122193
0.203814
0.292548
0.385203
0.47962
0.572929
0.661113
0.738105
0.786852
0.7646
0.630452
0.490723
0.376349
0.340168
0.346737
0.349334
0.351097
0.35181
-0.00836599
0.0264058
0.0909464
0.172016
0.259808
0.350963
0.443082
0.533017
0.616263
0.686298
0.72552
0.688083
0.537725
0.427372
0.347719
0.336574
0.341781
0.348591
0.351763
0.35274
-0.0379365
-0.00383205
0.0603453
0.140473
0.227115
0.316511
0.406088
0.492417
0.57049
0.633368
0.662933
0.61118
0.44005
0.348679
0.348556
0.333515
0.320387
0.317806
0.3214
0.324371
-0.064921
-0.0317577
0.0312759
0.110277
0.195456
0.282775
0.369573
0.452144
0.525001
0.580401
0.604232
0.530165
0.334883
0.192695
0.24173
0.232458
0.235603
0.237834
0.243739
0.248095
-0.0876959
-0.0560344
0.00544468
0.0826778
0.165928
0.250935
0.334746
0.413507
0.48138
0.529275
0.550183
0.453149
0.235041
-0.0392963
-0.118155
0.0128579
0.104888
0.135431
0.14286
0.147167
-0.104378
-0.0748019
-0.0154561
0.0592372
0.139996
0.222322
0.303051
0.378082
0.441525
0.48281
0.500485
0.399099
0.212704
-0.104653
-0.356766
-0.123878
-0.0449479
-0.0197061
0.00731946
0.0176051
-0.113017
-0.0859579
-0.0299445
0.0415848
0.11932
0.198534
0.276078
0.347756
0.40736
0.444275
0.457518
0.385621
0.351778
0.444808
0.388701
0.193565
0.0219136
-0.000272698
-0.0060244
-0.00791122
-0.111547
-0.0880775
-0.0364173
0.0313186
0.105373
0.181158
0.255594
0.32453
0.381067
0.415468
0.414675
0.378523
0.465167
0.889646
1.02394
0.501632
0.0906
-0.0047503
-0.015532
-0.0135007
-0.096787
-0.0787877
-0.0336388
0.0295865
0.0993567
0.171562
0.243263
0.310354
0.365774
0.398111
0.391216
0.256583
-0.00350107
-0.443625
-0.98025
-1.33083
-1.22229
-0.74312
-0.388603
-0.340442
-0.0698862
-0.0568806
-0.0202806
0.0366074
0.101774
0.170508
0.240191
0.306941
0.364799
0.399967
0.388507
0.130414
-0.630511
-1.74367
-2.38879
-2.67689
-2.52586
-2.11575
-1.74196
-1.58402
-0.0340204
-0.025415
0.00154851
0.0513332
0.112064
0.177723
0.246646
0.315613
0.379523
0.430091
0.435908
0.265541
-0.23003
-0.817232
-1.25869
-1.28309
-1.02094
-0.668687
-0.362661
-0.202218
0.00594364
0.0109551
0.0292757
0.0705349
0.127392
0.191505
0.261324
0.33515
0.409749
0.48646
0.550478
0.625713
0.699591
0.96128
1.32762
1.76091
2.16045
2.43031
2.57542
2.63294
0.0437437
0.0462291
0.0576032
0.0913765
0.14441
0.208635
0.280701
0.360646
0.449839
0.548894
0.676503
0.825243
1.15186
1.7385
2.41013
2.99906
3.41713
3.65982
3.77092
3.80197
0.0777396
0.0785847
0.0836209
0.109054
0.15901
0.224792
0.300106
0.385176
0.481627
0.59355
0.714909
0.848837
1.0677
1.58932
2.17096
2.67341
3.03229
3.23625
3.33055
3.36005
0.109678
0.110418
0.111816
0.127512
0.172322
0.23869
0.316291
0.403072
0.497611
0.605485
0.715104
0.827489
0.960949
1.32195
1.77913
2.15623
2.43403
2.59517
2.6683
2.6895
0.132579
0.133871
0.134123
0.143938
0.185604
0.253145
0.332113
0.417365
0.508378
0.60935
0.705958
0.794674
0.874969
1.09878
1.4213
1.69094
1.88929
2.00506
2.05636
2.06909
0.145212
0.144093
0.14172
0.151835
0.199129
0.272209
0.352452
0.434081
0.518831
0.609403
0.691961
0.757967
0.817088
0.959565
1.1728
1.3539
1.48409
1.55886
1.59285
1.60044
0.17995
0.175564
0.171467
0.18432
0.234471
0.306877
0.382583
0.456426
0.531091
0.60876
0.679335
0.73345
0.782017
0.872226
1.01522
1.13044
1.2111
1.25615
1.2749
1.27778
0.278225
0.273369
0.269846
0.280915
0.318234
0.371517
0.428822
0.486784
0.546848
0.610713
0.670059
0.715315
0.755728
0.815234
0.906216
0.979278
1.02874
1.05637
1.06689
1.06752
0.417213
0.414859
0.412463
0.415851
0.430916
0.455103
0.486423
0.523043
0.565446
0.614367
0.662488
0.702272
0.738419
0.77807
0.831268
0.878756
0.909644
0.92703
0.934469
0.934101
0.53611
0.535301
0.533028
0.529178
0.526776
0.529695
0.53986
0.557822
0.584075
0.618841
0.655768
0.691705
0.723428
0.753069
0.783037
0.810499
0.831235
0.843971
0.849063
0.84816
0.607218
0.606835
0.604364
0.597796
0.588407
0.581249
0.579901
0.585858
0.599569
0.62111
0.646914
0.674403
0.704087
0.721448
0.739946
0.759536
0.775856
0.786126
0.790165
0.788768
0.639346
0.638912
0.636588
0.63054
0.621135
0.612009
0.606156
0.605457
0.610662
0.621542
0.635602
0.652569
0.672077
0.681246
0.693227
0.71151
0.727491
0.73775
0.741787
0.74043
0.650219
0.649707
0.647759
0.643236
0.636117
0.628272
0.621779
0.61819
0.617865
0.61993
0.621521
0.621888
0.623026
0.624489
0.639627
0.662028
0.681612
0.694073
0.699044
0.697555
0.652346
0.65184
0.650288
0.64701
0.642138
0.636364
0.63075
0.626298
0.622928
0.618541
0.607959
0.587222
0.562181
0.563453
0.590319
0.620057
0.641887
0.654299
0.658593
0.657242
0.651745
0.651333
0.650186
0.647737
0.644277
0.640226
0.636034
0.632133
0.628143
0.620758
0.602058
0.564202
0.518628
0.523548
0.561128
0.593381
0.6125
0.62165
0.624973
0.624748
0.649905
0.649674
0.649003
0.647298
0.644892
0.642084
0.639459
0.637184
0.635029
0.629379
0.611973
0.572611
0.529401
0.543706
0.578054
0.602085
0.614073
0.618579
0.620056
0.619955
0.645702
0.64568
0.645517
0.644702
0.643248
0.641898
0.641231
0.641829
0.643507
0.64379
0.637608
0.615965
0.596231
0.611892
0.633143
0.64509
0.65076
0.653175
0.653858
0.653065
0.637349
0.637515
0.637784
0.637823
0.637675
0.637825
0.6403
0.644372
0.652186
0.661829
0.671621
0.674523
0.679912
0.694279
0.697421
0.696153
0.696626
0.698753
0.699861
0.699306
0.623226
0.62362
0.624352
0.625253
0.62658
0.629179
0.63414
0.642817
0.657205
0.677731
0.70213
0.726119
0.755195
0.757939
0.750452
0.745071
0.74535
0.747913
0.747113
0.745109
0.601663
0.602295
0.603469
0.605176
0.607852
0.61252
0.620533
0.63392
0.654674
0.684062
0.718172
0.751328
0.786086
0.78436
0.771681
0.769106
0.771282
0.771544
0.769173
0.768004
0.569542
0.570493
0.572204
0.574751
0.578696
0.585103
0.595502
0.612315
0.63741
0.672908
0.711743
0.742723
0.767792
0.765828
0.769572
0.777272
0.782668
0.784075
0.780842
0.780121
0.523641
0.524913
0.527109
0.530397
0.535288
0.542537
0.553386
0.570047
0.594674
0.631704
0.673957
0.702148
0.707096
0.708349
0.734247
0.769558
0.787666
0.790127
0.784986
0.7851
0.461143
0.462625
0.465095
0.468775
0.473746
0.479851
0.487154
0.496618
0.510579
0.539786
0.592779
0.631082
0.625481
0.632941
0.694946
0.756411
0.795729
0.79788
0.792562
0.79165
0.381504
0.382908
0.38523
0.388613
0.392047
0.393559
0.390461
0.380029
0.364572
0.378192
0.459475
0.523452
0.520417
0.552092
0.646193
0.722961
0.76789
0.767408
0.762494
0.760426
0.288726
0.289634
0.291307
0.293473
0.293279
0.28576
0.26276
0.2131
0.142946
0.13727
0.269811
0.383228
0.404629
0.464112
0.564968
0.654288
0.679127
0.671392
0.664544
0.661581
0.193105
0.193173
0.193989
0.194426
0.189569
0.17045
0.119236
0.0119352
-0.132333
-0.144886
0.0540805
0.21936
0.266031
0.361852
0.4515
0.499961
0.499784
0.497669
0.496105
0.495056
0.108571
0.10819
0.108272
0.107278
0.100406
0.073543
0.00107073
-0.148379
-0.323911
-0.350953
-0.109432
0.0704905
0.140929
0.25037
0.329549
0.329323
0.317846
0.313274
0.313214
0.313307
0.0433901
0.042513
0.0433861
0.0454635
0.0451471
0.0368841
0.00422877
-0.0832275
-0.218447
-0.306546
-0.21073
-0.0450935
-0.000103588
0.0760125
0.127301
0.150152
0.147286
0.141223
0.138383
0.137626
-0.0865888
0.50321
0.837684
1.06703
1.24369
1.38067
1.49237
1.58897
1.70202
1.69721
0.751879
0.91238
1.0858
1.23352
1.35583
1.45596
1.5387
1.60155
1.62774
1.6319
1.03956
1.14628
1.26121
1.36156
1.44739
1.51907
1.57618
1.61637
1.64147
1.65827
1.23981
1.31289
1.39218
1.4633
1.5249
1.5766
1.6181
1.64987
1.67453
1.693
1.38864
1.44287
1.49792
1.55022
1.59621
1.63568
1.6687
1.6957
1.718
1.73622
1.50734
1.54657
1.58963
1.6305
1.66731
1.69975
1.7278
1.7513
1.77081
1.78854
1.60784
1.63921
1.67597
1.71034
1.7423
1.7711
1.79624
1.81728
1.83423
1.85158
1.69928
1.72851
1.76279
1.79515
1.82536
1.85266
1.87632
1.89574
1.91036
1.9275
1.79092
1.82235
1.85795
1.89103
1.92126
1.94806
1.97081
1.98895
2.00165
2.01892
1.89531
1.93118
1.96945
2.0039
2.03411
2.05997
2.08135
2.09807
2.10973
2.12759
2.02504
2.0641
2.10239
2.13565
2.16372
2.18738
2.20707
2.22264
2.23451
2.25278
2.18622
2.22271
2.25466
2.28145
2.30434
2.3249
2.34356
2.35963
2.37337
2.39125
2.37095
2.3962
2.4162
2.43474
2.45243
2.4692
2.4851
2.50112
2.51826
2.53741
2.55783
2.56875
2.5815
2.59609
2.60972
2.62182
2.63275
2.64412
2.65954
2.67898
2.73976
2.75326
2.75833
2.75935
2.76133
2.76872
2.78246
2.80008
2.81383
2.82518
3.00868
2.95812
2.91067
2.8791
2.86608
2.87065
2.89389
2.93896
3.00566
3.09978
1.44049
1.43747
1.43141
1.42047
1.40797
1.39664
1.38756
1.38076
1.37622
1.37424
1.37536
1.37925
1.38533
1.39356
1.40401
1.4163
1.42863
1.43733
1.44184
1.44399
1.3688
1.37545
1.3807
1.3843
1.3854
1.38375
1.38027
1.37643
1.37338
1.37197
1.37293
1.37587
1.37988
1.38404
1.38702
1.38752
1.38517
1.38077
1.37447
1.36864
1.35873
1.36169
1.36505
1.36753
1.36927
1.37044
1.37063
1.36983
1.3687
1.36814
1.36888
1.37051
1.37208
1.3728
1.37233
1.37103
1.3691
1.36621
1.36286
1.36057
1.35273
1.35415
1.35636
1.35862
1.36033
1.3615
1.36236
1.36289
1.36307
1.36327
1.36382
1.36446
1.3647
1.36441
1.36372
1.36253
1.36068
1.35842
1.35665
1.35557
1.34742
1.34824
1.3497
1.35147
1.3532
1.35466
1.35576
1.35664
1.35738
1.35802
1.35852
1.35874
1.35861
1.35815
1.35724
1.3559
1.35432
1.35276
1.35172
1.35105
1.34244
1.343
1.34408
1.3455
1.347
1.34849
1.34985
1.351
1.35199
1.35285
1.35341
1.35357
1.35334
1.35269
1.3517
1.35052
1.34928
1.34815
1.34743
1.34697
1.33767
1.33808
1.33895
1.34018
1.34151
1.34291
1.34434
1.3457
1.34691
1.34796
1.34865
1.34883
1.34854
1.34789
1.34701
1.34605
1.34505
1.34416
1.34363
1.34328
1.33304
1.33336
1.33409
1.33517
1.33642
1.33776
1.33917
1.34063
1.34205
1.34332
1.34417
1.34443
1.34421
1.34369
1.34298
1.34218
1.34136
1.34067
1.34026
1.33999
1.32847
1.32873
1.32936
1.33035
1.33155
1.33287
1.33429
1.33581
1.33739
1.3389
1.33996
1.34039
1.34035
1.34001
1.33947
1.33883
1.33817
1.33762
1.3373
1.33708
1.32392
1.32414
1.32469
1.32563
1.32681
1.32813
1.3296
1.33121
1.33293
1.33467
1.33602
1.33674
1.33695
1.3368
1.33644
1.33596
1.33543
1.335
1.33476
1.33458
1.31931
1.31949
1.31999
1.32092
1.3221
1.32347
1.32504
1.32681
1.32876
1.33081
1.33251
1.33355
1.33401
1.33408
1.33389
1.33355
1.33315
1.33283
1.33264
1.33249
1.31459
1.31473
1.31521
1.31614
1.31738
1.31884
1.32053
1.3225
1.32474
1.32718
1.32933
1.33075
1.33153
1.33185
1.33186
1.33166
1.33138
1.33114
1.33101
1.33089
1.30971
1.30983
1.31028
1.31124
1.31255
1.31411
1.31595
1.31815
1.32074
1.32368
1.32636
1.32826
1.32944
1.33009
1.33036
1.33035
1.3302
1.33006
1.32997
1.32987
1.30461
1.30471
1.30516
1.30616
1.30756
1.30927
1.31135
1.31387
1.3169
1.32042
1.3238
1.32632
1.32797
1.32896
1.3295
1.32971
1.32972
1.32968
1.32964
1.32956
1.29924
1.2993
1.29975
1.30079
1.30231
1.3042
1.30655
1.30949
1.31311
1.31742
1.32162
1.32483
1.32705
1.3285
1.32935
1.32984
1.33005
1.33013
1.33014
1.33008
1.29341
1.29349
1.29393
1.295
1.29662
1.29871
1.30139
1.3048
1.30909
1.31432
1.31957
1.32371
1.32666
1.32869
1.33002
1.33091
1.33139
1.33162
1.33168
1.33163
1.28687
1.28694
1.2874
1.28853
1.29032
1.29271
1.29585
1.29995
1.30519
1.31163
1.31812
1.32329
1.32706
1.32974
1.33163
1.33293
1.33375
1.33414
1.33425
1.33419
1.27918
1.27926
1.27978
1.28102
1.28303
1.28581
1.28954
1.29447
1.30084
1.30875
1.3168
1.32329
1.3281
1.33159
1.33411
1.33591
1.33708
1.33766
1.3378
1.33773
1.26987
1.26996
1.27058
1.27205
1.27444
1.2778
1.28237
1.28845
1.29632
1.30608
1.31601
1.32402
1.32999
1.33439
1.33764
1.33995
1.34148
1.34222
1.3424
1.34231
1.25846
1.25858
1.25937
1.26117
1.26412
1.26832
1.27401
1.28159
1.29135
1.3034
1.31561
1.32545
1.33279
1.33823
1.34227
1.34516
1.34706
1.34797
1.34819
1.34808
1.24432
1.24449
1.24553
1.24783
1.25158
1.25692
1.26415
1.2737
1.28591
1.30081
1.31574
1.32771
1.33664
1.34326
1.34821
1.35177
1.3541
1.35517
1.35542
1.3553
1.22653
1.22679
1.22821
1.23123
1.23613
1.24307
1.25242
1.26463
1.27998
1.29838
1.31654
1.33096
1.3417
1.34968
1.35566
1.35999
1.36277
1.36402
1.36431
1.36416
1.20363
1.20406
1.20607
1.2102
1.21685
1.22615
1.2385
1.25427
1.27361
1.29623
1.31813
1.33535
1.34813
1.35765
1.36481
1.37001
1.37328
1.37472
1.37503
1.37486
1.17339
1.17413
1.17715
1.18316
1.19264
1.20558
1.22221
1.24272
1.26702
1.2946
1.32074
1.34104
1.35609
1.36733
1.37581
1.38195
1.38572
1.38736
1.38769
1.38749
1.13184
1.13334
1.13853
1.14816
1.16246
1.18104
1.20368
1.2303
1.26056
1.2938
1.32455
1.34817
1.36566
1.37879
1.3887
1.39583
1.40013
1.40196
1.40228
1.40204
1.07163
1.07625
1.08709
1.10372
1.12615
1.153
1.1836
1.21767
1.25477
1.29415
1.32976
1.35681
1.3768
1.39185
1.40321
1.41138
1.41629
1.41824
1.41849
1.41823
1.00012
1.00827
1.02799
1.0551
1.08774
1.1238
1.16296
1.20502
1.24961
1.2961
1.33772
1.36936
1.39291
1.41074
1.42422
1.43391
1.43979
1.44215
1.44242
1.44234
0.928474
0.942441
0.971038
1.00819
1.0503
1.09542
1.1431
1.19321
1.24541
1.29916
1.34701
1.38339
1.41053
1.43124
1.44711
1.45873
1.4652
1.46736
1.46801
1.4681
0.869902
0.887533
0.921822
0.966265
1.01601
1.06894
1.12437
1.18204
1.24152
1.3022
1.35586
1.39648
1.4267
1.44969
1.46722
1.47993
1.48724
1.49054
1.49152
1.49169
0.822053
0.841661
0.880158
0.930011
0.985722
1.04502
1.1071
1.17151
1.23764
1.30474
1.3637
1.40803
1.44082
1.46565
1.48463
1.49856
1.50691
1.51071
1.51186
1.51202
0.781875
0.8026
0.844298
0.898385
0.958943
1.02354
1.09131
1.16164
1.23375
1.30667
1.3704
1.41799
1.45293
1.47924
1.49928
1.51396
1.52306
1.52727
1.52856
1.52873
0.74693
0.768405
0.812614
0.870178
0.934791
1.00393
1.07667
1.15225
1.22975
1.30799
1.37605
1.42651
1.46328
1.49075
1.51154
1.52676
1.53644
1.54095
1.54228
1.54243
0.715652
0.737675
0.783915
0.844392
0.912479
0.985592
1.06273
1.14305
1.22548
1.30864
1.38073
1.43383
1.4722
1.50062
1.52192
1.53749
1.54737
1.55207
1.55347
1.55356
0.686906
0.709338
0.757367
0.820322
0.891431
0.968038
1.04912
1.13375
1.22075
1.30855
1.38451
1.44014
1.48001
1.50926
1.53099
1.54672
1.55671
1.56147
1.56283
1.56293
0.659812
0.682714
0.732288
0.797415
0.871217
0.950933
1.03556
1.12413
1.21541
1.30766
1.38741
1.4456
1.487
1.51709
1.53926
1.55518
1.56522
1.57006
1.57131
1.57128
0.633934
0.657357
0.708131
0.775312
0.851525
0.934033
1.02186
1.11406
1.20933
1.30588
1.38946
1.45029
1.49335
1.52441
1.54708
1.56322
1.57333
1.5781
1.57935
1.57928
0.608925
0.632859
0.684746
0.753791
0.832149
0.917168
1.00791
1.10343
1.20245
1.30318
1.39064
1.45432
1.49923
1.53141
1.5547
1.57115
1.58134
1.58603
1.58723
1.58712
0.584563
0.608974
0.66202
0.732699
0.812984
0.900262
0.993629
1.09219
1.19472
1.2995
1.39094
1.4577
1.50469
1.53818
1.56224
1.57906
1.58934
1.59394
1.59501
1.59489
0.560733
0.585668
0.639799
0.711951
0.793973
0.88327
0.979001
1.08033
1.18613
1.2948
1.39029
1.46036
1.50973
1.54478
1.56974
1.58699
1.59734
1.60176
1.6027
1.60252
0.537406
0.562895
0.618028
0.691526
0.775103
0.866206
0.964049
1.06787
1.17666
1.28904
1.38858
1.46222
1.51434
1.55121
1.57723
1.59493
1.60527
1.60947
1.61022
1.60999
0.514623
0.540608
0.596718
0.671434
0.756404
0.849104
0.948814
1.05485
1.16635
1.28219
1.38573
1.46319
1.51841
1.55748
1.58475
1.60288
1.61306
1.61692
1.61748
1.6172
0.492345
0.518851
0.575901
0.65172
0.737923
0.832022
0.933368
1.04134
1.15524
1.27426
1.38169
1.46309
1.52181
1.56357
1.59242
1.61093
1.62069
1.62402
1.62435
1.62403
0.470682
0.497696
0.555617
0.632423
0.719717
0.815042
0.917795
1.02744
1.14344
1.26527
1.37637
1.46178
1.52434
1.56938
1.60036
1.61935
1.62828
1.63068
1.6307
1.63038
0.449629
0.477193
0.535895
0.613605
0.701859
0.798236
0.90219
1.01325
1.13101
1.25531
1.36975
1.4591
1.52574
1.57467
1.6087
1.62872
1.63639
1.63705
1.63643
1.63616
0.429284
0.457345
0.516794
0.595319
0.684409
0.781687
0.886639
0.998859
1.1181
1.24446
1.36181
1.45491
1.52569
1.579
1.61723
1.63973
1.64656
1.64431
1.64169
1.64104
0.409585
0.438183
0.498361
0.577624
0.667443
0.765482
0.871263
0.984408
1.10482
1.23284
1.35261
1.44911
1.52391
1.58167
1.62512
1.65235
1.661
1.65694
1.64815
1.63041
0.390596
0.419714
0.480456
0.560319
0.650666
0.749283
0.855637
0.96942
1.09064
1.21989
1.34154
1.441
1.51986
1.58178
1.63077
1.66496
1.67947
1.67717
1.66055
1.67273
0.372189
0.401953
0.463135
0.543461
0.634133
0.733154
0.839773
0.953929
1.07557
1.20552
1.32846
1.43005
1.51294
1.57803
1.62997
1.66883
1.68812
1.68383
1.62243
1.6029
0.353778
0.384337
0.446649
0.527453
0.618327
0.717537
0.823873
0.938197
1.0599
1.18997
1.31343
1.41594
1.50251
1.57
1.61729
1.65489
1.66575
1.63284
1.56206
1.51865
0.334678
0.36601
0.431409
0.512649
0.603639
0.702577
0.808306
0.922396
1.04372
1.17326
1.29637
1.39865
1.48674
1.55837
1.60516
1.60824
1.59126
1.53252
1.45901
1.41377
0.738843
0.849369
0.966488
1.09094
1.21778
1.33057
1.42104
1.27777
0.31419
0.333068
0.37085
0.439209
0.524407
0.61858
0.720697
0.830068
0.946211
1.0692
1.19449
1.30583
1.39451
1.46806
1.51973
1.48845
1.34694
1.25914
1.19014
0.296778
0.309784
0.353802
0.423888
0.509351
0.603524
0.70506
0.81384
0.928953
1.0503
1.17297
1.28044
1.36363
1.42277
1.42292
1.32266
1.17655
1.06871
0.978036
0.273794
0.286537
0.333467
0.40465
0.490322
0.584592
0.686126
0.794439
0.908447
1.02795
1.14724
1.24951
1.325
1.36626
1.32672
1.1668
0.996059
0.85772
0.736683
0.250687
0.263609
0.312129
0.384502
0.470616
0.56486
0.666083
0.773567
0.886207
1.00345
1.11898
1.21557
1.28296
1.30094
1.2166
1.01655
0.810861
0.622496
0.442984
0.228437
0.24083
0.290169
0.363581
0.45015
0.544388
0.645172
0.751702
0.86281
0.977491
1.08885
1.17912
1.23713
1.22008
1.08761
0.878027
0.648382
0.426985
0.226198
0.205763
0.217826
0.267393
0.341487
0.42842
0.522705
0.623122
0.728766
0.838296
0.950297
1.05732
1.14081
1.18669
1.14252
0.969427
0.762825
0.540145
0.328159
0.198105
0.159559
0.18185
0.193735
0.243477
0.317926
0.405031
0.49927
0.599251
0.703893
0.811623
0.920567
1.02275
1.09882
1.13058
1.06677
0.862642
0.666382
0.47719
0.331568
0.284367
0.258229
0.156625
0.168325
0.218166
0.292799
0.379922
0.473936
0.573306
0.676687
0.78227
0.887658
0.984345
1.05261
1.06742
0.966051
0.76789
0.585914
0.426837
0.33508
0.312997
0.308046
0.129815
0.141351
0.191362
0.266114
0.35314
0.446775
0.545304
0.647156
0.750227
0.851577
0.942053
1.00244
0.990423
0.862827
0.679381
0.508805
0.379728
0.334193
0.331021
0.329104
0.10144
0.11288
0.163042
0.237901
0.32473
0.417831
0.5153
0.615355
0.715537
0.812381
0.896035
0.947427
0.912366
0.765412
0.596305
0.437732
0.358133
0.339355
0.339791
0.339939
0.0717102
0.0832435
0.13334
0.208286
0.294823
0.387211
0.483411
0.581379
0.678297
0.770145
0.846617
0.8865
0.840658
0.675711
0.520684
0.393394
0.352287
0.349104
0.346602
0.346505
0.0411731
0.0527362
0.102647
0.177549
0.263658
0.355157
0.449854
0.545449
0.638756
0.725177
0.79407
0.823109
0.764468
0.594347
0.454346
0.359183
0.341031
0.347501
0.349951
0.350618
0.0104227
0.0219118
0.0715694
0.146103
0.231658
0.322068
0.415018
0.507957
0.597321
0.677981
0.738903
0.759064
0.671284
0.515916
0.39893
0.36033
0.343476
0.346817
0.351197
0.352533
-0.0194602
-0.00848192
0.0407124
0.114746
0.19941
0.288523
0.379476
0.469499
0.554663
0.629259
0.682248
0.687809
0.574111
0.432317
0.36338
0.35128
0.341465
0.33873
0.341023
0.343413
-0.0474844
-0.0368661
0.0110198
0.0843395
0.167801
0.255338
0.34403
0.430916
0.511718
0.57999
0.625553
0.613773
0.478844
0.321777
0.28536
0.28342
0.281284
0.28353
0.285426
0.290069
-0.0723123
-0.0621072
-0.0158137
0.0559498
0.137965
0.223555
0.309735
0.393313
0.469728
0.531783
0.570151
0.54824
0.388272
0.173303
0.0481867
0.117171
0.159525
0.18477
0.193281
0.198273
-0.0917663
-0.0822833
-0.0382772
0.0313317
0.111155
0.194437
0.277881
0.358068
0.43026
0.486718
0.517342
0.492109
0.319535
0.057191
-0.297762
-0.196632
-0.020011
0.0517413
0.071952
0.0846529
-0.104235
-0.0957647
-0.0546946
0.0119684
0.0890052
0.169514
0.249947
0.326797
0.395124
0.447097
0.469235
0.452522
0.314704
0.189184
-0.131606
-0.0722876
-0.037791
-0.0345601
-0.0271788
-0.0186928
-0.10744
-0.100519
-0.0633692
-0.000555151
0.0731732
0.150368
0.227554
0.301329
0.366365
0.414978
0.430699
0.430594
0.3785
0.575833
1.03159
0.723238
0.206874
0.0110737
-0.00108
-0.00408566
-0.100545
-0.0948458
-0.0625234
-0.0046319
0.0649671
0.13842
0.212372
0.283472
0.346394
0.392286
0.407991
0.389988
0.310384
0.403667
0.542852
0.156325
-0.107378
-0.163048
-0.0711206
-0.0471244
-0.0803884
-0.0761592
-0.0500399
0.000801925
0.065193
0.134686
0.205616
0.274897
0.337515
0.383771
0.395935
0.329312
-0.06152
-0.863855
-1.73603
-2.29069
-2.31658
-1.87529
-1.38558
-1.04238
-0.0491962
-0.0465418
-0.0271682
0.0154997
0.0737412
0.139265
0.207815
0.276744
0.341432
0.394998
0.413055
0.358975
-0.166042
-0.997769
-1.91229
-2.37426
-2.37247
-2.0349
-1.65854
-1.36753
-0.0110746
-0.0095024
0.00236269
0.036934
0.0888314
0.15098
0.218308
0.288794
0.359334
0.42529
0.477858
0.500629
0.337709
0.164377
0.098733
0.213635
0.502405
0.801299
1.03749
1.1666
0.0278253
0.0287714
0.0348462
0.0601997
0.107094
0.167277
0.234595
0.308523
0.388345
0.471797
0.568397
0.672661
0.869511
1.24928
1.80613
2.40009
2.89458
3.21393
3.37493
3.43038
0.0617113
0.0622905
0.0652035
0.0822701
0.124228
0.183506
0.252868
0.331246
0.419062
0.520518
0.637774
0.777312
0.954681
1.3964
2.03497
2.65728
3.15095
3.46387
3.62084
3.67723
0.0940148
0.0945483
0.0956289
0.104322
0.138928
0.197124
0.269045
0.350774
0.441529
0.544797
0.657014
0.779169
0.899734
1.20261
1.73
2.21184
2.59617
2.84666
2.97672
3.02636
0.122421
0.123306
0.124219
0.127561
0.153657
0.210181
0.283934
0.366244
0.455942
0.554157
0.660005
0.761743
0.862932
1.02646
1.39992
1.75993
2.03918
2.22407
2.32071
2.35723
0.13817
0.13936
0.138934
0.140105
0.164743
0.224867
0.301148
0.382972
0.46906
0.560745
0.655465
0.737429
0.811324
0.908846
1.1537
1.40163
1.59677
1.72501
1.78899
1.8132
0.15628
0.15559
0.151396
0.1523
0.181718
0.248047
0.326324
0.405273
0.484479
0.566087
0.648536
0.716198
0.775267
0.838345
1.00072
1.16361
1.28648
1.36781
1.40839
1.42186
0.221574
0.219002
0.212608
0.214318
0.242961
0.301638
0.369568
0.437338
0.504501
0.573473
0.643218
0.701504
0.748767
0.791781
0.900587
1.00605
1.0821
1.13088
1.15407
1.16093
0.347822
0.34504
0.340943
0.341625
0.358388
0.392613
0.434485
0.480661
0.529851
0.583491
0.639954
0.689086
0.728457
0.764377
0.831683
0.89708
0.945593
0.975827
0.990232
0.994579
0.482968
0.481476
0.479569
0.477609
0.479672
0.488026
0.503831
0.526849
0.557109
0.594504
0.638156
0.680028
0.714633
0.747613
0.785857
0.824312
0.854978
0.875541
0.885558
0.887899
0.578193
0.577433
0.576299
0.57222
0.565095
0.559238
0.559043
0.566289
0.581544
0.604914
0.636164
0.66875
0.697732
0.725858
0.750098
0.77326
0.793409
0.807901
0.815475
0.817143
0.627355
0.626881
0.625811
0.621492
0.612845
0.60288
0.596082
0.59479
0.600223
0.612608
0.631869
0.653364
0.676028
0.695617
0.70999
0.726676
0.743968
0.756979
0.763877
0.764929
0.646744
0.646328
0.645257
0.641666
0.63462
0.62566
0.617827
0.613172
0.612903
0.617265
0.624899
0.633533
0.643312
0.651324
0.658795
0.676805
0.696682
0.711759
0.719819
0.720817
0.652081
0.65168
0.650708
0.647972
0.64304
0.636452
0.629772
0.624463
0.621285
0.619771
0.617411
0.60985
0.597709
0.590567
0.601612
0.626562
0.650209
0.666719
0.675406
0.67675
0.652399
0.652026
0.651228
0.64915
0.645645
0.641092
0.636081
0.631405
0.627398
0.622773
0.613377
0.589614
0.552855
0.530766
0.553243
0.588442
0.615746
0.631597
0.638831
0.639907
0.651175
0.650875
0.650347
0.648877
0.646267
0.643065
0.639598
0.636288
0.633089
0.628776
0.617159
0.58726
0.536711
0.511703
0.544325
0.580724
0.603702
0.615214
0.619095
0.619839
0.648339
0.648155
0.64797
0.647209
0.645517
0.643344
0.641393
0.640057
0.639519
0.638101
0.631772
0.609432
0.570667
0.56016
0.588213
0.612004
0.623209
0.627876
0.629348
0.630498
0.64222
0.642148
0.642268
0.642149
0.6415
0.640738
0.640782
0.642318
0.64569
0.649143
0.654703
0.650689
0.639467
0.645636
0.660054
0.669744
0.672895
0.675526
0.677643
0.677225
0.631145
0.631192
0.631627
0.632125
0.632595
0.633533
0.635989
0.640856
0.649182
0.661775
0.679578
0.69541
0.710659
0.729428
0.729124
0.724486
0.722793
0.725765
0.727094
0.725621
0.61354
0.613726
0.614427
0.615572
0.617162
0.619858
0.624797
0.633447
0.647225
0.668386
0.697119
0.727029
0.760215
0.782741
0.77106
0.760965
0.758324
0.758568
0.758946
0.757582
0.586955
0.587415
0.588519
0.590277
0.592917
0.597231
0.604517
0.616474
0.635099
0.663756
0.699761
0.734209
0.768861
0.786216
0.777072
0.775445
0.777521
0.780903
0.779244
0.776789
0.548258
0.548909
0.550438
0.552861
0.556513
0.562135
0.570923
0.584601
0.60554
0.637498
0.677
0.713803
0.736077
0.741264
0.743928
0.763728
0.782512
0.790662
0.785266
0.782866
0.494059
0.495018
0.496868
0.49982
0.504176
0.510214
0.518445
0.530248
0.547437
0.574676
0.614864
0.659018
0.674107
0.662004
0.689271
0.740783
0.780458
0.793872
0.789527
0.788636
0.422629
0.423773
0.425683
0.428787
0.433028
0.437604
0.441445
0.443984
0.445106
0.452623
0.49749
0.563763
0.5865
0.576597
0.632368
0.710681
0.773003
0.794433
0.787435
0.784035
0.335513
0.336614
0.338198
0.340868
0.343649
0.343885
0.337471
0.318765
0.283597
0.251779
0.309747
0.424762
0.470895
0.47301
0.563585
0.659671
0.722141
0.732292
0.726094
0.721198
0.239768
0.240437
0.241301
0.243067
0.243235
0.236574
0.213658
0.158335
0.0619421
-0.019446
0.060805
0.249428
0.327354
0.361642
0.466276
0.553228
0.600164
0.594092
0.588431
0.584919
0.148511
0.148419
0.148077
0.149105
0.146956
0.133593
0.0931404
-0.00309528
-0.164367
-0.289212
-0.171987
0.0653315
0.182456
0.248581
0.347132
0.400714
0.406913
0.404969
0.403938
0.403781
0.0731781
0.07253
0.0728807
0.0739046
0.0718846
0.0595983
0.0183706
-0.0896272
-0.26199
-0.39623
-0.272802
-0.0470787
0.0478651
0.146675
0.234723
0.241742
0.229486
0.225054
0.224715
0.225102
0.0428446
0.042634
0.0443948
0.0459869
0.0424778
0.0253858
-0.031726
-0.149938
-0.271517
-0.283347
-0.119777
-0.0150588
0.0484934
0.0972211
0.158327
0.149465
0.14366
0.139433
0.138039
0.0453597
0.263855
0.626987
0.867071
1.06921
1.23297
1.36452
1.4708
1.56134
1.6263
1.62313
0.79845
0.963031
1.11384
1.24378
1.3551
1.44839
1.52541
1.58514
1.62167
1.6354
1.08209
1.18514
1.28481
1.3745
1.45273
1.51926
1.57378
1.61534
1.6448
1.66453
1.27324
1.34257
1.4133
1.4788
1.53553
1.58436
1.62508
1.65785
1.68398
1.70245
1.41756
1.4653
1.51996
1.5685
1.61188
1.64995
1.6828
1.71042
1.73328
1.74912
1.53301
1.57121
1.61372
1.65202
1.68761
1.71975
1.74814
1.77242
1.79257
1.80564
1.63262
1.66562
1.70147
1.73558
1.76754
1.79692
1.82307
1.84533
1.8634
1.87402
1.72513
1.75679
1.79158
1.82535
1.85675
1.8854
1.91061
1.93167
1.94805
1.95676
1.82082
1.85577
1.89286
1.9286
1.96076
1.98924
2.0136
2.0335
2.0484
2.05645
1.93429
1.97461
2.01393
2.051
2.08297
2.11017
2.13285
2.15118
2.16493
2.17407
2.07849
2.12144
2.15894
2.19265
2.22075
2.2446
2.26528
2.28274
2.29663
2.30779
2.25632
2.29394
2.3222
2.34653
2.36757
2.3869
2.40518
2.42236
2.43828
2.45282
2.45405
2.47511
2.49012
2.50599
2.5223
2.53762
2.55135
2.56463
2.58015
2.59852
2.6449
2.65202
2.66254
2.67411
2.68404
2.69326
2.70354
2.71466
2.72629
2.73516
2.85784
2.85963
2.85172
2.83522
2.82409
2.82355
2.83571
2.86033
2.89446
2.919
3.27752
3.08363
2.98257
2.92474
2.89564
2.88902
2.90422
2.94505
3.02091
3.16386
0.350412
0.345906
0.384968
0.455487
0.540799
0.635683
1.50612
1.57565
1.57675
1.50087
1.43265
1.36086
1.11939
0.883155
0.59697
0.215859
-0.179211
)
;
boundaryField
{
wall-4
{
type zeroGradient;
}
pressure-outlet-7
{
type fixedValue;
value uniform 0;
}
velocity-inlet-6
{
type zeroGradient;
}
velocity-inlet-5
{
type zeroGradient;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //
|
|
de3848b60538ca1fc0abb2ae38808c6791df5656
|
0dafa415cc7d10703b09a3ecd5ca4753abdaad93
|
/concat/cpp/concat.cc
|
d64ee6ea3f5810d85876012acfa8520a8cdeaf43
|
[] |
no_license
|
abo-abo/simple-benchmark
|
f30db5bc815bedac2731b6bbd3d6ec53346014cc
|
6eee363a6b920f62c6dab647b618046f5c9b7e4f
|
refs/heads/master
| 2021-05-13T12:31:29.737905
| 2018-01-08T17:10:06
| 2018-01-08T17:10:06
| 116,675,788
| 4
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,344
|
cc
|
concat.cc
|
#include <iostream>
#include <vector>
#include <chrono>
#include <numeric>
#include <cstdint>
#include "printers.h"
using std::chrono::high_resolution_clock;
using std::chrono::duration_cast;
template <typename T>
std::vector<T> operator += (std::vector<T>& a, const std::vector<T>& b) {
a.insert(a.end(), b.begin(), b.end());
return a;
}
void check_shared_structure() {
std::vector<int64_t> a = {1, 2, 3};
std::vector<int64_t> b = {4, 5, 6};
TRACE(a);
TRACE(b);
// a is mutated, no structure is shared
a += b;
TRACE(a);
TRACE(b);
b[2] = 7;
TRACE(a);
TRACE(b);
}
high_resolution_clock::time_point tic_start;
void tic() {
tic_start = high_resolution_clock::now();
}
// return milliseconds since tic()
void toc() {
high_resolution_clock::time_point tic_end = high_resolution_clock::now();
int duration = duration_cast<std::chrono::microseconds>(tic_end - tic_start).count();
std::cout << int(duration/1000.0) << "ms\n";
}
void big_concat() {
std::vector<int64_t> a(1e7);
std::iota(a.begin(), a.end(), 0);
std::vector<int64_t> b = a;
tic();
a += b;
toc();
TRACE(a.size());
tic();
int64_t sum = std::accumulate(a.begin(), a.end(), int64_t(0));
toc();
TRACE(sum);
}
int main(int argc, char *argv[]) {
std::cout << "C++:\n";
// check_shared_structure();
big_concat();
return 0;
}
|
ccdaab56aee1d13d5b4a10148688c683369d8e06
|
5e1c85bf4ad9795b61866b77a1d35423a2300c6b
|
/Lab C++/struct_not_of_me.cpp
|
ddd0deb62109f494387e3f6f3f222096ffaf5e51
|
[] |
no_license
|
locvx1234/Programming
|
fc2ef908cc556a96c00d5ce9f09acceea0d7ffe9
|
6c3ded82d76db34d83011a81ab2c37828592bdf2
|
refs/heads/master
| 2021-03-24T14:03:22.453709
| 2017-06-23T09:45:48
| 2017-06-23T09:45:48
| 36,355,713
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,466
|
cpp
|
struct_not_of_me.cpp
|
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
struct hocsinh
{
char ho[5];
char ten[5];
char eamil[20];
int mshs, toan, ly, hoa, sdt;
};
int n;
void nhap(hocsinh hs[],int n)
{
cout<<"\tNhap vao so luong hocsinh:";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"\t--Nhap vao thong tin hocsinh thu "<<i+1<<"--\n";
cout<<"\tNhap vao ho hs : ";
fflush(stdin);
gets(hs[i].ho);
cout<<"\tNhap vao ten hs : ";
fflush(stdin);
gets(hs[i].ten);
cout<<"\tNhap vao MSHS : ";
cin>>hs[i].mshs;
cout<<"\tNhap vao sdt : ";
cin>>hs[i].sdt;
cout<<"\tNhap vao diem toan : ";
cin>>hs[i].toan;
cout<<"\tNhap vao diem ly : ";
cin>>hs[i].ly;
cout<<"\tNhap vao diem hoa : ";
cin>>hs[i].hoa;
}
}
void xuat(hocsinh hs[],int n)
{
for(int i=0;i<n;i++)
{
cout<<"\t--hoc sinh thu"<<i+1<<"--\n";
cout<<"\tHo hoc sinh:"<<hs[i].ho<<endl;
cout<<"\tTEn hoc sinh:"<<hs[i].ten<<endl;
cout<<"\tMSHS:"<<hs[i].mshs<<endl;
cout<<"\temail:"<<hs[i].eamil<<endl;
cout<<"\tSDT:"<<hs[i].sdt<<endl;
cout<<"\t dien toan:"<<hs[i].toan<<endl;
cout<<"\t diem ly:"<<hs[i].ly<<endl;
cout<<"\t diem hoa:"<<hs[i].hoa<<endl;
}
}
void them1(hocsinh hs[],int &n,int x)
{
hs[n]=x;
n++;
}
int main()
{
hocsinh hs[10];
nhap(hs,n);
xuat(hs,n);
int x;
cout<<"\t them 1 hs";
cin>>x;
them1(hs,n,x);
xuat(hs,n);
return 0;
}
|
163cde7455003a70945fbfde98961d85b493b4b4
|
8c5b5b9ee05b6c9363d3f6308ebdd75965357cba
|
/src/glow.h
|
a5002a97eac17eacbaa598e1abcda796999b60c3
|
[] |
no_license
|
wangscript007/Glow
|
8f9ebe723e05a109cb66517dc93fc7bceea2d147
|
3fc37f5d1fef6bb63a2ed3d7b868d254db484573
|
refs/heads/master
| 2021-05-30T13:18:06.339203
| 2015-10-10T09:12:20
| 2015-10-10T09:12:20
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 462
|
h
|
glow.h
|
#pragma once
#include "presets.h"
#include "eventqueue.h"
#include "graphics/displaymanager.h"
#include "utils/time.h"
namespace Glow {
class Engine {
private:
bool quit = false;
public:
graphics::DisplayManager *displayManager;
EventQueue *eventQueue;
public:
Engine();
void initEngine();
void terminateEngine();
bool shouldQuit() const;
void update();
private:
};
}
|
bd991a44548865bea89716b93c80b619cfafbdf3
|
e9b587d2a1f629beb61461726b9f55cabf95a9cd
|
/2_mux_INPROGRESS.ino
|
4fe414e1fe3be1582601a4aa9d16f557e54789ce
|
[] |
no_license
|
Normanras/Surge_Midi_Controller
|
ae166c1b366c78cca4e89d4803d2b17230c6a7d2
|
74f57dacad189446aaba60e6606a35cb58527018
|
refs/heads/main
| 2023-03-13T02:48:55.567213
| 2021-03-03T01:29:21
| 2021-03-03T01:29:21
| 343,915,670
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,053
|
ino
|
2_mux_INPROGRESS.ino
|
#include <Control_Surface.h> // Include the library
USBMIDI_Interface midi; // Instantiate a MIDI Interface to use
// Three Banks to change the channel of the pot
Bank<3> bank(7); // 1st number is # of banks, 2nd is # of tracks per bank
// Selector to change banks
IncrementDecrementSelectorLEDs<3> bankSelector = {
bank, // Bank to manage
{0, 1}, //push button pins (inc/dec)
{6, 9, 10}, //LED Pins
};
// Instantiate a multiplexer
CD74HC4067 mux = {
A5, // analog pin
{2, 3, 4, 5}, // Address pins S0, S1, S2, S3
7, // Optionally, specify the enable pin
};
Bankable::CCPotentiometer oscpotentiometers[] = {
{{bank, BankType::CHANGE_ADDRESS}, mux.pin(0), { MIDI_CC::Sound_Controller_1 } },
{{bank, BankType::CHANGE_ADDRESS}, mux.pin(1), { MIDI_CC::Sound_Controller_2 } },
{{bank, BankType::CHANGE_ADDRESS}, mux.pin(2), { MIDI_CC::Sound_Controller_3 } },
{{bank, BankType::CHANGE_ADDRESS}, mux.pin(3), { MIDI_CC::Sound_Controller_4 } },
{{bank, BankType::CHANGE_ADDRESS}, mux.pin(4), { MIDI_CC::Sound_Controller_5 } },
{{bank, BankType::CHANGE_ADDRESS}, mux.pin(5), { MIDI_CC::Sound_Controller_6 } },
{{bank, BankType::CHANGE_ADDRESS}, mux.pin(6), { MIDI_CC::Sound_Controller_7 } },
};
CCPotentiometer adsrpots[] = {
{mux.pin(7), {MIDI_CC::General_Purpose_Controller_1}},
{mux.pin(8), {MIDI_CC::General_Purpose_Controller_2}},
{mux.pin(9), {MIDI_CC::General_Purpose_Controller_3}},
{mux.pin(10), {MIDI_CC::General_Purpose_Controller_4}},
{mux.pin(11), {MIDI_CC::General_Purpose_Controller_5}},
{mux.pin(12), {MIDI_CC::General_Purpose_Controller_6}},
{mux.pin(13), {MIDI_CC::General_Purpose_Controller_7}},
};
CCPotentiometer MainVolume = {A3, {MIDI_CC::Channel_Volume, CHANNEL_1}};
CCPotentiometer SendFX1 = {A1, {MIDI_CC::Effect_Control_1}};
CCPotentiometer SendFX2 = {A2, {MIDI_CC::Effect_Control_2}};
void setup() {
Control_Surface.begin(); // Initialize the Control Surface
mux.begin();
}
void loop() {
Control_Surface.loop(); // Update the Control Surface
}
|
7c220a4504d77b53c43d212157c0845911cf4abe
|
50d3745fb24ba47208056c92510002afd3eef636
|
/test/test.cpp
|
10009c50e6ebb9925110e5769778e8050cab14c3
|
[
"MIT"
] |
permissive
|
hogliux/farbot
|
86e67e378457a84120bb118d94532e052da3a2ed
|
0416705394720c12f0d02e55c144e4f69bb06912
|
refs/heads/master
| 2023-03-24T15:16:19.234926
| 2023-03-03T17:27:31
| 2023-03-03T17:27:31
| 191,143,823
| 272
| 26
|
MIT
| 2020-04-04T15:32:07
| 2019-06-10T10:07:25
|
C++
|
UTF-8
|
C++
| false
| false
| 9,764
|
cpp
|
test.cpp
|
#include <gtest/gtest.h>
#include <atomic>
#include <random>
#include <array>
#include <unordered_set>
#include <mutex>
#include <condition_variable>
#include "farbot/RealtimeTraits.hpp"
#include "farbot/fifo.hpp"
#include "farbot/AsyncCaller.hpp"
#include "farbot/RealtimeObject.hpp"
using TestData = std::array<long long, 8>;
static_assert (farbot::is_realtime_move_assignable<TestData>::value);
// ensure that the object could be torn
static_assert(! std::atomic<TestData>::is_always_lock_free);
TestData create (int num)
{
return TestData {num, num, num, num, num, num, num, num};
}
bool operator==(const TestData& o, int num)
{
for (auto n : o)
if (n != num)
return false;
return true;
}
TEST(fifo, no_data_test)
{
farbot::fifo<TestData> fifo (256);
TestData test;
EXPECT_FALSE (fifo.pop (test));
}
TEST(fifo, one_in_one_out_test)
{
farbot::fifo<TestData> fifo (256);
EXPECT_TRUE (fifo.push (create (1)));
TestData test;
EXPECT_TRUE (fifo.pop (test));
EXPECT_TRUE (test == 1);
}
TEST(fifo, has_claimed_capacity)
{
farbot::fifo<TestData> fifo (256);
for (int i = 0; i < 256; ++i)
EXPECT_TRUE (fifo.push (create(0)));
EXPECT_FALSE (fifo.push (create(0)));
}
TEST (fifo, random_push_pop)
{
farbot::fifo<TestData> fifo (256);
int writeidx = 1, readidx = 1;
int read_available = 0, write_available = 256;
std::default_random_engine generator;
for (int i = 0; i < 10000; ++i)
{
if (write_available > 0)
{
std::uniform_int_distribution<int> distribution (0, write_available);
auto consec_writes = distribution (generator);
for (int j = 0; j < consec_writes; ++j)
EXPECT_TRUE (fifo.push (create(writeidx++)));
write_available -= consec_writes;
read_available += consec_writes;
if (write_available == 0)
{
EXPECT_FALSE (fifo.push (create(writeidx + 1)));
}
}
if (read_available > 0)
{
std::uniform_int_distribution<int> distribution (0, read_available);
auto consec_reads = distribution (generator);
for (int j = 0; j < consec_reads; ++j)
{
TestData test;
EXPECT_TRUE (fifo.pop (test));
EXPECT_TRUE (test == readidx++);
}
write_available += consec_reads;
read_available -= consec_reads;
if (read_available == 0)
{
TestData test;
EXPECT_FALSE (fifo.pop (test));
}
}
}
}
template <int number_of_reader_threads, int number_of_writer_threads,
farbot::fifo_options::concurrency consumer_concurrency,
farbot::fifo_options::concurrency producer_concurrency>
void do_thread_test()
{
farbot::fifo<TestData, consumer_concurrency, producer_concurrency> fifo (256);
std::atomic<bool> running = {true};
constexpr auto highest_write = 1000000;
std::array<std::unordered_set<long long>, number_of_reader_threads> readValues;
std::array<std::unique_ptr<std::thread>, number_of_reader_threads> readThreads;
std::array<std::unique_ptr<std::thread>, number_of_writer_threads> writeThreads;
for (int i = 0; i < number_of_reader_threads; ++i)
{
readThreads[i] =
std::make_unique<std::thread> ([&fifo, &running, &readValues, i] ()
{
auto& values = readValues[i];
long long lastValue = -1;
while (running.load (std::memory_order_relaxed))
{
TestData test;
auto success = false;
while (running.load (std::memory_order_relaxed))
{
success = fifo.pop (test);
if (success)
break;
}
auto value = test[0];
EXPECT_TRUE (test == static_cast<int> (value));
if (success)
{
EXPECT_TRUE (values.emplace (value).second);
if (number_of_writer_threads == 1)
{
EXPECT_GT (value, lastValue);
}
lastValue = value;
}
}
// read remaining data
{
TestData test;
while (fifo.pop (test))
EXPECT_TRUE (values.emplace (test[0]).second);
}
});
}
std::atomic<int> atomic_counter = 1;
for (int i = 0; i < number_of_writer_threads; ++i)
{
writeThreads[i] =
std::make_unique<std::thread> ([&fifo, &atomic_counter] ()
{
while (true)
{
auto value = atomic_counter.fetch_add(1);
if (value >= highest_write)
return;
while (! fifo.push (create(value)));
}
});
}
for (int i = 0; i < number_of_writer_threads; ++i)
writeThreads[i]->join();
running.store (false, std::memory_order_relaxed);
for (int i = 0; i < number_of_reader_threads; ++i)
readThreads[i]->join();
// ensure each value is picked up by each thread exactly once
for (int i = 1; i < highest_write; ++i)
{
int j;
for (j = 0; j < number_of_reader_threads; ++j)
{
if (readValues[j].find (i) != readValues[j].end())
break;
}
EXPECT_LT (j, number_of_reader_threads);
for (++j; j < number_of_reader_threads; ++j)
EXPECT_EQ (readValues[j].find (i), readValues[j].end());
}
}
TEST (fifo, multi_consumer_single_producer)
{
do_thread_test<10, 1, farbot::fifo_options::concurrency::multiple, farbot::fifo_options::concurrency::single>();
}
TEST (fifo, multi_consumer_multi_producer)
{
do_thread_test<10, 10, farbot::fifo_options::concurrency::multiple, farbot::fifo_options::concurrency::multiple>();
}
TEST(fifo, async_caller_test)
{
std::mutex init_mutex;
std::condition_variable init_cv;
std::atomic<bool> finish(false);
farbot::AsyncCaller<> asyncCaller;
EXPECT_FALSE (asyncCaller.process());
std::unique_lock<std::mutex> init_lock (init_mutex);
std::thread test ([&asyncCaller, &finish, &init_mutex, &init_cv] ()
{
asyncCaller.callAsync ([&finish] () { finish.store (true, std::memory_order_relaxed); } );
// TODO: this is not quite right as this will cause a synchronisation event and doesn't
// fully test if AsyncCaller is no data races
{
std::unique_lock<std::mutex> l (init_mutex);
init_cv.notify_all();
}
});
init_cv.wait (init_lock);
EXPECT_TRUE (asyncCaller.process());
EXPECT_TRUE (finish.load());
test.join();
}
TEST(RealtimeMutatable, tester)
{
struct BiquadCoeffecients {
BiquadCoeffecients() = default;
BiquadCoeffecients(float _a1, float _a2, float _b1, float _b2, float _b3) : a1(_a1), a2(_a2), b1(_b1), b2(_b2), b3(_b3) {}
float a1, a2, b1, b2, b3; } biquads;
using RealtimeBiquads = farbot::RealtimeObject<BiquadCoeffecients, farbot::RealtimeObjectOptions::nonRealtimeMutatable>;
RealtimeBiquads realtime(biquads);
{
RealtimeBiquads::ScopedAccess<farbot::ThreadType::nonRealtime> scopedAccess(realtime);
scopedAccess->a1 = 1.0;
scopedAccess->a2 = 1.4;
}
{
RealtimeBiquads::ScopedAccess<farbot::ThreadType::realtime> scopedAccess(realtime);
std::cout << scopedAccess->a1 << std::endl;
}
realtime.nonRealtimeReplace(1.0, 1.2, 3.4, 5.4, 5.4);
}
TEST(NonRealtimeMutatable, tester)
{
struct BiquadCoeffecients {
BiquadCoeffecients() = default;
BiquadCoeffecients(float _a1, float _a2, float _b1, float _b2, float _b3) : a1(_a1), a2(_a2), b1(_b1), b2(_b2), b3(_b3) {}
float a1, a2, b1, b2, b3; } biquads;
using RealtimeBiquads = farbot::RealtimeObject<BiquadCoeffecients, farbot::RealtimeObjectOptions::realtimeMutatable>;
RealtimeBiquads realtime(biquads);
{
RealtimeBiquads::ScopedAccess<farbot::ThreadType::realtime> scopedAccess(realtime);
scopedAccess->a1 = 1.0;
scopedAccess->a2 = 1.4;
}
{
RealtimeBiquads::ScopedAccess<farbot::ThreadType::nonRealtime> scopedAccess(realtime);
std::cout << scopedAccess->a1 << std::endl;
}
realtime.realtimeReplace(1.0, 1.2, 3.4, 5.4, 5.4);
}
TEST(RealtimeMutatable, valueIsPreserved)
{
using RealtimeHistogram = farbot::RealtimeObject<std::array<int, 256>, farbot::RealtimeObjectOptions::realtimeMutatable>;
RealtimeHistogram histogram(std::array<int, 256>{});
{
RealtimeHistogram::ScopedAccess<farbot::ThreadType::realtime> hist(histogram);
std::fill(hist->begin(), hist->end(), 0);
}
for (int i = 0; i < 100; ++i)
{
RealtimeHistogram::ScopedAccess<farbot::ThreadType::realtime> hist(histogram);
ASSERT_EQ((*hist)[0], i);
(*hist)[0]++;
}
{
RealtimeHistogram::ScopedAccess<farbot::ThreadType::realtime> hist(histogram);
std::fill(hist->begin(), hist->end(), 0);
}
for (int i = 0; i < 100; ++i)
{
{
RealtimeHistogram::ScopedAccess<farbot::ThreadType::realtime> hist(histogram);
ASSERT_EQ((*hist)[0], i);
(*hist)[0]++;
}
{
RealtimeHistogram::ScopedAccess<farbot::ThreadType::nonRealtime> hist(histogram);
ASSERT_EQ((*hist)[0], (i + 1));
}
}
}
|
deb7e4a4e32ec20d8969254723b8ca74be5f0796
|
fbf8e794ddfb6d73faa1d95d01fcacd33f50bc4a
|
/THOMAS/src/object/component/RigidBodyComponent.cpp
|
e12f81ba8a033c1c2f482497ca4e9488b7015c59
|
[] |
no_license
|
sojunator/LSP
|
e1063a5b7bde728c7390800b845879151f0368a3
|
6dfc0a0c5369450ea6c4b8c5dea08c696af38e0e
|
refs/heads/master
| 2021-06-14T04:04:10.084685
| 2017-03-14T17:58:31
| 2017-03-14T17:58:31
| 79,337,732
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,495
|
cpp
|
RigidBodyComponent.cpp
|
#include "RigidBodyComponent.h"
#include "../GameObject.h"
#include "../../utils/Math.h"
namespace thomas
{
namespace object
{
namespace component
{
void RigidBodyComponent::UpdateRigidbodyMass(float mass)
{
btVector3 inertia;
getCollisionShape()->calculateLocalInertia(mass, inertia);
setMassProps(mass, inertia);
updateInertiaTensor();
}
RigidBodyComponent::RigidBodyComponent() : Component("RigidBodyComponent"), btRigidBody(1, NULL, NULL)
{
}
RigidBodyComponent::~RigidBodyComponent()
{
delete getMotionState();
Physics::s_world->removeCollisionObject(this);
delete getCollisionShape();
Physics::s_world->removeRigidBody(this);
}
void RigidBodyComponent::OnEnable()
{
Physics::s_world->addRigidBody(this);
}
void RigidBodyComponent::OnDisable()
{
Physics::s_world->removeRigidBody(this);
}
void RigidBodyComponent::Start()
{
Physics::s_world->removeRigidBody(this);
btDefaultMotionState* motionState = new btDefaultMotionState(btTransform(*(btQuaternion*)&m_gameObject->m_transform->GetRotation(), *(btVector3*)&m_gameObject->m_transform->GetPosition()));
btCollisionShape* collider = new btBoxShape(btVector3(1, 1, 1));
btVector3 inertia(0, 0, 0);
collider->calculateLocalInertia(1, inertia);
setMotionState(motionState);
setCollisionShape(collider);
setMassProps(1, inertia);
Physics::s_world->addRigidBody(this);
m_kinematic = false;
}
void RigidBodyComponent::Update()
{
if (m_kinematic)
{
btTransform trans;
getMotionState()->getWorldTransform(trans);
trans.setOrigin(Physics::ToBullet(m_gameObject->m_transform->GetPosition()));
trans.setRotation(Physics::ToBullet(m_gameObject->m_transform->GetRotation()));
getMotionState()->setWorldTransform(trans);
setCenterOfMassTransform(trans);
}
else
{
//Update our transform to match the rigidbody.
btTransform trans;
btDefaultMotionState *myMotionState = (btDefaultMotionState *)getMotionState();
trans = myMotionState->m_graphicsWorldTrans;
math::Vector3 pos = (math::Vector3)trans.getOrigin();
math::Quaternion rot = (math::Quaternion)trans.getRotation();
m_gameObject->m_transform->SetRotation(rot);
m_gameObject->m_transform->SetPosition(pos);
}
}
void RigidBodyComponent::SetKinematic(bool kinematic)
{
if (kinematic && !m_kinematic)
{
m_mass = -getInvMass();
m_kinematic = kinematic;
Physics::s_world->removeRigidBody(this);
UpdateRigidbodyMass(0);
Physics::s_world->addRigidBody(this);
}
else if(!kinematic && m_kinematic)
{
m_kinematic = kinematic;
Physics::s_world->removeRigidBody(this);
UpdateRigidbodyMass(m_mass);
Physics::s_world->addRigidBody(this);
}
}
bool RigidBodyComponent::IsKinematic()
{
return m_kinematic;
}
void RigidBodyComponent::SetCollider(btCollisionShape * collider)
{
Physics::s_world->removeRigidBody(this);
delete getCollisionShape();
setCollisionShape(collider);
UpdateRigidbodyMass(m_mass);
Physics::s_world->addRigidBody(this);
}
void RigidBodyComponent::SetMass(float mass)
{
Physics::s_world->removeRigidBody(this);
m_mass = mass;
UpdateRigidbodyMass(m_mass);
Physics::s_world->addRigidBody(this);
}
float RigidBodyComponent::GetMass()
{
return m_mass;
}
}
}
}
|
21b347a836e127610f5af55a460d5c3096aa8dfd
|
c78c31473a3bf0cb181e166472670b1f30c55f24
|
/GAME1017_Template_W01/Rock.h
|
c805f020d6b34c1139b9f4163a6caf246c3ffe91
|
[] |
no_license
|
julaxe/IndianaJones
|
6cef2ec6e3fe17f11cda2d65a1877f3526481209
|
8b55833bf627d6019d9055aaad722207dbc4e517
|
refs/heads/master
| 2022-11-27T19:11:25.923297
| 2020-08-04T23:45:08
| 2020-08-04T23:45:08
| 273,011,006
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 270
|
h
|
Rock.h
|
#pragma once
#include "Sprite.h"
class Rock : public Sprite {
public:
Rock(SDL_Rect s, SDL_FRect d, const char* path, std::string key) : Sprite(s, d, path, key)
{
m_type = ENEMY2;
}
void Update();
private:
int timer = 0;
int respawnTimer = rand() % 30 + 20;
};
|
156f822e6c6c04f619956c08d655f65d51345bbf
|
9b8eeeca76c728cc3db78317f72f5e51219983b8
|
/自写/Algorithm/Sort/Sort/QuickSort.cpp
|
d3d5dd35dce7bc2df7ab5fa968efb8f03e5835d5
|
[] |
no_license
|
lYcHeeM/Demo
|
e3b8c59a489533e2bab2546b8d0f92bfb11e14cb
|
6d8ffc542e41389844e2d902385a48ce75c91f51
|
refs/heads/master
| 2021-07-15T20:37:15.628923
| 2021-02-22T02:45:03
| 2021-02-22T02:45:03
| 98,294,658
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,934
|
cpp
|
QuickSort.cpp
|
//
// QuickSort.cpp
// Sort
//
// Created by luozhijun on 16/9/17.
// Copyright © 2016年 luozhijun. All rights reserved.
//
#include "QuickSort.hpp"
#include <time.h>
#include <iostream>
void quick_sort(int *data, size_t length)
{
if (data == NULL || length <= 1) {
return;
}
int partition_position = -1;
// partition_array(data, data + length - 1, &partition_position);
partition_array_1(data, length, -1, &partition_position);
if (partition_position < 0 || partition_position >= length) return;
// 得到分隔位置(下标)后,对左右两个子序列再以同样的方式排序
// 直到最后排序的长度为1为止
quick_sort(data, partition_position);
quick_sort(data + partition_position + 1, length - partition_position - 1);
}
void partition_array(int *start, int *end, int *out_partition_position) {
if (start == NULL || end == NULL || start >= end || out_partition_position == NULL) return;
// 参照值
// 此处把尾部的数据作为参照值
int refrence = *end;
// 空位置, 初始状态为参照值的位置
int *empty_positon = end;
// 复制一份形参,以免直接修改形参,导致后面用的时候出现非预期结果
// 下面会看到start还要使用
int *using_start = start;
while (using_start != end) {
// start < end 是为了防止refrence刚好是一个很大的数
// 这样的话start会一直后移,超出数列边界,直到访问到一个地址中的值比refrence大为止
// 这样很可能造成死循环
while (*using_start <= refrence && using_start < end) {
using_start ++;
}
if (using_start != end) {
// 把using_start位置和空位置交换
*empty_positon = *using_start;
empty_positon = using_start;
}
while (*end >= refrence && end > using_start) {
end --;
}
if (end != using_start) {
// 把end位置和空位置交换
*empty_positon = *end;
empty_positon = end;
}
}
// 把参考值放入最终状态的空位置,此时便达到参考值左边的元素<=参考值,参考值右边的元素>=参考值
*empty_positon = refrence;
*out_partition_position = (int)(empty_positon - start);
}
/// @param ref_pos 调用者可指定参考值的位置, 也可不指定(此时ref_pos传-1);
/// @param result_pos 如果不指定参考值的位置, 此参数将存储参考值位置的输出;
int partition_array_1(int *array, size_t len, int ref_pos, int *result_pos) {
if (!array || len <= 1) return -1;
if ((ref_pos < 0 || ref_pos >= len) && !result_pos) return -2;
int *p_refrence = NULL;
if (ref_pos >= 0) {
p_refrence = array + ref_pos;
} else {
size_t random_index = 0;
int state = random_in_range(len, &random_index);
if (state != 0) return state;
p_refrence = array + (int)random_index;
}
// 交换参考值和尾值
int *end = array + len - 1;
swap_two_values(p_refrence, end);
int smaller_index = -1;
for (int index = 0; index < len - 1; ++ index) {
if (array[index] < *end) {
++ smaller_index;
if (smaller_index != index) {
swap_two_values(&array[index], &array[smaller_index]);
}
}
}
++ smaller_index;
swap_two_values(&array[smaller_index], end);
if (result_pos) *result_pos = smaller_index;
return 0;
}
int random_in_range(size_t range, size_t *result) {
if (range == 0 || result == NULL) return -1;
srand((unsigned)time(NULL));
*result = rand() % range;
return 0;
}
void swap_two_values(int *left, int *right) {
if (!left || !right) return;
int temp = *left;
*left = *right;
*right = temp;
return;
}
|
f832802da070691517ac4266bd8d25338deae1b4
|
a03ac198f274f17549fdb9cdb76c25e1d11fffe9
|
/122A.cpp
|
0010eae8b0bc6eb9bd30804c18078712ebc4cee1
|
[] |
no_license
|
milonsheikhcse/Codeforces_Coding
|
a9cbccfd651bad667e90c2c008efa98b3e018142
|
fedf0b76307571dd87c9db9307c7ad7ed2b1bbbe
|
refs/heads/master
| 2020-07-27T21:57:17.592465
| 2019-09-18T05:47:59
| 2019-09-18T05:47:59
| 209,227,362
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 351
|
cpp
|
122A.cpp
|
///AC
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
/// 47 74 777 774 747
if((n%4==0) || (n%7==0) || (n%47==0) || (n%774==0) || (n%744==0) || (n%447==0)|| n%474==0 || n%447==0 || n%477==0) {
cout << "YES" << endl;
} else
cout << "NO" << endl;
return 0;
}
|
117b2ead8d50bb964c00f67d65772043862a05af
|
9c2c71361e56a383241b99ab197ddbccd69d5acd
|
/src/Wing.h
|
75a593b861cb5c032c94353cb9e742a8657f1c49
|
[] |
no_license
|
KoenigEva/miniMICADO
|
f24884c354a6c7573834863017f1a06651a9d828
|
a22d53ffcb1642abc42375fa6ac3bc7b51a22f8b
|
refs/heads/master
| 2021-06-23T21:01:49.318410
| 2017-09-04T08:13:10
| 2017-09-04T08:13:10
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 792
|
h
|
Wing.h
|
#ifndef WING_H
#define WING_H
#include <math.h>
#include <vector>
//#include <stdlib.h>
#include "node.h"
#include "functions.h"
#include "Fuselage.h"
class Wing
{
public:
Wing(node& configXML, Fuselage &myFuselage);
virtual ~Wing();
double WingArea;
string WingAirfoilFile;
vector<double> x_coord;
vector<double> z_coord;
double TtoC;
vector<double> AVLresults;
void readWingAirfoilFile();
void calcTtoC();
void calcWing(double AoA);
void buildAVLInputFile();
void buildAVLCommandFile(double AoA);
void readAVLResults();
protected:
private:
node& configXML;
Fuselage *myFuselagePt;
};
#endif // WING_H
|
65c3c2232fcba143e87a84202113c67c4e497eda
|
03b340271058d3aa8e1ec04e16686a79b9acb3bd
|
/libs/ContourTree/HeightField_Construction.cpp
|
c0e6ce4d75aee864c767b3f440100e67ae9274ed
|
[] |
no_license
|
wesleygriffin/SPLIT_VIS2
|
bad9b7d252922b8e4d2cfa2f0244cb48daaae70f
|
d81d74e708c88d04c9433ce07036a0c6a18af8ef
|
refs/heads/master
| 2021-01-09T20:05:17.033582
| 2018-07-21T18:30:00
| 2018-07-21T18:30:00
| 81,224,112
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 79,564
|
cpp
|
HeightField_Construction.cpp
|
// IsoSurface II
// Hamish Carr, 2000
// HeightField: class representing the height field
// HeightField_Creation: routines dealing with construction, and computation of contour tree
// Palatino-12; 10 m-spaces/tab
#include "HeightField.h" // include the header for the definitions
#include <math.h> // for HUGE_VAL
#include <stdio.h>
#include <GL/freeglut.h>
#include <iostream>
#include <ctime>
//#include "RicVolume.h"
using namespace std;
#define HEIGHT_FIELD_DEBUG_STEP_THROUGH 1
//#define DEBUG_JOIN_TREE 1 // whether to include debug code for CreateJoinTree()
//#define DEBUG_SPLIT_TREE 1 // whether to include debug code for CreateSplitTree()
//#define DEBUG_COMBINE_TREES 1 // whether to include debug code for CombineTrees()
//#define DEBUG_CONSTRUCTOR 1 // whether to include debug code for constructor
//#define DEBUG_QUEUE_NEIGHBOURS 1 // whether to include debug code for QueueNeighbours
//#define DEBUG_ADD_SUPERARC 1 // whether to include debug code for DEBUG_ADD_SUPERARC
//#define FLUSH_TIMING_BUFFER 0
#define FLUSH_TIMING_BUFFER 1
#define IGNORE_TIMING_BUFFER 0
//#define IGNORE_TIMING_BUFFER 1
//#define ENDIAN_SWAP_SHORTS 1
static int dotFileNo = 0;
// declare a large memory buffer into which we can dump characters
char *timingBuffer, *timingStart;
// some timing structures
time_t startTime, lastTime, thisTime, thatTime;
// and a function to call at exit to print the buffer
void printTimingBuffer()
{ // printTimingBuffer
if (IGNORE_TIMING_BUFFER) return;
printf("%s", timingStart);
} // printTimingBuffer
// this routine flushes the buffer to standard out
void flushTimingBuffer()
{ // flushTimingBuffer
if (! FLUSH_TIMING_BUFFER) return;
if (IGNORE_TIMING_BUFFER) return;
printf("%s", timingStart);
// update the "start"
timingBuffer = timingStart;
*timingBuffer = '\0';
} // flushTimingBuffer
// compareHeightVoid(): compares two heights in an array
int compareHeightVoid(const void *e1, const void *e2) // comparison function for sorting, &c.
{
float **d1 = (float **) e1; float **d2 = (float **) e2; // convert to correct type
return compareHeight(*d1, *d2); // and call the comparison function
} // end of compareHeightVoid()
// compareHeight(): compares two heights in an array
int compareHeight(const float *d1, const float *d2) // comparison function for all other purposes
{
if (*d1 < *d2) return -1; // and compute return values
if (*d1 > *d2) return 1;
if (d1 < d2) return -1; // break ties with pointer addresses (unique)
if (d1 > d2) return 1;
printf("Major problem: neither sorted higher.\n");
printf("%p %p \n", d1, d2);
return 0;
} // end of compareHeight()
#define FILE_TYPE_ASCII 0
#define FILE_TYPE_VOL 1
#define FILE_TYPE_RAW 2
#define FILE_TYPE_MHA 3
#define FILE_TYPE_MIRG 4
#define FILE_TYPE_NIFTI 5
// constructor: constructs the object, and automatically computes the contour tree
HeightField::HeightField(int argc, char **argv) // constructor
{ // HeightField()
// HeightField() constructor needs to do the following:
// A. read in the dimensions
// B. set nVertices
// C. allocate leafQueue to a default size, and set leafQSize
// D. allocate height and heightSort
// E. read in the data, setting pointers in heightSort, and finding maxHeight and minHeight in the process
// F. call qsort() to sort heightSort
// set the first & last bytes of the buffer to '\0'
timingStart = timingBuffer = (char *) malloc(TIMING_BUFFER_SIZE);
timingBuffer[0] = '\0';
timingBuffer[TIMING_BUFFER_SIZE - 1] = '\0';
//gettimeofday(&lastFrameTime, NULL);
//gettimeofday(&startTime, NULL);
time(&lastFrameTime);
time(&startTime);
//timingBuffer += sprintf(timingBuffer, "Starting contour tree computation at: %d:%ld\n", startTime.tv_sec % 1000, (long) startTime.tv_usec);
flushTimingBuffer();
// timingBuffer += sprintf(timingBuffer, "Reading data\n");
long fileType = FILE_TYPE_ASCII;
char *suffix; // suffix of file name
suffix = strrchr(argv[1], '.');
if (suffix != NULL)
{ // non-NULL suffix
if (strcmp(suffix, ".vol") == 0)
fileType = FILE_TYPE_VOL;
else if (strcmp(suffix, ".raw") == 0)
fileType = FILE_TYPE_RAW;
else if (strcmp(suffix, ".i01") == 0)
fileType = FILE_TYPE_RAW;
else if (strcmp(suffix, ".img") == 0)
fileType = FILE_TYPE_RAW;
else if (strcmp(suffix, ".mha") == 0)
fileType = FILE_TYPE_MHA;
else if (strcmp(suffix, ".mirg") == 0)
fileType = FILE_TYPE_MIRG;
else if (strcmp(suffix, ".gz") == 0 || strcmp(suffix, ".nii") == 0)
fileType = FILE_TYPE_NIFTI;
} // non-NULL suffix
FILE *inFile;
sampleSum = 0;
switch(fileType)
{ // switch on filetype
case FILE_TYPE_ASCII:
LoadFromASCII(argv[1]);
break;
case FILE_TYPE_RAW:
if (argc < 6) { printf("Unable to open RAW format file %s unless sample size and dimensions are specified.\n", argv[1]); throw 0; }
inFile = fopen(argv[1], "rb");
if (inFile == NULL) { printf("Unable to open RAW format fiel %s\n", argv[1]); throw 0; }
sampleSize = atol(argv[2]); if ((sampleSize < 1) || (sampleSize > 8)) { printf("Illegal sample size %d\n", sampleSize); throw 0; }
xDim = atol(argv[3]); if ((xDim < 1) || (xDim > 2048)) { printf("Illegal x dimension %d\n", xDim); throw 0; }
yDim = atol(argv[4]); if ((yDim < 1) || (yDim > 2048)) { printf("Illegal y dimension %d\n", yDim); throw 0; }
zDim = atol(argv[5]); if ((zDim < 1) || (zDim > 2048)) { printf("Illegal z dimension %d\n", zDim); throw 0; }
LoadFromRaw(inFile);
break;
case FILE_TYPE_VOL:
{
ifstream fin(argv[1]);
if (!fin.is_open()) { printf("Unable to open file %s\n", argv[1]); throw 0; }
fin >> zDim >> yDim >> xDim;
if ((xDim < 1) || (xDim > 2048)) { printf("Illegal x dimension %d\n", xDim); throw 0; }
if ((yDim < 1) || (yDim > 2048)) { printf("Illegal y dimension %d\n", yDim); throw 0; }
if ((zDim < 1) || (zDim > 2048)) { printf("Illegal z dimension %d\n", zDim); throw 0; }
}
if (argc < 3) { printf("Unable to open VOL format file %s unless sample size is specified.\n", argv[1]); throw 0; }
sampleSize = atol(argv[2]); if ((sampleSize < 1) || (sampleSize > 8)) { printf("Illegal sample size %d\n", sampleSize); throw 0; }
inFile = fopen(argv[1], "rb");
if (inFile == NULL) { printf("Unable to open VOL format file %s\n", argv[1]); throw 0; }
// rewind to the beginning of the block
fseek(inFile, -xDim*yDim*zDim*sampleSize, SEEK_END);
LoadFromRaw(inFile);
break;
case FILE_TYPE_MHA:
{
FILE *dimFile = fopen(argv[1], "r");
if (dimFile == NULL) { printf("Unable to open file %s\n", argv[1]); throw 0; }
fscanf(dimFile, "NDims = 3\nDimSize = %d %d %d", &zDim, &yDim, &xDim);
printf("Dimensions read: %d %d %d\n", xDim, yDim, zDim);
if ((xDim < 1) || (xDim > 2048)) { printf("Illegal x dimension %d\n", xDim); throw 0; }
if ((yDim < 1) || (yDim > 2048)) { printf("Illegal y dimension %d\n", yDim); throw 0; }
if ((zDim < 1) || (zDim > 2048)) { printf("Illegal z dimension %d\n", zDim); throw 0; }
}
if (argc < 3) { printf("Unable to open MHA format file %s unless sample size is specified.\n", argv[1]); throw 0; }
sampleSize = atol(argv[2]); if ((sampleSize < 1) || (sampleSize > 8)) { printf("Illegal sample size %d\n", sampleSize); throw 0; }
inFile = fopen(argv[1], "rb");
if (inFile == NULL) { printf("Unable to open MHA format file %s\n", argv[1]); throw 0; }
// rewind to the beginning of the block
fseek(inFile, -xDim*yDim*zDim*sampleSize, SEEK_END);
LoadFromRaw(inFile);
break;
case FILE_TYPE_MIRG:
{
FILE *dimFile = fopen(argv[1], "r");
if (dimFile == NULL) { printf("Unable to open file %s\n", argv[1]); throw 0; }
int nRead = fscanf(dimFile, "X =%d\nY =%d\nZ =%d", &zDim, &yDim, &xDim);
printf("Dimensions read: %d %d %d\n", xDim, yDim, zDim);
if ((xDim < 1) || (xDim > 2048)) { printf("Illegal x dimension %d\n", xDim); throw 0; }
if ((yDim < 1) || (yDim > 2048)) { printf("Illegal y dimension %d\n", yDim); throw 0; }
if ((zDim < 1) || (zDim > 2048)) { printf("Illegal z dimension %d\n", zDim); throw 0; }
}
sampleSize = 2;
inFile = fopen(argv[1], "rb");
if (inFile == NULL) { printf("Unable to open MIRG format file %s\n", argv[1]); throw 0; }
// rewind to the beginning of the block
fseek(inFile, -xDim*yDim*zDim*sampleSize, SEEK_END);
LoadFromRaw(inFile);
break;
/* case FILE_TYPE_NIFTI:
{
FILE *dimFile = fopen(argv[1], "r");
if (dimFile == NULL) { printf("Unable to open file %s\n", argv[1]); throw 0; }
fclose(dimFile);
RicVolume vol;
vol.Read(argv[1]);
zDim = vol.get_numz();
yDim = vol.get_numy();
xDim = vol.get_numx();
printf("Dimensions read: %d %d %d\n", xDim, yDim, zDim);
if ((xDim < 1) || (xDim > 2048)) { printf("Illegal x dimension %d\n", xDim); throw 0; }
if ((yDim < 1) || (yDim > 2048)) { printf("Illegal y dimension %d\n", yDim); throw 0; }
if ((zDim < 1) || (zDim > 2048)) { printf("Illegal z dimension %d\n", zDim); throw 0; }
LoadFromNifti(argv[1]);
break;
}
*/
} // switch on filetype
printf("SampleSum: %12.1f\n", sampleSum);
// H. invoke the routines to do the rest of construction
CreateJoinTree();
CreateSplitTree();
AugmentTrees();
CombineTrees();
// I. clean up any dynamically allocated working memory
joinComponent.Construct(0, 0, 0); // reset join component to 0 logical size
splitComponent.Construct(0, 0, 0); // reset split component to 0 logical size
// we keep this, because it lets us know which vertices belong to which superarc
// contourComponent.Construct(0, 0, 0); // reset contour component to 0 logical size
joinArcs.Construct(0,0,0); splitArcs.Construct(0,0,0); // likewise for join and split arc arrays
free(leafQueue);
leafQueue = NULL;
free(heightSort);
heightSort = NULL;
// J. perform any additional processing (such as collapsing)
SetNodeXPositions(); // sets the x-positions of the nodes (must happen before epsilon collapse)
CollapseEpsilonEdges(); // collapses epsilon edges
collapseRecord = (long *) calloc(nNonEpsilonArcs, sizeof(long)); // allocate array for collapse record
collapseBounds = (long *) calloc(nNonEpsilonArcs, sizeof(long)); // allocate array for collapse bounds
// collapsePriority = PRIORITY_HYPERVOLUME;
// CollapseLeafPruning(1, nVertices);
savedNextSuperarc = nextSuperarc; // store this for use in resetting collapse priority
// K. allocate memory for variables associated with flexible isosurfaces
active = (long *) malloc(sizeof(long) * nSuperarcs); // and ample room for the active set
selected = (long *) malloc(sizeof(long) * nSuperarcs); // the selected set . . .
restorable = (long *) malloc(sizeof(long) * nSuperarcs); // the restorable set
selectionRoot = noContourSelected; // and, initially, no selection
// set the active, &c. lists
nActiveArcs = nSelectedArcs = nRestorableArcs = 0;
SetInitialColours();
baseDisplayListID = glGenLists(nSuperarcs * 2); // create display lists for each superarc
time(&thisTime);
// timingBuffer += sprintf(timingBuffer, "Construction complete at: %ld:%ld\n", thisTime.tv_sec % 1000, thisTime.tv_usec);
//timingBuffer += sprintf(timingBuffer, "Construction took %8.5f seconds\n", (float)(thisTime.tv_sec - startTime.tv_sec) + 1E-6 * (thisTime.tv_usec - startTime.tv_usec));
timingBuffer += sprintf(timingBuffer, "Construction took %8.5f seconds\n", (float)difftime(thisTime,startTime));
timingBuffer += sprintf(timingBuffer, "Contour tree has %ld superarcs\n", nSuperarcs);
timingBuffer += sprintf(timingBuffer, "Memory occupied by contour tree & related structures: %ld\n",
nSuperarcs * sizeof(Superarc) * 2 + // superarc storage, including collapsed superarcs
nSupernodes * sizeof(Supernode) + // supernode storage
nSuperarcs * sizeof(long) * 5 + // valid (x2), active, selected, restorable
nSupernodes * sizeof(long) + // validNodes
nNonEpsilonArcs * sizeof(long) * 2 // collapseRecord & collapseBounds
);
flushTimingBuffer();
pathLengths = (long *) malloc(sizeof(long) * 2 * nSuperarcs);
nContourTriangles = (long *) malloc(sizeof(long) * 2 * nSuperarcs);
extractionTime = (float *) malloc(sizeof(float) * 2 * nSuperarcs);
for (int i = 0; i < 2 * nSuperarcs; i++)
{
pathLengths[i] = nContourTriangles[i] = 0;
extractionTime[i] = 0.0;
}
PrintContourTree();
// register the function to dump the timing buffer to output
atexit(printTimingBuffer);
} // HeightField()
// destructor: destroys the object, and deallocates dynamically allocated storage
HeightField::~HeightField() // destructor
{
if (heightSort != NULL) free(heightSort); // release heightSort, if it exists
if (leafQueue != NULL) free(leafQueue); // ditto for leaf queue
free(superarcs); // free the superarc array
free(supernodes); // and the supernode array
free(collapseRecord);
free(collapseBounds);
free(active); free(valid); free(validNodes); free(selected); free(restorable);
} // end of destructor
// CreateJoinTree()
void HeightField::CreateJoinTree() // does the down sweep to create the join tree
{
// CreateJoinTree() needs to do the following:
// A. create the array holding the join components, all initialized to NULL
// B. do a loop in downwards order, adding each vertex to the union-find:
// i. queue up the neighbours of the vertex
// ii. loop through all neighbours of the vertex:
// a. if the neighbour is lower than the vertex, skip
// b. if the neighbour belongs to a different component than the vertex
// 1. and the vertex has no component yet, add the vertex to the component
// 2. the vertex is a component, but is not yet a join, make it a join
// 3. the vertex is a join, merge the additional component
// iii. if the vertex still has no (NULL) component, start a new one
// C. tie off the final component to minus_infinity
long x, y, z; // coordinates of any given vertex
long nbrX, nbrY, nbrZ; // coordinates of a neighbour
long joinX, joinY, joinZ; // for computing top end of join arc
long nNbrComponents; // # of neighbouring components
Component *jComp; // local pointer to join component of vertex
// A. create the array holding the join components, all initialized to NULL
// cout << "Starting computation of join tree." << endl;
joinComponent.Construct(xDim, yDim, zDim); // create the join component array
joinArcs.Construct(xDim, yDim, zDim);
nSupernodes = 0; // initially, we know of none
nJoinSupernodes = 0;
// B. do a loop in downwards order, adding each vertex to the union-find:
for (vertex = nVertices - 1; vertex >= 0; vertex--) // walk from high end of array
{ // i
if (vertex == nVertices - 2)
{
time(&thatTime);
// timingBuffer += sprintf(timingBuffer, "Starting computation of join tree at %ld: %ld\n", thatTime.tv_sec % 1000, thatTime.tv_usec);
// flushTimingBuffer();
}
// i. queue up the neighbours of the vertex
height.ComputeIndex(heightSort[vertex], x, y, z); // compute the indices of the vertex
#ifdef DEBUG_JOIN_TREE
printf("Examining vertex (%ld, %ld, %ld)\n", x, y, z); // print out the number of the vertex
// PrintJoinComponents();
// getc(stdin);
#endif
QueueJoinNeighbours(x, y, z); // and set up the neighbour queue
nNbrComponents = 0; // reset the count of neighbouring components
// ii. loop through all neighbours of the vertex:
jComp = joinComponent(x, y, z); // retrieve a local pointer to the join component of the vertex
for (long neighbour = 0; neighbour < nNeighbours; neighbour++) // loop through neighbours
{
nbrX = neighbourQueue[neighbour][0]; nbrY = neighbourQueue[neighbour][1]; nbrZ = neighbourQueue[neighbour][2];
// a. if the neighbour is lower than the vertex, skip
if (compareHeight(&(height(nbrX, nbrY, nbrZ)), heightSort[vertex]) < 0)
// if neighbour sorts lower
continue; // skip to end of loop
Component *nbrComponent = joinComponent(nbrX, nbrY, nbrZ)->component();
// retrieve the neighbour's component from union-find
// b. if the neighbour belongs to a different component than the vertex
if (jComp != nbrComponent) // compare components
{ // B.ii.b.
// 1. and the vertex has no component yet, add the vertex to the component
if (nNbrComponents == 0) // this is the first neighbouring component
{ // B.ii.b.1.
joinComponent(x, y, z) = jComp = nbrComponent; // set the vertex to point to it
nbrComponent->seedTo = (&height(nbrX, nbrY, nbrZ)); // set the seed pointer to nbr (it's adjacent to the vertex)
nbrComponent->seedFrom = heightSort[vertex]; // but set both ends . . .
height.ComputeIndex(nbrComponent->loEnd, joinX, joinY, joinZ);
joinArcs(joinX, joinY, joinZ) = heightSort[vertex]; // and add the corresponding join arc to the tree
nbrComponent->loEnd = heightSort[vertex]; // and update the lo end (for drawing purposes)
nNbrComponents++; // increment the number of neighbouring components
} // B.ii.b.1.
// 2. the vertex is a component, but is not yet a join, make it a join
else if (nNbrComponents == 1) // this is the second neighbouring component
{ // B.ii.b.2.
// create a new component
// printf("Join at (%3ld, %3ld, %3ld)\n", x, y, z); fflush(stdout);
Component *newComponent = new Component; // create a new component
newComponent->hiEnd = heightSort[vertex]; // with the vertex at the high end
newComponent->loEnd = heightSort[vertex]; // make the low end predictable
newComponent->nextHi = jComp; // set its nextHi pointer
newComponent->lastHi = nbrComponent; // and its lastHi pointer
// update the neighbour's component
// printf("Neighbour joining is: (%3ld, %3ld, %3ld)\n", nbrX, nbrY, nbrZ); fflush(stdout);
nbrComponent->seedTo = (&height(nbrX, nbrY, nbrZ)); // set the seed pointer to nbr (it's adjacent to the vertex)
nbrComponent->seedFrom = heightSort[vertex]; // but set both ends . . .
height.ComputeIndex(nbrComponent->loEnd, joinX, joinY, joinZ);
joinArcs(joinX, joinY, joinZ) = heightSort[vertex]; // and add the corresponding join arc to the tree
nbrComponent->loEnd = heightSort[vertex]; // make the vertex the low end of the neighbour's component
nbrComponent->nextLo = newComponent; // set the nextLo pointer
nbrComponent->lastLo = jComp; // and the lastLo pointer
// update the existing pointer for the vertex' component
// height.ComputeIndex(jComp->hiEnd, nbrX, nbrY, nbrZ);
// printf("Existing component is: (%3ld, %3ld, %3ld)\n", nbrX, nbrY, nbrZ); fflush(stdout);
jComp->loEnd = heightSort[vertex]; // make the vertex the low end of the component it was assigned to
jComp->nextLo = nbrComponent; // set the nextLo pointer
jComp->lastLo = newComponent; // and the lastLo pointer
// perform the merge
nbrComponent->mergeTo(newComponent); // perform the actual merge
jComp->mergeTo(newComponent); // for both old components
// and reset the join component
joinComponent(x, y, z) = jComp = newComponent; // reset it
nNbrComponents++; // increment the number of neighbouring components
nSupernodes++; // and increment the number of supernodes
nJoinSupernodes++;
} // B.ii.b.2.
// 3. the vertex is a join, merge the additional component
else // i.e. nNbrComponents > 1
{ // B.ii.b.3
// update the neighbour's component
nbrComponent->seedTo = (&height(nbrX, nbrY, nbrZ)); // set the seed pointer to nbr (it's adjacent to the vertex)
nbrComponent->seedFrom = heightSort[vertex]; // but set both ends . . .
height.ComputeIndex(nbrComponent->loEnd, joinX, joinY, joinZ);
joinArcs(joinX, joinY, joinZ) = heightSort[vertex]; // and add the corresponding join arc to the tree
nbrComponent->loEnd = heightSort[vertex]; // make the vertex the low end of the neighbour's component
nbrComponent->nextLo = jComp; // set the nextLo pointer
nbrComponent->lastLo = jComp->lastHi; // and the lastLo pointer (NB: jComp is downwards)
nbrComponent->lastLo->nextLo = nbrComponent; // reset the nextLo pointer of the old lastHi
// perform the merge
nbrComponent->mergeTo(jComp); // perform the actual merge
jComp->lastHi = nbrComponent; // and finally, the lastHi pointer
} // B.ii.b.3
} // B.ii.b.
} // neighbour
// iii. if the vertex still has no (NULL) component, start a new one
if (jComp == NULL) // no neighbours found: must be a local maximum
{ // B.iii.
joinComponent(x, y, z) = jComp = new Component; // create a new component
jComp->hiEnd = jComp->loEnd = heightSort[vertex]; // with the vertex at the high end (loEnd too, to give something to draw)
jComp->loEnd = heightSort[vertex]; // set it to something predictable
jComp->nextHi = jComp; // set circular links to itself
jComp->lastHi = jComp; // in both directions
jComp->nextLo = jComp->lastLo = jComp; // set bottom end to point to self
nSupernodes++; // and increment the number of supernodes
nJoinSupernodes++;
} // B.iii.
} // i
// C. tie off the final component to minus_infinity
height.ComputeIndex(jComp->loEnd, joinX, joinY, joinZ); // compute the low end
joinArcs(joinX, joinY, joinZ) = &minus_infinity; // and add the corresponding join arc to the tree
jComp->loEnd = &minus_infinity; // set the loEnd to minus infinity
jComp->nextLo = jComp->lastLo = jComp; // set the circular list pointers
joinRoot = jComp; // and store a pointer to it
#ifdef DEBUG_JOIN_TREE
// PrintJoinComponents();
#endif
time(&thisTime);
// timingBuffer += sprintf(timingBuffer, "Finished computation of join tree at %ld: %ld\n", thisTime.tv_sec % 1000, thisTime.tv_usec);
timingBuffer += sprintf(timingBuffer, "Join Tree has %ld supernodes, and took %8.5f seconds to compute\n", nJoinSupernodes,
//(float)(thisTime.tv_sec - thatTime.tv_sec) + 1E-6 * (thisTime.tv_usec - thatTime.tv_usec));
(float)difftime(thisTime, thatTime));
flushTimingBuffer();
// PrintJoinTree();
} // end of CreateJoinTree()
// CreateSplitTree()
void HeightField::CreateSplitTree() // does the up sweep to create the split tree
{
// CreateSplitTree() needs to do the following:
// A. create the array holding the split components, all initialized to NULL
// B. do a loop in upwards order, adding each vertex to the union-find:
// i. queue up the neighbours of the vertex
// ii. loop through all neighbours of the vertex:
// a. if the neighbour is higher than the vertex, skip
// b. if the neighbour belongs to a different component than the vertex
// 1. and the vertex has no component yet, add the vertex to the component
// 2. the vertex is a component, but is not yet a split, make it a split
// 3. the vertex is a split, merge the additional component
// iii. if the vertex still has no (NULL) component, start a new one
// C. tie off the final component to plus infinity
long x, y, z; // coordinates of any given vertex
long nbrX, nbrY, nbrZ; // coordinates of a neighbour
long splitX, splitY, splitZ; // for computing bottom end of split arc
long nNbrComponents; // # of neighbouring components
Component *sComp; // local pointer to split component of vertex
#ifdef DEBUG_SPLIT_TREE
printf("Starting computation of split tree\n");
#endif
// A. create the array holding the split components, all initialized to NULL
time(&thatTime);
// timingBuffer += sprintf(timingBuffer, "Starting computation of split tree at %ld: %ld\n", thatTime.tv_sec % 1000, thatTime.tv_usec);
// flushTimingBuffer();
splitComponent.Construct(xDim, yDim, zDim); // construct the array of split components
splitArcs.Construct(xDim, yDim, zDim);
nSplitSupernodes = 0; // reset count of split supernodes
// B. do a loop in upwards order, adding each vertex to the union-find:
for (vertex = 0; vertex < nVertices; vertex++) // walk from low end of array
{ // i
// i. queue up the neighbours of the vertex
height.ComputeIndex(heightSort[vertex], x, y, z); // compute the indices of the vertex
#ifdef DEBUG_SPLIT_TREE
printf("Examining vertex (%ld, %ld, %ld)\n", x, y, z); // print out the number of the vertex
// PrintSplitComponents();
#endif
QueueSplitNeighbours(x, y, z); // and set up the neighbour queue
nNbrComponents = 0; // reset the count of neighbouring components
// ii. loop through all neighbours of the vertex:
sComp = splitComponent(x, y, z); // retrieve a local pointer to the split component of the vertex
for (long neighbour = 0; neighbour < nNeighbours; neighbour++) // loop through neighbours
{
nbrX = neighbourQueue[neighbour][0]; nbrY = neighbourQueue[neighbour][1]; nbrZ = neighbourQueue[neighbour][2];
// a. if the neighbour is higher than the vertex, skip
if (compareHeight(&(height(nbrX, nbrY, nbrZ)), heightSort[vertex]) > 0)
// if neighbour sorts higher
continue; // skip to end of loop
#ifdef CHECK_INTERNAL_CONDITIONS
if (compareHeight(&(height(nbrX, nbrY, nbrZ)), heightSort[vertex]) == 0)
// this should *NEVER* be allowed to happen: a vertex cannot be its own neighbour
{ printf("compareHeight says that %p (%f) and %p (%f) have identical heights\n", neighbour, *neighbour, heightSort[vertex], *(heightSort[vertex])); BAILOUT; }
#endif
Component *nbrComponent = splitComponent(nbrX, nbrY, nbrZ)->component();
// retrieve the neighbour's component from union-find
// b. if the neighbour belongs to a different component than the vertex
if (sComp != nbrComponent) // compare components
{ // B.ii.b.
// 1. and the vertex has no component yet, add the vertex to the component
if (nNbrComponents == 0) // this is the first neighbouring component
{ // B.ii.b.1.
splitComponent(x, y, z) = sComp = nbrComponent; // set the vertex to point to it
nbrComponent->seedTo = (&height(nbrX, nbrY, nbrZ)); // set the seed pointer to nbr (it's adjacent to the vertex)
nbrComponent->seedFrom = heightSort[vertex]; // but set both ends . . .
height.ComputeIndex(nbrComponent->hiEnd, splitX, splitY, splitZ);
splitArcs(splitX, splitY, splitZ) = heightSort[vertex]; // and add the corresponding split arc to the tree
nbrComponent->hiEnd = heightSort[vertex]; // and update the hi end (for drawing purposes)
nNbrComponents++; // increment the number of neighbouring components
} // B.ii.b.1.
// 2. the vertex is a component, but is not yet a split, make it a split
else if (nNbrComponents == 1) // this is the second neighbouring component
{ // B.ii.b.2.
// create a new component
Component *newComponent = new Component; // create a new component
newComponent->loEnd = heightSort[vertex]; // with the vertex at the low end
newComponent->hiEnd = heightSort[vertex]; // make the high end something predictable
newComponent->nextLo = sComp; // set its nextLo pointer
newComponent->lastLo = nbrComponent; // and its lastLo pointer
// update the neighbour's component
nbrComponent->seedTo = (&height(nbrX, nbrY, nbrZ)); // set the seed pointer to nbr (it's adjacent to the vertex)
nbrComponent->seedFrom = heightSort[vertex]; // but set both ends . . .
height.ComputeIndex(nbrComponent->hiEnd, splitX, splitY, splitZ);
splitArcs(splitX, splitY, splitZ) = heightSort[vertex]; // and add the corresponding split arc to the tree
nbrComponent->hiEnd = heightSort[vertex]; // make the vertex the high end of the neighbour's component
nbrComponent->nextHi = newComponent; // set the nextHi pointer
nbrComponent->lastHi = sComp; // and the lastHi pointer
// perform the merge
nbrComponent->mergeTo(newComponent); // perform the actual merge
sComp->mergeTo(newComponent); // for both old components
// update the existing pointer for the vertex' component
sComp->hiEnd = heightSort[vertex]; // make the vertex the high end of the component it was assigned to
sComp->nextHi = nbrComponent; // set the nextHi pointer
sComp->lastHi = newComponent; // and the lastHi pointer
// and reset the split component
splitComponent(x, y, z) = sComp = newComponent;
nNbrComponents++; // increment the number of neighbouring components
// check to see if its a join supernode
if (joinComponent(x, y, z)->hiEnd != &height(x, y, z)) // if it isn't a join supernode
nSupernodes++; // increment the number of supernodes
nSplitSupernodes++;
} // B.ii.b.2.
// 3. the vertex is a split, merge the additional component
else // i.e. nNbrComponents > 1
{ // B.ii.b.3
// update the neighbour's component
nbrComponent->seedTo = (&height(nbrX, nbrY, nbrZ)); // set the seed pointer to nbr (it's adjacent to the vertex)
nbrComponent->seedFrom = heightSort[vertex]; // but set both ends . . .
height.ComputeIndex(nbrComponent->hiEnd, splitX, splitY, splitZ);
splitArcs(splitX, splitY, splitZ) = heightSort[vertex]; // and add the corresponding split arc to the tree
nbrComponent->hiEnd = heightSort[vertex]; // make the vertex the high end of the neighbour's component
nbrComponent->nextHi = sComp; // set the nextHi pointer
nbrComponent->lastHi = sComp->lastLo; // and the lastHi pointer (NB: sComp is upwards)
nbrComponent->lastHi->nextHi = nbrComponent; // reset the nextHi pointer of the old lastLo
// perform the merge
nbrComponent->mergeTo(sComp); // perform the actual merge
sComp->lastLo = nbrComponent; // and finally, the lastLo pointer
} // B.ii.b.3
} // B.ii.b.
} // neighbour
// iii. if the vertex still has no (NULL) component, start a new one
if (sComp == NULL) // no neighbours found: must be a local maximum
{ // B.iii.
splitComponent(x, y, z) = sComp = new Component; // create a new component
sComp->loEnd = heightSort[vertex]; // with the vertex at the low end
sComp->hiEnd = heightSort[vertex]; // and, just for good measure, at the high end
sComp->nextLo = sComp; // set circular links to itself
sComp->lastLo = sComp; // in both directions
sComp->nextHi = sComp->lastHi = sComp; // tie off the upper end
// check to see if its a join supernode
if (joinComponent(x, y, z)->hiEnd != &height(x, y, z)) // if it isn't a join supernode
nSupernodes++; // increment the number of supernodes
nSplitSupernodes++;
} // B.iii.
} // i
// C. tie off the final component to plus infinity
height.ComputeIndex(sComp->hiEnd, splitX, splitY, splitZ);
splitArcs(splitX, splitY, splitZ) = &plus_infinity; // and add the corresponding split arc to the tree
sComp->hiEnd = &plus_infinity; // set the hiEnd to plus infinity
sComp->nextHi = sComp->lastHi = sComp; // set the circular list pointers
splitRoot = sComp; // and store a pointer to it
#ifdef DEBUG_SPLIT_TREE
// PrintSplitComponents();
#endif
time(&thisTime);
// timingBuffer += sprintf(timingBuffer, "Finished computation of join tree at %ld: %ld\n", thisTime.tv_sec % 1000, thisTime.tv_usec);
timingBuffer += sprintf(timingBuffer, "Split Tree has %ld supernodes, and took %8.5f seconds to compute\n", nSplitSupernodes,
//(float) (thisTime.tv_sec - thatTime.tv_sec) + 1E-6 * (thisTime.tv_usec - thatTime.tv_usec));
difftime(thisTime, thatTime));
flushTimingBuffer();
// PrintSplitTree();
} // end of CreateSplitTree()
void HeightField::AugmentTrees() // augments join and split trees with nodes of other
{ // AugmentTrees()
// A. Allocate space for the leaf queue, contourComponent, and the contour tree
// B. Augment the join and split trees and construct the leaf queue: loop through vertices from high to low
// i. if a vertex is not in the split tree, but is in the join tree
// a. add to the split tree
// b. if the vertex is degree 1 in the join tree
// 1. add to leaf queue
// i. if a vertex is not in the join tree, but is in the split tree
// a. add to the join tree
// b. if the vertex is degree 1 in the split tree
// 1. add to leaf queue
long x, y, z; // coordinates of vertex
float *theVertex; // pointer to vertex in data set
Component *jComp, *sComp; // pointers to component in join & split trees
time(&thatTime);
// timingBuffer += sprintf(timingBuffer, "Starting augmentation of trees at %ld: %ld\n", thatTime.tv_sec % 1000, thatTime.tv_usec);
// flushTimingBuffer();
// A. Allocate space for the leaf queue, contourComponent, and the contour tree
nextSuperarc = nextSupernode = 0; // set index to next available superarc
nSuperarcs = nSupernodes - 1; // for a tree, this is always true
superarcs = (Superarc *) malloc((sizeof(Superarc) * 2 * nSuperarcs)); // allocate room for collapsed edges as well
supernodes = (Supernode *) malloc((sizeof(Supernode) * nSupernodes)); // allocate room forsupernodes
leafQueue = (float **) malloc((sizeof(float *) * (1 + nSupernodes))); // we need to add one because the last one will be added twice (due to pts at inf)
leafQSize = 0; // no nodes on the leaf queue (yet)
valid = (long *) malloc(sizeof(long) * nSuperarcs * 2); // allocate room for collapsed superarcs as well
validNodes = (long *) malloc(sizeof(long) * nSupernodes); // the set of valid supernodes
nValidNodes = nValidArcs = 0;
// B. Augment the join and split trees and construct the leaf queue: loop through vertices from high to low
for (vertex = nVertices - 1; vertex >= 0; vertex--)
{ // B.
#ifdef DEBUG_COMBINE_TREES
// printf("Join Tree: \n");
// PrintJoinTree();
// printf("Split Tree: \n");
// PrintSplitTree();
#endif
theVertex = heightSort[vertex]; // retrieve the vertex from the sort list
height.ComputeIndex(theVertex, x, y, z); // compute its indices
jComp = joinComponent(x, y, z); // retrieve the corresponding join component
sComp = splitComponent(x, y, z); // and the corresponding split component
// i. if a vertex is not in the split tree but is in the join tree
// this test suffices for two purposes: a. augmenting the split tree (for obvious reasons)
// b. to help find upper leaves, which can be neither splits nor local minima, and are therefore not in the split tree
if ((sComp->loEnd != theVertex) && (jComp->hiEnd == theVertex)) // if the component did not start at this vertex, it's not in the split tree
{ // B.i.
// a. add to the split tree
// to do this, I splice an additional component on to the top end of the existing component: thus, the existing component is valid for future tests
Component *splice = new Component; // create it
splice->hiEnd = sComp->hiEnd; splice->loEnd = theVertex; // set the ends of the splice
sComp->hiEnd = theVertex; // reset the upper end of the existing component
if (sComp->nextHi == sComp) // this only happens at plus infinity
splice->nextHi = splice->lastHi = splice; // link it to itself
else // any other case
{ // else sComp isn't highest arc
splice->nextHi = sComp->nextHi; splice->lastHi = sComp->lastHi; // grab the circular edge-list pointers from sComp
if (splice->nextHi->loEnd == splice->hiEnd) // this happens if the next edge around hiEnd is upwards
splice->nextHi->lastLo = splice; // so reset the low-end circular list there
else // i.e. next edge around hiEnd is also downwards
splice->nextHi->lastHi = splice; // reset the high-end circular list there
if (splice->lastHi->loEnd == splice->hiEnd) // basically the same as before, only in backwards direction
splice->lastHi->nextLo = splice; // reset the lo pointer
else
splice->lastHi->nextHi = splice; // reset the hi pointer
} // else sComp isn't highest arc
splice->seedFrom = sComp->seedFrom; splice->seedTo = sComp->seedTo; // make sure that any seed is in the top component
sComp->seedFrom = sComp->seedTo = NULL; // make sure that any seed is in the top component
splice->nextLo = splice->lastLo = sComp; // set up circular list around the vertex
sComp->nextHi = sComp->lastHi = splice; // above and below
splitComponent(x, y, z) = splice; // and set up the link in the split tree so that we can retrieve the edge-list
nSplitSupernodes++;
// b. if the vertex is degree 1 in the join tree
if (jComp->nextHi == jComp) // only one edge in the circular list at the upper end
// 1. add to leaf queue
{ // B. i. 1.
// printf("Adding leaf %2ld (%p) to leaf queue\n", leafQSize, theVertex);
leafQueue[leafQSize++] = theVertex; // add the vertex to the leaf queue
} // B. i. 1.
} // B. i.
// ii. if a vertex is not in the join tree, but is in the split tree: see above for explanation
if ((jComp->hiEnd != theVertex) && (sComp->loEnd == theVertex)) // if the component did not start at this vertex, it's not in the join tree
{ // B.ii.
// a. add to the join tree
// to do this, I splice an additional component on to the top end of the existing component: thus, the existing component is valid for future tests
Component *splice = new Component; // create it
splice->hiEnd = jComp->hiEnd; splice->loEnd = theVertex; // set the ends of the splice
jComp->hiEnd = theVertex; // reset the upper end of the existing component
if (jComp->nextHi == jComp) // this happens at local maxima
splice->nextHi = splice->lastHi = splice; // link it to itself
else // any other case
{ // else sComp isn't highest arc
splice->nextHi = jComp->nextHi; splice->lastHi = jComp->lastHi; // grab the circular edge-list pointers from sComp
// this next chunk is simpler than above, since join tree always has down-degree of 1
splice->nextHi->lastLo = splice; // so reset the low-end circular list there
splice->lastHi->nextLo = splice; // reset the lo pointer
} // else sComp isn't highest arc
splice->nextLo = splice->lastLo = jComp; // set up circular list around the vertex
jComp->nextHi = jComp->lastHi = splice; // above and below
long xx, yy, zz; // used for grabbing upper end
height.ComputeIndex(splice->hiEnd, xx, yy, zz); // compute index of upper end
joinComponent(xx, yy, zz) = splice; // and set pointer into edge-list for next stage
nJoinSupernodes++;
// b. if the vertex is degree 1 in the split tree
if (sComp->nextLo == sComp) // only one edge in the circular list at the lower end
// 1. add to leaf queue
{ // B.ii.b.1.
// printf("Adding leaf %2ld (%p) to leaf queue\n", leafQSize, theVertex);
leafQueue[leafQSize++] = theVertex; // add the vertex to the leaf queue
} // B.ii.b.1.
} // B. ii.
} // B.
time(&thisTime);
// timingBuffer += sprintf(timingBuffer, "Finished augmentation of trees at %ld: %ld\n", thisTime.tv_sec % 1000, thisTime.tv_usec);
timingBuffer += sprintf(timingBuffer, "Augmentation took %8.5f seconds to compute\n",
//(float)(thisTime.tv_sec - thatTime.tv_sec) + 1E-6 * (thisTime.tv_usec - thatTime.tv_usec));
difftime(thisTime,thatTime));
flushTimingBuffer();
} // AugmentTrees()
// CombineTrees()
void HeightField::CombineTrees() // combines join & split trees to produce contour tree
{ // CombineTrees()
// CombineTrees() needs to do the following:
// C. Loop through the leaves on the leaf queue
// i. if upper leaf
// a. add to contour tree
// b. delete from join tree
// c. delete from split tree
// d. test other end to see if it should be added to leaf queue
// ii. if lower leaf
// a. add to contour tree
// b. delete from split tree
// c. delete from join tree
// d. test other end to see if it should be added to leaf queue
// D. Clean up excess memory, &c.
long x, y, z; // coordinates of vertex
long xNext, yNext, zNext; // for walking down the arcs
float *theVertex; // pointer to vertex in data set
Component *jComp, *sComp; // pointers to component in join & split trees
float *otherEnd; // other end of the arc added
long newSuperarc; // the arc we just added
long upArc, downArc; // indices for walks around vertices
// JoinArcsToDotFile("joinArcs", dotFileNo++);
// SplitArcsToDotFile("splitArcs", dotFileNo++);
#ifdef DEBUG_COMBINE_TREES
// printf("About to start merge loop.\n");
// printf("Join Tree: \n");
// PrintJoinTree();
// printf("Join Components: \n");
// PrintJoinComponents();
// printf("Split Tree: \n");
// PrintSplitTree();
// printf("Split Components: \n");
// PrintSplitComponents();
// printf("Leaf Queue: \n");
// PrintLeafQueue();
#endif
time(&thatTime);
//timingBuffer += sprintf(timingBuffer, "Starting to merge join and split trees at %ld: %ld\n", (long)thatTime.tv_sec % 1000, (long)thatTime.tv_usec);
timingBuffer += sprintf(timingBuffer, "Starting to merge join and split trees now.\n");
flushTimingBuffer();
nodeLookup.Construct(xDim, yDim, zDim); // build array of supernode ID's
for (int i = 0; i < xDim; i++) // walk through each dimension
for (int j = 0; j < yDim; j++)
for (int k = 0; k < zDim; k++)
{
nodeLookup(i, j, k) = NO_SUPERNODE; // setting the ID to predictable value
visitFlags(i, j, k) = 1; // and set the "visit" flag, too
}
// C. Loop through the leaves on the leaf queue
for (vertex = 0; vertex < nSuperarcs; vertex++) // keep going until we've added n-1 edges
{ // C.
// CheckContourTree();
// printf("%ld\n", vertex);
// if (vertex % 10 == 0) { printf("."); fflush(stdout); }
#ifdef DEBUG_COMBINE_TREES
printf("Loop %ld\n", vertex);
// printf("Join Tree: \n");
// PrintJoinTree();
// printf("Split Tree: \n");
// PrintSplitTree();
// printf("Leaf Queue: \n");
// PrintLeafQueue();
// printf("Contour Components: \n");
// PrintContourComponents();
// getc(stdin);
// BAILOUT;
#endif
theVertex = leafQueue[vertex]; // retrieve the vertex from the leaf queue
height.ComputeIndex(theVertex, x, y, z); // compute its indices
jComp = joinComponent(x, y, z); // retrieve the corresponding join component
sComp = splitComponent(x, y, z); // and the corresponding split component
// i. if upper leaf
if (jComp->nextHi == jComp) // since we already know that it's a leaf, this suffices
{ // C. i.
// a. add to contour tree
otherEnd = jComp->loEnd; // grab a pointer to the other end
if (jComp->seedFrom == NULL) // if there wasn't a seed stored on the edge
newSuperarc = AddSuperarc(theVertex, otherEnd, theVertex, FindDescendingNeighbour(theVertex), NULL, NULL);
else
newSuperarc = AddSuperarc(theVertex, otherEnd, NULL, NULL, jComp->seedFrom, jComp->seedTo);
// now compute the sum of the nodes this side of the top end: initial -1 excludes the vertex proper
superarcs[newSuperarc].nodesThisSideOfTop = superarcs[newSuperarc].nodesThisSideOfBottom = nVertices - 1;
superarcs[newSuperarc].sampleSumTop = sampleSum - *theVertex;
for (downArc = superarcs[newSuperarc].nextDown; downArc != newSuperarc; downArc = superarcs[downArc].nextDown)
{ // other downarcs exist
superarcs[newSuperarc].nodesThisSideOfTop -= superarcs[downArc].nodesThisSideOfTop;
superarcs[newSuperarc].sampleSumTop -= superarcs[downArc].sampleSumTop;
// ContourTreeToDotFile("building", dotFileNo++);
} // other downarcs exist
// up arcs: first we have to check if any exist
upArc = supernodes[superarcs[newSuperarc].topID].upList;
if (upArc != NO_SUPERARC)
{ // there are uparcs
do
{ // walk around them
superarcs[newSuperarc].nodesThisSideOfTop -= superarcs[upArc].nodesThisSideOfBottom;
superarcs[newSuperarc].sampleSumTop -= superarcs[upArc].sampleSumBottom;
upArc = superarcs[upArc].nextUp;
} // walk around them
while (upArc != supernodes[superarcs[newSuperarc].topID].upList);
} // there are uparcs
visitFlags(x, y, z) = 0; // set flag for the vertex to mark "visited"
for (float *nextNode = joinArcs(x, y, z); nextNode != otherEnd; nextNode = joinArcs(xNext, yNext, zNext))
{ // nextNode // walk along join arcs to transfer nodes
height.ComputeIndex(nextNode, xNext, yNext, zNext); // find the x, y, z indices for the next step
// printf("Walking past (%1d, %1d, %1d): %8.5f\n", xNext, yNext, zNext, *nextNode);
if (visitFlags(xNext, yNext, zNext) == 1) // 1 => vertex is not yet on a superarc
{ // first time this vertex has been processed
// printf(": counting.");
visitFlags(xNext, yNext, zNext) = 0; // set to 0 to mark that its used, and reset flags for rendering
height.ComputeIndex(nextNode, xNext, yNext, zNext); // find the x, y, z indices
superarcs[newSuperarc].nodesOnArc++; // increment the superarcs node count
superarcs[newSuperarc].sampleSumOnArc += height(xNext, yNext, zNext);
} // first time this vertex has been processed
// printf("\n");
} // nextNode
// compute the count of nodes this side of the bottom
superarcs[newSuperarc].nodesThisSideOfBottom = superarcs[newSuperarc].nodesOnArc + (nVertices - superarcs[newSuperarc].nodesThisSideOfTop);
superarcs[newSuperarc].sampleSumBottom = sampleSum - superarcs[newSuperarc].sampleSumTop + superarcs[newSuperarc].sampleSumOnArc;
// b. delete from join tree
// note that otherEnd is degree 2 or higher (i.e. it is guaranteed to have a downarc, even for last edge, because of existence of -infinity
if (jComp->nextLo->hiEnd == otherEnd) // if the next edge at low end is downwards
jComp->nextLo->lastHi = jComp->lastLo; // reset its lastHi pointer
else jComp->nextLo->lastLo = jComp->lastLo; // otherwise reset the lastLo pointer
if (jComp->lastLo->hiEnd == otherEnd) // if the last edge at low end is downwards
jComp->lastLo->nextHi = jComp->nextLo; // reset its nextHi pointer
else jComp->lastLo->nextLo = jComp->nextLo; // otherwise reset the nextLo pointer
delete jComp; // get rid of the jComp edge
joinComponent(x, y, z) = NULL; // get rid of it in the jComponent array as well
nJoinSupernodes--;
// c. delete from split tree
// since we have +infinity, there will always be an up and a down arc
// this is true even for the last edge, since we start at an upper leaf U. This means that there is a down-arc to the other remaining node, L.
// and since sComp is the departing edge travelling upwards, UL must be downwards in the split tree.
// all we do is collapse sComp & sComp->nextLo onto sComp->nextLo
if (sComp->nextHi == sComp) // i.e. sComp leads to +inf
sComp->nextLo->nextHi = sComp->nextLo->lastHi = sComp->nextLo; // set the upper arcs to itself (i.e. no higher neighbours)
else // not an edge to +inf
{ // not edge to +inf
sComp->nextLo->nextHi = sComp->nextHi; // set the upper arcs
sComp->nextLo->lastHi = sComp->lastHi;
} // not edge to +inf
sComp->nextLo->hiEnd = sComp->hiEnd; // transfer the high end
sComp->nextLo->seedFrom = sComp->seedFrom; // transfer the seed as well
sComp->nextLo->seedTo = sComp->seedTo; // transfer the seed as well
if (sComp->nextHi->loEnd == sComp->hiEnd) // if nextHi is an up-arc
sComp->nextHi->lastLo = sComp->nextLo; // adjust the low end
else sComp->nextHi->lastHi = sComp->nextLo; // otherwise the high end
if (sComp->lastHi->loEnd == sComp->hiEnd) // if lastHi is an up-arc
sComp->lastHi->nextLo = sComp->nextLo; // adjust the low end
else sComp->lastHi->nextHi = sComp->nextLo; // otherwise the high end
delete sComp; // delete the now-useless edge
splitComponent(x, y, z) = NULL; // get rid of it in the sComponent array as well
nSplitSupernodes--;
// d. test other end to see if it should be added to leaf queue
// we have reduced the up-degree of otherEnd in the join tree, and haven't changed the degrees in the split tree
height.ComputeIndex(otherEnd, x, y, z); // compute indices
sComp = splitComponent(x, y, z); // retrieve the split component
jComp = joinComponent(x, y, z); // and the join component
if ( ( (jComp->nextHi == jComp) // two ways otherEnd can be a leaf: upper
&& (sComp->nextLo->nextHi == sComp) ) // (jComp has no "higher end" nbr, sComp has one each way)
|| ( ( (sComp->nextLo == sComp) // or lower
&& (jComp->nextHi->nextLo == jComp) ) ) ) // (sComp has no "lower end" nbr, jComp has one each way)
{
// printf("Adding leaf %2ld (%p) to leaf queue\n", leafQSize, otherEnd);
leafQueue[leafQSize++] = otherEnd; // so add it already
}
} // C. i.
else // i.e. a lower leaf
{ // C. ii.
// a. add to contour tree
otherEnd = sComp->hiEnd; // grab a pointer to the other end
if (sComp->seedFrom == NULL) // if there wasn't a seed stored on the edge
newSuperarc = AddSuperarc(otherEnd, theVertex, otherEnd, FindDescendingNeighbour(otherEnd), NULL, NULL);
else
newSuperarc = AddSuperarc(otherEnd, theVertex, sComp->seedFrom, sComp->seedTo, NULL, NULL);
// add the superarc to the contour tree
// if (newSuperarc == 175)
// ContourTreeToDotFile("building", dotFileNo++);
// now compute the sum of the nodes this side of the top end: initial -1 excludes the vertex proper
superarcs[newSuperarc].nodesThisSideOfTop = superarcs[newSuperarc].nodesThisSideOfBottom = nVertices - 1;
superarcs[newSuperarc].sampleSumBottom = sampleSum - *theVertex;
// printf("Bot: %8.5f\n", superarcs[newSuperarc].sampleSumBottom);
for (upArc = superarcs[newSuperarc].nextUp; upArc != newSuperarc; upArc = superarcs[upArc].nextUp)
{ // other uparcs exist
// printf("Up arc %d\n", upArc);
superarcs[newSuperarc].nodesThisSideOfBottom -= superarcs[upArc].nodesThisSideOfBottom;
superarcs[newSuperarc].sampleSumBottom -= superarcs[upArc].sampleSumBottom;
// printf("Bot: %8.5f \n", superarcs[newSuperarc].sampleSumBottom);
} // other uparcs exist
// down arcs: first we have to check if any exist
downArc = supernodes[superarcs[newSuperarc].bottomID].downList;
if (downArc != NO_SUPERARC)
{ // there are downarcs
do
{ // walk around them
superarcs[newSuperarc].nodesThisSideOfBottom -= superarcs[downArc].nodesThisSideOfTop;
superarcs[newSuperarc].sampleSumBottom -= superarcs[downArc].sampleSumTop;
// printf("Bot: %8.5f\n ", superarcs[newSuperarc].sampleSumBottom);
downArc = superarcs[downArc].nextDown;
} // walk around them
while (downArc != supernodes[superarcs[newSuperarc].bottomID].downList);
} // there are downarcs
// printf("On: %8.5f\n", superarcs[newSuperarc].sampleSumOnArc);
visitFlags(x, y, z) = 0; // set flag for the vertex to mark "visited"
for (float *nextNode = splitArcs(x, y, z); nextNode != otherEnd; nextNode = splitArcs(xNext, yNext, zNext))
{ // nextNode // walk along split arcs to transfer nodes
height.ComputeIndex(nextNode, xNext, yNext, zNext); // find the x, y, z indices
// printf("Walking past (%1d, %1d, %1d): %8.5f\n", xNext, yNext, zNext, *nextNode);
if (visitFlags(xNext, yNext, zNext)) // 1 => vertex is not yet on a superarc
{ // first time this vertex has been processed
// printf(": counting.");
visitFlags(xNext, yNext, zNext) = 0; // set to 0 to mark that its used, and reset flags for rendering
height.ComputeIndex(nextNode, xNext, yNext, zNext); // find the x, y, z indices
superarcs[newSuperarc].nodesOnArc++; // increment the superarcs node count
superarcs[newSuperarc].sampleSumOnArc += height(xNext, yNext, zNext);
// printf("On: %8.5f\n", superarcs[newSuperarc].sampleSumOnArc);
} // first time this vertex has been processed
// printf("\n");
} // nextNode
// compute the count of nodes this side of the top
superarcs[newSuperarc].nodesThisSideOfTop = superarcs[newSuperarc].nodesOnArc + (nVertices - superarcs[newSuperarc].nodesThisSideOfBottom);
superarcs[newSuperarc].sampleSumTop = sampleSum - superarcs[newSuperarc].sampleSumBottom + superarcs[newSuperarc].sampleSumOnArc;
// printf("Top: %8.5f\n", superarcs[newSuperarc].sampleSumTop);
// b. delete from split tree
// note that otherEnd is degree 2 or higher (i.e. it is guaranteed to have a up arc, even for last edge, because of existence of -infinity)
if (sComp->nextHi->loEnd == otherEnd) // if the next edge at high end is upwards
sComp->nextHi->lastLo = sComp->lastHi; // reset its lastLo pointer
else sComp->nextHi->lastHi = sComp->lastHi; // otherwise reset the lastHi pointer
if (sComp->lastHi->loEnd == otherEnd) // if the last edge at high end is upwards
sComp->lastHi->nextLo = sComp->nextHi; // reset its nextLo pointer
else sComp->lastHi->nextHi = sComp->nextHi; // otherwise reset the nextHi pointer
delete sComp; // get rid of the sComp edge
splitComponent(x, y, z) = NULL; // get rid of it in the sComponent array as well
nSplitSupernodes--;
// c. delete from join tree
// since we have -infinity, there will always be an up and a down arc
// this is true even for the last edge, since we start at a lower leaf L. This means that there is an up-arc to the other remaining node, U.
// and since jComp is the departing edge travelling downwards, LU must be upwards in the split tree.
// all we do is collapse jComp & jComp->nextHi onto jComp->nextHi
if (jComp->nextLo == jComp) // i.e. jComp leads to -inf
jComp->nextHi->nextLo = jComp->nextHi->lastLo =jComp->nextHi; // set the lower arcs to itself (i.e. no higher neighbours)
else // not an edge to -inf
{ // not edge to -inf
jComp->nextHi->nextLo = jComp->nextLo; // set the upper arcs
jComp->nextHi->lastLo = jComp->lastLo;
} // not edge to -inf
jComp->nextHi->loEnd = jComp->loEnd; // transfer the low end
jComp->nextHi->seedFrom = jComp->seedFrom; // transfer the seed
jComp->nextHi->seedTo = jComp->seedTo; // transfer the seed
if (jComp->nextLo->hiEnd == jComp->loEnd) // if nextLo is a down-arc
jComp->nextLo->lastHi = jComp->nextHi; // adjust the high end
else jComp->nextLo->lastLo = jComp->nextHi; // otherwise the low end
if (jComp->lastLo->hiEnd == jComp->loEnd) // if lastLo is a down-arc
jComp->lastLo->nextHi = jComp->nextHi; // adjust the high end
else jComp->lastLo->nextLo = jComp->nextHi; // otherwise the low end
delete jComp; // delete the now-useless edge
joinComponent(x, y, z) = NULL; // get rid of it in the jComponent array as well
nJoinSupernodes--;
// d. test other end to see if it should be added to leaf queue
// we have reduced the up-degree of otherEnd in the join tree, and haven't changed the degrees in the split tree
height.ComputeIndex(otherEnd, x, y, z); // compute indices
sComp = splitComponent(x, y, z); // retrieve the split component
jComp = joinComponent(x, y, z); // and the join component
if ( ( (jComp->nextHi == jComp) // two ways otherEnd can be a leaf: upper
&& (sComp->nextLo->nextHi == sComp) ) // (jComp has no "higher end" nbr, sComp has one each way)
|| ( ( (sComp->nextLo == sComp) // or lower
&& (jComp->nextHi->nextLo == jComp) ) ) ) // (sComp has no "lower end" nbr, jComp has one each way)
{
// printf("Adding leaf %2ld (%p) to leaf queue\n", leafQSize, otherEnd);
leafQueue[leafQSize++] = otherEnd; // so add it already
}
} // C. ii.
} // C.
// (x, y, z) i now set for the last of the "other ends", so set the visitFlag to 0
visitFlags(x, y, z) = 0;
// D. Clean up excess memory, &c.
// start off by getting rid of the two remaining edges in the join and split tree
nodeLookup.Construct(0,0,0);
// delete joinRoot; // delete the root (remaining arc) in join tree
// CheckContourTree();
// delete splitRoot; // delete the root (remaining arc) in split tree
joinRoot = splitRoot = NULL; // and reset to something predictable
time(&thisTime);
timingBuffer += sprintf(timingBuffer, "Finished merging trees mow.\n");
timingBuffer += sprintf(timingBuffer, "Merging took %8.5f seconds to compute: contour tree has %1d supernodes\n",
//(float)(thisTime.tv_sec - thatTime.tv_sec) + 1E-6 * ((long)thisTime.tv_usec - (long)thatTime.tv_usec), nSupernodes);
(float)difftime(thisTime, thatTime), nSupernodes);
flushTimingBuffer();
//PrintContourTree();
} // end of CombineTrees()
// QueueNeighbour()
void HeightField::QueueNeighbour(long x, long y, long z) // queues up the given neighbour, if it is in the field
{
if (x < 0) return;
if (x >= xDim) return;
if (y < 0) return;
if (y >= yDim) return;
if (z < 0) return;
if (z >= zDim) return;
neighbourQueue[nNeighbours][0] = x;
neighbourQueue[nNeighbours][1] = y;
neighbourQueue[nNeighbours][2] = z;
nNeighbours++;
} // end of QueueNeighbour()
// QueueJoinNeighbours()
void HeightField::QueueJoinNeighbours(long x, long y, long z) // queues up all neighbours in join sweep
{
nNeighbours = 0; // reset the size of the queue
QueueNeighbour(x-1, y, z); QueueNeighbour(x+1, y, z); // corner adjacencies: x-axis
QueueNeighbour(x, y-1, z); QueueNeighbour(x, y+1, z); // y-axis
QueueNeighbour(x, y, z-1); QueueNeighbour(x, y, z+1); // z-axis
} // end of QueueJoinNeighbours()
// QueueSplitNeighbours()
void HeightField::QueueSplitNeighbours(long x, long y, long z) // queues up all neighbours in join sweep
{
nNeighbours = 0; // reset the size of the queue
QueueNeighbour(x-1, y, z); QueueNeighbour(x+1, y, z); // corner adjacencies: x-axis
QueueNeighbour(x, y-1, z); QueueNeighbour(x, y+1, z); // y-axis
QueueNeighbour(x, y, z-1); QueueNeighbour(x, y, z+1); // z-axis
QueueNeighbour(x-1, y-1, z); QueueNeighbour(x+1, y+1, z); // face adjacencies: xy
QueueNeighbour(x+1, y-1, z); QueueNeighbour(x-1, y+1, z); // face adjacencies: xy
QueueNeighbour(x, y-1, z-1); QueueNeighbour(x, y+1, z+1); // yz
QueueNeighbour(x, y+1, z-1); QueueNeighbour(x, y-1, z+1); // yz
QueueNeighbour(x-1, y, z-1); QueueNeighbour(x+1, y, z+1); // xz
QueueNeighbour(x-1, y, z+1); QueueNeighbour(x+1, y, z-1); // xz
} // end of QueueSplitNeighbours()
long HeightField::AddSuperarc(float *hiEnd, float *loEnd, float *seedHiFrom, float *seedHiTo, float *seedLoFrom, float *seedLoTo)
{ // AddSuperarc() // adds a superarc to the contour tree
// find the top and bottom supernodes
// printf("Adding ");
long theTopNode = GetSupernode(hiEnd); // retrieve the supernode at the top end
// printf(" to ");
long theBottomNode = GetSupernode(loEnd); // retrieve the supernode at the bottom end
// printf("\n");
return AddSuperarc(theTopNode, theBottomNode, seedHiFrom, seedHiTo, seedLoFrom, seedLoTo);
} // end of AddSuperarc()
long HeightField::AddSuperarc(long topID, long bottomID, float *seedHiFrom, float *seedHiTo, float *seedLoFrom, float *seedLoTo)
{ // AddSuperarc() // adds a superarc to the contour tree
// create the new superarc
long newSuperarc = nextSuperarc++;
superarcs[newSuperarc].Initialize(topID, bottomID); // initialize the new superarc
superarcs[newSuperarc].SetHighSeed(seedHiFrom, seedHiTo); // and set the seeds
superarcs[newSuperarc].SetLowSeed(seedLoFrom, seedLoTo); // and set the seeds
// now add the arcs to the nodes at each end
AddDownArc(topID, newSuperarc); // insert at top end
AddUpArc(bottomID, newSuperarc); // and at bottom end
// and set the valid flag
AddToValid(newSuperarc);
// before returning
return newSuperarc;
} // end of AddSuperarc()
long HeightField::GetSupernode(float *theVertex) // get supernode for a vertex, creating it if necessary
{ // GetSupernode()
long x, y, z;
height.ComputeIndex(theVertex, x, y, z); // compute its indices
// printf("(%1d,%1d,%1d)/%8.5f", x, y, z, *theVertex);
long theNode = nodeLookup(x, y, z); // lookup the node
if (theNode != NO_SUPERNODE) return theNode; // return in the easy case
// if there isn't one already, make one
supernodes[nextSupernode].Initialize(theVertex); // initialize the next one
nodeLookup(x, y, z) = nextSupernode; // set it in the lookup table
AddToValidNodes(nextSupernode);
return nextSupernode++; // increment & return the ID
} // GetSupernode()
void HeightField::AddDownArc(long theNode, long theArc) // add a down arc at a given node
{ // AddDownArc()
long topOfList = supernodes[theNode].downList; // grab the top of the list
if (topOfList == NO_SUPERARC) // if there are no down arcs
{ // first down arc
superarcs[theArc].nextDown = superarcs[theArc].lastDown = theArc; // make it point to itself
supernodes[theNode].downList = theArc; // and set the list up
} // first down arc
else
{ // subsequent down arc
long oldLast = superarcs[topOfList].lastDown; // grab the old "last" arc
superarcs[theArc].lastDown = oldLast; // point this one at it
superarcs[oldLast].nextDown = theArc; // and vice versa
superarcs[topOfList].lastDown = theArc; // do the same for the top of the list
superarcs[theArc].nextDown = topOfList;
} // subsequent down arc
supernodes[theNode].downDegree++; // increment the down-degree
} // AddDownArc()
void HeightField::AddUpArc(long theNode, long theArc) // add an up arc at a given node
{ // AddUpArc()
long topOfList = supernodes[theNode].upList; // grab the top of the list
if (topOfList == NO_SUPERARC) // if there are no up arcs
{ // first up arc
superarcs[theArc].nextUp = superarcs[theArc].lastUp = theArc; // make it point to itself
supernodes[theNode].upList = theArc; // and set the list up
} // first up arc
else
{ // subsequent up arc
long oldLast = superarcs[topOfList].lastUp; // grab the old "last" arc
superarcs[theArc].lastUp = oldLast; // point this one at it
superarcs[oldLast].nextUp = theArc; // and vice versa
superarcs[topOfList].lastUp = theArc; // do the same for the top of the list
superarcs[theArc].nextUp = topOfList;
} // subsequent up arc
supernodes[theNode].upDegree++; // increment the up-degree
} // AddUpArc()
// routine to find seeds for edges that do not otherwise have them
float *HeightField::FindDescendingNeighbour(float *theVertex)
{ // FindDescendingNeighbour()
long x, y, z;
height.ComputeIndex(theVertex, x, y, z); // retrieve the indices
QueueSplitNeighbours(x, y, z); // queue up its neighbours in join order
for (int i = 0; i < nNeighbours; i++) // walk along queue
{ // for i
float *neighbour = &(height(neighbourQueue[i][0], neighbourQueue[i][1], neighbourQueue[i][2]));
if (compareHeight(neighbour, theVertex) < 0) // if the neighbour is smaller than the vertex
return neighbour; // it will make a valid seed
} // for i
printf("Major error at %s:%d: couldn't find descending neighbour.\n", __FILE__, __LINE__);
return NULL;
} // FindDescendingNeighbour()
// loads a file from ASCII text
void HeightField::LoadFromASCII(char *fileName)
{ // LoadFromASCII()
ifstream fin(fileName);
if (!fin.is_open()) { printf("Unable to open file %s\n", fileName); throw 0; }
sampleSize = 0; // set to something predictable
long i, j, k; // loop indices for general use
// A. copy the parameters into the object
fin >> xDim >> yDim >> zDim; // read in the dimensions
xDim += 2;
// B. set nVertices
nVertices = xDim * yDim * zDim;
// printf("vertices: %d (%d %d %d)\n",nVertices,xDim, yDim, zDim);
// C. allocate leafQueue to a default size, and set leafQSize
leafQueue = NULL; // allocate space on leaf queue
leafQSize = 0; // set logical size to zero
// D. allocate height, heightSort, and visitFlags
height.Construct(xDim, yDim, zDim); // call function to initialize the height array
heightSort = (float **)malloc(sizeof(float *) * nVertices); // allocate the array
visitFlags.Construct(xDim, yDim, zDim); // call template function to set up array
// E. read in the data, setting pointers in heightSort, and finding maxHeight and minHeight in the process
float **heightWalk = heightSort; // used to walk through heightSort: start at front of heightSort
maxHeight = -HUGE_VAL; minHeight = HUGE_VAL;
//minHeight = maxHeight = height(0, 0, 0); // initialize min, max heights to first element in array
for (i = 0; i < xDim; i++) // walk through each dimension
{ // E i
// printf("."); fflush(stdout);
for (j = 0; j < yDim; j++)
for (k = 0; k < zDim; k++)
{ // E ijk
float nextHeight; // temporary variable for reading in from array
if (i == 0 || i == 2) nextHeight = 0;
else
fin >> nextHeight; // read it in
height(i, j, k) = nextHeight; // store it in the array
sampleSum += nextHeight; // add to the running sum
*heightWalk = &(height(i, j, k)); // copy a pointer into sorting array
if (nextHeight > maxHeight) maxHeight = nextHeight; // update maxHeight
if (nextHeight < minHeight) minHeight = nextHeight; // update minHeight
heightWalk++; // step to next pointer in sorting array
} // E ijk: end of loop through i, j, k
} // E i
plus_infinity = HUGE_VAL; // set plus infinity in case we ever compare against it
minus_infinity = -HUGE_VAL; // and minus infinity
joinRoot = splitRoot = NULL; // set these to something predictable
// set nextAvailableComponent equal to componentBlockSize to force allocation on first call
// componentBlockSize = 1024;
// nextAvailableComponent = 1024;
#ifdef DEBUG_CONSTRUCTOR
// PrintField();
#endif
time(&lastTime);
timingBuffer += sprintf(timingBuffer, "Input size (n): %1ld x %1ld x %1ld = %1ld\n", xDim, yDim, zDim, nVertices);
// timingBuffer += sprintf(timingBuffer, "Reading data complete at: %ld:%ld\n", (lastTime.tv_sec) % 1000, lastTime.tv_usec);
//timingBuffer += sprintf(timingBuffer, "Reading data took %8.5f seconds\n", (float)(lastTime.tv_sec - startTime.tv_sec) + 1E-6 * (lastTime.tv_usec - startTime.tv_usec));
timingBuffer += sprintf(timingBuffer, "Reading data took %8.5f seconds\n", difftime(lastTime,startTime));
// timingBuffer += sprintf(timingBuffer, "Sorting data.\n");
flushTimingBuffer();
qsort(heightSort, nVertices, sizeof(float *), compareHeightVoid);
#ifdef DEBUG_CONSTRUCTOR
PrintSortOrder();
#endif
time(&thisTime);
// timingBuffer += sprintf(timingBuffer, "Sorting data complete at: %ld:%ld\n", thisTime.tv_sec % 1000, thisTime.tv_usec);
//timingBuffer += sprintf(timingBuffer, "Sorting data took %8.5f seconds\n", (float)(thisTime.tv_sec - lastTime.tv_sec) + 1E-6 * (thisTime.tv_usec - lastTime.tv_usec));
timingBuffer += sprintf(timingBuffer, "Sorting data took %8.5f seconds\n", difftime(thisTime, lastTime));
flushTimingBuffer();
} // LoadFromASCII()
// LoadFromRaw
void HeightField::LoadFromRaw(FILE *inFile)
{ // LoadFromRaw()
long index; // loop index
if (sampleSize < 1) { printf("Sample sizes less than 1 don't make sense.\n"); throw 0;}
if (sampleSize > 2) { printf("Sample sizes greater than 2 not yet implemented.\n"); throw 0;}
// B. set nVertices
nVertices = xDim * yDim * zDim;
// C. allocate leafQueue to a default size, and set leafQSize
leafQueue = NULL; // allocate space on leaf queue
leafQSize = 0; // set logical size to zero
// D. allocate height, heightSort, and visitFlags
heightSort = (float **)malloc(sizeof(float *) * nVertices); // allocate the array
visitFlags.Construct(xDim, yDim, zDim); // call template function to set up array
// E. read in the data, setting pointers in heightSort, and finding maxHeight and minHeight in the process
maxHeight = -HUGE_VAL; minHeight = HUGE_VAL;
// allocate memory
float *floatData = (float *) malloc(sizeof(float) * nVertices); // allocate the memory for the float representation
unsigned char *rawData = (unsigned char *) malloc(sizeof (unsigned char) * sampleSize * nVertices);
long nSamplesRead = fread(rawData, sizeof(unsigned char), nVertices, inFile); // read in the block of data
if (nSamplesRead != nVertices) { printf("Binary read of input file failed.\n"); throw 0; }
time(&lastTime);
timingBuffer += sprintf(timingBuffer, "Input size (n): %1ld x %1ld x %1ld = %1ld\n", xDim, yDim, zDim, nVertices);
//timingBuffer += sprintf(timingBuffer, "Reading data took %8.5f seconds\n", (float)(lastTime.tv_sec - startTime.tv_sec) + 1E-6 * (lastTime.tv_usec - startTime.tv_usec));
timingBuffer += sprintf(timingBuffer, "Reading data took %8.5f seconds\n", (float)difftime(lastTime, startTime));
flushTimingBuffer();
// set up radix sort bins
long nBins = (sampleSize == 1) ? 256 : 65536L;
long *firstInBin = new long[nBins];
for (int i = 0; i < nBins;i++) firstInBin[i] = -1; // initialize to "NONE"
long *nextInBin = (long *) malloc(nVertices * sizeof(long)); // and initialize the "next" array
for (int i = 0; i < nVertices; i++) nextInBin[i] = -1;
if (sampleSize == 1)
for (index = 0; index < nVertices; index++) // walk through the data
{ // walk through data
nextInBin[index] = firstInBin[rawData[index]]; // push into linked list at front of sorting bin
firstInBin[rawData[index]] = index; // and reset the front of the bin
floatData[index] = (float) rawData[index]; // copy into the float array
sampleSum += rawData[index]; // add to the running sum
} // walk through data
else
{ // 2-byte data
unsigned short *rawShort = (unsigned short * ) rawData;
for (index = 0; index < nVertices; index++) // walk through the data
{ // walk through data
unsigned short newShort = rawShort[index];
#ifdef ENDIAN_SWAP_SHORTS
newShort = (newShort >> 8) | ((newShort & 0x00FF) << 8);
#endif
nextInBin[index] = firstInBin[newShort]; // push into linked list at front of sorting bin
firstInBin[newShort] = index; // and reset the front of the bin
floatData[index] = (float) newShort; // copy into the float array
sampleSum += newShort; // add to the running sum
} // walk through data
} // 2-byte data
// we have now loaded up the float array, and need to setup heightSort properly
// our bin sort has now pushed the elements into bins IN REVERSE ORDER, so we have to
// flip again in reading them out
int bin = nBins; // which bin we are reading from
long nextSample = -1; // which sample comes next
for (index = nVertices-1; index >= 0; index--)
{ // filling in heightSort
while (nextSample == -1) // this bin is empty
nextSample = firstInBin[--bin]; // grab the first item in the next bin
heightSort[index] = floatData+nextSample; // generate & store the pointer
nextSample = nextInBin[nextSample]; // grab the next item
} // filling in heightSort
delete []firstInBin;
height.Construct(xDim, yDim, zDim, floatData); // call function to initialize the height array
plus_infinity = HUGE_VAL; // set plus infinity in case we ever compare against it
minus_infinity = -HUGE_VAL; // and minus infinity
joinRoot = splitRoot = NULL; // set these to something predictable
maxHeight = *(heightSort[nVertices-1]); minHeight = *(heightSort[0]); // set min. and max. height
// PrintSortOrder();
free (nextInBin); free(rawData); // release the working memory
time(&thisTime);
//timingBuffer += sprintf(timingBuffer, "Sorting data took %8.5f seconds\n", (float)(thisTime.tv_sec - lastTime.tv_sec) + 1E-6 * (thisTime.tv_usec - lastTime.tv_usec));
timingBuffer += sprintf(timingBuffer, "Sorting data took %8.5f seconds\n", difftime(thisTime, lastTime));
} // LoadFromRaw()
// LoadFromNifti
/*void HeightField::LoadFromNifti(char *fileName)
{ // LoadFromNifti()
RicVolume vol(fileName);
if (vol.nvox == 0) { printf("Unable to open file %s\n", fileName); throw 0; }
sampleSize = 0; // set to something predictable
long i, j, k; // loop indices for general use
// A. copy the parameters into the object
zDim = vol.get_numz();
yDim = vol.get_numy();
xDim = vol.get_numx(); // read in the dimensions
// B. set nVertices
nVertices = xDim * yDim * zDim;
// C. allocate leafQueue to a default size, and set leafQSize
leafQueue = NULL; // allocate space on leaf queue
leafQSize = 0; // set logical size to zero
// D. allocate height, heightSort, and visitFlags
height.Construct(xDim, yDim, zDim); // call function to initialize the height array
heightSort = (float **)malloc(sizeof(float *) * nVertices); // allocate the array
visitFlags.Construct(xDim, yDim, zDim); // call template function to set up array
// E. read in the data, setting pointers in heightSort, and finding maxHeight and minHeight in the process
float **heightWalk = heightSort; // used to walk through heightSort: start at front of heightSort
maxHeight = -HUGE_VAL; minHeight = HUGE_VAL;
//minHeight = maxHeight = height(0, 0, 0); // initialize min, max heights to first element in array
for (i = 0; i < xDim; i++) // walk through each dimension
{ // E i
// printf("."); fflush(stdout);
for (j = 0; j < yDim; j++)
for (k = 0; k < zDim; k++)
{ // E ijk
float nextHeight = vol.vox[i][j][k]; // temporary variable for reading in from array
height(i, j, k) = nextHeight; // store it in the array
sampleSum += nextHeight; // add to the running sum
*heightWalk = &(height(i, j, k)); // copy a pointer into sorting array
if (nextHeight > maxHeight) maxHeight = nextHeight; // update maxHeight
if (nextHeight < minHeight) minHeight = nextHeight; // update minHeight
heightWalk++; // step to next pointer in sorting array
} // E ijk: end of loop through i, j, k
} // E i
plus_infinity = HUGE_VAL; // set plus infinity in case we ever compare against it
minus_infinity = -HUGE_VAL; // and minus infinity
joinRoot = splitRoot = NULL; // set these to something predictable
// set nextAvailableComponent equal to componentBlockSize to force allocation on first call
// componentBlockSize = 1024;
// nextAvailableComponent = 1024;
#ifdef DEBUG_CONSTRUCTOR
// PrintField();
#endif
time(&lastTime);
timingBuffer += sprintf(timingBuffer, "Input size (n): %1ld x %1ld x %1ld = %1ld\n", xDim, yDim, zDim, nVertices);
// timingBuffer += sprintf(timingBuffer, "Reading data complete at: %ld:%ld\n", (lastTime.tv_sec) % 1000, lastTime.tv_usec);
//timingBuffer += sprintf(timingBuffer, "Reading data took %8.5f seconds\n", (float)(lastTime.tv_sec - startTime.tv_sec) + 1E-6 * (lastTime.tv_usec - startTime.tv_usec));
timingBuffer += sprintf(timingBuffer, "Reading data took %8.5f seconds\n", difftime(lastTime, startTime));
// timingBuffer += sprintf(timingBuffer, "Sorting data.\n");
flushTimingBuffer();
qsort(heightSort, nVertices, sizeof(float *), compareHeightVoid);
#ifdef DEBUG_CONSTRUCTOR
PrintSortOrder();
#endif
time(&thisTime);
// timingBuffer += sprintf(timingBuffer, "Sorting data complete at: %ld:%ld\n", thisTime.tv_sec % 1000, thisTime.tv_usec);
//timingBuffer += sprintf(timingBuffer, "Sorting data took %8.5f seconds\n", (float)(thisTime.tv_sec - lastTime.tv_sec) + 1E-6 * (thisTime.tv_usec - lastTime.tv_usec));
timingBuffer += sprintf(timingBuffer, "Sorting data took %8.5f seconds\n", difftime(thisTime, lastTime));
flushTimingBuffer();
} // LoadFromNifti()
*/
void HeightField::SetInitialColours() // sets the initial coloursf
{ // SetInitialColours()
long theArc = collapseRecord[1]; // find the initial arc
long topNode = superarcs[theArc].topID, bottomNode = superarcs[theArc].bottomID; // and it's bounding nodes
// use colour 0 for the base edge
superarcs[theArc].colour = supernodes[topNode].colour = supernodes[bottomNode].colour = 0;
// the rest are taken care of during UnCollapse()
} // SetInitialColours()
|
4c52e7da8fe792f135f4d3928e28a16b6b8eba6e
|
a7914b450aeae015a24ba90e5ce60d41d5c592a9
|
/SummerTraining/课上小练/冒泡排序.cpp
|
247faf3f95387fb789605de9f8098667346a6f56
|
[] |
no_license
|
packbacker-s/CCode
|
07eb157e0be7eade9d72807a508f4a9dee6eed90
|
4a2ac77352989f38c372671ac4e562aea7a25d96
|
refs/heads/master
| 2023-08-11T07:20:49.297388
| 2021-10-01T08:51:53
| 2021-10-01T08:51:53
| 412,320,148
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 635
|
cpp
|
冒泡排序.cpp
|
#include <cstdio>
long long q_pow(long long a, long long b, long long mod) {
long long sum = 1;
int n = 0;
while (b) {
if (b & 1)
sum = sum * a % mod;
a = a * a % mod;
b >>= 1;
n++;
}
printf("%d\n", n);
return sum;
}
int main(){
int i,j,k;
// int n;
// for(i=0;i<10;i++)
// scanf("%d",&n);
long long s = 1000000000 / 3600 / 24;
int a = 99999999, b = 9999999;
int c = a * b;
printf("%d\n", c);
c %= 100000000;
printf("%lld\n", s);
int n = 106, m = 106;
// long long a = 2, b = 1000000000000000000, c = 1000000009;
// a = q_pow(a, b, c);
printf("%lld\n", a);
return 0;
}
|
bc01b45994edccbd2ea4e8bc121e78145e3ad546
|
6c247c545e4bedb38c6ccdbbceffe1210f3b241d
|
/DynamicStringVector.cpp
|
28ee293881997df47027555c66b15920666028a5
|
[] |
no_license
|
AzizOKAY/simple-CPU-with-OOP-and-Dynamic-memory-in-c-
|
1fb76c3f552f5bbe231ac14d0d2429f6879ea935
|
2362ab70d6a6f88f85540f5baa507eaac9a11d3b
|
refs/heads/master
| 2021-01-09T06:12:05.315310
| 2017-02-04T14:08:44
| 2017-02-04T14:08:44
| 80,922,892
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,830
|
cpp
|
DynamicStringVector.cpp
|
/*
* File: DynamicStringVector.cpp
* Author: Aziz OKAY
*
* Created on December 1, 2016, 3:25 PM
*/
#include <iostream>
#include "GPUString.h"
#include "GPUStringVector.h"
using namespace std;
/*
GPUStringVector::~GPUStringVector() {
delete [] allLine;
}*/
int GPUStringVector::push_back(const GPUString &obj) {
if(getSize() >= getCapacity()) {
GPUString *temp = (GPUString*)new GPUString[getSize()];
for(int i = 0; i < getSize(); i++)
temp[i] = allLine[i];
delete [] allLine;
capacity = getCapacity() + 10;
size++;
allLine = (GPUString*)new GPUString[getCapacity()];
for(int i = 0; i < getSize()-1; i++)
allLine[i] = temp[i];
allLine[size-1] = obj;
delete [] temp;
}else {
allLine[size] = obj;
size++;
}
return 1;
}
int GPUStringVector::pop_back() {
delete [] &allLine[getSize() - 1];
size--;
return 1;
}
GPUString& GPUStringVector::operator[](const int index) {
if(index < getSize())
return allLine[index];
else {
cerr << "Out of size." << endl;
return allLine[getSize()-1];
}
}
GPUStringVector& GPUStringVector::operator =(const GPUStringVector& other) {
if(getSize() != 0)
delete [] allLine;
setSize(other.getSize());
capacity = other.getCapacity();
allLine = (GPUString*)new GPUString[getCapacity()];
for(int i = 0; i < other.getSize(); i++)
allLine[i] = other.getAllLine()[i];
return *this;
}
void GPUStringVector::print() {
for(int i = 0; i < getSize(); i++)
cout << allLine[i] << endl;
}
ostream& operator << (ostream& out, GPUStringVector& other) {
for (int i = 0 ; i < other.getSize() ; i++)
out << other.getAllLine()[i];
return out;
}
|
18747774dfb7d5e6bd5487e7a131fcfe19ad8f9c
|
6dfb80e0fb037a6dbe46f5cdca863afa552de363
|
/d3.cpp
|
c5e08b4e7ceda6b6138c1272f5007b79d05cc0ed
|
[] |
no_license
|
macharlavaibhavi/Apriori_Implementation
|
7ae92090625c46b17242602bf1199a9a13978935
|
74a0dffbf617aba9abcb357d709fd1e10a0132be
|
refs/heads/master
| 2020-03-27T09:47:53.089772
| 2018-08-28T01:29:07
| 2018-08-28T01:29:07
| 146,373,252
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,779
|
cpp
|
d3.cpp
|
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define structure map<vector<int> ,int>
#define for_map(ii,T) for(structure::iterator(ii)=(T).begin();(ii)!=(T).end();ii++)
#define for_next(jj,ii,T) for(structure::iterator(jj)=ii;(jj)!=T.end();jj++)
#define Vec vector<int>
const int min_sup=2;
structure c;
structure l;
void c1();
void l1();
void generate_C();
void generate_L();
void output(structure );
void prune();
void scan();
void set_count(Vec );
bool check(Vec,Vec);
int main()
{
c.clear();
l.clear();
bool mv=true;
int index=2;
while(true)
{
if(mv)
{
c1();
cout<<"C1\n";
output(c);
l1();
cout<<"L1\n";
output(l);
mv=!mv;
}
else
{
generate_C();
if(c.size()==0)
break;
cout<<"\nC"<<index<<"\n";
output(c);
prune();
if(c.size()==0)
break;
cout<<"\n C"<<index<<"after prune\n";
output(c);
scan();
cout<<"\nC"<<index<<"after scanning the datafrom file\n";
output(c);
generate_L();
if(l.size()==0)
break;
cout<<"\nL"<<index<<"\n";
output(l);
index++;
}
}
return 0;
}
void c1()
{
ifstream f2("file1.txt");
if(!f2)
{
cout<<"file does not exit\n";
return;
}
char str[255];
map<int,vector<int> >m;
m.clear();
int n;
while(f2)
{
f2.getline(str,255);
n=sizeof(str)/sizeof(str[0]);
if(f2)
{
int j=0,i=0;
while(str[i]!='-')
{
j=j*10+(str[i]-'0');
i++;
}
i=i+2;
while(i<n)
{
int k=0;
while(str[i]!=','&& str[i]!='/')
{
k=k*10+(str[i]-'0');
i++;
}
m[j].push_back(k);
i++;
if(str[i]=='/')
break;
}
}
}
f2.close();
Vec v;
map<int,vector<int> >::iterator itr;
for(itr=m.begin();itr!=m.end();itr++)
{
int l=itr->second.size();
for(int i=0;i<l;i++)
{ v.clear();
v.push_back(itr->second[i]);
if(c.count(v)>0)
c[v]++;
else
c[v]=1;
}
}
}
void output(structure T)
{
cout<<"\n";
Vec v;
cout<<"itemset\t\tfrequency\n";
for_map(ii,T)
{
v.clear();
v=ii->first;
int i;
for( i=0;i<v.size()-1;i++)
{
cout<<v[i]<<",";
}
cout<<v[i]<<"\t\t";
cout<<ii->second;
cout<<"\n";
}
}
void l1()
{
for_map(ii,c)
{
if(ii->second>=min_sup)
{
l[ii->first]=ii->second;
}
}
}
void generate_C()
{
c.clear();
for_map(ii,l)
{
for_next(jj,ii,l)
{
if(jj==ii)
continue;
Vec a,b;
a.clear();
b.clear();
a=ii->first;
b=jj->first;
if(check(a,b))
{
a.push_back(b.back());
sort(a.begin(),a.end());
c[a]=0;
}
}
}
}
bool check(Vec a,Vec b)
{
bool compare=true;
for(int i=0;i<a.size()-1;i++)
{
if(a[i]!=b[i])
{
compare=false;
break;
}
}
return compare;
}
void prune()
{
Vec a,b;
for_map(ii,c)
{
a.clear();
b.clear();
a=ii->first;
for(int i=0;i<a.size();i++)
{
b.clear();
for(int j=0;j<a.size();++j)
{
if(j==i)
continue;
b.push_back(a[j]);
}
if(l.find(b)==l.end())
{
ii->second=-1;
break;
}
}
}
structure temp;
temp.clear();
for_map(ii,c)
{
if(ii->second!=-1)
{
temp[ii->first]=ii->second;
}
}
c.clear();
c=temp;
temp.clear();
}
void scan()
{
ifstream f2("file1.txt");
if(!f2)
{
cout<<"file does not exit\n";
return;
}
char str[255];
map<int,vector<int> >m;
m.clear();
int n;
while(f2)
{
f2.getline(str,255);
n=sizeof(str)/sizeof(str[0]);
if(f2)
{
int j=0,i=0;
while(str[i]!='-')
{
j=j*10+(str[i]-'0');
i++;
}
i=i+2;
while(i<n)
{
int k=0;
while(str[i]!=','&& str[i]!='/')
{
k=k*10+(str[i]-'0');
i++;
}
m[j].push_back(k);
i++;
if(str[i]=='/')
break;
}
}
}
f2.close();
Vec a;
map<int,vector<int> >::iterator itr;
for(itr=m.begin();itr!=m.end();itr++)
{
a=itr->second;
set_count(a);
a.clear();
}
}
void set_count(Vec a)
{
for_map(ii,c)
{
Vec b;
b.clear();
b=ii->first;
int true_count=0;
if(b.size()<=a.size())
{
for(int i=0;i<b.size();i++)
{
for(int j=0;j<a.size();j++)
{
if(b[j]==a[j])
{
true_count++;
break;
}
}
}
}
if(true_count==b.size())
{
ii->second++;
}
}
}
void generate_L()
{
l.clear();
for_map(ii,c)
{
if(ii->second>=min_sup)
{
l[ii->first]=ii->second;
}
}
}
|
b16b15be5d3db55664e9ddecfd122d2f8fe3e4a9
|
dce4a52986ddccea91fbf937bd89e0ae00b9d046
|
/jni-build/jni-build/jni/include/tensorflow/core/framework/reader_op_kernel.cc
|
44df86b479c26c9b78dda11c552918651ed1f1cd
|
[
"MIT"
] |
permissive
|
Lab603/PicEncyclopedias
|
54a641b106b7bb2d2f71b2dacef1e5dbeaf773a6
|
6d39eeb66c63a6f0f7895befc588c9eb1dd105f9
|
refs/heads/master
| 2022-11-11T13:35:32.781340
| 2018-03-15T05:53:07
| 2018-03-15T05:53:07
| 103,941,664
| 6
| 3
|
MIT
| 2022-10-28T05:31:37
| 2017-09-18T13:20:47
|
C++
|
UTF-8
|
C++
| false
| false
| 2,071
|
cc
|
reader_op_kernel.cc
|
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/core/framework/reader_op_kernel.h"
namespace tensorflow {
ReaderOpKernel::ReaderOpKernel(OpKernelConstruction* context)
: OpKernel(context), have_handle_(false) {
OP_REQUIRES_OK(context, context->allocate_persistent(
tensorflow::DT_STRING,
tensorflow::TensorShape({2}), &handle_, nullptr));
}
ReaderOpKernel::~ReaderOpKernel() {
if (have_handle_ && cinfo_.resource_is_private_to_kernel()) {
TF_CHECK_OK(cinfo_.resource_manager()->Delete<ReaderInterface>(
cinfo_.container(), cinfo_.name()));
}
}
void ReaderOpKernel::Compute(OpKernelContext* ctx) {
mutex_lock l(mu_);
if (!have_handle_) {
OP_REQUIRES_OK(ctx, cinfo_.Init(ctx->resource_manager(), def(), false));
ReaderInterface* reader;
OP_REQUIRES_OK(ctx,
cinfo_.resource_manager()->LookupOrCreate<ReaderInterface>(
cinfo_.container(), cinfo_.name(), &reader,
[this](ReaderInterface** ret) {
*ret = factory_();
return Status::OK();
}));
reader->Unref();
auto h = handle_.AccessTensor(ctx)->flat<string>();
h(0) = cinfo_.container();
h(1) = cinfo_.name();
have_handle_ = true;
}
ctx->set_output_ref(0, &mu_, handle_.AccessTensor(ctx));
}
} // namespace tensorflow
|
d81d5ee53c461506a4545c5d0ebd35a5cced69ae
|
e0c8be9e85366b49a5b713f847e593f01a9e0f29
|
/D3/samsung SW 6692 다솔이의 월급 상자/samsung SW 6692 다솔이의 월급 상자/main.cpp
|
663ae83be183931a190b2a02625c987140d12e6d
|
[] |
no_license
|
mak3bread/samsung-SW-expertacademy
|
0f85c4c774237a491969e1a360fe70d2ea864b41
|
d80c71fac27c6d72eaa1b2a0753359c15826877c
|
refs/heads/master
| 2022-04-19T13:50:56.446723
| 2020-04-20T13:27:14
| 2020-04-20T13:27:14
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 324
|
cpp
|
main.cpp
|
#include <cstdio>
int main(){
int T;scanf("%d",&T);
for(int t=1;t<=T;t++){
int N;scanf("%d",&N);
double money=0;
for(int i=0;i<N;i++){
double p;int x;
scanf("%lf %d",&p,&x);
money+=p*x;
}
printf("#%d %6lf\n",t,money);
}
return 0;
}
|
c94efcd5bef3beda9fb008da2aec9b94b64d7c04
|
d220641796d2ba46e1b275f09e9713bcce51f906
|
/NG661DesignerSimulator/projets/ap2i_core/include/eventcomponent.h
|
e1ddd968c9ea88f9f4b29686fa3e77c07f900b43
|
[] |
no_license
|
AxelRICHARD/ng661designer
|
c0f98ed76dc77a2dac55d2caa424bba911de4960
|
410b70ab38035e528b7a40ac5e86e5fb0fbc58f7
|
refs/heads/master
| 2021-05-05T14:30:18.103534
| 2018-02-21T16:21:35
| 2018-02-21T16:21:35
| 118,460,308
| 0
| 0
| null | 2018-01-22T13:24:32
| 2018-01-22T13:24:32
| null |
UTF-8
|
C++
| false
| false
| 1,162
|
h
|
eventcomponent.h
|
/*******************************************************************************
* Copyright (c) 2015, 2016 Thales.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
* Contributors:
* Thales Avionics - initial design and implementation
*******************************************************************************/
#ifndef EVENTCOMPONENT_H
#define EVENTCOMPONENT_H
#include <QList>
#include <QHash>
#include <QVariant>
class QScriptEngine;
namespace AP2I
{
class RuntimeEvent;
class StateMachine;
class EventComponent : public QObject
{
Q_OBJECT
public:
explicit EventComponent(QScriptEngine *pScriptEngine);
virtual ~EventComponent();
void addEvent(const QString &pEventName, QVariant pVal);
void clearEvents();
bool event(QEvent *);
private:
bool mInitialized;
bool mClearInProgress;
QHash<QString, QVariant> mEvents;
};
} /* namespace */
#endif // EVENTCOMPONENT_H
|
1b9902336a8c7408a3ec44178f2c8da6cc655dc1
|
28cfaa54142e22845f65a49a431913369692e692
|
/SerialClass.cpp
|
024232cf2c31d3a530c1dd69f60a0a18afa00260
|
[
"Apache-2.0"
] |
permissive
|
sbatykov/servo_robot_module
|
62e0c3aa3e8e572ef6ac79a4048b1b0533b26bbe
|
f6223938b53c4f012aef1512d8fcd4bd35f75701
|
refs/heads/master
| 2021-05-03T16:52:57.285232
| 2016-07-29T07:56:55
| 2016-07-29T07:56:55
| 70,069,648
| 0
| 0
| null | 2016-10-05T14:44:32
| 2016-10-05T14:44:32
| null |
UTF-8
|
C++
| false
| false
| 4,796
|
cpp
|
SerialClass.cpp
|
//#define __STRICT_ANSI__
#define ERROR_VALUE -1
#include "SerialClass.h"
#include "stdio.h"
#include <string>
#include "string.h"
#include <errno.h>
#include "error.h"
Serial::Serial(char *portName) {
// We're not yet connected
this->connected = false;
#ifdef _WIN32
// Try to connect to the given port throuh CreateFile
this->hSerial = CreateFileA(portName, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
// Check if the connection was successfull
if (this->hSerial == INVALID_HANDLE_VALUE) {
// If not success full display an Error
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
// Print Error if neccessary
throw new Error(ConsoleColor(ConsoleColor::red),"Error: Handle was not attached. Reason: %s not available.\n",
portName);
} else {
throw new Error(ConsoleColor(ConsoleColor::red),"Unknown error on com port!");
}
} else {
// If connected we try to set the comm parameters
DCB dcbSerialParams = {0};
// Try to get the current
if (!GetCommState(this->hSerial, &dcbSerialParams)) {
// If impossible, show an error
printf("failed to get current serial parameters!");
} else {
// Define serial connection parameters for the arduino board
dcbSerialParams.BaudRate = CBR_9600;
dcbSerialParams.ByteSize = 8;
dcbSerialParams.StopBits = ONESTOPBIT;
dcbSerialParams.Parity = NOPARITY;
dcbSerialParams.XonLim = 42;
dcbSerialParams.XoffLim = 42;
dcbSerialParams.fAbortOnError = TRUE;
dcbSerialParams.fDtrControl = DTR_CONTROL_HANDSHAKE;
dcbSerialParams.fRtsControl = RTS_CONTROL_HANDSHAKE;
dcbSerialParams.fBinary = TRUE;
dcbSerialParams.fParity = FALSE;
dcbSerialParams.fInX = FALSE;
dcbSerialParams.fOutX = FALSE;
dcbSerialParams.XonChar = (unsigned char) 0x11;
dcbSerialParams.XoffChar = (unsigned char) 0x13;
dcbSerialParams.fErrorChar = FALSE;
dcbSerialParams.fNull = FALSE;
dcbSerialParams.fOutxCtsFlow = FALSE;
dcbSerialParams.fOutxDsrFlow = FALSE;
// Set the parameters and check for their proper application
if (!SetCommState(hSerial, &dcbSerialParams)) {
throw new Error(ConsoleColor(ConsoleColor::red),"Error: Could not set Serial Port parameters");
} else {
// If everything went fine we're connected
this->connected = true;
// Flush any remaining characters in the buffers
PurgeComm(this->hSerial, PURGE_RXCLEAR | PURGE_TXCLEAR);
// We wait 2s as the arduino board will be reseting
Sleep(ARDUINO_WAIT_TIME);
}
}
}
#else
com = open(portName, O_RDWR | O_NOCTTY);
memset(&tty, 0, sizeof tty);
/* Error Handling */
if (tcgetattr(com, &tty) != 0) {
throw new Error(ConsoleColor(ConsoleColor::red),"Error handling %d from tcgetattr: %s\n", errno, strerror(errno));
}
/* Save old tty parameters */
tty_old = tty;
/* Set Baud Rate */
cfsetospeed(&tty, (speed_t)B9600);
/* Setting other Port Stuff */
tty.c_cflag &= ~PARENB; // Make 8n1
tty.c_cflag &= ~CSTOPB;
tty.c_cflag &= ~CSIZE;
tty.c_cflag |= CS8;
tty.c_cflag &= ~CRTSCTS; // no flow control
tty.c_cc[VMIN] = 1; // read doesn't block
tty.c_cc[VTIME] = 5; // 0.5 seconds read timeout
tty.c_cflag |= CREAD | CLOCAL; // turn on READ & ignore ctrl lines
/* Make raw */
cfmakeraw(&tty);
/* Flush Port, then applies attributes */
tcflush(com, TCIFLUSH);
if (tcsetattr(com, TCSANOW, &tty) != 0) {
throw new Error(ConsoleColor(ConsoleColor::red), "Error apply attributes %d from tcsetattr\n", errno);
}
this->connected = true;
#endif
}
Serial::~Serial() {
// Check if we are connected before trying to disconnect
if (this->connected) {
// We're no longer connected
this->connected = false;
#ifdef _WIN32
// Close the serial handler
CloseHandle(this->hSerial);
#else
close(com);
#endif
}
}
bool Serial::WriteData(unsigned char *buffer, unsigned int nbChar) {
#ifdef _WIN32
DWORD bytesSend;
// Try to write the buffer on the Serial port
if (!WriteFile(this->hSerial, (void *)buffer, nbChar, &bytesSend, 0)) {
// In case it don't work get comm error and return false
ClearCommError(this->hSerial, &this->errors, &this->status);
return false;
} else
::Sleep(250); // Sleep 250ms to ensure a good break
FlushFileBuffers(this->hSerial);
PurgeComm(this->hSerial, PURGE_RXCLEAR | PURGE_TXCLEAR);
return true;
#else
if (write(com, buffer, nbChar) == ERROR_VALUE) {
return false;
};
return true;
#endif
}
bool Serial::IsConnected() {
// Simply return the connection status
return this->connected;
}
|
71b187335479582ca1d71f82c009aeadc27bdc4c
|
244b4eb938d3757469c4795dab375558cd915ad7
|
/src/client/main.cpp
|
298ed237ce6a27b5037777d1687658842f6838ed
|
[] |
no_license
|
nao23/ramp-with-rdma
|
b5fef0fdcce33efff29e22ec130df760c761a7b7
|
6e2ca73063466887c97bb21953d6711273ec39b3
|
refs/heads/master
| 2021-01-01T03:46:59.067131
| 2016-12-12T03:36:37
| 2016-12-12T03:36:37
| 58,362,122
| 5
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,146
|
cpp
|
main.cpp
|
#include "spdlog/spdlog.h"
#include "Client.h"
#include "cmdline.h"
int main(int argc, char *argv[]) {
// Create a multithreaded color logger
std::shared_ptr<spdlog::logger> logger = spdlog::stdout_logger_mt("main", true);
// Set global log level to info
spdlog::set_level(spdlog::level::info); // TODO: can be set dynamically
// Create a parser, setup and run
cmdline::parser parser;
parser.add<std::string>("log_level", 'l', "log level", false, "info");
parser.add<std::string>("trx_type", 't', "transaction type", true, "");
parser.add<std::string>("com_type", 'c', "communication type", true, "");
parser.add<int>("write_trx_num", 'w', "num of write transactions", true, 0);
parser.add<int>("read_trx_num", 'r', "num of read transactions", true, 0);
parser.add<int>("data_num", 'n', "num of data", false, 1000);
parser.add<int>("trx_size", 's', "transaction size (operations)", false, 8);
parser.add<int>("value_size", 'v', "value size (bytes)", false, 1000);
parser.parse_check(argc, argv);
// Set global log level
std::string log_level = parser.get<std::string>("log_level");
if (log_level == "info") {
spdlog::set_level(spdlog::level::info);
} else if (log_level == "debug") {
spdlog::set_level(spdlog::level::debug);
} else {
spdlog::set_level(spdlog::level::info);
logger->error("Unkown log level");
return EXIT_FAILURE;
}
Config& config = Config::get_config();
// Get trx type from parser and set it to config object
std::string trx_type = parser.get<std::string>("trx_type");
if (trx_type == "2PL" ) {
config.trx_type = TrxType::TWO_PHASE_LOCKING;
} else if (trx_type == "NO_CC") {
config.trx_type = TrxType::NO_CONCURRENCY_CONTROL;
} else if (trx_type == "RAMP_F") {
config.trx_type = TrxType::RAMP_FAST;
} else if (trx_type == "AC_RAMP_F") {
config.trx_type = TrxType::AC_RAMP_FAST;
} else {
logger->error("Unkown trx type");
return EXIT_FAILURE;
}
// Get com type from parser and set it to config object
std::string com_type = parser.get<std::string>("com_type");
if (com_type == "TCP") {
config.com_type = ComType::TCP;
} else if (com_type == "IPOIB") {
config.com_type = ComType::IPoIB;
} else if (com_type == "SEND_RECV") {
config.com_type = ComType::SEND_RECV;
} else if (com_type == "RDMA_WRITE") {
config.com_type = ComType::RDMA_WRITE;
} else if (com_type == "RDMA_WRITE_IMM") {
config.com_type = ComType::RDMA_WRITE_IMM;
} else {
logger->error("Unkown com type");
return EXIT_FAILURE;
}
config.data_num = parser.get<int>("data_num");
config.worker_num = 8;
config.trx_len = parser.get<int>("trx_size");
config.write_trx_num = parser.get<int>("write_trx_num");
config.read_trx_num = parser.get<int>("read_trx_num");
config.value_size = parser.get<int>("value_size");
config.read_server_list();
Client client;
client.start_all();
client.check_finish();
client.print_result();
return EXIT_SUCCESS;
}
|
9409b9b6d44f84e80f50f80321fcf98981ac369d
|
4aff5a49d635ecfab5cac986b1ddc1809189e8f8
|
/Codechef/Chef and way/chef and way.cpp
|
021a5068b18c4a6da98ba537c793d3119122a731
|
[] |
no_license
|
shreyrai99/CP-DSA-Questions
|
1221f595391643f5967a77efeb790352536ab9ff
|
5a5bfdaee6bf0253661259cae7780b8859108dbd
|
refs/heads/main
| 2023-09-04T06:38:59.114238
| 2021-10-22T09:46:59
| 2021-10-22T09:46:59
| 413,551,990
| 1
| 0
| null | 2021-10-04T19:10:04
| 2021-10-04T19:10:04
| null |
UTF-8
|
C++
| false
| false
| 752
|
cpp
|
chef and way.cpp
|
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); //for fast input & output
const long long int mod = 1000000007;
int n,k;
cin>>n>>k;
long long int a[n], d[n];
for (int i = 0; i < n; ++i)
{
cin>>a[i];
}
priority_queue<pair<double , int> , vector<pair<double , int > > ,
greater<pair<double , int > > > pq;
d[0] = a[0]%mod;
pq.push({log(a[0]), 0});
for (int i = 1; i < n; ++i)
{// find the cheapest accessible queue entry
while(i-pq.top().second > k)
{
pq.pop();
}
pair<double , int> t = pq.top();
d[i] = (a[i]*d[t.second])%mod;
pq.push({pq.top().first+log(a[i]), i});
}
cout<<d[n-1]%mod<<endl;
return 0;
}
|
43b32c22b1994d230d1551472d1302cb2ca1e9e1
|
888b8f657b27712fcbd2d6df295c1d4aed4e4307
|
/PAT/A1017 Queueing at Bank.cpp
|
bfcf086ad8f879b71908169e223f2a6d9236fbc8
|
[] |
no_license
|
zzwblog/AlgorithmCode
|
9a0b1fb0b459dad1c6d127cf1f1d996a97c2bac2
|
0e9c2f0b096298eaedf442674416d01afceac7a3
|
refs/heads/master
| 2022-12-15T16:09:04.009443
| 2020-09-03T10:48:53
| 2020-09-03T10:48:53
| null | 0
| 0
| null | null | null | null |
GB18030
|
C++
| false
| false
| 1,677
|
cpp
|
A1017 Queueing at Bank.cpp
|
//#include <iostream>
//#include <vector>
//#include <algorithm>
//
//using namespace std;
//
//struct Person
//{
// int arriveTime, serverTime, popTime;
//};
//
//int N, K;
//
//int main()
//{
// cin >> N >> K;
// vector<Person*>window(K);//就排一个人办业务,不需要用队列
// vector<Person*>data;
// double waitTime = 0.0;
// for (int i = 0; i < N; ++i)
// {
// int hh, mm, ss, tt;
// Person* one = new Person;
// scanf("%d:%d:%d %d", &hh, &mm, &ss, &tt);
// one->arriveTime = hh * 3600 + mm * 60 + ss;
// one->serverTime = tt * 60;
// if (one->arriveTime <= (17 * 3600))//下班了,不算
// data.push_back(one);
// }
// sort(data.begin(), data.end(), [](Person* a, Person* b) {return a->arriveTime < b->arriveTime; });
// for (int i = 0; i < data.size(); ++i)
// {
// if (i < K)
// {
// if (data[i]->arriveTime < (8 * 3600))//来早了
// waitTime += 8 * 3600 - data[i]->arriveTime;
// data[i]->popTime = data[i]->serverTime + (data[i]->arriveTime < (8 * 3600) ? 8 * 3600 : data[i]->arriveTime);
// window[i%K] = data[i];
// }
// else
// {
// int index = 0, minTime = window[0]->popTime;
// for (int j = 0; j < K; ++j)
// {
// if (minTime > window[j]->popTime)
// {
// index = j;
// minTime = window[j]->popTime;
// }
// }
// waitTime += data[i]->arriveTime < minTime ? (minTime - data[i]->arriveTime) : 0;//早到就等待
// data[i]->popTime = data[i]->serverTime + (data[i]->arriveTime < minTime ? minTime : data[i]->arriveTime);
// window[index] = data[i];
// }
// }
// if (data.size() == 0)
// printf("0.0\n");
// else
// printf("%0.1f\n", (waitTime / (60 * data.size())));
// return 0;
//}
//
|
bd05a8920e58e1703f570a075f4ddb39086882b6
|
8e63e4fd669ced86bf07b20be364da5a06bce70d
|
/CodeForces/798A. Mike and palindrome.cpp
|
dea8a0993c7c7dcaf875a3457e409d488a1201c3
|
[] |
no_license
|
AliOsm/CompetitiveProgramming
|
00a1e75a2635532651fcdfb0e478c009adf84032
|
af25b7f806e9c22a2176bfd05a1406ce5f1492c3
|
refs/heads/master
| 2023-03-07T01:17:25.555911
| 2023-02-10T09:09:17
| 2023-02-10T09:09:17
| 70,904,119
| 125
| 58
| null | 2021-02-27T13:13:18
| 2016-10-14T11:29:55
|
C++
|
UTF-8
|
C++
| false
| false
| 462
|
cpp
|
798A. Mike and palindrome.cpp
|
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
string s, rev;
cin >> s;
for(int i = 0; i < s.length(); i++) {
char tmp = s[i];
for(char ch = 'a'; ch <= 'z'; ch++) {
s[i] = ch;
rev = s;
reverse(rev.begin(), rev.end());
if(ch != tmp && s == rev) {
cout << "YES" << endl;
return 0;
}
}
s[i] = tmp;
}
cout << "NO" << endl;
return 0;
}
|
2d5023c242bc9914bd3e732ecfd866f872e9871f
|
a7cd54d2fda1019668eb398040e63b02729ef4d9
|
/Circular Linked List/DeletionCircular.cpp
|
243cf5c66a456f26cbd16e7308a077675186cf64
|
[] |
no_license
|
Udbhavsingh99/LinkedList
|
1c280f3b0ff6bdf1f3dcd158b582008a7a265fe8
|
20a05ed80dc9e8f92016be08bb69a6be7df2ad4f
|
refs/heads/main
| 2023-08-28T02:16:15.700566
| 2021-11-03T12:58:22
| 2021-11-03T12:58:22
| 417,816,585
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,244
|
cpp
|
DeletionCircular.cpp
|
#include<iostream>
using namespace std;
class Node
{
public:
int data;
Node* next;
};
/*Algorithm
Case 1 - List is empty
We simply return
Case 2 - List is not empty
If the list is not empty then we define two pointers curr and prev and initialize the pointer curr with the head node.
Traverse the list using curr to find the node to be deleted and before moving to curr to the next node, every time set prev = curr.
If the node is found, check if it is the only node in the list. If yes, set head = NULL and free(curr).
If the list has more than one node, check if it is the first node of the list. Condition to check this( curr == head). If yes, then move prev until it reaches the last node. After prev reaches the last node, set head = head -> next and prev -> next = head. Delete curr.
If curr is not the first node, we check if it is the last node in the list. Condition to check this is (curr -> next == head).
If curr is the last node. Set prev -> next = head and delete the node curr by free(curr).
If the node to be deleted is neither the first node nor the last node, then set prev -> next = curr -> next and delete curr.
*/
void deleteNode(Node** head, int key)
{
// If linked list is empty
if (*head == NULL)
return;
// If the list contains only a single node
if((*head)->data==key && (*head)->next==*head)
{
free(*head);
*head=NULL;
return;
}
Node *last=*head,*d;
// If head is to be deleted
if((*head)->data==key)
{
// Find the last node of the list
while(last->next!=*head)
last=last->next;
// Point last node to the next of head i.e.
// the second node of the list
last->next=(*head)->next;
free(*head);
*head=last->next;
}
// Either the node to be deleted is not found
// or the end of list is not reached
while(last->next!=*head&&last->next->data!=key)
{
last=last->next;
}
// If node to be deleted was found
if(last->next->data==key)
{
d=last->next;
last->next=d->next;
free(d);
}
else
cout<<"no such keyfound";
}
|
7cf0deedef4c548ae9a9aee9c5a9b9b041a4e3fa
|
796f67e47b9fe575471129d18161677efcb975dd
|
/2193.cpp
|
455fd1df518523018f7e90dbdfdb148122232d1c
|
[] |
no_license
|
sung9600/daily
|
ae129092119e479defcbcc149e1de87c1318c03f
|
ac7ea823c15772a4e201693aeccfb68e66e8e5c0
|
refs/heads/master
| 2022-12-08T13:15:08.895236
| 2020-09-05T20:58:48
| 2020-09-05T20:58:48
| 275,787,803
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 404
|
cpp
|
2193.cpp
|
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
long long arr[91];
long long execute(int n){
if(n==0||n==1||n==2)return arr[n];
else {
for(int i=3;i<=n;i++){
arr[i]=arr[i-1]+arr[i-2];
}
}
return arr[n];
}
int main(){
int n;
cin>>n;
arr[0]=0;
arr[1]=1;
arr[2]=1;
printf("%lld",execute(n));
}
|
eb713cb7d898536f228eb8f535af8ea755c051e9
|
176725d76064bbe970b70a13faad61e3bf8de847
|
/server/s_socket_connect.cpp
|
8f2a6267800dd05f626864a8e35243903adc37dd
|
[] |
no_license
|
Sniperer/filetrans
|
907f678a4a779593d62d83dc8cd4c0adff4390c3
|
0db80b46aaae97aa37727a8b452481b7f45d9578
|
refs/heads/master
| 2022-11-16T01:41:49.031118
| 2020-07-17T05:52:37
| 2020-07-17T05:52:37
| 273,910,214
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,044
|
cpp
|
s_socket_connect.cpp
|
#include "s_socket_connect.h"
#include <cstring>
//#define socklen_t int
#ifdef DEBUG
#define pr_data(str) printf("%s\n",str.c_str());
#define pr_c_data(str) printf("%s\n",str);
#define pr_int(len) printf("%d\n",len);
#else
#define pr_c_data(str)
#define pr_data(str)
#define pr_int(len)
#endif
static int str_from_ith_cmp(const char* str1,char* str2,int ith){
int len=0;
while(*(str1+len)!='\0'){
len++;
}
for(int i=0;i<len;i++){
if(*(str1+i)!=*(str2+ith+i)){
return 1;
}
}
return 0;
}
static int str_to_int(char* str,int num){
int len=0,ans=0;
while(len<num){
ans=ans*10+(int)(*(str+len)-'0');
len++;
}
return ans;
}
static void int_to_ith_chars(std::string& _buf,int num){
std::string tmp="";
while(num!=0){
tmp+=(char)('0'+num%10);
num=num/10;
}
reverse(tmp.begin(),tmp.end());
_buf+=tmp;
}
s_socket_connect_task::s_socket_connect_task(threadpool* tp,int _fd,struct sockaddr_in _addr,socklen_t _addr_len):thread_task(tp){
//thread_task(tp);
connect_proc=new s_socket_connect(_fd,_addr,_addr_len);
}
int s_socket_connect_task::exec(){
#ifdef DEBUG
std::cout<<"s_socket_connect_task running..."<<std::endl;
#endif
connect_proc->s_doit();
return 0;
}
s_socket_connect::s_socket_connect(int _fd,struct sockaddr_in _addr,socklen_t _addr_len):c_sockfd(_fd){
_cilent_addr=_addr;
addr_len=_addr_len;
}
/*
FILETRANS/upload'\r\n\r\n'
FILESIZE:$(len)'\r\n'
FILENAME:$(name)'\r\n\r\n'
'\r\n\r\n'
$(filedata)
error return 1;else return 0;
*/
int s_socket_connect::s_solve_upload(int len){
// int recv_len=recv(c_sockfd,data_buf,4096,0);
int recv_len=len;
#ifdef DEBUG
std::cout<<"first recv file...file size is "<<recv_len<<std::endl;
std::cout<<data_buf<<std::endl;
std::cout<<"header debug end."<<std::endl;
#endif
int i=0,flag=0;
bool have_head_bool=0,have_size_bool=0,have_name_bool=0;
s_recv_file *s_file=new s_recv_file();
int f_len;
while(i<recv_len){
if(data_buf[i]=='\r'&&data_buf[i+1]=='\n'){
if(data_buf[i+2]=='\r'&&data_buf[i+3]=='\n'){
if(have_head_bool==0&&str_from_ith_cmp("FILETRANS/upload",data_buf,flag)==0){
#ifdef DEBUG
std::cout<<"FILETRANS head recieved..."<<std::endl;
#endif
i=i+4;
flag=i;
have_head_bool=1;
}
else if(have_head_bool==1&&have_size_bool==1&&have_name_bool==1){
#ifdef DEBUG
std::cout<<"file data recving..."<<std::endl;
#endif
i=i+4;
flag=i;
char _data[4096];
int j;
for(j=flag;j<flag+f_len;j++){
_data[j-flag]=data_buf[j];
}
_data[j-flag]='\0';
std::string str_data(_data);
s_file->s_recv_file_size(str_data.size());
//pr_data(str_data);
//pr_int(str_data.size());
s_file->s_recv_file_set_file_data(std::move(str_data));
pr_int(s_file->s_get_size_diff());
while(s_file->s_get_size_diff()>=0){
if(s_file->s_get_size_diff()==0){
return 0;
}
else{
for(int i=0;i<4096;i++)
data_buf[i]='\0';
int _size=recv(c_sockfd,data_buf,4096,0);
s_file->s_recv_file_size(_size);
s_file->s_recv_file_set_file_data(data_buf);
}
}
}
else if(have_head_bool==1&&have_size_bool==1&&have_name_bool==0&&str_from_ith_cmp("FILENAME:",data_buf,flag)==0){
#ifdef DEBUG
std::cout<<"file_name running..."<<std::endl;
#endif
flag=flag+9;
char _name[256];
int j;
for(j=flag;j<i;j++){
_name[j-flag]=data_buf[j];
}
_name[j-flag]='\0';
std::string file_name(_name);
#ifdef DEBUG
std::cout<<file_name<<std::endl;
#endif
s_file->s_recv_file_set_file_name(std::move(file_name));
have_name_bool=1;
i=i+4;
flag=i;
#ifdef DEBUG
std::cout<<data_buf[i+4]<<std::endl;
#endif
}
else{
/*
Miss information.
*/
}
}
else{
if(have_head_bool==1&&have_size_bool==0&&str_from_ith_cmp("FILESIZE:",data_buf,flag)==0){
flag=flag+9;
f_len=str_to_int(data_buf+flag,i-flag);
s_file->s_recv_file_set_file_size(f_len);
#ifdef DEBUG
std::cout<<str_to_int(data_buf+flag,i-flag)<<std::endl;
#endif
have_size_bool=1;
i=i+2;
flag=i;
}
else{
/*
Miss information.
*/
}
}
}
else{
i++;
}
}
return 1;
}
/*
FILETRANS/login'\r\n\r\n'
USERNAME:$(user)'\r\n'
PASSWORD:&(name)'\r\n\r\n'
error return 1,else return 0;
*/
int s_socket_connect::s_solve_login(){
char _username[256];
char _password[256];
int recv_len=recv(c_sockfd,data_buf,4096,0);
#ifdef DEBUG
std::cout<<data_buf<<std::endl;
#endif
int i=0,flag=0;
bool have_head_bool=0,have_username_bool=0,have_password_bool=0;
while(i<recv_len){
if(data_buf[i]=='\r'&&data_buf[i+1]=='\n'){
if(data_buf[i+2]=='\r'&&data_buf[i+3]=='\n'){
if(have_head_bool==0&&str_from_ith_cmp("FILETRANS/login",data_buf,flag)==0){
#ifdef DEBUG
std::cout<<"have head."<<std::endl;
#endif
i=i+4;
flag=i;
have_head_bool=1;
}
else if(have_head_bool==1&&have_username_bool==1&&have_password_bool==0&&str_from_ith_cmp("PASSWORD:",data_buf,flag)==0){
flag=flag+9;
// char _password[256];
int j;
for(j=flag;j<i;j++){
_password[j-flag]=data_buf[j];
}
_password[j-flag]='\0';
#ifdef DEBUG1
std::cout<<_password<<std::endl;
#endif
i=i+4;
flag=i;
have_password_bool=1;
}
}
else{
if(have_head_bool==1&&have_username_bool==0&&str_from_ith_cmp("USERNAME:",data_buf,flag)==0){
flag=flag+9;
std::cout<<"???"<<std::endl;
int j;
for(j=flag;j<i;j++){
_username[j-flag]=data_buf[j];
}
_username[j-flag]='\0';
#ifdef DEBUG1
std::cout<<_username<<std::endl;
#endif
i=i+2;
flag=i;
have_username_bool=1;
}
}
}
else i++;
}
std::fstream fs2;
fs2.open("fileserver.conf",std::ios::in|std::ios::out);
if(!fs2.is_open()){
#ifdef DEBUG
std::cout<<"file not exist."<<std::endl;
#endif
return 1;
}
std::string cfg_buf(256,'\0');
std::string username(256,'\0'),password(256,'\0');
while(fs2.getline(&cfg_buf[0],256)){
if(str_from_ith_cmp("username",&cfg_buf[0],0)==0){
int i=9;
while(cfg_buf[i]!='\0'){
username[i-9]=cfg_buf[i];
i++;
}
username.resize(i-9);
}
else if(str_from_ith_cmp("password",&cfg_buf[0],0)==0){
int i=9;
while(cfg_buf[i]!='\0'){
password[i-9]=cfg_buf[i];
i++;
}
password.resize(i-9);
}
}
#ifdef DEBUG
std::cout<<password<<":"<<_username<<" "<<username<<":"<<_password<<std::endl;
#endif
fs2.close();
if(username==_username && password==_password){
#ifdef DEBUG
std::cout<<"success"<<std::endl;
#endif
for(int i=0;i<recv_len;i++)
data_buf[i]='\0';
s_send_suclogin();
// s_solve_connect();
return 0;
}
else{
#ifdef DEBUG
std::cout<<"error"<<std::endl;
#endif
for(int i=0;i<recv_len;i++)
data_buf[i]='\0';
s_send_errlogin();
// close(c_sockfd);
return 1;
}
//close(c_sockfd);
//return 0;
}
/*
ERROR\r\n
*/
void s_socket_connect::s_send_errlogin(){
std::string err_login="ERROR";
err_login+="\r\n\r\n";
send(c_sockfd,err_login.data(),err_login.size(),0);
}
/*
SUCCESS\r\n
*/
void s_socket_connect::s_send_suclogin(){
std::string suc_login="SUCCESS";
suc_login+="\r\n\r\n";
send(c_sockfd,suc_login.data(),suc_login.size(),0);
}
int s_socket_connect::s_solve_ls(){
std::string re_buf="FILETRANS/ls\r\n\r\n";
std::string files="";
std::string dir_path=getenv("HOME");
dir_path+="/filetrans_data";
DIR *s_dir=opendir(dir_path.data());
struct dirent *dir_pt;
int num=0;
while((dir_pt=readdir(s_dir))!=NULL){
num++;
files+=dir_pt->d_name;
files+="\r\n";
}
re_buf=re_buf+"FILENUMS:";
int_to_ith_chars(re_buf,num);
re_buf+="\r\n\r\n"+files;
send(c_sockfd,re_buf.data(),re_buf.size(),0);
return 0;
}
int s_socket_connect::s_solve_download(int len){
int recv_len=len;
int i=0,flag=0;
std::string re_buf;
while(i<recv_len){
if(str_from_ith_cmp("\r\n\r\n",data_buf,i)==0){
if(str_from_ith_cmp("FILETRANS/download",data_buf,flag)==0){
i=i+4;
flag=i;
}
else if(str_from_ith_cmp("FILENAME:",data_buf,flag)==0){
flag=flag+9;
std::string file_name=getenv("HOME");
file_name+="/filetrans_data/";
for(int j=flag;j<i;j++)
file_name+=data_buf[j];
pr_data(file_name);
s_send_file *s_file=new s_send_file(file_name);
if(s_file->exec_s_send_file_size()<0){
pr_int(1122333);
re_buf="FILETRANS/ 0\r\n\r\n";
send(c_sockfd,re_buf.data(),re_buf.size(),0);
return 1;
}
else{
re_buf="FILETRANS/ 1\r\n\r\n";
pr_data(re_buf);
send(c_sockfd,re_buf.data(),re_buf.size(),0);
re_buf="FILESIZE:";
pr_int(s_file->exec_s_send_file_size());
int_to_ith_chars(re_buf,s_file->exec_s_send_file_size());
re_buf+="\r\n\r\n";
//pr_data(re_buf);
send(c_sockfd,re_buf.data(),re_buf.size(),0);
re_buf="\r\n\r\n";
//send(c_sockfd,re_buf.data(),re_buf.size(),0);
//pr_data(re_buf);
send(c_sockfd,re_buf.data(),re_buf.size(),0);
//pr_data(re_buf);
int n=s_file->exec_s_send_file_data(re_buf,4096);
pr_data(re_buf);
send(c_sockfd,re_buf.data(),n,0);
return 0;
}
}
}
else{
i++;
}
}
return 1;
}
int s_socket_connect::s_doit(){
while(1){
std::cout<<"logining..."<<std::endl;
if(s_solve_login()==0){
status=1;
break;
}
}
int recv_len=recv(c_sockfd,data_buf,4096,0);
pr_int(recv_len);
pr_c_data(data_buf);
for(int i=0;i<recv_len;i++){
if(str_from_ith_cmp("\r\n\r\n",data_buf,i)==0){
if(str_from_ith_cmp("FILETRANS/upload",data_buf,0)==0){
#ifdef DEBUG
printf("upload\n");
#endif
s_solve_upload(recv_len);
break;
}
else if(str_from_ith_cmp("FILETRANS/download",data_buf,0)==0){
#ifdef DEBUG1
printf("download\n");
#endif
s_solve_download(recv_len);
break;
}
else if(str_from_ith_cmp("FILETRANS/ls",data_buf,0)==0){
#ifdef DEBUG
printf("ls\n");
#endif
s_solve_ls();
break;
}
}
else{
i++;
}
}
close(c_sockfd);
return 0;
}
|
0d5603248a37a7a2dfb07487dad02aeb209f0b6f
|
4eafc3b25f8b7d5749409318122a680068665613
|
/helloLeet/0516.cpp
|
e5281a76669e546444dc08c77f97ee768720d75f
|
[] |
no_license
|
ctyVegetableDog/leetcode
|
6f663ab230fb9dbaec4453828e2bd0b274b83a18
|
2b956412ddfa6b58f5c245da46f96665a8ec276d
|
refs/heads/master
| 2023-07-15T06:48:30.869786
| 2023-07-10T08:13:51
| 2023-07-10T08:13:51
| 216,207,344
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 404
|
cpp
|
0516.cpp
|
//longest palindromic subsequence
class Solution {
public:
int longestPalindromeSubseq(string s) {
int l = s.size();
int dp[l][l] = {0};
for (int i = l - 1; i >= 0; i --) {
dp[i][i] = 1;
for (int j = i + 1; j < l; j ++) dp[i][j] = s[i] == s[j] ? dp[i + 1][j - 1] + 2 : max(dp[i + 1][j], dp[i][j - 1]);
}
return dp[0][l - 1];
}
};
|
86c96c469d5a53b14270e728612632e2ecfdda7d
|
678ee396be8b4cc72fbe6d19c248c34dd09f5c7f
|
/AlgorithmHW3/AlgorithmHW3/AlgorithmHW3.cpp
|
7604e7281850a5ab4951f601f4758ddb327b9373
|
[] |
no_license
|
Chung-god/PNUHomework
|
7a1439f488530d2e668c907efeff347acf4e6c08
|
a178e17711caf9e3ceb09fffe20819c34dd5386b
|
refs/heads/master
| 2022-11-07T21:29:49.140070
| 2020-07-02T13:37:03
| 2020-07-02T13:37:03
| 266,472,155
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,472
|
cpp
|
AlgorithmHW3.cpp
|
// AlgorithmHW3.cpp : 이 파일에는 'main' 함수가 포함됩니다. 거기서 프로그램 실행이 시작되고 종료됩니다.
//
#include <iostream>
#define MAX 8
#define LEN 50
using namespace std;
char route[LEN];//이동경로를 담을 배열
char DRT[5] = { '?','U','D','R','L' }; //방향을 기록하는 배열
int DRTN[4] = { 0,0,0,0 };
bool visited[MAX][MAX];
int result = 0; //최종출력, 경로 갯수
//범위를 벗어났는지 판단하는 함수
bool OutofRange(int row, int col,int cnt) {
if (row == 6 && col == 0 && cnt < LEN-2) return false;
if ((row == 6 || row == 0) &&(col != 0) && (col != 6) ) {
if ((!visited[row][col - 1]) && (!visited[row][col + 1])) return false;
}
if ((col == 6 || col == 0) && (row != 0) && (row != 6)) {
if ((!visited[row+1][col]) && (!visited[row-1][col])) return false;
}
if (row < 0) return false;
if (row > 6) return false;
if (col < 0) return false;
if (col > 6)return false;
return true;
}
//d 방향으로의 이동이 가능한지 판단하는 함수
bool isValid(char d,int row,int col,int cnt) {
switch (d)
{
case 'U':
if (!visited[row - 1][col]) return false;
if (!OutofRange(row - 1, col, cnt)) return false;
break;
case 'D':
if (!visited[row - 1][col]) return false;
if (!OutofRange(row + 1, col, cnt)) return false;
break;
case 'R':
if (!visited[row - 1][col]) return false;
if (!OutofRange(row , col + 1, cnt)) return false;
break;
case 'L':
if (!visited[row - 1][col]) return false;
if (!OutofRange(row , col - 1, cnt)) return false;
break;
}
return true;
}
void backtracking(int cnt, int row, int col) {
if (cnt == LEN - 1) {
result += 1;
printf("Result : %d!!!!!!!!!!!!!!\n\n\n\n\n\n\n", result);
return;
}
else if (cnt > LEN - 1) return;
if (route[cnt] != '?') {//경로가 정해져있을때
if (isValid(route[cnt], row, col,cnt)) {
//printf("Before cnt %d)row : %2d col : %2d\n", cnt, row, col);
switch (route[cnt])
{
case 'U':
cout << "U" << endl;
cout << "row : " << row << " col :" << col << " cnt : " << cnt << endl;
visited[row - 1][col] = 1;
DRTN[0] += 1;
backtracking(cnt + 1, row - 1, col);
visited[row - 1][col] = 0;
break;
case 'D':
cout << "D" << endl;
cout << "row : " << row << " col :" << col << " cnt : " << cnt << endl;
visited[row + 1][col] = 1;
DRTN[1] += 1;
backtracking(cnt + 1, row + 1, col);
visited[row + 1][col] = 0;
break;
case 'R':
cout << "R" << endl;
cout << "row : " << row << " col :" << col << " cnt : " << cnt << endl;
visited[row][col + 1] = 1;
DRTN[2] += 1;
backtracking(cnt + 1, row, col + 1);
visited[row][col + 1] = 0;
break;
case 'L':
cout << "L" << endl;
cout << "row : " << row << " col :" << col << " cnt : " << cnt << endl;
visited[row][col - 1] = 1;
DRTN[3] += 1;
backtracking(cnt + 1, row, col - 1);
visited[row][col - 1] = 0;
break;
}
return;
}
else {
return;
}
}
else{//가능한 방향
for (int i = 1; i < 5;i++) {
if (isValid(DRT[i], row, col,cnt)) {
switch (DRT[i])
{
case 'U':
cout << "U" << endl;
cout << "row : " << row << " col :" << col << " cnt : " << cnt << endl;
visited[row - 1][col] = 1;
DRTN[0] += 1;
backtracking(cnt + 1, row - 1, col);
visited[row - 1][col] = 0;
break;
case 'D':
cout << "D" << endl;
cout << "row : " << row << " col :" << col << " cnt : " << cnt << endl;
visited[row + 1][col] = 1;
DRTN[1] += 1;
backtracking(cnt + 1, row + 1, col);
visited[row + 1][col] = 0;
break;
case 'R':
cout << "R" << endl;
cout << "row : " << row << " col :" << col << " cnt : " << cnt << endl;
visited[row][col + 1] = 1;
DRTN[2] += 1;
backtracking(cnt + 1, row, col + 1);
visited[row][col + 1] = 0;
break;
case 'L':
cout << "L" << endl;
cout << "row : " << row << " col :" << col << " cnt : " << cnt << endl;
visited[row][col - 1] = 1;
DRTN[3] += 1;
backtracking(cnt + 1, row, col - 1);
visited[row][col - 1] = 0;
break;
}
}
}
}
return;
}
int main()
{
//문자열 입력 받기
for (int i = 0;i < LEN - 2;i++) {
cin >> route[i];
}
if (route[0] == 'U' || route[0] == 'L') {
cout << 0;
return 0;
}
if (route[47] == 'U' || route[47] == 'R') {
cout << 0;
return 0;
}
visited[0][0] = 1;
backtracking(0, 0, 0);
cout << endl<<"끝"<<endl<< result;
}
// 프로그램 실행: <Ctrl+F5> 또는 [디버그] > [디버깅하지 않고 시작] 메뉴
// 프로그램 디버그: <F5> 키 또는 [디버그] > [디버깅 시작] 메뉴
// 시작을 위한 팁:
// 1. [솔루션 탐색기] 창을 사용하여 파일을 추가/관리합니다.
// 2. [팀 탐색기] 창을 사용하여 소스 제어에 연결합니다.
// 3. [출력] 창을 사용하여 빌드 출력 및 기타 메시지를 확인합니다.
// 4. [오류 목록] 창을 사용하여 오류를 봅니다.
// 5. [프로젝트] > [새 항목 추가]로 이동하여 새 코드 파일을 만들거나, [프로젝트] > [기존 항목 추가]로 이동하여 기존 코드 파일을 프로젝트에 추가합니다.
// 6. 나중에 이 프로젝트를 다시 열려면 [파일] > [열기] > [프로젝트]로 이동하고 .sln 파일을 선택합니다.
|
e486f82a5a716fbb08e8d29a157c7ecd17c5908f
|
92708c3e7a7d7dfde67246e97b49ed036b2a65fa
|
/src/image.cpp
|
54110afa89927a0482b9ad489cbdc88b28cf2343
|
[] |
no_license
|
PeterZhouSZ/seamless-compression
|
5165448367692231ede0584ff74ec5565e31a003
|
5a07c5ceccff61012a45d4ffdf71b4ef25a9f0fa
|
refs/heads/main
| 2023-01-02T01:12:38.824347
| 2020-11-01T14:54:50
| 2020-11-01T14:54:50
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 5,091
|
cpp
|
image.cpp
|
#include "image.h"
#include "mesh.h"
#include "sampling.h"
#include <cmath>
#include <cassert>
#include <iostream>
#include <numeric>
#include <glm/common.hpp>
#include <glm/geometric.hpp>
void Image::resize(int rx, int ry)
{
resx = rx;
resy = ry;
data.resize(resx * resy, vec3(0));
clearMask();
}
void Image::drawPoint(vec2 p, vec3 c)
{
pixel(std::floor(p[0] - 0.5), std::floor(p[1] - 0.5)) = c;
pixel(std::floor(p[0] - 0.5), std::floor(p[1] + 0.5)) = c;
pixel(std::floor(p[0] + 0.5), std::floor(p[1] - 0.5)) = c;
pixel(std::floor(p[0] + 0.5), std::floor(p[1] + 0.5)) = c;
}
void Image::drawLine(vec2 from, vec2 to, vec3 c)
{
int d = std::ceil(glm::distance(from, to));
for (double t = 0; t <= 1.0; t += 1.0 / d) {
drawPoint(mix(from, to, t), c);
}
}
unsigned Image::indexOf(int x, int y) const
{
x = (x + resx) % resx;
y = (y + resy) % resy;
return y * resx + x;
}
vec3 Image::pixel(vec2 p) const
{
vec2 p0, p1, w;
getLinearInterpolationData(p, p0, p1, w);
return mix(
mix(pixel(int(p0.x), int(p0.y)), pixel(int(p1.x), int(p0.y)), w.x),
mix(pixel(int(p0.x), int(p1.y)), pixel(int(p1.x), int(p1.y)), w.x),
w.y
);
}
void Image::fetch(vec2 p, vec3& t00, vec3& t10, vec3& t01, vec3& t11,
double &w00, double &w10, double &w01, double& w11) const
{
vec2 p0, p1, w;
getLinearInterpolationData(p, p0, p1, w);
t00 = data[indexOf(int(p0.x), int(p0.y))];
w00 = (1 - w.x) * (1 - w.y);
t10 = data[indexOf(int(p1.x), int(p0.y))];
w10 = ( w.x) * (1 - w.y);
t01 = data[indexOf(int(p0.x), int(p1.y))];
w01 = (1 - w.x) * ( w.y);
t11 = data[indexOf(int(p1.x), int(p1.y))];
w11 = ( w.x) * ( w.y);
}
void Image::fetchIndex(vec2 p, vec3& p00, vec3& p10, vec3& p01, vec3& p11) const
{
vec2 p0, p1, w;
getLinearInterpolationData(p, p0, p1, w);
p00 = vec3(p0.x, p0.y, (1 - w.x) * (1 - w.y));
p10 = vec3(p1.x, p0.y, ( w.x) * (1 - w.y));
p01 = vec3(p0.x, p1.y, (1 - w.x) * ( w.y));
p11 = vec3(p1.x, p1.y, ( w.x) * ( w.y));
}
// returns true when p lies in the ``left'' half-plane
static inline bool isInside(vec2 l0, vec2 l1, vec2 p)
{
vec2 l = l1 - l0;
vec2 n(l.y, -l.x);
return dot(p - l0, n) >= 0;
}
unsigned Image::setMaskInternal(const Mesh& m)
{
unsigned n = 0;
// FIXME does not work with polygonal faces
vec2 uvscale(resx, resy);
for (const Face& f : m.face) {
int minx = std::numeric_limits<int>::max();
int miny = std::numeric_limits<int>::max();
int maxx = std::numeric_limits<int>::min();
int maxy = std::numeric_limits<int>::min();
for (unsigned t : f.ti) {
vec2 tc = m.vtvec[t] * uvscale;
minx = min(minx, int(tc.x));
miny = min(miny, int(tc.y));
maxx = max(maxx, int(tc.x));
maxy = max(maxy, int(tc.y));
}
minx--;
miny--;
maxx++;
maxy++;
for (int y = miny; y <= maxy; ++y)
for (int x = minx; x <= maxx; ++x) {
Edge e0 = f.edge2(0);
Edge e1 = f.edge2(1);
Edge e2 = f.edge2(2);
bool ins0 = isInside(m.vtvec[e0.first] * uvscale, m.vtvec[e0.second] * uvscale, vec2(x, y));
bool ins1 = isInside(m.vtvec[e1.first] * uvscale, m.vtvec[e1.second] * uvscale, vec2(x, y));
bool ins2 = isInside(m.vtvec[e2.first] * uvscale, m.vtvec[e2.second] * uvscale, vec2(x, y));
if ((ins0 == ins1) && (ins1 == ins2)) {
if (!(mask(x, y) & MaskBit::Internal)) {
mask(x, y) |= MaskBit::Internal;
n++;
}
}
}
}
return n;
}
unsigned Image::setMaskSeam(const Mesh& m)
{
using ::Seam;
unsigned n = 0;
vec2 uvscale(resx, resy);
for (const Seam& s : m.seam) {
double d = m.maxLength(s, uvscale);
for (double t = 0; t <= 1; t += 1 / (SEAM_SAMPLING_FACTOR*d)) {
vec3 p[8];
fetchIndex(m.uvpos(s.first, t) * uvscale, p[0], p[1], p[2], p[3]);
fetchIndex(m.uvpos(s.second, t) * uvscale, p[4], p[5], p[6], p[7]);
for (int i = 0; i < 8; ++i) {
//mask[indexOf(int(p[i].x), int(p[i].y))] = std::max(mask[indexOf(int(p[i].x), int(p[i].y))], p[i].z);
int px = int(p[i].x);
int py = int(p[i].y);
if (!(mask(px, py) & MaskBit::Seam)) {
mask(px, py) |= MaskBit::Seam;
n++;
}
}
/*
fetchIndex(m.uvpos(s.second, t) * uvscale, p[0], p[1], p[2], p[3]);
for (int i = 0; i < 4; ++i) {
//mask[indexOf(int(p[i].x), int(p[i].y))] = std::max(mask[indexOf(int(p[i].x), int(p[i].y))], p[i].z);
mask(int(p[i].x), int(p[i].y)) = MaskBit::Seam;
}
*/
}
}
return n;
}
void Image::clearMask()
{
mask_.clear();
mask_.resize(resx * resy, 0);
}
|
01cc130cca1af219c429accd1a1f45ccb30b320e
|
5355f2c499fd7d4dbff5cfe153aec8d21776d46b
|
/Database/tester/MessageObjectBase.h
|
40cf79b862322cc1655e99e43f7197798d948c59
|
[] |
no_license
|
ssicard/systems-project
|
4d2224034f82ccfab4491968d29cc3a339596c65
|
48b69547e1376d90b73b6a1a8c04678de7786bac
|
refs/heads/master
| 2020-03-28T04:23:04.062082
| 2018-11-28T20:09:26
| 2018-11-28T20:09:26
| 147,711,567
| 5
| 0
| null | 2018-10-17T16:58:59
| 2018-09-06T17:48:13
|
C++
|
UTF-8
|
C++
| false
| false
| 1,264
|
h
|
MessageObjectBase.h
|
#include <string>
#pragma once
#include "cppclasses/SqlBase.h"
using namespace std;
#include "cppclasses/AssignmentInformation.h"
#include "cppclasses/AssignmentInstructions.h"
#include "cppclasses/ContactInformationType.h"
#include "cppclasses/ContactRoleLookup.h"
#include "cppclasses/Funding.h"
#include "cppclasses/IncidentInformation.h"
#include "cppclasses/LocationType.h"
#include "cppclasses/MessageProperties.h"
#include "cppclasses/MessagePropertiesLookup.h"
#include "cppclasses/MessageRecall.h"
#include "cppclasses/OwnershipInformation.h"
#include "cppclasses/RadioElement.h"
#include "cppclasses/Resource.h"
#include "cppclasses/ResourceInformation.h"
#include "cppclasses/ResourceMessage.h"
#include "cppclasses/ResourceStatus.h"
#include "cppclasses/ResponseInformation.h"
#include "cppclasses/ResponseTypeLookup.h"
#include "cppclasses/ScheduleInformation.h"
#include "cppclasses/TypeInfoType.h"
#include "cppclasses/ValueListType.h"
class MessageObjectBase: public SqlBase
{
public:
MessageObjectBase();
MessageProperties _MessageProperties;
ResourceMessage _ResourceMessage;
void getFromDatabase();
void insertIntoDatabase();
bool areFieldsValid();
bool getResourceMessage(string MessageObjectName);
};
|
3f7816b8bd0ae6f201ecde5d83942d9e73eb5b12
|
1954c351980f8f1829beaf8f2d2f88032dc81849
|
/apps/calc/CalcActivity.hh
|
2349c1d183b10ce65dc6df845d4b2c3a0a6ab313
|
[
"Apache-2.0"
] |
permissive
|
VincentWei/cell-phone-ux-demo
|
e219913d9032b20b4b2f221ddf8c55f05701191c
|
1085ba798dafe4c32ca4cf8eb65f348c762c224e
|
refs/heads/master
| 2023-01-09T16:56:42.756418
| 2022-09-15T03:17:54
| 2022-09-15T03:17:54
| 112,908,546
| 14
| 8
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,830
|
hh
|
CalcActivity.hh
|
///////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT NOTICE
//
// The following open source license statement does not apply to any
// entity in the Exception List published by FMSoft.
//
// For more information, please visit:
//
// https://www.fmsoft.cn/exception-list
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _CALC_ACTIVITY_HH_
#define _CALC_ACTIVITY_HH_
#include "NCSActivity.hh"
#include "global.h"
#define CALC_IDC_TITLECTRL 100
#define CALC_IDC_KEYBORADCTRL 101
#define CALC_TITLE_W SCREEN_W
#define CALC_TITLE_H 73
#define CALC_ROW_NUM 6
#define CALC_VER_NUM 4
#define CALC_SPACE_X 12
#define CALC_SPACE_Y 15
#define CALC_SPACE_V 5
#define CALC_GAP_W 13
#define CALC_GAP_H 7
#define CALC_BORDER_SPACE 3
#define CALC_PANEL_X ACTIVITY_X
#define CALC_PANEL_Y CALC_TITLE_H
#define CALC_PANEL_W CALC_TITLE_W
#define CALC_PANEL_H (SCREEN_H-CALC_TITLE_H)
#define CALC_NUM_SYM_BORDER_W ((CALC_PANEL_W-(CALC_SPACE_X<<1) \
-(CALC_GAP_W*(CALC_VER_NUM-1)))/CALC_VER_NUM)
#define CALC_NUM_SYM_BORDER_H ((CALC_PANEL_H-CALC_SPACE_V-(CALC_SPACE_Y<<1) \
-(CALC_GAP_H*(CALC_ROW_NUM-1)))/CALC_ROW_NUM)
#define CALC_C_EQUAL_BORDER_W ((CALC_PANEL_W-(CALC_SPACE_X<<1)-CALC_GAP_W)>>1)
#define CALC_C_EQUAL_BORDER_H CALC_NUM_SYM_H
#define CALC_NUM_SYM_W (CALC_NUM_SYM_BORDER_W-(CALC_BORDER_SPACE<<1))
#define CALC_NUM_SYM_H (CALC_NUM_SYM_BORDER_H-(CALC_BORDER_SPACE<<1))
#define CALC_C_EQUAL_W (CALC_C_EQUAL_BORDER_W-(CALC_BORDER_SPACE<<1))
#define CALC_C_EQUAL_H (CALC_C_EQUAL_BORDER_H-(CALC_BORDER_SPACE<<1))
#define CALC_RADIUS_RANGE 8
#define CALC_TITLE_FONT_H 42
#define CALC_M_KEY_FONT_H 23
#define CALC_ADD_KEY_FONT_H 35
#define CALC_SUB_KEY_FONT_H 48
#define CALC_MUL_DIV_KEY_FONT_H 30
#define CALC_EQUAL_KEY_FONT_H 45
#define CALC_KEY_FONT_H 33
#define CALC_C_KEY_FONT_H 30
#define OPERAND_MAX_NUM 16
#define CALC_BTN_NUM 22
#define CALC_ANIMATION_DURATION 400
#define CALC_TITLE_COLOR 0xc02b3d01
#define CALC_M_OP_FONT_COLOR 0xffffffff
#define CALC_TITLE_SHADOW_COLOR 0x7fffffff
#define CALC_KEYFONT_COLOR 0xc0192952
#define CALC_KEYFONT_SHADOWCOLOR 0x7fffffff
#define CALC_E_KEYFONT_SHADOWCOLOR 0x7f000000
typedef enum{
OPERAND_LEFT,
OPERAND_RIGHT,
OPERAND_STORE,
OPERAND_MAX,
}OPERAND_TYPE;
class CalcActivity : public NCSActivity {
public:
CalcActivity();
virtual mContainerCtrl* titleCreate(HWND hwnd,RECT rect);
virtual mContainerCtrl* keyBoardCreate(HWND hwnd,RECT rect);
virtual BOOL startTextFlipAnimation(mContainerCtrl *ctnr,
char *str1,char *str2,int duration,enum EffMotionType type);
virtual void initResource(void);
virtual void releaseResource(void);
intptr_t getButtonPieceIndex(mButtonPanelPiece* piece, int idx);
mAnimationEditPiece *getAnimationEditPiece(void)
{
return m_editPiece;
}
mPanelPiece* getTitlePanelPiece(void)
{
return m_containerpiece;
}
char getOpSymbol(void)
{
return m_op;
}
void setOpSymbol(char a)
{
m_op = a;
}
char *getOperand(int idx)
{
if (idx >= 0 && idx < OPERAND_MAX)
return m_operand[idx];
return NULL;
}
~CalcActivity();
public:
int m_lastIndex;
mHotPiece *m_titleBkPiece;
MGEFF_ANIMATION m_animation;
private:
PLOGFONT m_titleFont;
PLOGFONT m_numKeyFont;
PLOGFONT m_mKeyFont;
PLOGFONT m_addKeyFont;
PLOGFONT m_subKeyFont;
PLOGFONT m_mulDivKeyFont;
PLOGFONT m_equalKeyFont;
PLOGFONT m_cKeyFont;
mPanelPiece *m_containerpiece;
mAnimationEditPiece *m_editPiece;
mButtonPanelPiece* m_btnPiece[CALC_BTN_NUM];
char m_operand[OPERAND_MAX][OPERAND_MAX_NUM];
char m_op;
};
#endif/*end*/
|
f890d5080c87d0f89708e354f72714f4511ca321
|
fee34e5dc60112bb1c1e4847f2c3f3260ce639d3
|
/Dungeon Plunderers/SlimeEnemy.h
|
ce63d00b8f5c6befc2812e4e0a1d5ff7be6933a1
|
[] |
no_license
|
Patryk-Trojak/Dungeon-Plunderers
|
292c1547c18db7822854bc2aceb4f5bc0baeb2f9
|
a4c70724bc273c2472c001bb0e44a1cc6d2b7759
|
refs/heads/main
| 2023-06-24T07:14:26.413671
| 2021-07-27T10:40:11
| 2021-07-27T10:40:11
| 372,948,170
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 528
|
h
|
SlimeEnemy.h
|
#pragma once
#include "RangedEnemy.h"
#include "SlimeProjectile.h"
class SlimeEnemy
:public RangedEnemy
{
public:
SlimeEnemy(const sf::Vector2f& Position, const sf::Vector2f ChangeDirectionDistance, const Resources& resources, const sf::Vector2f& initialScale = sf::Vector2f(1.f, 1.f));
virtual ~SlimeEnemy();
virtual void attack(std::vector<std::unique_ptr<EnemyProjectile> >& Projectiles, const sf::Vector2f& PlayerPosition, const float deltaTime);
virtual void matchHitboxesToAnimation();
private:
bool canShoot;
};
|
7e959c231dbca08db577740ace5b554e9bff6189
|
2c85ecc5079da4dc286ee3e8440e7e59efe4ef78
|
/cp.cpp
|
8b540ff8fd96f783499cfd6e3501a4fd818148c6
|
[] |
no_license
|
deerishi/algorithms
|
7f744644e47203d792216f3287d73167baeae858
|
8f113bb50cb0313a81835320edd5c9ef523dd7af
|
refs/heads/master
| 2021-07-18T23:29:35.088631
| 2017-10-26T23:32:54
| 2017-10-26T23:32:54
| 29,521,515
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,260
|
cpp
|
cp.cpp
|
#include "bits/stdc++.h"
using namespace std;
#define blank putc_unlocked('\n',stdout);
char current[1<<10],ch;
unordered_map<char,int> map1;
class Order
{
public:
bool operator()(char a,char b)
{
return a>b;
}
};
priority_queue<char,vector<char>,Order> queue1;
int main()
{
int i,j,res;
char str1[1005],str2[1005];
while(1)
{
if(scanf("%s",str1)>0)
{
scanf("%s",str2);
map1.clear();
for(i=0;i<strlen(str1);i++)
{
if(map1[str1[i]]==0)
{
map1[str1[i]]=1;
}
else
{
map1[str1[i]]++;
}
}
res=0;
for(i=0;i<strlen(str2);i++)
{
if(map1[str2[i]]>0)
{
map1[str2[i]]--;
queue1.push(str2[i]);
}
}
while(!queue1.empty())
{
putc_unlocked(queue1.top(),stdout);
queue1.pop();
}
blank;
}
else
{
break;
}
}
return 0;
}
|
5c27bc60d26a81364e484f0a73cd29fe6741f429
|
2277375bd4a554d23da334dddd091a36138f5cae
|
/ThirdParty/Havok/Source/Physics/Physics/Collide/Shape/Composite/hknpSparseCompactMap.inl
|
ddcd5cae6231f35c8bc0a86582d6f4b4c2f42466
|
[] |
no_license
|
kevinmore/Project-Nebula
|
9a0553ccf8bdc1b4bb5e2588fc94516d9e3532bc
|
f6d284d4879ae1ea1bd30c5775ef8733cfafa71d
|
refs/heads/master
| 2022-10-22T03:55:42.596618
| 2020-06-19T09:07:07
| 2020-06-19T09:07:07
| 25,372,691
| 6
| 5
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,039
|
inl
|
hknpSparseCompactMap.inl
|
/*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2013 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
template <typename StoreT>
hknpSparseCompactMap<StoreT>::hknpSparseCompactMap(class hkFinishLoadedObjectFlag flag)
: m_primaryKeyToIndex(flag)
, m_valueAndSecondaryKeys(flag)
{
}
template <typename StoreT>
hknpSparseCompactMap<StoreT>::hknpSparseCompactMap()
{
m_secondaryKeyMask = 0xffffffff;
m_sencondaryKeyBits = 0;
}
template <typename StoreT>
void hknpSparseCompactMap<StoreT>::buildMap(int keyBits, int primaryKeyBits, int valueBits, hknpSparseCompactMapUtil::Entry* entries, int numEntries)
{
if (keyBits - primaryKeyBits + valueBits > int(8 * sizeof(StoreT)))
{
hkStringBuf errorMsg;
errorMsg.printf( "SparseCompactMap cannot hold all the bits required, keyBits(%i)-primaryKeyBits(%i)+valueBits(%i) must be less than %i", keyBits, primaryKeyBits, valueBits, 8*sizeof(StoreT));
HK_ERROR( 0xaf0ee222, errorMsg.cString() );
}
m_secondaryKeyMask = (1<<(keyBits-primaryKeyBits))-1;
m_sencondaryKeyBits = keyBits-primaryKeyBits;
hkUint32 numPrimaryKeys = 1<<primaryKeyBits;
m_primaryKeyToIndex.clear();
m_primaryKeyToIndex.reserve(numPrimaryKeys+1);
m_valueAndSecondaryKeys.clear();
m_valueAndSecondaryKeys.reserve(numEntries);
hknpSparseCompactMapUtil::sort( entries, numEntries );
//hkSort( entries, numEntries );
hkUint16 currentIndex = 0;
m_primaryKeyToIndex.pushBackUnchecked(0);
for (hkUint32 i=0; i<numPrimaryKeys; i++)
{
while (1)
{
if (currentIndex>=numEntries)
{
m_primaryKeyToIndex.pushBackUnchecked(currentIndex);
break;
}
hkUint32 primaryKey = entries[currentIndex].m_key >> m_sencondaryKeyBits;
if (primaryKey>i)
{
m_primaryKeyToIndex.pushBackUnchecked(currentIndex);
break;
}
HK_ASSERT(0x52184852, i==primaryKey);
StoreT val = (StoreT)((entries[currentIndex].m_key&m_secondaryKeyMask) | (entries[currentIndex].m_value<<m_sencondaryKeyBits));
m_valueAndSecondaryKeys.pushBackUnchecked(val);
currentIndex++;
}
}
}
// Lookup a value. Returns 0xffffffff if not found.
template <typename StoreT>
hkUint32 HK_FORCE_INLINE hknpSparseCompactMap<StoreT>::lookup(hkUint32 key) const
{
if (m_secondaryKeyMask==0xffffffff) return 0xffffffff;
hkUint32 secondaryKey = key & m_secondaryKeyMask;
hkUint32 primaryKey = key >> m_sencondaryKeyBits;
// Look up the bounds using the primary key.
// Then do a binary search on the secondary key
hkUint32 lowerBound = m_primaryKeyToIndex[primaryKey];
hkUint32 upperBound = m_primaryKeyToIndex[primaryKey+1];
while (lowerBound<upperBound)
{
hkUint32 mid = (lowerBound+upperBound)>>1;
hkUint32 midValue = m_valueAndSecondaryKeys[mid];
hkUint32 midSecondaryKey = midValue&m_secondaryKeyMask;
if (midSecondaryKey>secondaryKey)
{
upperBound = mid;
}
else if (midSecondaryKey<secondaryKey)
{
lowerBound = mid+1;
}
else //secondaryKey == midSecondaryKey
{
return midValue>>m_sencondaryKeyBits;
}
}
return 0xffffffff;
}
/*
* Havok SDK - Base file, BUILD(#20130912)
*
* Confidential Information of Havok. (C) Copyright 1999-2013
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available from salesteam@havok.com.
*
*/
|
bb574ebed2d4478da9058a3413aa3d43329d8831
|
a27780abcc0f1eccff0da0f997852f298b347581
|
/Source.h
|
4c07e5eddb8925d6032c912698b024ee1f85bb52
|
[] |
no_license
|
lcarvalhodev/CG-2018-2
|
96288b7f7b5a656b761389e6ef360f93da5c4f32
|
045a77a5dbf6603d54a3de9c75e230f08207996b
|
refs/heads/master
| 2020-03-26T14:32:07.830552
| 2018-12-11T02:51:00
| 2018-12-11T02:51:00
| 144,992,567
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 557
|
h
|
Source.h
|
/*
Graphics Computer 2018.2
Federal University of Ceará
Team: Leandro Almeida de Carvalho (Leader)
Letícia Fernandes
Levi Tavares
Karen Raiany
Kayron Melo
Professor: Creto Vidal
Work: Build a RayTracer to render a snowman with a image background.
*/
#ifndef _SOURCE_H
#define _SOURCE_H
class Source {
public:
Source();
//Getters
virtual Vect getLightPosition() {
return Vect (0,0,0);
}
virtual Color getLightColor(){
return Color (1,1,1,0);
}
};
Source::Source() {}
#endif
|
e86bc22a5a68b5636c48b95ad5afac490a0dfe74
|
dcc7cd122af348f090ffacb28c0a8de0c22f79b5
|
/hello/main_hello2.cpp
|
7444bcd0ec8f737891e84c9441a2bbcc9232f97b
|
[
"Unlicense"
] |
permissive
|
alexbernardino/scdtr1718
|
0ba8191d10a54b831d9ce19d71fc40a3d1da91e5
|
9fa86f2f2f7b5ada1f978d46a4ce6699ce67f705
|
refs/heads/master
| 2021-08-28T05:29:15.687735
| 2017-12-11T09:09:49
| 2017-12-11T09:09:49
| 104,222,261
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 138
|
cpp
|
main_hello2.cpp
|
//main_hello2.cpp
#include "hello2.h"
#include <stdio.h>
int main()
{
Hello2 obj;
obj.set_id(2);
obj.run(2,3);
getchar();
}
|
05ee12c061ad4deab39e3bd4dcd4f88465f21952
|
6eb8886beefcd6fa0e48293acc19d6b80511d6d9
|
/Code/CFeatureExtraction.cpp
|
479234fe5b239fc64abdeebf38ac68c1393bd538
|
[] |
no_license
|
TBeeren/ShapeDetection
|
9dbe8025a600500a8475039d3243ac8a29a6dba1
|
a58b21e95b291030b87576ff5b64e29d038f266b
|
refs/heads/master
| 2023-04-11T06:07:02.090489
| 2021-04-25T10:38:54
| 2021-04-25T10:38:54
| 361,393,461
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,933
|
cpp
|
CFeatureExtraction.cpp
|
#include "CFeatureExtraction.h"
#include "CCalibration.h"
#include <iostream>
#include "stdint.h"
namespace
{
constexpr const int8_t BILATERFILTER_ITERATIONS = 3;
constexpr const int8_t BILATERFILTER_KERNEL = 9;
constexpr const int16_t BILATERFILTER_SIGMA_COLOUR = 50;
constexpr const int16_t BILATERFILTER_SIGMA_SPACE = 120;
constexpr const int16_t EDGE_LINKING_THRESHHOLD = 0;
constexpr const int16_t INITIAL_STRONG_EDGE_THRESHOLD = 50;
constexpr const int16_t CANNY_APERATURE_SIZE = 5;
constexpr const int16_t MIN_SHAPE_SIZE = 200;
constexpr const double EDGE_APPROX_FACTOR = 0.02;
}
CFeatureExtraction::CFeatureExtraction()
: m_spCalibration(std::make_shared<CCalibration>())
{
}
CFeatureExtraction::~CFeatureExtraction()
{
}
bool CFeatureExtraction::Init(bool userCalibration)
{
return m_spCalibration->InitColours(userCalibration);
}
std::vector<std::vector<cv::Point>> CFeatureExtraction::GetCornerPoints(const cv::Mat& source, eColours colour)
{
std::vector<std::vector<cv::Point>> returnVector;
cv::Mat colourMask, edgeMatrix;
colourMask = ExtractColours(source, colour);
edgeMatrix = ExtractEdges(colourMask);
returnVector = ExtractContours(edgeMatrix);
return returnVector;
}
cv::Mat CFeatureExtraction::ExtractColours(const cv::Mat& rInput, eColours colour)
{
cv::Mat hsv, output, biFilter;
m_spLookupColour = m_spCalibration->GetColour(colour);
for (int i = 0; i < BILATERFILTER_ITERATIONS; ++i)
{
cv::bilateralFilter(rInput, biFilter, BILATERFILTER_KERNEL, BILATERFILTER_SIGMA_COLOUR, BILATERFILTER_SIGMA_SPACE);
}
cv::cvtColor(rInput, hsv, cv::COLOR_RGB2HSV);
cv::inRange(hsv, m_spLookupColour->GetLowerLimit(), m_spLookupColour->GetUpperLimit(), output);
return output;
}
cv::Mat CFeatureExtraction::ExtractEdges(const cv::Mat &input)
{
cv::Mat output;
cv::Canny(input, output, EDGE_LINKING_THRESHHOLD, INITIAL_STRONG_EDGE_THRESHOLD, CANNY_APERATURE_SIZE);
cv::dilate(output, output, cv::Mat());
cv::erode(output, output, cv::Mat());
return output;
}
std::vector<std::vector<cv::Point>> CFeatureExtraction::ExtractContours(const cv::Mat &input)
{
std::vector<std::vector<cv::Point>> allContours; //stores all contour point
std::vector<std::vector<cv::Point>> contourCorners; //stores all contour corner points
std::vector<cv::Point> approx; //temporarily stores contour corner points
cv::findContours(input, allContours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);
for (uint64_t i = 0; i < allContours.size(); ++i)
{
if (std::fabs(cv::contourArea(allContours[i])) > MIN_SHAPE_SIZE)
{
cv::approxPolyDP(cv::Mat(allContours[i]), approx, cv::arcLength(cv::Mat(allContours[i]), true) * EDGE_APPROX_FACTOR, true);
contourCorners.push_back(approx);
}
}
return contourCorners;
}
|
c7450e660e06124efdf21e2a96a3df907ce96f17
|
20716fa9f6d2b4d91ccf5c45267b1c86ed64f757
|
/player.cpp
|
1286cb3966117e7e8036de68d44dfd57457ee05e
|
[] |
no_license
|
leodlplq/othello
|
7b73e7ff6f5e9578b47816085db6b4cd49cee413
|
1442d0ce0101e16fe4d425e23e171e8c49a510e1
|
refs/heads/main
| 2023-02-19T18:20:17.599569
| 2021-01-22T17:10:02
| 2021-01-22T17:10:02
| 322,866,555
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,415
|
cpp
|
player.cpp
|
//C++ file about the player.
#include "game.h"
void createPlayer(Joueur *joueur, int n){
char name[20];
Jeton *jetonJoueur = new Jeton;
int nbJetons = 2;
if(n == 1){
joueur->color = 'x';
int array[2] = {4,4};
int array2[2] = {5,5};
jetonJoueur->color = 'x';
jetonJoueur->coordonate[0] = array[0];
jetonJoueur->coordonate[1] = array[1];
jetonJoueur->next = NULL;
addCoordonate(&jetonJoueur, array2, 'x');
}else{
joueur->color = 'o';
int array[2] = {4,5};
int array2[2] = {5,4};
jetonJoueur->color = 'o';
jetonJoueur->coordonate[0] = array[0];
jetonJoueur->coordonate[1] = array[1];
jetonJoueur->next = NULL;
addCoordonate(&jetonJoueur, array2, 'o');
}
cout << "Creation du joueur " << n << endl;
cout << "Quel est votre nom ? " << endl;
do{ //on recupere le nom du joueur.
cout << "Mon nom est : ";
cin >> name;
}while((unsigned)strlen(name) > 20);
strcpy(joueur->name, name);
joueur->nbJetons = nbJetons;
joueur->jetonJoueur = *jetonJoueur;
if(n == 1){
cout << "Ma couleur est 'x'" <<endl;
cout << "\n" <<endl;
}else{
cout << "Ma couleur est 'o'" << endl;
cout << "\n\n\n" << endl;
cout << "Le jeu va commencer preparez vous !" <<endl;
}
}
|
b7b7cb8d11f745c18cc2b46f638e8c42628b5697
|
948479e1809e7bc8054c7318cbf8f89b86084fb7
|
/part_data.hpp
|
b225084cf04ce073cff21f3a7c63a961e4ac00d1
|
[
"MIT"
] |
permissive
|
sbird/S-GenIC
|
6d643ba2a6c55664e15b81b55dd8e253794e739d
|
d48b6ed02b3d98476258ae1f0a89cbb8949575ff
|
refs/heads/master
| 2020-12-15T20:29:34.690564
| 2018-06-16T23:13:31
| 2018-06-16T23:13:31
| 4,801,073
| 8
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,126
|
hpp
|
part_data.hpp
|
#ifndef __PART_DATA_HPP
#define __PART_DATA_HPP
#include <valarray>
#define FLOAT_TYPE float
#define N_TYPES 6
//Class to generate a regular grid of particle positions on demand.
class part_grid
{
public:
/* Construct the particle grid parameters.
* NumPart should be the number of particles per side; the cube root of the total number of particles.
* Masses are the mass ratios of the different particle species, for making sure no two types share the same position
* Box is the boxsize.*/
part_grid(const int64_t NumPart[], const double Masses[], const double Box);
/* Get the position of a particle at some index on a grid.
* We want to return:
* size_t index = k + j* NumPart + i * NumPart**2
* Pos[0] = i /NumPart * pspace[type]
* Pos[1] = j /NumPart * pspace[type]
* Pos[2] = k /NumPart * pspace[type]
* In other words, k is fast, j is medium, i is slow.
*/
double Pos(size_t index, int axis, int type);
//Get number of particles
int64_t GetNumPart(int type);
//Get box size
inline double GetBox(){
return Box;
}
double get_shift(int type) {
return shift[type];
}
private:
const std::valarray<int64_t> NumPart;
const double Box;
double pspace[N_TYPES];
double shift[N_TYPES];
};
//Class to store the Zeldovich and 2LPT displacements for a particle type.
class lpt_data
{
public:
//Again, NumPart is the cube root of the particle number!
lpt_data(const int NumPart, bool twolpt=true): vel_prefac(0), vel_prefac2(0), twolpt(twolpt),Vel_data(3*static_cast<size_t>(NumPart)*NumPart*NumPart),Vel_2_data(twolpt*3*static_cast<size_t>(NumPart)*NumPart*NumPart)
{}
//Note Vel_2_data takes zero space if !twolpt
inline void SetVel(FLOAT_TYPE Vel_in, size_t index, int axis){
Vel_data[3*index+axis] = Vel_in;
return;
}
inline void Set2Vel(FLOAT_TYPE Vel_in, size_t index, int axis){
Vel_2_data[3*index+axis] = Vel_in;
return;
}
inline double GetVel(size_t index, int axis)
{
double vel = vel_prefac*Vel_data[3*index+axis];
if(twolpt)
vel += vel_prefac2*Vel_2_data[3*index+axis];
return vel;
}
inline double GetDisp(size_t index, int axis)
{
double disp = Vel_data[3*index+axis];
if(twolpt)
disp -= 3./7.*Vel_2_data[3*index+axis];
return disp;
}
inline size_t GetNumPart(){
return Vel_data.size()/3;
}
void SetVelPrefac(double vel_prefac_i, double vel_prefac2_i)
{
vel_prefac = vel_prefac_i;
vel_prefac2 = vel_prefac2_i;
}
private:
double vel_prefac;
double vel_prefac2;
const bool twolpt;
std::valarray <FLOAT_TYPE> Vel_data;
std::valarray <FLOAT_TYPE> Vel_2_data;
};
#endif
|
a65de297dbb8dc619a8100f13c1bd7f4120e4300
|
0d6560bb341dca5ab9a5c0f4c9fb3970e2fdb035
|
/POSCAT/upload/code/acmicpc/2033.cpp
|
0d25861b6b303dcd83e2a70734bf9b0c88b00917
|
[] |
no_license
|
yougatup/yougatup.github.io
|
7737d70baceab147fed645d40cd63f66f2be22bd
|
194626540a90b15d9b9279e185886c701385bb7f
|
refs/heads/master
| 2020-04-12T05:39:11.078724
| 2016-10-14T01:28:23
| 2016-10-14T01:28:23
| 65,126,836
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 285
|
cpp
|
2033.cpp
|
#include <cstdio>
using namespace std;
int find(int n,int b)
{
if(b>4)
n++;
if(n/10==0)
return n;
else
return find(n/10,n%10)*10;
}
int main()
{
int n;
scanf("%d",&n);
if(n<10)
printf("%d\n",n);
else
printf("%d\n",find(n,0));
return 0;
}
|
a014bff36e3457f60759f39fd00e2f7b2c4c7188
|
36e12292ea03f8407e39a9d51ac8be1f9f124618
|
/PI_2021_II_P2_PROYECTO2_GRUPO1/EmpleadoTemporal.cpp
|
06d9a1112b7b13f9544f33e11ff19de730b63cb5
|
[] |
no_license
|
RicoyPagoaga/PI_2021_II_P2_PROYECTO2_GRUPO1
|
3fedd1c76e5fb3aa176fda230b59a4a91e73af94
|
8d6d0f9ad156b083502206983068e97dbfeabc16
|
refs/heads/master
| 2023-07-06T15:01:05.002174
| 2021-08-04T23:21:15
| 2021-08-04T23:21:15
| 388,623,493
| 0
| 0
| null | 2021-08-04T22:08:20
| 2021-07-22T23:25:14
|
C++
|
UTF-8
|
C++
| false
| false
| 1,590
|
cpp
|
EmpleadoTemporal.cpp
|
#include <string>
#include <stdexcept>
#include <iostream>
#include "EmpleadoTemporal.h"
using namespace std;
EmpleadoTemporal::EmpleadoTemporal() {
establecerNumeroSeguroSocial(" ");
}
EmpleadoTemporal::EmpleadoTemporal(string nombre, string apellido, string _direccion, string _identificacion,
int _edad, string seguro, int numero, double ventas)
:Persona(nombre, apellido, _direccion, _identificacion, _edad) {
establecerNumeroCuenta(numero), establecerVentas(ventas), establecerNumeroSeguroSocial(seguro);
}
string EmpleadoTemporal::obtenerNumeroSeguroSocial() const {
return numeroSeguroSocial;
}
void EmpleadoTemporal::establecerNumeroSeguroSocial(string seguro) {
int longitud = seguro.size();
longitud = (longitud < 15 ? longitud : 14);
seguro.copy(numeroSeguroSocial, longitud);
numeroSeguroSocial[longitud] = '\0';
}
void EmpleadoTemporal::establecerVentas(double ventas) {
if (ventas >= 0.0)
Ventas = ventas;
else
throw invalid_argument("Las ventas debe ser >= 0");
}
double EmpleadoTemporal::obtenerVentas() const {
return Ventas;
}
void EmpleadoTemporal::establecerNumeroCuenta(int numero) {
if (numero > 0 && numero < 100)
numeroCuenta = numero;
else
throw invalid_argument("El numero de cuenta debe ser 0-100");
}
int EmpleadoTemporal::obtenerNumeroCuenta() const {
return numeroCuenta;
}
void EmpleadoTemporal::imprimirInformacion() const {
cout << "Empleado Temporal: ";
Persona::imprimirInformacion();
cout << endl << " Salario: " << calcularIngresos();
}
double EmpleadoTemporal::calcularIngresos() const {
return (obtenerVentas() * 0.5);
}
|
4752820d039e72ae508f454429797cda3b166fca
|
e30d8e1c98a40273392efbe9a9eee6daf02df107
|
/码库/P5025 [SNOI2017]炸弹.cpp
|
82d68e924f49fce1a8e2480a9cfb6f7d66ca7e8e
|
[] |
no_license
|
zzctommy/public-source-code
|
c11099de0e1bac21a9db26ab6d83d8e15ffdf460
|
bf2cf1ea607f097952ccd059fb8fbbcce7b08466
|
refs/heads/master
| 2023-03-21T06:24:19.206752
| 2021-03-05T01:18:35
| 2021-03-05T01:18:35
| 277,446,660
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,458
|
cpp
|
P5025 [SNOI2017]炸弹.cpp
|
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned int uint;
#define rint register int
#define pb push_back
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
#define int long long
inline int rd() {
int x=0,f=1;char ch=getchar();
while(!isdigit(ch)) {if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch))x=x*10+(ch^48),ch=getchar();
return x*f;
}
const int N=500010;
const int M=N<<2;
const int mod=1e9+7;
int n,pos[N],ans;
LL x[N],r[N];
int lp[M],rp[M],Lp[M],Rp[M];
int head[M],num_edge;
int dfn[M],low[M],timer,st[M],top,C,scc[M];
int ind[M],numnode;
struct edge {
int nxt,to;
}e[N*25];
vector<int>g[M];
void addedge(int from,int to) {
++num_edge;
e[num_edge].nxt=head[from];
e[num_edge].to=to;
head[from]=num_edge;
}
#define lc (p<<1)
#define rc (p<<1|1)
void build(int l,int r,int p) {
lp[p]=l,rp[p]=r,numnode=max(numnode,p);
if(l==r)return void(pos[l]=p);
int mid=(l+r)>>1;
addedge(p,lc),addedge(p,rc);
build(l,mid,lc),build(mid+1,r,rc);
}
void update(int ql,int qr,int l,int r,int p,int k) {
if(ql<=l&&r<=qr) {
addedge(k,p);return;
}
int mid=(l+r)>>1;
if(mid>=ql)update(ql,qr,l,mid,lc,k);
if(mid<qr)update(ql,qr,mid+1,r,rc,k);
}
void tarjan(int u) {
dfn[u]=low[u]=++timer,st[++top]=u;
for(rint i=head[u];i;i=e[i].nxt) {
int v=e[i].to;
if(!dfn[v])tarjan(v),low[u]=min(low[u],low[v]);
else if(!scc[v])low[u]=min(low[u],dfn[v]);
}
if(dfn[u]==low[u]) {
scc[u]=++C,Lp[C]=lp[u],Rp[C]=rp[u];
while(st[top]!=u)scc[st[top]]=C,Lp[C]=min(Lp[C],lp[st[top]]),Rp[C]=max(Rp[C],rp[st[top]]),--top;
--top;
}
}
void buildDAG() {
for(rint u=1;u<=numnode;++u) {
for(rint i=head[u];i;i=e[i].nxt) {
int v=e[i].to;
if(scc[u]!=scc[v])g[scc[v]].pb(scc[u]),++ind[scc[u]];
}
}
}
void topo() {
queue<int>q;
for(rint i=1;i<=C;++i)if(!ind[i])q.push(i);
while(!q.empty()) {
int u=q.front();q.pop();
for(uint i=0;i<g[u].size();++i) {
int v=g[u][i];
Lp[v]=min(Lp[v],Lp[u]);
Rp[v]=max(Rp[v],Rp[u]);
--ind[v];
if(!ind[v])q.push(v);
}
}
}
signed main() {
n=rd();build(1,n,1);
for(rint i=1;i<=n;++i)x[i]=rd(),r[i]=rd();
for(rint i=1;i<=n;++i) {
int lp=lower_bound(x+1,x+i+1,x[i]-r[i])-x;
int rp=upper_bound(x+i,x+n+1,x[i]+r[i])-x-1;
update(lp,rp,1,n,1,pos[i]);
}
tarjan(1),buildDAG(),topo();
for(rint i=1;i<=n;++i)ans=(ans+(Rp[scc[pos[i]]]-Lp[scc[pos[i]]]+1)*i)%mod;
printf("%lld\n",ans);
return 0;
}
|
044aeb9731b83b980ed841a7f05864d37f400b97
|
fcd17fa8b71094eb8f33773a0bbba2e19ae9b5b6
|
/src/mesh/DICe_Mesh.cpp
|
975831b667f8bffceda57ac266c5ebbece4a3239
|
[
"BSD-2-Clause",
"BSD-3-Clause"
] |
permissive
|
fangliang11/dice
|
40a1f3af0841458e994c510cc38c392cd714e860
|
a3b6a0e53f3c4ba3a7f1a6268e99bd36f8a6382f
|
refs/heads/master
| 2022-11-29T21:12:05.532870
| 2020-08-14T18:54:01
| 2020-08-14T18:54:01
| 293,441,209
| 1
| 0
|
NOASSERTION
| 2020-09-07T06:27:38
| 2020-09-07T06:27:37
| null |
UTF-8
|
C++
| false
| false
| 128,037
|
cpp
|
DICe_Mesh.cpp
|
// @HEADER
// ************************************************************************
//
// Digital Image Correlation Engine (DICe)
// Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
//
// 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 Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY NTESS "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 NTESS OR THE
// 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.
//
// Questions? Contact: Dan Turner (dzturne@sandia.gov)
//
// ************************************************************************
// @HEADER
#include <DICe_Mesh.h>
#include <Teuchos_Tuple.hpp>
namespace DICe {
namespace mesh {
Element::Element(const connectivity_vector & connectivity,
const int_t global_id,
const int_t local_id,
const int_t block_id,
const int_t block_local_id) :
Mesh_Object(global_id,local_id),
block_id_(block_id),
block_local_id_(block_local_id),
connectivity_(connectivity)
{}
Subelement::Subelement(Teuchos::RCP<Element> element,
const int_t local_id,
const int_t global_id) :
Mesh_Object(global_id,local_id),
block_id_(element->block_id()),
connectivity_(element->get_connectivity()),
parent_element_(element)
{}
Subelement::Subelement(const connectivity_vector & connectivity,
Teuchos::RCP<Element> element,
const int_t local_id,
const int_t global_id,
const int_t block_id) :
Mesh_Object(global_id,local_id),
block_id_(block_id),
connectivity_(connectivity),
parent_element_(element)
{}
Mesh_Object::Mesh_Object(const int_t global_id,
const int_t local_id) :
global_id_(global_id),
local_id_(local_id),
overlap_local_id_(-1),
overlap_neighbor_local_id_(-1),
initial_num_node_relations_(0),
initial_num_elem_relations_(0)
{}
void
Mesh_Object::add_shallow_relation(const field_enums::Entity_Rank entity_rank,
const int_t global_id) const
{
// cast away the constness because the mesh object is part of a set
const DICe::mesh::Mesh_Object & cobj = *this;
DICe::mesh::Mesh_Object & obj = const_cast<DICe::mesh::Mesh_Object&>(cobj);
shallow_relations_map::iterator it=obj.get_shallow_relations_map()->find(entity_rank);
if(it==obj.get_shallow_relations_map()->end())
{
std::set<int_t> ord_set;
ord_set.insert(global_id);
obj.get_shallow_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::set<int_t> >(entity_rank,ord_set));
}
else
{
std::set<int_t> ord_set = it->second;
ord_set.insert(global_id);
obj.get_shallow_relations_map()->erase(it);
obj.get_shallow_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::set<int_t> >(entity_rank,ord_set));
}
}
// TODO condense all of these below
void
Mesh_Object::add_deep_relation(const Teuchos::RCP<Node> node) const
{
// cast away the constness because the mesh object is part of a set
const DICe::mesh::Mesh_Object & cobj = *this;
DICe::mesh::Mesh_Object & obj = const_cast<DICe::mesh::Mesh_Object&>(cobj);
deep_relations_map::iterator it=obj.get_deep_relations_map()->find(field_enums::NODE_RANK);
if(it==obj.get_deep_relations_map()->end())
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set;
ptr_set.push_back(node);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::NODE_RANK,ptr_set));
}
else
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set = it->second;
ptr_set.push_back(node);
obj.get_deep_relations_map()->erase(it);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::NODE_RANK,ptr_set));
}
}
void
Mesh_Object::add_deep_relation(const Teuchos::RCP<Element> element) const
{
// cast away the constness because the mesh object is part of a set
const DICe::mesh::Mesh_Object & cobj = *this;
DICe::mesh::Mesh_Object & obj = const_cast<DICe::mesh::Mesh_Object&>(cobj);
deep_relations_map::iterator it=obj.get_deep_relations_map()->find(field_enums::ELEMENT_RANK);
if(it==obj.get_deep_relations_map()->end())
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set;
ptr_set.push_back(element);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::ELEMENT_RANK,ptr_set));
}
else
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set = it->second;
ptr_set.push_back(element);
obj.get_deep_relations_map()->erase(it);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::ELEMENT_RANK,ptr_set));
}
}
void
Mesh_Object::add_deep_relation(const Teuchos::RCP<Internal_Face_Edge> internal_face_edge) const
{
// cast away the constness because the mesh object is part of a set
const DICe::mesh::Mesh_Object & cobj = *this;
DICe::mesh::Mesh_Object & obj = const_cast<DICe::mesh::Mesh_Object&>(cobj);
deep_relations_map::iterator it=obj.get_deep_relations_map()->find(field_enums::INTERNAL_FACE_EDGE_RANK);
if(it==obj.get_deep_relations_map()->end())
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set;
ptr_set.push_back(internal_face_edge);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::INTERNAL_FACE_EDGE_RANK,ptr_set));
}
else
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set = it->second;
ptr_set.push_back(internal_face_edge);
obj.get_deep_relations_map()->erase(it);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::INTERNAL_FACE_EDGE_RANK,ptr_set));
}
}
//void
//Mesh_Object::add_deep_relation(const Teuchos::RCP<External_Face_Edge> external_face_edge) const
//{
// // cast away the constness because the mesh object is part of a set
// const DICe::mesh::Mesh_Object & cobj = *this;
// DICe::mesh::Mesh_Object & obj = const_cast<DICe::mesh::Mesh_Object&>(cobj);
//
// deep_relations_map::iterator it=obj.get_deep_relations_map()->find(field_enums::EXTERNAL_FACE_EDGE_RANK);
// if(it==obj.get_deep_relations_map()->end())
// {
// std::vector<Teuchos::RCP<Mesh_Object> > ptr_set;
// ptr_set.push_back(external_face_edge);
// obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::EXTERNAL_FACE_EDGE_RANK,ptr_set));
// }
// else
// {
// std::vector<Teuchos::RCP<Mesh_Object> > ptr_set = it->second;
// ptr_set.push_back(external_face_edge);
// obj.get_deep_relations_map()->erase(it);
// obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::EXTERNAL_FACE_EDGE_RANK,ptr_set));
// }
//}
void
Mesh_Object::add_deep_relation(const Teuchos::RCP<Internal_Cell> internal_cell) const
{
// cast away the constness because the mesh object is part of a set
const DICe::mesh::Mesh_Object & cobj = *this;
DICe::mesh::Mesh_Object & obj = const_cast<DICe::mesh::Mesh_Object&>(cobj);
deep_relations_map::iterator it=obj.get_deep_relations_map()->find(field_enums::INTERNAL_CELL_RANK);
if(it==obj.get_deep_relations_map()->end())
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set;
ptr_set.push_back(internal_cell);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::INTERNAL_CELL_RANK,ptr_set));
}
else
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set = it->second;
ptr_set.push_back(internal_cell);
obj.get_deep_relations_map()->erase(it);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::INTERNAL_CELL_RANK,ptr_set));
}
}
void
Mesh_Object::add_deep_relation(const Teuchos::RCP<Bond> bond) const
{
// cast away the constness because the mesh object is part of a set
const DICe::mesh::Mesh_Object & cobj = *this;
DICe::mesh::Mesh_Object & obj = const_cast<DICe::mesh::Mesh_Object&>(cobj);
deep_relations_map::iterator it=obj.get_deep_relations_map()->find(field_enums::BOND_RANK);
if(it==obj.get_deep_relations_map()->end())
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set;
ptr_set.push_back(bond);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::BOND_RANK,ptr_set));
}
else
{
std::vector<Teuchos::RCP<Mesh_Object> > ptr_set = it->second;
ptr_set.push_back(bond);
obj.get_deep_relations_map()->erase(it);
obj.get_deep_relations_map()->insert(std::pair<field_enums::Entity_Rank,std::vector<Teuchos::RCP<Mesh_Object> > >(field_enums::BOND_RANK,ptr_set));
}
}
int_t
Mesh_Object::is_elem_relation(const int_t gid,
scalar_t & sign)
{
for(size_t i=0;i<deep_bond_relations_.size();++i)
{
if(deep_bond_relations_[i]->get_left_global_id()==gid) {sign = 1.0; return deep_bond_relations_[i]->local_id();} // left elem is positive
else if(deep_bond_relations_[i]->get_right_global_id()==gid) {sign = -1.0; return deep_bond_relations_[i]->local_id();} // right elem is negative
}
return -1;
}
void
Mesh_Object::set_initial_num_relations(const int_t num_relations,
const field_enums::Entity_Rank relation_rank) const
{
// cast away the constness because the mesh object is part of a set
const DICe::mesh::Mesh_Object & cobj = *this;
DICe::mesh::Mesh_Object & obj = const_cast<DICe::mesh::Mesh_Object&>(cobj);
if(relation_rank==field_enums::ELEMENT_RANK)
obj.initial_num_elem_relations_ = num_relations;
else if(relation_rank==field_enums::NODE_RANK)
obj.initial_num_node_relations_ = num_relations;
else
TEUCHOS_TEST_FOR_EXCEPTION(true, std::invalid_argument,"set_initial_num_relations: unknown entity rank");
}
Node::Node(const int_t global_id,
const int_t local_id) :
//local_id(local_id),
Mesh_Object(global_id,local_id)
{}
Mesh::Mesh(const std::string & input_filename,
const std::string & output_filename) :
spatial_dimension_(-1),
is_initialized_(false),
max_num_elem_relations_(0),
max_num_node_relations_(0),
max_num_subelem_face_relations_(0),
mean_num_elem_relations_(0),
mean_num_node_relations_(0),
mean_num_subelem_face_relations_(0),
min_num_elem_relations_(0),
min_num_node_relations_(0),
min_num_subelem_face_relations_(0),
max_num_entries_per_row_(0),
input_exoid_(-1),
output_exoid_(-1),
face_edge_output_exoid_(-1),
input_filename_(input_filename),
output_filename_(output_filename),
face_edge_output_filename_("face_edge_" + output_filename),
control_volumes_are_initialized_(false),
cell_sizes_are_initialized_(false),
ic_value_x_(0.0),
ic_value_y_(0.0),
is_regular_grid_(false)
{
comm_ = Teuchos::rcp(new MultiField_Comm());
element_set_ = Teuchos::rcp(new element_set);
subelement_set_ = Teuchos::rcp(new subelement_set);
internal_face_edge_set_ = Teuchos::rcp(new internal_face_edge_set);
//boundary_face_edge_set_ = Teuchos::rcp(new external_face_edge_set);
edge_set_ = Teuchos::rcp(new edge_set);
bond_set_ = Teuchos::rcp(new bond_set);
internal_cell_set_ = Teuchos::rcp(new internal_cell_set);
node_set_ = Teuchos::rcp(new node_set);
}
/// Create the field maps for the mixed formulation elements
void
Mesh::create_mixed_node_field_maps(Teuchos::RCP<Mesh> alt_mesh){
DEBUG_MSG("Creating the mixed element and node field maps for the mesh");
const int_t indexBase = 0;
const int_t spa_dim = spatial_dimension();
const int_t p_rank = comm_->get_rank();
// get the number of nodes in the alt_mesh
const int_t alt_num_nodes_this_proc = alt_mesh->num_nodes();
// Some nodes are shared among different processors so the node_overlap_map is not 1-to-1!
Teuchos::Array<int_t>::size_type num_nodes_this_proc = num_nodes();
const int_t offset = num_nodes_this_proc*spa_dim;
Teuchos::Array<int_t> node_list_mixed (num_nodes_this_proc*spa_dim + alt_num_nodes_this_proc); // add one for the lagrange multiplier on each lm node
DICe::mesh::node_set::const_iterator node_it = get_node_set()->begin();
DICe::mesh::node_set::const_iterator node_end = get_node_set()->end();
int_t node_index = 0;
for(;node_it!=node_end;++node_it)
{
for(int_t dim=0;dim<spa_dim;++dim)
{
const int_t index_stride = node_index * spa_dim + dim;
node_list_mixed[index_stride] = node_it->first * spa_dim + dim;
}
node_index++;
}
node_it = alt_mesh->get_node_set()->begin();
node_end = alt_mesh->get_node_set()->end();
node_index = 0;
for(;node_it!=node_end;++node_it)
{
const int_t index_stride = offset + node_index;
node_list_mixed[index_stride] = node_it->first + vector_node_dist_map_->get_max_global_index();
node_index++;
}
mixed_vector_node_overlap_map_ = Teuchos::rcp (new MultiField_Map(-1, node_list_mixed, indexBase, *comm_));
//std::cout << " MIXED_VECTOR_NODE_OVERLAP MAP: " << std::endl;
//mixed_vector_node_overlap_map_->describe();
// go through all your local nodes, if the remote index list matches your processor than add it to the new_dist_list
// otherwise another proc will pick it up
const int_t total_num_nodes = mixed_vector_node_overlap_map_->get_num_global_elements();
Teuchos::Array<int_t> nodeIDList(total_num_nodes);
Teuchos::Array<int_t> GIDList(total_num_nodes);
const int_t min_gid = mixed_vector_node_overlap_map_->get_min_global_index();
Teuchos::Array<int_t> gids_on_this_proc_mixed;
for(int_t i=0;i<total_num_nodes;++i)
GIDList[i] = min_gid + i;
mixed_vector_node_overlap_map_->get_remote_index_list(GIDList,nodeIDList);
for(int_t i=0;i<total_num_nodes;++i)
if(nodeIDList[i]==p_rank) // only add the nodes that have this processor as their remote index
gids_on_this_proc_mixed.push_back(min_gid+i);
mixed_vector_node_dist_map_ = Teuchos::rcp(new MultiField_Map(-1,gids_on_this_proc_mixed, indexBase, *comm_));
//std::cout << " MIXED_VECTOR_NODE_DIST MAP: " << std::endl;
//mixed_vector_node_dist_map_->describe();
}
void
Mesh::create_elem_node_field_maps(const bool force_elem_and_node_maps_to_match){
DEBUG_MSG("Creating the element and node field maps for the mesh");
const int_t indexBase = 0;
const int_t spa_dim = spatial_dimension();
const int_t p_rank = comm_->get_rank();
Teuchos::Array<int_t> my_proc(1,p_rank);
proc_map_ = Teuchos::rcp (new MultiField_Map(-1, my_proc, 0, *comm_));
Teuchos::Array<int_t> all_proc;
for(int_t i=0;i<comm_->get_size();++i)
all_proc.push_back(i);
all_own_all_proc_map_ = Teuchos::rcp (new MultiField_Map(-1, all_proc, 0, *comm_));
// NODE DIST MAP
// Some nodes are shared among different processors so the node_overlap_map is not 1-to-1!
Teuchos::Array<int_t>::size_type num_nodes_this_proc = num_nodes();
Teuchos::Array<int_t> node_list (num_nodes_this_proc);
Teuchos::Array<int_t> node_list_vectorized (num_nodes_this_proc * spa_dim);
DICe::mesh::node_set::const_iterator node_it = get_node_set()->begin();
DICe::mesh::node_set::const_iterator node_end = get_node_set()->end();
int_t node_index = 0;
for(;node_it!=node_end;++node_it)
{
node_list[node_index] = node_it->first;
for(int_t dim=0;dim<spa_dim;++dim)
{
const int_t index_stride = node_index * spa_dim + dim;
node_list_vectorized[index_stride] = node_it->first * spa_dim + dim;
}
node_index++;
}
scalar_node_overlap_map_ = Teuchos::rcp (new MultiField_Map(-1, node_list, indexBase, *comm_));
//std::cout << " SCALAR_NODE_OVERLAP MAP: " << std::endl;
//scalar_node_overlap_map_->describe();
vector_node_overlap_map_ = Teuchos::rcp (new MultiField_Map(-1, node_list_vectorized, indexBase, *comm_));
//std::cout << " VECTOR_NODE_OVERLAP MAP: " << std::endl;
//vector_node_overlap_map_->describe();
// ELEM DIST MAP AND VECTORIZED MAP
// This map should be 1-to-1
Teuchos::Array<int_t>::size_type num_elem_this_proc = num_elem();
Teuchos::Array<int_t> elem_list (num_elem_this_proc);
Teuchos::Array<int_t> elem_list_vectorized (num_elem_this_proc * spa_dim);
DICe::mesh::element_set::const_iterator elem_it = get_element_set()->begin();
DICe::mesh::element_set::const_iterator elem_end = get_element_set()->end();
int_t elem_index = 0;
for(;elem_it!=elem_end;++elem_it)
{
elem_list[elem_index] = elem_it->get()->global_id();
for(int_t dim=0;dim<spa_dim;++dim)
{
const int_t index_stride = elem_index * spa_dim + dim;
const int_t stride = elem_it->get()->global_id() * spa_dim + dim;
elem_list_vectorized[index_stride] = stride;
}
elem_index++;
}
scalar_elem_dist_map_ = Teuchos::rcp (new MultiField_Map(-1, elem_list, indexBase, *comm_));
//std::cout << " ELEM DIST MAP " << std::endl;
//scalar_elem_dist_map_->describe();
vector_elem_dist_map_ = Teuchos::rcp (new MultiField_Map(-1, elem_list_vectorized, indexBase, *comm_));
if(force_elem_and_node_maps_to_match){
scalar_node_dist_map_ = Teuchos::rcp(new MultiField_Map(-1,elem_list, indexBase, *comm_));
vector_node_dist_map_ = Teuchos::rcp(new MultiField_Map(-1,elem_list_vectorized, indexBase, *comm_));
}
else{
// go through all your local nodes, if the remote index list matches your processor then add it to the new_dist_list
// otherwise another proc will pick it up
const int_t total_num_nodes = scalar_node_overlap_map_->get_num_global_elements();
Teuchos::Array<int_t> nodeIDList(total_num_nodes);
Teuchos::Array<int_t> GIDList(total_num_nodes);
const int_t min_gid = scalar_node_overlap_map_->get_min_global_index();
//const int_t max_gid = scalar_node_overlap_map_->get_max_global_index();
Teuchos::Array<int_t> gids_on_this_proc;
Teuchos::Array<int_t> gids_on_this_proc_vectorized;
for(int_t i=0;i<total_num_nodes;++i)
{
GIDList[i] = min_gid + i;
}
scalar_node_overlap_map_->get_remote_index_list(GIDList,nodeIDList);
for(int_t i=0;i<total_num_nodes;++i)
{
if(nodeIDList[i]==p_rank) // only add the nodes that have this processor as their remote index
{
gids_on_this_proc.push_back(min_gid + i);
for(int_t dim=0;dim<spa_dim;++dim)
gids_on_this_proc_vectorized.push_back((min_gid + i)*spa_dim+dim);
}
}
scalar_node_dist_map_ = Teuchos::rcp(new MultiField_Map(-1,gids_on_this_proc, indexBase, *comm_));
//std::cout << " SCALAR_NODE_DIST MAP: " << std::endl;
//scalar_node_dist_map_->describe();
vector_node_dist_map_ = Teuchos::rcp(new MultiField_Map(-1,gids_on_this_proc_vectorized, indexBase, *comm_));
//std::cout << " VECTOR_NODE_DIST MAP: " << std::endl;
//vector_node_dist_map->describe();
}
//std::cout << " SCALAR_NODE_DIST MAP: " << std::endl;
//scalar_node_dist_map_->describe();
for(node_it = get_node_set()->begin(); node_it!=node_end;++node_it)
{
// since the map used by exodus for the nodes is the overlap map (nodes appear on multiple processors)
// the local id as created by exodus is really the overlap_local_id. Here the local_id gets saved
// off as it should in the overlap_local_id member data, and later we replace the local_id data
// with the true local_id from the distributed map
node_it->second->update_overlap_local_id(node_it->second->local_id());
// replace the local id with the value corresponding to the dist map
// NOTE some will be -1 if they are not locally owned
node_it->second->update_local_id(scalar_node_dist_map_->get_local_element(node_it->first));
}
}
void
Mesh::create_face_cell_field_maps(){
DEBUG_MSG("Creating the face field maps for the mesh");
const int_t indexBase = 0;
const int_t spa_dim = spatial_dimension();
DICe::mesh::element_set::const_iterator elem_it = get_element_set()->begin();
DICe::mesh::element_set::const_iterator elem_end = get_element_set()->end();
// INTERNAL CELL DISTRIBUTION MAPS
bool post_warning = false;
// count up the number of faces/cells per element:
Teuchos::Array<int_t>::size_type num_faces_this_proc = 0;
Teuchos::Array<int_t>::size_type num_cells_this_proc = 0;
// search all the elements for thier element type
elem_it = get_element_set()->begin();
for(;elem_it!=elem_end;++elem_it)
{
Teuchos::RCP<DICe::mesh::Element> elem = *elem_it;
const Base_Element_Type elem_type = get_block_type_map()->find(elem_it->get()->block_id())->second;
if(elem_type == HEX8)
{
num_faces_this_proc+=6*6;
num_cells_this_proc+=6*4;
}
else if(elem_type == TETRA4 || elem_type == TETRA) // FIXME: we should only accept tetra4, tetra is a poor selection in cubit
{
num_faces_this_proc+=6;
num_cells_this_proc+=4;
}
else if(elem_type == QUAD4)
{
num_faces_this_proc+=6;
num_cells_this_proc+=6;
}
else if(elem_type == TRI3 || elem_type ==TRI6)
{
num_faces_this_proc+=3;
num_cells_this_proc+=3;
}
else if(elem_type == PYRAMID5)
post_warning = true;
else if(elem_type == SPHERE) // sphere gets you kicked out of this method
return;
else
{
std::stringstream oss;
oss << "create_field(): unknown element type: " << tostring(elem_type) << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,oss.str());
}
}
if(post_warning)
std::cout << " WARNING: Subelement distribution maps will not be created for PYRAMID5 elements" << std::endl;
scalar_cell_dist_map_ = Teuchos::rcp (new MultiField_Map(-1,num_cells_this_proc, indexBase, *comm_));
//std::cout << " SCALAR CELL DIST MAP " << std::endl;
//scalar_cell_dist_map->describe();
vector_cell_dist_map_ = Teuchos::rcp (new MultiField_Map(-1,num_cells_this_proc*spa_dim, indexBase, *comm_));
//std::cout << " VECTOR CELL DIST MAP " << std::endl;
//vector_cell_dist_map->describe();
//int_t num_boundary_faces_this_proc = 0;
// gather up all the external faces and add them to the list:
std::set<std::pair<int_t,int_t> > elem_face_pairs;
const int_t num_sets = side_set_info_.ids.size();
for(int_t id_it=1;id_it<=num_sets;++id_it){
const int_t set_index = side_set_info_.get_set_index(id_it);
const int_t num_sides_this_set = side_set_info_.num_side_per_set[set_index];
const int_t start_index = side_set_info_.elem_ind[set_index];
for(int_t i=0;i<num_sides_this_set;++i){
const int_t side_index = start_index+i;
const int_t elem_gid = side_set_info_.ss_global_elem_list[side_index];
const int_t side_id = side_set_info_.ss_side_list[side_index];
// check if this elem is local to this process:
if(scalar_elem_dist_map_->get_local_element(elem_gid)<0) continue;
// add another face if the element is local to this process
TEUCHOS_TEST_FOR_EXCEPTION(elem_face_pairs.find(std::pair<int_t,int_t>(elem_gid,side_id))!=elem_face_pairs.end(),
std::runtime_error,"Error: Only one side set can be specified per element edge.");
elem_face_pairs.insert(std::pair<int_t,int_t>(elem_gid,side_id));
//num_boundary_faces_this_proc+=2; // each boundary face is split in two
num_faces_this_proc+=2; // each boundary face is split in two
}
}
//DEBUG_MSG("[" << p_rank << "] There are " << num_boundary_faces_this_proc << " boundary faces on this processor");
DEBUG_MSG("[" << get_comm()->get_rank() << "] There are " << num_faces_this_proc << " internal faces and " << num_cells_this_proc << " cells on this processor");
scalar_face_dist_map_ = Teuchos::rcp (new MultiField_Map(-1,num_faces_this_proc, indexBase, *comm_));
//std::cout << " SCALAR FACE DIST MAP " << std::endl;
//scalar_face_dist_map->describe();
vector_face_dist_map_ = Teuchos::rcp (new MultiField_Map(-1,num_faces_this_proc*spa_dim, indexBase, *comm_));
//std::cout << " VECTOR FACE DIST MAP " << std::endl;
//vector_face_dist_map->describe();
// scalar_boundary_face_dist_map_ = Teuchos::rcp (new MultiField_Map<int_t>(-1,num_faces_this_proc, indexBase, *comm_));
// vector_boundary_face_dist_map_ = Teuchos::rcp (new MultiField_Map<int_t>(-1,num_faces_this_proc*spa_dim, indexBase, *comm_));
// SUBELEMENT MAPS:
// count up the number of faces/cells per element:
Teuchos::Array<int_t>::size_type num_subelem_this_proc = 0;
post_warning = false;
// search all the elements for thier element type
elem_it = get_element_set()->begin();
for(;elem_it!=elem_end;++elem_it)
{
Teuchos::RCP<DICe::mesh::Element> elem = *elem_it;
const Base_Element_Type elem_type = get_block_type_map()->find(elem_it->get()->block_id())->second;
if(elem_type == HEX8)
num_subelem_this_proc+=6;
else if(elem_type == TETRA4 || elem_type == TETRA) // FIXME: we should only accept tetra4, tetra is a poor selection in cubit
num_subelem_this_proc+=1;
else if(elem_type == QUAD4)
num_subelem_this_proc+=2;
else if(elem_type == TRI3 || elem_type == TRI6)
num_subelem_this_proc+=1;
else if(elem_type == PYRAMID5)
post_warning = true;
else
{
std::stringstream oss;
oss << "create_subelem_dist_map(): unknown element type: " << tostring(elem_type) << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,oss.str());
}
}
if(post_warning)
std::cout << " WARNING: Subelement distribution maps will not be created for PYRAMID5 elements" << std::endl;
scalar_subelem_dist_map_ = Teuchos::rcp (new MultiField_Map(-1, num_subelem_this_proc, indexBase, *comm_));
//std::cout << "SCALAR SUBELEM MAP " << std::endl;
//scalar_subelem_dist_map->describe();
vector_subelem_dist_map_ = Teuchos::rcp (new MultiField_Map(-1, num_subelem_this_proc*spa_dim, indexBase, *comm_));
//std::cout << "VECTOR SUBELEM MAP " << std::endl;
//vector_subelem_dist_map->describe();
}
int_t
Mesh::num_elem_in_block(const int_t block_id)const
{
int_t num_elem = 0;
DICe::mesh::element_set::const_iterator elem_it = element_set_->begin();
DICe::mesh::element_set::const_iterator elem_end = element_set_->end();
for(;elem_it!=elem_end;++elem_it)
{
if(elem_it->get()->block_id()==block_id) num_elem++;
}
return num_elem;
}
Teuchos::RCP<Shape_Function_Evaluator> Shape_Function_Evaluator_Factory::create(const Base_Element_Type elem_type)
{
if(elem_type==CVFEM_TRI)
return Teuchos::rcp(new CVFEM_Linear_Tri3());
else if(elem_type==CVFEM_TETRA)
return Teuchos::rcp(new CVFEM_Linear_Tet4());
else if(elem_type==HEX8)
return Teuchos::rcp(new FEM_Linear_Hex8());
else if(elem_type==QUAD4)
return Teuchos::rcp(new FEM_Linear_Quad4());
else if(elem_type==TRI3)
return Teuchos::rcp(new FEM_Linear_Tri3());
else if(elem_type==TRI6)
return Teuchos::rcp(new FEM_Quadratic_Tri6());
else
{
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,"Shape_Function_Evaluator_Factory: invalid element type: " + tostring(elem_type));
}
}
bool
Mesh::field_exists(const std::string & field_name){
// only one field is allowed per field spec
field_registry::iterator field_it = field_registry_.begin();
field_registry::iterator field_end = field_registry_.end();
for(;field_it!=field_end;++field_it)
if(field_it->first.get_name_label()==field_name) return true;
return false;
}
void
Mesh::create_field(const field_enums::Field_Spec & field_spec)
{
// only one field is allowed per field spec
if(field_registry_.find(field_spec)!=field_registry_.end()) return;
Teuchos::RCP<MultiField_Map> map;
if(field_spec.get_rank()==field_enums::NODE_RANK && field_spec.get_field_type()==field_enums::SCALAR_FIELD_TYPE)
map = scalar_node_dist_map_;
else if(field_spec.get_rank()==field_enums::NODE_RANK && field_spec.get_field_type()==field_enums::VECTOR_FIELD_TYPE)
map = vector_node_dist_map_;
else if(field_spec.get_rank()==field_enums::NODE_RANK && field_spec.get_field_type()==field_enums::MIXED_VECTOR_FIELD_TYPE)
map = mixed_vector_node_dist_map_;
else if(field_spec.get_rank()==field_enums::ELEMENT_RANK && field_spec.get_field_type()==field_enums::VECTOR_FIELD_TYPE)
map = vector_elem_dist_map_;
else if(field_spec.get_rank()==field_enums::ELEMENT_RANK && field_spec.get_field_type()==field_enums::SCALAR_FIELD_TYPE)
map = scalar_elem_dist_map_;
else if(field_spec.get_rank()==field_enums::INTERNAL_CELL_RANK && field_spec.get_field_type()==field_enums::VECTOR_FIELD_TYPE)
map = vector_cell_dist_map_;
else if(field_spec.get_rank()==field_enums::INTERNAL_CELL_RANK && field_spec.get_field_type()==field_enums::SCALAR_FIELD_TYPE)
map = scalar_cell_dist_map_;
else if(field_spec.get_rank()==field_enums::INTERNAL_FACE_EDGE_RANK && field_spec.get_field_type()==field_enums::VECTOR_FIELD_TYPE)
map = vector_face_dist_map_;
else if(field_spec.get_rank()==field_enums::INTERNAL_FACE_EDGE_RANK && field_spec.get_field_type()==field_enums::SCALAR_FIELD_TYPE)
map = scalar_face_dist_map_;
//else if(field_spec.get_rank()==field_enums::EXTERNAL_FACE_EDGE_RANK && field_spec.get_field_type()==field_enums::VECTOR_FIELD_TYPE)
// map = vector_boundary_face_dist_map_;
//else if(field_spec.get_rank()==field_enums::EXTERNAL_FACE_EDGE_RANK && field_spec.get_field_type()==field_enums::SCALAR_FIELD_TYPE)
// map = scalar_boundary_face_dist_map_;
else if(field_spec.get_rank()==field_enums::SUBELEMENT_RANK && field_spec.get_field_type()==field_enums::VECTOR_FIELD_TYPE)
map = vector_subelem_dist_map_;
else if(field_spec.get_rank()==field_enums::SUBELEMENT_RANK && field_spec.get_field_type()==field_enums::SCALAR_FIELD_TYPE)
map = scalar_subelem_dist_map_;
else
{
std::stringstream oss;
oss << " MG_Mesh::create_field(): unknown rank and tensor order combination specified: " << DICe::tostring(field_spec.get_rank()) << " " << DICe::tostring(field_spec.get_field_type()) << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,oss.str());
}
Teuchos::RCP<MultiField> field_ptr = Teuchos::rcp(new MultiField(map,1,true));
field_registry_.insert(std::pair<field_enums::Field_Spec,Teuchos::RCP<MultiField > >(field_spec,field_ptr));
}
void
Mesh::re_register_field(const field_enums::Field_Spec & existing_field_spec,
const field_enums::Field_Spec & new_field_spec)
{
if(field_registry_.find(existing_field_spec)==field_registry_.end())
{
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,"Requested field does not exist" + existing_field_spec.get_name_label());
}
// double check that all the specs agree
TEUCHOS_TEST_FOR_EXCEPTION(existing_field_spec.get_field_type()!=new_field_spec.get_field_type(),std::invalid_argument,"Field types must agree.");
TEUCHOS_TEST_FOR_EXCEPTION(existing_field_spec.get_rank()!=new_field_spec.get_rank(),std::invalid_argument,"Field ranks must agree.");
Teuchos::RCP<MultiField > field = get_field(existing_field_spec);
field_registry_.insert(std::pair<field_enums::Field_Spec,Teuchos::RCP<MultiField > >(new_field_spec,field));
}
std::pair<field_enums::Field_Spec,Teuchos::RCP<MultiField> >
Mesh::get_field(const std::string & field_name)
{
// if the requested field spec has more than one state, always retrieve the state n_plus_one spec
// search the field specs of every field for this name:
field_registry::const_iterator reg_it = field_registry_.begin();
const field_registry::const_iterator reg_end = field_registry_.end();
bool field_found = false;
bool multi_state_field = false;
field_enums::Field_Spec fs;
for(;reg_it!=reg_end;++reg_it)
{
if(reg_it->first.get_name_label()==field_name)
{
if(field_found) multi_state_field = true;
field_found = true;
fs = reg_it->first;
}
}
if(field_found)
{
if(multi_state_field) fs.set_state(field_enums::STATE_N_PLUS_ONE);
return std::pair<field_enums::Field_Spec,Teuchos::RCP<MultiField > >(fs,field_registry_.find(fs)->second);
}
if(comm_->get_rank()==0) std::cout << " The following fields are defined: " << std::endl;
for(reg_it = field_registry_.begin();reg_it!=reg_end;++reg_it)
{
if(comm_->get_rank()==0) std::cout << " " << reg_it->first.get_name_label() << std::endl;
}
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,"Field was not found in the registry: " + field_name);
}
field_enums::Field_Spec
Mesh::get_field_spec(const std::string & field_name,
const field_enums::Field_State state){
// if the requested field spec has more than one state, always retrieve the state n_plus_one spec
// search the field specs of every field for this name:
field_registry::const_iterator reg_it = field_registry_.begin();
const field_registry::const_iterator reg_end = field_registry_.end();
bool field_found = false;
bool multi_state_field = false;
field_enums::Field_Spec fs;
for(;reg_it!=reg_end;++reg_it)
{
if(reg_it->first.get_name_label()==field_name)
{
if(field_found) multi_state_field = true;
field_found = true;
fs = reg_it->first;
}
}
if(field_found)
{
if(multi_state_field) fs.set_state(state);
return fs;
}
// if(comm_->get_rank()==0) std::cout << " The following fields are defined: " << std::endl;
// for(reg_it = field_registry_.begin();reg_it!=reg_end;++reg_it)
// {
// if(comm_->get_rank()==0) std::cout << " " << reg_it->first.get_name_label() << std::endl;
// }
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,"Field was not found in the registry: " + field_name);
}
std::vector<std::string>
Mesh::get_field_names(const field_enums::Entity_Rank entity_rank,
const field_enums::Field_Type field_type,
const bool only_the_printable)const
{
std::vector<std::string> names;
field_registry::const_iterator field_it = field_registry_.begin();
field_registry::const_iterator field_end = field_registry_.end();
for(;field_it!=field_end;++field_it)
{
if(field_it->first.get_field_type()==field_type && field_it->first.get_rank()==entity_rank)
{
if(!field_it->first.is_printable()&&only_the_printable) continue;
names.push_back(field_it->first.get_name_label());
}
}
return names;
}
Teuchos::RCP<MultiField >
Mesh::get_overlap_field(const field_enums::Field_Spec & field_spec)
{
Teuchos::RCP<MultiField_Map> map;
if(field_spec.get_rank()==field_enums::NODE_RANK && field_spec.get_field_type()==field_enums::SCALAR_FIELD_TYPE)
map = scalar_node_overlap_map_;
else if(field_spec.get_rank()==field_enums::NODE_RANK && field_spec.get_field_type()==field_enums::VECTOR_FIELD_TYPE)
map = vector_node_overlap_map_;
else if(field_spec.get_rank()==field_enums::NODE_RANK && field_spec.get_field_type()==field_enums::MIXED_VECTOR_FIELD_TYPE)
map = mixed_vector_node_overlap_map_;
else
{
std::stringstream oss;
oss << " MG_Mesh::get_overlap_field(): unknown rank and tensor order combination specified: " << DICe::tostring(field_spec.get_rank()) << " " << DICe::tostring(field_spec.get_field_type()) << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,oss.str());
}
const Teuchos::RCP<MultiField > to_field = field_import(field_spec,map);
return to_field;
}
Teuchos::RCP<MultiField>
Mesh::field_import(const field_enums::Field_Spec & field_spec,
Teuchos::RCP<MultiField_Map> to_map)
{
Teuchos::RCP<MultiField > from_field = field_registry_.find(field_spec)->second;
Teuchos::RCP<MultiField > field_gather = Teuchos::rcp( new MultiField(to_map,1,true)); // FIXME: need to check this should be one
MultiField_Exporter exporter(*to_map,*from_field->get_map());
//export_type exporter (to_map->get(),from_field->get_map()->get());
field_gather->do_import(from_field,exporter);
//field_gather->get()->doImport((*from_field->get()), exporter, Tpetra::INSERT);
return field_gather;
}
void
Mesh::field_overlap_export(const Teuchos::RCP<MultiField > from_field,
const field_enums::Field_Spec & to_field_spec,
const Combine_Mode mode)
{
Teuchos::RCP<MultiField_Map> map;
if(to_field_spec.get_rank()==field_enums::NODE_RANK && to_field_spec.get_field_type()==field_enums::SCALAR_FIELD_TYPE)
map = scalar_node_overlap_map_;
else if(to_field_spec.get_rank()==field_enums::NODE_RANK && to_field_spec.get_field_type()==field_enums::VECTOR_FIELD_TYPE)
map = vector_node_overlap_map_;
else if(to_field_spec.get_rank()==field_enums::NODE_RANK && to_field_spec.get_field_type()==field_enums::MIXED_VECTOR_FIELD_TYPE)
map = mixed_vector_node_overlap_map_;
else{
std::stringstream oss;
oss << " MG_Mesh::field_overlap_export(): unknown rank and tensor order combination specified: " << DICe::tostring(to_field_spec.get_rank()) << " " << DICe::tostring(to_field_spec.get_field_type()) << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,oss.str());
}
if(field_registry_.find(to_field_spec)==field_registry_.end()){
std::stringstream oss;
oss << " MG_Mesh::field_overlap_export(): could not find the destination field: " << to_field_spec.get_name_label() << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,oss.str());
}
Teuchos::RCP<MultiField > to_field = field_registry_.find(to_field_spec)->second;
//export_type exporter (map->get(),to_field->get_map()->get());
MultiField_Exporter exporter(*map,*to_field->get_map());
to_field->do_export(from_field,exporter,mode);
// to_field->get()->doExport((*from_field->get()), exporter, mode);
}
void
Mesh::print_field_info()
{
if(comm_->get_rank()!=0) return;
#ifndef DICE_DEBUG_MSG
return;
#endif
std::cout << " =============== REGISTERED NODAL SCALAR FIELDS ===============" << std::endl;
std::vector<std::string> nodal_scalar_fields = get_field_names(field_enums::NODE_RANK,field_enums::SCALAR_FIELD_TYPE,false);
for (size_t i = 0; i < nodal_scalar_fields.size(); ++i){
std::cout << " " << nodal_scalar_fields[i] << std::endl;
}
std::cout << " =============== REGISTERED NODAL VECTOR FIELDS ===============" << std::endl;
std::vector<std::string> nodal_vector_fields = get_field_names(field_enums::NODE_RANK,field_enums::VECTOR_FIELD_TYPE,false);
for (size_t i = 0; i < nodal_vector_fields.size(); ++i){
for(int_t j=0; j<spatial_dimension();++j)
std::cout << " " << nodal_vector_fields[i] + index_to_component_string(j) << std::endl;
}
std::cout << " ============== REGISTERED NODAL MIXED VECTOR FIELDS ==========" << std::endl;
std::vector<std::string> mixed_nodal_vector_fields = get_field_names(field_enums::NODE_RANK,field_enums::MIXED_VECTOR_FIELD_TYPE,false);
for (size_t i = 0; i < mixed_nodal_vector_fields.size(); ++i){
for(int_t j=0; j<spatial_dimension();++j)
std::cout << " " << mixed_nodal_vector_fields[i] + index_to_component_string(j) << std::endl;
std::cout << " " << mixed_nodal_vector_fields[i] + "LAM" << std::endl;
}
std::cout << " ============== REGISTERED ELEMENT SCALAR FIELDS ==============" << std::endl;
std::vector<std::string> element_scalar_fields = get_field_names(field_enums::ELEMENT_RANK,field_enums::SCALAR_FIELD_TYPE,false);
for (size_t i = 0; i < element_scalar_fields.size(); ++i){
std::cout << " " << element_scalar_fields[i] << std::endl;
}
std::cout << " ============== REGISTERED ELEMENT VECTOR FIELDS ==============" << std::endl;
std::vector<std::string> element_vector_fields = get_field_names(field_enums::ELEMENT_RANK,field_enums::VECTOR_FIELD_TYPE,false);
for (size_t i = 0; i < element_vector_fields.size(); ++i){
for(int_t j=0; j<spatial_dimension();++j)
std::cout << " " << element_vector_fields[i] + index_to_component_string(j) << std::endl;
}
std::cout << " ============== REGISTERED FACE EDGE SCALAR FIELDS ============" << std::endl;
std::vector<std::string> face_scalar_fields = get_field_names(field_enums::INTERNAL_FACE_EDGE_RANK,field_enums::SCALAR_FIELD_TYPE,false);
for (size_t i = 0; i < face_scalar_fields.size(); ++i){
std::cout << " " << face_scalar_fields[i] << std::endl;
}
std::cout << " ============== REGISTERED FACE EDGE VECTOR FIELDS ============" << std::endl;
std::vector<std::string> face_vector_fields = get_field_names(field_enums::INTERNAL_FACE_EDGE_RANK,field_enums::VECTOR_FIELD_TYPE,false);
for (size_t i = 0; i < face_vector_fields.size(); ++i){
for(int_t j=0; j<spatial_dimension();++j)
std::cout << " " << face_vector_fields[i] + index_to_component_string(j) << std::endl;
}
//std::cout << " ============== REGISTERED BOUNDARY FACE EDGE SCALAR FIELDS ==============" << std::endl;
//std::vector<std::string> ex_face_scalar_fields = get_field_names(field_enums::EXTERNAL_FACE_EDGE_RANK,field_enums::SCALAR_FIELD_TYPE,false);
//for (int_t i = 0; i < ex_face_scalar_fields.size(); ++i){
// std::cout << " " << ex_face_scalar_fields[i] << std::endl;
//}
//std::cout << " ============== REGISTERED BOUNDARY FACE EDGE VECTOR FIELDS ==============" << std::endl;
//std::vector<std::string> ex_face_vector_fields = get_field_names(field_enums::EXTERNAL_FACE_EDGE_RANK,field_enums::VECTOR_FIELD_TYPE,false);
//for (int_t i = 0; i < ex_face_vector_fields.size(); ++i){
// for(int_t j=0; j<spatial_dimension();++j)
// std::cout << " " << ex_face_vector_fields[i] + index_to_component_string(j) << std::endl;
//}
std::cout << " --------------------------------------------------------------------------------------" << std::endl;
}
scalar_t
Mesh::field_stats(const field_enums::Field_Spec & field_spec,
scalar_t & min,
scalar_t & max,
scalar_t & avg,
scalar_t & std_dev,
const int_t comp,
const field_enums::Field_Spec & marker_spec,
const scalar_t & threshold){
std::vector<std::string> comps;
comps.push_back("_X");
comps.push_back("_Y");
field_registry::const_iterator field_it = field_registry_.find(field_spec);
TEUCHOS_TEST_FOR_EXCEPTION(field_it==field_registry_.end(),std::runtime_error,
"Error, invalid field " << field_spec.get_name_label());
const int_t p_rank = comm_->get_rank();
const bool has_marker = marker_spec != DICe::field_enums::NO_SUCH_FS;
scalar_t failure_rate = 0.0;
max = std::numeric_limits<scalar_t>::lowest();
min = std::numeric_limits<scalar_t>::max();
avg = 0.0;
std_dev = 0.0;
// Send the whole field to procesor 0
// create all on zero map
Teuchos::RCP<MultiField> field = field_it->second;
const int_t num_values = field->get_map()->get_num_global_elements();
Teuchos::Array<int_t> all_on_zero_ids;
if(p_rank==0){
all_on_zero_ids.resize(num_values);
for(int_t i=0;i<num_values;++i)
all_on_zero_ids[i] = i;
}
Teuchos::RCP<MultiField_Map> all_on_zero_map = Teuchos::rcp (new MultiField_Map(-1, all_on_zero_ids, 0, *comm_));
Teuchos::RCP<MultiField> all_on_zero_field = Teuchos::rcp( new MultiField(all_on_zero_map,1,true));
// create exporter with the map
MultiField_Exporter exporter(*all_on_zero_map,*field->get_map());
// export the field to zero
all_on_zero_field->do_import(field,exporter);
// bring in the marker field
Teuchos::RCP<MultiField> marker_on_zero_field;
Teuchos::RCP<MultiField_Map> marker_on_zero_map;
Teuchos::Array<int_t> marker_on_zero_ids;
if(has_marker){
field_registry::const_iterator marker_it = field_registry_.find(marker_spec);
TEUCHOS_TEST_FOR_EXCEPTION(marker_it==field_registry_.end(),std::runtime_error,
"Error, invalid marker field " << marker_spec.get_name_label());
Teuchos::RCP<MultiField> marker_field = marker_it->second;
// for a scalar field the array list above can be reused
if(field_spec.get_field_type()==DICe::field_enums::SCALAR_FIELD_TYPE){
marker_on_zero_map = Teuchos::rcp (new MultiField_Map(-1, all_on_zero_ids, 0, *comm_));
}else{
if(p_rank==0){
marker_on_zero_ids.resize(marker_field->get_map()->get_num_global_elements());
for(int_t i=0;i<marker_field->get_map()->get_num_global_elements();++i)
marker_on_zero_ids[i] = i;
}
marker_on_zero_map = Teuchos::rcp (new MultiField_Map(-1, marker_on_zero_ids, 0, *comm_));
}
marker_on_zero_field = Teuchos::rcp( new MultiField(marker_on_zero_map,1,true));
// create exporter with the map
MultiField_Exporter exporter_marker(*marker_on_zero_map,*marker_field->get_map());
// export the field to zero
marker_on_zero_field->do_import(marker_field,exporter_marker);
}
// analyze stats
int_t num_failed = 0;
const int_t num_points = all_on_zero_field->get_map()->get_num_local_elements();
TEUCHOS_TEST_FOR_EXCEPTION(num_points > 0 && p_rank > 0,std::runtime_error,"Error, only process zero should have any points here");
if(field_spec.get_field_type()==DICe::field_enums::SCALAR_FIELD_TYPE){
TEUCHOS_TEST_FOR_EXCEPTION(comp!=0,std::runtime_error,"Error, invalid comp for scalar field")
TEUCHOS_TEST_FOR_EXCEPTION(p_rank==0 && num_points<=0,std::runtime_error,"Error, num_points = 0");
for(int_t i=0;i<num_points;++i){
if(has_marker){
if(marker_on_zero_field->local_value(i)<=threshold){
num_failed++;
continue;
}
}
avg += all_on_zero_field->local_value(i);
if(all_on_zero_field->local_value(i)>max) max = all_on_zero_field->local_value(i);
if(all_on_zero_field->local_value(i)<min) min = all_on_zero_field->local_value(i);
}
if(num_points - num_failed > 0)
avg /= num_points-num_failed==0?1.0:(num_points-num_failed);
for(int_t i=0;i<num_points;++i){
if(has_marker){
if(marker_on_zero_field->local_value(i)<=threshold){
continue;
}
}
std_dev += (all_on_zero_field->local_value(i)-avg)*(all_on_zero_field->local_value(i)-avg);
}
if(num_points-num_failed > 0)
std_dev = num_points-num_failed==0?0.0:std::sqrt(std_dev/(num_points-num_failed));
}
else if(field_spec.get_field_type()==DICe::field_enums::VECTOR_FIELD_TYPE){
TEUCHOS_TEST_FOR_EXCEPTION(comp!=0&&comp!=1,std::runtime_error,"Error, invalid comp for scalar field")
for(int_t i=0;i<num_points/2;++i){
if(has_marker){
if(marker_on_zero_field->local_value(i)<=threshold){
num_failed++;
continue;
}
}
int_t index = i*spatial_dimension() + comp;
avg += all_on_zero_field->local_value(index);
if(all_on_zero_field->local_value(index)>max) max = all_on_zero_field->local_value(index);
if(all_on_zero_field->local_value(index)<min) min = all_on_zero_field->local_value(index);
}
if(num_points - num_failed> 0)
avg /= num_points-num_failed==0?1.0:(num_points-num_failed)*0.5;
for(int_t i=0;i<num_points/2;++i){
int_t index = i*spatial_dimension() + comp;
if(has_marker){
if(marker_on_zero_field->local_value(i)<=threshold){
continue;
}
}
std_dev += (all_on_zero_field->local_value(index)-avg)*(all_on_zero_field->local_value(index)-avg);
}
if(num_points - num_failed > 0)
std_dev = num_points-num_failed==0?0.0:std::sqrt(std_dev/(0.5*(num_points-num_failed)));
}
else{
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Error: unknown field type in stats call");
}
// communicate results back to dist procs
Teuchos::Array<int_t> results_on_zero_ids;
if(p_rank==0){
results_on_zero_ids.resize(5);
for(int_t i=0;i<5;++i)
results_on_zero_ids[i] = i;
}
// create a field to send out the results to the other procs:
Teuchos::RCP<MultiField_Map> results_on_zero_map = Teuchos::rcp (new MultiField_Map(-1, results_on_zero_ids, 0, *comm_));
Teuchos::RCP<MultiField> results_on_zero_field = Teuchos::rcp( new MultiField(results_on_zero_map,1,true));
// set the values on zero
if(p_rank==0){
results_on_zero_field->local_value(0) = min;
results_on_zero_field->local_value(1) = max;
results_on_zero_field->local_value(2) = avg;
results_on_zero_field->local_value(3) = std_dev;
results_on_zero_field->local_value(4) = num_failed / scalar_node_dist_map_->get_num_global_elements();
}
// create the all on all map
Teuchos::Array<int_t> results_on_all_ids;
results_on_all_ids.resize(5);
for(int_t i=0;i<5;++i)
results_on_all_ids[i] = i;
// create a field to send out the results to the other procs:
Teuchos::RCP<MultiField_Map> results_on_all_map = Teuchos::rcp (new MultiField_Map(-1, results_on_all_ids, 0, *comm_));
Teuchos::RCP<MultiField> results_on_all_field = Teuchos::rcp( new MultiField(results_on_all_map,1,true));
// create exporter with the map
MultiField_Exporter exporter_res(*results_on_all_map,*results_on_zero_field->get_map());
// export the field to zero
results_on_all_field->do_import(results_on_zero_field,exporter_res);
if(p_rank==0){
TEUCHOS_TEST_FOR_EXCEPTION(results_on_all_field->local_value(0)!=min,std::runtime_error,"Error miscommunication of field stats across processors");
TEUCHOS_TEST_FOR_EXCEPTION(results_on_all_field->local_value(1)!=max,std::runtime_error,"Error miscommunication of field stats across processors");
TEUCHOS_TEST_FOR_EXCEPTION(results_on_all_field->local_value(2)!=avg,std::runtime_error,"Error miscommunication of field stats across processors");
TEUCHOS_TEST_FOR_EXCEPTION(results_on_all_field->local_value(3)!=std_dev,std::runtime_error,"Error miscommunication of field stats across processors");
}else{
min = results_on_all_field->local_value(0);
max = results_on_all_field->local_value(1);
avg = results_on_all_field->local_value(2);
std_dev = results_on_all_field->local_value(3);
}
failure_rate = results_on_all_field->local_value(4);
return failure_rate;
}
void
Mesh::print_field_stats()
{
if(comm_->get_rank()!=0) return;
std::cout.fill('*');
std::cout.width(90);
std::cout << "*" << std::endl;
std::cout.fill(' ');
std::cout.width(30);
std::cout << "Field";
std::cout.width(15);
std::cout << "Max";
std::cout.width(15);
std::cout << "Min";
std::cout.width(15);
std::cout << "Avg";
std::cout.width(15);
std::cout << "Std Dev" << std::endl;
std::cout.width(90);
std::cout.fill('-');
std::cout << "-" << std::endl;
std::cout.fill(' ');
std::vector<std::string> comps;
comps.push_back("_X");
comps.push_back("_Y");
// iterate the fields
std::vector<std::string> names;
field_registry::const_iterator field_it = field_registry_.begin();
field_registry::const_iterator field_end = field_registry_.end();
for(;field_it!=field_end;++field_it)
{
if(!field_it->first.is_printable())continue;
if(field_it->first.get_field_type()==DICe::field_enums::SCALAR_FIELD_TYPE){
scalar_t max = 0.0;
scalar_t min = 0.0;
scalar_t avg = 0.0;
scalar_t std_dev = 0.0;
field_stats(field_it->first,min,max,avg,std_dev,0);
std::cout.width(30);
std::cout << field_it->first.get_name_label();
std::cout.width(15);
std::cout << max;
std::cout.width(15);
std::cout << min;
std::cout.width(15);
std::cout << avg;
std::cout.width(15);
std::cout << std_dev << std::endl;
}
else if(field_it->first.get_field_type()==DICe::field_enums::VECTOR_FIELD_TYPE){
for(int_t dim=0;dim<spatial_dimension();++dim){
scalar_t max = 0.0;
scalar_t min = 0.0;
scalar_t avg = 0.0;
scalar_t std_dev = 0.0;
field_stats(field_it->first,min,max,avg,std_dev,dim);
std::cout.width(30);
std::cout << field_it->first.get_name_label() + comps[dim];
std::cout.width(15);
std::cout << max;
std::cout.width(15);
std::cout << min;
std::cout.width(15);
std::cout << avg;
std::cout.width(15);
std::cout << std_dev << std::endl;
}
}
}
std::cout.fill('*');
std::cout.width(90);
std::cout << "*" << std::endl;
std::cout.fill(' ');
}
bool
CVFEM_Linear_Tri3::is_in_element(const scalar_t * nodal_coords,
const scalar_t * point_coords,
const scalar_t & coefficient){
const scalar_t A[] = {point_coords[0], point_coords[1]};
scalar_t B[2], C[2];
scalar_t area=0.0;
scalar_t sum_area=0.0;
// N1 = Area p23/A
B[0] = nodal_coords[2];
B[1] = nodal_coords[3];
C[0] = nodal_coords[4];
C[1] = nodal_coords[5];
area = cross(&A[0],&B[0],&C[0]);
area = 0.5 * std::abs(area);
sum_area += area;
// N2 = Area p13/A
B[0] = nodal_coords[0];
B[1] = nodal_coords[1];
C[0] = nodal_coords[4];
C[1] = nodal_coords[5];
area = cross(&A[0],&B[0],&C[0]);
area = 0.5 * std::abs(area);
sum_area += area;
// N3 = Area p12/A
B[0] = nodal_coords[0];
B[1] = nodal_coords[1];
C[0] = nodal_coords[2];
C[1] = nodal_coords[3];
area = cross(&A[0],&B[0],&C[0]);
area = 0.5 * std::abs(area);
sum_area += area;
if(std::abs(sum_area - coefficient)<1E-4)
return true;
else
return false;
}
void
CVFEM_Linear_Tri3::get_natural_integration_points(const int_t order,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & locations,
Teuchos::ArrayRCP<scalar_t> & weights,
int_t & num_points){
tri3d_natural_integration_points(order,locations,weights,num_points);
}
void
CVFEM_Linear_Tri3::evaluate_shape_functions(const scalar_t * nodal_coords,
const scalar_t * point_coords,
const scalar_t & coefficient,
scalar_t * shape_function_values)
{
const scalar_t A[] = {point_coords[0], point_coords[1]};
scalar_t B[2], C[2];
scalar_t area=0.0;
scalar_t sum_area=0.0;
// N1 = Area p23/A
B[0] = nodal_coords[2];
B[1] = nodal_coords[3];
C[0] = nodal_coords[4];
C[1] = nodal_coords[5];
area = cross(&A[0],&B[0],&C[0]);
area = 0.5 * std::abs(area);
sum_area += area;
shape_function_values[0] = area/coefficient;
// N2 = Area p13/A
B[0] = nodal_coords[0];
B[1] = nodal_coords[1];
C[0] = nodal_coords[4];
C[1] = nodal_coords[5];
area = cross(&A[0],&B[0],&C[0]);
area = 0.5 * std::abs(area);
sum_area += area;
shape_function_values[1] = area/coefficient;
// N3 = Area p12/A
B[0] = nodal_coords[0];
B[1] = nodal_coords[1];
C[0] = nodal_coords[2];
C[1] = nodal_coords[3];
area = cross(&A[0],&B[0],&C[0]);
area = 0.5 * std::abs(area);
sum_area += area;
shape_function_values[2] = area/coefficient;
// check that the shape functions sum to one at the point
//stringstream oss;
//std::cout << " sum_area: " << sum_area << " coefficient: " << coefficient << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(std::abs(sum_area - coefficient)>1E-3,std::logic_error,"Areas do not sum to total subelem area."); // + oss.str());
}
void
CVFEM_Linear_Tri3::evaluate_shape_function_derivatives(const scalar_t * nodal_coords,
const scalar_t & coefficient,
scalar_t * shape_function_derivative_values)
{
const scalar_t x1 = nodal_coords[0];
const scalar_t y1 = nodal_coords[1];
const scalar_t x2 = nodal_coords[2];
const scalar_t y2 = nodal_coords[3];
const scalar_t x3 = nodal_coords[4];
const scalar_t y3 = nodal_coords[5];
shape_function_derivative_values[0] = (y2-y3)/(2.0*coefficient);
shape_function_derivative_values[1] = (x3-x2)/(2.0*coefficient);
shape_function_derivative_values[2] = (y3-y1)/(2.0*coefficient);
shape_function_derivative_values[3] = (x1-x3)/(2.0*coefficient);
shape_function_derivative_values[4] = (y1-y2)/(2.0*coefficient);
shape_function_derivative_values[5] = (x2-x1)/(2.0*coefficient);
}
void
CVFEM_Linear_Tet4::evaluate_shape_functions(const scalar_t * nodal_coords,
const scalar_t * point_coords,
const scalar_t & coefficient,
scalar_t * shape_function_values)
{
assert(coefficient!=0.0);
scalar_t volume = 0.0;
scalar_t sum_volume = 0.0;
scalar_t det = 0.0;
scalar_t a[4*4];
// N1 = Volume XABC / Volume IABC
for(int_t i=0;i<3;++i)
{
a[i+0*4] = nodal_coords[1*3+i];
a[i+1*4] = nodal_coords[2*3+i];
a[i+2*4] = nodal_coords[3*3+i];
a[i+3*4] = point_coords[i];
}
for (int_t j = 0; j < 4; j++ )
{
a[3+j*4] = 1.0;
}
det = determinant_4x4(&a[0]);
volume = std::abs(det) / 6.0;
sum_volume+=volume;
shape_function_values[0] = volume/coefficient;
// N2
for(int_t i=0;i<3;++i)
{
a[i+0*4] = nodal_coords[0*3+i];
a[i+1*4] = nodal_coords[2*3+i];
a[i+2*4] = nodal_coords[3*3+i];
a[i+3*4] = point_coords[i];
}
for (int_t j = 0; j < 4; j++ )
{
a[3+j*4] = 1.0;
}
det = determinant_4x4(&a[0]);
volume = std::abs(det) / 6.0;
sum_volume+=volume;
shape_function_values[1] = volume/coefficient;
// N3
for(int_t i=0;i<3;++i)
{
a[i+0*4] = nodal_coords[0*3+i];
a[i+1*4] = nodal_coords[1*3+i];
a[i+2*4] = nodal_coords[3*3+i];
a[i+3*4] = point_coords[i];
}
for (int_t j = 0; j < 4; j++ )
{
a[3+j*4] = 1.0;
}
det = determinant_4x4(&a[0]);
volume = std::abs(det) / 6.0;
sum_volume+=volume;
shape_function_values[2] = volume/coefficient;
// N4
for(int_t i=0;i<3;++i)
{
a[i+0*4] = nodal_coords[0*3+i];
a[i+1*4] = nodal_coords[1*3+i];
a[i+2*4] = nodal_coords[2*3+i];
a[i+3*4] = point_coords[i];
}
for (int_t j = 0; j < 4; j++ )
{
a[3+j*4] = 1.0;
}
det = determinant_4x4(&a[0]);
volume = std::abs(det) / 6.0;
sum_volume+=volume;
shape_function_values[3] = volume/coefficient;
//stringstream oss;
//oss << " sum_volume: " << sum_volume << " coefficient: " << coefficient << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(std::abs(sum_volume - coefficient)>1E-3,std::logic_error,"Areas do not sum to total subelem area.");// + oss.str());
}
bool
CVFEM_Linear_Tet4::is_in_element(const scalar_t * nodal_coords,
const scalar_t * point_coords,
const scalar_t & coefficient)
{
scalar_t volume = 0.0;
scalar_t sum_volume = 0.0;
scalar_t det = 0.0;
scalar_t a[4*4];
// N1 = Volume XABC / Volume IABC
for(int_t i=0;i<3;++i)
{
a[i+0*4] = nodal_coords[1*3+i];
a[i+1*4] = nodal_coords[2*3+i];
a[i+2*4] = nodal_coords[3*3+i];
a[i+3*4] = point_coords[i];
}
for (int_t j = 0; j < 4; j++ )
{
a[3+j*4] = 1.0;
}
det = determinant_4x4(&a[0]);
volume = std::abs(det) / 6.0;
sum_volume+=volume;
// N2
for(int_t i=0;i<3;++i)
{
a[i+0*4] = nodal_coords[0*3+i];
a[i+1*4] = nodal_coords[2*3+i];
a[i+2*4] = nodal_coords[3*3+i];
a[i+3*4] = point_coords[i];
}
for (int_t j = 0; j < 4; j++ )
{
a[3+j*4] = 1.0;
}
det = determinant_4x4(&a[0]);
volume = std::abs(det) / 6.0;
sum_volume+=volume;
// N3
for(int_t i=0;i<3;++i)
{
a[i+0*4] = nodal_coords[0*3+i];
a[i+1*4] = nodal_coords[1*3+i];
a[i+2*4] = nodal_coords[3*3+i];
a[i+3*4] = point_coords[i];
}
for (int_t j = 0; j < 4; j++ )
{
a[3+j*4] = 1.0;
}
det = determinant_4x4(&a[0]);
volume = std::abs(det) / 6.0;
sum_volume+=volume;
// N4
for(int_t i=0;i<3;++i)
{
a[i+0*4] = nodal_coords[0*3+i];
a[i+1*4] = nodal_coords[1*3+i];
a[i+2*4] = nodal_coords[2*3+i];
a[i+3*4] = point_coords[i];
}
for (int_t j = 0; j < 4; j++ )
{
a[3+j*4] = 1.0;
}
det = determinant_4x4(&a[0]);
volume = std::abs(det) / 6.0;
sum_volume+=volume;
if(std::abs(sum_volume - coefficient)<1E-4)
return true;
else
return false;
}
void
CVFEM_Linear_Tet4::evaluate_shape_function_derivatives(const scalar_t * nodal_coords,
const scalar_t & coefficient,
scalar_t * shape_function_derivative_values)
{
scalar_t A[3];
scalar_t B[3];
scalar_t C[3];
scalar_t I[3];
scalar_t cross[3];
assert(coefficient!=0.0);
for(int_t i=0;i<3;++i)
{
I[i] = nodal_coords[i];
A[i] = nodal_coords[1*3+i];
B[i] = nodal_coords[2*3+i];
C[i] = nodal_coords[3*3+i];
}
const scalar_t coefficient_times_6 = coefficient * 6.0;
// Derivs at node 0
// -[(B-A)x(C-A)]_0 / T_I
// -[(B-A)x(C-A)]_1 / T_I
// -[(B-A)x(C-A)]_2 / T_I
cross3d_with_cross_prod(&A[0],&B[0],&C[0],&cross[0]);
shape_function_derivative_values[0] = -1.0*cross[0]/coefficient_times_6;
shape_function_derivative_values[1] = -1.0*cross[1]/coefficient_times_6;
shape_function_derivative_values[2] = -1.0*cross[2]/coefficient_times_6;
// -[(C-B)x(I-B)]_0 / T_A
// -[(C-B)x(I-B)]_1 / T_A
// -[(C-B)x(I-B)]_2 / T_A
cross3d_with_cross_prod(&B[0],&C[0],&I[0],&cross[0]);
shape_function_derivative_values[3] = 1.0*cross[0]/coefficient_times_6;
shape_function_derivative_values[4] = 1.0*cross[1]/coefficient_times_6;
shape_function_derivative_values[5] = 1.0*cross[2]/coefficient_times_6;
// -[(I-C)x(A-C)]_0 / T_B
// -[(I-C)x(A-C)]_1 / T_B
// -[(I-C)x(A-C)]_2 / T_B
cross3d_with_cross_prod(&C[0],&I[0],&A[0],&cross[0]);
shape_function_derivative_values[6] = -1.0*cross[0]/coefficient_times_6;
shape_function_derivative_values[7] = -1.0*cross[1]/coefficient_times_6;
shape_function_derivative_values[8] = -1.0*cross[2]/coefficient_times_6
;
// -[(A-I)x(B-I)]_0 / T_C
// -[(A-I)x(B-I)]_1 / T_C
// -[(A-I)x(B-I)]_2 / T_C
cross3d_with_cross_prod(&I[0],&A[0],&B[0],&cross[0]);
shape_function_derivative_values[9] = 1.0*cross[0]/coefficient_times_6;
shape_function_derivative_values[10] = 1.0*cross[1]/coefficient_times_6;
shape_function_derivative_values[11] = 1.0*cross[2]/coefficient_times_6;
}
bool
FEM_Linear_Hex8::is_in_element(const scalar_t * nodal_coords,
const scalar_t * point_coords,
const scalar_t & coefficient){
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Method not implemented yet");
return false;
}
void
FEM_Linear_Hex8::get_natural_integration_points(const int_t order,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & locations,
Teuchos::ArrayRCP<scalar_t> & weights,
int_t & num_points){
//assert(order == 1 && "Error: only first order integration has been implemented");
const int_t spa_dim = 3;
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > kron_sol, zeta1, zeta2,weight1,weight2, temp_weights;
num_points = order*order*order;
locations.resize(num_points);
weights.resize(num_points);
kron_sol.resize(num_points);
for(int_t i=0;i<num_points;++i){
locations[i].resize(spa_dim);
kron_sol[i].resize(2);
}
int_t i=0,j=0,m=order,n=1;
// create a matrix of ones
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > ones;
ones.resize(m);
for(int_t i=0;i<m;++i)
ones[i].resize(n);
for(i=0;i<m;i++){
for(j=0;j<n;j++){
ones[i][j] = 1.0;
};
};
gauss_1D(zeta1, weight1, order);
gauss_2D(zeta2, weight2, order);
kron_sol = kronecker(ones,zeta2);
for(i=0;i<order*order*order;i++){
for(j=1;j<=2;j++){
locations[i][j] = kron_sol[i][j-1];
}
};
for(i=0;i<order;i++){
for(j=i*order*order;j<(i+1)*order*order;j++){
locations[j][0] = zeta1[i][0];
};
};
// for(int_t i=0;i<weight1.size();++i)
// for(int_t j=0;j<weight1[i].size();++j)
// std::cout << " weight1 " << i << " " << j << " " << weight1[i][j] << std::endl;
//
// for(int_t i=0;i<weight2.size();++i)
// for(int_t j=0;j<weight2[i].size();++j)
// std::cout << " weight2 " << i << " " << j << " " << weight2[i][j] << std::endl;
temp_weights = kronecker(weight1,weight2);
for(int_t i=0;i<num_points;++i)
weights[i] = temp_weights[i][0];
}
void
FEM_Linear_Hex8::evaluate_shape_functions(const scalar_t * natural_coords,
scalar_t * shape_function_values){
const scalar_t xi = natural_coords[0];
const scalar_t eta = natural_coords[1];
const scalar_t zeta = natural_coords[2];
shape_function_values[0] = (1.0/8.0) * (1-xi)*(1-eta)*(1+zeta);
shape_function_values[1] = (1.0/8.0) * (1-xi)*(1-eta)*(1-zeta);
shape_function_values[2] = (1.0/8.0) * (1-xi)*(1+eta)*(1-zeta);
shape_function_values[3] = (1.0/8.0) * (1-xi)*(1+eta)*(1+zeta);
shape_function_values[4] = (1.0/8.0) * (1+xi)*(1-eta)*(1+zeta);
shape_function_values[5] = (1.0/8.0) * (1+xi)*(1-eta)*(1-zeta);
shape_function_values[6] = (1.0/8.0) * (1+xi)*(1+eta)*(1-zeta);
shape_function_values[7] = (1.0/8.0) * (1+xi)*(1+eta)*(1+zeta);
}
void
FEM_Linear_Hex8::evaluate_shape_function_derivatives(const scalar_t * natural_coords,
scalar_t * shape_function_derivative_values){
const scalar_t xi = natural_coords[0];
const scalar_t eta = natural_coords[1];
const scalar_t zeta = natural_coords[2];
const int_t spa_dim = 3;
shape_function_derivative_values[0*spa_dim+0] = (-1.0/8.0)*(1+zeta)*(1-eta);
shape_function_derivative_values[1*spa_dim+0] = (-1.0/8.0)*(1-zeta)*(1-eta);
shape_function_derivative_values[2*spa_dim+0] = (-1.0/8.0)*(1-zeta)*(1+eta);
shape_function_derivative_values[3*spa_dim+0] = (-1.0/8.0)*(1+zeta)*(1+eta);
shape_function_derivative_values[4*spa_dim+0] = (1.0/8.0)*(1+zeta)*(1-eta);
shape_function_derivative_values[5*spa_dim+0] = (1.0/8.0)*(1-zeta)*(1-eta);
shape_function_derivative_values[6*spa_dim+0] = (1.0/8.0)*(1-zeta)*(1+eta);
shape_function_derivative_values[7*spa_dim+0] = (1.0/8.0)*(1+zeta)*(1+eta);
shape_function_derivative_values[0*spa_dim+1] = (-1.0/8.0)*(1+zeta)*(1-xi);
shape_function_derivative_values[1*spa_dim+1] = (-1.0/8.0)*(1-zeta)*(1-xi);
shape_function_derivative_values[2*spa_dim+1] = (1.0/8.0)*(1-zeta)*(1-xi);
shape_function_derivative_values[3*spa_dim+1] = (1.0/8.0)*(1+zeta)*(1-xi);
shape_function_derivative_values[4*spa_dim+1] = (-1.0/8.0)*(1+zeta)*(1+xi);
shape_function_derivative_values[5*spa_dim+1] = (-1.0/8.0)*(1-zeta)*(1+xi);
shape_function_derivative_values[6*spa_dim+1] = (1.0/8.0)*(1-zeta)*(1+xi);
shape_function_derivative_values[7*spa_dim+1] = (1.0/8.0)*(1+zeta)*(1+xi);
shape_function_derivative_values[0*spa_dim+2] = (1.0/8.0)*(1-eta)*(1-xi);
shape_function_derivative_values[1*spa_dim+2] = (-1.0/8.0)*(1-eta)*(1-xi);
shape_function_derivative_values[2*spa_dim+2] = (-1.0/8.0)*(1+eta)*(1-xi);
shape_function_derivative_values[3*spa_dim+2] = (1.0/8.0)*(1+eta)*(1-xi);
shape_function_derivative_values[4*spa_dim+2] = (1.0/8.0)*(1-eta)*(1+xi);
shape_function_derivative_values[5*spa_dim+2] = (-1.0/8.0)*(1-eta)*(1+xi);
shape_function_derivative_values[6*spa_dim+2] = (-1.0/8.0)*(1+eta)*(1+xi);
shape_function_derivative_values[7*spa_dim+2] = (1.0/8.0)*(1+eta)*(1+xi);
}
bool
FEM_Linear_Quad4::is_in_element(const scalar_t * nodal_coords,
const scalar_t * point_coords,
const scalar_t & coefficient){
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Method not implemented yet");
return false;
}
void
FEM_Linear_Quad4::get_natural_integration_points(const int_t order,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & locations,
Teuchos::ArrayRCP<scalar_t> & weights,
int_t & num_points){
//assert(order == 1 && "Error: only first order integration has been implemented");
const int_t spa_dim = 2;
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > zeta,weight;
num_points = order*order;
locations.resize(num_points);
weights.resize(num_points);
for(int_t i=0;i<num_points;++i){
locations[i].resize(spa_dim);
}
gauss_2D(locations, weight, order);
for(int_t i=0;i<num_points;++i)
weights[i] = weight[i][0];
}
void
FEM_Linear_Quad4::evaluate_shape_functions(const scalar_t * natural_coords,
scalar_t * shape_function_values){
const scalar_t xi = natural_coords[0];
const scalar_t eta = natural_coords[1];
shape_function_values[0] = 0.25 * (1.0 - xi) * (1.0 - eta);
shape_function_values[1] = 0.25 * (1.0 + xi) * (1.0 - eta);
shape_function_values[2] = 0.25 * (1.0 + xi) * (1.0 + eta);
shape_function_values[3] = 0.25 * (1.0 - xi) * (1.0 + eta);
}
void
FEM_Linear_Quad4::evaluate_shape_function_derivatives(const scalar_t * natural_coords,
scalar_t * shape_function_derivative_values){
const scalar_t xi = natural_coords[0];
const scalar_t eta = natural_coords[1];
const int_t spa_dim = 2;
shape_function_derivative_values[0*spa_dim+0] = -0.25 * (1.0 - eta);
shape_function_derivative_values[1*spa_dim+0] = 0.25 * (1.0 - eta);
shape_function_derivative_values[2*spa_dim+0] = 0.25 * (1.0 + eta);
shape_function_derivative_values[3*spa_dim+0] = -0.25 * (1.0 + eta);
shape_function_derivative_values[0*spa_dim+1] = -0.25 * (1.0 - xi);
shape_function_derivative_values[1*spa_dim+1] = -0.25 * (1.0 + xi);
shape_function_derivative_values[2*spa_dim+1] = 0.25 * (1.0 + xi);
shape_function_derivative_values[3*spa_dim+1] = 0.25 * (1.0 - xi);
}
bool
FEM_Linear_Tri3::is_in_element(const scalar_t * nodal_coords,
const scalar_t * point_coords,
const scalar_t & coefficient){
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Method not implemented yet");
return false;
}
void
FEM_Linear_Tri3::get_natural_integration_points(const int_t order,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & locations,
Teuchos::ArrayRCP<scalar_t> & weights,
int_t & num_points){
tri2d_natural_integration_points(order,locations,weights,num_points);
}
void
FEM_Linear_Tri3::evaluate_shape_functions(const scalar_t * natural_coords,
scalar_t * shape_function_values){
const scalar_t xi = natural_coords[0];
const scalar_t eta = natural_coords[1];
shape_function_values[0] = 1 - xi - eta;
shape_function_values[1] = xi;
shape_function_values[2] = eta;
}
void
FEM_Linear_Tri3::evaluate_shape_function_derivatives(const scalar_t * natural_coords,
scalar_t * shape_function_derivative_values){
// natural coords not needed because constant, but passing in to make the
// function call similar
const int_t spa_dim = 2;
shape_function_derivative_values[0*spa_dim+0] = -1;
shape_function_derivative_values[1*spa_dim+0] = 1;
shape_function_derivative_values[2*spa_dim+0] = 0;
shape_function_derivative_values[0*spa_dim+1] = -1;
shape_function_derivative_values[1*spa_dim+1] = 0;
shape_function_derivative_values[2*spa_dim+1] = 1;
}
bool
FEM_Quadratic_Tri6::is_in_element(const scalar_t * nodal_coords,
const scalar_t * point_coords,
const scalar_t & coefficient){
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Method not implemented yet");
return false;
}
void
FEM_Quadratic_Tri6::get_natural_integration_points(const int_t order,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & locations,
Teuchos::ArrayRCP<scalar_t> & weights,
int_t & num_points){
// Note assumes the coordinates for the natural points has two values, x and y
tri2d_natural_integration_points(order,locations,weights,num_points);
}
void
FEM_Quadratic_Tri6::evaluate_shape_functions(const scalar_t * natural_coords,
scalar_t * shape_function_values){
// Note assumes the coordinates for the natural points has two values, x and y
const scalar_t xi = natural_coords[0];
const scalar_t eta = natural_coords[1];
shape_function_values[0] = (1.0 - 2.0 * xi - 2.0 * eta) * (1.0 - xi - eta);
shape_function_values[1] = xi * (2.0 * xi - 1.0);
shape_function_values[2] = eta * (2.0 * eta - 1.0);
shape_function_values[3] = 4.0 * xi * (1.0 - xi - eta);
shape_function_values[4] = 4.0 * xi * eta;
shape_function_values[5] = 4.0 * eta * (1.0 - xi - eta);
}
void
FEM_Quadratic_Tri6::evaluate_shape_function_derivatives(const scalar_t * natural_coords,
scalar_t * shape_function_derivative_values){
// Note assumes the coordinates for the natural points has two values, x and y
const scalar_t xi = natural_coords[0];
const scalar_t eta = natural_coords[1];
const int_t spa_dim = 2;
shape_function_derivative_values[0*spa_dim+0] = -2.0 * (1.0 - xi - eta) -1.0 * (1.0 - 2.0 * xi - 2.0 * eta);
shape_function_derivative_values[0*spa_dim+1] = -2.0 * (1.0 - xi - eta) -1.0 * (1.0 - 2.0 * xi - 2.0 * eta);
shape_function_derivative_values[1*spa_dim+0] = 4.0 * xi - 1.0;
shape_function_derivative_values[1*spa_dim+1] = 0.0;
shape_function_derivative_values[2*spa_dim+0] = 0.0;
shape_function_derivative_values[2*spa_dim+1] = 4.0 * eta - 1.0;
shape_function_derivative_values[3*spa_dim+0] = 4.0 * (1.0 - 2.0 * xi - eta);
shape_function_derivative_values[3*spa_dim+1] = -4.0 * xi;
shape_function_derivative_values[4*spa_dim+0] = 4.0 * eta;
shape_function_derivative_values[4*spa_dim+1] = 4.0 * xi;
shape_function_derivative_values[5*spa_dim+0] = -4.0 * eta;
shape_function_derivative_values[5*spa_dim+1] = 4.0 * (1.0 - xi - 2.0 * eta);
}
bool
FEM_Barycentric_Tri6::is_in_element(const scalar_t * nodal_coords,
const scalar_t * point_coords,
const scalar_t & coefficient){
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Method not implemented yet");
return false;
}
void
FEM_Barycentric_Tri6::get_natural_integration_points(const int_t order,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & locations,
Teuchos::ArrayRCP<scalar_t> & weights,
int_t & num_points){
if(order==3){
num_points = 6;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(3); // there are 3 coordinates for Barycentric elements z1, z2, and z3
weights.resize(num_points);
locations[0][0] = 0.816847572980458; locations[0][1] = 0.091576213509771; locations[0][2] = 0.091576213509771;
locations[1][0] = 0.091576213509771; locations[1][1] = 0.816847572980458; locations[1][2] = 0.091576213509771;
locations[2][0] = 0.091576213509771; locations[2][1] = 0.091576213509771; locations[2][2] = 0.816847572980458;
locations[3][0] = 0.108103018168070; locations[3][1] = 0.445948490915965; locations[3][2] = 0.445948490915965;
locations[4][0] = 0.445948490915965; locations[4][1] = 0.108103018168070; locations[4][2] = 0.445948490915965;
locations[5][0] = 0.445948490915965; locations[5][1] = 0.445948490915965; locations[5][2] = 0.108103018168070;
weights[0] = 0.109951743655322;
weights[1] = 0.109951743655322;
weights[2] = 0.109951743655322;
weights[3] = 0.223381589678011;
weights[4] = 0.223381589678011;
weights[5] = 0.223381589678011;
}
else{
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Error, invalid order for Barycentric_Tri6 natural integration points");
}
}
void
FEM_Barycentric_Tri6::evaluate_shape_functions(const scalar_t * natural_coords,
scalar_t * shape_function_values){
// Note assumes the coordinates for the natural points has 3 values
const scalar_t z1 = natural_coords[0];
const scalar_t z2 = natural_coords[1];
const scalar_t z3 = natural_coords[2];
shape_function_values[0] = z1*(2.0*z1 - 1.0);
shape_function_values[1] = z2*(2.0*z2 - 1.0);
shape_function_values[2] = z3*(2.0*z3 - 1.0);
shape_function_values[3] = 4.0*z1*z2;
shape_function_values[4] = 4.0*z2*z3;
shape_function_values[5] = 4.0*z3*z1;
}
void
FEM_Barycentric_Tri6::evaluate_shape_function_derivatives(const scalar_t * natural_coords,
scalar_t * shape_function_derivative_values){
// Note assumes the coordinates for the natural points has three values
const scalar_t z1 = natural_coords[0];
const scalar_t z2 = natural_coords[1];
const scalar_t z3 = natural_coords[2];
const int_t spa_dim = 3; // three coords per barycentric point
shape_function_derivative_values[0*spa_dim+0] = 4.0*z1-1.0;
shape_function_derivative_values[0*spa_dim+1] = 0.0;
shape_function_derivative_values[0*spa_dim+2] = 0.0;
shape_function_derivative_values[1*spa_dim+0] = 0.0;
shape_function_derivative_values[1*spa_dim+1] = 4.0*z2-1.0;
shape_function_derivative_values[1*spa_dim+2] = 0.0;
shape_function_derivative_values[2*spa_dim+0] = 0.0;
shape_function_derivative_values[2*spa_dim+1] = 0.0;
shape_function_derivative_values[2*spa_dim+2] = 4.0*z3-1.0;
shape_function_derivative_values[3*spa_dim+0] = 4.0*z2;
shape_function_derivative_values[3*spa_dim+1] = 4.0*z1;
shape_function_derivative_values[3*spa_dim+2] = 0.0;
shape_function_derivative_values[4*spa_dim+0] = 0.0;
shape_function_derivative_values[4*spa_dim+1] = 4.0*z3;
shape_function_derivative_values[4*spa_dim+2] = 4.0*z2;
shape_function_derivative_values[5*spa_dim+0] = 4.0*z3;
shape_function_derivative_values[5*spa_dim+1] = 0.0;
shape_function_derivative_values[5*spa_dim+2] = 4.0*z1;
}
// mesh generation utilities:
DICE_LIB_DLL_EXPORT
Teuchos::RCP<Mesh> create_point_or_tri_mesh(const DICe::mesh::Base_Element_Type elem_type,
Teuchos::ArrayRCP<scalar_t> node_coords_x,
Teuchos::ArrayRCP<scalar_t> node_coords_y,
Teuchos::ArrayRCP<int_t> connectivity, // this is based on the gids of the elements (always 1..n never 0 based)
Teuchos::ArrayRCP<int_t> node_map,
Teuchos::ArrayRCP<int_t> elem_map,
std::vector<std::pair<int_t,int_t> > & dirichlet_boundary_nodes,
std::set<int_t> & neumann_boundary_nodes,
std::set<int_t> & lagrange_boundary_nodes,
const std::string & serial_output_filename)
{
// notes on creating an exodus mesh below:
// the input connectivity vector is in terms of local ids
// the output connectivity stored on each element is in terms of global ids
// the node map maps local ids to global node ids
// the elem map maps local elem ids to global ids
// in the exodus mesh: the connectivity vectors have to be 1 based,
// although in the elem and node maps the "display global id" can be 0 based
DEBUG_MSG("create_exodus_mesh(): creating an exodus mesh");
TEUCHOS_TEST_FOR_EXCEPTION(elem_type!=DICe::mesh::TRI6&&elem_type!=DICe::mesh::TRI3&&elem_type!=DICe::mesh::MESHLESS,
std::runtime_error,
"Error, invalid element type");
int_t num_nodes_per_elem = 1;
if(elem_type==DICe::mesh::TRI6)
num_nodes_per_elem = 6;
else if(elem_type==DICe::mesh::TRI3)
num_nodes_per_elem = 3;
TEUCHOS_TEST_FOR_EXCEPTION((elem_type==DICe::mesh::TRI6&&connectivity.size()%6!=0)||
(elem_type==DICe::mesh::TRI3&&connectivity.size()%3!=0),std::runtime_error,
"Error connectivity should be a multiple of 6 for TRI6 or 3 for TRI3");
const int_t num_elem = connectivity.size()/num_nodes_per_elem;
// check the input data
TEUCHOS_TEST_FOR_EXCEPTION(node_coords_x.size()<0,std::runtime_error,
"Error node coords x is of zero size");
TEUCHOS_TEST_FOR_EXCEPTION(node_coords_x.size()!=node_coords_y.size(),std::runtime_error,
"Error the dims of the node coord vectors don't match");
std::stringstream out_file_base;
// find the position of the file extension
size_t pos_out = serial_output_filename.find(".g");
if(pos_out==std::string::npos){
pos_out = serial_output_filename.find(".e");
}
if(pos_out==std::string::npos)
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Error, output mesh files must have the extension .g or .e");
out_file_base << serial_output_filename;
int_t num_procs = 1;
int_t my_rank = 0;
#ifdef HAVE_MPI
int_t mpi_is_initialized = 0;
MPI_Initialized(&mpi_is_initialized);
TEUCHOS_TEST_FOR_EXCEPTION(!mpi_is_initialized,std::runtime_error,"Error: if MPI is enabled, MPI must be initialized at this point.");
MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
#endif
if(num_procs>1)
{
std::stringstream temp_ss1, temp_ss2, file_name_post;
temp_ss1 << num_procs;
const size_t procs_num_digits = temp_ss1.str().length();
temp_ss2 << my_rank;
const size_t rank_num_digits = temp_ss2.str().length();
const int_t num_fill_zeros = procs_num_digits - rank_num_digits;
file_name_post << "." << num_procs << ".";
for(int_t i=0;i<num_fill_zeros;++i)
file_name_post << "0";
file_name_post << my_rank;
out_file_base << file_name_post.str();
}
std::string output_filename = out_file_base.str();
DEBUG_MSG("Output file name: " << output_filename);
Teuchos::RCP<DICe::mesh::Mesh> mesh = Teuchos::rcp(new DICe::mesh::Mesh(output_filename));
const int_t p_rank = mesh->get_comm()->get_rank();
mesh->set_input_exoid(-1);
const int_t num_dim = 2;
mesh->set_spatial_dimension(num_dim);
// put all the overlap nodes in the mesh
const int_t num_nodes = node_map.size();
for(int_t i =0;i<num_nodes;++i){
Teuchos::RCP<Node> node_rcp = Teuchos::rcp(new DICe::mesh::Node(node_map[i],i));
mesh->get_node_set()->insert(std::pair<int_t,Teuchos::RCP<Node> >(node_rcp->global_id(),node_rcp));
}
// create one block all of type TRI6 or TRI3 elems
if(elem_type==DICe::mesh::MESHLESS)
mesh->get_block_type_map()->insert(std::pair<int_t,Base_Element_Type>(1,MESHLESS));
else if(elem_type==DICe::mesh::TRI6)
mesh->get_block_type_map()->insert(std::pair<int_t,Base_Element_Type>(1,TRI6));
else
mesh->get_block_type_map()->insert(std::pair<int_t,Base_Element_Type>(1,TRI3));
// read element connectivity
Teuchos::ArrayRCP<int_t> connectivity_swap(num_nodes_per_elem);
for(int_t j=0; j<num_elem; ++j)
{
connectivity_vector conn;
//std::cout << " Element " << j << std::endl;
// the connectivity vector needs to be re-arranged from Triangle format to exodus format
connectivity_swap[0] = connectivity[j*num_nodes_per_elem + 0];
if(elem_type==DICe::mesh::TRI6||elem_type==DICe::mesh::TRI3){
connectivity_swap[1] = connectivity[j*num_nodes_per_elem + 1];
connectivity_swap[2] = connectivity[j*num_nodes_per_elem + 2];
if(elem_type==DICe::mesh::TRI6){
connectivity_swap[4] = connectivity[j*num_nodes_per_elem + 3];
connectivity_swap[5] = connectivity[j*num_nodes_per_elem + 4];
connectivity_swap[3] = connectivity[j*num_nodes_per_elem + 5];
}
}
for(int_t k=0;k<num_nodes_per_elem;++k)
{
assert(node_map.size()>connectivity_swap[k]-1);
const int_t global_node_id = node_map[connectivity_swap[k]-1];
// find the node in the set with the same global id
if(mesh->get_node_set()->find(global_node_id)!=mesh->get_node_set()->end()){
conn.push_back(mesh->get_node_set()->find(global_node_id)->second);
}
else{
TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,"Proc " << mesh->get_comm()->get_rank() << " Could not find node rcp in set: " << global_node_id);
}
}
// create an element and put it in the mesh
const int_t elem_local_id = j;
const int_t elem_global_id = elem_map[j];
const int_t elem_index_in_block = elem_local_id;
Teuchos::RCP<DICe::mesh::Element> element_rcp = Teuchos::rcp(new DICe::mesh::Element(conn,elem_global_id,elem_local_id,1,elem_index_in_block));
mesh->get_element_set()->push_back(element_rcp);
}
// since we are going to read in some field data like coordinates or volumes, etc
// we pause here to generate the Tpetra maps that will organize this stuff
const bool force_elem_and_node_maps_to_match = num_nodes_per_elem == 1;
mesh->create_elem_node_field_maps(force_elem_and_node_maps_to_match);
mesh->create_field(field_enums::BLOCK_ID_FS);
MultiField & block_id_field = *mesh->get_field(field_enums::BLOCK_ID_FS);
DICe::mesh::element_set::const_iterator elem_it = mesh->get_element_set()->begin();
DICe::mesh::element_set::const_iterator elem_end = mesh->get_element_set()->end();
for(;elem_it!=elem_end;++elem_it){
block_id_field.local_value(elem_it->get()->local_id()) = elem_it->get()->block_id();
}
//mesh->create_field(field_enums::MASTER_NODE_ID_FS);
//MultiField & master_field = *mesh->get_field(field_enums::MASTER_NODE_ID_FS);
//DICe::mesh::node_set::iterator node_it = mesh->get_node_set()->begin();
//DICe::mesh::node_set::iterator node_end = mesh->get_node_set()->end();
//for(;node_it!=node_end;++node_it){
// master_field.local_value(node_it->second->local_id()) = node_it->second->local_id();
//}
// put the element blocks in a field so they are accessible in parallel from other processors
block_type_map::iterator blk_map_it = mesh->get_block_type_map()->begin();
block_type_map::iterator blk_map_end = mesh->get_block_type_map()->end();
for(;blk_map_it!=blk_map_end;++blk_map_it)
{
// TODO: do the same for faces/edges
Teuchos::RCP<element_set> elem_set = Teuchos::rcp(new element_set);
for(elem_it=mesh->get_element_set()->begin();elem_it!=elem_end;++elem_it)
{
if(elem_it->get()->block_id()==blk_map_it->first)
{
elem_set->push_back(*elem_it);
}
}
mesh->get_element_sets_by_block()->insert(std::pair<int_t,Teuchos::RCP<element_set> >(blk_map_it->first,elem_set));
}
//std::vector<int_t> dirichlet_bc_def;
//std::map<int_t,int_t>::const_iterator mit = dirichlet_boundary_nodes.begin();
//std::map<int_t,int_t>::const_iterator mit_end = dirichlet_boundary_nodes.end();
std::map<int_t,std::vector<int_t> > bc_node_collections;
for(size_t i=0;i<dirichlet_boundary_nodes.size();++i){
if(bc_node_collections.find(dirichlet_boundary_nodes[i].second)==bc_node_collections.end())
bc_node_collections.insert(std::pair<int_t,std::vector<int_t> >(dirichlet_boundary_nodes[i].second,std::vector<int_t>()));
bc_node_collections.find(dirichlet_boundary_nodes[i].second)->second.push_back(dirichlet_boundary_nodes[i].first);
}
if(bc_node_collections.size()>0){
std::map<int_t,std::vector<int_t> >::iterator col_it = bc_node_collections.begin();
std::map<int_t,std::vector<int_t> >::iterator col_end = bc_node_collections.end();
for(;col_it!=col_end;++col_it){
mesh->get_node_bc_sets()->insert(std::pair<int_t,std::vector<int_t> >(col_it->first,col_it->second));
}
}
std::vector<int_t> neumann_bc_def;
std::set<int_t>::const_iterator it = neumann_boundary_nodes.begin();
std::set<int_t>::const_iterator it_end = neumann_boundary_nodes.end();
it = neumann_boundary_nodes.begin();
it_end = neumann_boundary_nodes.end();
for(;it!=it_end;++it){
neumann_bc_def.push_back(*it);
}
if(neumann_bc_def.size()>0)
mesh->get_node_bc_sets()->insert(std::pair<int_t,std::vector<int_t> >(0,neumann_bc_def)); // all neumann boundary nodes go in node set 0
std::vector<int_t> lagrange_bc_def;
it = lagrange_boundary_nodes.begin();
it_end = lagrange_boundary_nodes.end();
for(;it!=it_end;++it){
lagrange_bc_def.push_back(*it);
}
if(lagrange_bc_def.size()>0)
mesh->get_node_bc_sets()->insert(std::pair<int_t,std::vector<int_t> >(-1,lagrange_bc_def)); // all lagrange boundary nodes go in node set -1
mesh->set_initialized();
//mesh->create_face_cell_field_maps();
// initialize the fields needed for coordinates etc:
mesh->create_field(field_enums::INITIAL_COORDINATES_FS);
Teuchos::RCP<MultiField > initial_coords = mesh->get_overlap_field(field_enums::INITIAL_COORDINATES_FS);
for(int_t i=0;i<num_nodes;++i) // i represents the local_id
{
initial_coords->local_value(i*num_dim+0) = node_coords_x[i];
initial_coords->local_value(i*num_dim+1) = node_coords_y[i];
}
// export the coordinates back to the non-overlap field
mesh->field_overlap_export(initial_coords, field_enums::INITIAL_COORDINATES_FS, INSERT);
//std::cout << "INITIAL COORDS: " << std::endl;
//initial_coords_ptr->vec()->describe();
// CELL COORDINATES
mesh->create_field(field_enums::INITIAL_CELL_COORDINATES_FS);
Teuchos::RCP<MultiField > coords = mesh->get_overlap_field(field_enums::INITIAL_COORDINATES_FS);
MultiField & initial_cell_coords = *mesh->get_field(field_enums::INITIAL_CELL_COORDINATES_FS);
//compute the centroid from the coordinates of the nodes;
for(elem_it=mesh->get_element_set()->begin();elem_it!=elem_end;++elem_it)
{
const DICe::mesh::connectivity_vector & connectivity = *elem_it->get()->connectivity();
assert(connectivity.size()!=0);
scalar_t centroid[num_dim];
for(int_t i=0;i<num_dim;++i) centroid[i]=0.0;
for(size_t node_it=0;node_it<connectivity.size();++node_it)
{
const Teuchos::RCP<DICe::mesh::Node> node = connectivity[node_it];
centroid[0] += coords->local_value(node.get()->overlap_local_id()*num_dim+0);
centroid[1] += coords->local_value(node.get()->overlap_local_id()*num_dim+1);
}
for(int_t dim=0;dim<num_dim;++dim)
{
centroid[dim] /= connectivity.size();
initial_cell_coords.local_value(elem_it->get()->local_id()*num_dim+dim) = centroid[dim];
}
}
//std::cout << " INITIAL CELL COORDS: " << std::endl;
//initial_cell_coords.vec()->describe();
// PROCESSOR ID
// create the cell_coords, cell_radius and cell_size fields:
mesh->create_field(field_enums::PROCESSOR_ID_FS);
MultiField & proc_id = *mesh->get_field(field_enums::PROCESSOR_ID_FS);
elem_it = mesh->get_element_set()->begin();
for(;elem_it!=elem_end;++elem_it){
proc_id.local_value(elem_it->get()->local_id()) = p_rank;
}
DEBUG_MSG(" ------------------ Analysis Model Definition (processsor " << p_rank <<") --------------------------");
DEBUG_MSG(" Title: " << "autogenerated Triangle mesh, or subset points");
DEBUG_MSG(" Output file: " << output_filename);
DEBUG_MSG(" Spatial dimension: " << num_dim);
DEBUG_MSG(" Nodes: " << num_nodes);
DEBUG_MSG(" Elements: " << num_elem);
DEBUG_MSG(" Dirichlet nodes: " << dirichlet_boundary_nodes.size());
DEBUG_MSG(" Neumann nodes: " << neumann_boundary_nodes.size());
//DEBUG_MSG(" Element blocks: " << num_elem_blk);
DEBUG_MSG(" Node sets: " << mesh->num_node_sets());
//DEBUG_MSG(" Side sets: " << num_side_sets);
DEBUG_MSG(" --------------------------------------------------------------------------------------");
return mesh;
}
DICE_LIB_DLL_EXPORT
Teuchos::RCP<Mesh> create_tri3_mesh_from_tri6(Teuchos::RCP<Mesh> tri6_mesh,
const std::string & serial_output_filename){
DEBUG_MSG("create_tri3_mesh_from_tri6(): creating a tri3 mesh from a tri6 one");
// find the position of the file extension
std::stringstream out_file_base;
size_t pos_out = serial_output_filename.find(".g");
if(pos_out==std::string::npos){
pos_out = serial_output_filename.find(".e");
}
if(pos_out==std::string::npos)
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Error, output mesh files must have the extension .g or .e");
out_file_base << serial_output_filename;
const int_t spa_dim = tri6_mesh->spatial_dimension();
int_t num_procs = 1;
int_t my_rank = 0;
#ifdef HAVE_MPI
int_t mpi_is_initialized = 0;
MPI_Initialized(&mpi_is_initialized);
TEUCHOS_TEST_FOR_EXCEPTION(!mpi_is_initialized,std::runtime_error,"Error: if MPI is enabled, MPI must be initialized at this point.");
MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
#endif
if(num_procs>1)
{
std::stringstream temp_ss1, temp_ss2, file_name_post;
temp_ss1 << num_procs;
const size_t procs_num_digits = temp_ss1.str().length();
temp_ss2 << my_rank;
const size_t rank_num_digits = temp_ss2.str().length();
const int_t num_fill_zeros = procs_num_digits - rank_num_digits;
file_name_post << "." << num_procs << ".";
for(int_t i=0;i<num_fill_zeros;++i)
file_name_post << "0";
file_name_post << my_rank;
out_file_base << file_name_post.str();
}
std::string output_filename = out_file_base.str();
DEBUG_MSG("Output file name: " << output_filename);
// iterate the elements, taking only the first three indices of the connectivity to
// populate the node list:
std::map<int_t,scalar_t> coords_x;
std::map<int_t,scalar_t> coords_y;
// element loop
TEUCHOS_TEST_FOR_EXCEPTION(tri6_mesh->get_block_type_map()->begin()->second!=TRI6,std::runtime_error,
"Error, the input mesh must be TRI6 elements");
Teuchos::RCP<MultiField > tri6_initial_coords = tri6_mesh->get_overlap_field(field_enums::INITIAL_COORDINATES_FS);
DICe::mesh::element_set::iterator elem_it = tri6_mesh->get_element_set()->begin();
DICe::mesh::element_set::iterator elem_end = tri6_mesh->get_element_set()->end();
//const int_t tri6_num_nodes_per_elem = 6;
const int_t tri3_num_nodes_per_elem = 3;
for(;elem_it!=elem_end;++elem_it)
{
//std::cout << "ELEM: " << elem_it->get()->global_id() << std::endl;
const DICe::mesh::connectivity_vector & connectivity = *elem_it->get()->connectivity();
for(int_t nd=0;nd<tri3_num_nodes_per_elem;++nd){ // only collect the first three nodes
const int_t node_gid = connectivity[nd]->global_id();
const int_t node_olid = connectivity[nd]->overlap_local_id();
coords_x.insert(std::pair<int_t,scalar_t>(node_gid,tri6_initial_coords->local_value(node_olid*spa_dim+0)));
coords_y.insert(std::pair<int_t,scalar_t>(node_gid,tri6_initial_coords->local_value(node_olid*spa_dim+1)));
}
}
TEUCHOS_TEST_FOR_EXCEPTION(coords_x.size()!=coords_y.size(),std::runtime_error,"Error, coords should be the same size");
const int_t num_nodes = coords_x.size();
int_t * local_to_master_node_map = new int_t[num_nodes];
Teuchos::RCP<DICe::mesh::Mesh> mesh = Teuchos::rcp(new DICe::mesh::Mesh(output_filename));
const int_t p_rank = mesh->get_comm()->get_rank();
mesh->set_input_exoid(-1);
const int_t num_dim = 2;
mesh->set_spatial_dimension(num_dim);
// std::cout << "nodes that got collected " << std::endl;
std::map<int_t,scalar_t>::iterator it=coords_x.begin();
std::map<int_t,scalar_t>::iterator it_end=coords_x.end();
int_t node_index = 0;
std::map<int_t,int_t> master_to_local_node_map;
for(;it!=it_end;++it){
local_to_master_node_map[node_index] = it->first;
//master_to_local_node_map.insert(std::pair<int_t,int_t>(it->first,node_index));
Teuchos::RCP<Node> node_rcp = Teuchos::rcp(new DICe::mesh::Node(it->first,node_index));
mesh->get_node_set()->insert(std::pair<int_t,Teuchos::RCP<Node> >(node_rcp->global_id(),node_rcp));
node_index++;
//std::cout << "gid " << it->first << " x " << it->second << std::endl;
}
// create one block all of type TRI3 elems
mesh->get_block_type_map()->insert(std::pair<int_t,Base_Element_Type>(1,TRI3));
for(elem_it = tri6_mesh->get_element_set()->begin();elem_it!=elem_end;++elem_it)
{
connectivity_vector conn;
const DICe::mesh::connectivity_vector & connectivity = *elem_it->get()->connectivity();
for(int_t k=0;k<tri3_num_nodes_per_elem;++k)
{
//TEUCHOS_TEST_FOR_EXCEPTION(master_to_local_node_map.find(connectivity[k]->global_id())==master_to_local_node_map.end(),std::runtime_error,
// "Error, invalid master to local node.");
const int_t global_node_id = connectivity[k]->global_id();//master_to_local_node_map.find(connectivity[k]->global_id())->second;
// find the node in the set with the same global id
if(mesh->get_node_set()->find(global_node_id)!=mesh->get_node_set()->end()){
conn.push_back(mesh->get_node_set()->find(global_node_id)->second);
}
else{
TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,"Could not find node rcp in set " << global_node_id);
}
}
TEUCHOS_TEST_FOR_EXCEPTION((int_t)conn.size()!=tri3_num_nodes_per_elem,std::runtime_error,"Error, connectivity is of invalid size");
const int_t elem_local_id = elem_it->get()->local_id();
const int_t elem_global_id = elem_it->get()->global_id();
const int_t elem_index_in_block = elem_it->get()->index_in_block();
Teuchos::RCP<DICe::mesh::Element> element_rcp = Teuchos::rcp(new DICe::mesh::Element(conn,elem_global_id,elem_local_id,1,elem_index_in_block));
mesh->get_element_set()->push_back(element_rcp);
}
// since we are going to read in some field data like coordinates or volumes, etc
// we pause here to generate the Tpetra maps that will organize this stuff
mesh->create_elem_node_field_maps();
mesh->create_field(field_enums::BLOCK_ID_FS);
MultiField & block_id_field = *mesh->get_field(field_enums::BLOCK_ID_FS);
elem_it = mesh->get_element_set()->begin();
elem_end = mesh->get_element_set()->end();
for(;elem_it!=elem_end;++elem_it){
block_id_field.local_value(elem_it->get()->local_id()) = elem_it->get()->block_id();
}
//mesh->create_field(field_enums::MASTER_NODE_ID_FS);
//MultiField & master_field = *mesh->get_field(field_enums::MASTER_NODE_ID_FS);
//DICe::mesh::node_set::iterator node_it = mesh->get_node_set()->begin();
//DICe::mesh::node_set::iterator node_end = mesh->get_node_set()->end();
//for(;node_it!=node_end;++node_it){
// master_field.local_value(node_it->second->local_id()) = local_to_master_node_map[node_it->second->local_id()];
//}
// put the element blocks in a field so they are accessible in parallel from other processors
block_type_map::iterator blk_map_it = mesh->get_block_type_map()->begin();
block_type_map::iterator blk_map_end = mesh->get_block_type_map()->end();
for(;blk_map_it!=blk_map_end;++blk_map_it)
{
// TODO: do the same for faces/edges
Teuchos::RCP<element_set> elem_set = Teuchos::rcp(new element_set);
for(elem_it=mesh->get_element_set()->begin();elem_it!=elem_end;++elem_it)
{
if(elem_it->get()->block_id()==blk_map_it->first)
{
elem_set->push_back(*elem_it);
}
}
mesh->get_element_sets_by_block()->insert(std::pair<int_t,Teuchos::RCP<element_set> >(blk_map_it->first,elem_set));
}
// TODO deal with boundary conditions on the lagrange mesh
//
// std::vector<int_t> dirichlet_bc_def;
// std::set<int_t>::const_iterator it = dirichlet_boundary_nodes.begin();
// std::set<int_t>::const_iterator it_end = dirichlet_boundary_nodes.end();
// for(;it!=it_end;++it){
// dirichlet_bc_def.push_back(*it);
// }
// if(dirichlet_bc_def.size()>0)
// mesh->get_node_bc_sets()->insert(std::pair<int_t,std::vector<int_t> >(0,dirichlet_bc_def)); // all dirichlet boundary nodes go in node set 0
// std::vector<int_t> neumann_bc_def;
// it = neumann_boundary_nodes.begin();
// it_end = neumann_boundary_nodes.end();
// for(;it!=it_end;++it){
// neumann_bc_def.push_back(*it);
// }
// if(neumann_bc_def.size()>0)
// mesh->get_node_bc_sets()->insert(std::pair<int_t,std::vector<int_t> >(1,neumann_bc_def)); // all neumann boundary nodes go in node set 1
//
mesh->set_initialized();
// initialize the fields needed for coordinates etc:
mesh->create_field(field_enums::INITIAL_COORDINATES_FS);
Teuchos::RCP<MultiField > initial_coords = mesh->get_overlap_field(field_enums::INITIAL_COORDINATES_FS);
for(int_t i=0;i<num_nodes;++i) // i represents the local_id
{
initial_coords->local_value(i*num_dim+0) = coords_x.find(local_to_master_node_map[i])->second;
initial_coords->local_value(i*num_dim+1) = coords_y.find(local_to_master_node_map[i])->second;
}
// export the coordinates back to the non-overlap field
mesh->field_overlap_export(initial_coords, field_enums::INITIAL_COORDINATES_FS, INSERT);
//std::cout << "INITIAL COORDS: " << std::endl;
//initial_coords_ptr->vec()->describe();
// CELL COORDINATES
mesh->create_field(field_enums::INITIAL_CELL_COORDINATES_FS);
Teuchos::RCP<MultiField > mcoords = mesh->get_overlap_field(field_enums::INITIAL_COORDINATES_FS);
MultiField & initial_cell_coords = *mesh->get_field(field_enums::INITIAL_CELL_COORDINATES_FS);
//compute the centroid from the coordinates of the nodes;
for(elem_it=mesh->get_element_set()->begin();elem_it!=elem_end;++elem_it)
{
const DICe::mesh::connectivity_vector & connectivity = *elem_it->get()->connectivity();
assert(connectivity.size()!=0);
scalar_t centroid[num_dim];
for(int_t i=0;i<num_dim;++i) centroid[i]=0.0;
for(size_t node_it=0;node_it<connectivity.size();++node_it)
{
const Teuchos::RCP<DICe::mesh::Node> node = connectivity[node_it];
centroid[0] += mcoords->local_value(node.get()->overlap_local_id()*spa_dim+0);
centroid[1] += mcoords->local_value(node.get()->overlap_local_id()*spa_dim+1);
}
for(int_t dim=0;dim<num_dim;++dim)
{
centroid[dim] /= connectivity.size();
initial_cell_coords.local_value(elem_it->get()->local_id()*num_dim+dim) = centroid[dim];
}
}
//std::cout << " INITIAL CELL COORDS: " << std::endl;
//initial_cell_coords.vec()->describe();
// PROCESSOR ID
// create the cell_coords, cell_radius and cell_size fields:
mesh->create_field(field_enums::PROCESSOR_ID_FS);
MultiField & proc_id = *mesh->get_field(field_enums::PROCESSOR_ID_FS);
elem_it = mesh->get_element_set()->begin();
for(;elem_it!=elem_end;++elem_it){
proc_id.local_value(elem_it->get()->local_id()) = p_rank;
}
DEBUG_MSG(" ------------------ Analysis Model Definition (processsor " << p_rank <<") --------------------------");
DEBUG_MSG(" Title: " << "autogenerated linear Triangle mesh");
DEBUG_MSG(" Output file: " << output_filename);
DEBUG_MSG(" Spatial dimension: " << num_dim);
DEBUG_MSG(" Nodes: " << num_nodes);
DEBUG_MSG(" Elements: " << tri6_mesh->num_elem());
DEBUG_MSG(" --------------------------------------------------------------------------------------");
delete[] local_to_master_node_map;
return mesh;
}
} // namespace mesh
DICE_LIB_DLL_EXPORT
void tri3d_natural_integration_points(const int_t order,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & locations,
Teuchos::ArrayRCP<scalar_t> & weights,
int_t & num_points){
TEUCHOS_TEST_FOR_EXCEPTION(order < 0 || order > 5,std::runtime_error,"");
const int_t spa_dim = 3;
// Dunavant quadrature:
if(order==1){
num_points = 1;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.333333333333333; locations[0][1] = 0.333333333333333; locations[0][2] = 0.333333333333333;
weights[0] = 1.000000000000000;
}
else if(order==2){
num_points = 3;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.666666666666667; locations[0][1] = 0.166666666666667; locations[0][2] = 0.166666666666667;
locations[1][0] = 0.166666666666667; locations[1][1] = 0.666666666666667; locations[1][2] = 0.166666666666667;
locations[2][0] = 0.166666666666667; locations[2][1] = 0.166666666666667; locations[2][2] = 0.666666666666667;
weights[0] = 0.333333333333333;
weights[1] = 0.333333333333333;
weights[2] = 0.333333333333333;
}
else if(order==3){
num_points = 4;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.333333333333333; locations[0][1] = 0.333333333333333; locations[0][2] = 0.333333333333333;
locations[1][0] = 0.600000000000000; locations[1][1] = 0.200000000000000; locations[1][2] = 0.200000000000000;
locations[2][0] = 0.200000000000000; locations[2][1] = 0.600000000000000; locations[2][2] = 0.200000000000000;
locations[3][0] = 0.200000000000000; locations[3][1] = 0.200000000000000; locations[3][2] = 0.600000000000000;
weights[0] = -0.562500000000000;
weights[1] = 0.520833333333333;
weights[2] = 0.520833333333333;
weights[3] = 0.520833333333333;
}
else if(order==4){
num_points = 6;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.108103018168070; locations[0][1] = 0.445948490915965; locations[0][2] = 0.445948490915965;
locations[1][0] = 0.445948490915965; locations[1][1] = 0.108103018168070; locations[1][2] = 0.445948490915965;
locations[2][0] = 0.445948490915965; locations[2][1] = 0.445948490915965; locations[2][2] = 0.108103018168070;
locations[3][0] = 0.816847572980459; locations[3][1] = 0.091576213509771; locations[3][2] = 0.091576213509771;
locations[4][0] = 0.091576213509771; locations[4][1] = 0.816847572980459; locations[4][2] = 0.091576213509771;
locations[5][0] = 0.091576213509771; locations[5][1] = 0.091576213509771; locations[5][2] = 0.816847572980459;
weights[0] = 0.223381589678011;
weights[1] = 0.223381589678011;
weights[2] = 0.223381589678011;
weights[3] = 0.109951743655322;
weights[4] = 0.109951743655322;
weights[5] = 0.109951743655322;
}
else if(order==5){
num_points = 7;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.333333333333333; locations[0][1] = 0.333333333333333; locations[0][2] = 0.333333333333333;
locations[1][0] = 0.059715871789770; locations[1][1] = 0.470142064105115; locations[1][2] = 0.470142064105115;
locations[2][0] = 0.470142064105115; locations[2][1] = 0.059715871789770; locations[2][2] = 0.470142064105115;
locations[3][0] = 0.470142064105115; locations[3][1] = 0.470142064105115; locations[3][2] = 0.059715871789770;
locations[4][0] = 0.797426985353087; locations[4][1] = 0.101286507323456; locations[4][2] = 0.101286507323456;
locations[5][0] = 0.101286507323456; locations[5][1] = 0.797426985353087; locations[5][2] = 0.101286507323456;
locations[6][0] = 0.101286507323456; locations[6][1] = 0.101286507323456; locations[6][2] = 0.797426985353087;
weights[0] = 0.225000000000000;
weights[1] = 0.132394152788506;
weights[2] = 0.132394152788506;
weights[3] = 0.132394152788506;
weights[4] = 0.125939180544827;
weights[5] = 0.125939180544827;
weights[6] = 0.125939180544827;
}
else{
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Error: invalid pixel integration order.");
}
}
DICE_LIB_DLL_EXPORT
void tri2d_nonexact_integration_points(const int_t order,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & locations,
Teuchos::ArrayRCP<scalar_t> & weights,
int_t & num_points){
// note 0.5 factor for being a triangle is included in the gauss weight
TEUCHOS_TEST_FOR_EXCEPTION(order<=0,std::runtime_error,"");
const int_t spa_dim = 2;
//std::cout << "ORDER " << order << std::endl;
const scalar_t h = 1.0 / order;
//std::cout << "H " << h << std::endl;
// determine the number of points
num_points = 0;
for(int_t i=0;i<=order;++i){
num_points += i;
}
//std::cout << "NUM_POINTS " << num_points << std::endl;
TEUCHOS_TEST_FOR_EXCEPTION(num_points<=0,std::runtime_error,"");
const scalar_t weight = 0.5 / (num_points-0.5*order); // There are order number half cells along the diag
// resize the storage
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
int_t index = 0;
for(int_t j=0;j<order;++j){
scalar_t y = 0.5*h + j*h;
for(int_t i=0;i<=order-j-1;++i){
scalar_t x = 0.5*h + i*h;
locations[index][0] = x;
locations[index][1] = y;
weights[index] = i==order-j-1?0.5*weight:weight;
index++;
}
}
TEUCHOS_TEST_FOR_EXCEPTION(index!=num_points,std::runtime_error,"");
}
DICE_LIB_DLL_EXPORT
void tri2d_natural_integration_points(const int_t order,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & locations,
Teuchos::ArrayRCP<scalar_t> & weights,
int_t & num_points){
TEUCHOS_TEST_FOR_EXCEPTION(order < -7 || order > 7,std::runtime_error,"");
const int_t spa_dim = 2;
// Dunavant quadrature:
if(order==1){
num_points = 1;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.333333333333333; locations[0][1] = 0.333333333333333;
weights[0] = 0.5;
}
else if(order==-2){
num_points = 3;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.5; locations[0][1] = 0.0;
locations[1][0] = 0.0; locations[1][1] = 0.5;
locations[2][0] = 0.5; locations[2][1] = 0.5;
weights[0] = 0.1666666666666667; // weights sum to 1/2 because that is the area of the iso-tri
weights[1] = 0.1666666666666667;
weights[2] = 0.1666666666666667;
}
else if(order==2){
num_points = 3;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.1666666666666667; locations[0][1] = 0.1666666666666667;
locations[1][0] = 0.6666666666666667; locations[1][1] = 0.1666666666666667;
locations[2][0] = 0.1666666666666667; locations[2][1] = 0.6666666666666667;
weights[0] = 0.1666666666666667; // weights sum to 1/2 because that is the area of the iso-tri
weights[1] = 0.1666666666666667;
weights[2] = 0.1666666666666667;
}
else if(order==3){
num_points = 4;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.333333333333333; locations[0][1] = 0.333333333333333;
locations[1][0] = 0.600000000000000; locations[1][1] = 0.200000000000000;
locations[2][0] = 0.200000000000000; locations[2][1] = 0.600000000000000;
locations[3][0] = 0.200000000000000; locations[3][1] = 0.200000000000000;
weights[0] = -0.281250000000000;// weights sum to 1/2 because that is the area of the iso-tri
weights[1] = 0.260416666666667;
weights[2] = 0.260416666666667;
weights[3] = 0.260416666666667;
}
else if(order==4){
num_points = 6;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.44594849091597; locations[0][1] = 0.44594849091597;
locations[1][0] = 0.44594849091597; locations[1][1] = 0.10810301816807;
locations[2][0] = 0.10810301816807; locations[2][1] = 0.44594849091597;
locations[3][0] = 0.09157621350977; locations[3][1] = 0.09157621350977;
locations[4][0] = 0.09157621350977; locations[4][1] = 0.81684757298046;
locations[5][0] = 0.81684757298046; locations[5][1] = 0.09157621350977;
weights[0] = 0.11169079483901;// weights sum to 1/2 because that is the area of the iso-tri
weights[1] = 0.11169079483901;
weights[2] = 0.11169079483901;
weights[3] = 0.05497587182766;
weights[4] = 0.05497587182766;
weights[5] = 0.05497587182766;
}
else if(order==5){
num_points = 7;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.333333333333333; locations[0][1] = 0.333333333333333;
locations[1][0] = 0.797426985353087; locations[1][1] = 0.101286507323456;
locations[2][0] = 0.101286507323456; locations[2][1] = 0.797426985353087;
locations[3][0] = 0.101286507323456; locations[3][1] = 0.101286507323456;
locations[4][0] = 0.470142064105115; locations[4][1] = 0.059715871789770;
locations[5][0] = 0.059715871789770; locations[5][1] = 0.470142064105115;
locations[6][0] = 0.470142064105115; locations[6][1] = 0.470142064105115;
weights[0] = 0.112500000000000;// weights sum to 1/2 because that is the area of the iso-tri
weights[1] = 0.06296959027241;
weights[2] = 0.06296959027241;
weights[3] = 0.06296959027241;
weights[4] = 0.06619707639425;
weights[5] = 0.06619707639425;
weights[6] = 0.06619707639425;
}
else if(order==6){
num_points = 12;
locations.resize(num_points);
for(int_t i=0;i<num_points;++i)
locations[i].resize(spa_dim);
weights.resize(num_points);
locations[0][0] = 0.24928674517091; locations[0][1] = 0.24928674517091;
locations[1][0] = 0.24928674517091; locations[1][1] = 0.50142650965818;
locations[2][0] = 0.50142650965818; locations[2][1] = 0.24928674517091;
locations[3][0] = 0.06308901449150; locations[3][1] = 0.06308901449150;
locations[4][0] = 0.06308901449150; locations[4][1] = 0.87382197101700;
locations[5][0] = 0.87382197101700; locations[5][1] = 0.06308901449150;
locations[6][0] = 0.31035245103378; locations[6][1] = 0.63650249912140;
locations[7][0] = 0.63650249912140; locations[7][1] = 0.05314504984482;
locations[8][0] = 0.05314504984482; locations[8][1] = 0.31035245103378;
locations[9][0] = 0.63650249912140; locations[9][1] = 0.31035245103378;
locations[10][0] = 0.31035245103378; locations[10][1] = 0.05314504984482;
locations[11][0] = 0.05314504984482; locations[11][1] = 0.63650249912140;
weights[0] = 0.05839313786319;// weights sum to 1/2 because that is the area of the iso-tri
weights[1] = 0.05839313786319;
weights[2] = 0.05839313786319;
weights[3] = 0.02542245318511;
weights[4] = 0.02542245318511;
weights[5] = 0.02542245318511;
weights[6] = 0.04142553780919;
weights[7] = 0.04142553780919;
weights[8] = 0.04142553780919;
weights[9] = 0.04142553780919;
weights[10] = 0.04142553780919;
weights[11] = 0.04142553780919;
}
else{
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"Error: invalid pixel integration order.");
}
}
//Compute the cross product AB x AC
DICE_LIB_DLL_EXPORT
scalar_t cross(const scalar_t * a_coords,
const scalar_t * b_coords,
const scalar_t * c_coords)
{
scalar_t AB[2];
scalar_t AC[2];
AB[0] = b_coords[0]-a_coords[0];
AB[1] = b_coords[1]-a_coords[1];
AC[0] = c_coords[0]-a_coords[0];
AC[1] = c_coords[1]-a_coords[1];
const scalar_t cross = AB[0] * AC[1] - AB[1] * AC[0];
return cross;
}
//Compute the cross product AB x AC
DICE_LIB_DLL_EXPORT
scalar_t cross3d(const scalar_t * a_coords,
const scalar_t * b_coords,
const scalar_t * c_coords)
{
scalar_t AB[3];
scalar_t AC[3];
AB[0] = b_coords[0]-a_coords[0];
AB[1] = b_coords[1]-a_coords[1];
AB[2] = b_coords[2]-a_coords[2];
AC[0] = c_coords[0]-a_coords[0];
AC[1] = c_coords[1]-a_coords[1];
AC[2] = c_coords[2]-a_coords[2];
const scalar_t cross_0 = AB[1] * AC[2] - AC[1] * AB[2];
const scalar_t cross_1 = AC[0] * AB[2] - AB[0] * AC[2];
const scalar_t cross_2 = AB[0] * AC[1] - AB[1] * AC[0];
return std::sqrt(cross_0 * cross_0 + cross_1 * cross_1 + cross_2 * cross_2);
}
//Compute the cross product AB x AC return the area of the parallelogram and update the normal pointer
DICE_LIB_DLL_EXPORT
scalar_t cross3d_with_normal(const scalar_t * a_coords,
const scalar_t * b_coords,
const scalar_t * c_coords,
scalar_t * normal)
{
scalar_t AB[3];
scalar_t AC[3];
AB[0] = b_coords[0]-a_coords[0];
AB[1] = b_coords[1]-a_coords[1];
AB[2] = b_coords[2]-a_coords[2];
AC[0] = c_coords[0]-a_coords[0];
AC[1] = c_coords[1]-a_coords[1];
AC[2] = c_coords[2]-a_coords[2];
const scalar_t cross_0 = AB[1] * AC[2] - AC[1] * AB[2];
const scalar_t cross_1 = AC[0] * AB[2] - AB[0] * AC[2];
const scalar_t cross_2 = AB[0] * AC[1] - AB[1] * AC[0];
const scalar_t mag = std::sqrt(cross_0 * cross_0 + cross_1 * cross_1 + cross_2 * cross_2);
assert(mag!=0.0);
normal[0] = cross_0/mag;
normal[1] = cross_1/mag;
normal[2] = cross_2/mag;
return mag;
}
//Compute the cross product AB x AC return the area of the parallelogram and update the normal pointer
//TODO condense these three functions to use the same subfunction
DICE_LIB_DLL_EXPORT
void cross3d_with_cross_prod(const scalar_t * a_coords,
const scalar_t * b_coords,
const scalar_t * c_coords,
scalar_t * cross_prod)
{
scalar_t AB[3];
scalar_t AC[3];
AB[0] = b_coords[0]-a_coords[0];
AB[1] = b_coords[1]-a_coords[1];
AB[2] = b_coords[2]-a_coords[2];
AC[0] = c_coords[0]-a_coords[0];
AC[1] = c_coords[1]-a_coords[1];
AC[2] = c_coords[2]-a_coords[2];
cross_prod[0] = AB[1] * AC[2] - AC[1] * AB[2];
cross_prod[1] = AC[0] * AB[2] - AB[0] * AC[2];
cross_prod[2] = AB[0] * AC[1] - AB[1] * AC[0];
}
DICE_LIB_DLL_EXPORT
scalar_t determinant_4x4(const scalar_t * a)
{
const scalar_t det =
a[0+0*4] * (
a[1+1*4] * ( a[2+2*4] * a[3+3*4] - a[2+3*4] * a[3+2*4] )
- a[1+2*4] * ( a[2+1*4] * a[3+3*4] - a[2+3*4] * a[3+1*4] )
+ a[1+3*4] * ( a[2+1*4] * a[3+2*4] - a[2+2*4] * a[3+1*4] ) )
- a[0+1*4] * (
a[1+0*4] * ( a[2+2*4] * a[3+3*4] - a[2+3*4] * a[3+2*4] )
- a[1+2*4] * ( a[2+0*4] * a[3+3*4] - a[2+3*4] * a[3+0*4] )
+ a[1+3*4] * ( a[2+0*4] * a[3+2*4] - a[2+2*4] * a[3+0*4] ) )
+ a[0+2*4] * (
a[1+0*4] * ( a[2+1*4] * a[3+3*4] - a[2+3*4] * a[3+1*4] )
- a[1+1*4] * ( a[2+0*4] * a[3+3*4] - a[2+3*4] * a[3+0*4] )
+ a[1+3*4] * ( a[2+0*4] * a[3+1*4] - a[2+1*4] * a[3+0*4] ) )
- a[0+3*4] * (
a[1+0*4] * ( a[2+1*4] * a[3+2*4] - a[2+2*4] * a[3+1*4] )
- a[1+1*4] * ( a[2+0*4] * a[3+2*4] - a[2+2*4] * a[3+0*4] )
+ a[1+2*4] * ( a[2+0*4] * a[3+1*4] - a[2+1*4] * a[3+0*4] ) );
return det;
}
DICE_LIB_DLL_EXPORT
void gauss_1D(Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & r,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & w,
int_t gauss_order){
r.clear();
w.clear();
r.resize(gauss_order);
w.resize(gauss_order);
for(int_t i=0;i<gauss_order;++i){
r[i].resize(1);
w[i].resize(1);
}
switch(gauss_order){
case 1:
r[0][0] = 0.0;
w[0][0] = 2.0;
break;
case 2:
r[0][0] = -1.0/std::sqrt(3.0);
r[1][0] = -1.0*r[0][0];
w[0][0] = 1.0;
w[1][0] = 1.0;
break;
case 3:
r[0][0] = -1.0*std::sqrt(0.6);
r[1][0] = 0.0;
r[2][0] = -1.0*r[0][0];
w[0][0] = 5.0/9.0;
w[1][0] = 8.0/9.0;
w[2][0] = 5.0/9.0;
break;
case 4:
r[0][0] = -0.861136311594053;
r[1][0] = -0.339981043584856;
r[2][0] = 0.339981043584856;
r[3][0] = 0.861136311594053;
//
w[0][0] = 0.347854845137454;
w[1][0] = 0.652145154862546;
w[2][0] = 0.652145154862546;
w[3][0] = 0.347854845137454;
break;
case 5:
r[0][0] = -0.906179845938664;
r[1][0] = -0.538469310105683;
r[2][0] = 0.000000000000000;
r[3][0] = 0.538469310105683;
r[4][0] = 0.906179845938664;
//
w[0][0] = 0.236926885056189;
w[1][0] = 0.478628670499366;
w[2][0] = 0.568888888888889;
w[3][0] = 0.478628670499366;
w[4][0] = 0.236926885056189;
break;
case 6:
r[0][0] = -0.932469514203152;
r[1][0] = -0.661209386466265;
r[2][0] = -0.238619186083197;
r[3][0] = 0.238619186083197;
r[4][0] = 0.661209386466265;
r[5][0] = 0.932469514203152;
//
w[0][0] = 0.171324492379170;
w[1][0] = 0.360761573048139;
w[2][0] = 0.467913934572691;
w[3][0] = 0.467913934572691;
w[4][0] = 0.360761573048139;
w[5][0] = 0.171324492379170;
break;
case 7:
r[0][0] = -0.949107912342759;
r[1][0] = -0.741531185599394;
r[2][0] = -0.405845151377397;
r[3][0] = 0.000000000000000;
r[4][0] = 0.405845151377397;
r[5][0] = 0.741531185599394;
r[6][0] = 0.949107912342759;
//
w[0][0] = 0.129484966168870;
w[1][0] = 0.279705391489277;
w[2][0] = 0.381830050505119;
w[3][0] = 0.417959183673469;
w[4][0] = 0.381830050505119;
w[5][0] = 0.279705391489277;
w[6][0] = 0.129484966168870;
break;
case 8:
r[0][0] = -0.960289856497536;
r[1][0] = -0.796666477413627;
r[2][0] = -0.525532409916329;
r[3][0] = -0.183434642495650;
r[4][0] = 0.183434642495650;
r[5][0] = 0.525532409916329;
r[6][0] = 0.796666477413627;
r[7][0] = 0.960289856497536;
//
w[0][0] = 0.101228536290376;
w[1][0] = 0.222381034453374;
w[2][0] = 0.313706645877887;
w[3][0] = 0.362683783378362;
w[4][0] = 0.362683783378362;
w[5][0] = 0.313706645877887;
w[6][0] = 0.222381034453374;
w[7][0] = 0.101228536290376;
break;
case 9:
r[0][0] = -0.968160239507626;
r[1][0] = -0.836031170326636;
r[2][0] = -0.613371432700590;
r[3][0] = -0.324253423403809;
r[4][0] = 0.000000000000000;
r[5][0] = 0.324253423403809;
r[6][0] = 0.613371432700590;
r[7][0] = 0.836031107326636;
r[8][0] = 0.968160239507626;
//
w[0][0] = 0.081274388361574;
w[1][0] = 0.180648160694857;
w[2][0] = 0.260610696402935;
w[3][0] = 0.312347077040003;
w[4][0] = 0.330239355001260;
w[5][0] = 0.312347077040003;
w[6][0] = 0.260610696402935;
w[7][0] = 0.180648160694857;
w[8][0] = 0.081274388361574;
break;
default:
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"");
break;
}
}
DICE_LIB_DLL_EXPORT
void gauss_2D(Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & r,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & w,
int_t gauss_order){
r.clear();
w.clear();
r.resize(gauss_order*gauss_order);
w.resize(gauss_order*gauss_order);
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > kron_sol, zeta1,weight1;
kron_sol.resize(gauss_order*gauss_order);
for(int_t i=0;i<gauss_order*gauss_order;++i){
r[i].resize(2);
w[i].resize(1);
kron_sol[i].resize(1);
}
gauss_1D(zeta1, weight1, gauss_order);
int_t i=0,j=0;
int_t m = gauss_order; int_t n = 1;
// create a matrix of ones
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > ones;
ones.resize(m);
for(int_t i=0;i<m;++i)
ones[i].resize(n);
for(i=0;i<m;i++){
for(j=0;j<n;j++){
ones[i][j] = 1.0;
};
};
kron_sol = kronecker(ones,zeta1);
for(i=0;i<gauss_order*gauss_order;i++){
r[i][1] = kron_sol[i][0];
};
for(i=0;i<gauss_order;i++){
for(j=i*gauss_order; j< (i+1)*gauss_order;j++){
r[j][0] = zeta1[i][0];
};
};
w = kronecker(weight1,weight1);
}
DICE_LIB_DLL_EXPORT
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > kronecker( Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & A,
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > & B){
int_t B_i = 0;
int_t B_j = 0;
int_t nAx = A.size();
int_t nAy = A[0].size();
int_t nBx = B.size();
int_t nBy = B[0].size();
Teuchos::ArrayRCP<Teuchos::ArrayRCP<scalar_t> > C;
C.resize(nAx*nBx);
for(int_t i=0;i<nAx*nBx;++i)
C[i].resize(nAy*nBy);
for(int_t i = 0; i<nAx;i++){
for(int_t j = 0; j< nAy; j++){ // go through each entry in A
for(int_t n = i*nBx; n < (i+1)*nBx; n++){
B_i = n - i* nBx;
for(int_t m =j*nBy; m< (j+1)*nBy; m++){
B_j = m - j*nBy;
C[n][m] = A[i][j] * B[B_i][B_j];
};
};
};
};
return C;
};
DICE_LIB_DLL_EXPORT
void calc_jacobian(const scalar_t * xcap,
const scalar_t * DN,
scalar_t * jacobian,
scalar_t * inv_jacobian,
scalar_t & J,
int_t num_elem_nodes,
int_t dim ){
for(int_t i=0;i<dim*dim;++i){
jacobian[i] = 0.0;
inv_jacobian[i] = 0.0;
}
J = 0.0;
for(int_t i=0;i<dim;++i)
for(int_t j=0;j<dim;++j)
for(int_t k=0;k<num_elem_nodes;++k)
jacobian[i*dim+j] += xcap[k*dim + i] * DN[k*dim+j];
// std::cout << " jacobian " << std::endl;
// for(int_t i=0;i<dim;++i){
// for(int_t j=0;j<dim;++j)
// std::cout << " " << jacobian[i*dim+j];
// std::cout << std::endl;
// }
if(dim==2){
J = jacobian[0]*jacobian[3] - jacobian[1]*jacobian[2];
TEUCHOS_TEST_FOR_EXCEPTION(J<=0.0,std::runtime_error,"Error: determinant 0.0 encountered or negative det");
inv_jacobian[0] = jacobian[3] / J;
inv_jacobian[1] = -jacobian[1] / J;
inv_jacobian[2] = -jacobian[2] / J;
inv_jacobian[3] = jacobian[0] / J;
}
else if(dim==3){
J = jacobian[0]*jacobian[4]*jacobian[8] + jacobian[1]*jacobian[5]*jacobian[6] + jacobian[2]*jacobian[3]*jacobian[7]
- jacobian[6]*jacobian[4]*jacobian[2] - jacobian[7]*jacobian[5]*jacobian[0] - jacobian[8]*jacobian[3]*jacobian[1];
TEUCHOS_TEST_FOR_EXCEPTION(J<=0.0,std::runtime_error,"Error: determinant 0.0 encountered or negative det");
inv_jacobian[0] = ( -jacobian[5]*jacobian[7] + jacobian[4]*jacobian[8]) / J;
inv_jacobian[1] = ( jacobian[2]*jacobian[7] - jacobian[1]*jacobian[8]) / J;
inv_jacobian[2] = ( -jacobian[2]*jacobian[4] + jacobian[1]*jacobian[5]) / J;
inv_jacobian[3] = ( jacobian[5]*jacobian[6] - jacobian[3]*jacobian[8]) / J;
inv_jacobian[4] = ( -jacobian[2]*jacobian[6] + jacobian[0]*jacobian[8]) / J;
inv_jacobian[5] = ( jacobian[2]*jacobian[3] - jacobian[0]*jacobian[5]) / J;
inv_jacobian[6] = ( -jacobian[4]*jacobian[6] + jacobian[3]*jacobian[7]) / J;
inv_jacobian[7] = ( jacobian[1]*jacobian[6] - jacobian[0]*jacobian[7]) / J;
inv_jacobian[8] = ( -jacobian[1]*jacobian[3] + jacobian[0]*jacobian[4]) / J;
}
else
TEUCHOS_TEST_FOR_EXCEPTION(true,std::runtime_error,"");
// std::cout << " J " << J << std::endl;
// std::cout << " inv_jacobian " << std::endl;
// for(int_t i=0;i<dim;++i){
// for(int_t j=0;j<dim;++j)
// std::cout << " " << inv_jacobian[i*dim+j];
// std::cout << std::endl;
// }
};
DICE_LIB_DLL_EXPORT
void calc_B(const scalar_t * DN,
const scalar_t * inv_jacobian,
int_t num_elem_nodes,
int_t dim,
scalar_t * solid_B){
scalar_t * dN = new scalar_t[dim*num_elem_nodes];
for(int_t i=0;i<dim*num_elem_nodes;++i)
dN[i] = 0.0;
// std::cout << " DN " << std::endl;
// for(int_t j=0;j<num_elem_nodes;++j){
// for(int_t i=0;i<dim;++i)
// std::cout << " " << DN[j*dim+i];
// std::cout << std::endl;
// }
// compute j_inv_transpose * DN_transpose
for(int_t i=0;i<dim;++i)
for(int_t j=0;j<num_elem_nodes;++j)
for(int_t k=0;k<dim;++k)
dN[i*num_elem_nodes+j] += inv_jacobian[k*dim + i] * DN[j*dim+k];
// std::cout << " dN " << std::endl;
// for(int_t i=0;i<dim;++i){
// for(int_t j=0;j<num_elem_nodes;++j)
// std::cout << " " << dN[i*num_elem_nodes+j];
// std::cout << std::endl;
// }
const int_t stride = dim*num_elem_nodes;
int_t placer = 0;
if(dim ==3){
for(int_t i=0;i<6*dim*num_elem_nodes;++i)
solid_B[i] = 0.0;
for(int_t i=0;i<num_elem_nodes;i++){
placer = i*dim; // hold the place in B for each node
solid_B[0*stride + placer + 0] = dN[0*num_elem_nodes + i];
solid_B[1*stride + placer + 1] = dN[1*num_elem_nodes + i];
solid_B[2*stride + placer + 2] = dN[2*num_elem_nodes + i];
solid_B[3*stride + placer + 0] = dN[1*num_elem_nodes + i];
solid_B[3*stride + placer + 1] = dN[0*num_elem_nodes + i];
solid_B[4*stride + placer + 1] = dN[2*num_elem_nodes + i];
solid_B[4*stride + placer + 2] = dN[1*num_elem_nodes + i];
solid_B[5*stride + placer + 0] = dN[2*num_elem_nodes + i];
solid_B[5*stride + placer + 2] = dN[0*num_elem_nodes + i];
};
};
if(dim==2){
for(int_t i=0;i<3*dim*num_elem_nodes;++i)
solid_B[i] = 0.0;
for(int_t i=0;i<=num_elem_nodes;i++){
placer = i*dim; // hold the place in B for each node
solid_B[0*stride + placer + 0] = dN[0*num_elem_nodes + i];
solid_B[1*stride + placer + 1] = dN[1*num_elem_nodes + i];
solid_B[2*stride + placer + 0] = dN[1*num_elem_nodes + i];
solid_B[2*stride + placer + 1] = dN[0*num_elem_nodes + i];
};
};
// std::cout << " B " << std::endl;
// for(int_t i=0;i<6;++i){
// for(int_t j=0;j<num_elem_nodes*dim;++j)
// std::cout << " " << solid_B[i*(num_elem_nodes*dim)+j];
// std::cout << std::endl;
// }
delete [] dN;
}
} // DICe
|
26aaa8c10206054ccfca890651cca4866f31b58e
|
0a40dba1c8de8ca33b9b1a22b6287f8e0800c2fd
|
/include/lsag.h
|
4eecbef654f88a81b17c31ef88a605c37efc2bb7
|
[] |
no_license
|
levduc/DLSAG-prototype-number
|
383bb4118e0f341547e4537d2d6ce1ed494eaad3
|
95f849d724e6fe7ac7c15a278c6a81cb97e15020
|
refs/heads/master
| 2021-01-04T12:38:50.586410
| 2020-02-14T17:30:52
| 2020-02-14T17:30:52
| 240,554,085
| 1
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 980
|
h
|
lsag.h
|
//
// Created by dduck on 2/3/20.
//
#include <cstdint>
#include <stdio.h>
#include <sodium.h>
#include <iostream>
#include <string.h>
#ifndef DLSAG_LSAG_H
#define DLSAG_LSAG_H
struct lsag_keyPair{
uint8_t lsag_sk[crypto_core_ed25519_SCALARBYTES];
uint8_t lsag_pk[crypto_core_ed25519_BYTES];
};
struct lsag_signature{
struct edSK *scalarPoints;
uint8_t h0[crypto_core_ed25519_SCALARBYTES];
uint8_t keyImage[crypto_core_ed25519_BYTES];
};
struct edSK{
uint8_t skb[crypto_core_ed25519_SCALARBYTES];
};
struct edPK{
uint8_t pkb[crypto_core_ed25519_BYTES];
};
void lsag_gen_garbage_PKs(edPK *vecPK, uint32_t ringSize);
void lsag_keygen(lsag_keyPair *keyPair);
int lsag_sign(lsag_signature *signature, lsag_keyPair *keyPair, uint8_t* message, uint32_t message_len,
uint32_t ringSize, edPK *vecPK);
int lsag_verify(lsag_signature *signature, uint8_t* message, uint32_t message_len, uint32_t ringSize, edPK *vecPK);
#endif //DLSAG_LSAG_H
|
e99741d6560e54fabf310c453322e322534f17cf
|
43034f1ac5a203f83224b30a92672aab03821cca
|
/Cliente.h
|
d14786de9ba3d0f936a297d94d5a3bb5f85f8e4f
|
[] |
no_license
|
danielmmf/cpp_tests
|
66376833e112cf7a15f472bc8edf08050d51c57f
|
9f5182c71c3c198f697662fc34261e427fcf27c9
|
refs/heads/master
| 2021-06-28T05:38:06.186317
| 2017-09-11T03:54:08
| 2017-09-11T03:54:08
| 103,068,203
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 532
|
h
|
Cliente.h
|
#pragma once
#include<iostream>
#include<string>
#include <locale>
#ifndef CLIENTE_H__
#define CLIENTE_H__
using namespace std;
class Cliente{
public:
Cliente();
~Cliente();
int codigo;
int getCodigo();
bool setCodigo(int cod);
bool setNome(string nome);
bool setCpf(string cpf);
string getNome();
string getCpf();
Cliente procurarNome(string nome);
private:
int cod;
string nome;
string cpf;
char descricao;
};
//depois de assinar o metodo aqui , crie ele no arquivo cpp desse header
#endif
|
8c26a2903933324547b5a3c5fb591588a85230fc
|
dcca86d376f43f8e921dd8c88b136390a6186eca
|
/1042/main.cpp
|
575cfd9786bad035285bad82b5f8d99814f0d9b8
|
[] |
no_license
|
wxy3265/NOIP
|
66768430d7523ff9f62ddcc8031488d85db57848
|
6bcf0857791248194671aa64b7416c7a3efdc063
|
refs/heads/master
| 2021-01-19T17:31:53.334821
| 2018-01-13T02:44:18
| 2018-01-13T02:44:18
| 100,245,342
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,638
|
cpp
|
main.cpp
|
#include <iostream>
using namespace std;
void change(int* a, int* b);
int main()
{
int n;
cin >> n;
int id[n], chinese[n], math[n], english[n], score[n];
int i;
for (i = 0; i < n; i++) {
id[i] = i + 1;
cin >> chinese[i] >> math[i] >> english[i];
score[i] = chinese[i] + math[i] + english[i];
}
int max = score[0], maxnum, max1;
int j;
bool flag = false, flag1 = false;
for (i = 0; i < n; i++) {
//cout << "~ i :" << i << endl;
max = score[i];
flag = false;
flag1 = false;
for (j = i + 1; j < n; j++) {
if (score[j] > max) {
max = score[j];
maxnum = j;
flag = true;
}
}
if (flag) {
change(&chinese[maxnum], &chinese[i]);
change(&score[maxnum], &score[i]);
change(&id[maxnum], &id[i]);
}
max = chinese[i];
max1 = id[i];
for (j = i + 1; j < n; j++) {
if (score[j] == score[i] && (chinese[j] > max || (chinese[j] == max && id[j] < max1))) {
flag1 = true;
maxnum = j;
max1 = id[j];
max = chinese[j];
}
}
if (flag1) {
change(&chinese[maxnum], &chinese[i]);
change(&score[maxnum], &score[i]);
change(&id[maxnum], &id[i]);
}
}
for (i = 0; i < 5; i++) {
cout << id[i] << " " << score[i] << endl;
}
return 0;
}
void change(int *a, int *b)
{
int c;
c = *a;
*a = *b;
*b = c;
}
|
df9003907aebbebf9e2b43adfcaa08731937abe5
|
ede27af111a24fb36550c4e943e8ca4324ae9a64
|
/Client/clientMain.cpp
|
281375b8f2918809cccd882d9059f9bad8a751be
|
[
"MIT"
] |
permissive
|
shawnvision7264/tcp-protocol
|
e959c0d22a55afa1c55cb21706db824b7943d7eb
|
7011195b529dbcb0761d2b1d0131bdb209c1365d
|
refs/heads/master
| 2021-03-17T08:52:43.740455
| 2019-01-25T06:59:04
| 2019-01-25T06:59:04
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 278
|
cpp
|
clientMain.cpp
|
#include <iostream>
#include "Client/Client.h"
using namespace std;
int main() {
Client client("client.txt");
int stopAndWait = 0;
int selective_repeat = 1;
int GBN = 2;
client.connect_to_server();
client.receive_file(selective_repeat);
return 0;
}
|
894807ced6ae67b7d2e44dfe723a46fc428a1dab
|
412490586f58cd690eea9bb0fdc30bb1fafa79e1
|
/gdb/kernel/core/src/geometry/vertex2f.cpp
|
fe4a52906b21e1f5bbaadad08f9ae737ffb5ea1b
|
[] |
no_license
|
xyfigo/gtl
|
a93e236557fc3eee73fe8025775cef22977be125
|
2468d858dec43d664e7aafa252e1d2b79623fba1
|
refs/heads/master
| 2020-04-15T15:55:41.025404
| 2017-03-29T04:09:30
| 2017-03-29T04:09:30
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 419
|
cpp
|
vertex2f.cpp
|
#include "vertex2f.h"
begin_gtl_namespace
begin_gdb_namespace
Vertex2f::Vertex2f() :x(0), y(0){ }
Vertex2f::Vertex2f(float xx, float yy) : x(xx), y(yy){ }
Vertex2f::Vertex2f(const Vertex2f & vt) {
x = vt.x; y = vt.y;
}
void Vertex2f::operator*=(float rhd){
x *= rhd;
y *= rhd;
}
Vertex2f Vertex2f::operator = (const Vertex2f & c){
x = c.x; y = c.y;
return *this;
}
end_gdb_namespace
end_gtl_namespace
|
e46a945a7ae70ba2cbc6b4c6d07329041fbfa48c
|
13c31f17496ece324b6f4ed8a332a145d7509d62
|
/demo/glyphy-demo.cc
|
2ecd3e533183ae248609cd7e5a1ded64c6c768e2
|
[
"Apache-2.0"
] |
permissive
|
behdad/glyphy
|
020690d6ed9c3528684599d6a0bbc4a01beb4d7d
|
68a5f8d8ae64e0158d776b21581d0ecb70ec8304
|
refs/heads/master
| 2023-08-31T05:26:57.222215
| 2023-07-04T18:36:52
| 2023-07-07T14:53:10
| 5,050,513
| 638
| 79
|
NOASSERTION
| 2023-07-07T14:53:11
| 2012-07-14T19:49:03
|
C++
|
UTF-8
|
C++
| false
| false
| 6,451
|
cc
|
glyphy-demo.cc
|
/*
* Copyright 2012 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.
*
* Google Author(s): Behdad Esfahbod, Maysum Panju, Wojciech Baranowski
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef _WIN32
#include <libgen.h>
#include <unistd.h>
#endif
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include "demo-buffer.h"
#include "demo-font.h"
#include "demo-view.h"
static demo_glstate_t *st;
static demo_view_t *vu;
static demo_buffer_t *buffer;
#define WINDOW_W 700
#define WINDOW_H 700
#ifdef _WIN32
static int isroot(const char *path)
{
return ((strlen(path) == 1 && path[0] == '/') ||
(strlen(path) == 3 && isalpha(path[0]) && path[1] == ':' && (path[2] == '/' || path[2] == '\\')));
}
static char *basename(char *path)
{
if (path == NULL || *path == '\0')
return (char *)".";
while ((path[strlen(path)-1] == '/' ||
path[strlen(path)-1] == '\\') &&
!isroot(path))
path[strlen(path)-1] = '\0';
if (isroot(path))
return path;
char *slash = strrchr(path, '/');
char *backslash = strrchr(path, '\\');
if (slash != NULL && (backslash == NULL || backslash < slash))
return slash + 1;
else if (backslash != NULL && (slash == NULL || slash < backslash))
return backslash + 1;
else
return path;
}
static int opterr = 1;
static int optind = 1;
static int optopt;
static char *optarg;
static int getopt(int argc, char *argv[], char *opts)
{
static int sp = 1;
int c;
char *cp;
if (sp == 1) {
if (optind >= argc ||
argv[optind][0] != '-' || argv[optind][1] == '\0')
return EOF;
else if (!strcmp(argv[optind], "--")) {
optind++;
return EOF;
}
}
optopt = c = argv[optind][sp];
if (c == ':' || !(cp = strchr(opts, c))) {
fprintf(stderr, ": illegal option -- %c\n", c);
if (argv[optind][++sp] == '\0') {
optind++;
sp = 1;
}
return '?';
}
if (*++cp == ':') {
if (argv[optind][sp+1] != '\0')
optarg = &argv[optind++][sp+1];
else if(++optind >= argc) {
fprintf(stderr, ": option requires an argument -- %c\n", c);
sp = 1;
return '?';
} else
optarg = argv[optind++];
sp = 1;
} else {
if (argv[optind][++sp] == '\0') {
sp = 1;
optind++;
}
optarg = NULL;
}
return c;
}
#endif
static void
reshape_func (int width, int height)
{
demo_view_reshape_func (vu, width, height);
}
static void
keyboard_func (unsigned char key, int x, int y)
{
demo_view_keyboard_func (vu, key, x, y);
}
static void
special_func (int key, int x, int y)
{
demo_view_special_func (vu, key, x, y);
}
static void
mouse_func (int button, int state, int x, int y)
{
demo_view_mouse_func (vu, button, state, x, y);
}
static void
motion_func (int x, int y)
{
demo_view_motion_func (vu, x, y);
}
static void
display_func (void)
{
demo_view_display (vu, buffer);
}
static void
show_usage(const char *path)
{
char *name, *p = strdup(path);
name = basename(p);
printf("Usage:\n"
" %s [fontfile [text]]\n"
"or:\n"
" %s [-h] [-f fontfile] [-t text]\n"
"\n"
" -h show this help message and exit;\n"
" -t text the text string to be rendered; \n"
" -f fontfile the font file (e.g. /Library/Fonts/Microsoft/Verdana.ttf)\n"
"\n", name, name);
free(p);
}
int
main (int argc, char** argv)
{
/* Process received parameters */
# include "default-text.h"
const char *text = NULL;
const char *font_path = NULL;
char arg;
while ((arg = getopt(argc, argv, (char *)"t:f:h")) != -1) {
switch (arg) {
case 't':
text = optarg;
break;
case 'f':
font_path = optarg;
break;
case 'h':
show_usage(argv[0]);
return 0;
default:
return 1;
}
}
if (!font_path)
{
if (optind < argc)
font_path = argv[optind++];
}
if (!text)
{
if (optind < argc)
text = argv[optind++];
else
text = default_text;
}
if (!text || optind < argc)
{
show_usage(argv[0]);
return 1;
}
/* Setup glut */
glutInit (&argc, argv);
glutInitWindowSize (WINDOW_W, WINDOW_H);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
int window = glutCreateWindow ("GLyphy Demo");
glutReshapeFunc (reshape_func);
glutDisplayFunc (display_func);
glutKeyboardFunc (keyboard_func);
glutSpecialFunc (special_func);
glutMouseFunc (mouse_func);
glutMotionFunc (motion_func);
/* Setup glew */
if (GLEW_OK != glewInit ())
die ("Failed to initialize GL; something really broken");
if (!glewIsSupported ("GL_VERSION_2_0"))
die ("OpenGL 2.0 not supported");
st = demo_glstate_create ();
vu = demo_view_create (st);
demo_view_print_help (vu);
hb_blob_t *blob = NULL;
if (font_path)
{
blob = hb_blob_create_from_file_or_fail (font_path);
}
else
{
#ifdef _WIN32
blob = hb_blob_create_from_file_or_fail ("C:\\Windows\\Fonts\\calibri.ttf");
#else
#include "default-font.h"
blob = hb_blob_create ((const char *) default_font, sizeof (default_font),
HB_MEMORY_MODE_READONLY, NULL, NULL);
#endif
}
if (!blob)
die ("Failed to open font file");
hb_face_t *hb_face = hb_face_create (blob, 0);
demo_font_t *font = demo_font_create (hb_face, demo_glstate_get_atlas (st));
buffer = demo_buffer_create ();
glyphy_point_t top_left = {0, 0};
demo_buffer_move_to (buffer, &top_left);
demo_buffer_add_text (buffer, text, font, 1);
demo_font_print_stats (font);
demo_view_setup (vu);
glutMainLoop ();
demo_buffer_destroy (buffer);
demo_font_destroy (font);
hb_face_destroy (hb_face);
hb_blob_destroy (blob);
demo_view_destroy (vu);
demo_glstate_destroy (st);
glutDestroyWindow (window);
return 0;
}
|
29706748d74ad93facea00846b83bb147f221a80
|
fdcae9bcce8ee53d572a351a6811047edbbd3b3e
|
/code/Singularity_Engine/include/common/DelegateHandler.h
|
1cd7d66ccb3eec29d9370e063b952bba1b79e459
|
[] |
no_license
|
jobelobes/Ultragon.Games.TriggerHappy
|
d4378e34946759e4f19db14fc09120e4086dc3b8
|
f438b5d3af4ff2173f9b02a489a8c907c48a9bf5
|
refs/heads/master
| 2021-03-24T12:44:34.589323
| 2012-06-28T22:37:04
| 2012-06-28T22:37:04
| 4,823,923
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 828
|
h
|
DelegateHandler.h
|
#include "common\Singularity.Common.h"
namespace Singularity
{
class DelegateHandler
{
private:
#pragma region Variables
DynamicList<IDelegate*> m_pDelegates;
#pragma endregion
public:
#pragma region Constructors and Finalizers
DelegateHandler();
~DelegateHandler();
#pragma endregion
#pragma region Methods
unsigned Count();
#pragma endregion
#pragma region Methods
void Add(IDelegate* method);
void Remove(IDelegate* method);
void Clear();
#pragma endregion
#pragma region Overriden Operators
DelegateHandler& operator += (IDelegate* method);
DelegateHandler& operator -= (IDelegate* method);
bool operator == (const DelegateHandler* other) const;
IDelegate* operator [] (unsigned index) const;
#pragma endregion
};
}
|
35a86b472462d4102a57a26f1ce0d1dcfcd161ec
|
06a85cf0123dd2a27f75e145d4c233fb25eb393b
|
/hdu/2042.cpp
|
0e2827465a53589299b83ee6d3c3ede82448e39b
|
[] |
no_license
|
nosyndicate/onlinejudge
|
6db7f50382751310a9b0ce48cf56bb2a258a1800
|
2a7b775e182eafdb7ca349f5c56d694f40072f58
|
refs/heads/master
| 2021-01-19T08:16:57.045164
| 2014-04-07T06:24:16
| 2014-04-07T06:24:16
| 1,598,029
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 288
|
cpp
|
2042.cpp
|
//http://acm.hdu.edu.cn/showproblem.php?pid=2042
#include <stdio.h>
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int t,ret = 3;
scanf("%d",&t);
for(int i = 0;i<t;++i)
{
ret = (ret-1)*2;
}
printf("%d\n",ret);
}
return 0;
}
|
db8a889b0aa288817af9bfe8fc690a3740305557
|
7579d827cb7b50b438dfd9ef6fa80ba2797848c9
|
/sources/plug_osg/src/luna/bind_osgUtil_AddRangeOperator.cpp
|
114fcecb1781adc02eae86ceb949859750ab5087
|
[] |
no_license
|
roche-emmanuel/sgt
|
809d00b056e36b7799bbb438b8099e3036377377
|
ee3a550f6172c7d14179d9d171e0124306495e45
|
refs/heads/master
| 2021-05-01T12:51:39.983104
| 2014-09-08T03:35:15
| 2014-09-08T03:35:15
| 79,538,908
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 11,034
|
cpp
|
bind_osgUtil_AddRangeOperator.cpp
|
#include <plug_common.h>
class luna_wrapper_osgUtil_AddRangeOperator {
public:
typedef Luna< osgUtil::AddRangeOperator > luna_t;
inline static bool _lg_typecheck___eq(lua_State *L) {
if( lua_gettop(L)!=2 ) return false;
if( !Luna<void>::has_uniqueid(L,1,12139482) ) return false;
return true;
}
static int _bind___eq(lua_State *L) {
if (!_lg_typecheck___eq(L)) {
luaL_error(L, "luna typecheck failed in __eq function, expected prototype:\n__eq(osgUtil::AddRangeOperator*). Got arguments:\n%s",luna_dumpStack(L).c_str());
}
osgUtil::AddRangeOperator* rhs =(Luna< osgUtil::AddRangeOperator >::check(L,2));
osgUtil::AddRangeOperator* self=(Luna< osgUtil::AddRangeOperator >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call __eq(...)");
}
lua_pushboolean(L,self==rhs?1:0);
return 1;
}
inline static bool _lg_typecheck_fromVoid(lua_State *L) {
if( lua_gettop(L)!=1 ) return false;
if( !Luna<void>::has_uniqueid(L,1,3625364) ) return false;
return true;
}
static int _bind_fromVoid(lua_State *L) {
if (!_lg_typecheck_fromVoid(L)) {
luaL_error(L, "luna typecheck failed in fromVoid function, expected prototype:\nfromVoid(void*). Got arguments:\n%s",luna_dumpStack(L).c_str());
}
osgUtil::AddRangeOperator* self= (osgUtil::AddRangeOperator*)(Luna< void >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call fromVoid(...)");
}
Luna< osgUtil::AddRangeOperator >::push(L,self,false);
return 1;
}
inline static bool _lg_typecheck_asVoid(lua_State *L) {
if( lua_gettop(L)!=1 ) return false;
if( !Luna<void>::has_uniqueid(L,1,12139482) ) return false;
return true;
}
static int _bind_asVoid(lua_State *L) {
if (!_lg_typecheck_asVoid(L)) {
luaL_error(L, "luna typecheck failed in fromVoid function, expected prototype:\nasVoid(). Got arguments:\n%s",luna_dumpStack(L).c_str());
}
void* self= (void*)(Luna< osgUtil::AddRangeOperator >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call asVoid(...)");
}
Luna< void >::push(L,self,false);
return 1;
}
// Base class dynamic cast support:
inline static bool _lg_typecheck_dynCast(lua_State *L) {
if( lua_gettop(L)!=2 ) return false;
if( lua_type(L,2)!=LUA_TSTRING ) return false;
return true;
}
static int _bind_dynCast(lua_State *L) {
if (!_lg_typecheck_dynCast(L)) {
luaL_error(L, "luna typecheck failed in dynCast function, expected prototype:\ndynCast(const std::string &). Got arguments:\n%s",luna_dumpStack(L).c_str());
}
std::string name(lua_tostring(L,2),lua_objlen(L,2));
osgUtil::AddRangeOperator* self=(Luna< osgUtil::AddRangeOperator >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call dynCast(...)");
}
static LunaConverterMap& converters = luna_getConverterMap("osgUtil::AddRangeOperator");
return luna_dynamicCast(L,converters,"osgUtil::AddRangeOperator",name);
}
// Constructor checkers:
// Function checkers:
inline static bool _lg_typecheck_getBegin(lua_State *L) {
if( lua_gettop(L)!=1 ) return false;
return true;
}
inline static bool _lg_typecheck_getCount(lua_State *L) {
if( lua_gettop(L)!=1 ) return false;
return true;
}
inline static bool _lg_typecheck_getVector(lua_State *L) {
if( lua_gettop(L)!=1 ) return false;
return true;
}
inline static bool _lg_typecheck_setBegin(lua_State *L) {
if( lua_gettop(L)!=2 ) return false;
if( (lua_type(L,2)!=LUA_TNUMBER || lua_tointeger(L,2) != lua_tonumber(L,2)) ) return false;
return true;
}
inline static bool _lg_typecheck_setCount(lua_State *L) {
if( lua_gettop(L)!=2 ) return false;
if( (lua_type(L,2)!=LUA_TNUMBER || lua_tointeger(L,2) != lua_tonumber(L,2)) ) return false;
return true;
}
inline static bool _lg_typecheck_setVector(lua_State *L) {
if( lua_gettop(L)!=2 ) return false;
if( !Luna<void>::has_uniqueid(L,2,92303202) ) return false;
return true;
}
// Operator checkers:
// (found 0 valid operators)
// Constructor binds:
// Function binds:
// unsigned int osgUtil::AddRangeOperator::_begin()
static int _bind_getBegin(lua_State *L) {
if (!_lg_typecheck_getBegin(L)) {
luaL_error(L, "luna typecheck failed in unsigned int osgUtil::AddRangeOperator::_begin() function, expected prototype:\nunsigned int osgUtil::AddRangeOperator::_begin()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str());
}
osgUtil::AddRangeOperator* self=(Luna< osgUtil::AddRangeOperator >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call unsigned int osgUtil::AddRangeOperator::_begin(). Got : '%s'\n%s",typeid(Luna< osgUtil::AddRangeOperator >::check(L,1)).name(),luna_dumpStack(L).c_str());
}
unsigned int lret = self->_begin;
lua_pushnumber(L,lret);
return 1;
}
// unsigned int osgUtil::AddRangeOperator::_count()
static int _bind_getCount(lua_State *L) {
if (!_lg_typecheck_getCount(L)) {
luaL_error(L, "luna typecheck failed in unsigned int osgUtil::AddRangeOperator::_count() function, expected prototype:\nunsigned int osgUtil::AddRangeOperator::_count()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str());
}
osgUtil::AddRangeOperator* self=(Luna< osgUtil::AddRangeOperator >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call unsigned int osgUtil::AddRangeOperator::_count(). Got : '%s'\n%s",typeid(Luna< osgUtil::AddRangeOperator >::check(L,1)).name(),luna_dumpStack(L).c_str());
}
unsigned int lret = self->_count;
lua_pushnumber(L,lret);
return 1;
}
// osg::Vec3d osgUtil::AddRangeOperator::_vector()
static int _bind_getVector(lua_State *L) {
if (!_lg_typecheck_getVector(L)) {
luaL_error(L, "luna typecheck failed in osg::Vec3d osgUtil::AddRangeOperator::_vector() function, expected prototype:\nosg::Vec3d osgUtil::AddRangeOperator::_vector()\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str());
}
osgUtil::AddRangeOperator* self=(Luna< osgUtil::AddRangeOperator >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call osg::Vec3d osgUtil::AddRangeOperator::_vector(). Got : '%s'\n%s",typeid(Luna< osgUtil::AddRangeOperator >::check(L,1)).name(),luna_dumpStack(L).c_str());
}
const osg::Vec3d* lret = &self->_vector;
if(!lret) return 0; // Do not write NULL pointers.
Luna< osg::Vec3d >::push(L,lret,false);
return 1;
}
// void osgUtil::AddRangeOperator::_begin(unsigned int value)
static int _bind_setBegin(lua_State *L) {
if (!_lg_typecheck_setBegin(L)) {
luaL_error(L, "luna typecheck failed in void osgUtil::AddRangeOperator::_begin(unsigned int value) function, expected prototype:\nvoid osgUtil::AddRangeOperator::_begin(unsigned int value)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str());
}
unsigned int value=(unsigned int)lua_tointeger(L,2);
osgUtil::AddRangeOperator* self=(Luna< osgUtil::AddRangeOperator >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call void osgUtil::AddRangeOperator::_begin(unsigned int). Got : '%s'\n%s",typeid(Luna< osgUtil::AddRangeOperator >::check(L,1)).name(),luna_dumpStack(L).c_str());
}
self->_begin = value;
return 0;
}
// void osgUtil::AddRangeOperator::_count(unsigned int value)
static int _bind_setCount(lua_State *L) {
if (!_lg_typecheck_setCount(L)) {
luaL_error(L, "luna typecheck failed in void osgUtil::AddRangeOperator::_count(unsigned int value) function, expected prototype:\nvoid osgUtil::AddRangeOperator::_count(unsigned int value)\nClass arguments details:\n\n%s",luna_dumpStack(L).c_str());
}
unsigned int value=(unsigned int)lua_tointeger(L,2);
osgUtil::AddRangeOperator* self=(Luna< osgUtil::AddRangeOperator >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call void osgUtil::AddRangeOperator::_count(unsigned int). Got : '%s'\n%s",typeid(Luna< osgUtil::AddRangeOperator >::check(L,1)).name(),luna_dumpStack(L).c_str());
}
self->_count = value;
return 0;
}
// void osgUtil::AddRangeOperator::_vector(osg::Vec3d value)
static int _bind_setVector(lua_State *L) {
if (!_lg_typecheck_setVector(L)) {
luaL_error(L, "luna typecheck failed in void osgUtil::AddRangeOperator::_vector(osg::Vec3d value) function, expected prototype:\nvoid osgUtil::AddRangeOperator::_vector(osg::Vec3d value)\nClass arguments details:\narg 1 ID = 92303202\n\n%s",luna_dumpStack(L).c_str());
}
osg::Vec3d* value_ptr=(Luna< osg::Vec3d >::check(L,2));
if( !value_ptr ) {
luaL_error(L, "Dereferencing NULL pointer for arg value in osgUtil::AddRangeOperator::_vector function");
}
osg::Vec3d value=*value_ptr;
osgUtil::AddRangeOperator* self=(Luna< osgUtil::AddRangeOperator >::check(L,1));
if(!self) {
luaL_error(L, "Invalid object in function call void osgUtil::AddRangeOperator::_vector(osg::Vec3d). Got : '%s'\n%s",typeid(Luna< osgUtil::AddRangeOperator >::check(L,1)).name(),luna_dumpStack(L).c_str());
}
self->_vector = value;
return 0;
}
// Operator binds:
};
osgUtil::AddRangeOperator* LunaTraits< osgUtil::AddRangeOperator >::_bind_ctor(lua_State *L) {
return NULL; // No valid default constructor.
}
void LunaTraits< osgUtil::AddRangeOperator >::_bind_dtor(osgUtil::AddRangeOperator* obj) {
delete obj;
}
const char LunaTraits< osgUtil::AddRangeOperator >::className[] = "AddRangeOperator";
const char LunaTraits< osgUtil::AddRangeOperator >::fullName[] = "osgUtil::AddRangeOperator";
const char LunaTraits< osgUtil::AddRangeOperator >::moduleName[] = "osgUtil";
const char* LunaTraits< osgUtil::AddRangeOperator >::parents[] = {0};
const int LunaTraits< osgUtil::AddRangeOperator >::hash = 12139482;
const int LunaTraits< osgUtil::AddRangeOperator >::uniqueIDs[] = {12139482,0};
luna_RegType LunaTraits< osgUtil::AddRangeOperator >::methods[] = {
{"getBegin", &luna_wrapper_osgUtil_AddRangeOperator::_bind_getBegin},
{"getCount", &luna_wrapper_osgUtil_AddRangeOperator::_bind_getCount},
{"getVector", &luna_wrapper_osgUtil_AddRangeOperator::_bind_getVector},
{"setBegin", &luna_wrapper_osgUtil_AddRangeOperator::_bind_setBegin},
{"setCount", &luna_wrapper_osgUtil_AddRangeOperator::_bind_setCount},
{"setVector", &luna_wrapper_osgUtil_AddRangeOperator::_bind_setVector},
{"dynCast", &luna_wrapper_osgUtil_AddRangeOperator::_bind_dynCast},
{"__eq", &luna_wrapper_osgUtil_AddRangeOperator::_bind___eq},
{"fromVoid", &luna_wrapper_osgUtil_AddRangeOperator::_bind_fromVoid},
{"asVoid", &luna_wrapper_osgUtil_AddRangeOperator::_bind_asVoid},
{0,0}
};
luna_ConverterType LunaTraits< osgUtil::AddRangeOperator >::converters[] = {
{0,0}
};
luna_RegEnumType LunaTraits< osgUtil::AddRangeOperator >::enumValues[] = {
{0,0}
};
|
470c01cee0fd6a2c6a12735cc2fb87b56b79c6f8
|
f9997ffeffa371b83f31419327932944e3622964
|
/openGL_00/src/SphericalHarmonicsLighting.h
|
4b324f60d7882321a4f3f29673f1660d9ce623df
|
[] |
no_license
|
joaodafonseca/OPENGL_studies
|
d984b7a14795c5f8eb1d10d5d924953436d0dbba
|
608700d61a96103b7021257388fa871a082e9ee9
|
refs/heads/master
| 2018-12-28T07:56:22.719550
| 2015-09-19T09:20:24
| 2015-09-19T09:20:24
| 42,767,087
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 721
|
h
|
SphericalHarmonicsLighting.h
|
//
// SphericalHarmonisLighting.h
// openGL_00
//
// Created by João Fonseca on 28/06/15.
//
//
#pragma once
#include "Scene.h"
#include "ofMain.h"
#include "ofxGui.h"
#include "ofxAssimpModelLoader.h"
class SphericalHarmonicsLighting : public Scene {
public:
SphericalHarmonicsLighting();
void setup();
void update();
void draw();
void reloadShader();
string title;
ofMatrix3x3 mat4ToMat3(ofMatrix4x4 mat4);
ofShader shader;
ofSpherePrimitive sphere;
//this is our model we'll draw
ofxAssimpModelLoader model;
ofEasyCam cam;
ofImage texture[3];
ofParameter<float> ScaleFactor;
ofxPanel gui;
};
|
23631f22ae6903e6326d1cfb21e19aef6577eced
|
5d7afd39f8dc6660b5c7486b37f8f1f6117eeb30
|
/medium/519_random_flip_matrix.cpp
|
14b88b8cc092fb86a1277557c9123774ac88dcd9
|
[] |
no_license
|
JackieCkc/leetcode
|
4bdf02ca731358e1d7c81cf1af736703ba860508
|
49136647219abb17573a4b9cbe9579c9a47702c0
|
refs/heads/master
| 2020-06-05T07:44:01.522927
| 2020-01-18T06:40:15
| 2020-01-18T06:40:15
| 192,363,980
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,225
|
cpp
|
519_random_flip_matrix.cpp
|
#include <iostream>
#include <map>
#include <vector>
#include <tuple>
#include <array>
#include <stack>
#include <math.h>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
using namespace std;
#define f(x, n) for (int x = 0; x < n; x++)
#define f1(x, s, n) for (int x = s; x < n; x++)
typedef vector<int> int_arr;
typedef vector<string> str_arr;
typedef vector<vector<int>> int2_arr;
typedef vector<vector<string>> str2_arr;
template <typename T>
void print(T t) {
cout << t << endl ;
}
template<typename T, typename... Args>
void print(T t, Args... args) {
cout << t << " ";
print(args...);
}
class Solution {
public:
Solution(int n_rows, int n_cols) {
n = n_rows;
c = n_cols;
t = n * c;
curr = t;
}
vector<int> flip() {
int i = (rand() % curr) + 1;
int i1 = i;
if (m.count(i)) {
i = m[i];
}
int b = curr;
if (m.count(curr)) {
b = m[curr];
}
m[i1] = b;
i -= 1;
curr -= 1;
return {i / c, i % c};
}
void reset() {
curr = t;
m.clear();
}
private:
map<int, int> m;
int n, c, t, curr;
};
|
65f5547846e910cf2e8103b9721a4739bacb2b68
|
111c3ebecfa9eac954bde34b38450b0519c45b86
|
/SDK_Perso/include/WeaponBlocks/Include/constraint_base.h
|
4a9d702fef5ce0c6b521a12726253be9d4e84f86
|
[] |
no_license
|
1059444127/NH90
|
25db189bb4f3b7129a3c6d97acb415265339dab7
|
a97da9d49b4d520ad169845603fd47c5ed870797
|
refs/heads/master
| 2021-05-29T14:14:33.309737
| 2015-10-05T17:06:10
| 2015-10-05T17:06:10
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,232
|
h
|
constraint_base.h
|
#ifndef __CONSTRAINT_BASE_H__
#define __CONSTRAINT_BASE_H__
#include "WeaponBlocks.h"
#include "Math/Vector.h"
#include "Math/Rotation3.h"
enum eConstraintType
{
CONSTRAINT_FIXED,
CONSTRAINT_RAIL,
CONSTRAINT_ROTATION
};
class wAmmunition;
// Для запроса положения и скорости связи, а также для различных операций типа разъединения
class wIConstraintHost
{
public:
/* // FIXME: wAmmunition тут уместно?
virtual void attachClient(const wAmmunition* client) = 0;
virtual void detachClient(const wAmmunition* client) = 0;*/
// Это все относится к хосту
virtual Math::Vec3d getGlobalPosition() = 0;
virtual Math::Vec3d getGlobalVelocity() = 0;
virtual Math::Matrix3d getGlobalOrientation() = 0;
// В локальной системе координат (хоста)
virtual Math::Vec3d getLocalAcceleration() = 0;
virtual Math::Vec3d getLocalAngularVelocity() = 0;
virtual Math::Vec3d getLocalAngularAcceleration() = 0;
virtual void acceptImpulse(const Math::Vec3d& pos, const Math::Vec3d& impulse) = 0;
};
// Сочленение считается жестко закрепленным на хосте со смещением position_ (в системе координат хоста) и ориентацией
// orientation_
class WEAPON_BLOCKS_API wConstraintBase
{
public:
wConstraintBase();
wConstraintBase(wIConstraintHost* host, const Math::Vec3d& position, const Math::Matrix3d& orientation);
virtual ~wConstraintBase() {};
virtual eConstraintType getType() const = 0;
// В мировой системе координат
Math::Vec3d getGlobalPosition();
Math::Vec3d getGlobalVelocity();
Math::Matrix3d getGlobalOrientation();
Math::Vec3d getGlobalAngularVelocity();
Math::Vec3d getLocalAngularVelocity();
// Позиция и ориентация в системе координат хоста
Math::Vec3d getHostLocalPosition() { return position_; }
Math::Matrix3d getHostLocalOrientation() { return orientation_; }
wIConstraintHost* getHost() { return host_; }
protected:
wIConstraintHost* host_;
Math::Vec3d position_;
Math::Matrix3d orientation_;
};
#endif
|
18513c781900925f826bc7ff17abc30595970876
|
46a2d51a6a25a54c5821c978bc0d8af80ad46ba1
|
/2D_횡스크롤_슈팅/TeamProjects/TeamProject/Player.cpp
|
83ded0e3cb005a3b7422826f098b7fbea099b212
|
[] |
no_license
|
charles6919/StudyStorage
|
b0421fc885e356cc02fe7a4e2b4db96cb524af32
|
619dcfe332fd5755680324ad6503c6b0ebb8313e
|
refs/heads/master
| 2021-08-28T06:39:54.010103
| 2021-08-17T07:55:26
| 2021-08-17T07:55:26
| 221,620,060
| 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 6,942
|
cpp
|
Player.cpp
|
#include "stdafx.h"
#include "Player.h"
Player::Player()
{
m_pAniCharacter = NULL;
m_pAniGun = NULL;
m_pHitCollider = NULL;
m_pFootCollider = NULL;
{
g_pTextureManager->AddTexture(L"Player", L"CupHead_Sprites.png");
g_pTextureManager->AddTexture(L"Player_Gun_R", L"CupHead_HandGun_Idle_R.png");
g_pTextureManager->AddTexture(L"Player_Gun_L", L"CupHead_HandGun_Idle_L.png");
}
}
Player::~Player()
{
SAFE_DELETE(m_pAniCharacter );
SAFE_DELETE(m_pAniGun );
SAFE_DELETE(m_pHitCollider );
SAFE_DELETE(m_pFootCollider );
}
void Player::Init()
{
Character::Init();
m_pTransform2D->SetPosition(WINSIZEX * 0.5f, GroundY);
m_pTransform2D->SetScale(128, 128);
m_nHp = 3;
m_pRigidBody->SetDrag(150);
m_ePlayerState = Player_State::Idle_R;
m_eState = IDLE;
m_eGunState = Gun_State::Idle_R;
m_isJumping = false;
m_isShooting = false;
m_isSitting = false;
m_isHit = false;
m_fJumpPower = 300.0f;
m_fMoveSpeed = 300.0f;
m_fGunAngle = 0.0f;
m_enableToShot = true;
m_fShotTimer = 0.0f;
m_fShotDelay = 0.25f;
m_fInvinvibleTimer = 0.0f;
m_fInvincibleDuration = 1.0f;
m_isInvincible = false;
m_isTwinkleOn = true;
m_fTwinkleTimer = 0.0f;
m_fTwinkleDuration = 0.05f;
}
void Player::Update()
{
float dirX = m_vDir.x;
ImGui::InputFloat("DirX", &dirX);
if (m_fShotTimer >= m_fShotDelay)
{
m_fShotTimer = 0.0f;
m_enableToShot = true;
}
m_fShotTimer += g_pTimeManager->GetDeltaTime();
if (m_isInvincible)
{
if (m_fInvinvibleTimer >= m_fInvincibleDuration)
{
m_isHit = false;
m_fInvinvibleTimer = 0.0f;
m_isInvincible = false;
m_pAniCharacter->SetColorAllClip(D3DXCOLOR(1, 1, 1, 1));
}
m_fInvinvibleTimer += g_pTimeManager->GetDeltaTime();
}
//키입력
{
if (m_isDead == false && m_isHit == false)
{
if (m_enableToShot)
{
if (g_pKeyManager->isStayKeyDown(VK_LBUTTON))
{
m_isShooting = true;
}
}
if (g_pKeyManager->isStayKeyDown('D'))
{
m_eDir = CharacterDir::RIGHT;
m_isRunning = true;
}
else if (g_pKeyManager->isStayKeyDown('A'))
{
m_eDir = CharacterDir::LEFT;
m_isRunning = true;
}
else
{
m_isRunning = false;
}
if (m_pRigidBody->GetIsFalling() == false)
{
if (g_pKeyManager->isOnceKeyDown(VK_SPACE))
{
m_isJumping = true;
}
}
if (g_pKeyManager->isOnceKeyDown(VK_F3))
{
m_isHit = true;
}
}
}
if (m_isDead)
{
m_eState = STATE::DIE;
}
else
{
if (m_isHit)
{
if (!m_isInvincible)
{
this->TakeDmg(1);
m_pRigidBody->SetForce(D3DXVECTOR2( -m_vDir.x * 150.0f, 100.0f));
m_pRigidBody->SetIsFalling(true);
m_isInvincible = true;
if (m_nHp <= 0)
{
m_isDead = true;
}
}
}
else
{
if (m_isJumping)
{
Jump();
}
m_pHitCollider->GetTransform2D().SetScale(STAND_SCALE);
if (m_isShooting)
{
Shot();
m_isShooting = false;
m_enableToShot = false;
m_fShotTimer = 0.0f;
}
if (m_isRunning)
{
Move();
}
}
}
if (m_isInvincible)
{
if (m_fTwinkleTimer >= m_fTwinkleDuration)
{
m_fTwinkleTimer = 0.0f;
if(m_isTwinkleOn)
m_pAniCharacter->SetColor(D3DXCOLOR(1, 1, 1, 1));
else
m_pAniCharacter->SetColor(D3DXCOLOR(1, 1, 1, 0.3f));
m_isTwinkleOn = !m_isTwinkleOn;
}
m_fTwinkleTimer += g_pTimeManager->GetDeltaTime();
}
//Animation 분기점
if (m_isHit)
{
m_eState = STATE::Hit;
}
else if (m_pRigidBody->GetIsFalling() == true)
{
if (m_pRigidBody->GetForce().y >= 0)
{
m_eState = STATE::JumpUp;
}
else
{
m_eState = STATE::Fall;
}
}
else if (m_isRunning)
{
m_eState = STATE::RUN;
}
else
{
m_eState = STATE::IDLE;
}
Character::Update();
if (m_pTransform2D->GetPosition().y <= GroundY)
{
m_pRigidBody->SetIsFalling(false);
}
m_pAniCharacter->SetConstantSizeScale(m_pTransform2D->GetScale());
m_pAniCharacter->SetPosition(m_pTransform2D->GetPosition());
m_pHitCollider->GetTransform2D().SetPosition(m_pTransform2D->GetPosition().x, m_pTransform2D->GetPosition().y - 15);
m_pFootCollider->GetTransform2D().SetScale(20, 6);
m_pFootCollider->GetTransform2D().SetPosition(m_pAniCharacter->GetPosition().x ,
m_pAniCharacter->GetPosition().y - m_pTransform2D->GetScale().y * 0.5f + m_pFootCollider->GetTransform2D().GetScale().y * 0.5f);
m_fGunAngle = GetRadianAngle(m_pHitCollider->GetTransform2D().GetPosition(), D3DXVECTOR2(g_ptMouse.x, g_ptMouse.y));
m_pAniGun->SetConstantSizeScale(m_pTransform2D->GetScale());
m_pAniGun->SetRotation(D3DXVECTOR3(0, 0, m_fGunAngle));
m_pAniGun->SetPosition(m_pTransform2D->GetPosition().x , m_pTransform2D->GetPosition().y - 24);
switch (m_eState)
{
case IDLE:
{
if (m_eDir == CharacterDir::RIGHT)
{
m_ePlayerState = Player_State::Idle_R;
}
else
{
m_ePlayerState = Player_State::Idle_L;
}
}
break;
case RUN:
{
if (m_eDir == CharacterDir::RIGHT)
{
m_ePlayerState = Player_State::Run_R;
}
else
{
m_ePlayerState = Player_State::Run_L;
}
}
break;
case JumpUp:
{
if (m_eDir == CharacterDir::RIGHT)
{
m_ePlayerState = Player_State::JumpUp_R;
}
else
{
m_ePlayerState = Player_State::JumpUp_L;
}
}
break;
case Fall:
{
if (m_eDir == CharacterDir::RIGHT)
{
m_ePlayerState = Player_State::Fall_R;
}
else
{
m_ePlayerState = Player_State::Fall_L;
}
}
break;
case Hit:
{
if (m_eDir == CharacterDir::RIGHT)
{
m_ePlayerState = Player_State::Hit_R;
}
else
{
m_ePlayerState = Player_State::Hit_L;
}
}
break;
case DIE:
{
}
break;
default:
break;
}
if (m_fGunAngle > D3DX_PI * 0.5f && m_fGunAngle < D3DX_PI * 1.5f)
{
m_eGunState = Gun_State::Idle_L;
}
else
{
m_eGunState = Gun_State::Idle_R;
}
m_pAniCharacter->Play(m_ePlayerState);
m_pAniGun->Play(m_eGunState);
if (m_pTransform2D->GetPosition().x < 0)
m_pTransform2D->SetPosition(0.0f, m_pTransform2D->GetPosition().y);
if (m_pTransform2D->GetPosition().x > WINSIZEX)
m_pTransform2D->SetPosition(WINSIZEX, m_pTransform2D->GetPosition().y);
SAFE_UPDATE(m_pAniCharacter );
SAFE_UPDATE(m_pAniGun );
SAFE_UPDATE(m_pHitCollider );
SAFE_UPDATE(m_pFootCollider );
}
void Player::Render()
{
SAFE_RENDER(m_pAniGun);
SAFE_RENDER(m_pAniCharacter);
SAFE_RENDER(m_pHitCollider);
SAFE_RENDER(m_pFootCollider);
}
void Player::Jump()
{
m_pRigidBody->SetIsFalling(true);
m_pRigidBody->SetForceY(m_fJumpPower);
m_isJumping = false;
}
void Player::Shot()
{
D3DXVECTOR2 dir = D3DXVECTOR2(g_ptMouse.x, g_ptMouse.y) - m_pAniGun->GetPosition();
D3DXVec2Normalize(&dir, &dir);
Transform2D* tr = new Transform2D;
tr->SetPosition(m_pAniGun->GetPosition());
tr->SetScale(10, 10);
Bullet* bullet = new Bullet;
bullet->SetBulletType(Bullet_Type::Player_Normal);
bullet->SetDamage(1);
bullet->SetMoveDir(dir);
bullet->SetMoveSpeed(500.0f);
bullet->SetTransform2D(tr);
g_pBulletManager->AddPlayerBullet(bullet);
}
|
3261c3193ea411eb7e6e75578ffe92902e1e03e7
|
dcd70031041dabecc6abfa5f2847c299fc7fef70
|
/프로그래머스/2019 카카오 개발자 겨울 인턴십/튜플.cpp
|
b9a851ef2ca72e334db3f208c554efc8dc8ac4ae
|
[] |
no_license
|
JJJoonngg/Algorithm
|
cab395760ef604a1764391847473c838e3beac9f
|
32d574558c1747008e7ac3dfe4f9d4f07c58a58b
|
refs/heads/master
| 2021-06-21T01:01:36.302243
| 2021-03-24T14:01:06
| 2021-03-24T14:01:06
| 196,032,101
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,420
|
cpp
|
튜플.cpp
|
//
// Created by 김종신 on 2020/05/05.
//
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
using namespace std;
bool comp(vector<int> a, vector<int> b) {
return a.size() < b.size();
}
vector<int> solution(string s) {
vector<int> answer, tmp;
vector<vector<int>> v;
set<int> ss;
int cur = 0, num;
bool flag = false;
for (int i = 1; i < s.length() - 1; i++) {
if (s[i] == '{') continue;
if (s[i] == '}' || s[i] == ',') {
if (!flag) continue;
flag = false;
if (i - cur == 1)num = s[cur] - '0';
else num = stoi(s.substr(cur, i - cur));
tmp.push_back(num);
if (s[i] == '}') {
v.push_back(tmp);
tmp.clear();
}
} else {
if (flag) continue;
cur = i;
flag = true;
}
}
sort(v.begin(), v.end(), comp);
for (auto a : v) {
sort(a.begin(), a.end());
for (auto b : a) {
if (ss.find(b) == ss.end()) {
ss.insert(b);
answer.push_back(b);
}
}
}
return answer;
}
int main() {
cin.tie(NULL);
cout.tie(NULL);
std::ios::sync_with_stdio(false);
vector<int> v = solution("{{1,2,3},{2,1},{1,2,4,3},{2}}");
for (auto a: v)
cout << a << " ";
return 0;
}
|
704bb982ed27f4dac479d0e04268b66ce7b7995b
|
67ccc9efd94f4fb90b52ee0b73e1485d47845bca
|
/parciales/parcial02b/bateries/workingBateries.cpp
|
046bf880b18bc2531ec083638878909d8e571f3a
|
[] |
no_license
|
mzabala1/244smzabala1
|
ffbc8562c526ca4cfb50739da343089ef4d801c9
|
22af4f84ec0c15219c5c5fc697b87a1d7b5fee3c
|
refs/heads/master
| 2020-03-11T12:42:31.889408
| 2018-04-18T05:58:04
| 2018-04-18T05:58:04
| 130,004,890
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 911
|
cpp
|
workingBateries.cpp
|
#include "bateries.h"
#include <iostream>
using namespace std;
int
main() {
int nBateries;
cin >> nBateries;
Batery *bateries[nBateries];
for (int i = 0; i < nBateries; ++i) {
float charge[2];
cin >> charge[0] >> charge[1];
bateries[i] = new B2Batery(charge);
}
float amount;
cin >> amount;
while (amount != 0.0) {
float total = getTotalBateries(bateries, nBateries);
if (amount <= total) {
for (int i = 0; i < nBateries; ++i) {
bateries[i]->setDischarge(amount *
bateries[i]->getTotalCharge() / total);
cout << bateries[i]->getTotalCharge() << " ";
}
cout << endl;
}
cin >> amount;
}
for (int i = 0; i < nBateries; ++i) {
cout << i << ": ";
for (int j = 0; j < 2; ++j) {
cout << bateries[i]->getCharge(j) << " ";
}
cout << endl;
}
cout << getTotalBateries(bateries, nBateries);
return 0;
}
|
74a46aaf96de80807b59d99b284761b114553c5b
|
fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd
|
/third_party/WebKit/Source/modules/media_controls/elements/MediaControlOverlayEnclosureElement.cpp
|
d0b974a6a41685b86de134a451019c89d4f16ebf
|
[
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"BSD-3-Clause"
] |
permissive
|
wzyy2/chromium-browser
|
2644b0daf58f8b3caee8a6c09a2b448b2dfe059c
|
eb905f00a0f7e141e8d6c89be8fb26192a88c4b7
|
refs/heads/master
| 2022-11-23T20:25:08.120045
| 2018-01-16T06:41:26
| 2018-01-16T06:41:26
| 117,618,467
| 3
| 2
|
BSD-3-Clause
| 2022-11-20T22:03:57
| 2018-01-16T02:09:10
| null |
UTF-8
|
C++
| false
| false
| 1,420
|
cpp
|
MediaControlOverlayEnclosureElement.cpp
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "modules/media_controls/elements/MediaControlOverlayEnclosureElement.h"
#include "core/dom/events/Event.h"
#include "modules/media_controls/MediaControlsImpl.h"
namespace blink {
MediaControlOverlayEnclosureElement::MediaControlOverlayEnclosureElement(
MediaControlsImpl& media_controls)
: MediaControlDivElement(media_controls, kMediaControlsPanel) {
SetShadowPseudoId(AtomicString("-webkit-media-controls-overlay-enclosure"));
}
EventDispatchHandlingState*
MediaControlOverlayEnclosureElement::PreDispatchEventHandler(Event* event) {
// When the media element is clicked or touched we want to make the overlay
// cast button visible (if the other requirements are right) even if
// JavaScript is doing its own handling of the event. Doing it in
// preDispatchEventHandler prevents any interference from JavaScript.
// Note that we can't simply test for click, since JS handling of touch events
// can prevent their translation to click events.
if (event && (event->type() == EventTypeNames::click ||
event->type() == EventTypeNames::touchstart)) {
GetMediaControls().ShowOverlayCastButtonIfNeeded();
}
return MediaControlDivElement::PreDispatchEventHandler(event);
}
} // namespace blink
|
9f39f2c4a773c351bd3a52dc179430dc4cb237a3
|
b2139a7f5e04114c39faea797f0f619e69b8b4ae
|
/src/piSquare/include/iCub/piSquare/policyLibrary/dmpPolicy.h
|
2bf7b413b6c1fc05ab5f901f55c40def465c1d3d
|
[] |
no_license
|
hychyc07/contrib_bk
|
6b82391a965587603813f1553084a777fb54d9d7
|
6f3df0079b7ea52d5093042112f55a921c9ed14e
|
refs/heads/master
| 2020-05-29T14:01:20.368837
| 2015-04-02T21:00:31
| 2015-04-02T21:00:31
| 33,312,790
| 5
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,465
|
h
|
dmpPolicy.h
|
/*********************************************************************
* Copyright (c) 2008, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
**********************************************************************/
#ifndef DMP_POLICY_H_
#define DMP_POLICY_H_
#define EIGEN2_SUPPORT
#include <Eigen/Eigen>
#include <boost/shared_ptr.hpp>
#include <iCub/piSquare/policyLibrary/policy.h>
#include <iCub/piSquare/dmpMotionGeneration/dynamicMovementPrimitive.h>
namespace library
{
/**
* \ingroup piSquare
*
* Specialization of policy base class by defining DMPs as parameterized policies.
*/
class DMPPolicy : public Policy
{
public:
/**
* class constructor
*/
DMPPolicy();
/**
* class destructor
*/
virtual ~DMPPolicy();
/**
* Initializes the DMPPolicy object with a pointer to a already initialized dmp
* @param dmp is the dynamic motion primitive used for initialization
* @return true if operation is successful (initialization), false otherwise
*/
bool initialize(boost::shared_ptr<dmp::DynamicMovementPrimitive> dmp);
/**
* Gets a dmp object
* @param dmp is a pointer to the output dmp object
* @return true if operation is successful, false otherwise
*/
bool getDMP(boost::shared_ptr<dmp::DynamicMovementPrimitive>& dmp);
/**
* Sets the number of time steps used for reinforcement learning
* @param numTimeSteps is the number of time steps
* @return true if operation is successful, false otherwise
*/
bool setNumTimeSteps(const int numTimeSteps);
/**
* Gets the number of time steps used for reinforcement learning
* @param numTimeSteps is the number of time steps
* @return true if operation is successful, false otherwise
*/
bool getNumTimeSteps(int& numTimeSteps);
/**
* Gets the number of dimensions of the dmp
* @param numDimensions is the number of dimensions
* @return true if operation is successful, false otherwise
*/
bool getNumDimensions(int& numDimensions);
/**
* Gets the number of policy parameters per dimension
* @param numParams is a vector holding the number of parameters for each dimension
* @return true if operation is successful, false otherwise
*/
bool getNumParameters(std::vector<int>& numParams);
/**
* Extracts from the underlying dmp a vector of matrices representing the basis
* functions used for the nonlinear function f. Information about the number
* of time steps for the trajectory is used.
* In a sense it is the inverse step of regression. From the knowledge of the theta
* parameters, the nonlinear function values are computed by keeping in account the
* basis functions values and the canonial system.
* @param basisFunctions is a vector of basis function matrices (numDimensions x [numTimeSteps] x [numParameters])
* @return true if operation is successful, false otherwise
*/
bool getBasisFunctions(std::vector<Eigen::MatrixXd>& basisFunctions);
/**
* Compute the positive semi-definite matrix of the quadratic control cost.
* More precisely it is a vector of matrix: a matrix for each dimension and
* the dimensions are coherent with the number of theta parameters used for
* each dimension. In this case such control cost matrix is just an identity
* matrix.
* @param controlCosts is a vector of control costs matrices, one for each parameter.
* @return true if operation is successful, false otherwise
*/
bool getControlCosts(std::vector<Eigen::MatrixXd>& controlCosts);
/**
* Performs the parameters time independent updates vector starting from
* the parameters updates for each time steps.
* @param updates is a vector of updates matrices (one updates vector for each time step)
* @return true if operation is successful, false otherwise
*/
bool updateParameters(const std::vector<Eigen::MatrixXd>& updates);
/**
* Extracts from the dmp the theta parameters vectors.
* @param parameters is a vector of parameters vectors (one for each dimension)
* @return true if operation is successful, false otherwise
*/
bool getParameters(std::vector<Eigen::VectorXd>& parameters);
/**
* Sets the theta parameters vectors for the dmp
* @param parameters is a vector of parameters vectors (one for each dimension)
* @return true if operation is successful, false otherwise
*/
bool setParameters(const std::vector<Eigen::VectorXd>& parameters);
private:
///indicates if the object is initialized or not
bool initialized_;
///number of time steps for reinforcement learning
int numTimeSteps_;
//pointer to a dmp object containing all the data representing a dmp
boost::shared_ptr<dmp::DynamicMovementPrimitive> dmp_;
};
}
#endif /* DMP_POLICY_H_ */
|
5be3fd64906454144e4bc44f7b5b887093f859ca
|
db7379aa0723bcf4cb303f5e5ed8c07ff72d1f67
|
/POO_TPII_DavidsonDias_MateusAlves/2.6/include/InterSet.h
|
0c47c455848e9f7c3eddf736d0ace2c0549a3736
|
[] |
no_license
|
MatLopes23/POO
|
8e5e0336c0df46bcfd0030520218c54a98eaa8f8
|
c5f93c802a5c28973a4161eac12bd2dd50ee04e9
|
refs/heads/master
| 2020-04-07T20:58:06.816632
| 2018-11-23T12:18:14
| 2018-11-23T12:18:14
| 158,709,473
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 540
|
h
|
InterSet.h
|
#ifndef INTERSET_H
#define INTERSET_H
#include<array>
class InterSet
{
std::array<bool,101> a;
public:
InterSet();
virtual ~InterSet();
int InsereElemento(const int k);
int RemoveElemento(const int k);
void Uniao(const InterSet x,const InterSet y);
void Intersecao(const InterSet x,const InterSet y);
void Imprime() const ;
int Igual(const InterSet x) const;
void LeDeArquivo(const std::string nomeArquivo);
};
#endif // INTERSET_H
|
f32d28c436d264415b071299b6d4b2bae06e1628
|
8994954408db862f36fedc6a9346dcf5f405478f
|
/PCA_Downsample/voxel_grid_downsampling.cpp
|
7ae09a3d950779e2c7bbad622abf113774f9c32a
|
[] |
no_license
|
zhangsongdmk/analyze_pointcloud
|
f26855264e921ad3709fb2b19e4e23d8032a9007
|
4c5ed82614995bb9b9a5d5f177e8b9a332bc99d4
|
refs/heads/master
| 2022-10-17T15:36:22.860498
| 2020-06-13T08:01:40
| 2020-06-13T08:01:40
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,727
|
cpp
|
voxel_grid_downsampling.cpp
|
#include "PCA_Downsample/voxel_grid_downsampling.h"
#include <cmath>
#include <algorithm>
#include <fstream>
#include <cstdlib>
#include <cmath>
bool VoxelGridDownsampling::set_data(const std::string& pts_file) {
_pcd = Utils::read_pointcloud_from_file(pts_file);
std::cout << "point cloud size: " << _pcd.cols() << std::endl;
return true;
}
bool VoxelGridDownsampling::set_data(const Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>& data) {
_pcd = data;
return true;
}
bool VoxelGridDownsampling::downsampling(double grid_size, SelectPointsMethod select_pts_method) {
Eigen::Vector3d min = _pcd.rowwise().minCoeff();
Eigen::Vector3d max = _pcd.rowwise().maxCoeff();
std::cout << "min: " << min.transpose() << std::endl;
std::cout << "max: " << max.transpose() << std::endl;
Eigen::Vector3d dim = (max - min) / grid_size;
std::cout << "dim: " << dim.transpose() << std::endl;
for (size_t i = 0; i < _pcd.cols(); ++i) {
Eigen::Vector3d pts = _pcd.col(i);
int h_x = floor((pts(0) - min(0)) / grid_size);
int h_y = floor((pts(1) - min(1)) / grid_size);
int h_z = floor((pts(2) - min(2)) / grid_size);
int h = h_x + dim(0) * h_y + dim(0) * dim(1) * h_z;
_downsample.emplace_back(std::make_pair(h, pts));
}
std::cout << "_downsample size: " << _downsample.size() << std::endl;
std::sort(_downsample.begin(), _downsample.end(), [] (const std::pair<int, Eigen::Vector3d>& p1, const std::pair<int, Eigen::Vector3d>& p2) -> bool {
return p1.first < p2.first;
});
// select_point
switch (select_pts_method) {
case SelectPointsMethod::CENTROID:
select_centroid(_downsample);
break;
case SelectPointsMethod::RANDOM:
select_random(_downsample);
break;
default:
std::cerr << "invalid select points method" << std::endl;
return false;
}
std::cout << "_downsample size after select: " << _downsample.size() << std::endl;
return true;
}
bool VoxelGridDownsampling::select_centroid(std::vector<std::pair<int, Eigen::Vector3d>>& downsample) {
std::vector<std::pair<int, Eigen::Vector3d>> res;
std::vector<std::pair<int, Eigen::Vector3d>> grid_pts;
for (size_t i = 0; i < downsample.size(); ++i) {
if (grid_pts.size() == 0) {
grid_pts.emplace_back(downsample[i]);
} else if (grid_pts[grid_pts.size() - 1].first != downsample[i].first) {
// find_centroid
double cx = 0, cy = 0, cz = 0;
for (size_t j = 0; j < grid_pts.size(); ++j) {
cx += grid_pts[j].second[0];
cy += grid_pts[j].second[1];
cz += grid_pts[j].second[2];
}
cx /= grid_pts.size();
cy /= grid_pts.size();
cz /= grid_pts.size();
res.emplace_back(std::make_pair(grid_pts[0].first, Eigen::Vector3d(cx, cy, cz)));
// clear and push new data
grid_pts.clear();
grid_pts.emplace_back(downsample[i]);
} else {
grid_pts.emplace_back(downsample[i]);
}
}
downsample.swap(res);
return true;
}
bool VoxelGridDownsampling::select_random(std::vector<std::pair<int, Eigen::Vector3d>>& downsample) {
std::vector<std::pair<int, Eigen::Vector3d>> res;
std::vector<std::pair<int, Eigen::Vector3d>> grid_pts;
std::srand(time(0));
for (size_t i = 0; i < downsample.size(); ++i) {
if (grid_pts.size() == 0) {
grid_pts.emplace_back(downsample[i]);
} else if (grid_pts[grid_pts.size() - 1].first != downsample[i].first) {
int rand_id = std::rand() % grid_pts.size();
Eigen::Vector3d rand_pts;
rand_pts << grid_pts[rand_id].second(0),
grid_pts[rand_id].second(1),
grid_pts[rand_id].second(2);
res.emplace_back(std::make_pair(grid_pts[0].first, rand_pts));
// clear and push new data
grid_pts.clear();
grid_pts.emplace_back(downsample[i]);
} else {
grid_pts.emplace_back(downsample[i]);
}
}
downsample.swap(res);
return true;
}
bool VoxelGridDownsampling::save_to_file(const std::string& file_name) {
std::ofstream ofs(file_name);
if (!ofs.is_open()) {
std::cerr << "can not open " << file_name << std::endl;
return false;
}
for (const auto& d : _downsample) {
ofs << d.second[0] << " " << d.second[1] << " " << d.second[2] << std::endl;
}
ofs.close();
std::cout << "save " << _downsample.size() << " points to " << file_name << std::endl;
return true;
}
|
a6a6faa3f81662c9c1e4bfd182696beb2ebbaa33
|
b3e525a3c48800303019adac8f9079109c88004e
|
/nic/metaswitch/stubs/test/hals/ipsfeeder/vrf_ips_feeder.cc
|
82bdb71d23983e3b7aa2bc89210398d833bb0994
|
[] |
no_license
|
PsymonLi/sw
|
d272aee23bf66ebb1143785d6cb5e6fa3927f784
|
3890a88283a4a4b4f7488f0f79698445c814ee81
|
refs/heads/master
| 2022-12-16T21:04:26.379534
| 2020-08-27T07:57:22
| 2020-08-28T01:15:20
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 473
|
cc
|
vrf_ips_feeder.cc
|
//------------------------------------------------------------------------------
// {C} Copyright 2019 Pensando Systems Inc. All rights reserved
//------------------------------------------------------------------------------
#include "nic/metaswitch/stubs/test/hals/ipsfeeder/vrf_ips_feeder.hpp"
namespace pds_ms_test {
void load_vrf_test_input ()
{
static vrf_ips_feeder_t g_vrf_ips_feeder;
test_params()->test_input = &g_vrf_ips_feeder;
}
} // End namespace
|
19f8b6b47190cdc739c7694b791524ffe6482b4d
|
7f6d2df4f97ee88d8614881b5fa0e30d51617e61
|
/王朝国/homework/chapt_3_demo/Date1.h
|
f446d86cee419123c6fcf090261ae54369bb7c72
|
[] |
no_license
|
tsingke/Homework_Turing
|
79d36b18692ec48b1b65cfb83fc21abf87fd53b0
|
aa077a2ca830cdf14f4a0fd55e61822a4f99f01d
|
refs/heads/master
| 2021-10-10T02:03:53.951212
| 2019-01-06T07:44:20
| 2019-01-06T07:44:20
| 148,451,853
| 15
| 25
| null | 2018-10-17T15:20:24
| 2018-09-12T09:01:50
|
C++
|
GB18030
|
C++
| false
| false
| 995
|
h
|
Date1.h
|
//Date1.h:完整的Date类定义,成员函数的定义放在类体外
#include<iostream>
using namespace std;
class Date
{private:
int year;
int month;
int day;
public:
void SetDate(int ,int ,int ); //对数据成员初始化的公有成员函数
void Display( ); //执行显示功能的公有成员函数
int GetYear( ); //公有成员函数,提取year变量值
int GetMonth( ); //公有成员函数,提取month变量值
int GetDay( ); //公有成员函数,提取day变量值
}; //此分号不能少,表示类定义结束
void Date::SetDate(int y,int m,int d)
{ year=y;
month=m;
day=d;
}
int Date::GetYear( )
{ return year;
}
int Date::GetMonth( )
{ return month;
}
int Date::GetDay( )
{ return day;
}
void Date::Display()
{ cout << year<< "-" << month << "-" << day << endl;
}
|
56753d21fb3183943816d4ad1d17f913d000ba3e
|
0c86b4e2ff65ee96fce989c66652e7145ff06d9d
|
/src/rt_light_dir.cpp
|
894b32304329fcea3356909070aced76f0222445
|
[] |
no_license
|
shinhugh/raytracer
|
209542d62b3aeb02fe92a9c5e74ab5b2cd434ff2
|
560673ff0757f312c3f7dff89047ad3afa6f025d
|
refs/heads/master
| 2020-12-02T09:35:44.137925
| 2020-05-10T18:41:36
| 2020-05-10T18:41:36
| 181,390,324
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 83
|
cpp
|
rt_light_dir.cpp
|
/*
* Refer to rt_light_dir.h for details.
*/
#include "rt_light_dir.h"
// TODO
|
18629155cce04696e1c6b0dba4a37c1436bb763b
|
f1a387ca07a6252bb70daa5ece8b5901e3c9faa4
|
/simpleVitisKernel/src/types.hpp
|
b2af15d8a90ce6dcc3014e4c941bc8e7880c8faa
|
[] |
no_license
|
shahzadXilinx/hlsVectorTests
|
30ee675f768d6ae1c457cddbc58df15fadd25f87
|
55dbc464954575fbdaa251cff72b12192bf2a159
|
refs/heads/main
| 2022-12-29T16:20:28.024278
| 2020-10-19T23:13:36
| 2020-10-19T23:13:36
| 305,170,298
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 253
|
hpp
|
types.hpp
|
#include <hls_vector.h>
using element_type= unsigned int;
constexpr auto elemSize = sizeof(element_type);
constexpr auto memWidth = 512/8;
constexpr auto elementsPerVec = memWidth / elemSize;
using uintVec = hls::vector<element_type,elementsPerVec>;
|
146ee3b72f09ac99beb30002eeefb0dad9f9a3dc
|
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
|
/PWGDQ/dielectron/core/AliDielectronCutQA.h
|
eae0783e83d013a3bccbd400fd8e688252a7689e
|
[] |
permissive
|
alisw/AliPhysics
|
91bf1bd01ab2af656a25ff10b25e618a63667d3e
|
5df28b2b415e78e81273b0d9bf5c1b99feda3348
|
refs/heads/master
| 2023-08-31T20:41:44.927176
| 2023-08-31T14:51:12
| 2023-08-31T14:51:12
| 61,661,378
| 129
| 1,150
|
BSD-3-Clause
| 2023-09-14T18:48:45
| 2016-06-21T19:31:29
|
C++
|
UTF-8
|
C++
| false
| false
| 2,279
|
h
|
AliDielectronCutQA.h
|
#ifndef ALIDIELECTRONCUTQA_H
#define ALIDIELECTRONCUTQA_H
/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
* See cxx source for full Copyright notice */
//#################################################################
//# #
//# Class AliDielectronCutQA #
//# Dielectron Group of cuts #
//# #
//# Authors: #
//# Julian Book, Uni Ffm / Julian.Book@cern.ch #
//# #
//#################################################################
#include <TNamed.h>
#include <AliAnalysisFilter.h>
#include <TH1F.h>
#include <TList.h>
#include <TObjArray.h>
class TCollection;
class AliDielectronCutQA : public TNamed {
public:
enum { kEvent=0, kTrack, kPair, kNtypes };
AliDielectronCutQA();
AliDielectronCutQA(const char*name, const char* title);
virtual ~AliDielectronCutQA();
//Analysis cuts interface
//
void Init();
void AddTrackFilter( AliAnalysisFilter *trkFilter);
/* void AddPrePairFilter( AliAnalysisFilter *prePairFilter); */
/* void AddPrePairLegFilter(AliAnalysisFilter *prePairLegFilter); */
void AddPairFilter( AliAnalysisFilter *pairFilter);
void AddEventFilter( AliAnalysisFilter *eventFilter);
// void Fill(AliAnalysisCuts *cut);
void Fill(UInt_t mask, TObject *obj);
void FillAll(TObject *obj);// { fCutQA->Fill(0); }
const TObjArray * GetQAHistArray() const { return &fQAHistArray; }
private:
TObjArray fQAHistArray; //-> array of QA histograms
TH1F *fCutQA[kNtypes]; // qa histogram
Int_t fNCuts[kNtypes]; // number of cuts
const char* fCutNames[20][kNtypes]; // cut names
const char* fTypeKeys[kNtypes]; // type names
UInt_t GetObjIndex(TObject *obj); // return object index
AliDielectronCutQA(const AliDielectronCutQA &);
AliDielectronCutQA &operator=(const AliDielectronCutQA &);
ClassDef(AliDielectronCutQA,1) //Group of cuts
};
#endif
|
44ac3a0fe99fa37e915c31886cf48a514c726563
|
f318dd18a187f5c931741ec6e5947dd54600942e
|
/include/QueueNode.hpp
|
2dada3770e4d59fb407afef3318b924d5fc80d2c
|
[] |
no_license
|
GeomartBrenthPAbong/InfixExpressionCalculator
|
d583ebf511ac0dcef5a5694bd5500a7f9d97a8b6
|
2d6bec90118d8f3d150de4ca6d6fc6bcfa75c12c
|
refs/heads/master
| 2021-01-11T23:53:44.046397
| 2017-01-11T13:31:36
| 2017-01-23T15:58:33
| 78,641,019
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 486
|
hpp
|
QueueNode.hpp
|
#ifndef QUEUE_NODE_H
#define QUEUE_NODE_H
namespace gba
{
template<typename T>
class QueueNode
{
public:
QueueNode();
QueueNode(T p_data);
~QueueNode();
void setData(T p_data);
void setNextNode(QueueNode<T> *p_node);
T getData();
QueueNode<T> *getNextNode();
private:
QueueNode *m_next_node;
T m_data;
};
}
#include "QueueNode.cpp"
#endif
|
e44cc084ba5834bf832b3c55bf7fed77cfbcb85a
|
b22588340d7925b614a735bbbde1b351ad657ffc
|
/athena/Trigger/TrigT1/TrigT1EventTPCnv/TrigT1EventTPCnv/JEMHitsCollection_p1.h
|
4620b8fb910eae80fd5fb996b4b40bcc33de4876
|
[] |
no_license
|
rushioda/PIXELVALID_athena
|
90befe12042c1249cbb3655dde1428bb9b9a42ce
|
22df23187ef85e9c3120122c8375ea0e7d8ea440
|
refs/heads/master
| 2020-12-14T22:01:15.365949
| 2020-01-19T03:59:35
| 2020-01-19T03:59:35
| 234,836,993
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 349
|
h
|
JEMHitsCollection_p1.h
|
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRIGT1EVENTTPCNV_JEMHitsCOLLECTION_P1_H
#define TRIGT1EVENTTPCNV_JEMHitsCOLLECTION_P1_H
#include "AthenaPoolUtilities/TPObjRef.h"
#include <vector>
class JEMHitsCollection_p1 : public std::vector<TPObjRef>
{
public:
JEMHitsCollection_p1() {}
};
#endif
|
9e7600ae0ec595a329c062ebf5f020070594fce1
|
99f08f10f02219f00f257c87d159d589f2bbe31a
|
/PRACTICA4/mochila.hpp
|
80450c845abbc5681a494dbeac80d1d6158a7d10
|
[] |
no_license
|
aluquerivas-dev/Algoritmica
|
1c3111a50c77630edc7d7c50500acff3986ce7de
|
2f9d7100e2233a140a54afbff052919ac535583c
|
refs/heads/master
| 2021-10-08T23:56:17.240083
| 2018-12-19T00:39:20
| 2018-12-19T00:39:20
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,230
|
hpp
|
mochila.hpp
|
#ifndef _MOCHILA_HPP
#define _MOCHILA_HPP
#include <vector>
#include <string>
#include "material.hpp"
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <algorithm>
class Mochila
{
private:
std::vector<Material> Vmats;
int volumen_;
public:
Mochila(int v)
{
setVolumen(v);
};
inline void start()
{
//showMatVector();
ordination();//Ordenamos de mayor a menor
//showMatVector();
bagAlgorithm();//FIN
};
inline int getVolumen() const {return volumen_;}
inline void setVolumen(int &v) {volumen_ = v;}
inline void addMatVector(Material &mat) {Vmats.push_back(mat);}
inline Material & getMatVector(int i) {return Vmats[i];}
inline std::vector<Material> & getVector() {return Vmats;}
inline void showMatVector()
{
for (auto value : Vmats) {
std::cout << "ID--> " << value.getId() << " VOLUMEN--> " << value.getVolumen() << " PRECIO--> " << value.getPrecio() << " ESTADO--> " << value.getEstado() << "\n";
}
}
inline static bool comparacion(const Material& m1, const Material& m2)
{
return m1.getPrecio() > m2.getPrecio();
}
inline void ordination()
{
std::sort(getVector().begin(), getVector().end(), comparacion);
}
inline void bagAlgorithm()
{
//Seleccionamos el indice del objeto de mayor coste, puesto que hemos ordenado la estructura de dantes anteriormente de mayor a menor el elemento de mayor coste siempre sera i=0
int maximoCoste = 0;
int resto = getVolumen();
int cuenta = 0;
do {
if (Vmats[maximoCoste].getEstado() == "No Usado") {
if (resto >= Vmats[maximoCoste].getVolumen()) {
cuenta = cuenta + (Vmats[maximoCoste].getVolumen() * Vmats[maximoCoste].getPrecio());
resto = resto - Vmats[maximoCoste].getVolumen();
std::cout<<RED<<"Material Usado: "<<BLUE<<Vmats[maximoCoste].getId()<<YELLOW<<"\n -->Unidades Empleadas: "<<CYAN<<Vmats[maximoCoste].getVolumen()<<YELLOW<<"\n -->Precio por unidad: "<<CYAN<<Vmats[maximoCoste].getPrecio()<<YELLOW<<"\n -->Coste: "<<Vmats[maximoCoste].getVolumen() * Vmats[maximoCoste].getPrecio()<<CYAN<<"\n [Total en mochila: "<<cuenta<<" ]"<<RESET<<std::endl;
maximoCoste++;
} else {
cuenta = cuenta + (resto * Vmats[maximoCoste].getPrecio());
Vmats[maximoCoste].setEstado("Parcialmente Usado");
resto = 0;
std::cout<<RED<<"Material Usado: "<<BLUE<<Vmats[maximoCoste].getId()<<YELLOW<<"\n -->Unidades Empleadas: "<<CYAN<<Vmats[maximoCoste].getVolumen()<<YELLOW<<"\n -->Precio por unidad: "<<CYAN<<Vmats[maximoCoste].getPrecio()<<YELLOW<<"\n -->Coste: "<<Vmats[maximoCoste].getVolumen() * Vmats[maximoCoste].getPrecio()<<CYAN<<"\n [Total en mochila: "<<cuenta<<" ]"<<RESET<<std::endl;
}
}
} while (resto != 0);
std::cout << "\n\n Con un volumen en la Mochila de " << getVolumen() << " Unidades/Volumen el coste maximo de los materiales son " << cuenta << " Unidades/Precio" << std::endl;
getchar();
}
};
inline Mochila &operator<<(Mochila &bag, const std::string &fichero)
{
std::ifstream f(fichero, std::ios::in);
int id, volumen, precio;
if (f.good()) {
while (f >> id >> volumen >> precio) {
Material mat(id, volumen, precio);
bag.addMatVector(mat);
}
} else {
std::cout << "Error al abrir fichero\n";
}
return bag;
}
#endif
|
474229f1ae4aac5b67390ace297f9cd6e31f2643
|
f31558c867590e22bab50ec661d105c282ee1146
|
/src/Application.cpp
|
b089c13dac1dbc516fd920baaa2e8e91c670347e
|
[
"MIT"
] |
permissive
|
EleDe01/Arkanoid-Returns
|
56b23ffaa13f273977de0b97a5a8d52e504effeb
|
478ae8df92f978dce95fd227a9047e83dea9a855
|
refs/heads/master
| 2022-05-09T08:42:38.462501
| 2019-08-25T17:51:30
| 2019-08-25T17:51:30
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,685
|
cpp
|
Application.cpp
|
#include "Application.hpp"
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_acodec.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_physfs.h>
#include <physfs.h>
#include <iostream>
using namespace std;
#include "R.hpp"
#include "AllegroException.hpp"
#include "Gallery.hpp"
#include "Menu.hpp"
#include "Peripheral.hpp"
#include "Keyboard.hpp"
#include "Mouse.hpp"
#include "About.hpp"
#include "Help.hpp"
#include "Options.hpp"
#include "HighScores.hpp"
#include "Game.hpp"
#include "Sound.hpp"
Application::Application() :
display(nullptr),
eventQueue(nullptr),
timer(nullptr),
actualInterface(nullptr),
exit(false) {
}
void Application::init(int argc, char** argv) {
if (!al_init()) {
throw AllegroException(R::String::ERROR_ALLEGRO_INIT);
}
al_init_image_addon();
al_init_font_addon();
al_init_acodec_addon();
al_init_ttf_addon();
al_init_primitives_addon();
if (!al_install_keyboard()) {
throw AllegroException(R::String::ERROR_INSTALL_KEYBOARD);
}
if (!al_install_mouse()) {
throw AllegroException(R::String::ERROR_INSTALL_MOUSE);
}
if (!al_install_audio()) {
throw AllegroException(R::String::ERROR_INSTALL_AUDIO);
}
else {
al_reserve_samples(16);
}
display = al_create_display(R::Dimen::WIDTH, R::Dimen::HEIGHT);
al_set_window_title(display, R::String::WINDOW_TITLE.c_str());
timer = al_create_timer(1.0 / R::Constant::FPS);
eventQueue = al_create_event_queue();
/// Registra los eventos de los perifericos para que puedan ser escuchados.
al_register_event_source(eventQueue, al_get_display_event_source(display));
al_register_event_source(eventQueue, al_get_mouse_event_source());
al_register_event_source(eventQueue, al_get_timer_event_source(timer));
al_register_event_source(eventQueue, al_get_keyboard_event_source());
// Cargando los recursos
Gallery& gallery = Gallery::getSingleton();
gallery.loadResources();
keyboard = new Keyboard;
mouse = new Mouse;
menu = new Menu(this);
about = new About(this);
help = new Help(this);
options = new Options(this);
highScores = new HighScores(this);
game = new Game(this);
srand(static_cast<unsigned int>(time(NULL)));
al_start_timer(timer);
}
void Application::loop() {
actualInterface = menu;
while (!exit && event.type != ALLEGRO_EVENT_DISPLAY_CLOSE) {
al_wait_for_event(eventQueue, &event);
keyboard->poll();
mouse->poll();
if (event.type == ALLEGRO_EVENT_TIMER) {
actualInterface->draw();
actualInterface->update();
al_flip_display();
}
else if (event.type == ALLEGRO_EVENT_DISPLAY_SWITCH_OUT) {
game->setPause(true);
}
}
}
void Application::setInterface(INTERFACE_SCREEN interfaceApp, bool reinit) {
switch (interfaceApp) {
case INTERFACE_SCREEN::MAIN_MENU:
actualInterface = menu;
break;
case INTERFACE_SCREEN::ABOUT:
actualInterface = about;
break;
case INTERFACE_SCREEN::HELP:
actualInterface = help;
break;
case INTERFACE_SCREEN::OPTIONS:
actualInterface = options;
break;
case INTERFACE_SCREEN::HIGHSCORES:
actualInterface = highScores;
break;
case INTERFACE_SCREEN::GAME:
actualInterface = game;
game->reinit();
break;
}
}
void Application::quit() {
exit = true;
}
Keyboard* Application::getKeyboard() const {
return keyboard;
}
Mouse* Application::getMouse() const {
return mouse;
}
ALLEGRO_DISPLAY* Application::getDisplay() const {
return display;
}
Application::~Application() {
delete menu;
delete about;
delete help;
delete options;
delete highScores;
delete game;
al_destroy_display(display);
al_destroy_event_queue(eventQueue);
al_destroy_timer(timer);
}
|
ebfe11c7507cf2818e0f99950994f2bf7c4c5e28
|
3da52a12f80fc6d4a58ba5578a6bfa7794930a15
|
/source/WorldGenerator/Main.h
|
95f261a2251a9ecffcc0878411bdeb2a030d7d1e
|
[] |
no_license
|
Epiphane/NCW
|
db11a5130bc0f07458905e898b26d957dd4ce4f5
|
531a88e03e42450152d91f82925a420ef0b9ee2c
|
refs/heads/master
| 2021-06-06T21:05:28.739882
| 2021-06-05T06:14:22
| 2021-06-05T06:14:22
| 136,872,412
| 2
| 0
| null | 2020-02-02T05:03:13
| 2018-06-11T03:57:13
|
C++
|
UTF-8
|
C++
| false
| false
| 1,095
|
h
|
Main.h
|
//
// main.h
// FinalProject
//
// Created by Thomas Steinke on 3/3/15.
// Copyright (c) 2015 Thomas Steinke. All rights reserved.
//
#pragma once
#include <vector>
#pragma warning(disable : 4201)
#include <glm/glm.hpp>
#pragma warning(default : 4201)
#include "../GLSL.h"
#ifndef M_PI
#define M_PI 3.1415926535897932384626433832795
#endif
#ifndef MATH_PI
#define MATH_PI M_PI
#endif
#define RADIANS_TO_DEG float(180.0f / M_PI)
#define DEG_TO_RADIANS float(M_PI / 180.0f)
#define DEGREES(radians) (radians * RADIANS_TO_DEG)
#define RADIANS(degrees) (degrees * DEG_TO_RADIANS)
#define INIT_BENCHMARK float _clock = glfwGetTime();
#define COMPUTE_BENCHMARK(samp, msg, everyframe) {\
static float _samples[samp] = {1};\
static int _pos = 0;\
_samples[_pos] = glfwGetTime() - _clock;\
_pos = (_pos + 1) % samp;\
float _elapsed = 0;\
for (int i = 0; i < samp; i ++)\
_elapsed += _samples[i];\
_elapsed = _elapsed / samp;\
/*RendererDebug::Instance().log(msg + std::to_string(_elapsed), !everyframe);*/\
_clock = glfwGetTime(); /* Chain debugging */ \
}
|
84688bd9885dea196ed78a09e5a2d70d8efb0f3a
|
032312022846042162ef1d423cb4c478b205d41f
|
/LFR_new/LFR_new.ino
|
d9c2da7464c0086318a242b18bb716f35dec369d
|
[] |
no_license
|
hamza-smh/project-
|
d528e994cc67dadb39727605c2d5eb95b916dbf9
|
6ea4f7f927f664cf8084328f2a1111601177309b
|
refs/heads/main
| 2023-08-17T10:52:47.667706
| 2021-09-28T18:05:15
| 2021-09-28T18:05:15
| 345,573,564
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,966
|
ino
|
LFR_new.ino
|
#define L_S A0 // left sensor
#define M_S A1 // right sensor
#define R_S A4 //middle sensor
#define L_M_F 6 // left motor fwd
#define L_M_R 5 // left motor rvrs
#define R_M_F 2 // right motor fwd
#define R_M_R 3 // right motor rvrs
void setup() {
pinMode(L_S, INPUT);
pinMode(R_S, INPUT);
pinMode(M_S, INPUT);
pinMode(L_M_F, OUTPUT);
pinMode(L_M_R, OUTPUT);
pinMode(R_M_F, OUTPUT);
pinMode(R_M_R, OUTPUT);
}
void loop() {
if(digitalRead(L_S) && digitalRead(R_S)&& digitalRead(M_S)) // Move Forward
{
digitalWrite(L_M_F,HIGH);
digitalWrite(L_M_R,LOW);
digitalWrite(R_M_F,HIGH);
digitalWrite(R_M_R,LOW);
}
if(!digitalRead(L_S) && !digitalRead(R_S)&& digitalRead(M_S)) // Move Forward
{
digitalWrite(L_M_F,HIGH);
digitalWrite(L_M_R,LOW);
digitalWrite(R_M_F,HIGH);
digitalWrite(R_M_R,LOW);
}
if(!(digitalRead(L_S)) && digitalRead(R_S)&& digitalRead(M_S)) // Turn right
{
digitalWrite(L_M_F,HIGH);
digitalWrite(L_M_R,LOW);
digitalWrite(R_M_F,LOW);
digitalWrite(R_M_R,LOW);
}
if(!(digitalRead(L_S)) && digitalRead(R_S)&& !digitalRead(M_S)) // Turn extreme right
{
digitalWrite(L_M_F,HIGH);
digitalWrite(L_M_R,LOW);
digitalWrite(R_M_F,LOW);
digitalWrite(R_M_R,HIGH);
}
if(digitalRead(L_S) && !(digitalRead(R_S)&& digitalRead(M_S))) // Turn left
{
digitalWrite(L_M_F,LOW);
digitalWrite(L_M_R,LOW);
digitalWrite(R_M_F,HIGH);
digitalWrite(R_M_R,LOW);
}
if(digitalRead(L_S) && !(digitalRead(R_S))&& !(digitalRead(M_S))) // Turn extreme left
{
digitalWrite(L_M_F,LOW);
digitalWrite(L_M_R,HIGH);
digitalWrite(R_M_F,HIGH);
digitalWrite(R_M_R,LOW);
}
if(!(digitalRead(L_S)) && !(digitalRead(R_S))&& !(digitalRead(M_S))) // Stop
{
digitalWrite(L_M_F,LOW);
digitalWrite(L_M_R,LOW);
digitalWrite(R_M_F,LOW);
digitalWrite(R_M_R,LOW);
}
}
|
cbab7c54ec9013f7e6a9a9c5a92a8943e06cd816
|
dd80a584130ef1a0333429ba76c1cee0eb40df73
|
/external/chromium/chrome/browser/chromeos/login/login_html_dialog.cc
|
b5187366eb54a7514f1c2ddcb43c86a0a0da0f9c
|
[
"MIT",
"BSD-3-Clause"
] |
permissive
|
karunmatharu/Android-4.4-Pay-by-Data
|
466f4e169ede13c5835424c78e8c30ce58f885c1
|
fcb778e92d4aad525ef7a995660580f948d40bc9
|
refs/heads/master
| 2021-03-24T13:33:01.721868
| 2017-02-18T17:48:49
| 2017-02-18T17:48:49
| 81,847,777
| 0
| 2
|
MIT
| 2020-03-09T00:02:12
| 2017-02-13T16:47:00
| null |
UTF-8
|
C++
| false
| false
| 4,272
|
cc
|
login_html_dialog.cc
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/login/login_html_dialog.h"
#include "chrome/browser/chromeos/frame/bubble_frame_view.h"
#include "chrome/browser/chromeos/frame/bubble_window.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/views/html_dialog_view.h"
#include "content/common/notification_service.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "views/window/window.h"
namespace chromeos {
namespace {
// Default width/height ratio of screen size.
const double kDefaultWidthRatio = 0.6;
const double kDefaultHeightRatio = 0.6;
// Custom HtmlDialogView with disabled context menu.
class HtmlDialogWithoutContextMenuView : public HtmlDialogView {
public:
HtmlDialogWithoutContextMenuView(Profile* profile,
HtmlDialogUIDelegate* delegate)
: HtmlDialogView(profile, delegate) {}
virtual ~HtmlDialogWithoutContextMenuView() {}
// TabContentsDelegate implementation.
bool HandleContextMenu(const ContextMenuParams& params) {
// Disable context menu.
return true;
}
};
} // namespace
///////////////////////////////////////////////////////////////////////////////
// LoginHtmlDialog, public:
LoginHtmlDialog::LoginHtmlDialog(Delegate* delegate,
gfx::NativeWindow parent_window,
const std::wstring& title,
const GURL& url,
Style style)
: delegate_(delegate),
parent_window_(parent_window),
title_(title),
url_(url),
style_(style),
bubble_frame_view_(NULL),
is_open_(false) {
gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
width_ = static_cast<int>(kDefaultWidthRatio * screen_bounds.width());
height_ = static_cast<int>(kDefaultHeightRatio * screen_bounds.height());
}
LoginHtmlDialog::~LoginHtmlDialog() {
delegate_ = NULL;
}
void LoginHtmlDialog::Show() {
HtmlDialogWithoutContextMenuView* html_view =
new HtmlDialogWithoutContextMenuView(ProfileManager::GetDefaultProfile(),
this);
if (style_ & STYLE_BUBBLE) {
views::Window* bubble_window = BubbleWindow::Create(
parent_window_, gfx::Rect(),
static_cast<BubbleWindow::Style>(
BubbleWindow::STYLE_XBAR | BubbleWindow::STYLE_THROBBER),
html_view);
bubble_frame_view_ = static_cast<BubbleFrameView*>(
bubble_window->non_client_view()->frame_view());
} else {
views::Window::CreateChromeWindow(parent_window_, gfx::Rect(), html_view);
}
if (bubble_frame_view_) {
bubble_frame_view_->StartThrobber();
notification_registrar_.Add(this,
NotificationType::LOAD_COMPLETED_MAIN_FRAME,
NotificationService::AllSources());
}
html_view->InitDialog();
html_view->window()->Show();
is_open_ = true;
}
void LoginHtmlDialog::SetDialogSize(int width, int height) {
DCHECK(width >= 0 && height >= 0);
width_ = width;
height_ = height;
}
void LoginHtmlDialog::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
DCHECK(type.value == NotificationType::LOAD_COMPLETED_MAIN_FRAME);
if (bubble_frame_view_)
bubble_frame_view_->StopThrobber();
}
///////////////////////////////////////////////////////////////////////////////
// LoginHtmlDialog, protected:
void LoginHtmlDialog::OnDialogClosed(const std::string& json_retval) {
is_open_ = false;
notification_registrar_.RemoveAll();
if (delegate_)
delegate_->OnDialogClosed();
}
void LoginHtmlDialog::OnCloseContents(TabContents* source,
bool* out_close_dialog) {
if (out_close_dialog)
*out_close_dialog = true;
}
void LoginHtmlDialog::GetDialogSize(gfx::Size* size) const {
size->SetSize(width_, height_);
}
} // namespace chromeos
|
d63f4d71e6975d82cccaf4f0a7b598e2a68b2239
|
84be2fd2200f577e7dc54e94ad3947e6bb7002ad
|
/Parkour/Classes/BankRaiseLayer.cpp
|
a89ca4b38389b014fe5ba425d53eb0b4b1d5d04e
|
[] |
no_license
|
joyfish/cocos2d
|
1f0f9e8aad282b95690c19e5f4fe375d175d76bb
|
6745cfff22ae61e4ad70c49c0cf4c30a68485549
|
refs/heads/master
| 2021-01-18T00:53:54.661212
| 2015-10-25T13:09:06
| 2015-10-25T13:09:06
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,942
|
cpp
|
BankRaiseLayer.cpp
|
#include "BankRaiseLayer.h"
#include "GAMEDATA.h"
#include "PlayerRank.h"
bool BankRaiseLayer::init()
{
if (!Layer::init())
{
return false;
}
animeTime = 0;
Size visibleSize = Director::getInstance()->getVisibleSize();
Sprite* background = Sprite::create("black_bg.png");
background->setScaleX(800);
background->setScaleY(480);
background->setPosition(visibleSize.width/2,visibleSize.height/2);
this->addChild(background);
upBg = Sprite::createWithSpriteFrameName("bank_up.png");
upBg->setPosition(232,281);
upBg->setTag(2001);
this->addChild(upBg);
upNum = LabelAtlas::create(String::createWithFormat("%d",
PLAYERRANK::getInstance()->getRankList(GAMEDATA::getInstance()->getGameScore()))->_string,"bank_num.png",
28,37,48);
upNum->setTag(2002);
upNum->setAnchorPoint(Point(0.5,0.5));
upNum->setPosition(232,247);
this->addChild(upNum);
downBg = Sprite::createWithSpriteFrameName("bank_down.png");
downBg->setPosition(552,190);
downBg->setTag(2003);
this->addChild(downBg);
downNum = LabelAtlas::create(String::createWithFormat("%d",
PLAYERRANK::getInstance()->getRankList(GAMEDATA::getInstance()->getHistoryScore()))->_string,"bank_num.png",
28,37,48);
downNum->setTag(2004);
downNum->setAnchorPoint(Point(0.5,0.5));
downNum->setPosition(552,234);
this->addChild(downNum);
this->scheduleUpdate();
return true;
}
void BankRaiseLayer::update(float dt){
if(this->isVisible()){
animeTime += dt/0.05;
if(((int)animeTime)/16 % 2 == 0){
upBg->setPositionY(upBg->getPositionY()+1);
upNum->setPositionY(upNum->getPositionY()+1);
downBg->setPositionY(downBg->getPositionY()-1);
downNum->setPositionY(downNum->getPositionY()-1);
}else{
upBg->setPositionY(upBg->getPositionY()-1);
upNum->setPositionY(upNum->getPositionY()-1);
downBg->setPositionY(downBg->getPositionY()+1);
downNum->setPositionY(downNum->getPositionY()+1);
}
}
}
void BankRaiseLayer::refreshInfo(){
}
|
e3cdea35ecc5e3a549a40f05e15b809201d3c549
|
4d33c090428407d599a4c0a586e0341353bcf8d7
|
/trunk/math/RootFinding.cpp
|
e43583a4ea14bebda96e582bd4ce0387b7fae4aa
|
[] |
no_license
|
yty/bud
|
f2c46d689be5dfca74e239f90570617b3471ea81
|
a37348b77fb2722c73d972a77827056b0b2344f6
|
refs/heads/master
| 2020-12-11T06:07:55.915476
| 2012-07-22T21:48:05
| 2012-07-22T21:48:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 49
|
cpp
|
RootFinding.cpp
|
#include "RootFinding.h"
namespace Zen
{
}
|
342b8ffc697eb9fe1bf939ce25b3157dc5d95851
|
c2b708c6b9341c3976b0fd50b2fcd038083f4b5f
|
/hw2-templates-functions/structS.cpp
|
23d852fe5da5abd3462b5a30e582d65a19a127d9
|
[] |
no_license
|
KristinaJelyazkova/OOP-Object-Oriented-Programming
|
9fc7956d0f03d9d90e39d1014eaf4ea06575d705
|
61e55f3796a3514de5c0d439a38dc1cf0ec7dcd2
|
refs/heads/master
| 2022-04-14T23:45:06.646208
| 2020-04-15T18:57:43
| 2020-04-15T18:57:43
| 114,671,793
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,098
|
cpp
|
structS.cpp
|
#include<iostream>
#include<fstream>
using namespace std;
struct S {
int a;
int b;
int c;
};
void swap(S &s1, S &s2) {
S buf = s2;
s2 = s1;
s1 = buf;
}
int compareByA(S s1, S s2) {
if (s1.a > s2.a) return 1;
if (s1.a == s2.a) return 0;
return -1;
}
int compareByB(S s1, S s2) {
if (s1.b > s2.b) return 1;
if (s1.b == s2.b) return 0;
return -1;
}
int compareLeks(S s1, S s2) {
if (s1.a > s2.a) return 1;
if (s1.a < s2.a) return -1;
if (s1.b > s2.b) return 1;
if (s1.b < s2.b) return -1;
if (s1.c > s2.c) return 1;
if (s1.c < s2.c) return -1;
return 0;
}
void sort(S *array, int n, int(*compare)(S, S)) {
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (compare(array[j], array[j + 1]) == 1) swap(array[j], array[j + 1]);
}
}
}
int main() {
S s[5];
for (int i = 0; i < 5; i++) {
cin >> s[i].a >> s[i].b >> s[i].c;
}
sort(s, 5, compareLeks);
for (int i = 0; i < 5; i++) {
cout << s[i].a << " "
<< s[i].b << " "
<< s[i].c << endl;
}
system("pause");
return 0;
}
|
0e036b3863b78d198fc0dd9f14c207fddaa1f124
|
2b6c5b7ba1a7cdb3bfc26f30c9b2d275b336f97c
|
/old/Welcome.cpp
|
0575fe908df2fb9bddc4216d5a60d2336f9de156
|
[
"MIT"
] |
permissive
|
DistinctWind/OI
|
cbbc81429ae5daada9d6c13b21cb52f65e438e4e
|
da0aa104731b30958d4fdc87fb76205ff4a481ea
|
refs/heads/master
| 2021-04-08T02:18:43.410471
| 2020-03-24T14:29:06
| 2020-03-24T14:29:06
| 248,726,252
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,661
|
cpp
|
Welcome.cpp
|
#include <cstdio>
#include <vector>
#include <stack>
using namespace std;
const int MAXN=10010;
const int MAXM=50010;
int n,m;
int head[MAXN],cnt_edge;
int bhead[MAXN],cnt_bedge;
int dfn[MAXN],b[MAXN],low[MAXN],t,ans=-1;
int out[MAXN];
int cnt_block;
stack <int> s;
vector <int> block[MAXN];
bool is[MAXN];
struct Edge{
int nxt,to;
}edge[MAXM],bedge[MAXM];
inline void add(int from,int to)
{
cnt_edge++;
edge[cnt_edge].nxt=head[from];
head[from]=cnt_edge;
edge[cnt_edge].to=to;
}
inline void badd(int from,int to)
{
cnt_bedge++;
bedge[cnt_bedge].nxt=bhead[from];
bhead[from]=cnt_bedge;
bedge[cnt_bedge].to=to;
}
void tarjan(int x)
{
dfn[x]=low[x]=++t;
is[x]=true;
s.push(x);
for (int i=head[x];i;i=edge[i].nxt)
if (!dfn[edge[i].to])
{
tarjan(edge[i].to);
if (low[edge[i].to]<low[x])
low[x]=low[edge[i].to];
}
else if (is[edge[i].to]&&low[edge[i].to]<low[x])
{
low[x]=low[edge[i].to];
}
if (low[x]==dfn[x])
{
int i;
cnt_block++;
do
{
i=s.top(); s.pop();
b[i]=cnt_block;
is[i]=false;
for (int j=head[i];j;j=edge[j].nxt)
if (!is[edge[j].to]&&b[i]!=b[edge[j].to])
out[b[i]]++;
block[cnt_block].push_back(i);
}
while (low[i]!=dfn[i]);
}
}
inline void solve()
{
for (int i=1;i<=n;i++)
if (!dfn[i])
tarjan(i);
}
int main()
{
//freopen("in.txt","r",stdin);
scanf("%d%d",&n,&m);
for (int i=1;i<=m;i++)
{
int a,b;
scanf("%d%d",&a,&b);
add(a,b);
}
solve();
for (int i=1;i<=cnt_block;i++)
{
if (out[i]==0)
{
if (ans!=-1)
{
printf("0");
return 0;
}
else ans=i;
}
}
printf("%d\n",(int)block[ans].size());
}
//LGOJ https://www.luogu.org/problem/P2341
|
49cfd356f497f3229b37d6c13e0cb2c8aad1aa19
|
e17546794b54bb4e7f65320fda8a046ce28c7915
|
/DeviceCode/Drivers/BatteryMeasurement/stubs/fastcompile_BatteryMeasurement_stubs.cpp
|
f31185706f12c7996debba92bf5ca22762337e95
|
[
"BSD-3-Clause",
"OpenSSL",
"MIT",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"Apache-2.0"
] |
permissive
|
smaillet-ms/netmf-interpreter
|
693e5dc8c9463ff0824c515e9240270c948c706f
|
53574a439396cc98e37b82f296920c7e83a567bf
|
refs/heads/dev
| 2021-01-17T22:21:36.617467
| 2016-09-05T06:29:07
| 2016-09-05T06:29:07
| 32,760,598
| 2
| 1
| null | 2016-04-26T02:49:52
| 2015-03-23T21:44:01
|
C#
|
UTF-8
|
C++
| false
| false
| 92
|
cpp
|
fastcompile_BatteryMeasurement_stubs.cpp
|
#include "BatteryMeas_stubs_functions.cpp"
#include "BatteryMeasurement_stubs_config.cpp"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.