blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
8fa8bfc1b505eb299af0655e24aca5d43a61dd2f
83afc3a864e99064ca7b6d87dfbae7b8fa470379
/New folder/LIBRARY.h
821dcfd24655d3e8bd051e1781d633a82c6c6477
[]
no_license
talhaty1/C-projects
c54cc1f558cc56f219bf1a405959ea3f20439520
7f57933fd47b074bae931471188e531a49b519b2
refs/heads/main
2023-06-01T19:22:05.414078
2021-06-16T09:06:27
2021-06-16T09:06:27
377,434,008
0
0
null
null
null
null
UTF-8
C++
false
false
45,794
h
// Made By Talha Yunus // (2020497) (2020408) (2020493) #include <iostream> #include <cstring> #include "CERR.h" #include <windows.h> using namespace std; //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- class CBook{ // A doubly Linked List struct Node{ int ID; char* BookName; char* author; char* ISBN; int price; int pages; char* IssuedBy; char* IssuedOn; char* ReturnDate; //Next and Previous pointer to keep track of the nodes in the List Node *next, *prev; //overloaded constructors Node(int ID=0, char* BookName=NULL, char* author=NULL, char* ISBN=NULL, int price=0, int pages=0, char* IssuedBy=0, char* IssuedOn=NULL, char* ReturnDate=NULL) : next(NULL) , prev(NULL) { BookName = new char; author = new char; ISBN = new char; IssuedBy = new char; IssuedOn = new char; ReturnDate = new char; Node::ID = ID; Node::BookName = BookName; Node::author = author; Node::ISBN = ISBN; Node::price = price; Node::pages = pages; Node::IssuedBy = IssuedBy; Node::IssuedOn = IssuedOn; Node::ReturnDate = ReturnDate; } Node(const Node& obj){ BookName = new char; author = new char; ISBN = new char; IssuedBy = new char; IssuedOn = new char; ReturnDate = new char; Node::ID = obj.ID; Node::BookName = obj.BookName; Node::author = obj.author; Node::ISBN = obj.ISBN; Node::price = obj.price; Node::pages = obj.pages; Node::IssuedBy = obj.IssuedBy; Node::IssuedOn = obj.IssuedOn; Node::ReturnDate = obj.ReturnDate; Node::next = obj.next; Node::prev = obj.prev; } Node(const Node* obj){ BookName = new char; author = new char; ISBN = new char; IssuedBy = new char; IssuedOn = new char; ReturnDate = new char; Node::ID = obj->ID; Node::BookName = obj->BookName; Node::author = obj->author; Node::ISBN = obj->ISBN; Node::price = obj->price; Node::pages = obj->pages; Node::IssuedBy = obj->IssuedBy; Node::IssuedOn = obj->IssuedOn; Node::ReturnDate = obj->ReturnDate; Node::next = obj->next; Node::prev = obj->prev; } //ALL GETTERS int getID() {return Node::ID;} char* getBookName() {return Node::BookName;} char* getauthor() {return Node::author;} char* getISBN() {return Node::ISBN;} int getprice() {return Node::price;} int getpages() {return Node::pages;} char* getIssuedBy() {return Node::IssuedBy;} char* getIssuedOn() {return Node::IssuedOn;} char* getReturnDate() {return Node::ReturnDate;} //ALL SETTERS void setID(int& ID) {Node::ID = ID;} void setBookName(char* BookName) {Node::BookName = BookName;} void setauthor(char* author) {Node::author = author;} void setISBN(char* ISBN) {Node::ISBN = ISBN;} void setprice(int& price) {Node::price = price;} void setpages(int& pages) {Node::pages = pages;} void setIssuedBy(char* IssuedBy) {Node::IssuedBy = IssuedBy;} void setIssuedOn(char* IssuedOn) {Node::IssuedOn = IssuedOn;} void setReturnDate(char* ReturnDate) {Node::ReturnDate = ReturnDate;} void setAll(int ID, char* BookName, char* author, char* ISBN, int price, int pages, char* IssuedBy, char* IssuedOn, char* ReturnDate){ Node::ID = ID; Node::BookName = BookName; Node::author = author; Node::ISBN = ISBN; Node::price = price; Node::pages = pages; Node::IssuedBy = IssuedBy; Node::IssuedOn = IssuedOn; Node::ReturnDate = ReturnDate; } }; //head and tail pointer //head = first Node tail = Last Node //totalBooks is used to keep track of total Nodes Node *head, *tail; int totalBooks; public: //initialization CBook() : head(NULL) , tail(NULL) , totalBooks(0) {} //it will delete all the nodes made and free the memory at the end ~CBook(){ totalBooks = 0; Node *tmp; while(tail){ tmp = tail; tail = tail->prev; delete tmp; } head = NULL; tail = NULL; } //Simply outputs all the Books void PrintAll(){ Node *temp; temp = head; for(int i=0; i<totalBooks; i++){ cout<<"\n\n\nBOOK ID: "<<temp->ID<<"\n\n\tBOOKNAME: "<<temp->BookName<<"\tAUTHOR: "<<temp->author <<"\tISBN: "<<temp->ISBN<<"\tPRICE: "<<temp->price<<"\tPAGES: "<<temp->pages <<"\n\n\tISSUED BY: "<<temp->IssuedBy<<"\tISSUED ON: "<<temp->IssuedOn<<"\tRETURN DATE: "<<temp->ReturnDate <<endl<<endl; temp = temp->next; } } //Prints a specific Book with a specific ID void PrintSome(int ID){ Node *temp = head; bool found = false; //iterate through the List for(int i=0; i<totalBooks; i++){ if(temp->ID == ID){ cout<<"\n\n\nBOOK ID: "<<temp->ID<<"\n\n\tBOOKNAME: "<<temp->BookName<<"\tAUTHOR: "<<temp->author <<"\tISBN: "<<temp->ISBN<<"\tPRICE: "<<temp->price<<"\tPAGES: "<<temp->pages <<"\n\n\tISSUED BY: "<<temp->IssuedBy<<"\tISSUED ON: "<<temp->IssuedOn<<"\tRETURN DATE: "<<temp->ReturnDate <<endl<<endl; found = true; return; } //Moves to next node temp = temp->next; } if(found == false){ cout<<"\n\nNOT FOUND\n\n"; } } //there are two Add functions (overloaded) //It simply add a node (adds a new book) void Add(int ID, char* BookName, char* author, char* ISBN, int price, int pages, char* IssuedBy, char* IssuedOn, char* ReturnDate){ Node *temp; temp = new Node; Node *temp2 = head; for(int i=0; i<totalBooks; i++){ if(temp2->ID == ID){ cout<<"\n\nBOOK ID ALREADY EXISTS\n\n"; return; } temp2 = temp2->next; } temp->ID = ID; temp->BookName = BookName; temp->author = author; temp->ISBN = ISBN; temp->price = price; temp->pages = pages; temp->IssuedBy = IssuedBy; temp->IssuedOn = IssuedOn; temp->ReturnDate = ReturnDate; temp->next = NULL; //If the List is empty And the new node is going to be a head if(head==NULL){ head = temp; tail = temp; temp->prev = NULL; } //If the List is not empty else{ temp->prev = tail; tail->next = temp; tail = temp; } totalBooks++; cout<<"\n\nNew Book Added\n\n"; } //It copies all the book of object 1 to object 2 void operator=(CBook& books){ Node* temp1; Node* temp2; temp1 = this->head; temp2 = books.head; this->DeleteAll(); int totalBooks2 = books.gettotalBooks(); for(int i=0; i<totalBooks2; i++){ this->Add(temp2->ID, temp2->BookName, temp2->author, temp2->ISBN, temp2->price, temp2->pages, temp2->IssuedBy, temp2->IssuedOn, temp2->ReturnDate); temp2 = temp2->next; } } //It copies all the Data of one Node to the Node which calls the function void Copy(CBook& book, int ID){ bool found = false; Node *temp = book.gettail(); //checks if the provided ID is present in the List while(temp){ if(temp->ID == ID){ found=true; break; } temp = temp->prev; } //if ID is present the it simply copies it to the node if (found==true){ Add(temp->ID, temp->BookName, temp->author, temp->ISBN, temp->price, temp->pages, temp->IssuedBy, temp->IssuedOn, temp->ReturnDate); } else{ cout<<"\n\nNOT FOUND\n\n"; } } //overloaded //It adds a new Node void Add(){ Node *temp; temp = new Node; bool found = false; //this loops checks if the ID given by the user is already present in the List //Because the ID is unique in list //if ID is already present in the List then it will ask the user to enter the ID again do{ found = false; cout<<"\n\n\nBOOK ID: "; CERR(temp->ID); Node *temp2 = head; for(int i=0; i<totalBooks; i++){ if(temp2->ID == temp->ID){ cout<<"\n\nBOOK ID ALREADY EXISTS\tTRY DIFFERENT ID\n\n"; found = true; break; } temp2 = temp2->next; } }while(found); cout<<"\n\nBOOK NAME: "; CERR(temp->BookName); cout<<"\n\nAUTHOR: "; CERR(temp->author); cout<<"\n\nISBN: "; CERR(temp->ISBN); cout<<"\n\nPRICE: "; CERR(temp->price); cout<<"\n\nPAGES: "; CERR(temp->pages); cout<<"\n\nISSUED BY: "; CERR(temp->IssuedBy); cout<<"\n\nISSUED ON: "; CERR(temp->IssuedOn); cout<<"\n\nRETURN DATE: "; CERR(temp->ReturnDate); temp->next = NULL; //if the List is already Empty then the Node to be added will become head and tail both if(head==NULL){ head = temp; tail = temp; head->prev = NULL; } //if the List is not empty else{ temp->prev = tail; tail->next = temp; tail = temp; } totalBooks++; cout<<"\n\nNew Book Added\n\n"; } //Sort the Books with respect to the ID in Ascending order void Sort_A(){ //If there is only one Node then there is not need to sort it if(totalBooks==1){ return; } //declare all the variables //the nodes will remain at the same position that is the next and previous addresses will not change //only the data will be changed from one node to other int ID; char* BookName; char* author; char* ISBN; int price; int pages; char* IssuedBy; char* IssuedOn; char* ReturnDate; BookName = new char; author = new char; ISBN = new char; IssuedBy = new char; IssuedOn = new char; ReturnDate = new char; Node *temp1; Node *temp2; //compare two nodes ID using Bubble sort Algorithm //if they are in wrong order then swap the data in them for(int i=0; i<totalBooks-1; i++){ temp1 = head; temp2 = head->next; for(int j=0; j<totalBooks-1; j++){ if(j > 0) { temp1 = temp1->next; temp2 = temp2->next; } if(temp1->ID > temp2->ID){ ID = temp2->ID; BookName = temp2->BookName; author = temp2->author; ISBN = temp2->ISBN; price = temp2->price; pages = temp2->pages; IssuedBy = temp2->IssuedBy; IssuedOn = temp2->IssuedOn; ReturnDate = temp2->ReturnDate; temp2->setAll(temp1->ID, temp1->BookName, temp1->author, temp1->ISBN, temp1->price, temp1->pages, temp1->IssuedBy, temp1->IssuedOn, temp1->ReturnDate); temp1->ID = ID; temp1->BookName = BookName; temp1->author = author; temp1->ISBN = ISBN; temp1->price = price; temp1->pages = pages; temp1->IssuedBy = IssuedBy; temp1->IssuedOn = IssuedOn; temp1->ReturnDate = ReturnDate; } } } } //Sort the Books with respect to the ID in Descending order //compare two nodes ID using Bubble sort Algorithm //if they are in wrong order then swap the data in them //same as above Sort_A() Function void Sort_D(){ if(totalBooks==1){ return; } int ID; char* BookName; char* author; char* ISBN; int price; int pages; char* IssuedBy; char* IssuedOn; char* ReturnDate; BookName = new char; author = new char; ISBN = new char; IssuedBy = new char; IssuedOn = new char; ReturnDate = new char; Node *temp1; Node *temp2; for(int i=0; i<totalBooks-1; i++){ temp1 = head; temp2 = head->next; for(int j=0; j<totalBooks-1; j++){ if(j > 0) { temp1 = temp1->next; temp2 = temp2->next; } if(temp1->ID < temp2->ID){ ID = temp2->ID; BookName = temp2->BookName; author = temp2->author; ISBN = temp2->ISBN; price = temp2->price; pages = temp2->pages; IssuedBy = temp2->IssuedBy; IssuedOn = temp2->IssuedOn; ReturnDate = temp2->ReturnDate; temp2->setAll(temp1->ID, temp1->BookName, temp1->author, temp1->ISBN, temp1->price, temp1->pages, temp1->IssuedBy, temp1->IssuedOn, temp1->ReturnDate); temp1->ID = ID; temp1->BookName = BookName; temp1->author = author; temp1->ISBN = ISBN; temp1->price = price; temp1->pages = pages; temp1->IssuedBy = IssuedBy; temp1->IssuedOn = IssuedOn; temp1->ReturnDate = ReturnDate; } } } } void DeleteAll(){ totalBooks = 0; Node *tmp; while(tail){ tmp = tail; tail = tail->prev; delete tmp; } head = NULL; tail = NULL; } void Delete(int ID){ Node *temp = head; //Go through the List to get the Node for which the ID is equal to the Node ID for(int i=0; i<totalBooks; i++){ if(temp->ID == ID){ //if there is only one node //Then the head will be equal to tail if(head == tail){ delete temp; head = NULL; tail = NULL; totalBooks = 0; return; } //if the node to remove is the last node that is Tail //then change the tail to previous Node else if(temp->next == temp){ tail = temp->prev; tail->next = temp->prev; } //If the node to remove is the head //then change the head to the next node else if(temp->prev == NULL){ head = temp->next; head->prev = NULL; } //if the node to remove is somewhere in the middle of the list else{ Node* tempPrev = temp->prev; Node* tempNext = temp->next; tempPrev->next = tempNext; tempNext->prev = tempPrev; } totalBooks--; //delete the node which was just removed delete temp; cout<<"\n\nDeleted Successfully\n\n"; return; } temp = temp->next; } } //All GETTER FUNCTIONS int gettotalBooks(){ return CBook::totalBooks; } Node* gethead(){ return head; } Node* gettail(){ return tail; } }; //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- class CBookList{ //This is indented List that is list is inside a list //books is a list and Now it is inside Node struct Node{ CBook books; int ListID; Node *next; Node *prev; //Constructors Node(CBook books, int ListID=0) :next(NULL), prev(NULL) { Node::books = books; Node::ListID = ListID; } Node() : ListID(0), next(NULL), prev(NULL) {} //All getters CBook getbooks() {return Node::books;} int getListID() {return Node::ListID;} //All Setters CBook setbooks(CBook books) {Node::books = books;} int setListID(int& ListID) {Node::ListID = ListID;} }; Node *head, *tail; int totalLists; public: //destructor ~CBookList(){ Node *tmp; while(tail){ tmp = tail; tail = tail->prev; delete tmp; } } //constructor CBookList() : totalLists(0) { head = NULL; tail = NULL; } void PrintAll(){ Node* temp; temp = head; for(int i=0; i<totalLists; i++){ cout<<"\n\n\n\t\t***** LIST ID: "<<temp->ListID<<" *****"<<endl<<endl<<endl; temp->Node::books.PrintAll(); temp = temp->next; } } void PrintSome(int ListID){ bool found = false; Node* temp; temp = head; //put head in temp and go through the list by comparing the ID for(int i=0; i<totalLists; i++){ if(temp->ListID == ListID){ temp->Node::books.PrintAll(); found = true; return; } temp = temp->next; } if(found == false){ cout<<"\n\nNOT FOUND\n\n"; } } //It will sort all the list as well as books in it in ascending order void Sort_A(){ Node *temp3; temp3 = new Node; Node *temp1; Node *temp2; for(int i=0; i<totalLists-1; i++){ if(totalLists==1){ break; } temp1 = head; temp2 = head->next; for(int j=0; j<totalLists-1; j++){ if(j>0){ temp1 = temp1->next; temp2 = temp2->next; } if((temp1->ListID > temp2->ListID)){ temp3->Node::ListID = temp2->Node::ListID; temp3->Node::books = temp2->books; temp2->Node::ListID = temp1->Node::ListID; temp2->Node::books = temp1->books; temp1->Node::ListID = temp3->Node::ListID; temp1->Node::books = temp3->books; system("cls"); } } } temp1 = head; for(int i=0; i<totalLists; i++){ if(i>0) temp1 = temp1->next; temp1->Node::books.Sort_A(); } } //It will sort all the list as well as books in it in descending order void Sort_D(){ Node *temp3; temp3 = new Node; Node *temp1; Node *temp2; for(int i=0; i<totalLists-1; i++){ if(totalLists==1){ break; } temp1 = head; temp2 = head->next; for(int j=0; j<totalLists-1; j++){ if(j>0){ temp1 = temp1->next; temp2 = temp2->next; } if((temp1->ListID < temp2->ListID)){ temp3->Node::ListID = temp2->Node::ListID; temp3->Node::books = temp2->books; temp2->Node::ListID = temp1->Node::ListID; temp2->Node::books = temp1->books; temp1->Node::ListID = temp3->Node::ListID; temp1->Node::books = temp3->books; system("cls"); } } } temp1 = head; for(int i=0; i<totalLists; i++){ if(i>0) temp1 = temp1->next; temp1->Node::books.Sort_A(); } } void AddList(int ListID){ Node* temp; temp = new Node; Node* temp2 = head; bool found = false; do{ found = false; temp2 = head; for(int i=0; i<totalLists; i++){ if(temp2->ListID == ListID){ found = true; cout<<"\n\nLIST ID ALREADY EXISTS\tTRY AGAIN: "; CERR(ListID); break; } temp2 = temp2->next; } }while(found); temp->ListID = ListID; temp->next = NULL; if(head==NULL){ head = temp; tail = temp; head->prev = NULL; } else{ temp->prev = tail; tail->next = temp; tail = temp; } totalLists++; cout<<"\n\nNew List Added\n\n"; } //This will add books to the List which you just made above void AddNode(int ListID){ Node* temp; temp = new Node; temp = head; bool found = false; //First it will check if the List ID you just entered is present in the list //if yes it will add a new book //if not then it will add a new list and then add a new book while(found == false){ for(int i=0; i<totalLists; i++){ if(temp->ListID == ListID){ found = true; break; } temp = temp->next; } if(found == true){ temp->Node::books.Add(); return; } else{ cout<<"\n\nLIST ID NOT FOUND\n\n"; cout<<"\n\nMAKING A NEW LIST FOR YOU\n\n"; AddList(ListID); temp = head; } } } //this will copy items of one Node to Another node bool Copy(int ListID_old, int ListID_new, int BookID){ Node* temp_old = new Node; temp_old = head; Node* temp_new = new Node; temp_new = head; bool found1 = false; bool found2 = false; for(int i=0; i<totalLists; i++){ if(temp_old->ListID == ListID_old){ found1 = true; break; } temp_old = temp_old->next; } for(int i=0; i<totalLists; i++){ if(temp_new->ListID == ListID_new){ found2 = true; break; } temp_new = temp_new->next; } //if both the list ID you entered are prsent then it will copy the old one to new if(found1==true && found2==true){ temp_new->Node::books.Copy(temp_old->Node::books, BookID); return true; } else{ if(found1==false && found2==true){ cout<<"\n\nTHE LIST FROM WHICH YOU WANT TO DELETE THE ITEM NOT FOUND\n\n"; } else if(found1==true && found2==false){ cout<<"\n\nTHE LIST to WHICH YOU WANT TO MOVE THE ITEM NOT FOUND\n\n"; } else if(found1==false && found2==false){ cout<<"\n\nBOTH LISTS NOT FOUND\n\n"; } return false; } } int gettotalLists(){ return totalLists; } //Simply deletes a List an frees up memory void Delete(int ListID){ Node *temp = head; bool found = false; for(int i=0; i<totalLists; i++){ if(temp->ListID == ListID){ found = true; //If the List has only one node if(tail==head){ delete temp; tail = NULL; head = NULL; totalLists = 0; return; } //if the node to delete is the tail else if(temp->next == temp){ tail = temp->prev; tail->next = temp->prev; } //if the node is head else if(temp->prev == NULL){ head = temp->next; head->prev = NULL; } //if the node is somewhere in between else{ Node* tempPrev = temp->prev; Node* tempNext = temp->next; tempPrev->next = tempNext; tempNext->prev = tempPrev; } cout<<"\n\nSUCCESSFULLY DELETED\n\n"; totalLists--; delete temp; return; } temp = temp->next; } if(found == false){ cout<<"\n\nLIST ID NOT FOUND\n\n"; } } //this wil delete a specific book inside a list void DeleteNode(int ListID, int BookID){ Node *temp = head; bool found = false; for(int i=0; i<totalLists; i++){ if(temp->ListID == ListID){ found = true; temp->Node::books.Delete(BookID); return; } temp = temp->next; } if(found == false){ cout<<"\n\nLIST ID NOT FOUND\n\n"; } } //Simply deletes all the lists and free up memeory void DeleteAll(){ Node *tmp; while(tail){ tmp = tail; tail = tail->prev; delete tmp; } cout<<"\n\nDeleted Successfully\n\n"; totalLists = 0; } }; //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- class CStudent{ struct Node{ int ID; char* StdName; int RollNo; int BooksIssued; Node* next, *prev; //Constructor Node(): ID(0), RollNo(0), BooksIssued(0), next(NULL), prev(NULL) { StdName = new char; } //ALL GETTERS int getID() {return Node::ID;} char* getStdName() {return Node::StdName;} int getRollNo() {return Node::RollNo;} int getBooksIssued() {return Node::BooksIssued;} //ALL SETTERS void setID(int ID) {Node::ID = ID;} void setStdName(char* StdName) {Node::StdName = StdName;} void setRollNo(int RollNo) {Node::RollNo = RollNo;} void setBooksIssued(int BooksIssued) {Node::BooksIssued = BooksIssued;} }; Node* head, *tail; int totalStudents; public: //constructor CStudent() : head(NULL), tail(NULL), totalStudents(0) {} //destructor ~CStudent(){ Node *tmp; while(tail){ tmp = tail; tail = tail->prev; delete tmp; } } //ALL GETTERS int getBooksIssued() { return head->Node::BooksIssued; } void setBooksIssued(int BooksIssued) { head->Node::BooksIssued = BooksIssued; } int getStudentID(){ return head->Node::ID; } //PRINTS ALL THE STUDENTS void PrintAll(){ Node *temp; temp = head; for(int i=0; i<totalStudents; i++){ cout<<"\n\n\nSTUDENT ID: "<<temp->ID<<"\n\n\tSTUDENT NAME: "<<temp->StdName<<"\tROLL NO: "<<temp->RollNo <<"\tBOOKS ISSUED: "<<temp->BooksIssued <<endl<<endl; temp = temp->next; } } //Prints a student with a specific ID void PrintSome(int ID){ Node *temp = head; bool found = false; for(int i=0; i<totalStudents; i++){ if(temp->ID == ID){ found = true; cout<<"\n\n\nSTUDENT ID: "<<temp->ID<<"\n\n\tSTUDENT NAME: "<<temp->StdName<<"\tROLL NO: "<<temp->RollNo <<"\tBOOKS ISSUED: "<<temp->BooksIssued <<endl<<endl; return; } temp = temp->next; } if(found == false){ cout<<"\n\nSTUDENT ID NOT FOUND\n\n"; } return; } //Adds a student in the list void Add(int ID, char* StdName, int RollNo, int BooksIssued){ Node *temp; temp = new Node; bool found = false; Node *temp2; //check if the given ID is already present then it will ask the user to enter a different ID do{ found = false; temp2 = head; for(int i=0; i<totalStudents; i++){ if(temp2->ID == ID){ cout<<"\n\nSUDENT ID ALREADY EXISTS\tTRY DIFFERENT ID\n\n"; CERR(ID); found = true; break; } temp2 = temp2->next; } }while(found); temp->ID = ID; temp->StdName = StdName; temp->RollNo = RollNo; temp->BooksIssued = BooksIssued; temp->next = NULL; if(head==NULL){ head = temp; tail = temp; temp->prev = NULL; } else{ temp->prev = tail; tail->next = temp; tail = temp; } totalStudents++; cout<<"\n\nNew Student Added\n\n"; } //Overloaded Add function void Add(int StudentId=0){ Node *temp; temp = new Node; bool found = false; Node *temp2; //check if the given ID is already present then it will ask the user to enter a different ID if(StudentId==0){ do{ found = false; temp2 = head; cout<<"\n\n\nSTUDENT ID: "; CERR(temp->ID); for(int i=0; i<totalStudents; i++){ if(temp2->ID == temp->ID){ cout<<"\n\nSUDENT ID ALREADY EXISTS\tTRY DIFFERENT ID\n\n"; found = true; break; } temp2 = temp2->next; } }while(found); } else{ temp->ID = StudentId; } cout<<"\n\nSTUDENT NAME: "; CERR(temp->StdName); cout<<"\n\nROLL NO: "; CERR(temp->RollNo); do{ cout<<"\n\nBOOKS ISSUED: "; CERR(temp->BooksIssued); if(temp->BooksIssued>5){ cout<<"\n\nYou cannot issue more than 5 books at a time\n\n"; } }while(temp->BooksIssued>5); temp->next = NULL; //if the student to be added in the list is first then the node will become head as well as tail if(head==NULL){ head = temp; tail = temp; head->prev = NULL; } //if some students are already present in list else{ temp->prev = tail; tail->next = temp; tail = temp; } totalStudents++; cout<<"\n\nNew Student Added\n\n"; } //Simply deletes a student in the list void Delete(int ID){ Node *temp = head; int found = false; for(int i=0; i<totalStudents; i++){ if(temp->ID == ID){ found = true; //if only one student is present in the the list if(head == tail){ delete temp; head = NULL; tail = NULL; totalStudents = 0; return; } //if the node to be deleted is the tail else if(temp->next == temp){ tail = temp->prev; tail->next = temp->prev; } //if the node to be deleted is the head else if(temp->prev == NULL){ head = temp->next; head->prev = NULL; } // if the node is somewhere in between else{ Node* tempPrev = temp->prev; Node* tempNext = temp->next; tempPrev->next = tempNext; tempNext->prev = tempPrev; } totalStudents--; delete temp; cout<<"\n\nSUCCESSFULLY DELETED\n\n"; return; } temp = temp->next; } if(found == false){ cout<<"\n\nSTUDENT ID NOT FOUND\n\n"; } } int gettotalStudents(){ return totalStudents; } }; //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- class CStudentList{ struct Node{ CStudent std; int ListID; Node *next, *prev; //Constructor Node() : ListID(0), next(NULL), prev(NULL) {} //ALL GETTERS CStudent getstd(){ return std; } int getListID(){ return ListID; } //ALL SETTERS void setListID(int ListID){ Node::ListID = ListID; } }; Node *head, *tail; int totalLists; public: //constructor CStudentList() : head(NULL), tail(NULL), totalLists(0) {} //destructor which will simply free up the memory at the end ~CStudentList(){ Node *tmp; while(tail){ tmp = tail; tail = tail->prev; delete tmp; } } //it will print all the lists along with the students in those lists void PrintAll(){ Node* temp; temp = head; for(int i=0; i<totalLists; i++){ cout<<"\n\n\t\t***** LIST ID: "<<temp->ListID<<" *****"<<endl<<endl; temp->Node::std.PrintAll(); temp = temp->next; } } //Print a specific List along with the students in that list void PrintSome(int ListID){ Node* temp; temp = head; bool found = false; for(int i=0; i<totalLists; i++){ if(temp->ListID == ListID){ found = true; temp->Node::std.PrintAll(); return; } temp = temp->next; } if(found == false){ cout<<"\n\nLIST ID NOT FOUND\n\n"; } } //Adds a new List only not the students void AddList(int ListID){ Node* temp2 = head; bool found = false; do{ found = false; for(int i=0; i<totalLists; i++){ if(temp2->ListID == ListID){ found = true; cout<<"\n\nLIST ID ALREADY EXIST\tTRY ANOTHER ID: "; CERR(ListID); break; } temp2 = temp2->next; } }while(found); Node* temp; temp = new Node; temp->ListID = ListID; temp->next = NULL; if(head==NULL){ head = temp; tail = temp; head->prev = NULL; } else{ temp->prev = tail; tail->next = temp; tail = temp; } cout<<"\n\nNew List Added\n\n"; totalLists++; } //Adds new student in the list void AddNode(int ListID){ Node* temp; temp = head; bool found = false; //checks if the list ID is already present //if yes it will add a new student in that list //if not it will create a new list and then add the student while(found == false){ for(int i=0; i<totalLists; i++){ if(temp->ListID == ListID){ found = true; break; } temp = temp->next; } if(found == true){ temp->Node::std.Add(); return; } else{ cout<<"\n\nLIST ID NOT FOUND\n\n"; cout<<"\n\nADDING NEW LIST FOR YOU\n\n"; AddList(ListID); temp = head; } } return; } //deletes a complete list along with the students void Delete(int ListID){ Node *temp = head; bool found = false; for(int i=0; i<totalLists; i++){ if(temp->ListID == ListID){ found = true; if(head == tail){ delete temp; head = NULL; tail = NULL; totalLists = 0; return; } else if(temp->next == temp){ tail = temp->prev; tail->next = temp->prev; } else if(temp->prev == NULL){ head = temp->next; head->prev = NULL; } else{ Node* tempPrev = temp->prev; Node* tempNext = temp->next; tempPrev->next = tempNext; tempNext->prev = tempPrev; } totalLists--; cout<<"\n\nList Deleted Successfully\n\n"; delete temp; return; } temp = temp->next; } if(found == false){ cout<<"\n\nLIST ID NOT FOUND\n\n"; } } //deletes a student in the specific list void DeleteNode(int ListID, int StudentID){ Node *temp = head; bool found = false; for(int i=0; i<totalLists; i++){ if(temp->ListID == ListID){ found = true; temp->Node::std.Delete(StudentID); return; } temp = temp->next; } if(found == false){ cout<<"\n\nLIST ID NOT FOUND\n\n"; } } //deletes all the lists void DeleteAll(){ Node *tmp; while(tail){ tmp = tail; tail = tail->prev; delete tmp; } cout<<"\n\nDeleted Successfully\n\n"; totalLists = 0; } }; //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------- class CLibrary{ struct Node{ CBook books; CStudent std; Node* next, *prev; //constructor Node() : next(NULL), prev(NULL) {} }; Node* head, *tail; int total; public: //destructor CLibrary() : total(0), head(NULL), tail(NULL) {} //destructor ~CLibrary(){ Node *tmp; while(tail){ tmp = tail; tail = tail->prev; delete tmp; } } void Issue(int StudentID){ //if the student has already issued some books then it will add another book to the same student ID Node* temp; temp = head; int ID; int BooksIssued; int newBooksIssued; int oldBooksIssued; for(int i=0; i<total; i++){ ID = temp->Node::std.getStudentID(); if(StudentID == ID){ oldBooksIssued = temp->Node::std.getBooksIssued(); cout<<"\n\nENTER THE TOTAL BOOKS YOU WANT TO ISSUE: "; CERR(BooksIssued); cout<<"\n\nNOW ENTER ALL THE DATA ABOUT THE BOOKS YOU JUST ISSUED\n\n"; newBooksIssued = BooksIssued + oldBooksIssued; temp->Node::std.setBooksIssued(newBooksIssued); for(int j=0; j<BooksIssued; j++){ cout<<"\n\n\n\t\t\tBOOK #"<<j+1<<"\n"; temp->Node::books.Add(); } return; } temp = temp->next; } //If the student has issued a book for the first time then it will add a new Student to list and issue the //book temp = new Node; temp->Node::std.Add(StudentID); BooksIssued = temp->Node::std.getBooksIssued(); cout<<"\n\nNOW ENTER ALL THE DATA ABOUT THE BOOKS YOU JUST ISSUED\n\n"; for(int j=0; j<BooksIssued; j++){ cout<<"\n\n\n\t\t\tBOOK #"<<j+1<<"\n"; temp->Node::books.Add(); } temp->next = NULL; if(head==NULL){ head = temp; tail = temp; head->prev = NULL; } else{ temp->prev = tail; tail->next = temp; tail = temp; } total++; } //it will delete the specific book from the student record void Return(int StudentID){ Node* temp; temp = head; int SID, BID; for(int i=0; i<total; i++){ SID = temp->Node::std.getStudentID(); if(StudentID == SID){ temp->Node::books.PrintAll(); cout<<"\n\nEnter Book ID which you want to return: "; CERR(BID); temp->Node::books.Delete(BID); cout<<"\n\nBOOK RETURNED SUCCESSFULLY\n\n"; return; } temp = temp->next; } } // This Function is used to print all the books issued against a specific student void Print(int StudentID){ Node* temp; temp = head; int ID; for(int i=0; i<total; i++){ ID = temp->Node::std.getStudentID(); if(StudentID == ID){ temp->Node::std.PrintAll(); temp->Node::books.PrintAll(); return; } temp = temp->next; } } //Prints all the books which were issued by all the students void PrintIssued(){ Node* temp; temp = head; for(int i=0; i<total; i++){ temp->Node::books.PrintAll(); temp = temp->next; } } };
[ "noreply@github.com" ]
noreply@github.com
945cbddb9a46574f065b1fa4faf8f65d16931e3e
e780ac4efed690d0671c9e25df3e9732a32a14f5
/RaiderEngine/libs/assimp-5.2.3/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
1a4d11856a8f415d840594ad0d293a040cfa2ebe
[ "MIT", "BSD-3-Clause", "LGPL-2.0-or-later" ]
permissive
rystills/RaiderEngine
fbe943143b48f4de540843440bd4fcd2a858606a
3fe2dcdad6041e839e1bad3632ef4b5e592a47fb
refs/heads/master
2022-06-16T20:35:52.785407
2022-06-11T00:51:40
2022-06-11T00:51:40
184,037,276
6
0
MIT
2022-05-07T06:00:35
2019-04-29T09:05:20
C++
UTF-8
C++
false
false
16,112
cpp
/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- Copyright (c) 2006-2022, assimp team All rights reserved. Redistribution and use of this software in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the assimp team, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission of the assimp team. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------- */ /** @file FBXBinaryTokenizer.cpp * @brief Implementation of a fake lexer for binary fbx files - * we emit tokens so the parser needs almost no special handling * for binary files. */ #ifndef ASSIMP_BUILD_NO_FBX_IMPORTER #include "FBXTokenizer.h" #include "FBXUtil.h" #include <assimp/defs.h> #include <stdint.h> #include <assimp/Exceptional.h> #include <assimp/ByteSwapper.h> #include <assimp/DefaultLogger.hpp> #include <assimp/StringUtils.h> namespace Assimp { namespace FBX { //enum Flag //{ // e_unknown_0 = 1 << 0, // e_unknown_1 = 1 << 1, // e_unknown_2 = 1 << 2, // e_unknown_3 = 1 << 3, // e_unknown_4 = 1 << 4, // e_unknown_5 = 1 << 5, // e_unknown_6 = 1 << 6, // e_unknown_7 = 1 << 7, // e_unknown_8 = 1 << 8, // e_unknown_9 = 1 << 9, // e_unknown_10 = 1 << 10, // e_unknown_11 = 1 << 11, // e_unknown_12 = 1 << 12, // e_unknown_13 = 1 << 13, // e_unknown_14 = 1 << 14, // e_unknown_15 = 1 << 15, // e_unknown_16 = 1 << 16, // e_unknown_17 = 1 << 17, // e_unknown_18 = 1 << 18, // e_unknown_19 = 1 << 19, // e_unknown_20 = 1 << 20, // e_unknown_21 = 1 << 21, // e_unknown_22 = 1 << 22, // e_unknown_23 = 1 << 23, // e_flag_field_size_64_bit = 1 << 24, // Not sure what is // e_unknown_25 = 1 << 25, // e_unknown_26 = 1 << 26, // e_unknown_27 = 1 << 27, // e_unknown_28 = 1 << 28, // e_unknown_29 = 1 << 29, // e_unknown_30 = 1 << 30, // e_unknown_31 = 1 << 31 //}; // //bool check_flag(uint32_t flags, Flag to_check) //{ // return (flags & to_check) != 0; //} // ------------------------------------------------------------------------------------------------ Token::Token(const char* sbegin, const char* send, TokenType type, size_t offset) : #ifdef DEBUG contents(sbegin, static_cast<size_t>(send-sbegin)), #endif sbegin(sbegin) , send(send) , type(type) , line(offset) , column(BINARY_MARKER) { ai_assert(sbegin); ai_assert(send); // binary tokens may have zero length because they are sometimes dummies // inserted by TokenizeBinary() ai_assert(send >= sbegin); } namespace { // ------------------------------------------------------------------------------------------------ // signal tokenization error, this is always unrecoverable. Throws DeadlyImportError. AI_WONT_RETURN void TokenizeError(const std::string& message, size_t offset) AI_WONT_RETURN_SUFFIX; AI_WONT_RETURN void TokenizeError(const std::string& message, size_t offset) { throw DeadlyImportError("FBX-Tokenize", Util::GetOffsetText(offset), message); } // ------------------------------------------------------------------------------------------------ size_t Offset(const char* begin, const char* cursor) { ai_assert(begin <= cursor); return cursor - begin; } // ------------------------------------------------------------------------------------------------ void TokenizeError(const std::string& message, const char* begin, const char* cursor) { TokenizeError(message, Offset(begin, cursor)); } // ------------------------------------------------------------------------------------------------ uint32_t ReadWord(const char* input, const char*& cursor, const char* end) { const size_t k_to_read = sizeof( uint32_t ); if(Offset(cursor, end) < k_to_read ) { TokenizeError("cannot ReadWord, out of bounds",input, cursor); } uint32_t word; ::memcpy(&word, cursor, 4); AI_SWAP4(word); cursor += k_to_read; return word; } // ------------------------------------------------------------------------------------------------ uint64_t ReadDoubleWord(const char* input, const char*& cursor, const char* end) { const size_t k_to_read = sizeof(uint64_t); if(Offset(cursor, end) < k_to_read) { TokenizeError("cannot ReadDoubleWord, out of bounds",input, cursor); } uint64_t dword /*= *reinterpret_cast<const uint64_t*>(cursor)*/; ::memcpy( &dword, cursor, sizeof( uint64_t ) ); AI_SWAP8(dword); cursor += k_to_read; return dword; } // ------------------------------------------------------------------------------------------------ uint8_t ReadByte(const char* input, const char*& cursor, const char* end) { if(Offset(cursor, end) < sizeof( uint8_t ) ) { TokenizeError("cannot ReadByte, out of bounds",input, cursor); } uint8_t word;/* = *reinterpret_cast< const uint8_t* >( cursor )*/ ::memcpy( &word, cursor, sizeof( uint8_t ) ); ++cursor; return word; } // ------------------------------------------------------------------------------------------------ unsigned int ReadString(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end, bool long_length = false, bool allow_null = false) { const uint32_t len_len = long_length ? 4 : 1; if(Offset(cursor, end) < len_len) { TokenizeError("cannot ReadString, out of bounds reading length",input, cursor); } const uint32_t length = long_length ? ReadWord(input, cursor, end) : ReadByte(input, cursor, end); if (Offset(cursor, end) < length) { TokenizeError("cannot ReadString, length is out of bounds",input, cursor); } sbegin_out = cursor; cursor += length; send_out = cursor; if(!allow_null) { for (unsigned int i = 0; i < length; ++i) { if(sbegin_out[i] == '\0') { TokenizeError("failed ReadString, unexpected NUL character in string",input, cursor); } } } return length; } // ------------------------------------------------------------------------------------------------ void ReadData(const char*& sbegin_out, const char*& send_out, const char* input, const char*& cursor, const char* end) { if(Offset(cursor, end) < 1) { TokenizeError("cannot ReadData, out of bounds reading length",input, cursor); } const char type = *cursor; sbegin_out = cursor++; switch(type) { // 16 bit int case 'Y': cursor += 2; break; // 1 bit bool flag (yes/no) case 'C': cursor += 1; break; // 32 bit int case 'I': // <- fall through // float case 'F': cursor += 4; break; // double case 'D': cursor += 8; break; // 64 bit int case 'L': cursor += 8; break; // note: do not write cursor += ReadWord(...cursor) as this would be UB // raw binary data case 'R': { const uint32_t length = ReadWord(input, cursor, end); cursor += length; break; } case 'b': // TODO: what is the 'b' type code? Right now we just skip over it / // take the full range we could get cursor = end; break; // array of * case 'f': case 'd': case 'l': case 'i': case 'c': { const uint32_t length = ReadWord(input, cursor, end); const uint32_t encoding = ReadWord(input, cursor, end); const uint32_t comp_len = ReadWord(input, cursor, end); // compute length based on type and check against the stored value if(encoding == 0) { uint32_t stride = 0; switch(type) { case 'f': case 'i': stride = 4; break; case 'd': case 'l': stride = 8; break; case 'c': stride = 1; break; default: ai_assert(false); }; ai_assert(stride > 0); if(length * stride != comp_len) { TokenizeError("cannot ReadData, calculated data stride differs from what the file claims",input, cursor); } } // zip/deflate algorithm (encoding==1)? take given length. anything else? die else if (encoding != 1) { TokenizeError("cannot ReadData, unknown encoding",input, cursor); } cursor += comp_len; break; } // string case 'S': { const char* sb, *se; // 0 characters can legally happen in such strings ReadString(sb, se, input, cursor, end, true, true); break; } default: TokenizeError("cannot ReadData, unexpected type code: " + std::string(&type, 1),input, cursor); } if(cursor > end) { TokenizeError("cannot ReadData, the remaining size is too small for the data type: " + std::string(&type, 1),input, cursor); } // the type code is contained in the returned range send_out = cursor; } // ------------------------------------------------------------------------------------------------ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor, const char* end, bool const is64bits) { // the first word contains the offset at which this block ends const uint64_t end_offset = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end); // we may get 0 if reading reached the end of the file - // fbx files have a mysterious extra footer which I don't know // how to extract any information from, but at least it always // starts with a 0. if(!end_offset) { return false; } if(end_offset > Offset(input, end)) { TokenizeError("block offset is out of range",input, cursor); } else if(end_offset < Offset(input, cursor)) { TokenizeError("block offset is negative out of range",input, cursor); } // the second data word contains the number of properties in the scope const uint64_t prop_count = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end); // the third data word contains the length of the property list const uint64_t prop_length = is64bits ? ReadDoubleWord(input, cursor, end) : ReadWord(input, cursor, end); // now comes the name of the scope/key const char* sbeg, *send; ReadString(sbeg, send, input, cursor, end); output_tokens.push_back(new_Token(sbeg, send, TokenType_KEY, Offset(input, cursor) )); // now come the individual properties const char* begin_cursor = cursor; if ((begin_cursor + prop_length) > end) { TokenizeError("property length out of bounds reading length ", input, cursor); } for (unsigned int i = 0; i < prop_count; ++i) { ReadData(sbeg, send, input, cursor, begin_cursor + prop_length); output_tokens.push_back(new_Token(sbeg, send, TokenType_DATA, Offset(input, cursor) )); if(i != prop_count-1) { output_tokens.push_back(new_Token(cursor, cursor + 1, TokenType_COMMA, Offset(input, cursor) )); } } if (Offset(begin_cursor, cursor) != prop_length) { TokenizeError("property length not reached, something is wrong",input, cursor); } // at the end of each nested block, there is a NUL record to indicate // that the sub-scope exists (i.e. to distinguish between P: and P : {}) // this NUL record is 13 bytes long on 32 bit version and 25 bytes long on 64 bit. const size_t sentinel_block_length = is64bits ? (sizeof(uint64_t)* 3 + 1) : (sizeof(uint32_t)* 3 + 1); if (Offset(input, cursor) < end_offset) { if (end_offset - Offset(input, cursor) < sentinel_block_length) { TokenizeError("insufficient padding bytes at block end",input, cursor); } output_tokens.push_back(new_Token(cursor, cursor + 1, TokenType_OPEN_BRACKET, Offset(input, cursor) )); // XXX this is vulnerable to stack overflowing .. while(Offset(input, cursor) < end_offset - sentinel_block_length) { ReadScope(output_tokens, input, cursor, input + end_offset - sentinel_block_length, is64bits); } output_tokens.push_back(new_Token(cursor, cursor + 1, TokenType_CLOSE_BRACKET, Offset(input, cursor) )); for (unsigned int i = 0; i < sentinel_block_length; ++i) { if(cursor[i] != '\0') { TokenizeError("failed to read nested block sentinel, expected all bytes to be 0",input, cursor); } } cursor += sentinel_block_length; } if (Offset(input, cursor) != end_offset) { TokenizeError("scope length not reached, something is wrong",input, cursor); } return true; } } // anonymous namespace // ------------------------------------------------------------------------------------------------ // TODO: Test FBX Binary files newer than the 7500 version to check if the 64 bits address behaviour is consistent void TokenizeBinary(TokenList& output_tokens, const char* input, size_t length) { ai_assert(input); ASSIMP_LOG_DEBUG("Tokenizing binary FBX file"); if(length < 0x1b) { TokenizeError("file is too short",0); } //uint32_t offset = 0x15; /* const char* cursor = input + 0x15; const uint32_t flags = ReadWord(input, cursor, input + length); const uint8_t padding_0 = ReadByte(input, cursor, input + length); // unused const uint8_t padding_1 = ReadByte(input, cursor, input + length); // unused*/ if (strncmp(input,"Kaydara FBX Binary",18)) { TokenizeError("magic bytes not found",0); } const char* cursor = input + 18; /*Result ignored*/ ReadByte(input, cursor, input + length); /*Result ignored*/ ReadByte(input, cursor, input + length); /*Result ignored*/ ReadByte(input, cursor, input + length); /*Result ignored*/ ReadByte(input, cursor, input + length); /*Result ignored*/ ReadByte(input, cursor, input + length); const uint32_t version = ReadWord(input, cursor, input + length); ASSIMP_LOG_DEBUG("FBX version: ", version); const bool is64bits = version >= 7500; const char *end = input + length; try { while (cursor < end ) { if (!ReadScope(output_tokens, input, cursor, input + length, is64bits)) { break; } } } catch (const DeadlyImportError& e) { if (!is64bits && (length > std::numeric_limits<std::uint32_t>::max())) { throw DeadlyImportError("The FBX file is invalid. This may be because the content is too big for this older version (", ai_to_string(version), ") of the FBX format. (", e.what(), ")"); } throw; } } } // !FBX } // !Assimp #endif
[ "rystills@gmail.com" ]
rystills@gmail.com
96508bb87be8774e35d679995b9ca939a32057a6
6f5379f9dc222a2b409cdf54ac62617e988e7754
/TCP/Draft/Connet_heartbeat/Custom/Custom/customtcpserver.h
223b4f70d2a23cd2f110658fab93dcbddddb5489
[]
no_license
ToSaySomething/Leaning
b581379b9bf572682bd45ac11c5a315552cea51f
523e040f16a6de3d4bf2e5de8a1e65fd1a7ff4e8
refs/heads/master
2020-03-28T11:57:04.180983
2018-09-12T02:50:27
2018-09-12T02:50:27
148,258,479
2
1
null
null
null
null
UTF-8
C++
false
false
622
h
#ifndef CUSTOMTCPSERVER_H #define CUSTOMTCPSERVER_H #include "mythread.h" #include "Poco/Util/ServerApplication.h" #include "Poco/Util/Application.h" #include "Poco/Net/ServerSocket.h" #include "Poco/Net/TCPServer.h" #include "Poco/Timestamp.h" using Poco::Util::ServerApplication; using Poco::Util::Application; class CustomTCPServer : public ServerApplication { public: CustomTCPServer() {} ~CustomTCPServer() {} protected: void initialize(Application& self); void uninitialize(); int main(const std::vector<std::string>& args); ThreadRunnable runnable[1024]; }; #endif // CUSTOMTCPSERVER_H
[ "dengyuting@cloudwalk.cn" ]
dengyuting@cloudwalk.cn
f1bd41ce28809ae51093220c83dd4dcc4351267f
44263cffb017c805a842a687be172dd79f014988
/Source/TestGame/HitBox/GateDoor.h
2bfa0e1e7bbb466706211e4667856c84f0ec0c6d
[]
no_license
XGD1119363048/TestGame
73131a14d6519d0469f4e0f14914b1bc9b3f4cdc
3274575ac5f9d3c97572ffd9e3d5fdc26bb3bcf6
refs/heads/master
2022-09-07T20:13:11.848762
2020-06-02T16:38:56
2020-06-02T16:38:56
267,587,717
1
0
null
null
null
null
UTF-8
C++
false
false
564
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "HitBoxBase.h" #include "GateDoor.generated.h" /** * */ UCLASS() class TESTGAME_API AGateDoor : public AHitBoxBase { GENERATED_BODY() public: AGateDoor(); public: UPROPERTY(EditAnywhere, BlueprintReadWrite) class UStaticMeshComponent* DoorComp; UPROPERTY(EditAnywhere, BlueprintReadWrite) class UParticleSystemComponent* ParticleComp; public: virtual void OnHitSphere(class ASpherePawnBase* SpherePawn) override; };
[ "1119363048@qq.com" ]
1119363048@qq.com
da331662baccf9a5899b7c9f6a04ce48c4fc65fa
ac0b710bc456ac30b23276da953299fc8769e829
/cpp17/searchers/simpleperf.h
6dd26d8c1a7a8b87e741ff512a56c7038ff425f6
[]
no_license
fenbf/articles
68ca7031c5efb6681bd5e00fd39280dd9e813f12
41e5f1f9760a9f13ee521283b2d5ce0da336295e
refs/heads/master
2023-07-21T06:37:11.509960
2023-07-13T13:31:47
2023-07-13T13:31:47
8,863,369
50
29
null
2019-04-24T13:54:05
2013-03-18T20:23:38
C++
UTF-8
C++
false
false
1,090
h
#pragma once #include <iostream> // from https://stackoverflow.com/questions/33975479/escape-and-clobber-equivalent-in-msvc /** * Call doNotOptimizeAway(var) against variables that you use for * benchmarking but otherwise are useless. The compiler tends to do a * good job at eliminating unused variables, and this function fools * it into thinking var is in fact needed. */ #ifdef _MSC_VER #pragma optimize("", off) template <class T> void DoNotOptimizeAway(T&& datum) { datum = datum; } #pragma optimize("", on) #elif defined(__clang__) template <class T> __attribute__((__optnone__)) void DoNotOptimizeAway(T&& /* datum */) {} #else template <class T> void DoNotOptimizeAway(T&& datum) { asm volatile("" : "+r" (datum)); } #endif template <typename TFunc> void RunAndMeasure(const char* title, TFunc func) { const auto start = std::chrono::steady_clock::now(); auto ret = func(); const auto end = std::chrono::steady_clock::now(); DoNotOptimizeAway(ret); std::cout << title << ": " << std::chrono::duration <double, std::milli>(end - start).count() << " ms\n"; }
[ "joebaf@gmail.com" ]
joebaf@gmail.com
f464db38182893de3e7a09f78752217680d4bf40
16943a756d8ea51133084b87b28ec83d57201c57
/msnet/src/SrvTcpBusiness.cpp
f7f32a143097cfcba70678c14f4c0620ed1c47b1
[]
no_license
chengls/examples-make
cf10c0bb71ff8f842ac4837796089ab5b8f9f1f5
554d3323df9f9a5a41b79a2d6ce735da3ee59a81
refs/heads/master
2021-04-14T06:06:25.705564
2020-02-28T10:49:36
2020-02-28T10:49:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,002
cpp
#include "SrvTcpBusiness.h" #include "3rd/x2struct-1.1/x2struct.hpp" ho::MsgHeader_t new_response(unsigned short codeId, int len) { ho::MsgHeader_t pMsg; pMsg.ucFlag = ho::MsgFlag; pMsg.ucVersion = ho::MsgVersion; pMsg.usCodeID = codeId; pMsg.unPayloadLen = len; return pMsg; } struct RegisterMediaLink { std::string ss; std::string dn; std::string at; std::string mt; std::string ch; std::string of; std::string ft; XTOSTRUCT(O(ss, dn, at, mt, ch, of, ft)); }; struct ResponseMediaLink { std::string ss; int err; int of; XTOSTRUCT(O(ss, err, of)); }; std::string resolve_register_medialink(const char* data, int len, std::string& ss) { std::string repStr(data, len); RegisterMediaLink req; if (!x2struct::X::loadjson(repStr, req, false)) { return NULL; } ss = req.ss; ResponseMediaLink resp; resp.ss = req.ss; resp.err = 0; return x2struct::X::tojson(resp); }
[ "wanguandong@gmail.com" ]
wanguandong@gmail.com
8cf7de9be300eefb4194cf3870b27983b81c9f09
26c3dc4de48bfc67904a3be440119e825f008596
/NodeMCU_Temperature_Sensor_MQTT/NodeMCU_Temperature_Sensor_MQTT.ino
465faf76cdf28ef66e73c2c583643cb23ea6f239
[]
no_license
joshinmansi/EE629_Project_Environment_Sensing
5f543a556f536291284d8fe9ead5ed69a7ffb56d
9421a6781fb15d4b86a3d80c82bb182d1c9a2e35
refs/heads/master
2022-06-13T06:01:45.686964
2020-05-04T19:11:32
2020-05-04T19:11:32
261,272,148
0
0
null
2020-05-04T19:06:02
2020-05-04T19:06:02
null
UTF-8
C++
false
false
8,413
ino
/* Author: Sanket Jain * Project: Environment Sensing and Monitoring * * * */ /*__________________________________________________________________________________________________________________________________________________________________________________________*/ #include <ESP8266WiFi.h> //ESP8266 WiFi Library DECLARATIONS #include <PubSubClient.h> //MQTT Library (Download in Library Manager) #include <DHT.h> //DHT 11 Sensor Library #define DHTPIN 4 //DHT Sensor Data Input Pin const int ledPin = 16; //LED Pin for NodeMCU const char* ssid = "YOUR_WIFI_SSID"; //Your Wi-Fi SSID const char* wifi_password = "YOUR_WIFI_PASSWORD"; //Your WiFi password const char* mqtt_server = "MQTT_SERVER_ADDRESS"; //Address of your RaspberryPi (MQTT Server), if not Pi then whatever device you're using const char* mqtt_topic = "SUB_TOPIC_NAME"; //Subscribing Topic const char* mqttp_topic = "PUB_TOPIC_NAME"; //Publishing Topic const char* mqtt_username = "YOUR_MQTT_USERNAME"; //Username of MQTT service const char* mqtt_password = "YOUR_MQTT_PASSWORD"; //Password of MQTT service const char* clientID = "NODE_NAME"; //Name of your Node DHT dht(DHTPIN, DHT11); //Create DHT class object WiFiClient wifiClient; //Create Wifi Class object PubSubClient client(mqtt_server, 1883, wifiClient); //Create MQTT class object /*__________________________________________________________________________________________________________________________________________________________________________________________*/ void ReceivedMessage(char* topic, byte* payload, unsigned int length) { //Callback function CALLBACK FUNCTION String msg; char* mesg; for(int i = 0; i<length; i++){ Serial.print(char(payload[i])); //Convert single byte to character and print msg += (char)payload[i]; //Add character to string } Serial.println(); //Print new line if(msg=="Initialize"){ ledBlink(5); } if(msg=="On"){ //Trigger message condition loop //NOTE: In our project, all group members had one Pi and one Node only. //If you're using one server and multiple nodes, you can change the trigger message //(coming from the server) for different nodes. float h = dht.readHumidity(); //Read humidity from sensor float t = dht.readTemperature(); //Read temperature from sensor in Celsius float f = dht.readTemperature(true); //Read temperature from sensor in Fahrenheit (isFahrenheit = true) Serial.println(t); //Print celsius temperature value if (isnan(h) || isnan(t) || isnan(f)) { //if garbage values Serial.println(F("Failed to read from DHT sensor!")); client.publish(mqttp_topic, "Sensor Failure"); //send Sensor Failure message to the server ledBlink(1); delay(3700); } client.publish(mqttp_topic, (String(t)+':'+String(h)).c_str()); //sending sensor data to the server after formatting ledBlink(1); delay(3700); } else if(msg=="Off"){ //if server code is off //NOTE: This is more of a broadcast message here. If you want to shut down particular //nodes, you can make different Off trigger messages also for different nodes. } } /*__________________________________________________________________________________________________________________________________________________________________________________________*/ bool Connect() { //funcntion to connect to MQTT server CONNECT FUNCTION if (client.connect(clientID, mqtt_username, mqtt_password)) { //MQTT class object function to check if connected to server or not client.subscribe(mqtt_topic); //subscribe to a topic if connected return true; } else { return false; } } /*__________________________________________________________________________________________________________________________________________________________________________________________*/ void setup() { // SETUP FUNCTION pinMode(ledPin, OUTPUT); digitalWrite(ledPin, HIGH); Serial.begin(115200); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, wifi_password); //Wifi Class object method, to connect to WiFi network while (WiFi.status() != WL_CONNECTED) { //Wait until the connection has been confirmed before continuing delay(500); Serial.print("."); } Serial.println("WiFi connected"); client.setCallback(ReceivedMessage); //Pass the callback function as parameter to this method, this is to call that function whenever message is received if (client.connect(clientID, mqtt_username, mqtt_password)) { //Connect to MQTT Broker Serial.println("Connected to MQTT Broker!"); client.subscribe(mqtt_topic); //Subscribe to MQTT topic ledBlink(3); } else { Serial.println("Connection to MQTT Broker failed..."); } dht.begin(); //Initialise DHT data reading } /*__________________________________________________________________________________________________________________________________________________________________________________________*/ void loop() { // MAIN LOOP if (!client.connected()) { //If client is not connected, connect again Connect(); } client.loop(); //Class method to keep looking for messages } /*__________________________________________________________________________________________________________________________________________________________________________________________*/ void ledBlink(int count){ //Function to blink LED light LED BLINK FUNCTION for(int i=0; i<count; i++){ digitalWrite(ledPin, LOW); delay(300); digitalWrite(ledPin, HIGH); delay(300); } }
[ "djsj37@gmail.com" ]
djsj37@gmail.com
fd70f4fe9e6e14a572f02998a116aca4725f0ffc
99a3758ce6396dce2a167256c7f73c03bc239eae
/Code Examples And Proteus Files/Atmel(arduino) 433MHz/ask_transmitter/ask_transmitter.ino
fe9144fc24150ec7f33fe5feecd54f3ba8adb6db
[ "MIT" ]
permissive
mesutsaygioglu/techmeetings-w1-rf-modules
3d3e70a754a253c67e1132dbf0f95f4d42140b54
1384cac1d8f09b18a5b7b3bcd25eef55ef2b7d52
refs/heads/main
2023-02-02T17:22:53.965993
2020-12-20T18:30:21
2020-12-20T18:30:21
323,057,028
0
1
null
null
null
null
UTF-8
C++
false
false
329
ino
#include <RH_ASK.h> RH_ASK driver(3000,3,4);// speed,rx,tx void setup() { Serial.begin(9600); // Debugging only if (!driver.init()) Serial.println("init failed"); } void loop() { const char *msg = "hello"; driver.send((uint8_t *)msg, strlen(msg)); driver.waitPacketSent(); delay(1000); }
[ "mesut_saygioglu_@hotmail.com" ]
mesut_saygioglu_@hotmail.com
0d64b75453f8a6db56da3bc3a970c0e961fa44b9
b338beeb2765284c006e333d6549260d18bc1d80
/src/graphic/context.h
a322a00ae61aa0b37453b027bcb10d3f83b3d3fd
[ "MIT" ]
permissive
Lexikus/lx
f4819f4cf2b85e195e3973f85670b3f1bb7632a7
3a9b51e08f1b20201c3930d04c912f4054181fd8
refs/heads/master
2023-08-22T05:17:06.807768
2021-09-24T09:42:10
2021-09-24T09:42:10
192,376,374
0
0
null
null
null
null
UTF-8
C++
false
false
64
h
#pragma once class Context { public: bool init() const; };
[ "alexander.bifulco@gmail.com" ]
alexander.bifulco@gmail.com
20cd6622aa575a2f25a7540475ef8e92b3144331
fa36e2d3797d4ea8cd6db61c8825ad97799a9074
/Source/PluginProcessor.h
9799d5cf890951eda06564ebdde24b611aedfd52
[]
no_license
Luke-kb/AlgoReverb
7ca6aa1bd60c7026485143082573120acbb90b5e
6a07b5256f9f375481fb1502120771ca34a2a3a6
refs/heads/master
2023-03-15T09:14:05.848978
2020-03-10T17:41:48
2020-03-10T17:41:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,292
h
/* ============================================================================== This file was auto-generated! It contains the basic framework code for a JUCE plugin processor. ============================================================================== */ #pragma once #include <JuceHeader.h> //============================================================================== /** */ class AlgoReverbAudioProcessor : public AudioProcessor { public: //============================================================================== AlgoReverbAudioProcessor(); ~AlgoReverbAudioProcessor(); //============================================================================== void prepareToPlay (double sampleRate, int samplesPerBlock) override; void releaseResources() override; #ifndef JucePlugin_PreferredChannelConfigurations bool isBusesLayoutSupported (const BusesLayout& layouts) const override; #endif void processBlock (AudioBuffer<float>&, MidiBuffer&) override; //============================================================================== AudioProcessorEditor* createEditor() override; bool hasEditor() const override; //============================================================================== const String getName() const override; bool acceptsMidi() const override; bool producesMidi() const override; bool isMidiEffect() const override; double getTailLengthSeconds() const override; //============================================================================== int getNumPrograms() override; int getCurrentProgram() override; void setCurrentProgram (int index) override; const String getProgramName (int index) override; void changeProgramName (int index, const String& newName) override; //============================================================================== void getStateInformation (MemoryBlock& destData) override; void setStateInformation (const void* data, int sizeInBytes) override; private: //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AlgoReverbAudioProcessor) };
[ "hackaudio@gmail.com" ]
hackaudio@gmail.com
1eb21ee38a6d7b1bdefdf2902f647d549bbba22c
6c471cc9944ab1375d602dbe1cf59936a58b2c90
/trapezoid.cpp
395503302a2b5ec3fa35b7083af0893a69ca668c
[]
no_license
Anton-Boldyrev/oop_exercise_08
1cf19b966e3aa3282df5dd864fd8be4833b14125
fbc8669c03a6e06b098c00439b775503a5b4113f
refs/heads/master
2021-07-06T16:53:46.054787
2021-04-11T16:32:59
2021-04-11T16:32:59
233,116,419
0
0
null
null
null
null
UTF-8
C++
false
false
2,065
cpp
#include "trapezoid.h" TTrapezoid::TTrapezoid (const TPoint p1, const TPoint p2, const TPoint p3, const TPoint p4) { a = p1; b = p2; c = p3; d = p4; TPoint ab, ad, bc, dc; ab.x = b.x - a.x; ab.y = b.y - a.y; ad.x = d.x - a.x; ad.y = d.y - a.y; bc.x = c.x - b.x; bc.y = c.y - b.y; dc.x = c.x - d.x; dc.y = c.y - d.y; if (acos((ab.x * dc.x + ab.y * dc.y) / (sqrt(ab.x * ab.x + ab.y * ab.y) * sqrt(dc.x * dc.x + dc.y * dc.y))) != 0 && acos((ad.x * bc.x + ad.y * bc.y) / (sqrt(ad.x * ad.x + ad.y * ad.y) * sqrt(bc.x * bc.x + bc.y * bc.y))) != 0) { throw std::logic_error("it's not trapezoid\n"); } //assert(acos((ab.x * dc.x + ab.y * dc.y) / (sqrt(ab.x * ab.x + ab.y * ab.y) * sqrt(dc.x * dc.x + dc.y * dc.y))) == 0 || acos((ad.x * bc.x + ad.y * bc.y) / (sqrt(ad.x * ad.x + ad.y * ad.y) * sqrt(bc.x * bc.x + bc.y * bc.y))) == 0); } TTrapezoid::TTrapezoid(std::istream& is) { is >> a >> b >> c >> d; TPoint ab, ad, bc, dc; ab.x = b.x - a.x; ab.y = b.y - a.y; ad.x = d.x - a.x; ad.y = d.y - a.y; bc.x = c.x - b.x; bc.y = c.y - b.y; dc.x = c.x - d.x; dc.y = c.y - d.y; if (acos((ab.x * dc.x + ab.y * dc.y) / (sqrt(ab.x * ab.x + ab.y * ab.y) * sqrt(dc.x * dc.x + dc.y * dc.y))) != 0 && acos((ad.x * bc.x + ad.y * bc.y) / (sqrt(ad.x * ad.x + ad.y * ad.y) * sqrt(bc.x * bc.x + bc.y * bc.y))) != 0) { throw std::logic_error("it's not trapezoid\n"); } } TPoint TTrapezoid::Center() const { TPoint p; double x = (a.x + b.x + c.x + d.x) /4; double y = (a.y + b.y + c.y + d.y) /4; p.x = x; p.y = y; return p; } double TTrapezoid::Square() const { TPoint p = this->Center(); double t1 = 0.5 * fabs((b.x - a.x) * (p.y - a.y) - (p.x - a.x) * (b.y - a.y)); double t2 = 0.5 * fabs((c.x - b.x) * (p.y - b.y) - (p.x - b.x) * (c.y - b.y)); double t3 = 0.5 * fabs((d.x - c.x) * (p.y - c.y) - (p.x - c.x) * (d.y - c.y)); double t4 = 0.5 * fabs((a.x - d.x) * (p.y - d.y) - (p.x - d.x) * (a.y - d.y)); return t1 + t2 + t3 + t4; } void TTrapezoid::Print(std::ostream& os) const { os << a << " " << b << " " << c << " " << d << "\n"; }
[ "noreply@github.com" ]
noreply@github.com
786205e806bb52d67f44ffb1d1b4ef14589ed884
7c5c667d10f01f6cd0e87e6af53a720bd2502bc7
/src/codeforces/2014.3.30/C1.cpp
20285fd471caf3b01b9748510cf344f57871e51d
[]
no_license
xyiyy/icpc
3306c163a4fdefb190518435c09929194b3aeebc
852c53860759772faa052c32f329149f06078e77
refs/heads/master
2020-04-12T06:15:50.747975
2016-10-25T12:16:57
2016-10-25T12:16:57
40,187,486
5
0
null
null
null
null
UTF-8
C++
false
false
923
cpp
#include <iostream> #include <sstream> #include <ios> #include <iomanip> #include <functional> #include <algorithm> #include <vector> #include <string> #include <list> #include <queue> #include <deque> #include <stack> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cmath> #include <cstring> #include <climits> using namespace std; #define XINF INT_MAX #define INF 0x3FFFFFFF #define MP(X, Y) make_pair(X,Y) #define PB(X) push_back(X) #define REP(X, N) for(int X=0;X<N;X++) typedef pair<int, int> PII; typedef vector<int> VI; typedef long long ll; int main() { ios::sync_with_stdio(false); freopen("fuck.out", "w", stdout); for (int i = 1; i <= 1500; i++) { for (int j = 1; j <= 1500; j++) { for (int k = j; k <= 1500; k++) { if (i * i == j * j + k * k) cout << i << ','; } } } return 0; }
[ "fraudxyiyy@gmail.com" ]
fraudxyiyy@gmail.com
7e320b75185e18f3aeade516df056126d1d89b07
91ba0c0c42b3fcdbc2a7778e4a4684ab1942714b
/Cpp/SDK/BP_wpn_cutlass_brg_01_a_ItemDesc_classes.h
2e4e198e99c2d24fda3dce398768e5f47b5a177c
[]
no_license
zH4x/SoT-SDK-2.1.1
0f8c1ec3ad8821de82df3f75a0356642b581b8c6
35144dfc629aeddf96c1741e9e27e5113a2b1bb3
refs/heads/main
2023-05-12T09:03:32.050860
2021-06-05T01:54:15
2021-06-05T01:54:15
373,997,263
0
0
null
null
null
null
UTF-8
C++
false
false
795
h
#pragma once // Name: SoT, Version: 2.1.1 /*!!DEFINE!!*/ /*!!HELPER_DEF!!*/ /*!!HELPER_INC!!*/ #ifdef _MSC_VER #pragma pack(push, 0x01) #endif namespace CG { //--------------------------------------------------------------------------- // Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_wpn_cutlass_brg_01_a_ItemDesc.BP_wpn_cutlass_brg_01_a_ItemDesc_C // 0x0000 (FullSize[0x0130] - InheritedSize[0x0130]) class UBP_wpn_cutlass_brg_01_a_ItemDesc_C : public UItemDesc { public: static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_wpn_cutlass_brg_01_a_ItemDesc.BP_wpn_cutlass_brg_01_a_ItemDesc_C"); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "Massimo.linker@gmail.com" ]
Massimo.linker@gmail.com
13569b416aa9312ee632fa95a84aa0f9351f1d64
060591cee2eca06aaef4e05dd8476d3692160d54
/src/xrEngine/xrGame/ai/monsters/bloodsucker/bloodsucker_state_manager.h
55c267dea8c45a0c5ce499f61b38e61d3a8d597c
[ "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
Georgiy-Timoshin/X-Ray
7c96c494803edbe4c9e03d4e3b8ebb46c02ff35e
51dc8ddcfdde3167f3a025022d8420a94c5c1c43
refs/heads/main
2023-04-29T18:35:06.229863
2021-05-14T02:13:00
2021-05-14T02:13:00
367,538,251
0
2
NOASSERTION
2021-05-15T04:48:44
2021-05-15T04:23:35
null
UTF-8
C++
false
false
316
h
#pragma once #include "../monster_state_manager.h" class CAI_Bloodsucker; class CStateManagerBloodsucker : public CMonsterStateManager<CAI_Bloodsucker> { typedef CMonsterStateManager<CAI_Bloodsucker> inherited; public: CStateManagerBloodsucker (CAI_Bloodsucker *monster); virtual void execute (); };
[ "53347567+xrModder@users.noreply.github.com" ]
53347567+xrModder@users.noreply.github.com
3f409035019ebac169455d686c6b23681a0b889d
55996cef8a153f074c76a4a61e451c4e065568c5
/算法提高/算法提高 和最大子序列/未命名1.cpp
fa9f8eccd1872f3ab1e3165ab4ab6c20af3b93bc
[]
no_license
SterbenDa/LanQiao-Linda
3f187a95188c9e09e06e7f99056b68ad48dae670
bc30a73b3a955403449f0a044ee2d1f92234d437
refs/heads/master
2020-09-01T06:01:51.572160
2019-11-01T02:54:28
2019-11-01T02:54:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
363
cpp
#include <iostream> #include <cstdio> #include <string.h> #include <math.h> using namespace std; const int N=100000+10; int dp[N]; int re; int main() { int i,n; while(cin>>n){ dp[0]=0; re=-99999999; for(i=1;i<=n;i++){ cin>>dp[i]; dp[i]=max(dp[i-1]+dp[i],dp[i]); if(re<dp[i]) re=dp[i]; } cout<<re<<endl; } return 0; }
[ "270801364@qq.com" ]
270801364@qq.com
e26760447f6ae962285bc9c9cbc48cb2c7856243
17216697080c5afdd5549aff14f42c39c420d33a
/src/src/Share/ShareLib/LinuxPublic/ACE_wrappers/examples/C++NPv2/Logging_Acceptor.cpp
e10ecf2fbe50dc2075e584bf0eab4ea05ed309ea
[ "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-unknown-license-reference" ]
permissive
AI549654033/RDHelp
9c8b0cc196de98bcd81b2ccc4fc352bdc3783159
0f5f9c7d098635c7216713d7137c845c0d999226
refs/heads/master
2022-07-03T16:04:58.026641
2020-05-18T06:04:36
2020-05-18T06:04:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,011
cpp
/* ** $Id: Logging_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $ ** ** Copyright 2002 Addison Wesley. All Rights Reserved. */ #include "Logging_Acceptor.h" #include "Logging_Event_Handler.h" int Logging_Acceptor::open (const ACE_INET_Addr &local_addr) { if (acceptor_.open (local_addr) == -1) return -1; return reactor ()->register_handler (this, ACE_Event_Handler::ACCEPT_MASK); } int Logging_Acceptor::handle_input (ACE_HANDLE) { Logging_Event_Handler *peer_handler = 0; ACE_NEW_RETURN (peer_handler, Logging_Event_Handler (reactor ()), -1); if (acceptor_.accept (peer_handler->peer ()) == -1) { delete peer_handler; return -1; } else if (peer_handler->open () == -1) { peer_handler->handle_close (); return -1; } return 0; } int Logging_Acceptor::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { acceptor_.close (); delete this; return 0; }
[ "jim_xie@trendmicro.com" ]
jim_xie@trendmicro.com
0c4334357c356e00be07495d932f6ed56ea99ce1
cfeac52f970e8901871bd02d9acb7de66b9fb6b4
/generated/src/aws-cpp-sdk-ec2/source/model/DisassociateNatGatewayAddressResponse.cpp
7db2f66257cabc9b82e720b3ef328d211562bf57
[ "Apache-2.0", "MIT", "JSON" ]
permissive
aws/aws-sdk-cpp
aff116ddf9ca2b41e45c47dba1c2b7754935c585
9a7606a6c98e13c759032c2e920c7c64a6a35264
refs/heads/main
2023-08-25T11:16:55.982089
2023-08-24T18:14:53
2023-08-24T18:14:53
35,440,404
1,681
1,133
Apache-2.0
2023-09-12T15:59:33
2015-05-11T17:57:32
null
UTF-8
C++
false
false
2,320
cpp
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/ec2/model/DisassociateNatGatewayAddressResponse.h> #include <aws/core/utils/xml/XmlSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/logging/LogMacros.h> #include <utility> using namespace Aws::EC2::Model; using namespace Aws::Utils::Xml; using namespace Aws::Utils::Logging; using namespace Aws::Utils; using namespace Aws; DisassociateNatGatewayAddressResponse::DisassociateNatGatewayAddressResponse() { } DisassociateNatGatewayAddressResponse::DisassociateNatGatewayAddressResponse(const Aws::AmazonWebServiceResult<XmlDocument>& result) { *this = result; } DisassociateNatGatewayAddressResponse& DisassociateNatGatewayAddressResponse::operator =(const Aws::AmazonWebServiceResult<XmlDocument>& result) { const XmlDocument& xmlDocument = result.GetPayload(); XmlNode rootNode = xmlDocument.GetRootElement(); XmlNode resultNode = rootNode; if (!rootNode.IsNull() && (rootNode.GetName() != "DisassociateNatGatewayAddressResponse")) { resultNode = rootNode.FirstChild("DisassociateNatGatewayAddressResponse"); } if(!resultNode.IsNull()) { XmlNode natGatewayIdNode = resultNode.FirstChild("natGatewayId"); if(!natGatewayIdNode.IsNull()) { m_natGatewayId = Aws::Utils::Xml::DecodeEscapedXmlText(natGatewayIdNode.GetText()); } XmlNode natGatewayAddressesNode = resultNode.FirstChild("natGatewayAddressSet"); if(!natGatewayAddressesNode.IsNull()) { XmlNode natGatewayAddressesMember = natGatewayAddressesNode.FirstChild("item"); while(!natGatewayAddressesMember.IsNull()) { m_natGatewayAddresses.push_back(natGatewayAddressesMember); natGatewayAddressesMember = natGatewayAddressesMember.NextNode("item"); } } } if (!rootNode.IsNull()) { XmlNode requestIdNode = rootNode.FirstChild("requestId"); if (!requestIdNode.IsNull()) { m_responseMetadata.SetRequestId(StringUtils::Trim(requestIdNode.GetText().c_str())); } AWS_LOGSTREAM_DEBUG("Aws::EC2::Model::DisassociateNatGatewayAddressResponse", "x-amzn-request-id: " << m_responseMetadata.GetRequestId() ); } return *this; }
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
ceab205791ee7dc1ee505818b316326f3dea38ad
3bb0d6d519e3242562c47e43565d4ef9ab891b58
/3rdparty/libcxx/libcxx/test/std/containers/views/span.sub/subspan.pass.cpp
79cdc7bcaf1afca9b53dc71989657ec93793b7f3
[ "BSD-3-Clause", "OpenSSL", "MIT", "Apache-2.0", "LicenseRef-scancode-public-domain", "NCSA", "LicenseRef-scancode-generic-cla" ]
permissive
mofanv/openenclave
2e384c5853e3087dcba9de2741c561f166c03e82
1424f0034ea896f503307cbf5696a931c35d01d5
refs/heads/master
2020-04-08T22:57:19.532446
2018-11-30T08:44:07
2018-11-30T08:44:07
159,805,893
2
0
NOASSERTION
2018-11-30T10:16:03
2018-11-30T10:16:02
null
UTF-8
C++
false
false
7,470
cpp
// -*- C++ -*- //===------------------------------ span ---------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===---------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17 // <span> // template<ptrdiff_t Offset, ptrdiff_t Count = dynamic_extent> // constexpr span<element_type, see below> subspan() const; // // constexpr span<element_type, dynamic_extent> subspan( // index_type offset, index_type count = dynamic_extent) const; // // Requires: (0 <= Offset && Offset <= size()) // && (Count == dynamic_extent || Count >= 0 && Offset + Count <= size()) #include <span> #include <cassert> #include <algorithm> #include <string> #include "test_macros.h" template <typename Span, ptrdiff_t Offset, ptrdiff_t Count> constexpr bool testConstexprSpan(Span sp) { LIBCPP_ASSERT((noexcept(sp.template subspan<Offset, Count>()))); LIBCPP_ASSERT((noexcept(sp.subspan(Offset, Count)))); auto s1 = sp.template subspan<Offset, Count>(); auto s2 = sp.subspan(Offset, Count); using S1 = decltype(s1); using S2 = decltype(s2); ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type); ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type); static_assert(S1::extent == (Span::extent == std::dynamic_extent ? std::dynamic_extent : Count), ""); static_assert(S2::extent == std::dynamic_extent, ""); return s1.data() == s2.data() && s1.size() == s2.size() && std::equal(s1.begin(), s1.end(), sp.begin() + Offset); } template <typename Span, ptrdiff_t Offset> constexpr bool testConstexprSpan(Span sp) { LIBCPP_ASSERT((noexcept(sp.template subspan<Offset>()))); LIBCPP_ASSERT((noexcept(sp.subspan(Offset)))); auto s1 = sp.template subspan<Offset>(); auto s2 = sp.subspan(Offset); using S1 = decltype(s1); using S2 = decltype(s2); ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type); ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type); static_assert(S1::extent == (Span::extent == std::dynamic_extent ? std::dynamic_extent : Span::extent - Offset), ""); static_assert(S2::extent == std::dynamic_extent, ""); return s1.data() == s2.data() && s1.size() == s2.size() && std::equal(s1.begin(), s1.end(), sp.begin() + Offset, sp.end()); } template <typename Span, ptrdiff_t Offset, ptrdiff_t Count> void testRuntimeSpan(Span sp) { LIBCPP_ASSERT((noexcept(sp.template subspan<Offset, Count>()))); LIBCPP_ASSERT((noexcept(sp.subspan(Offset, Count)))); auto s1 = sp.template subspan<Offset, Count>(); auto s2 = sp.subspan(Offset, Count); using S1 = decltype(s1); using S2 = decltype(s2); ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type); ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type); static_assert(S1::extent == (Span::extent == std::dynamic_extent ? std::dynamic_extent : Count), ""); static_assert(S2::extent == std::dynamic_extent, ""); assert(s1.data() == s2.data()); assert(s1.size() == s2.size()); assert(std::equal(s1.begin(), s1.end(), sp.begin() + Offset)); } template <typename Span, ptrdiff_t Offset> void testRuntimeSpan(Span sp) { LIBCPP_ASSERT((noexcept(sp.template subspan<Offset>()))); LIBCPP_ASSERT((noexcept(sp.subspan(Offset)))); auto s1 = sp.template subspan<Offset>(); auto s2 = sp.subspan(Offset); using S1 = decltype(s1); using S2 = decltype(s2); ASSERT_SAME_TYPE(typename Span::value_type, typename S1::value_type); ASSERT_SAME_TYPE(typename Span::value_type, typename S2::value_type); static_assert(S1::extent == (Span::extent == std::dynamic_extent ? std::dynamic_extent : Span::extent - Offset), ""); static_assert(S2::extent == std::dynamic_extent, ""); assert(s1.data() == s2.data()); assert(s1.size() == s2.size()); assert(std::equal(s1.begin(), s1.end(), sp.begin() + Offset, sp.end())); } constexpr int carr1[] = {1,2,3,4}; int arr1[] = {5,6,7}; int main () { { using Sp = std::span<const int>; static_assert(testConstexprSpan<Sp, 0>(Sp{}), ""); static_assert(testConstexprSpan<Sp, 0, 4>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 0, 3>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 0, 2>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 0, 1>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 0, 0>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 1, 3>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 2, 2>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 3, 1>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 4, 0>(Sp{carr1}), ""); } { using Sp = std::span<const int, 4>; static_assert(testConstexprSpan<Sp, 0, 4>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 0, 3>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 0, 2>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 0, 1>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 0, 0>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 1, 3>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 2, 2>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 3, 1>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 4, 0>(Sp{carr1}), ""); } { using Sp = std::span<const int>; static_assert(testConstexprSpan<Sp, 0>(Sp{}), ""); static_assert(testConstexprSpan<Sp, 0>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 1>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 2>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 3>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 4>(Sp{carr1}), ""); } { using Sp = std::span<const int, 4>; static_assert(testConstexprSpan<Sp, 0>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 1>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 2>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 3>(Sp{carr1}), ""); static_assert(testConstexprSpan<Sp, 4>(Sp{carr1}), ""); } { using Sp = std::span<int>; testRuntimeSpan<Sp, 0>(Sp{}); testRuntimeSpan<Sp, 0, 3>(Sp{arr1}); testRuntimeSpan<Sp, 0, 2>(Sp{arr1}); testRuntimeSpan<Sp, 0, 1>(Sp{arr1}); testRuntimeSpan<Sp, 0, 0>(Sp{arr1}); testRuntimeSpan<Sp, 1, 2>(Sp{arr1}); testRuntimeSpan<Sp, 2, 1>(Sp{arr1}); testRuntimeSpan<Sp, 3, 0>(Sp{arr1}); } { using Sp = std::span<int, 3>; testRuntimeSpan<Sp, 0, 3>(Sp{arr1}); testRuntimeSpan<Sp, 0, 2>(Sp{arr1}); testRuntimeSpan<Sp, 0, 1>(Sp{arr1}); testRuntimeSpan<Sp, 0, 0>(Sp{arr1}); testRuntimeSpan<Sp, 1, 2>(Sp{arr1}); testRuntimeSpan<Sp, 2, 1>(Sp{arr1}); testRuntimeSpan<Sp, 3, 0>(Sp{arr1}); } { using Sp = std::span<int>; testRuntimeSpan<Sp, 0>(Sp{}); testRuntimeSpan<Sp, 0>(Sp{arr1}); testRuntimeSpan<Sp, 1>(Sp{arr1}); testRuntimeSpan<Sp, 2>(Sp{arr1}); testRuntimeSpan<Sp, 3>(Sp{arr1}); } { using Sp = std::span<int, 3>; testRuntimeSpan<Sp, 0>(Sp{arr1}); testRuntimeSpan<Sp, 1>(Sp{arr1}); testRuntimeSpan<Sp, 2>(Sp{arr1}); testRuntimeSpan<Sp, 3>(Sp{arr1}); } }
[ "berin.paul@vvdntech.in" ]
berin.paul@vvdntech.in
6074b07088814b00b6475f98e0b60414099eb5c3
e2669f8490bb7b7d030480feaf8179ce42973ecc
/src/center_server/game_service.h
b7e10477466000e1f376997ee73bebc1e6110c2b
[]
no_license
slayercat/ZeusMud
f0f268a905f69710f219691bd49a36bafe9cb900
d40620c142d6fefbf39e57947ae039992cff2c54
refs/heads/master
2021-01-24T20:01:32.121556
2017-05-22T09:48:45
2017-05-22T09:48:45
14,261,164
0
0
null
null
null
null
UTF-8
C++
false
false
366
h
#ifndef __GAME_SERVICE_H__ #define __GAME_SERVICE_H__ #include <common.h> #include <service.h> class GameService : public Venus::Service, public Venus::Singleton<GameService> { public: GameService(); ~GameService(); public: bool initialize(); void destroy(); private: bool registerDatabase(); void unregisterDatabase(); }; #endif
[ "138001655@qq.com" ]
138001655@qq.com
50e7ba91062a2143f6b249cde5da514e4acd9ce6
4fd9e45f26a849c55c0dd4e5b362c808bccc66bf
/9_Function/3_FunctionDefinations/main.cpp
aaaa3a3a718c9715f8bee9298802d25df9fa6e3b
[]
no_license
akshayyadav76/Try_CPP
68bc6da7c236cb892301e03a7c34d1eaaa087b40
85e473295af1ccfb011f01e7336eaa772e7bbaf7
refs/heads/master
2020-08-05T02:52:40.748533
2019-12-20T06:32:56
2019-12-20T06:32:56
212,367,216
2
1
null
2019-12-20T06:32:57
2019-10-02T14:48:18
C++
UTF-8
C++
false
false
1,082
cpp
#include<iostream> using namespace std; const double pi{1.2345}; // functions prototype double cir_area(double); // double cir_area(double cir); no need to put variable name compiler just want to know its type void circul(); double volume_area(double radious, double height); // but puting variable inside only usefull for documentation void volum(); int main(){ circul(); volum(); return 0; } double cir_area(double cir){ return pi*cir*cir; } void circul(){ cout<<" Enter a number for Cyliender"<<endl; int circul; cin>>circul; cout<<" the circular of that number is "<<cir_area(circul)<<endl; } double volume_area(double radious, double height){ return pi*radious*radious*height; } void volum(){ double radius; double height; cout <<" enter radious \n"; cin>>radius; cout<<" enter height \n"; cin>>height; cout<<" this is the total radious and height "<<volume_area(radius,height)<<endl; }
[ "akshayyadav7613@gmail.com" ]
akshayyadav7613@gmail.com
f660d4a87c02086dae1f576bfdf4e63d776f6f7b
6fc1240c9ae2a7b3d8eead384668e1f4b58d47da
/assignments/criollok/unit1/HW02C++Code/pro 2s.cpp
348943e256df96d6e434dd725b02322c91127bc4
[]
no_license
elascano/ESPE202105-OOP-TC-3730
38028e870d4de004cbbdf82fc5f8578126f8ca32
4275a03d410cf6f1929b1794301823e990fa0ef4
refs/heads/main
2023-08-09T13:24:26.898865
2021-09-13T17:08:10
2021-09-13T17:08:10
371,089,640
3
0
null
null
null
null
UTF-8
C++
false
false
321
cpp
//Suma de elementos de un arreglo de 5 enteros #include<stdio.h> #include <iostream> #include<conio.h> using namespace std; int main() { int numero[] = {6,12,7,18,10}; int suma=0; for(int i=0;i<5;i++){ suma += numero[i]; } cout<<"La suma de los elementos de un arreglo es: "<<suma<<endl; getch(); return 0; }
[ "kevincriollo2997_@hotmail.com" ]
kevincriollo2997_@hotmail.com
abeb47e227c5d9639744d73141f319109d31f25b
912bdeed5f33b00d486485e7449014ce1eba0a8c
/remote_pelco_2_com/test_pelco/test_pelco.cpp
ca04ee152ffdceea70d5402bb14d91a8df179763
[]
no_license
xibeilang524/RemotePelco
cd6c716eb90dfaffabf53e0dd1556cbc9742ccf4
cfb2c82a569d5ec95655bfd19711878a5c4e8f4c
refs/heads/master
2021-05-15T22:27:11.030269
2017-05-10T14:59:44
2017-05-10T14:59:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,521
cpp
// test_pelco.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "test_pelco.h" #include "test_pelcoDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // Ctest_pelcoApp BEGIN_MESSAGE_MAP(Ctest_pelcoApp, CWinApp) ON_COMMAND(ID_HELP, &CWinApp::OnHelp) END_MESSAGE_MAP() // Ctest_pelcoApp construction Ctest_pelcoApp::Ctest_pelcoApp() { // support Restart Manager m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART; // TODO: add construction code here, // Place all significant initialization in InitInstance } // The one and only Ctest_pelcoApp object Ctest_pelcoApp theApp; // Ctest_pelcoApp initialization BOOL Ctest_pelcoApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); AfxEnableControlContainer(); // Create the shell manager, in case the dialog contains // any shell tree view or shell list view controls. CShellManager *pShellManager = new CShellManager; // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("Local AppWizard-Generated Applications")); Ctest_pelcoDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Delete the shell manager created above. if (pShellManager != NULL) { delete pShellManager; } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
[ "wangzjpku@163.com" ]
wangzjpku@163.com
6688cb23346fb03b47c25c6551c23ba93e255fd3
39f5ed1178375c65876323589a03ef5daf6e4739
/chrome/browser/web_applications/preinstalled_web_apps/google_chat.cc
e64d1a461deeffb9a52879f26813710e69423c7c
[ "BSD-3-Clause" ]
permissive
berber1016/chromium
2718166c02fcb3aad24cc3bd326a4f8d2d7c0cae
9dc373d511536c916dec337b4ccc53106967d28d
refs/heads/main
2023-03-21T21:53:55.686443
2021-05-14T10:13:20
2021-05-14T10:13:20
367,332,075
1
0
BSD-3-Clause
2021-05-14T10:46:30
2021-05-14T10:46:29
null
UTF-8
C++
false
false
909
cc
// Copyright 2021 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/web_applications/preinstalled_web_apps/google_chat.h" #include "chrome/browser/web_applications/components/preinstalled_app_install_features.h" namespace web_app { ExternalInstallOptions GetConfigForGoogleChat() { ExternalInstallOptions options( /*install_url=*/GURL( "https://mail.google.com/chat/download?usp=chrome_default"), /*user_display_mode=*/DisplayMode::kStandalone, /*install_source=*/ExternalInstallSource::kExternalDefault); options.user_type_allowlist = {"unmanaged", "managed", "child"}; options.gate_on_feature = kDefaultChatWebApp.name; options.only_for_new_users = true; options.add_to_quick_launch_bar = false; return options; } } // namespace web_app
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
e97323c129f959ace6342dd3d99090670a3951e3
6375a199f2e25177e56ac5da9c540d03feb42fb4
/include/UILivesRenderComponent.h
d235bc286444db3b30dee4cef50e04a5bb4ae563
[ "MIT" ]
permissive
CSID-DGU/2020-1-OSSP2-CarpeDiem-5
2cec1f84a41185ed45e9d9d27e23c01abf4d994f
1d25cbb82f5d8c8e40a7746ff3e17a095c5bf4c9
refs/heads/master
2021-05-19T03:56:23.019966
2020-06-25T10:27:06
2020-06-25T10:27:06
251,517,873
2
3
MIT
2020-06-25T10:27:08
2020-03-31T06:22:40
OpenEdge ABL
UTF-8
C++
false
false
1,187
h
/*******************************************************************//* * Render component for UILives * * @author Brandon To * @version 1.0 * @since 2015-02-17 * @modified 2015-02-19 *********************************************************************/ #ifndef SPACESHOOTER_UILIVESRENDERCOMPONENT_ #define SPACESHOOTER_UILIVESRENDERCOMPONENT_ #include "RenderComponent.h" #include <map> #ifdef _WIN32 #include <SDL.h> #endif #ifdef __linux #include <SDL2/SDL.h> #endif class GameEntity; struct WindowElements; class UILivesRenderComponent : public RenderComponent { private: Texture* xTexture; SDL_Rect xRect; std::map<int, Texture*> numLivesTextures; SDL_Rect numLivesRect; int* livesPointer; public: //Constructor UILivesRenderComponent(GameEntity* gameEntity, WindowElements* windowElements); //Destructor ~UILivesRenderComponent(); //Methods void update(); void enableBlending(); void setAlphaBlend(Uint8 alpha); Uint8 getAlphaBlend(); void setLivesPointer(int* ptr); }; #endif
[ "shalalastal@naver.com" ]
shalalastal@naver.com
ff0bd97a9d4c9a0bb01042f7e15c3b79f795d4a8
94237aa3ab6a23e9493d5ec48d190beffc076722
/H3/H3P3/inputdialog.h
d697342759ad25295a4a68555ccf520dfb31ec13
[]
no_license
Mctashuo/Computer_graphics_Grade3
d7083106d41954829822c7eb0fe9b0712b0eec4b
f921079e65c57a2ee5f70b806085d84a5dda3e44
refs/heads/master
2021-03-19T11:35:27.602067
2017-11-27T02:18:20
2017-11-27T02:18:20
109,634,522
0
0
null
null
null
null
UTF-8
C++
false
false
1,217
h
#if !defined(AFX_INPUTDIALOG_H__DCEA5000_6CC2_42A1_A983_A8FA488F186B__INCLUDED_) #define AFX_INPUTDIALOG_H__DCEA5000_6CC2_42A1_A983_A8FA488F186B__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // inputdialog.h : header file // ///////////////////////////////////////////////////////////////////////////// // Cinputdialog dialog class Cinputdialog : public CDialog { // Construction public: Cinputdialog(CWnd* pParent = NULL); // standard constructor // Dialog Data //{{AFX_DATA(Cinputdialog) enum { IDD = IDD_DIALOG1 }; int m_ex; int m_ey; int m_sx; int m_sy; //}}AFX_DATA // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(Cinputdialog) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: // Generated message map functions //{{AFX_MSG(Cinputdialog) // NOTE: the ClassWizard will add member functions here //}}AFX_MSG DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_INPUTDIALOG_H__DCEA5000_6CC2_42A1_A983_A8FA488F186B__INCLUDED_)
[ "mctashuo@gmail.com" ]
mctashuo@gmail.com
91fdf5138e49bc1df457a11003e2e1b69a3c7308
e170e98d08c76fdcb9e6ee4fa4e09db6c3055ee1
/cunno.cpp
1436b0280134c49886e0fad05c1cfd3464bc1fd4
[]
no_license
Locke-bot/graphy
74ed58ea99480ae6aef7ec7630f4995875543d35
4eadb198a5aea642cbfdb8795ad56f592f547d3a
refs/heads/master
2023-09-01T04:05:53.719439
2021-10-01T17:33:13
2021-10-01T17:33:13
397,513,539
0
0
null
null
null
null
UTF-8
C++
false
false
137,227
cpp
//Gauss Elimination #include<iostream> #include <iterator> #include <algorithm> #include <vector> #include "fraction.cxx" // #include<iomanip> using namespace std; int main() { int i,j; cout<<"\nEnter the no. of equations\n"; // long a[n][n+1] = {{3, 2, -4, 3, 9, 76}, // {2, 3, 3, 15, 8, 45}, // {5, -3, 1, 12, -4, 56}, // {23, 13, -1, 12, 6, -9}, // {-2, 12, 21, 19, -7, 4}, // }; vector<vector<Fraction>> a {{Fraction("8881784197001252323389053344726562500000000000000000000000000000000000000000000000000", "1"), Fraction("177635683940025046467781066894531250000000000000000000000000000000000000000000000000", "1"), Fraction("3552713678800500929355621337890625000000000000000000000000000000000000000000000000", "1"), Fraction("71054273576010018587112426757812500000000000000000000000000000000000000000000000", "1"), Fraction("1421085471520200371742248535156250000000000000000000000000000000000000000000000", "1"), Fraction("28421709430404007434844970703125000000000000000000000000000000000000000000000", "1"), Fraction("568434188608080148696899414062500000000000000000000000000000000000000000000", "1"), Fraction("11368683772161602973937988281250000000000000000000000000000000000000000000", "1"), Fraction("227373675443232059478759765625000000000000000000000000000000000000000000", "1"), Fraction("4547473508864641189575195312500000000000000000000000000000000000000000", "1"), Fraction("90949470177292823791503906250000000000000000000000000000000000000000", "1"), Fraction("1818989403545856475830078125000000000000000000000000000000000000000", "1"), Fraction("36379788070917129516601562500000000000000000000000000000000000000", "1"), Fraction("727595761418342590332031250000000000000000000000000000000000000", "1"), Fraction("14551915228366851806640625000000000000000000000000000000000000", "1"), Fraction("291038304567337036132812500000000000000000000000000000000000", "1"), Fraction("5820766091346740722656250000000000000000000000000000000000", "1"), Fraction("116415321826934814453125000000000000000000000000000000000", "1"), Fraction("2328306436538696289062500000000000000000000000000000000", "1"), Fraction("46566128730773925781250000000000000000000000000000000", "1"), Fraction("931322574615478515625000000000000000000000000000000", "1"), Fraction("18626451492309570312500000000000000000000000000000", "1"), Fraction("372529029846191406250000000000000000000000000000", "1"), Fraction("7450580596923828125000000000000000000000000000", "1"), Fraction("149011611938476562500000000000000000000000000", "1"), Fraction("2980232238769531250000000000000000000000000", "1"), Fraction("59604644775390625000000000000000000000000", "1"), Fraction("1192092895507812500000000000000000000000", "1"), Fraction("23841857910156250000000000000000000000", "1"), Fraction("476837158203125000000000000000000000", "1"), Fraction("9536743164062500000000000000000000", "1"), Fraction("190734863281250000000000000000000", "1"), Fraction("3814697265625000000000000000000", "1"), Fraction("76293945312500000000000000000", "1"), Fraction("1525878906250000000000000000", "1"), Fraction("30517578125000000000000000", "1"), Fraction("610351562500000000000000", "1"), Fraction("12207031250000000000000", "1"), Fraction("244140625000000000000", "1"), Fraction("4882812500000000000", "1"), Fraction("97656250000000000", "1"), Fraction("1953125000000000", "1"), Fraction("39062500000000", "1"), Fraction("781250000000", "1"), Fraction("15625000000", "1"), Fraction("312500000", "1"), Fraction("6250000", "1"), Fraction("125000", "1"), Fraction("2500", "1"), Fraction("50", "1"), Fraction("1", "1"), Fraction("150000205", "1")}, {Fraction("3234476509624757991344647769100216810857203198904625400933895331391691459636928060001", "1"), Fraction("66009724686219550843768321818371771650147004059278069406814190436565131829325062449", "1"), Fraction("1347137238494276547832006567721872890819326613454654477690085519113574118965817601", "1"), Fraction("27492596703964827506775644239221895731006665580707234238573173859460696305424849", "1"), Fraction("561073402121731173607666208963712157775646236340963964052513752233891761335201", "1"), Fraction("11450477594321044359340126713545146077054004823284978858214566372120240027249", "1"), Fraction("233683216210633558353880137011125430143959282107856711392134007594290612801", "1"), Fraction("4769045228788439966405717081859702655999169022609320640655796073352869649", "1"), Fraction("97327453648743672783790144527749033795901408624680013074608083129650401", "1"), Fraction("1986274564260074954771227439341817016242885890299592103563430267952049", "1"), Fraction("40536215597144386832065866109016673800875222251012083746192454448001", "1"), Fraction("827269706064171159838078900184013751038269841857389464208009274449", "1"), Fraction("16883055225799411425266916330285994919148364119538560494041005601", "1"), Fraction("344552147465294110719732986332367243247925798357929806000836849", "1"), Fraction("7031676478883553279994550741476882515263791803223057265323201", "1"), Fraction("143503601609868434285603076356671071740077383739246066639249", "1"), Fraction("2928644930813641516032715844013695341634232321209103400801", "1"), Fraction("59768263894155949306790119265585619217025149412430681649", "1"), Fraction("1219760487635835700138573862562971820755615294131238401", "1"), Fraction("24893071176241544900787221684958608586849291716964049", "1"), Fraction("508021860739623365322188197652216501772434524836001", "1"), Fraction("10367793076318844190248738727596255138212949486449", "1"), Fraction("211587613802425391637729361787678676290060193601", "1"), Fraction("4318114567396436564035293097707728087552248849", "1"), Fraction("88124787089723195184393736687912818113311201", "1"), Fraction("1798465042647412146620280340569649349251249", "1"), Fraction("36703368217294125441230211032033660188801", "1"), Fraction("749048330965186233494494102694564493649", "1"), Fraction("15286700631942576193765185769276826401", "1"), Fraction("311973482284542371301330321821976049", "1"), Fraction("6366805760909027985741435139224001", "1"), Fraction("129934811447123020117172145698449", "1"), Fraction("2651730845859653471779023381601", "1"), Fraction("54116956037952111668959660849", "1"), Fraction("1104427674243920646305299201", "1"), Fraction("22539340290692258087863249", "1"), Fraction("459986536544739960976801", "1"), Fraction("9387480337647754305649", "1"), Fraction("191581231380566414401", "1"), Fraction("3909821048582988049", "1"), Fraction("79792266297612001", "1"), Fraction("1628413597910449", "1"), Fraction("33232930569601", "1"), Fraction("678223072849", "1"), Fraction("13841287201", "1"), Fraction("282475249", "1"), Fraction("5764801", "1"), Fraction("117649", "1"), Fraction("2401", "1"), Fraction("49", "1"), Fraction("1", "1"), Fraction("138355425", "1")}, {Fraction("1153617588319010271378133306175011326520419737189530113840977835459429144159137562624", "1"), Fraction("24033699756646047320377777211979402635842077858115210705020371572071440503315365888", "1"), Fraction("500702078263459319174537025249570888246709955377400223021257741084821677152403456", "1"), Fraction("10431293297155402482802854692699393505139790737029171312942869605933784940675072", "1"), Fraction("217318610357404218391726139431237364690412307021441069019643116790287186264064", "1"), Fraction("4527471049112587883160961238150778431050256396280022271242564933130983047168", "1"), Fraction("94322313523178914232520025794807883980213674922500463984220102773562146816", "1"), Fraction("1965048198399560713177500537391830916254451560885426333004585474449211392", "1"), Fraction("40938504133324181524531261195663144088634407518446381937595530717691904", "1"), Fraction("852885502777587115094401274909648835179883489967632957033240223285248", "1"), Fraction("17768447974533064897800026560617684066247572707659019938192504651776", "1"), Fraction("370175999469438852037500553346201751380157764742896248712343846912", "1"), Fraction("7711999988946642750781261528045869820419953432143671848173830144", "1"), Fraction("160666666436388390641276281834288954592082363169659830170288128", "1"), Fraction("3347222217424758138359922538214353220668382566034579795214336", "1"), Fraction("69733796196349127882498386212799025430591303459053745733632", "1"), Fraction("1452787420757273497552049712766646363137318822063619702784", "1"), Fraction("30266404599109864532334369015971799232027475459658743808", "1"), Fraction("630550095814788844423632687832745817333905738742890496", "1"), Fraction("13136460329474767592159014329848871194456369557143552", "1"), Fraction("273676256864057658169979465205184816551174365773824", "1"), Fraction("5701588684667867878541238858441350344816132620288", "1"), Fraction("118783097597247247469609142884194798850336096256", "1"), Fraction("2474647866609317655616857143420724976048668672", "1"), Fraction("51555163887694117825351190487931770334347264", "1"), Fraction("1074065914326960788028149801831911881965568", "1"), Fraction("22376373215145016417253120871498164207616", "1"), Fraction("466174441982187842026106684822878420992", "1"), Fraction("9711967541295580042210555933809967104", "1"), Fraction("202332657110324584212719915287707648", "1"), Fraction("4215263689798428837764998235160576", "1"), Fraction("87817993537467267453437463232512", "1"), Fraction("1829541532030568071946613817344", "1"), Fraction("38115448583970168165554454528", "1"), Fraction("794071845499378503449051136", "1"), Fraction("16543163447903718821855232", "1"), Fraction("344649238497994142121984", "1"), Fraction("7180192468708211294208", "1"), Fraction("149587343098087735296", "1"), Fraction("3116402981210161152", "1"), Fraction("64925062108545024", "1"), Fraction("1352605460594688", "1"), Fraction("28179280429056", "1"), Fraction("587068342272", "1"), Fraction("12230590464", "1"), Fraction("254803968", "1"), Fraction("5308416", "1"), Fraction("110592", "1"), Fraction("2304", "1"), Fraction("48", "1"), Fraction("1", "1"), Fraction("127402181", "1")}, {Fraction("402617730805669449351119414631101081965810862692259490987379173664059714186381625249", "1"), Fraction("8566334697992967007470625843214916637570443887069350872071897312001270514603864367", "1"), Fraction("182262440382829085265332464749253545480222210363177678129189304510665330097954561", "1"), Fraction("3877924263464448622666648186154330754898344901344205917642325627886496385062863", "1"), Fraction("82509026882222311120566982684134696912730742581791615268985651657159497554529", "1"), Fraction("1755511210260049172778020908173078657717675374080672665297567056535308458607", "1"), Fraction("37351302345958493037830232088788907611014369661290907772288660777346988481", "1"), Fraction("794708560552308362507026214655083140659880205559381016431673633560574223", "1"), Fraction("16908692777708688563979281162874109375742132033178319498546247522565409", "1"), Fraction("359759420802312522637857046018598071824300681556985521245664840905647", "1"), Fraction("7654455761751330268890575447204214294134057054403947260546060444801", "1"), Fraction("162860760888326175933842030791579027534767171370296750224384264783", "1"), Fraction("3465122572092046296464724059395298458186535561070143621795409889", "1"), Fraction("73726012172171197797121788497772307620990118320641353655221487", "1"), Fraction("1568638556854706336108974223356857608957236560013645822451521", "1"), Fraction("33375288443717156087424983475677821467175245957737145158543", "1"), Fraction("710112520079088427392020925014421733344154169313556279969", "1"), Fraction("15108777022959328242383423936477058156258599347096942127", "1"), Fraction("321463340914028260476243062478235279920395730789296641", "1"), Fraction("6839645551362303414388150265494367657880760229559503", "1"), Fraction("145524373433240498178471282244561013997462983607649", "1"), Fraction("3096263264537031876137686856267255616967297523567", "1"), Fraction("65877941798660252683780571409941608871644628161", "1"), Fraction("1401658336141707503910224923615778912162651663", "1"), Fraction("29822517790249095827877126034378274726864929", "1"), Fraction("634521655111682889954832468816559036741807", "1"), Fraction("13500460747057082764996435506735298654081", "1"), Fraction("287243845682065590744605010781602099023", "1"), Fraction("6111571184724799803076702357055363809", "1"), Fraction("130033429462229783044185156533092847", "1"), Fraction("2766668711962335809450748011342401", "1"), Fraction("58865291743879485307462723645583", "1"), Fraction("1252453015827223091648143056289", "1"), Fraction("26647936506962193439322192687", "1"), Fraction("566977372488557307219621121", "1"), Fraction("12063348350820368238715343", "1"), Fraction("256666986187667409334369", "1"), Fraction("5460999706120583177327", "1"), Fraction("116191483108948578241", "1"), Fraction("2472159215084012303", "1"), Fraction("52599132235830049", "1"), Fraction("1119130473102767", "1"), Fraction("23811286661761", "1"), Fraction("506623120463", "1"), Fraction("10779215329", "1"), Fraction("229345007", "1"), Fraction("4879681", "1"), Fraction("103823", "1"), Fraction("2209", "1"), Fraction("47", "1"), Fraction("1", "1"), Fraction("117112537", "1")}, {Fraction("137369900626569127919715942598229385418793943383832182092025785413140781304303845376", "1"), Fraction("2986302187534111476515563969526725769973781377909395262870125769850886550093561856", "1"), Fraction("64919612772480684272077477598407081955951769084986853540654908040236664132468736", "1"), Fraction("1411295929836536614610379947791458303390255849673627250883802348700797046358016", "1"), Fraction("30680346300794274230660433647640397899788170645078853280082659754365153181696", "1"), Fraction("666964050017266831101313774948704302169308057501714201740927385964459851776", "1"), Fraction("14499218478636235458724212498884876134115392554385091342194073607923040256", "1"), Fraction("315200401709483379537482880410540785524247664225762855265088556693979136", "1"), Fraction("6852182645858334337771366965446538815744514439690496853588881667260416", "1"), Fraction("148960492301268137777638412292316061211837270428054279425845253636096", "1"), Fraction("3238271571766698647339965484615566548083418922349006074474896818176", "1"), Fraction("70397208081884753203042727926425359740943889616282740749454278656", "1"), Fraction("1530374088736625069631363650574464342194432382962668277162049536", "1"), Fraction("33269001929057066731116601099444877004226790933971049503522816", "1"), Fraction("723239172370805798502534806509671239222321542042848902250496", "1"), Fraction("15722590703713169532663800141514592157006990044409758744576", "1"), Fraction("341795450080721076797039133511186786021891087921951277056", "1"), Fraction("7430335871320023408631285511112756217867197563520679936", "1"), Fraction("161529040680870074100680119806799048214504294859145216", "1"), Fraction("3511500884366740741319133039278240178576180323024896", "1"), Fraction("76336975747103059593894196506048699534264789630976", "1"), Fraction("1659499472763109991171612967522797815962278035456", "1"), Fraction("36076075494850217199382890598321691651353870336", "1"), Fraction("784262510757613417377888926050471557638127616", "1"), Fraction("17049185016469856899519324479358077339959296", "1"), Fraction("370634456879779497815637488681697333477376", "1"), Fraction("8057270801734336909035597580036898553856", "1"), Fraction("175158060907268193674686903913845620736", "1"), Fraction("3807783932766699862493193563344470016", "1"), Fraction("82777911581884779619417251377053696", "1"), Fraction("1799519816997495209117766334283776", "1"), Fraction("39119996021684678459081876832256", "1"), Fraction("850434696123579966501779931136", "1"), Fraction("18487710785295216663082172416", "1"), Fraction("401906756202069927458308096", "1"), Fraction("8737103395697172336050176", "1"), Fraction("189937030341242876870656", "1"), Fraction("4129065876983540801536", "1"), Fraction("89762301673555234816", "1"), Fraction("1951354384207722496", "1"), Fraction("42420747482776576", "1"), Fraction("922190162669056", "1"), Fraction("20047612231936", "1"), Fraction("435817657216", "1"), Fraction("9474296896", "1"), Fraction("205962976", "1"), Fraction("4477456", "1"), Fraction("97336", "1"), Fraction("2116", "1"), Fraction("46", "1"), Fraction("1", "1"), Fraction("107459133", "1")}, {Fraction("45774719191272635313479811160208512239764957207999174215728999115526676177978515625", "1"), Fraction("1017215982028280784743995803560189160883665715733314982571755535900592803955078125", "1"), Fraction("22604799600628461883199906745781981352970349238518110723816789686679840087890625", "1"), Fraction("502328880013965819626664594350710696732674427522624682751484215259552001953125", "1"), Fraction("11162864000310351547259213207793571038503876167169437394477427005767822265625", "1"), Fraction("248063644451341145494649182395412689744530581492654164321720600128173828125", "1"), Fraction("5512525432252025455436648497675837549878457366503425873816013336181640625", "1"), Fraction("122500565161156121231925522170574167775076830366742797195911407470703125", "1"), Fraction("2722234781359024916265011603790537061668374008149839937686920166015625", "1"), Fraction("60494106252422775917000257862011934703741644625551998615264892578125", "1"), Fraction("1344313472276061687044450174711376326749814325012266635894775390625", "1"), Fraction("29873632717245815267654448326919473927773651666939258575439453125", "1"), Fraction("663858504827684783725654407264877198394970037043094635009765625", "1"), Fraction("14752411218392995193903431272552826630999334156513214111328125", "1"), Fraction("327831360408733226531187361612285036244429647922515869140625", "1"), Fraction("7285141342416293922915274702495223027653992176055908203125", "1"), Fraction("161892029831473198287006104499893845058977603912353515625", "1"), Fraction("3597600662921626628600135655553196556866168975830078125", "1"), Fraction("79946681398258369524447459012293256819248199462890625", "1"), Fraction("1776592919961297100543276866939850151538848876953125", "1"), Fraction("39479842665806602234295041487552225589752197265625", "1"), Fraction("877329837017924494095445366390049457550048828125", "1"), Fraction("19496218600398322091009897030889987945556640625", "1"), Fraction("433249302231073824244664378464221954345703125", "1"), Fraction("9627762271801640538770319521427154541015625", "1"), Fraction("213950272706703123083784878253936767578125", "1"), Fraction("4754450504593402735195219516754150390625", "1"), Fraction("105654455657631171893227100372314453125", "1"), Fraction("2347876792391803819849491119384765625", "1"), Fraction("52175039830928973774433135986328125", "1"), Fraction("1159445329576199417209625244140625", "1"), Fraction("25765451768359987049102783203125", "1"), Fraction("572565594852444156646728515625", "1"), Fraction("12723679885609870147705078125", "1"), Fraction("282748441902441558837890625", "1"), Fraction("6283298708943145751953125", "1"), Fraction("139628860198736572265625", "1"), Fraction("3102863559971923828125", "1"), Fraction("68952523554931640625", "1"), Fraction("1532278301220703125", "1"), Fraction("34050628916015625", "1"), Fraction("756680642578125", "1"), Fraction("16815125390625", "1"), Fraction("373669453125", "1"), Fraction("8303765625", "1"), Fraction("184528125", "1"), Fraction("4100625", "1"), Fraction("91125", "1"), Fraction("2025", "1"), Fraction("45", "1"), Fraction("1", "1"), Fraction("98415185", "1")}, {Fraction("14881058511424953988078608769806432918740714444252299374974281300129389429838053376", "1"), Fraction("338205875259658045183604744768328020880470782823915894885779120457486123405410304", "1"), Fraction("7686497164992228299627380562916545929101608700543543065585889101306502804668416", "1"), Fraction("174693117386187006809713194611739680206854743194171433308770206847875063742464", "1"), Fraction("3970298122413341063857118059357720004701244163503896211562959246542615085056", "1"), Fraction("90234048236666842360389046803584545561391912806906732080976346512332161024", "1"), Fraction("2050773823560610053645205609172376035486179836520607547294916966189367296", "1"), Fraction("46608495990013864855572854753917637170140450830013807893066294686121984", "1"), Fraction("1059283999773042383081201244407219026594101155227586543024233970139136", "1"), Fraction("24074636358478235979118210100164068786229571709717875977823499321344", "1"), Fraction("547150826329050817707232047731001563323399357039042635859624984576", "1"), Fraction("12435246052932973129709819266613671893713621750887332633173295104", "1"), Fraction("282619228475749389311586801513947088493491403429257559844847616", "1"), Fraction("6423164283539758847990609125316979283942986441574035451019264", "1"), Fraction("145981006444085428363422934666294983725976964581228078432256", "1"), Fraction("3317750146456487008259612151506704175590385558664274509824", "1"), Fraction("75403412419465613824082094352425094899781489969642602496", "1"), Fraction("1713713918624218496001865780736933974995033862946422784", "1"), Fraction("38948043605095874909133313198566681249887133248782336", "1"), Fraction("885182809206724429753029845421970028406525755654144", "1"), Fraction("20117791118334646130750678305044773372875585355776", "1"), Fraction("457222525416696502971606325114653940292626939904", "1"), Fraction("10391421032197647794809234661696680461196066816", "1"), Fraction("236168659822673813518391696856742737754456064", "1"), Fraction("5367469541424404852690720383107789494419456", "1"), Fraction("121987944123281928470243645070631579418624", "1"), Fraction("2772453275529134737960082842514354077696", "1"), Fraction("63010301716571244044547337329871683584", "1"), Fraction("1432052311740255546466984939315265536", "1"), Fraction("32546643448642171510613294075346944", "1"), Fraction("739696442014594807059393047166976", "1"), Fraction("16811282773058972887713478344704", "1"), Fraction("382074608478613020175306326016", "1"), Fraction("8683513829059386822166052864", "1"), Fraction("197352587024076973231046656", "1"), Fraction("4485286068729022118887424", "1"), Fraction("101938319743841411792896", "1"), Fraction("2316779994178213904384", "1"), Fraction("52654090776777588736", "1"), Fraction("1196683881290399744", "1"), Fraction("27197360938418176", "1"), Fraction("618121839509504", "1"), Fraction("14048223625216", "1"), Fraction("319277809664", "1"), Fraction("7256313856", "1"), Fraction("164916224", "1"), Fraction("3748096", "1"), Fraction("85184", "1"), Fraction("1936", "1"), Fraction("44", "1"), Fraction("1", "1"), Fraction("89954485", "1")}, {Fraction("4714360387980744262490899308202381019261517110394362838564169693991640398273296249", "1"), Fraction("109636288092575447964904635074473977192128304892892159036376039395154427866820843", "1"), Fraction("2549681118431987161974526397080790167258797788206794396194791613840800648065601", "1"), Fraction("59294909730976445627314567373971864354855762516437078981274223577693038327107", "1"), Fraction("1378951389092475479704989938929578240810599128289234394913354036690535775049", "1"), Fraction("32068636955638964644302091603013447460711607634633358021240791550942692443", "1"), Fraction("745782254782301503355862595418917382807246689177519953982343989556806801", "1"), Fraction("17343773367030267519903781288812032158308062539012091953077767198995507", "1"), Fraction("403343566675122500462878634623535631588559593930513766350645748813849", "1"), Fraction("9380082945933081406113456619151991432292083579779389915131296484043", "1"), Fraction("218141463858908869909615270212837010053304269297195114305378988001", "1"), Fraction("5073057299044392323479424888670628140774517890632444518729743907", "1"), Fraction("117978076721962612173940113690014607924988788154242895784412649", "1"), Fraction("2743676202836339817998607295116618788953227631494020832195643", "1"), Fraction("63806423321775344604618774305037646254726223988233042609201", "1"), Fraction("1483870309808728944293459867559015029179679627633326572307", "1"), Fraction("34508611856016952192871159710674768120457665758914571449", "1"), Fraction("802525857116673306810957202573831816754829436253827243", "1"), Fraction("18663392025969146670022260524972832947786731075670401", "1"), Fraction("434032372696956899302843268022624022041551885480707", "1"), Fraction("10093776109231555797740541116805209814919811290249", "1"), Fraction("234738979284454785993966072483842088719065378843", "1"), Fraction("5459046029871041534743397034507955551606171601", "1"), Fraction("126954558834210268249846442662975710502469107", "1"), Fraction("2952431600795587633717359131697109546569049", "1"), Fraction("68661200018502037993426956551095570850443", "1"), Fraction("1596772093453535767288998989560362112801", "1"), Fraction("37134234731477575983465092780473537507", "1"), Fraction("863586854220408743801513785592407849", "1"), Fraction("20083415214428110320965436874242043", "1"), Fraction("467056167777397914441056671494001", "1"), Fraction("10861771343660416614908294685907", "1"), Fraction("252599333573498060811820806649", "1"), Fraction("5874403106360420018879553643", "1"), Fraction("136614025729312093462315201", "1"), Fraction("3177070365797955661914307", "1"), Fraction("73885357344138503765449", "1"), Fraction("1718264124282290785243", "1"), Fraction("39959630797262576401", "1"), Fraction("929293739471222707", "1"), Fraction("21611482313284249", "1"), Fraction("502592611936843", "1"), Fraction("11688200277601", "1"), Fraction("271818611107", "1"), Fraction("6321363049", "1"), Fraction("147008443", "1"), Fraction("3418801", "1"), Fraction("79507", "1"), Fraction("1849", "1"), Fraction("43", "1"), Fraction("1", "1"), Fraction("82051401", "1")}, {Fraction("1453665622146771666761099934493492006225419233517791732362319211631615699398426624", "1"), Fraction("34611086241589801589549998440321238243462362702804565056245695515038469033295872", "1"), Fraction("824073481942614323560714248579077101034818159590584882291564178929487357935616", "1"), Fraction("19620797189109864846683672585216121453209956180728211483132480450702079950848", "1"), Fraction("467161837835949163016277918695621939362141813826862178169820963111954284544", "1"), Fraction("11122900900855932452768521873705284270527186043496718527852880074094149632", "1"), Fraction("264830973829903153637345758897744863583980620083255203044116192240336896", "1"), Fraction("6305499376902456038984422830898687228190014763887028643907528386674688", "1"), Fraction("150130937545296572356771972164254457814047970568738777235893533016064", "1"), Fraction("3574546132030870770399332670577487090810665965922351838949846024192", "1"), Fraction("85108241238830256438079349299463978352634903950532186641663000576", "1"), Fraction("2026386696162625153287603554749142341729402475012671110515785728", "1"), Fraction("48247302289586313173514370351170055755461963690777883583709184", "1"), Fraction("1148745292609197932702723103599287041796713421208997228183552", "1"), Fraction("27351078395457093635779121514268739090397938600214219718656", "1"), Fraction("651216152272787943709026702720684264057093776195576659968", "1"), Fraction("15505146482685427231167302445730577715645089909418491904", "1"), Fraction("369170154349653029313507201088823278943930712129011712", "1"), Fraction("8789765579753643555083504787829125689141207431643136", "1"), Fraction("209280132851277227501988209234026802122409700753408", "1"), Fraction("4982860305982791130999719267476828621962135732224", "1"), Fraction("118639531094828360261898077797067348141955612672", "1"), Fraction("2824750740353056196711858995168270193856086016", "1"), Fraction("67255970008406099921710928456387385568002048", "1"), Fraction("1601332619247764283850260201342556799238144", "1"), Fraction("38126967124946768663101433365298971410432", "1"), Fraction("907784931546351634835748413459499319296", "1"), Fraction("21613926941579800829422581272845221888", "1"), Fraction("514617308132852400700537649353457664", "1"), Fraction("12252793050782200016679467841748992", "1"), Fraction("291733167875766667063796853374976", "1"), Fraction("6946027806565873025328496508928", "1"), Fraction("165381614442044595841154678784", "1"), Fraction("3937657486715347520027492352", "1"), Fraction("93753749683698750476845056", "1"), Fraction("2232232135326160725639168", "1"), Fraction("53148384174432398229504", "1"), Fraction("1265437718438866624512", "1"), Fraction("30129469486639681536", "1"), Fraction("717368321110468608", "1"), Fraction("17080198121677824", "1"), Fraction("406671383849472", "1"), Fraction("9682651996416", "1"), Fraction("230539333248", "1"), Fraction("5489031744", "1"), Fraction("130691232", "1"), Fraction("3111696", "1"), Fraction("74088", "1"), Fraction("1764", "1"), Fraction("42", "1"), Fraction("1", "1"), Fraction("74680877", "1")}, {Fraction("435705293158188780045492006945841798765480379972742781555000875455118595048362001", "1"), Fraction("10626958369711921464524195291361995091840984877383970281829289645246795001179561", "1"), Fraction("259194106578339547915224275399073051020511826277657811751933893786507195150721", "1"), Fraction("6321807477520476778420104278026171976110044543357507603705704726500175491481", "1"), Fraction("154190426280987238498051323854296877466098647398963600090383042109760377841", "1"), Fraction("3760742104414322890196373752543826279660942619486917075375196149018545801", "1"), Fraction("91725417180837143663326189086434787308803478524071148179882832902891361", "1"), Fraction("2237205297093588869837224124059385056312279964001735321460556900070521", "1"), Fraction("54565982855941191947249368879497196495421462536627690767330656099281", "1"), Fraction("1330877630632711998713399240963346255985889330161650994325137953641", "1"), Fraction("32460430015431999968619493682032835511850959272235390105491169601", "1"), Fraction("791717805254439023624865699561776475898803884688668051353443161", "1"), Fraction("19310190372059488381094285355165279899970826455821171984230321", "1"), Fraction("470980252977060692221811837930860485365142108678565170347081", "1"), Fraction("11487323243342943712727117998313670374759563626306467569441", "1"), Fraction("280178615691291310066515073129601716457550332348938233401", "1"), Fraction("6833624772958324635768660320234188206281715423144834961", "1"), Fraction("166673774950203039896796593176443614787358912759630121", "1"), Fraction("4065214023175683899921868126254722311886802750234881", "1"), Fraction("99151561540870339022484588445237129558214701225241", "1"), Fraction("2418330769289520463963038742566759257517431737201", "1"), Fraction("58983677299744401560074115672359981890669066761", "1"), Fraction("1438626275603521989270100382252682485138269921", "1"), Fraction("35088445746427365591953667859821524027762681", "1"), Fraction("855815749912862575413504094141988390921041", "1"), Fraction("20873554875923477449109855954682643681001", "1"), Fraction("509111094534718962173411120845918138561", "1"), Fraction("12417343769139486882278320020632149721", "1"), Fraction("302862043149743582494593171234930481", "1"), Fraction("7386879101213258109624223688656841", "1"), Fraction("180167782956420929503029846064801", "1"), Fraction("4394336169668803158610484050361", "1"), Fraction("107178930967531784356353269521", "1"), Fraction("2614120267500775228203738281", "1"), Fraction("63759030914653054346432641", "1"), Fraction("1555098314991537910888601", "1"), Fraction("37929227194915558802161", "1"), Fraction("925103102315013629321", "1"), Fraction("22563490300366186081", "1"), Fraction("550329031716248441", "1"), Fraction("13422659310152401", "1"), Fraction("327381934393961", "1"), Fraction("7984925229121", "1"), Fraction("194754273881", "1"), Fraction("4750104241", "1"), Fraction("115856201", "1"), Fraction("2825761", "1"), Fraction("68921", "1"), Fraction("1681", "1"), Fraction("41", "1"), Fraction("1", "1"), Fraction("67818433", "1")}, {Fraction("126765060022822940149670320537600000000000000000000000000000000000000000000000000", "1"), Fraction("3169126500570573503741758013440000000000000000000000000000000000000000000000000", "1"), Fraction("79228162514264337593543950336000000000000000000000000000000000000000000000000", "1"), Fraction("1980704062856608439838598758400000000000000000000000000000000000000000000000", "1"), Fraction("49517601571415210995964968960000000000000000000000000000000000000000000000", "1"), Fraction("1237940039285380274899124224000000000000000000000000000000000000000000000", "1"), Fraction("30948500982134506872478105600000000000000000000000000000000000000000000", "1"), Fraction("773712524553362671811952640000000000000000000000000000000000000000000", "1"), Fraction("19342813113834066795298816000000000000000000000000000000000000000000", "1"), Fraction("483570327845851669882470400000000000000000000000000000000000000000", "1"), Fraction("12089258196146291747061760000000000000000000000000000000000000000", "1"), Fraction("302231454903657293676544000000000000000000000000000000000000000", "1"), Fraction("7555786372591432341913600000000000000000000000000000000000000", "1"), Fraction("188894659314785808547840000000000000000000000000000000000000", "1"), Fraction("4722366482869645213696000000000000000000000000000000000000", "1"), Fraction("118059162071741130342400000000000000000000000000000000000", "1"), Fraction("2951479051793528258560000000000000000000000000000000000", "1"), Fraction("73786976294838206464000000000000000000000000000000000", "1"), Fraction("1844674407370955161600000000000000000000000000000000", "1"), Fraction("46116860184273879040000000000000000000000000000000", "1"), Fraction("1152921504606846976000000000000000000000000000000", "1"), Fraction("28823037615171174400000000000000000000000000000", "1"), Fraction("720575940379279360000000000000000000000000000", "1"), Fraction("18014398509481984000000000000000000000000000", "1"), Fraction("450359962737049600000000000000000000000000", "1"), Fraction("11258999068426240000000000000000000000000", "1"), Fraction("281474976710656000000000000000000000000", "1"), Fraction("7036874417766400000000000000000000000", "1"), Fraction("175921860444160000000000000000000000", "1"), Fraction("4398046511104000000000000000000000", "1"), Fraction("109951162777600000000000000000000", "1"), Fraction("2748779069440000000000000000000", "1"), Fraction("68719476736000000000000000000", "1"), Fraction("1717986918400000000000000000", "1"), Fraction("42949672960000000000000000", "1"), Fraction("1073741824000000000000000", "1"), Fraction("26843545600000000000000", "1"), Fraction("671088640000000000000", "1"), Fraction("16777216000000000000", "1"), Fraction("419430400000000000", "1"), Fraction("10485760000000000", "1"), Fraction("262144000000000", "1"), Fraction("6553600000000", "1"), Fraction("163840000000", "1"), Fraction("4096000000", "1"), Fraction("102400000", "1"), Fraction("2560000", "1"), Fraction("64000", "1"), Fraction("1600", "1"), Fraction("40", "1"), Fraction("1", "1"), Fraction("61440165", "1")}, {Fraction("35746238718968309426816568571460866163394039231362700613798165973818878491558001", "1"), Fraction("916570223563289985302988937729765799061385621316992323430722204456894320296359", "1"), Fraction("23501800604186922700076639428968353822086810802999803164890312934792162058881", "1"), Fraction("602610271902228787181452293050470610822738738538456491407443921404927232279", "1"), Fraction("15451545433390481722601340847447964380070224065088627984806254394998134161", "1"), Fraction("396193472651037992887213867883281137950518565771503281661698830640977799", "1"), Fraction("10158806991052256227877278663673875332064578609525725170812790529255841", "1"), Fraction("260482230539801441740443042658304495693963554090403209508020269980919", "1"), Fraction("6679031552302601070267770324571910145999065489497518192513340255921", "1"), Fraction("171257219289810283853019751912100260153822192038397902372136929639", "1"), Fraction("4391210751020776509051788510566673337277492103548664163388126401", "1"), Fraction("112595147462071192539789448988889059930192105219196517009951959", "1"), Fraction("2887055063130030577943319204843309228979284749210167102819281", "1"), Fraction("74027052900770014819059466790854082794340634595132489815879", "1"), Fraction("1898129561558205508181011968996258533188221399875192046561", "1"), Fraction("48669988757902705337974665871698936748415933330133129399", "1"), Fraction("1247948429689812957383965791582024019190152136670080241", "1"), Fraction("31998677684354178394460661322616000492055182991540519", "1"), Fraction("820478914983440471652837469810666679283466230552321", "1"), Fraction("21037920897011294144944550507965812289319646937239", "1"), Fraction("539433869154135747306270525845277238187683254801", "1"), Fraction("13831637670618865315545398098596852261222647559", "1"), Fraction("354657376169714495270394823040944929774939681", "1"), Fraction("9093778876146525519753713411306280250639479", "1"), Fraction("233173817337090397942402907982212314118961", "1"), Fraction("5978815829156164049805202768774674720999", "1"), Fraction("153302969978363180764235968430119864641", "1"), Fraction("3930845384060594378570153036669740119", "1"), Fraction("100790907283604984065901359914608721", "1"), Fraction("2584382238041153437587214356784839", "1"), Fraction("66266211231824447117620880943201", "1"), Fraction("1699133621328831977374894383159", "1"), Fraction("43567528752021332753202420081", "1"), Fraction("1117116121846700839825703079", "1"), Fraction("28644003124274380508351361", "1"), Fraction("734461618571137961752599", "1"), Fraction("18832349194131742609041", "1"), Fraction("482880748567480579719", "1"), Fraction("12381557655576425121", "1"), Fraction("317475837322472439", "1"), Fraction("8140406085191601", "1"), Fraction("208728361158759", "1"), Fraction("5352009260481", "1"), Fraction("137231006679", "1"), Fraction("3518743761", "1"), Fraction("90224199", "1"), Fraction("2313441", "1"), Fraction("59319", "1"), Fraction("1521", "1"), Fraction("39", "1"), Fraction("1", "1"), Fraction("55522745", "1")}, {Fraction("9753934409407192353813974248397136611840748841936794487146262206775534890778624", "1"), Fraction("256682484458084009310894059168345700311598653735178802293322689651987760283648", "1"), Fraction("6754802222581158139760369978114360534515754045662600060350597096104941060096", "1"), Fraction("177757953225819951046325525739851593013572474885857896325015713055393185792", "1"), Fraction("4677840874363682922271724361575041921409801970680470955921466133036662784", "1"), Fraction("123101075641149550586098009515132682142363209754749235682143845606227968", "1"), Fraction("3239501990556567120686789724082439003746400256703927254793259094900736", "1"), Fraction("85250052383067555807547098002169447467010533071155980389296291971072", "1"), Fraction("2243422431133356731777555210583406512289750870293578431297270841344", "1"), Fraction("59037432398246229783619873962721224007625022902462590297296601088", "1"), Fraction("1553616642059111310095259841124242737042763760591120797297278976", "1"), Fraction("40884648475239771318296311608532703606388520015555810455191552", "1"), Fraction("1075911801979993982060429252856123779115487368830416064610304", "1"), Fraction("28313468473157736370011296127792731029354930758695159595008", "1"), Fraction("745091275609414115000297266520861342877761335755135778816", "1"), Fraction("19607665147616160921060454382127930075730561467240415232", "1"), Fraction("515991188095162129501590904792840265150804249137905664", "1"), Fraction("13578715476188477092147129073495796451336953924681728", "1"), Fraction("357334617794433607688082344039363064508867208544256", "1"), Fraction("9403542573537726518107430106299028013391242330112", "1"), Fraction("247461646672045434687037634376290210878716903424", "1"), Fraction("6512148596632774597027306167797110812597813248", "1"), Fraction("171372331490336173605981741257818705594679296", "1"), Fraction("4509798197114109831736361612047860673544192", "1"), Fraction("118678899924055521887798989790733175619584", "1"), Fraction("3123128945369882154942078678703504621568", "1"), Fraction("82187603825523214603738912597460647936", "1"), Fraction("2162831679619031963256287173617385472", "1"), Fraction("56916623147869262190954925621510144", "1"), Fraction("1497805872312349005025129621618688", "1"), Fraction("39415944008219710658556042674176", "1"), Fraction("1037261684426834491014632701952", "1"), Fraction("27296360116495644500385071104", "1"), Fraction("718325266223569592115396608", "1"), Fraction("18903296479567620845142016", "1"), Fraction("497455170514937390661632", "1"), Fraction("13090925539866773438464", "1"), Fraction("344498040522809827328", "1"), Fraction("9065737908494995456", "1"), Fraction("238572050223552512", "1"), Fraction("6278211847988224", "1"), Fraction("165216101262848", "1"), Fraction("4347792138496", "1"), Fraction("114415582592", "1"), Fraction("3010936384", "1"), Fraction("79235168", "1"), Fraction("2085136", "1"), Fraction("54872", "1"), Fraction("1444", "1"), Fraction("38", "1"), Fraction("1", "1"), Fraction("50043421", "1")}, {Fraction("2570906032674836362493098841827039250513722520868666904498196035555315023364249", "1"), Fraction("69483946829049631418732401130460520284154662726180186608059352312305811442277", "1"), Fraction("1877944508893233281587362192715149196869044938545410448866468981413670579521", "1"), Fraction("50755256997114413015874653857166194509974187528254336455850513011180285933", "1"), Fraction("1371763702624713865293909563707194446215518581844711796104067919221088809", "1"), Fraction("37074694665532807170105663883978228276095096806613832327136970789759157", "1"), Fraction("1002018774744129923516369294161573737191759373151725198030728940263761", "1"), Fraction("27081588506598106040982953896258749653831334409506086433262944331453", "1"), Fraction("731934824502651514621160916115101341995441470527191525223322819769", "1"), Fraction("19782022283855446341112457192300036270147066771005176357387103237", "1"), Fraction("534649250915012063273309653845946926220190993810950712361813601", "1"), Fraction("14449979754459785493873233887728295303248405238133803036805773", "1"), Fraction("390539993363777986320898213181845819006713655084697379373129", "1"), Fraction("10555134955777783414078330085995832946127396083370199442517", "1"), Fraction("285273917723723876056171083405292782327767461712708093041", "1"), Fraction("7710105884424969623139759010953858981831553019262380893", "1"), Fraction("208381240119593773598371865160915107617069000520604889", "1"), Fraction("5631925408637669556712753112457165070731594608664997", "1"), Fraction("152214200233450528559804138174517974884637692126081", "1"), Fraction("4113897303606771042156868599311296618503721408813", "1"), Fraction("111186413610993811950185637819224232932533011049", "1"), Fraction("3005038205702535458113125346465519808987378677", "1"), Fraction("81217248802771228597652036390959994837496721", "1"), Fraction("2195060778453276448585190172728648509121533", "1"), Fraction("59325966985223687799599734398071581327609", "1"), Fraction("1603404513114153724313506335083015711557", "1"), Fraction("43335257111193343900365036083324748961", "1"), Fraction("1171223165167387672982838813062831053", "1"), Fraction("31654680139659126296833481434130569", "1"), Fraction("855531895666462872887391390111637", "1"), Fraction("23122483666661158726686253786801", "1"), Fraction("624931990990842127748277129373", "1"), Fraction("16890053810563300749953435929", "1"), Fraction("456487940826035155404146917", "1"), Fraction("12337511914217166362274241", "1"), Fraction("333446267951815307088493", "1"), Fraction("9012061295995008299689", "1"), Fraction("243569224216081305397", "1"), Fraction("6582952005840035281", "1"), Fraction("177917621779460413", "1"), Fraction("4808584372417849", "1"), Fraction("129961739795077", "1"), Fraction("3512479453921", "1"), Fraction("94931877133", "1"), Fraction("2565726409", "1"), Fraction("69343957", "1"), Fraction("1874161", "1"), Fraction("50653", "1"), Fraction("1369", "1"), Fraction("37", "1"), Fraction("1", "1"), Fraction("44980017", "1")}, {Fraction("653318623500070906096690267158057820537143710472954871543071966369497141477376", "1"), Fraction("18147739541668636280463618532168272792698436402026524209529776843597142818816", "1"), Fraction("504103876157462118901767181449118688686067677834070116931382690099920633856", "1"), Fraction("14002885448818392191715755040253296907946324384279725470316185836108906496", "1"), Fraction("388969040244955338658770973340369358554064566229992374175449606558580736", "1"), Fraction("10804695562359870518299193703899148848724015728610899282651377959960576", "1"), Fraction("300130432287774181063866491774976356909000436905858313406982721110016", "1"), Fraction("8336956452438171696218513660416009914138901025162730927971742253056", "1"), Fraction("231582123678838102672736490567111386503858361810075859110326173696", "1"), Fraction("6432836768856613963131569182419760736218287828057662753064615936", "1"), Fraction("178689910246017054531432477289437798228285773001601743140683776", "1"), Fraction("4963608617944918181428679924706605506341271472266715087241216", "1"), Fraction("137878017165136616150796664575183486287257540896297641312256", "1"), Fraction("3829944921253794893077685127088430174646042802674934480896", "1"), Fraction("106387358923716524807713475752456393740167855629859291136", "1"), Fraction("2955204414547681244658707659790455381671329323051646976", "1"), Fraction("82089011515213367907186323883068205046425814529212416", "1"), Fraction("2280250319867037997421842330085227917956272625811456", "1"), Fraction("63340286662973277706162286946811886609896461828096", "1"), Fraction("1759452407304813269615619081855885739163790606336", "1"), Fraction("48873677980689257489322752273774603865660850176", "1"), Fraction("1357602166130257152481187563160405662935023616", "1"), Fraction("37711171281396032013366321198900157303750656", "1"), Fraction("1047532535594334222593508922191671036215296", "1"), Fraction("29098125988731506183153025616435306561536", "1"), Fraction("808281277464764060643139600456536293376", "1"), Fraction("22452257707354557240087211123792674816", "1"), Fraction("623673825204293256669089197883129856", "1"), Fraction("17324272922341479351919144385642496", "1"), Fraction("481229803398374426442198455156736", "1"), Fraction("13367494538843734067838845976576", "1"), Fraction("371319292745659279662190166016", "1"), Fraction("10314424798490535546171949056", "1"), Fraction("286511799958070431838109696", "1"), Fraction("7958661109946400884391936", "1"), Fraction("221073919720733357899776", "1"), Fraction("6140942214464815497216", "1"), Fraction("170581728179578208256", "1"), Fraction("4738381338321616896", "1"), Fraction("131621703842267136", "1"), Fraction("3656158440062976", "1"), Fraction("101559956668416", "1"), Fraction("2821109907456", "1"), Fraction("78364164096", "1"), Fraction("2176782336", "1"), Fraction("60466176", "1"), Fraction("1679616", "1"), Fraction("46656", "1"), Fraction("1296", "1"), Fraction("36", "1"), Fraction("1", "1"), Fraction("40310933", "1")}, {Fraction("159735783946449685066351550639187570834853691081889337510801851749420166015625", "1"), Fraction("4563879541327133859038615732548216309567248316625409643165767192840576171875", "1"), Fraction("130396558323632395972531878072806180273349951903583132661879062652587890625", "1"), Fraction("3725615952103782742072339373508748007809998625816660933196544647216796875", "1"), Fraction("106446170060108078344923982100249943080285675023333169519901275634765625", "1"), Fraction("3041319144574516524140685202864284088008162143523804843425750732421875", "1"), Fraction("86894832702129043546876720081836688228804632672108709812164306640625", "1"), Fraction("2482709505775115529910763430909619663680132362060248851776123046875", "1"), Fraction("70934557307860443711736098025989133248003781773149967193603515625", "1"), Fraction("2026701637367441248906745657885403807085822336375713348388671875", "1"), Fraction("57905761067641178540192733082440108773880638182163238525390625", "1"), Fraction("1654450316218319386862649516641145964968018233776092529296875", "1"), Fraction("47270009034809125338932843332604170427657663822174072265625", "1"), Fraction("1350571686708832152540938380931547726504504680633544921875", "1"), Fraction("38587762477395204358312525169472792185842990875244140625", "1"), Fraction("1102507499354148695951786433413508348166942596435546875", "1"), Fraction("31500214267261391312908183811814524233341217041015625", "1"), Fraction("900006121921754037511662394623272120952606201171875", "1"), Fraction("25714460626335829643190354132093489170074462890625", "1"), Fraction("734698875038166561234010118059813976287841796875", "1"), Fraction("20991396429661901749543146230280399322509765625", "1"), Fraction("599754183704625764272661320865154266357421875", "1"), Fraction("17135833820132164693504609167575836181640625", "1"), Fraction("489595252003776134100131690502166748046875", "1"), Fraction("13988435771536460974289476871490478515625", "1"), Fraction("399669593472470313551127910614013671875", "1"), Fraction("11419131242070580387175083160400390625", "1"), Fraction("326260892630588011062145233154296875", "1"), Fraction("9321739789445371744632720947265625", "1"), Fraction("266335422555582049846649169921875", "1"), Fraction("7609583501588058567047119140625", "1"), Fraction("217416671473944530487060546875", "1"), Fraction("6211904899255558013916015625", "1"), Fraction("177482997121587371826171875", "1"), Fraction("5070942774902496337890625", "1"), Fraction("144884079282928466796875", "1"), Fraction("4139545122369384765625", "1"), Fraction("118272717781982421875", "1"), Fraction("3379220508056640625", "1"), Fraction("96549157373046875", "1"), Fraction("2758547353515625", "1"), Fraction("78815638671875", "1"), Fraction("2251875390625", "1"), Fraction("64339296875", "1"), Fraction("1838265625", "1"), Fraction("52521875", "1"), Fraction("1500625", "1"), Fraction("42875", "1"), Fraction("1225", "1"), Fraction("35", "1"), Fraction("1", "1"), Fraction("36015145", "1")}, {Fraction("37492625348170371777370847524933279225453074113982960068676870198800863461376", "1"), Fraction("1102724274946187405216789633086272918395678650411263531431672652905907748864", "1"), Fraction("32433066910181982506376165679008027011637607365037162689166842732526698496", "1"), Fraction("953913732652411250187534284676706676812870804854034196740201256839020544", "1"), Fraction("28056286254482683829045126019903137553319729554530417551182389907030016", "1"), Fraction("825184889837725994971915471173621692744697928074424045623011467853824", "1"), Fraction("24270143818756646910938690328635932139549939061012471930088572583936", "1"), Fraction("713827759375195497380549715548115651163233501794484468532016840704", "1"), Fraction("20994934099270455805310285751415166210683338288073072603882848256", "1"), Fraction("617498061743248700156184875041622535608333479060972723643613184", "1"), Fraction("18161707698330844122240731618871251047303925854734491871870976", "1"), Fraction("534167873480318944771786224084448560214821348668661525643264", "1"), Fraction("15710819808244674846229006590719075300435922019666515460096", "1"), Fraction("462082935536608083712617840903502214718703588813721042944", "1"), Fraction("13590674574606120109194642379514771021138340847462383616", "1"), Fraction("399725722782532944388077717044552088857010024925364224", "1"), Fraction("11756638905368616011414050501310355554617941909569536", "1"), Fraction("345783497216724000335707367685598692782880644399104", "1"), Fraction("10170102859315411774579628461341138023025901305856", "1"), Fraction("299120672332806228664106719451209941853702979584", "1"), Fraction("8797666833317830254826668219153233583932440576", "1"), Fraction("258754906862289125141960829975095105409777664", "1"), Fraction("7610438437126150739469436175738091335581696", "1"), Fraction("223836424621357374690277534580532098105344", "1"), Fraction("6583424253569334549714045134721532297216", "1"), Fraction("193630125104980427932766033374162714624", "1"), Fraction("5695003679558247880375471569828315136", "1"), Fraction("167500108222301408246337399112597504", "1"), Fraction("4926473771244159066068747032723456", "1"), Fraction("144896287389534090178492559785984", "1"), Fraction("4261655511456885005249781170176", "1"), Fraction("125342809160496617801464152064", "1"), Fraction("3686553210602841700043063296", "1"), Fraction("108428035605965932354207744", "1"), Fraction("3189059870763703892770816", "1"), Fraction("93795878551873643905024", "1"), Fraction("2758702310349224820736", "1"), Fraction("81138303245565435904", "1"), Fraction("2386420683693101056", "1"), Fraction("70188843638032384", "1"), Fraction("2064377754059776", "1"), Fraction("60716992766464", "1"), Fraction("1785793904896", "1"), Fraction("52523350144", "1"), Fraction("1544804416", "1"), Fraction("45435424", "1"), Fraction("1336336", "1"), Fraction("39304", "1"), Fraction("1156", "1"), Fraction("34", "1"), Fraction("1", "1"), Fraction("32072205", "1")}, {Fraction("8427465705576358635622839396817058164066162897508094340376170494254080797249", "1"), Fraction("255377748653829049564328466570213883759580693863881646678065772553153963553", "1"), Fraction("7738719656176637865585711108188299507866081632238837778123205228883453441", "1"), Fraction("234506656247776905017748821460251500238366110067843569034036522087377377", "1"), Fraction("7106262310538694091446933983643984855708063941449805122243530972344769", "1"), Fraction("215341282137536184589301029807393480476001937619691064310410029464993", "1"), Fraction("6525493398107157108766697872951317590181876897566395888194243317121", "1"), Fraction("197742224185065366932324177968221745157026572653527148127098282337", "1"), Fraction("5992188611668647482797702362673386216879593110712943882639341889", "1"), Fraction("181581473080868105539324314020405642935745245779180117655737633", "1"), Fraction("5502468881238427440585585273345625543507431690278185383507201", "1"), Fraction("166741481249649316381381371919564410409316111826611678288097", "1"), Fraction("5052772159080282314587314300592860921494427631109444796609", "1"), Fraction("153114307850917645896585281836147300651346291851801357473", "1"), Fraction("4639827510633868057472281267762039413677160359145495681", "1"), Fraction("140600833655571759317341856598849679202338192701378657", "1"), Fraction("4260631322896113918707328987843929672798127051556929", "1"), Fraction("129110040087761027839616029934664535539337183380513", "1"), Fraction("3912425457204879631503516058626198046646581314561", "1"), Fraction("118558347188026655500106547231096910504441858017", "1"), Fraction("3592677187515959257578986279730209409225510849", "1"), Fraction("108869005682301795684211705446369982097742753", "1"), Fraction("3299060778251569566188233498374847942355841", "1"), Fraction("99971538734896047460249499950752967950177", "1"), Fraction("3029440567724122650310590907598574786369", "1"), Fraction("91801229324973413645775482048441660193", "1"), Fraction("2781855434090103443811378243892171521", "1"), Fraction("84298649517881922539738734663399137", "1"), Fraction("2554504530844906743628446504951489", "1"), Fraction("77409228207421416473589288028833", "1"), Fraction("2345734188103679287078463273601", "1"), Fraction("71082854184959978396317068897", "1"), Fraction("2154025884392726618070214209", "1"), Fraction("65273511648264442971824673", "1"), Fraction("1977985201462558877934081", "1"), Fraction("59938945498865420543457", "1"), Fraction("1816331681783800622529", "1"), Fraction("55040353993448503713", "1"), Fraction("1667889514952984961", "1"), Fraction("50542106513726817", "1"), Fraction("1531578985264449", "1"), Fraction("46411484401953", "1"), Fraction("1406408618241", "1"), Fraction("42618442977", "1"), Fraction("1291467969", "1"), Fraction("39135393", "1"), Fraction("1185921", "1"), Fraction("35937", "1"), Fraction("1089", "1"), Fraction("33", "1"), Fraction("1", "1"), Fraction("28462241", "1")}, {Fraction("1809251394333065553493296640760748560207343510400633813116524750123642650624", "1"), Fraction("56539106072908298546665520023773392506479484700019806659891398441363832832", "1"), Fraction("1766847064778384329583297500742918515827483896875618958121606201292619776", "1"), Fraction("55213970774324510299478046898216203619608871777363092441300193790394368", "1"), Fraction("1725436586697640946858688965569256363112777243042596638790631055949824", "1"), Fraction("53919893334301279589334030174039261347274288845081144962207220498432", "1"), Fraction("1684996666696914987166688442938726917102321526408785780068975640576", "1"), Fraction("52656145834278593348959013841835216159447547700274555627155488768", "1"), Fraction("1645504557321206042154969182557350504982735865633579863348609024", "1"), Fraction("51422017416287688817342786954917203280710495801049370729644032", "1"), Fraction("1606938044258990275541962092341162602522202993782792835301376", "1"), Fraction("50216813883093446110686315385661331328818843555712276103168", "1"), Fraction("1569275433846670190958947355801916604025588861116008628224", "1"), Fraction("49039857307708443467467104868809893875799651909875269632", "1"), Fraction("1532495540865888858358347027150309183618739122183602176", "1"), Fraction("47890485652059026823698344598447161988085597568237568", "1"), Fraction("1496577676626844588240573268701473812127674924007424", "1"), Fraction("46768052394588893382517914646921056628989841375232", "1"), Fraction("1461501637330902918203684832716283019655932542976", "1"), Fraction("45671926166590716193865151022383844364247891968", "1"), Fraction("1427247692705959881058285969449495136382746624", "1"), Fraction("44601490397061246283071436545296723011960832", "1"), Fraction("1393796574908163946345982392040522594123776", "1"), Fraction("43556142965880123323311949751266331066368", "1"), Fraction("1361129467683753853853498429727072845824", "1"), Fraction("42535295865117307932921825928971026432", "1"), Fraction("1329227995784915872903807060280344576", "1"), Fraction("41538374868278621028243970633760768", "1"), Fraction("1298074214633706907132624082305024", "1"), Fraction("40564819207303340847894502572032", "1"), Fraction("1267650600228229401496703205376", "1"), Fraction("39614081257132168796771975168", "1"), Fraction("1237940039285380274899124224", "1"), Fraction("38685626227668133590597632", "1"), Fraction("1208925819614629174706176", "1"), Fraction("37778931862957161709568", "1"), Fraction("1180591620717411303424", "1"), Fraction("36893488147419103232", "1"), Fraction("1152921504606846976", "1"), Fraction("36028797018963968", "1"), Fraction("1125899906842624", "1"), Fraction("35184372088832", "1"), Fraction("1099511627776", "1"), Fraction("34359738368", "1"), Fraction("1073741824", "1"), Fraction("33554432", "1"), Fraction("1048576", "1"), Fraction("32768", "1"), Fraction("1024", "1"), Fraction("32", "1"), Fraction("1", "1"), Fraction("25165957", "1")}, {Fraction("369900306960760058257055122792882737298592289523754278027523770486241304001", "1"), Fraction("11932267966476130911517907186867185074148138371734008968629799047943267871", "1"), Fraction("384911869886326803597351844737651131424133495862387386084832227353008641", "1"), Fraction("12416511931816993664430704668956488110455919221367335034994587979129311", "1"), Fraction("400532642961838505304216279643757680982449007140881775322406063842881", "1"), Fraction("12920407837478661461426331601411538096208032488415541139432453672351", "1"), Fraction("416787349596085853594397793593920583748646209303727133530079150721", "1"), Fraction("13444753212776963019174122373997438185440200300120230113873520991", "1"), Fraction("433701716541192355457229753999917360820651622584523552060436161", "1"), Fraction("13990377952941688885717088838707011639375858793049146840659231", "1"), Fraction("451302514611022222119906091571193923850834154614488607763201", "1"), Fraction("14558145632613620068384067470038513672607553374660922831071", "1"), Fraction("469617601052052260270453789356081086213146883053578155841", "1"), Fraction("15148954872646847105498509334067131813327318808179940511", "1"), Fraction("488675963633769261467693849486036510107332864779998081", "1"), Fraction("15763740762379653595732059660839887422817189186451551", "1"), Fraction("508507766528375922442969666478706045897328683433921", "1"), Fraction("16403476339625029756224827950926001480558989788191", "1"), Fraction("529144398052420314716929933900838757437386767361", "1"), Fraction("17069174130723235958610643029059314756044734431", "1"), Fraction("550618520345910837374536871905139185678862401", "1"), Fraction("17761887753093897979823770061456102763834271", "1"), Fraction("572964121067545096123347421337293637543041", "1"), Fraction("18482713582824035358817658752815923791711", "1"), Fraction("596216567187872108348956733961803993281", "1"), Fraction("19232792489931358333837313998767870751", "1"), Fraction("620412660965527688188300451573157121", "1"), Fraction("20013311644049280264138724244295391", "1"), Fraction("645590698195138073036733040138561", "1"), Fraction("20825506393391550743120420649631", "1"), Fraction("671790528819082282036142601601", "1"), Fraction("21670662219970396194714277471", "1"), Fraction("699053619999045038539170241", "1"), Fraction("22550116774162743178682911", "1"), Fraction("727423121747185263828481", "1"), Fraction("23465261991844685929951", "1"), Fraction("756943935220796320321", "1"), Fraction("24417546297445042591", "1"), Fraction("787662783788549761", "1"), Fraction("25408476896404831", "1"), Fraction("819628286980801", "1"), Fraction("26439622160671", "1"), Fraction("852891037441", "1"), Fraction("27512614111", "1"), Fraction("887503681", "1"), Fraction("28629151", "1"), Fraction("923521", "1"), Fraction("29791", "1"), Fraction("961", "1"), Fraction("31", "1"), Fraction("1", "1"), Fraction("22164633", "1")}, {Fraction("71789798769185258877024900000000000000000000000000000000000000000000000000", "1"), Fraction("2392993292306175295900830000000000000000000000000000000000000000000000000", "1"), Fraction("79766443076872509863361000000000000000000000000000000000000000000000000", "1"), Fraction("2658881435895750328778700000000000000000000000000000000000000000000000", "1"), Fraction("88629381196525010959290000000000000000000000000000000000000000000000", "1"), Fraction("2954312706550833698643000000000000000000000000000000000000000000000", "1"), Fraction("98477090218361123288100000000000000000000000000000000000000000000", "1"), Fraction("3282569673945370776270000000000000000000000000000000000000000000", "1"), Fraction("109418989131512359209000000000000000000000000000000000000000000", "1"), Fraction("3647299637717078640300000000000000000000000000000000000000000", "1"), Fraction("121576654590569288010000000000000000000000000000000000000000", "1"), Fraction("4052555153018976267000000000000000000000000000000000000000", "1"), Fraction("135085171767299208900000000000000000000000000000000000000", "1"), Fraction("4502839058909973630000000000000000000000000000000000000", "1"), Fraction("150094635296999121000000000000000000000000000000000000", "1"), Fraction("5003154509899970700000000000000000000000000000000000", "1"), Fraction("166771816996665690000000000000000000000000000000000", "1"), Fraction("5559060566555523000000000000000000000000000000000", "1"), Fraction("185302018885184100000000000000000000000000000000", "1"), Fraction("6176733962839470000000000000000000000000000000", "1"), Fraction("205891132094649000000000000000000000000000000", "1"), Fraction("6863037736488300000000000000000000000000000", "1"), Fraction("228767924549610000000000000000000000000000", "1"), Fraction("7625597484987000000000000000000000000000", "1"), Fraction("254186582832900000000000000000000000000", "1"), Fraction("8472886094430000000000000000000000000", "1"), Fraction("282429536481000000000000000000000000", "1"), Fraction("9414317882700000000000000000000000", "1"), Fraction("313810596090000000000000000000000", "1"), Fraction("10460353203000000000000000000000", "1"), Fraction("348678440100000000000000000000", "1"), Fraction("11622614670000000000000000000", "1"), Fraction("387420489000000000000000000", "1"), Fraction("12914016300000000000000000", "1"), Fraction("430467210000000000000000", "1"), Fraction("14348907000000000000000", "1"), Fraction("478296900000000000000", "1"), Fraction("15943230000000000000", "1"), Fraction("531441000000000000", "1"), Fraction("17714700000000000", "1"), Fraction("590490000000000", "1"), Fraction("19683000000000", "1"), Fraction("656100000000", "1"), Fraction("21870000000", "1"), Fraction("729000000", "1"), Fraction("24300000", "1"), Fraction("810000", "1"), Fraction("27000", "1"), Fraction("900", "1"), Fraction("30", "1"), Fraction("1", "1"), Fraction("19440125", "1")}, {Fraction("13179529148667419313752621434193363370806933128742294644974969657446901001", "1"), Fraction("454466522367842045301814532213564254165756314784217056723274815774031069", "1"), Fraction("15671259391994553286269466628053939798819183268421277818043959164621761", "1"), Fraction("540388254896363906423085056139791027545489078221423373035998591883509", "1"), Fraction("18634077755047031255968450211716931984327209593842185277103399720121", "1"), Fraction("642554405346449353654084490059204551183696882546282250934599990349", "1"), Fraction("22157048460222391505313258277903605213230926984354560377055172081", "1"), Fraction("764036153800772120872870975100124317697618171874295185415695589", "1"), Fraction("26346074268992142099064516382762907506814419719803282255713641", "1"), Fraction("908485319620418693071190220095272672648773093786320077783229", "1"), Fraction("31327079986910989416247938623974919746509417027114485440801", "1"), Fraction("1080244137479689290215446159447411025741704035417740877269", "1"), Fraction("37249797844127216903980902049910725025576001221301409561", "1"), Fraction("1284475787728524720826927656893473276744000042113841709", "1"), Fraction("44292268542362921407825091617016319887724139383235921", "1"), Fraction("1527319604909066255442244538517804134059453082180549", "1"), Fraction("52666193272726422601456708224751866691705278695881", "1"), Fraction("1816075630094014572464024421543167816955354437789", "1"), Fraction("62623297589448778360828428329074752308805325441", "1"), Fraction("2159424054808578564166497528588784562372597429", "1"), Fraction("74462898441675122902293018227199467668020601", "1"), Fraction("2567686153161211134561828214731016126483469", "1"), Fraction("88540901833145211536614766025207452637361", "1"), Fraction("3053134545970524535745336759489912159909", "1"), Fraction("105280501585190501232597819292755591721", "1"), Fraction("3630362123627258663193028251474330749", "1"), Fraction("125184900814733057351483732809459681", "1"), Fraction("4316720717749415770740818372739989", "1"), Fraction("148852438543083302439338564577241", "1"), Fraction("5132842708382182842735812571629", "1"), Fraction("176994576151109753197786640401", "1"), Fraction("6103261246589991489578849669", "1"), Fraction("210457284365172120330305161", "1"), Fraction("7257147736730073114838109", "1"), Fraction("250246473680347348787521", "1"), Fraction("8629188747598184440949", "1"), Fraction("297558232675799463481", "1"), Fraction("10260628712958602189", "1"), Fraction("353814783205469041", "1"), Fraction("12200509765705829", "1"), Fraction("420707233300201", "1"), Fraction("14507145975869", "1"), Fraction("500246412961", "1"), Fraction("17249876309", "1"), Fraction("594823321", "1"), Fraction("20511149", "1"), Fraction("707281", "1"), Fraction("24389", "1"), Fraction("841", "1"), Fraction("29", "1"), Fraction("1", "1"), Fraction("16974865", "1")}, {Fraction("2279825290801480196406648025754245250165892545647714123325296883871514624", "1"), Fraction("81422331814338578443094572348365901791639019487418361547332031566839808", "1"), Fraction("2907940421940663515824806155298782206844250695979227198119001127387136", "1"), Fraction("103855015069309411279457362689242221673008953427829542789964325978112", "1"), Fraction("3709107681046764688552048667472936488321748336708197956784440213504", "1"), Fraction("132468131465955881734001738124033446011491012025292784170872864768", "1"), Fraction("4731004695212710061928633504429765928981821858046170863245459456", "1"), Fraction("168964453400453930783165482301063068892207923501648959401623552", "1"), Fraction("6034444764301926099398767225037966746150282982201748550057984", "1"), Fraction("215515884439354503549955972322784526648224392221491019644928", "1"), Fraction("7696995872834089412498427582956590237436585436481822130176", "1"), Fraction("274892709744074621874943842248449651337020908445779361792", "1"), Fraction("9817596776574093638390851508873201833465032444492120064", "1"), Fraction("350628456306217629942530411031185779766608301589004288", "1"), Fraction("12522444868079201069376086108256634991664582199607296", "1"), Fraction("447230173859971466763431646723451249702306507128832", "1"), Fraction("15972506209284695241551130240123258917939518111744", "1"), Fraction("570446650331596258626826080004402104212125646848", "1"), Fraction("20373094654699866379529502857300075150433058816", "1"), Fraction("727610523382138084983196530617859826801180672", "1"), Fraction("25986090120790645892257018950637850957185024", "1"), Fraction("928074647171094496152036391094208962756608", "1"), Fraction("33145523113253374862572728253364605812736", "1"), Fraction("1183768682616191959377597437620164493312", "1"), Fraction("42277452950578284263485622772148731904", "1"), Fraction("1509909033949224437981629384719597568", "1"), Fraction("53925322641043729927915335168557056", "1"), Fraction("1925904380037276068854119113162752", "1"), Fraction("68782299287045573887647111184384", "1"), Fraction("2456510688823056210273111113728", "1"), Fraction("87732524600823436081182539776", "1"), Fraction("3133304450029408431470804992", "1"), Fraction("111903730358193158266814464", "1"), Fraction("3996561798506898509529088", "1"), Fraction("142734349946674946768896", "1"), Fraction("5097655355238390956032", "1"), Fraction("182059119829942534144", "1"), Fraction("6502111422497947648", "1"), Fraction("232218265089212416", "1"), Fraction("8293509467471872", "1"), Fraction("296196766695424", "1"), Fraction("10578455953408", "1"), Fraction("377801998336", "1"), Fraction("13492928512", "1"), Fraction("481890304", "1"), Fraction("17210368", "1"), Fraction("614656", "1"), Fraction("21952", "1"), Fraction("784", "1"), Fraction("28", "1"), Fraction("1", "1"), Fraction("14751861", "1")}, {Fraction("369988485035126972924700782451696644186473100389722973815184405301748249", "1"), Fraction("13703277223523221219433362313025801636536040755174924956117940937101787", "1"), Fraction("507528786056415600719754159741696356908742250191663887263627442114881", "1"), Fraction("18797362446533911137768672583025790996620083340431995824578794152403", "1"), Fraction("696198609130885597695136021593547814689632716312296141651066450089", "1"), Fraction("25785133671514281396116148947909178321838248752307264505595053707", "1"), Fraction("955004950796825236893190701774414011919935138974343129836853841", "1"), Fraction("35370553733215749514562618584237555997034634776827523327290883", "1"), Fraction("1310020508637620352391208095712502073964245732475093456566329", "1"), Fraction("48519278097689642681155855396759336072749841943521979872827", "1"), Fraction("1797010299914431210413179829509605039731475627537851106401", "1"), Fraction("66555937033867822607895549241096482953017615834735226163", "1"), Fraction("2465034704958067503996131453373943813074726512397600969", "1"), Fraction("91297581665113611259115979754590511595360241199911147", "1"), Fraction("3381391913522726342930221472392241170198527451848561", "1"), Fraction("125236737537878753441860054533045969266612127846243", "1"), Fraction("4638397686588101979328150167890591454318967698009", "1"), Fraction("171792506910670443678820376588540424234035840667", "1"), Fraction("6362685441135942358474828762538534230890216321", "1"), Fraction("235655016338368235499067731945871638181119123", "1"), Fraction("8727963568087712425891397479476727340041449", "1"), Fraction("323257909929174534292273980721360271853387", "1"), Fraction("11972515182562019788602740026717047105681", "1"), Fraction("443426488243037769948249630619149892803", "1"), Fraction("16423203268260658146231467800709255289", "1"), Fraction("608266787713357709119683992618861307", "1"), Fraction("22528399544939174411840147874772641", "1"), Fraction("834385168331080533771857328695283", "1"), Fraction("30903154382632612361920641803529", "1"), Fraction("1144561273430837494885949696427", "1"), Fraction("42391158275216203514294433201", "1"), Fraction("1570042899082081611640534563", "1"), Fraction("58149737003040059690390169", "1"), Fraction("2153693963075557766310747", "1"), Fraction("79766443076872509863361", "1"), Fraction("2954312706550833698643", "1"), Fraction("109418989131512359209", "1"), Fraction("4052555153018976267", "1"), Fraction("150094635296999121", "1"), Fraction("5559060566555523", "1"), Fraction("205891132094649", "1"), Fraction("7625597484987", "1"), Fraction("282429536481", "1"), Fraction("10460353203", "1"), Fraction("387420489", "1"), Fraction("14348907", "1"), Fraction("531441", "1"), Fraction("19683", "1"), Fraction("729", "1"), Fraction("27", "1"), Fraction("1", "1"), Fraction("12754697", "1")}, {Fraction("56061846576641933068511861128435847024473459936647893758520097689829376", "1"), Fraction("2156224868332382041096610043401378731710517689871072836866157603454976", "1"), Fraction("82931725705091616965254232438514566604250680379656647571775292440576", "1"), Fraction("3189681757888139114048239709173637177086564629986794137375972786176", "1"), Fraction("122680067611082273617239988814370660657175562691799774514460491776", "1"), Fraction("4718464138887779754509230339014256179122137026607683635171557376", "1"), Fraction("181479389957222298250355013039009853043159116407987832121982976", "1"), Fraction("6979976536816242240398269732269609732429196784922608927768576", "1"), Fraction("268460636031393932323010374318061912785738337881638804914176", "1"), Fraction("10325409078130535858577322089156227414836089918524569419776", "1"), Fraction("397131118389635994560666234198316439032157304558637285376", "1"), Fraction("15274273784216769021564085930704478424313742483024510976", "1"), Fraction("587472068623721885444772535796326093242836249347096576", "1"), Fraction("22595079562450841747875866761397157432416778821042176", "1"), Fraction("869041521632724682610610260053736824323722262347776", "1"), Fraction("33424673908950949331177317694374493243220087013376", "1"), Fraction("1285564381113498051199127603629788201662311038976", "1"), Fraction("49444783888980694276889523216530315448550424576", "1"), Fraction("1901722457268488241418827816020396748021170176", "1"), Fraction("73143171433403393900724146770015259539275776", "1"), Fraction("2813198901284745919258621029615971520741376", "1"), Fraction("108199957741720996894562347292921981566976", "1"), Fraction("4161536836220038342098551818958537752576", "1"), Fraction("160059109085386090080713531498405298176", "1"), Fraction("6156119580207157310796674288400203776", "1"), Fraction("236773830007967588876795164938469376", "1"), Fraction("9106685769537214956799814036094976", "1"), Fraction("350257144982200575261531309080576", "1"), Fraction("13471428653161560586981973426176", "1"), Fraction("518131871275444637960845131776", "1"), Fraction("19928148895209409152340197376", "1"), Fraction("766467265200361890474622976", "1"), Fraction("29479510200013918864408576", "1"), Fraction("1133827315385150725554176", "1"), Fraction("43608742899428874059776", "1"), Fraction("1677259342285725925376", "1"), Fraction("64509974703297150976", "1"), Fraction("2481152873203736576", "1"), Fraction("95428956661682176", "1"), Fraction("3670344486987776", "1"), Fraction("141167095653376", "1"), Fraction("5429503678976", "1"), Fraction("208827064576", "1"), Fraction("8031810176", "1"), Fraction("308915776", "1"), Fraction("11881376", "1"), Fraction("456976", "1"), Fraction("17576", "1"), Fraction("676", "1"), Fraction("26", "1"), Fraction("1", "1"), Fraction("10967533", "1")}, {Fraction("7888609052210118054117285652827862296732064351090230047702789306640625", "1"), Fraction("315544362088404722164691426113114491869282574043609201908111572265625", "1"), Fraction("12621774483536188886587657044524579674771302961744368076324462890625", "1"), Fraction("504870979341447555463506281780983186990852118469774723052978515625", "1"), Fraction("20194839173657902218540251271239327479634084738790988922119140625", "1"), Fraction("807793566946316088741610050849573099185363389551639556884765625", "1"), Fraction("32311742677852643549664402033982923967414535582065582275390625", "1"), Fraction("1292469707114105741986576081359316958696581423282623291015625", "1"), Fraction("51698788284564229679463043254372678347863256931304931640625", "1"), Fraction("2067951531382569187178521730174907133914530277252197265625", "1"), Fraction("82718061255302767487140869206996285356581211090087890625", "1"), Fraction("3308722450212110699485634768279851414263248443603515625", "1"), Fraction("132348898008484427979425390731194056570529937744140625", "1"), Fraction("5293955920339377119177015629247762262821197509765625", "1"), Fraction("211758236813575084767080625169910490512847900390625", "1"), Fraction("8470329472543003390683225006796419620513916015625", "1"), Fraction("338813178901720135627329000271856784820556640625", "1"), Fraction("13552527156068805425093160010874271392822265625", "1"), Fraction("542101086242752217003726400434970855712890625", "1"), Fraction("21684043449710088680149056017398834228515625", "1"), Fraction("867361737988403547205962240695953369140625", "1"), Fraction("34694469519536141888238489627838134765625", "1"), Fraction("1387778780781445675529539585113525390625", "1"), Fraction("55511151231257827021181583404541015625", "1"), Fraction("2220446049250313080847263336181640625", "1"), Fraction("88817841970012523233890533447265625", "1"), Fraction("3552713678800500929355621337890625", "1"), Fraction("142108547152020037174224853515625", "1"), Fraction("5684341886080801486968994140625", "1"), Fraction("227373675443232059478759765625", "1"), Fraction("9094947017729282379150390625", "1"), Fraction("363797880709171295166015625", "1"), Fraction("14551915228366851806640625", "1"), Fraction("582076609134674072265625", "1"), Fraction("23283064365386962890625", "1"), Fraction("931322574615478515625", "1"), Fraction("37252902984619140625", "1"), Fraction("1490116119384765625", "1"), Fraction("59604644775390625", "1"), Fraction("2384185791015625", "1"), Fraction("95367431640625", "1"), Fraction("3814697265625", "1"), Fraction("152587890625", "1"), Fraction("6103515625", "1"), Fraction("244140625", "1"), Fraction("9765625", "1"), Fraction("390625", "1"), Fraction("15625", "1"), Fraction("625", "1"), Fraction("25", "1"), Fraction("1", "1"), Fraction("9375105", "1")}, {Fraction("1024618246531448192529486101931556275808450117982966277666337116389376", "1"), Fraction("42692426938810341355395254247148178158685421582623594902764046516224", "1"), Fraction("1778851122450430889808135593631174089945225899275983120948501938176", "1"), Fraction("74118796768767953742005649734632253747717745803165963372854247424", "1"), Fraction("3088283198698664739250235405609677239488239408465248473868926976", "1"), Fraction("128678466612444364135426475233736551645343308686052019744538624", "1"), Fraction("5361602775518515172309436468072356318555971195252167489355776", "1"), Fraction("223400115646604798846226519503014846606498799802173645389824", "1"), Fraction("9308338151941866618592771645958951941937449991757235224576", "1"), Fraction("387847422997577775774698818581622997580727082989884801024", "1"), Fraction("16160309291565740657279117440900958232530295124578533376", "1"), Fraction("673346220481905860719963226704206593022095630190772224", "1"), Fraction("28056092520079410863331801112675274709253984591282176", "1"), Fraction("1169003855003308785972158379694803112885582691303424", "1"), Fraction("48708493958471199415506599153950129703565945470976", "1"), Fraction("2029520581602966642312774964747922070981914394624", "1"), Fraction("84563357566790276763032290197830086290913099776", "1"), Fraction("3523473231949594865126345424909586928788045824", "1"), Fraction("146811384664566452713597726037899455366168576", "1"), Fraction("6117141027690268863066571918245810640257024", "1"), Fraction("254880876153761202627773829926908776677376", "1"), Fraction("10620036506406716776157242913621199028224", "1"), Fraction("442501521100279865673218454734216626176", "1"), Fraction("18437563379178327736384102280592359424", "1"), Fraction("768231807465763655682670928358014976", "1"), Fraction("32009658644406818986777955348250624", "1"), Fraction("1333735776850284124449081472843776", "1"), Fraction("55572324035428505185378394701824", "1"), Fraction("2315513501476187716057433112576", "1"), Fraction("96479729228174488169059713024", "1"), Fraction("4019988717840603673710821376", "1"), Fraction("167499529910025153071284224", "1"), Fraction("6979147079584381377970176", "1"), Fraction("290797794982682557415424", "1"), Fraction("12116574790945106558976", "1"), Fraction("504857282956046106624", "1"), Fraction("21035720123168587776", "1"), Fraction("876488338465357824", "1"), Fraction("36520347436056576", "1"), Fraction("1521681143169024", "1"), Fraction("63403380965376", "1"), Fraction("2641807540224", "1"), Fraction("110075314176", "1"), Fraction("4586471424", "1"), Fraction("191102976", "1"), Fraction("7962624", "1"), Fraction("331776", "1"), Fraction("13824", "1"), Fraction("576", "1"), Fraction("24", "1"), Fraction("1", "1"), Fraction("7962725", "1")}, {Fraction("122008981252869411022491112993141891091036959856659100591281395343249", "1"), Fraction("5304738315342148305325700564919212656132041732898221764838321536663", "1"), Fraction("230640796319223839361986981083444028527480075343400946297318327681", "1"), Fraction("10027860709531471276608129612323653414238264145365258534666014247", "1"), Fraction("435993943892672664200353461405376235401663658494141675420261489", "1"), Fraction("18956258430116202791319715713277227626159289499745290235663543", "1"), Fraction("824185149135487077883465900577270766354751717380230010246241", "1"), Fraction("35834136918934220777541995677272642015423987712183913488967", "1"), Fraction("1558005952997140033806173725098810522409738596181909282129", "1"), Fraction("67739389260745218861137988047774370539553852007909099223", "1"), Fraction("2945190837423705167875564697729320458241471826430830401", "1"), Fraction("128051775540161094255459334683883498184411818540470887", "1"), Fraction("5567468501746134532846058029734065138452687762629169", "1"), Fraction("242063847902005849254176436075394136454464685331703", "1"), Fraction("10524515126174167358877236351104092889324551536161", "1"), Fraction("457587614181485537342488537004525777796719632007", "1"), Fraction("19895113660064588580108197261066338165074766609", "1"), Fraction("865004941741938633917747707002884268046728983", "1"), Fraction("37608910510519071039902074217516707306379521", "1"), Fraction("1635170022196481349560959748587682926364327", "1"), Fraction("71094348791151363024389554286420996798449", "1"), Fraction("3091058643093537522799545838540043339063", "1"), Fraction("134393854047545109686936775588697536481", "1"), Fraction("5843211045545439551605946764725979847", "1"), Fraction("254052654154149545721997685422868689", "1"), Fraction("11045767571919545466173812409689943", "1"), Fraction("480250763996501976790165756943041", "1"), Fraction("20880467999847912034355032910567", "1"), Fraction("907846434775996175406740561329", "1"), Fraction("39471584120695485887249589623", "1"), Fraction("1716155831334586342923895201", "1"), Fraction("74615470927590710561908487", "1"), Fraction("3244150909895248285300369", "1"), Fraction("141050039560662968926103", "1"), Fraction("6132610415680998648961", "1"), Fraction("266635235464391245607", "1"), Fraction("11592836324538749809", "1"), Fraction("504036361936467383", "1"), Fraction("21914624432020321", "1"), Fraction("952809757913927", "1"), Fraction("41426511213649", "1"), Fraction("1801152661463", "1"), Fraction("78310985281", "1"), Fraction("3404825447", "1"), Fraction("148035889", "1"), Fraction("6436343", "1"), Fraction("279841", "1"), Fraction("12167", "1"), Fraction("529", "1"), Fraction("23", "1"), Fraction("1", "1"), Fraction("6716281", "1")}, {Fraction("13217035032142513618039644258500715884299760500166608934135475994624", "1"), Fraction("600774319642841528092711102659123449286352750007573133369794363392", "1"), Fraction("27307923620129160367850504666323793149379670454889687880445198336", "1"), Fraction("1241269255460416380356841121196536052244530475222258540020236288", "1"), Fraction("56421329793655290016220050963478911465660476146466297273647104", "1"), Fraction("2564605899711604091646365952885405066620930733930286239711232", "1"), Fraction("116572995441436549620289361494791139391860487905922101805056", "1"), Fraction("5298772520065297710013152795217779063266385813905550082048", "1"), Fraction("240853296366604441364234217964444502875744809722979549184", "1"), Fraction("10947877107572929152919737180202022857988400441953615872", "1"), Fraction("497630777616951325132715326372819220817654565543346176", "1"), Fraction("22619580800770514778759787562400873673529752979243008", "1"), Fraction("1028162763671387035398172161927312439705897862692864", "1"), Fraction("46734671075972137972644189178514201804813539213312", "1"), Fraction("2124303230726006271483826780841554627491524509696", "1"), Fraction("96559237760273012340173944583707028522342023168", "1"), Fraction("4389056261830591470007906571986683114651910144", "1"), Fraction("199502557355935975909450298726667414302359552", "1"), Fraction("9068298061633453450429559033030337013743616", "1"), Fraction("412195366437884247746798137865015318806528", "1"), Fraction("18736153019903829443036278993864332673024", "1"), Fraction("851643319086537701956194499721106030592", "1"), Fraction("38711059958478986452554295441868455936", "1"), Fraction("1759593634476317566025195247357657088", "1"), Fraction("79981528839832616637508874879893504", "1"), Fraction("3635524038174209847159494312722432", "1"), Fraction("165251092644282265779977014214656", "1"), Fraction("7511413302012830262726227918848", "1"), Fraction("341427877364219557396646723584", "1"), Fraction("15519448971100888972574851072", "1"), Fraction("705429498686404044207947776", "1"), Fraction("32064977213018365645815808", "1"), Fraction("1457498964228107529355264", "1"), Fraction("66249952919459433152512", "1"), Fraction("3011361496339065143296", "1"), Fraction("136880068015412051968", "1"), Fraction("6221821273427820544", "1"), Fraction("282810057883082752", "1"), Fraction("12855002631049216", "1"), Fraction("584318301411328", "1"), Fraction("26559922791424", "1"), Fraction("1207269217792", "1"), Fraction("54875873536", "1"), Fraction("2494357888", "1"), Fraction("113379904", "1"), Fraction("5153632", "1"), Fraction("234256", "1"), Fraction("10648", "1"), Fraction("484", "1"), Fraction("22", "1"), Fraction("1", "1"), Fraction("5622237", "1")}, {Fraction("1291114435050719026386456475646628666554089222911187324493837291001", "1"), Fraction("61481639764319953637450308364125174597813772519580348785420823381", "1"), Fraction("2927697131634283506545252779244055933229227262837159465972420161", "1"), Fraction("139414149125442071740250132344955044439487012516055212665353341", "1"), Fraction("6638769005973431987630958683093097354261286310288343460254921", "1"), Fraction("316131857427306285125283746813957016869585062394683021916901", "1"), Fraction("15053897972728870720251606991140810327123098209270620091281", "1"), Fraction("716852284415660510488171761482895729863004676631934290061", "1"), Fraction("34135823067412405261341512451566463326809746506282585241", "1"), Fraction("1625515384162495488635310116741260158419511738394408821", "1"), Fraction("77405494483928356601681434130536198019976749447352801", "1"), Fraction("3685975927806112219127687339549342762856035687969181", "1"), Fraction("175522663228862486625127968549968702993144556569961", "1"), Fraction("8358222058517261267863236597617557285387836027141", "1"), Fraction("398010574215107679422058885600836061208944572721", "1"), Fraction("18952884486433699020098042171468383867092598701", "1"), Fraction("902518308877795191433240103403256374623457081", "1"), Fraction("42977062327514056734916195400155065458259861", "1"), Fraction("2046526777500669368329342638102622164679041", "1"), Fraction("97453656071460446110921078004886769746621", "1"), Fraction("4640650289117164100520051333566036654601", "1"), Fraction("220983347100817338120002444455525554981", "1"), Fraction("10523016528610349434285830688358359761", "1"), Fraction("501096025171921401632658604207540941", "1"), Fraction("23861715484377209601555171628930521", "1"), Fraction("1136272165922724266740722458520501", "1"), Fraction("54108198377272584130510593262881", "1"), Fraction("2576580875108218291929075869661", "1"), Fraction("122694327386105632949003612841", "1"), Fraction("5842587018385982521381124421", "1"), Fraction("278218429446951548637196401", "1"), Fraction("13248496640331026125580781", "1"), Fraction("630880792396715529789561", "1"), Fraction("30041942495081691894741", "1"), Fraction("1430568690241985328321", "1"), Fraction("68122318582951682301", "1"), Fraction("3243919932521508681", "1"), Fraction("154472377739119461", "1"), Fraction("7355827511386641", "1"), Fraction("350277500542221", "1"), Fraction("16679880978201", "1"), Fraction("794280046581", "1"), Fraction("37822859361", "1"), Fraction("1801088541", "1"), Fraction("85766121", "1"), Fraction("4084101", "1"), Fraction("194481", "1"), Fraction("9261", "1"), Fraction("441", "1"), Fraction("21", "1"), Fraction("1", "1"), Fraction("4667633", "1")}, {Fraction("112589990684262400000000000000000000000000000000000000000000000000", "1"), Fraction("5629499534213120000000000000000000000000000000000000000000000000", "1"), Fraction("281474976710656000000000000000000000000000000000000000000000000", "1"), Fraction("14073748835532800000000000000000000000000000000000000000000000", "1"), Fraction("703687441776640000000000000000000000000000000000000000000000", "1"), Fraction("35184372088832000000000000000000000000000000000000000000000", "1"), Fraction("1759218604441600000000000000000000000000000000000000000000", "1"), Fraction("87960930222080000000000000000000000000000000000000000000", "1"), Fraction("4398046511104000000000000000000000000000000000000000000", "1"), Fraction("219902325555200000000000000000000000000000000000000000", "1"), Fraction("10995116277760000000000000000000000000000000000000000", "1"), Fraction("549755813888000000000000000000000000000000000000000", "1"), Fraction("27487790694400000000000000000000000000000000000000", "1"), Fraction("1374389534720000000000000000000000000000000000000", "1"), Fraction("68719476736000000000000000000000000000000000000", "1"), Fraction("3435973836800000000000000000000000000000000000", "1"), Fraction("171798691840000000000000000000000000000000000", "1"), Fraction("8589934592000000000000000000000000000000000", "1"), Fraction("429496729600000000000000000000000000000000", "1"), Fraction("21474836480000000000000000000000000000000", "1"), Fraction("1073741824000000000000000000000000000000", "1"), Fraction("53687091200000000000000000000000000000", "1"), Fraction("2684354560000000000000000000000000000", "1"), Fraction("134217728000000000000000000000000000", "1"), Fraction("6710886400000000000000000000000000", "1"), Fraction("335544320000000000000000000000000", "1"), Fraction("16777216000000000000000000000000", "1"), Fraction("838860800000000000000000000000", "1"), Fraction("41943040000000000000000000000", "1"), Fraction("2097152000000000000000000000", "1"), Fraction("104857600000000000000000000", "1"), Fraction("5242880000000000000000000", "1"), Fraction("262144000000000000000000", "1"), Fraction("13107200000000000000000", "1"), Fraction("655360000000000000000", "1"), Fraction("32768000000000000000", "1"), Fraction("1638400000000000000", "1"), Fraction("81920000000000000", "1"), Fraction("4096000000000000", "1"), Fraction("204800000000000", "1"), Fraction("10240000000000", "1"), Fraction("512000000000", "1"), Fraction("25600000000", "1"), Fraction("1280000000", "1"), Fraction("64000000", "1"), Fraction("3200000", "1"), Fraction("160000", "1"), Fraction("8000", "1"), Fraction("400", "1"), Fraction("20", "1"), Fraction("1", "1"), Fraction("3840085", "1")}, {Fraction("8663234049605954426644038200675212212900743262211018069459689001", "1"), Fraction("455959686821366022454949378982905905942144382221632529971562579", "1"), Fraction("23997878253756106444997335735942416102218125380085922630082241", "1"), Fraction("1263046223881900339210386091365390321169375020004522243688539", "1"), Fraction("66476117046415807326862425861336332693125001052869591773081", "1"), Fraction("3498743002442937227729601361122964878585526371203662724899", "1"), Fraction("184144368549628275143663229532787625188711914273876985521", "1"), Fraction("9691808871033067112824380501725664483616416540730367659", "1"), Fraction("510095203738582479622335815880298130716653502143703561", "1"), Fraction("26847115986241183138017674520015691090350184323352819", "1"), Fraction("1413006104539009638843035501053457425807904438071201", "1"), Fraction("74368742344158402044370289529129338200416023056379", "1"), Fraction("3914144333903073791808962606796280957916632792441", "1"), Fraction("206007596521214410095208558252435839890349094339", "1"), Fraction("10842505080063916320800450434338728415281531281", "1"), Fraction("570658162108627174778971075491512021856922699", "1"), Fraction("30034640110980377619945846078500632729311721", "1"), Fraction("1580770532156861979997149793605296459437459", "1"), Fraction("83198449060887472631428936505541918917761", "1"), Fraction("4378865740046709085864680868712732574619", "1"), Fraction("230466617897195215045509519405933293401", "1"), Fraction("12129821994589221844500501021364910179", "1"), Fraction("638411683925748518131605316913942641", "1"), Fraction("33600614943460448322716069311260139", "1"), Fraction("1768453418076865701195582595329481", "1"), Fraction("93076495688256089536609610280499", "1"), Fraction("4898762930960846817716295277921", "1"), Fraction("257829627945307727248226067259", "1"), Fraction("13569980418174090907801371961", "1"), Fraction("714209495693373205673756419", "1"), Fraction("37589973457545958193355601", "1"), Fraction("1978419655660313589123979", "1"), Fraction("104127350297911241532841", "1"), Fraction("5480386857784802185939", "1"), Fraction("288441413567621167681", "1"), Fraction("15181127029874798299", "1"), Fraction("799006685782884121", "1"), Fraction("42052983462257059", "1"), Fraction("2213314919066161", "1"), Fraction("116490258898219", "1"), Fraction("6131066257801", "1"), Fraction("322687697779", "1"), Fraction("16983563041", "1"), Fraction("893871739", "1"), Fraction("47045881", "1"), Fraction("2476099", "1"), Fraction("130321", "1"), Fraction("6859", "1"), Fraction("361", "1"), Fraction("19", "1"), Fraction("1", "1"), Fraction("3127785", "1")}, {Fraction("580263502580954076834176784379033815974530084312159480524570624", "1"), Fraction("32236861254497448713009821354390767554140560239564415584698368", "1"), Fraction("1790936736360969372944990075243931530785586679975800865816576", "1"), Fraction("99496485353387187385832781957996196154754815554211159212032", "1"), Fraction("5527582519632621521435154553222010897486378641900619956224", "1"), Fraction("307087917757367862301953030734556160971465480105589997568", "1"), Fraction("17060439875409325683441835040808675609525860005866110976", "1"), Fraction("947802215300518093524546391156037533862547778103672832", "1"), Fraction("52655678627806560751363688397557640770141543227981824", "1"), Fraction("2925315479322586708409093799864313376118974623776768", "1"), Fraction("162517526629032594911616322214684076451054145765376", "1"), Fraction("9028751479390699717312017900815782025058563653632", "1"), Fraction("501597304410594428739556550045321223614364647424", "1"), Fraction("27866516911699690485530919446962290200798035968", "1"), Fraction("1548139828427760582529495524831238344488779776", "1"), Fraction("86007768245986699029416418046179908027154432", "1"), Fraction("4778209346999261057189801002565550445953024", "1"), Fraction("265456074833292280954988944586975024775168", "1"), Fraction("14747559712960682275277163588165279154176", "1"), Fraction("819308872942260126404286866009182175232", "1"), Fraction("45517159607903340355793714778287898624", "1"), Fraction("2528731089327963353099650821015994368", "1"), Fraction("140485060518220186283313934500888576", "1"), Fraction("7804725584345565904628551916716032", "1"), Fraction("433595865796975883590475106484224", "1"), Fraction("24088659210943104643915283693568", "1"), Fraction("1338258845052394702439737982976", "1"), Fraction("74347713614021927913318776832", "1"), Fraction("4130428534112329328517709824", "1"), Fraction("229468251895129407139872768", "1"), Fraction("12748236216396078174437376", "1"), Fraction("708235345355337676357632", "1"), Fraction("39346408075296537575424", "1"), Fraction("2185911559738696531968", "1"), Fraction("121439531096594251776", "1"), Fraction("6746640616477458432", "1"), Fraction("374813367582081024", "1"), Fraction("20822964865671168", "1"), Fraction("1156831381426176", "1"), Fraction("64268410079232", "1"), Fraction("3570467226624", "1"), Fraction("198359290368", "1"), Fraction("11019960576", "1"), Fraction("612220032", "1"), Fraction("34012224", "1"), Fraction("1889568", "1"), Fraction("104976", "1"), Fraction("5832", "1"), Fraction("324", "1"), Fraction("18", "1"), Fraction("1", "1"), Fraction("2519501", "1")}, {Fraction("33300140732146818380750772381422989832214186835186851059977249", "1"), Fraction("1958831807773342257691221904789587637189069813834520650586897", "1"), Fraction("115225400457255426923013053222916919834651165519677685328641", "1"), Fraction("6777964732779730995471356071936289402038303854098687372273", "1"), Fraction("398703807810572411498315063055075847178723756123452198369", "1"), Fraction("23453165165327788911665591944416226304630809183732482257", "1"), Fraction("1379597950901634641862681879083307429684165246101910721", "1"), Fraction("81152820641272625991922463475488672334362661535406513", "1"), Fraction("4773695331839566234818968439734627784374274207965089", "1"), Fraction("280805607755268602048174614102036928492604365174417", "1"), Fraction("16517976926780506002833800829531584028976727363201", "1"), Fraction("971645701575323882519635342913622589939807491953", "1"), Fraction("57155629504430816618802078994918975878812205409", "1"), Fraction("3362095853201812742282475234995233875224247377", "1"), Fraction("197770344305988984840145602058543169130838081", "1"), Fraction("11633549665058175578832094238737833478284593", "1"), Fraction("684326450885775034048946719925754910487329", "1"), Fraction("40254497110927943179349807054456171205137", "1"), Fraction("2367911594760467245844106297320951247361", "1"), Fraction("139288917338851014461418017489467720433", "1"), Fraction("8193465725814765556554001028792218849", "1"), Fraction("481968572106750915091411825223071697", "1"), Fraction("28351092476867700887730107366063041", "1"), Fraction("1667711322168688287513535727415473", "1"), Fraction("98100666009922840441972689847969", "1"), Fraction("5770627412348402378939569991057", "1"), Fraction("339448671314611904643504117121", "1"), Fraction("19967568900859523802559065713", "1"), Fraction("1174562876521148458974062689", "1"), Fraction("69091933913008732880827217", "1"), Fraction("4064231406647572522401601", "1"), Fraction("239072435685151324847153", "1"), Fraction("14063084452067724991009", "1"), Fraction("827240261886336764177", "1"), Fraction("48661191875666868481", "1"), Fraction("2862423051509815793", "1"), Fraction("168377826559400929", "1"), Fraction("9904578032905937", "1"), Fraction("582622237229761", "1"), Fraction("34271896307633", "1"), Fraction("2015993900449", "1"), Fraction("118587876497", "1"), Fraction("6975757441", "1"), Fraction("410338673", "1"), Fraction("24137569", "1"), Fraction("1419857", "1"), Fraction("83521", "1"), Fraction("4913", "1"), Fraction("289", "1"), Fraction("17", "1"), Fraction("1", "1"), Fraction("2004577", "1")}, {Fraction("1606938044258990275541962092341162602522202993782792835301376", "1"), Fraction("100433627766186892221372630771322662657637687111424552206336", "1"), Fraction("6277101735386680763835789423207666416102355444464034512896", "1"), Fraction("392318858461667547739736838950479151006397215279002157056", "1"), Fraction("24519928653854221733733552434404946937899825954937634816", "1"), Fraction("1532495540865888858358347027150309183618739122183602176", "1"), Fraction("95780971304118053647396689196894323976171195136475136", "1"), Fraction("5986310706507378352962293074805895248510699696029696", "1"), Fraction("374144419156711147060143317175368453031918731001856", "1"), Fraction("23384026197294446691258957323460528314494920687616", "1"), Fraction("1461501637330902918203684832716283019655932542976", "1"), Fraction("91343852333181432387730302044767688728495783936", "1"), Fraction("5708990770823839524233143877797980545530986496", "1"), Fraction("356811923176489970264571492362373784095686656", "1"), Fraction("22300745198530623141535718272648361505980416", "1"), Fraction("1393796574908163946345982392040522594123776", "1"), Fraction("87112285931760246646623899502532662132736", "1"), Fraction("5444517870735015415413993718908291383296", "1"), Fraction("340282366920938463463374607431768211456", "1"), Fraction("21267647932558653966460912964485513216", "1"), Fraction("1329227995784915872903807060280344576", "1"), Fraction("83076749736557242056487941267521536", "1"), Fraction("5192296858534827628530496329220096", "1"), Fraction("324518553658426726783156020576256", "1"), Fraction("20282409603651670423947251286016", "1"), Fraction("1267650600228229401496703205376", "1"), Fraction("79228162514264337593543950336", "1"), Fraction("4951760157141521099596496896", "1"), Fraction("309485009821345068724781056", "1"), Fraction("19342813113834066795298816", "1"), Fraction("1208925819614629174706176", "1"), Fraction("75557863725914323419136", "1"), Fraction("4722366482869645213696", "1"), Fraction("295147905179352825856", "1"), Fraction("18446744073709551616", "1"), Fraction("1152921504606846976", "1"), Fraction("72057594037927936", "1"), Fraction("4503599627370496", "1"), Fraction("281474976710656", "1"), Fraction("17592186044416", "1"), Fraction("1099511627776", "1"), Fraction("68719476736", "1"), Fraction("4294967296", "1"), Fraction("268435456", "1"), Fraction("16777216", "1"), Fraction("1048576", "1"), Fraction("65536", "1"), Fraction("4096", "1"), Fraction("256", "1"), Fraction("16", "1"), Fraction("1", "1"), Fraction("1572933", "1")}, {Fraction("63762150021404958690340780691485633724369108676910400390625", "1"), Fraction("4250810001426997246022718712765708914957940578460693359375", "1"), Fraction("283387333428466483068181247517713927663862705230712890625", "1"), Fraction("18892488895231098871212083167847595177590847015380859375", "1"), Fraction("1259499259682073258080805544523173011839389801025390625", "1"), Fraction("83966617312138217205387036301544867455959320068359375", "1"), Fraction("5597774487475881147025802420102991163730621337890625", "1"), Fraction("373184965831725409801720161340199410915374755859375", "1"), Fraction("24878997722115027320114677422679960727691650390625", "1"), Fraction("1658599848141001821340978494845330715179443359375", "1"), Fraction("110573323209400121422731899656355381011962890625", "1"), Fraction("7371554880626674761515459977090358734130859375", "1"), Fraction("491436992041778317434363998472690582275390625", "1"), Fraction("32762466136118554495624266564846038818359375", "1"), Fraction("2184164409074570299708284437656402587890625", "1"), Fraction("145610960604971353313885629177093505859375", "1"), Fraction("9707397373664756887592375278472900390625", "1"), Fraction("647159824910983792506158351898193359375", "1"), Fraction("43143988327398919500410556793212890625", "1"), Fraction("2876265888493261300027370452880859375", "1"), Fraction("191751059232884086668491363525390625", "1"), Fraction("12783403948858939111232757568359375", "1"), Fraction("852226929923929274082183837890625", "1"), Fraction("56815128661595284938812255859375", "1"), Fraction("3787675244106352329254150390625", "1"), Fraction("252511682940423488616943359375", "1"), Fraction("16834112196028232574462890625", "1"), Fraction("1122274146401882171630859375", "1"), Fraction("74818276426792144775390625", "1"), Fraction("4987885095119476318359375", "1"), Fraction("332525673007965087890625", "1"), Fraction("22168378200531005859375", "1"), Fraction("1477891880035400390625", "1"), Fraction("98526125335693359375", "1"), Fraction("6568408355712890625", "1"), Fraction("437893890380859375", "1"), Fraction("29192926025390625", "1"), Fraction("1946195068359375", "1"), Fraction("129746337890625", "1"), Fraction("8649755859375", "1"), Fraction("576650390625", "1"), Fraction("38443359375", "1"), Fraction("2562890625", "1"), Fraction("170859375", "1"), Fraction("11390625", "1"), Fraction("759375", "1"), Fraction("50625", "1"), Fraction("3375", "1"), Fraction("225", "1"), Fraction("15", "1"), Fraction("1", "1"), Fraction("1215065", "1")}, {Fraction("2024891623976437135118764865774783290467102632746078437376", "1"), Fraction("144635115998316938222768918983913092176221616624719888384", "1"), Fraction("10331079714165495587340637070279506584015829758908563456", "1"), Fraction("737934265297535399095759790734250470286844982779183104", "1"), Fraction("52709590378395385649697127909589319306203213055655936", "1"), Fraction("3764970741313956117835509136399237093300229503975424", "1"), Fraction("268926481522425436988250652599945506664302107426816", "1"), Fraction("19209034394458959784875046614281821904593007673344", "1"), Fraction("1372073885318497127491074758162987278899500548096", "1"), Fraction("98005277522749794820791054154499091349964324864", "1"), Fraction("7000376965910699630056503868178506524997451776", "1"), Fraction("500026926136478545004035990584179037499817984", "1"), Fraction("35716209009748467500288285041727074107129856", "1"), Fraction("2551157786410604821449163217266219579080704", "1"), Fraction("182225556172186058674940229804729969934336", "1"), Fraction("13016111155156147048210016414623569281024", "1"), Fraction("929722225368296217729286886758826377216", "1"), Fraction("66408730383449729837806206197059026944", "1"), Fraction("4743480741674980702700443299789930496", "1"), Fraction("338820052976784335907174521413566464", "1"), Fraction("24201432355484595421941037243826176", "1"), Fraction("1728673739677471101567216945987584", "1"), Fraction("123476695691247935826229781856256", "1"), Fraction("8819763977946281130444984418304", "1"), Fraction("629983141281877223603213172736", "1"), Fraction("44998795805848373114515226624", "1"), Fraction("3214199700417740936751087616", "1"), Fraction("229585692886981495482220544", "1"), Fraction("16398978063355821105872896", "1"), Fraction("1171355575953987221848064", "1"), Fraction("83668255425284801560576", "1"), Fraction("5976303958948914397184", "1"), Fraction("426878854210636742656", "1"), Fraction("30491346729331195904", "1"), Fraction("2177953337809371136", "1"), Fraction("155568095557812224", "1"), Fraction("11112006825558016", "1"), Fraction("793714773254144", "1"), Fraction("56693912375296", "1"), Fraction("4049565169664", "1"), Fraction("289254654976", "1"), Fraction("20661046784", "1"), Fraction("1475789056", "1"), Fraction("105413504", "1"), Fraction("7529536", "1"), Fraction("537824", "1"), Fraction("38416", "1"), Fraction("2744", "1"), Fraction("196", "1"), Fraction("14", "1"), Fraction("1", "1"), Fraction("922045", "1")}, {Fraction("49792922297912707801714181535533618316401192004725734249", "1"), Fraction("3830224792147131369362629348887201408953937846517364173", "1"), Fraction("294632676319010105335586872991323185304149065116720321", "1"), Fraction("22664052024539238871968220999332552715703774239747717", "1"), Fraction("1743388617272249143997555461487119439669521095365209", "1"), Fraction("134106816713249934153658112422086110743809315028093", "1"), Fraction("10315908977942302627204470186314316211062255002161", "1"), Fraction("793531459841715586708036168178024323927865769397", "1"), Fraction("61040881526285814362156628321386486455989674569", "1"), Fraction("4695452425098908797088971409337422035076128813", "1"), Fraction("361188648084531445929920877641340156544317601", "1"), Fraction("27783742160348572763840067510872319734178277", "1"), Fraction("2137210935411428674141543654682486133398329", "1"), Fraction("164400841185494513395503358052498933338333", "1"), Fraction("12646218552730347184269489080961456410641", "1"), Fraction("972786042517719014174576083150881262357", "1"), Fraction("74829695578286078013428929473144712489", "1"), Fraction("5756130429098929077956071497934208653", "1"), Fraction("442779263776840698304313192148785281", "1"), Fraction("34059943367449284484947168626829637", "1"), Fraction("2619995643649944960380551432833049", "1"), Fraction("201538126434611150798503956371773", "1"), Fraction("15502932802662396215269535105521", "1"), Fraction("1192533292512492016559195008117", "1"), Fraction("91733330193268616658399616009", "1"), Fraction("7056410014866816666030739693", "1"), Fraction("542800770374370512771595361", "1"), Fraction("41753905413413116367045797", "1"), Fraction("3211838877954855105157369", "1"), Fraction("247064529073450392704413", "1"), Fraction("19004963774880799438801", "1"), Fraction("1461920290375446110677", "1"), Fraction("112455406951957393129", "1"), Fraction("8650415919381337933", "1"), Fraction("665416609183179841", "1"), Fraction("51185893014090757", "1"), Fraction("3937376385699289", "1"), Fraction("302875106592253", "1"), Fraction("23298085122481", "1"), Fraction("1792160394037", "1"), Fraction("137858491849", "1"), Fraction("10604499373", "1"), Fraction("815730721", "1"), Fraction("62748517", "1"), Fraction("4826809", "1"), Fraction("371293", "1"), Fraction("28561", "1"), Fraction("2197", "1"), Fraction("169", "1"), Fraction("13", "1"), Fraction("1", "1"), Fraction("685521", "1")}, {Fraction("910043815000214977332758527534256632492715260325658624", "1"), Fraction("75836984583351248111063210627854719374392938360471552", "1"), Fraction("6319748715279270675921934218987893281199411530039296", "1"), Fraction("526645726273272556326827851582324440099950960836608", "1"), Fraction("43887143856106046360568987631860370008329246736384", "1"), Fraction("3657261988008837196714082302655030834027437228032", "1"), Fraction("304771832334069766392840191887919236168953102336", "1"), Fraction("25397652694505813866070015990659936347412758528", "1"), Fraction("2116471057875484488839167999221661362284396544", "1"), Fraction("176372588156290374069930666601805113523699712", "1"), Fraction("14697715679690864505827555550150426126974976", "1"), Fraction("1224809639974238708818962962512535510581248", "1"), Fraction("102067469997853225734913580209377959215104", "1"), Fraction("8505622499821102144576131684114829934592", "1"), Fraction("708801874985091845381344307009569161216", "1"), Fraction("59066822915424320448445358917464096768", "1"), Fraction("4922235242952026704037113243122008064", "1"), Fraction("410186270246002225336426103593500672", "1"), Fraction("34182189187166852111368841966125056", "1"), Fraction("2848515765597237675947403497177088", "1"), Fraction("237376313799769806328950291431424", "1"), Fraction("19781359483314150527412524285952", "1"), Fraction("1648446623609512543951043690496", "1"), Fraction("137370551967459378662586974208", "1"), Fraction("11447545997288281555215581184", "1"), Fraction("953962166440690129601298432", "1"), Fraction("79496847203390844133441536", "1"), Fraction("6624737266949237011120128", "1"), Fraction("552061438912436417593344", "1"), Fraction("46005119909369701466112", "1"), Fraction("3833759992447475122176", "1"), Fraction("319479999370622926848", "1"), Fraction("26623333280885243904", "1"), Fraction("2218611106740436992", "1"), Fraction("184884258895036416", "1"), Fraction("15407021574586368", "1"), Fraction("1283918464548864", "1"), Fraction("106993205379072", "1"), Fraction("8916100448256", "1"), Fraction("743008370688", "1"), Fraction("61917364224", "1"), Fraction("5159780352", "1"), Fraction("429981696", "1"), Fraction("35831808", "1"), Fraction("2985984", "1"), Fraction("248832", "1"), Fraction("20736", "1"), Fraction("1728", "1"), Fraction("144", "1"), Fraction("12", "1"), Fraction("1", "1"), Fraction("497717", "1")}, {Fraction("11739085287969531650666649599035831993898213898723001", "1"), Fraction("1067189571633593786424240872639621090354383081702091", "1"), Fraction("97017233784872162402203715694511008214034825609281", "1"), Fraction("8819748525897469309291246881319182564912256873571", "1"), Fraction("801795320536133573571931534665380233173841533961", "1"), Fraction("72890483685103052142902866787761839379440139451", "1"), Fraction("6626407607736641103900260617069258125403649041", "1"), Fraction("602400691612421918536387328824478011400331731", "1"), Fraction("54763699237492901685126120802225273763666521", "1"), Fraction("4978518112499354698647829163838661251242411", "1"), Fraction("452592555681759518058893560348969204658401", "1"), Fraction("41144777789250865278081232758997200423491", "1"), Fraction("3740434344477351388916475705363381856681", "1"), Fraction("340039485861577398992406882305761986971", "1"), Fraction("30912680532870672635673352936887453361", "1"), Fraction("2810243684806424785061213903353404851", "1"), Fraction("255476698618765889551019445759400441", "1"), Fraction("23225154419887808141001767796309131", "1"), Fraction("2111377674535255285545615254209921", "1"), Fraction("191943424957750480504146841291811", "1"), Fraction("17449402268886407318558803753801", "1"), Fraction("1586309297171491574414436704891", "1"), Fraction("144209936106499234037676064081", "1"), Fraction("13109994191499930367061460371", "1"), Fraction("1191817653772720942460132761", "1"), Fraction("108347059433883722041830251", "1"), Fraction("9849732675807611094711841", "1"), Fraction("895430243255237372246531", "1"), Fraction("81402749386839761113321", "1"), Fraction("7400249944258160101211", "1"), Fraction("672749994932560009201", "1"), Fraction("61159090448414546291", "1"), Fraction("5559917313492231481", "1"), Fraction("505447028499293771", "1"), Fraction("45949729863572161", "1"), Fraction("4177248169415651", "1"), Fraction("379749833583241", "1"), Fraction("34522712143931", "1"), Fraction("3138428376721", "1"), Fraction("285311670611", "1"), Fraction("25937424601", "1"), Fraction("2357947691", "1"), Fraction("214358881", "1"), Fraction("19487171", "1"), Fraction("1771561", "1"), Fraction("161051", "1"), Fraction("14641", "1"), Fraction("1331", "1"), Fraction("121", "1"), Fraction("11", "1"), Fraction("1", "1"), Fraction("351433", "1")}, {Fraction("100000000000000000000000000000000000000000000000000", "1"), Fraction("10000000000000000000000000000000000000000000000000", "1"), Fraction("1000000000000000000000000000000000000000000000000", "1"), Fraction("100000000000000000000000000000000000000000000000", "1"), Fraction("10000000000000000000000000000000000000000000000", "1"), Fraction("1000000000000000000000000000000000000000000000", "1"), Fraction("100000000000000000000000000000000000000000000", "1"), Fraction("10000000000000000000000000000000000000000000", "1"), Fraction("1000000000000000000000000000000000000000000", "1"), Fraction("100000000000000000000000000000000000000000", "1"), Fraction("10000000000000000000000000000000000000000", "1"), Fraction("1000000000000000000000000000000000000000", "1"), Fraction("100000000000000000000000000000000000000", "1"), Fraction("10000000000000000000000000000000000000", "1"), Fraction("1000000000000000000000000000000000000", "1"), Fraction("100000000000000000000000000000000000", "1"), Fraction("10000000000000000000000000000000000", "1"), Fraction("1000000000000000000000000000000000", "1"), Fraction("100000000000000000000000000000000", "1"), Fraction("10000000000000000000000000000000", "1"), Fraction("1000000000000000000000000000000", "1"), Fraction("100000000000000000000000000000", "1"), Fraction("10000000000000000000000000000", "1"), Fraction("1000000000000000000000000000", "1"), Fraction("100000000000000000000000000", "1"), Fraction("10000000000000000000000000", "1"), Fraction("1000000000000000000000000", "1"), Fraction("100000000000000000000000", "1"), Fraction("10000000000000000000000", "1"), Fraction("1000000000000000000000", "1"), Fraction("100000000000000000000", "1"), Fraction("10000000000000000000", "1"), Fraction("1000000000000000000", "1"), Fraction("100000000000000000", "1"), Fraction("10000000000000000", "1"), Fraction("1000000000000000", "1"), Fraction("100000000000000", "1"), Fraction("10000000000000", "1"), Fraction("1000000000000", "1"), Fraction("100000000000", "1"), Fraction("10000000000", "1"), Fraction("1000000000", "1"), Fraction("100000000", "1"), Fraction("10000000", "1"), Fraction("1000000", "1"), Fraction("100000", "1"), Fraction("10000", "1"), Fraction("1000", "1"), Fraction("100", "1"), Fraction("10", "1"), Fraction("1", "1"), Fraction("240045", "1")}, {Fraction("515377520732011331036461129765621272702107522001", "1"), Fraction("57264168970223481226273458862846808078011946889", "1"), Fraction("6362685441135942358474828762538534230890216321", "1"), Fraction("706965049015104706497203195837614914543357369", "1"), Fraction("78551672112789411833022577315290546060373041", "1"), Fraction("8727963568087712425891397479476727340041449", "1"), Fraction("969773729787523602876821942164080815560161", "1"), Fraction("107752636643058178097424660240453423951129", "1"), Fraction("11972515182562019788602740026717047105681", "1"), Fraction("1330279464729113309844748891857449678409", "1"), Fraction("147808829414345923316083210206383297601", "1"), Fraction("16423203268260658146231467800709255289", "1"), Fraction("1824800363140073127359051977856583921", "1"), Fraction("202755595904452569706561330872953769", "1"), Fraction("22528399544939174411840147874772641", "1"), Fraction("2503155504993241601315571986085849", "1"), Fraction("278128389443693511257285776231761", "1"), Fraction("30903154382632612361920641803529", "1"), Fraction("3433683820292512484657849089281", "1"), Fraction("381520424476945831628649898809", "1"), Fraction("42391158275216203514294433201", "1"), Fraction("4710128697246244834921603689", "1"), Fraction("523347633027360537213511521", "1"), Fraction("58149737003040059690390169", "1"), Fraction("6461081889226673298932241", "1"), Fraction("717897987691852588770249", "1"), Fraction("79766443076872509863361", "1"), Fraction("8862938119652501095929", "1"), Fraction("984770902183611232881", "1"), Fraction("109418989131512359209", "1"), Fraction("12157665459056928801", "1"), Fraction("1350851717672992089", "1"), Fraction("150094635296999121", "1"), Fraction("16677181699666569", "1"), Fraction("1853020188851841", "1"), Fraction("205891132094649", "1"), Fraction("22876792454961", "1"), Fraction("2541865828329", "1"), Fraction("282429536481", "1"), Fraction("31381059609", "1"), Fraction("3486784401", "1"), Fraction("387420489", "1"), Fraction("43046721", "1"), Fraction("4782969", "1"), Fraction("531441", "1"), Fraction("59049", "1"), Fraction("6561", "1"), Fraction("729", "1"), Fraction("81", "1"), Fraction("9", "1"), Fraction("1", "1"), Fraction("157505", "1")}, {Fraction("1427247692705959881058285969449495136382746624", "1"), Fraction("178405961588244985132285746181186892047843328", "1"), Fraction("22300745198530623141535718272648361505980416", "1"), Fraction("2787593149816327892691964784081045188247552", "1"), Fraction("348449143727040986586495598010130648530944", "1"), Fraction("43556142965880123323311949751266331066368", "1"), Fraction("5444517870735015415413993718908291383296", "1"), Fraction("680564733841876926926749214863536422912", "1"), Fraction("85070591730234615865843651857942052864", "1"), Fraction("10633823966279326983230456482242756608", "1"), Fraction("1329227995784915872903807060280344576", "1"), Fraction("166153499473114484112975882535043072", "1"), Fraction("20769187434139310514121985316880384", "1"), Fraction("2596148429267413814265248164610048", "1"), Fraction("324518553658426726783156020576256", "1"), Fraction("40564819207303340847894502572032", "1"), Fraction("5070602400912917605986812821504", "1"), Fraction("633825300114114700748351602688", "1"), Fraction("79228162514264337593543950336", "1"), Fraction("9903520314283042199192993792", "1"), Fraction("1237940039285380274899124224", "1"), Fraction("154742504910672534362390528", "1"), Fraction("19342813113834066795298816", "1"), Fraction("2417851639229258349412352", "1"), Fraction("302231454903657293676544", "1"), Fraction("37778931862957161709568", "1"), Fraction("4722366482869645213696", "1"), Fraction("590295810358705651712", "1"), Fraction("73786976294838206464", "1"), Fraction("9223372036854775808", "1"), Fraction("1152921504606846976", "1"), Fraction("144115188075855872", "1"), Fraction("18014398509481984", "1"), Fraction("2251799813685248", "1"), Fraction("281474976710656", "1"), Fraction("35184372088832", "1"), Fraction("4398046511104", "1"), Fraction("549755813888", "1"), Fraction("68719476736", "1"), Fraction("8589934592", "1"), Fraction("1073741824", "1"), Fraction("134217728", "1"), Fraction("16777216", "1"), Fraction("2097152", "1"), Fraction("262144", "1"), Fraction("32768", "1"), Fraction("4096", "1"), Fraction("512", "1"), Fraction("64", "1"), Fraction("8", "1"), Fraction("1", "1"), Fraction("98341", "1")}, {Fraction("1798465042647412146620280340569649349251249", "1"), Fraction("256923577521058878088611477224235621321607", "1"), Fraction("36703368217294125441230211032033660188801", "1"), Fraction("5243338316756303634461458718861951455543", "1"), Fraction("749048330965186233494494102694564493649", "1"), Fraction("107006904423598033356356300384937784807", "1"), Fraction("15286700631942576193765185769276826401", "1"), Fraction("2183814375991796599109312252753832343", "1"), Fraction("311973482284542371301330321821976049", "1"), Fraction("44567640326363195900190045974568007", "1"), Fraction("6366805760909027985741435139224001", "1"), Fraction("909543680129861140820205019889143", "1"), Fraction("129934811447123020117172145698449", "1"), Fraction("18562115921017574302453163671207", "1"), Fraction("2651730845859653471779023381601", "1"), Fraction("378818692265664781682717625943", "1"), Fraction("54116956037952111668959660849", "1"), Fraction("7730993719707444524137094407", "1"), Fraction("1104427674243920646305299201", "1"), Fraction("157775382034845806615042743", "1"), Fraction("22539340290692258087863249", "1"), Fraction("3219905755813179726837607", "1"), Fraction("459986536544739960976801", "1"), Fraction("65712362363534280139543", "1"), Fraction("9387480337647754305649", "1"), Fraction("1341068619663964900807", "1"), Fraction("191581231380566414401", "1"), Fraction("27368747340080916343", "1"), Fraction("3909821048582988049", "1"), Fraction("558545864083284007", "1"), Fraction("79792266297612001", "1"), Fraction("11398895185373143", "1"), Fraction("1628413597910449", "1"), Fraction("232630513987207", "1"), Fraction("33232930569601", "1"), Fraction("4747561509943", "1"), Fraction("678223072849", "1"), Fraction("96889010407", "1"), Fraction("13841287201", "1"), Fraction("1977326743", "1"), Fraction("282475249", "1"), Fraction("40353607", "1"), Fraction("5764801", "1"), Fraction("823543", "1"), Fraction("117649", "1"), Fraction("16807", "1"), Fraction("2401", "1"), Fraction("343", "1"), Fraction("49", "1"), Fraction("7", "1"), Fraction("1", "1"), Fraction("57657", "1")}, {Fraction("808281277464764060643139600456536293376", "1"), Fraction("134713546244127343440523266742756048896", "1"), Fraction("22452257707354557240087211123792674816", "1"), Fraction("3742042951225759540014535187298779136", "1"), Fraction("623673825204293256669089197883129856", "1"), Fraction("103945637534048876111514866313854976", "1"), Fraction("17324272922341479351919144385642496", "1"), Fraction("2887378820390246558653190730940416", "1"), Fraction("481229803398374426442198455156736", "1"), Fraction("80204967233062404407033075859456", "1"), Fraction("13367494538843734067838845976576", "1"), Fraction("2227915756473955677973140996096", "1"), Fraction("371319292745659279662190166016", "1"), Fraction("61886548790943213277031694336", "1"), Fraction("10314424798490535546171949056", "1"), Fraction("1719070799748422591028658176", "1"), Fraction("286511799958070431838109696", "1"), Fraction("47751966659678405306351616", "1"), Fraction("7958661109946400884391936", "1"), Fraction("1326443518324400147398656", "1"), Fraction("221073919720733357899776", "1"), Fraction("36845653286788892983296", "1"), Fraction("6140942214464815497216", "1"), Fraction("1023490369077469249536", "1"), Fraction("170581728179578208256", "1"), Fraction("28430288029929701376", "1"), Fraction("4738381338321616896", "1"), Fraction("789730223053602816", "1"), Fraction("131621703842267136", "1"), Fraction("21936950640377856", "1"), Fraction("3656158440062976", "1"), Fraction("609359740010496", "1"), Fraction("101559956668416", "1"), Fraction("16926659444736", "1"), Fraction("2821109907456", "1"), Fraction("470184984576", "1"), Fraction("78364164096", "1"), Fraction("13060694016", "1"), Fraction("2176782336", "1"), Fraction("362797056", "1"), Fraction("60466176", "1"), Fraction("10077696", "1"), Fraction("1679616", "1"), Fraction("279936", "1"), Fraction("46656", "1"), Fraction("7776", "1"), Fraction("1296", "1"), Fraction("216", "1"), Fraction("36", "1"), Fraction("6", "1"), Fraction("1", "1"), Fraction("31133", "1")}, {Fraction("88817841970012523233890533447265625", "1"), Fraction("17763568394002504646778106689453125", "1"), Fraction("3552713678800500929355621337890625", "1"), Fraction("710542735760100185871124267578125", "1"), Fraction("142108547152020037174224853515625", "1"), Fraction("28421709430404007434844970703125", "1"), Fraction("5684341886080801486968994140625", "1"), Fraction("1136868377216160297393798828125", "1"), Fraction("227373675443232059478759765625", "1"), Fraction("45474735088646411895751953125", "1"), Fraction("9094947017729282379150390625", "1"), Fraction("1818989403545856475830078125", "1"), Fraction("363797880709171295166015625", "1"), Fraction("72759576141834259033203125", "1"), Fraction("14551915228366851806640625", "1"), Fraction("2910383045673370361328125", "1"), Fraction("582076609134674072265625", "1"), Fraction("116415321826934814453125", "1"), Fraction("23283064365386962890625", "1"), Fraction("4656612873077392578125", "1"), Fraction("931322574615478515625", "1"), Fraction("186264514923095703125", "1"), Fraction("37252902984619140625", "1"), Fraction("7450580596923828125", "1"), Fraction("1490116119384765625", "1"), Fraction("298023223876953125", "1"), Fraction("59604644775390625", "1"), Fraction("11920928955078125", "1"), Fraction("2384185791015625", "1"), Fraction("476837158203125", "1"), Fraction("95367431640625", "1"), Fraction("19073486328125", "1"), Fraction("3814697265625", "1"), Fraction("762939453125", "1"), Fraction("152587890625", "1"), Fraction("30517578125", "1"), Fraction("6103515625", "1"), Fraction("1220703125", "1"), Fraction("244140625", "1"), Fraction("48828125", "1"), Fraction("9765625", "1"), Fraction("1953125", "1"), Fraction("390625", "1"), Fraction("78125", "1"), Fraction("15625", "1"), Fraction("3125", "1"), Fraction("625", "1"), Fraction("125", "1"), Fraction("25", "1"), Fraction("5", "1"), Fraction("1", "1"), Fraction("15025", "1")}, {Fraction("1267650600228229401496703205376", "1"), Fraction("316912650057057350374175801344", "1"), Fraction("79228162514264337593543950336", "1"), Fraction("19807040628566084398385987584", "1"), Fraction("4951760157141521099596496896", "1"), Fraction("1237940039285380274899124224", "1"), Fraction("309485009821345068724781056", "1"), Fraction("77371252455336267181195264", "1"), Fraction("19342813113834066795298816", "1"), Fraction("4835703278458516698824704", "1"), Fraction("1208925819614629174706176", "1"), Fraction("302231454903657293676544", "1"), Fraction("75557863725914323419136", "1"), Fraction("18889465931478580854784", "1"), Fraction("4722366482869645213696", "1"), Fraction("1180591620717411303424", "1"), Fraction("295147905179352825856", "1"), Fraction("73786976294838206464", "1"), Fraction("18446744073709551616", "1"), Fraction("4611686018427387904", "1"), Fraction("1152921504606846976", "1"), Fraction("288230376151711744", "1"), Fraction("72057594037927936", "1"), Fraction("18014398509481984", "1"), Fraction("4503599627370496", "1"), Fraction("1125899906842624", "1"), Fraction("281474976710656", "1"), Fraction("70368744177664", "1"), Fraction("17592186044416", "1"), Fraction("4398046511104", "1"), Fraction("1099511627776", "1"), Fraction("274877906944", "1"), Fraction("68719476736", "1"), Fraction("17179869184", "1"), Fraction("4294967296", "1"), Fraction("1073741824", "1"), Fraction("268435456", "1"), Fraction("67108864", "1"), Fraction("16777216", "1"), Fraction("4194304", "1"), Fraction("1048576", "1"), Fraction("262144", "1"), Fraction("65536", "1"), Fraction("16384", "1"), Fraction("4096", "1"), Fraction("1024", "1"), Fraction("256", "1"), Fraction("64", "1"), Fraction("16", "1"), Fraction("4", "1"), Fraction("1", "1"), Fraction("6165", "1")}, {Fraction("717897987691852588770249", "1"), Fraction("239299329230617529590083", "1"), Fraction("79766443076872509863361", "1"), Fraction("26588814358957503287787", "1"), Fraction("8862938119652501095929", "1"), Fraction("2954312706550833698643", "1"), Fraction("984770902183611232881", "1"), Fraction("328256967394537077627", "1"), Fraction("109418989131512359209", "1"), Fraction("36472996377170786403", "1"), Fraction("12157665459056928801", "1"), Fraction("4052555153018976267", "1"), Fraction("1350851717672992089", "1"), Fraction("450283905890997363", "1"), Fraction("150094635296999121", "1"), Fraction("50031545098999707", "1"), Fraction("16677181699666569", "1"), Fraction("5559060566555523", "1"), Fraction("1853020188851841", "1"), Fraction("617673396283947", "1"), Fraction("205891132094649", "1"), Fraction("68630377364883", "1"), Fraction("22876792454961", "1"), Fraction("7625597484987", "1"), Fraction("2541865828329", "1"), Fraction("847288609443", "1"), Fraction("282429536481", "1"), Fraction("94143178827", "1"), Fraction("31381059609", "1"), Fraction("10460353203", "1"), Fraction("3486784401", "1"), Fraction("1162261467", "1"), Fraction("387420489", "1"), Fraction("129140163", "1"), Fraction("43046721", "1"), Fraction("14348907", "1"), Fraction("4782969", "1"), Fraction("1594323", "1"), Fraction("531441", "1"), Fraction("177147", "1"), Fraction("59049", "1"), Fraction("19683", "1"), Fraction("6561", "1"), Fraction("2187", "1"), Fraction("729", "1"), Fraction("243", "1"), Fraction("81", "1"), Fraction("27", "1"), Fraction("9", "1"), Fraction("3", "1"), Fraction("1", "1"), Fraction("1961", "1")}, {Fraction("1125899906842624", "1"), Fraction("562949953421312", "1"), Fraction("281474976710656", "1"), Fraction("140737488355328", "1"), Fraction("70368744177664", "1"), Fraction("35184372088832", "1"), Fraction("17592186044416", "1"), Fraction("8796093022208", "1"), Fraction("4398046511104", "1"), Fraction("2199023255552", "1"), Fraction("1099511627776", "1"), Fraction("549755813888", "1"), Fraction("274877906944", "1"), Fraction("137438953472", "1"), Fraction("68719476736", "1"), Fraction("34359738368", "1"), Fraction("17179869184", "1"), Fraction("8589934592", "1"), Fraction("4294967296", "1"), Fraction("2147483648", "1"), Fraction("1073741824", "1"), Fraction("536870912", "1"), Fraction("268435456", "1"), Fraction("134217728", "1"), Fraction("67108864", "1"), Fraction("33554432", "1"), Fraction("16777216", "1"), Fraction("8388608", "1"), Fraction("4194304", "1"), Fraction("2097152", "1"), Fraction("1048576", "1"), Fraction("524288", "1"), Fraction("262144", "1"), Fraction("131072", "1"), Fraction("65536", "1"), Fraction("32768", "1"), Fraction("16384", "1"), Fraction("8192", "1"), Fraction("4096", "1"), Fraction("2048", "1"), Fraction("1024", "1"), Fraction("512", "1"), Fraction("256", "1"), Fraction("128", "1"), Fraction("64", "1"), Fraction("32", "1"), Fraction("16", "1"), Fraction("8", "1"), Fraction("4", "1"), Fraction("2", "1"), Fraction("1", "1"), Fraction("397", "1")}, {Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("1", "1"), Fraction("33", "1")}, {Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("0", "1"), Fraction("1", "1"), Fraction("5", "1")}}; n = a.size(); Fraction x[n]; //declare an array to store the elements of augmented-matrix cout<<"\nEnter the elements of the augmented-matrix row-wise:"<<endl; // input the elements of array for (int i=0;i<n;i++) //Pivotisation for (int k=i+1;k<n;k++) if (a[i][i].abso()<a[k][i].abso()) for (j=0;j<=n;j++) { Fraction temp=a[i][j]; a[i][j]=a[k][j]; a[k][j]=temp; } cout<<"\nThe matrix after Pivotisation is:" << endl; for (int i=0;i<n;i++) //print the new matrix { for (int j=0;j<=n;j++) // cout<<a[i][j]<<setw(16); cout<<"\n"; } for (int i=0;i<n-1;i++) //loop to perform the gauss elimination for (int k=i+1;k<n;k++) { Fraction t=a[k][i]/a[i][i]; for (j=0;j<=n;j++) a[k][j]=a[k][j]-t*a[i][j]; //make the elements below the pivot elements equal to zero or eliminate the variables } cout<<"\n\nThe matrix after gauss-elimination is as follows:"<<endl; for (i=0;i<n;i++) //print the new matrix { for (j=0;j<=n;j++) // cout<<a[i][j]<<setw(16); cout<<"\n"; } for (i=n-1;i>=0;i--) //back-substitution { //x is an array whose values correspond to the values of x,y,z.. x[i]=a[i][n]; //make the variable to be calculated equal to the rhs of the last equation for (j=i+1;j<n;j++) if (j!=i) //then subtract all the lhs values except the coefficient of the variable whose value is being calculated x[i]=x[i]-a[i][j]*x[j]; x[i]=x[i]/a[i][i]; //now finally divide the rhs by the coefficient of the variable to be calculated } cout<<"\nThe values of the variables are as follows:\n"; for (i=0;i<n;i++) cout<<x[i]<<endl; // Print the values of x, y,z,.... return 0; }
[ "oladosumoses24@gmail.com" ]
oladosumoses24@gmail.com
b0975675b75e27b9dcc89c961e8ff686abcc1899
6d8a7b8e195722bb8c7f5d43ae7124736dea2df3
/Tests/BattleWidget/surface_object.h
8c1cc90e0434ba736293edcd6fa6834dc120112b
[]
no_license
EldarGiniyatullin/Project_game
02b4dcadc10edd2a0022853e85c661dc567291e0
d65658188aba03a6da10080e4f408f20e91f25bd
refs/heads/master
2021-01-10T19:12:32.951837
2014-12-22T03:53:04
2014-12-22T03:53:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,614
h
#pragma once #include <QPixmap> #include "map_object.h" enum SurfaceType {NOIMAGE = 0, FIELD, ROAD, WATER, ROCKS, SWAMP /*, SAND, BURNED*/ }; class SurfaceObject : public MapObject { public: SurfaceObject() : MapObject(QPixmap("://No_image.png")), isPassable(true), type(NOIMAGE) {setDrawingPriority(0);} SurfaceObject(QPixmap pixmap, int vert, int horiz, SurfaceType objType, bool isPass = true) : MapObject(pixmap, vert, horiz), isPassable(isPass), type(objType) {setDrawingPriority(0);} SurfaceObject(QPixmap pixmap, SurfaceType objType, bool isPass = true) : MapObject(pixmap), isPassable(isPass), type(objType) {setDrawingPriority(0);} SurfaceObject(PixmapItem *pixItem, SurfaceType objType, bool isPass = true) : MapObject(pixItem), isPassable(isPass), type(objType) {setDrawingPriority(0);} SurfaceObject(const SurfaceObject& objectToCopy) : MapObject(objectToCopy), isPassable(objectToCopy.getIsPassable()), type(objectToCopy.getSurfaceType()) {setDrawingPriority(0);} // SurfaceObject( SurfaceObject *objectToCopy) : MapObject(*objectToCopy), isPassable(objectToCopy->getIsPassable()) {} ~SurfaceObject() { } void setPassability(bool passability) { isPassable = passability; } bool getIsPassable() const { return isPassable; } SurfaceType getSurfaceType() const { return type; } protected: bool isPassable; SurfaceType type; };
[ "smirnov.il.ev@gmail.com" ]
smirnov.il.ev@gmail.com
2313eb52d9b305d12be10ca8ef29a55724af406d
bdb6c007003f4e367b1ac78ec1a34ffd46ec6579
/Cpp/fostgres/response.cpp
0659045d93df639dd96b41e85f5548006cae7111
[ "BSL-1.0" ]
permissive
pombredanne/fostgres
bca42346fbc5208fe27274489fda0c33a64ce355
ccdaa279ae01a8430b7d3b554cd89d3101f6bd15
refs/heads/master
2020-06-30T13:21:46.631217
2019-07-19T03:17:20
2019-07-19T03:17:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,248
cpp
/* Copyright 2016-2017, Felspar Co Ltd. http://support.felspar.com/ Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt */ #include <fostgres/fostgres.hpp> #include <fostgres/matcher.hpp> #include <fostgres/response.hpp> #include <f5/threading/map.hpp> /* fostgres::responder */ namespace { using responder_map = f5::tsmap<fostlib::string, fostgres::responder_function>; responder_map &g_responders() { static responder_map rm; return rm; } } fostgres::responder::responder(fostlib::string name, responder_function fn) { g_responders().insert_or_assign(std::move(name), fn); } /* fostgres::response */ std::pair<boost::shared_ptr<fostlib::mime>, int> fostgres::response( const fostlib::json &config, const match &m, fostlib::http::server::request &req) { auto fname = fostlib::coerce<fostlib::nullable<f5::u8view>>( m.configuration["return"]); if (fname) { auto returner = g_responders().find(fname.value()); if (returner) { return returner(config, m, req); } } return response_csj(config, m, req); }
[ "k@kirit.com" ]
k@kirit.com
68135afa69eed71551c1f20836b632f068767753
c1b8146ecaf39d92d892380377f53a10976b18b3
/src/capture_ZWO.cpp
0a9db16569104393bc31604e3f9b05e468b4b05b
[ "MIT" ]
permissive
gmke/allsky
1c6b2a0ea717b10f029e521a7255fb62eea4e9ce
9af7a2e33a5067e74e6d6f8a1eb27a3da59b9695
refs/heads/master
2023-05-30T18:39:28.267000
2023-05-10T15:30:31
2023-05-10T15:30:31
207,248,864
0
0
MIT
2019-10-31T16:06:24
2019-09-09T07:20:56
null
UTF-8
C++
false
false
65,160
cpp
#include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> #include <opencv2/highgui.hpp> #include "include/ASICamera2.h" #include <math.h> #include <unistd.h> #include <string.h> #include <errno.h> #include <string> #include <tr1/memory> #include <stdlib.h> #include <signal.h> #include <fstream> #include <stdarg.h> #include <chrono> #include "include/allsky_common.h" // CG holds all configuration variables. // There are only a few cases where it's not passed to a function. // When it's passed, functions call it "cg", so use upper case for global version. config CG; #define CAMERA_TYPE "ZWO" #define IS_ZWO #include "ASI_functions.cpp" #define USE_HISTOGRAM // use the histogram code as a workaround to ZWO's bug #ifdef USE_HISTOGRAM // Got these by trial and error. They are more-or-less half the max of 255, plus or minus some. #define MINMEAN 122 #define MAXMEAN 134 #endif // Forward definitions char *getRetCode(ASI_ERROR_CODE); void closeUp(int); bool checkMaxErrors(int *, int); //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- // These are global so they can be used by other routines. // Variables for command-line settings are first and are "long" so we can use validateLong(). // In version 0.8 we introduced a different way to take exposures. Instead of turning video mode on at // the beginning of the program and off at the end (which kept the camera running all the time, heating it up), // version 0.8 turned video mode on, then took a picture, then turned it off. This helps cool the camera, // but some users (seems hit or miss) get ASI_ERROR_TIMEOUTs when taking exposures with the new method. // So, we added the ability for them to use the 0.7 video-always-on method, or the 0.8 "new exposure" method. timeval exposureStartDateTime; // date/time an image started cv::Mat pRgb; std::vector<int> compressionParameters; bool bMain = true; bool bDisplay = false; std::string dayOrNight; bool bSaveRun = false; bool bSavingImg = false; pthread_mutex_t mtxSaveImg; pthread_cond_t condStartSave; ASI_CONTROL_CAPS ControlCaps; int numErrors = 0; // Number of errors in a row. int maxErrors = 5; // Max number of errors in a row before we exit bool gotSignal = false; // did we get a SIGINT (from keyboard), or SIGTERM/SIGHUP (from service)? int iNumOfCtrl = NOT_SET; // Number of camera control capabilities pthread_t threadDisplay = 0; pthread_t hthdSave = 0; int numExposures = 0; // how many valid pictures have we taken so far? int currentBpp = NOT_SET; // bytes per pixel: 8, 16, or 24 // Make sure we don't try to update a non-updateable control, and check for errors. ASI_ERROR_CODE setControl(int camNum, ASI_CONTROL_TYPE control, long value, ASI_BOOL makeAuto) { ASI_ERROR_CODE ret = ASI_SUCCESS; // The array of controls might contain 3 items, control IDs 1, 5, and 9. // The 2nd argument to ASIGetControlCaps() is the INDEX into the controll array, // NOT the control ID (e.g., 1, 5, or 9). // Hence if we're looking for control ID 5 we can't do // ASIGetControlCaps(camNum, 5, &ControlCaps) since there are only 3 elements in the array. for (int i = 0; i < iNumOfCtrl && i <= control; i++) // controls are sorted 1 to n { ret = ASIGetControlCaps(camNum, i, &ControlCaps); if (ret != ASI_SUCCESS) { Log(-1, "WARNING: ASIGetControlCaps() for control %d failed: %s, camNum=%d, iNumOfCtrl=%d, control=%d\n", i, getRetCode(ret), camNum, iNumOfCtrl, (int) control); return(ret); } if (ControlCaps.ControlType == control) { if (ControlCaps.IsWritable) { if (value > ControlCaps.MaxValue) { Log(1, "WARNING: Value of %ld greater than max value allowed (%ld) for control '%s' (#%d).\n", value, ControlCaps.MaxValue, ControlCaps.Name, ControlCaps.ControlType); value = ControlCaps.MaxValue; } else if (value < ControlCaps.MinValue) { Log(1, "WARNING: Value of %ld less than min value allowed (%ld) for control '%s' (#%d).\n", value, ControlCaps.MinValue, ControlCaps.Name, ControlCaps.ControlType); value = ControlCaps.MinValue; } if (makeAuto == ASI_TRUE && ControlCaps.IsAutoSupported == ASI_FALSE) { Log(1, "WARNING: control '%s' (#%d) doesn't support auto mode.\n", ControlCaps.Name, ControlCaps.ControlType); makeAuto = ASI_FALSE; } ret = ASISetControlValue(camNum, control, value, makeAuto); if (ret != ASI_SUCCESS) { Log(-1, "WARNING: ASISetControlCaps() for control %d, value=%ld failed: %s\n", control, value, getRetCode(ret)); return(ret); } } else { Log(0, "ERROR: ControlCap: '%s' (#%d) not writable; not setting to %ld.\n", ControlCaps.Name, ControlCaps.ControlType, value); ret = ASI_ERROR_INVALID_MODE; // this seemed like the closest error } return ret; } } Log(2, "NOTICE: Camera does not support ControlCap # %d; not setting to %ld.\n", control, value); return ASI_ERROR_INVALID_CONTROL_TYPE; } //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- void *Display(void *params) { cv::Mat *pImg = (cv::Mat *)params; int w = pImg->cols; int h = pImg->rows; cv::namedWindow("Preview", cv::WINDOW_AUTOSIZE); cv::Mat Img2 = *pImg, *pImg2 = &Img2; while (bDisplay) { // default preview size usually fills whole screen, so shrink. cv::resize(*pImg, *pImg2, cv::Size((int)w/2, (int)h/2)); cv::imshow("Preview", *pImg2); cv::waitKey(500); // TODO: wait for exposure time instead of hard-coding value } cv::destroyWindow("Preview"); Log(4, "Display thread over\n"); return (void *)0; } void *SaveImgThd(void *para) { while (bSaveRun) { pthread_mutex_lock(&mtxSaveImg); pthread_cond_wait(&condStartSave, &mtxSaveImg); if (gotSignal) { // we got a signal to exit, so don't save the (probably incomplete) image pthread_mutex_unlock(&mtxSaveImg); break; } bSavingImg = true; // I don't know how to cast "st" to 0, so call now() and ignore it. auto st = std::chrono::high_resolution_clock::now(); auto et = st; bool result = false; if (pRgb.data) { char cmd[1100+strlen(CG.allskyHome)]; Log(1, " > Saving %s image '%s'\n", CG.takeDarkFrames ? "dark" : dayOrNight.c_str(), CG.finalFileName); snprintf(cmd, sizeof(cmd), "%s/scripts/saveImage.sh %s '%s'", CG.allskyHome, dayOrNight.c_str(), CG.fullFilename); add_variables_to_command(CG, cmd, exposureStartDateTime); strcat(cmd, " &"); st = std::chrono::high_resolution_clock::now(); try { result = imwrite(CG.fullFilename, pRgb, compressionParameters); } catch (const cv::Exception& ex) { Log(0, "*** ERROR: Exception saving image: %s\n", ex.what()); } et = std::chrono::high_resolution_clock::now(); if (result) system(cmd); else Log(0, "*** ERROR: Unable to save image '%s'.\n", CG.fullFilename); } else { // This can happen if the program is closed before the first picture. Log(0, "----- SaveImgThd(): pRgb.data is null\n"); } bSavingImg = false; if (result) { static int totalSaves = 0; static double totalTime_ms = 0; totalSaves++; // FIX: should be / ? long long diff_us = std::chrono::duration_cast<std::chrono::microseconds>(et - st).count(); double diff_ms = diff_us / US_IN_MS; totalTime_ms += diff_ms; char const *x; if (diff_ms > 1 * MS_IN_SEC) x = " > *****\n"; // indicate when it takes a REALLY long time to save else x = ""; Log(3, "%s > Image took %'.1f ms to save (average %'.1f ms).\n%s", x, diff_ms, totalTime_ms / totalSaves, x); } pthread_mutex_unlock(&mtxSaveImg); } return (void *)0; } long roundTo(long n, int roundTo) { long a = (n / roundTo) * roundTo; // Smaller multiple long b = a + roundTo; // Larger multiple return (n - a > b - n)? b : a; // Return of closest of two } #ifdef USE_HISTOGRAM // As of July 2021, ZWO's SDK (version 1.9) has a bug where autoexposure daylight shots' // exposures jump all over the place. One is way too dark and the next way too light, etc. // As a workaround, our histogram code replaces ZWO's code auto-exposure mechanism. // We look at the mean brightness of an X by X rectangle in image, and adjust exposure based on that. // FIXME prevent this from misbehaving when unreasonable settings are given, // eg. box size 0x0, box size WxW, box crosses image edge, ... basically // anything that would read/write out-of-bounds int computeHistogram(unsigned char *imageBuffer, config cg, int *histogram) { int h, i; unsigned char *buf = imageBuffer; // Clear the histogram array. for (h = 0; h < 256; h++) { histogram[h] = 0; } // Different image types have a different number of bytes per pixel. cg.width *= currentBpp; int roiX1 = (cg.width * cg.HB.histogramBoxPercentFromLeft) - (cg.HB.currentHistogramBoxSizeX * currentBpp / 2); int roiX2 = roiX1 + (currentBpp * cg.HB.currentHistogramBoxSizeX); int roiY1 = (cg.height * cg.HB.histogramBoxPercentFromTop) - (cg.HB.currentHistogramBoxSizeY / 2); int roiY2 = roiY1 + cg.HB.currentHistogramBoxSizeY; // Start off and end on a logical pixel boundries. roiX1 = (roiX1 / currentBpp) * currentBpp; roiX2 = (roiX2 / currentBpp) * currentBpp; // For RGB24, data for each pixel is stored in 3 consecutive bytes: blue, green, red. // For all image types, each row in the image contains one row of pixels. // currentBpp doesn't apply to rows, just columns. switch (cg.imageType) { case IMG_RGB24: case IMG_RAW8: case IMG_Y8: for (int y = roiY1; y < roiY2; y++) { for (int x = roiX1; x < roiX2; x+=currentBpp) { i = (cg.width * y) + x; int total = 0; for (int z = 0; z < currentBpp; z++) { // For RGB24 this averages the blue, green, and red pixels. total += buf[i+z]; } int avg = total / currentBpp; histogram[avg]++; } } break; case IMG_RAW16: for (int y = roiY1; y < roiY2; y++) { for (int x = roiX1; x < roiX2; x+=currentBpp) { i = (cg.width * y) + x; int pixelValue; // This assumes the image data is laid out in big endian format. // We are going to grab the most significant byte // and use that for the histogram value ignoring the // least significant byte so we can use the 256 value histogram array. // If it's acutally little endian then add a +1 to the array subscript for buf[i]. pixelValue = buf[i]; histogram[pixelValue]++; } } break; case ASI_IMG_END: break; } // Now calculate the mean. int meanBin = 0; int a = 0, b = 0; for (int h = 0; h < 256; h++) { a += (h+1) * histogram[h]; b += histogram[h]; } if (b == 0) { // This is one heck of a dark picture! return(0); } meanBin = a/b - 1; return meanBin; } #endif // This is based on code from PHD2. // Camera has 2 internal frame buffers we need to clear. // The camera and/or driver will buffer frames and return the oldest one which // could be very old. Read out all the buffered frames so the frame we get is current. void flushBufferedImages(int cameraId, void *buf, size_t size) { enum { NUM_IMAGE_BUFFERS = 2 }; int numCleared; for (numCleared = 0; numCleared < NUM_IMAGE_BUFFERS; numCleared++) { ASI_ERROR_CODE status = ASIGetVideoData(cameraId, (unsigned char *) buf, size, 1); /*xxxxx if (status != ASI_SUCCESS) break; // no more buffered frames */ if (status != ASI_ERROR_TIMEOUT) // Most are ASI_ERROR_TIMEOUT, so don't show them Log(3, " > [Cleared buffer frame]: %s\n", getRetCode(status)); } } // Next exposure suggested by the camera. long suggestedNextExposure_us = 0; // "auto" flag returned by ASIGetControlValue(), when we don't care what it is. ASI_BOOL bAuto = ASI_FALSE; ASI_BOOL wasAutoExposure = ASI_FALSE; long bufferSize = NOT_SET; ASI_ERROR_CODE takeOneExposure(config *cg, unsigned char *imageBuffer, int *histogram) { if (imageBuffer == NULL) { return (ASI_ERROR_CODE) -1; } ASI_ERROR_CODE status; // ZWO recommends timeout = (exposure*2) + 500 ms // After some discussion, we're doing +5000ms to account for delays induced by // USB contention, such as that caused by heavy USB disk IO long timeout = ((cg->currentExposure_us * 2) / US_IN_MS) + 5000; // timeout is in ms // This debug message isn't typcally needed since we already displayed a message about // starting a new exposure, and below we display the result when the exposure is done. Log(4, " > %s to %s\n", wasAutoExposure == ASI_TRUE ? "Camera set auto-exposure" : "Exposure set", length_in_units(cg->currentExposure_us, true)); setControl(cg->cameraNumber, ASI_EXPOSURE, cg->currentExposure_us, cg->currentAutoExposure ? ASI_TRUE :ASI_FALSE); flushBufferedImages(cg->cameraNumber, imageBuffer, bufferSize); if (cg->videoOffBetweenImages) { status = ASIStartVideoCapture(cg->cameraNumber); } else { status = ASI_SUCCESS; } if (status == ASI_SUCCESS) { // Make sure the actual time to take the picture is "close" to the requested time. auto tStart = std::chrono::high_resolution_clock::now(); status = ASIGetVideoData(cg->cameraNumber, imageBuffer, bufferSize, timeout); if (cg->videoOffBetweenImages) (void) ASIStopVideoCapture(cg->cameraNumber); if (status != ASI_SUCCESS) { int exitCode; Log(0, " > ERROR: Failed getting image: %s\n", getRetCode(status)); // Check if we reached the maximum number of consective errors if (! checkMaxErrors(&exitCode, maxErrors)) { closeUp(exitCode); } } else { // The timeToTakeImage_us should never be less than what was requested. // and shouldn't be less then the time taked plus overhead of setting up the shot. auto tElapsed = std::chrono::high_resolution_clock::now() - tStart; long timeToTakeImage_us = std::chrono::duration_cast<std::chrono::microseconds>(tElapsed).count(); long diff_us = timeToTakeImage_us - cg->currentExposure_us; long threshold_us = 0; bool tooShort = false; if (diff_us < 0) { tooShort = true; // WAY too short } else if (cg->currentExposure_us > (5 * US_IN_SEC)) { // There is too much variance in the overhead of taking pictures to // accurately determine the actual time to take an image at short exposures, // so only check for long ones. // Testing shows there's about this much us overhead, // so subtract it to get our best estimate of the "actual" time. const int OVERHEAD = 340000; // Don't subtract if it would have made timeToTakeImage_us negative. if (timeToTakeImage_us > OVERHEAD) diff_us -= OVERHEAD; threshold_us = cg->currentExposure_us * 0.5; // 50% seems like a good number if (abs(diff_us) > threshold_us) tooShort = true; } if (tooShort) { Log(1, "*** WARNING: Time to take exposure (%s) ", length_in_units(timeToTakeImage_us, true)); Log(1, "differs from requested exposure time (%s) ", length_in_units(cg->currentExposure_us, true)); Log(1, "by %s, ", length_in_units(diff_us, true)); Log(1, "threshold=%'ld\n", length_in_units(threshold_us, true)); } else { Log(4, " > timeToTakeImage_us=%'ld us, diff_us=%'ld, threshold_us=%'ld\n", timeToTakeImage_us, diff_us, threshold_us); } numErrors = 0; long l; ASIGetControlValue(cg->cameraNumber, ASI_GAIN, &l, &bAuto); cg->lastGain = (double) l; debug_text[0] = '\0'; #ifdef USE_HISTOGRAM if (histogram != NULL) { cg->lastMean = (double)computeHistogram(imageBuffer, *cg, histogram); sprintf(debug_text, " @ mean %d", (int) cg->lastMean); if (cg->currentAutoGain && ! cg->takeDarkFrames) { char *p = debug_text + strlen(debug_text); sprintf(p, ", auto gain %ld", (long) cg->lastGain); } } #endif cg->lastExposure_us = cg->currentExposure_us; // Per ZWO, when in manual-exposure mode, the returned exposure length should always // be equal to the requested length; in fact, "there's no need to call ASIGetControlValue()". // When in auto-exposure mode, the returned exposure length is what the driver thinks the // next exposure should be, and will eventually converge on the correct exposure. ASIGetControlValue(cg->cameraNumber, ASI_EXPOSURE, &suggestedNextExposure_us, &wasAutoExposure); Log(2, " > Got image%s.", debug_text); if (cg->currentAutoExposure) Log(3, " Suggested next exposure: %s", length_in_units(suggestedNextExposure_us, true)); Log(2, "\n"); long temp; ASIGetControlValue(cg->cameraNumber, ASI_TEMPERATURE, &temp, &bAuto); cg->lastSensorTemp = (long) ((double)temp / cg->divideTemperatureBy); if (cg->isColorCamera) { ASIGetControlValue(cg->cameraNumber, ASI_WB_R, &l, &bAuto); cg->lastWBR = (double) l; ASIGetControlValue(cg->cameraNumber, ASI_WB_B, &l, &bAuto); cg->lastWBB = (double) l; } if (cg->asiAutoBandwidth) ASIGetControlValue(cg->cameraNumber, ASI_BANDWIDTHOVERLOAD, &cg->lastAsiBandwidth, &wasAutoExposure); } } else { Log(0, " > ERROR: Not fetching exposure data because status is %s\n", getRetCode(status)); } return status; } bool adjustGain = false; // Should we adjust the gain? Set by user on command line. bool currentAdjustGain = false; // Adjusting it right now? int totalAdjustGain = 0; // The total amount to adjust gain. int perImageAdjustGain = 0; // Amount of gain to adjust each image int gainTransitionImages = 0; int numGainChanges = 0; // This is reset at every day/night and night/day transition. // Reset the gain transition variables for the first transition image. // This is called when the program first starts and at the beginning of every day/night transition. // "dayOrNight" is the new value, e.g., if we just transitioned from day to night, it's "NIGHT". bool resetGainTransitionVariables(config cg) { if (adjustGain == false) { // determineGainChange() will never be called so no need to set any variables. return(false); } if (numExposures == 0) { // we don't adjust when the program first starts since there's nothing to transition from return(false); } // Determine the amount to adjust gain per image. // Do this once per day/night or night/day transition (i.e., numGainChanges == 0). // First determine how long an exposure and delay is, in seconds. // The user specifies the transition period in seconds, // but day exposure is in microseconds, night max is in milliseconds, // and delays are in milliseconds, so convert to seconds. float totalTimeInSec; if (dayOrNight == "DAY") { totalTimeInSec = (cg.dayExposure_us / US_IN_SEC) + (cg.dayDelay_ms / MS_IN_SEC); } else // NIGHT { // At nightime if the exposure is less than the max, we wait until max has expired, // so use it instead of the exposure time. totalTimeInSec = (cg.nightMaxAutoExposure_us / US_IN_SEC) + (cg.nightDelay_ms / MS_IN_SEC); } gainTransitionImages = ceil(cg.gainTransitionTime / totalTimeInSec); if (gainTransitionImages == 0) { Log(-1, "*** INFORMATION: Not adjusting gain - your 'gaintransitiontime' (%d seconds) is less than the time to take one image plus its delay (%.1f seconds).\n", cg.gainTransitionTime, totalTimeInSec); return(false); } totalAdjustGain = cg.nightGain - cg.dayGain; perImageAdjustGain = ceil(totalAdjustGain / gainTransitionImages); // spread evenly if (perImageAdjustGain == 0) perImageAdjustGain = totalAdjustGain; else { // Since we can't adust gain by fractions, see if there's any "left over" after gainTransitionImages. // For example, if totalAdjustGain is 7 and we're adjusting by 3 each of 2 times, // we need an extra transition to get the remaining 1 ((7 - (3 * 2)) == 1). if (gainTransitionImages * perImageAdjustGain < totalAdjustGain) gainTransitionImages++; // this one will get the remaining amount } Log(4, " totalAdjustGain=%d, gainTransitionImages=%d\n", totalAdjustGain, gainTransitionImages); return(true); } // Determine the change in gain needed for smooth transitions between night and day. // Gain during the day is usually 0 and at night is usually > 0. // If auto-exposure is on for both, the first several night frames may be too bright at night // because of the sudden (often large) increase in gain, or too dark at the night-to-day // transition. // Try to mitigate that by changing the gain over several images at each transition. int determineGainChange(config cg) { if (numGainChanges > gainTransitionImages || totalAdjustGain == 0) { // no more changes needed in this transition Log(4, " xxxx No more gain changes needed.\n"); currentAdjustGain = false; return(0); } numGainChanges++; int amt; // amount to adjust gain on next picture if (dayOrNight == "DAY") { // During DAY, want to start out adding the full gain adjustment minus the increment on the first image, // then DECREASE by totalAdjustGain each exposure. // This assumes night gain is > day gain. amt = totalAdjustGain - (perImageAdjustGain * numGainChanges); Log(4, ">> DAY: amt=%d, totalAdjustGain=%d, perImageAdjustGain=%d, numGainChanges=%d\n", amt, totalAdjustGain, perImageAdjustGain, numGainChanges); if (amt < 0) { amt = 0; totalAdjustGain = 0; // we're done making changes } } else // NIGHT { // During NIGHT, want to start out (nightGain-perImageAdjustGain), // then DECREASE by perImageAdjustGain each time, until we get to "nightGain". // This last image was at dayGain and we wen't to increase each image. amt = (perImageAdjustGain * numGainChanges) - totalAdjustGain; if (amt > 0) { amt = 0; totalAdjustGain = 0; // we're done making changes } } Log(4, "Adjusting %s gain by %d on next picture to %d (currentGain=%2f); will be gain change # %d of %d.\n", dayOrNight.c_str(), amt, amt+(int)cg.currentGain, cg.currentGain, numGainChanges, gainTransitionImages); return(amt); } // Check if the maximum number of consecutive errors has been reached bool checkMaxErrors(int *e, int maxErrors) { // Once takeOneExposure() fails with a timeout, it seems to always fail, // even with extremely large timeout values, so apparently ASI_ERROR_TIMEOUT doesn't // necessarily mean it's timing out. Exit which will cause us to be restarted. numErrors++; sleep(2); if (numErrors >= maxErrors) { *e = EXIT_RESET_USB; // exit code. Need to reset USB bus Log(0, "*** ERROR: Maximum number of consecutive errors of %d reached; capture program exited.\n", maxErrors); return(false); // gets us out of inner and outer loop } return(true); } //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- int main(int argc, char *argv[]) { CG.ME = argv[0]; static char *a = getenv("ALLSKY_HOME"); // This must come before anything else if (a == NULL) { Log(0, "%s: ERROR: ALLSKY_HOME not set!\n", CG.ME); exit(EXIT_ERROR_STOP); } else { CG.allskyHome = a; } pthread_mutex_init(&mtxSaveImg, 0); pthread_cond_init(&condStartSave, 0); char bufTime[128] = { 0 }; char bufTemp[1024] = { 0 }; char const *bayer[] = { "RG", "BG", "GR", "GB" }; bool justTransitioned = false; ASI_ERROR_CODE asiRetCode; // used for return code from ASI functions. // Some settings have both day and night versions, some have only one version that applies to both, // and some have either a day OR night version but not both. // For settings with both versions we keep a "current" variable (e.g., "currentBin") that's either the day // or night version so the code doesn't always have to check if it's day or night. // The settings have either "day" or "night" in the name. // In theory, almost every setting could have both day and night versions (e.g., width & height), // but the chances of someone wanting different versions. #ifdef USE_HISTOGRAM int maxHistogramAttempts = 15; // max number of times we'll try for a better histogram mean // If we just transitioned from night to day, it's possible currentExposure_us will // be MUCH greater than the daytime max (and will possibly be at the nighttime's max exposure). // So, decrease currentExposure_us by a certain amount of the difference between the two so // it takes several frames to reach the daytime max (which is now in currentMaxAutoExposure_us). // If we don't do this, we'll be stuck in a loop taking an exposure // that's over the max forever. // Note that it's likely getting lighter outside with every exposure // so the mean will eventually get into the valid range. const int percentChange = 10.0; // percent of ORIGINAL difference #endif //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- setlinebuf(stdout); // Line buffer output so entries appear in the log immediately. CG.ct = ctZWO; if (! getCommandLineArguments(&CG, argc, argv)) { // getCommandLineArguents outputs an error message. exit(EXIT_ERROR_STOP); } if (! CG.saveCC && ! CG.help) { displayHeader(CG); } doLocale(&CG); if (CG.help) { displayHelp(CG); closeUp(EXIT_OK); } processConnectedCameras(); // exits on error ASI_CAMERA_INFO ASICameraInfo; asiRetCode = ASIOpenCamera(CG.cameraNumber); if (asiRetCode != ASI_SUCCESS) { Log(0, "*** ERROR opening camera, check that you have root permissions! (%s)\n", getRetCode(asiRetCode)); closeUp(EXIT_NO_CAMERA); } asiRetCode = ASIGetCameraProperty(&ASICameraInfo, CG.cameraNumber); if (asiRetCode != ASI_SUCCESS) { Log(0, "ERROR: ASIGetCamerProperty() returned: %s\n", getRetCode(asiRetCode)); exit(EXIT_ERROR_STOP); } asiRetCode = ASIGetNumOfControls(CG.cameraNumber, &iNumOfCtrl); if (asiRetCode != ASI_SUCCESS) { Log(0, "ERROR: ASIGetNumOfControls() returned: %s\n", getRetCode(asiRetCode)); exit(EXIT_ERROR_STOP); } CG.ASIversion = ASIGetSDKVersion(); // Set defaults that depend on the camera type. if (! setDefaults(&CG, ASICameraInfo)) closeUp(EXIT_ERROR_STOP); // Do argument error checking if we're not going to exit soon. if (! CG.saveCC && ! validateSettings(&CG, ASICameraInfo)) closeUp(EXIT_ERROR_STOP); if (! checkForValidExtension(&CG)) { // checkForValidExtension() displayed the error message. closeUp(EXIT_ERROR_STOP); } int iMaxWidth, iMaxHeight; double pixelSize; iMaxWidth = ASICameraInfo.MaxWidth; iMaxHeight = ASICameraInfo.MaxHeight; pixelSize = ASICameraInfo.PixelSize; if (CG.width == 0 || CG.height == 0) { CG.width = iMaxWidth; CG.height = iMaxHeight; } else { validateLong(&CG.width, 0, iMaxWidth, "Width", true); validateLong(&CG.height, 0, iMaxHeight, "Height", true); } long originalWidth = CG.width; long originalHeight = CG.height; // Limit these to a reasonable value based on the size of the sensor. validateLong(&CG.overlay.iTextLineHeight, 0, (long)(iMaxHeight / 2), "Line Height", true); validateLong(&CG.overlay.iTextX, 0, (long)iMaxWidth - 10, "Text X", true); validateLong(&CG.overlay.iTextY, 0, (long)iMaxHeight - 10, "Text Y", true); validateFloat(&CG.overlay.fontsize, 0.1, iMaxHeight / 2, "Font Size", true); validateLong(&CG.overlay.linewidth, 0, (long)(iMaxWidth / 2), "Font Weight", true); if (CG.saveCC) { saveCameraInfo(ASICameraInfo, CG.CC_saveFile, iMaxWidth, iMaxHeight, pixelSize, bayer[ASICameraInfo.BayerPattern]); closeUp(EXIT_OK); } outputCameraInfo(ASICameraInfo, CG, iMaxWidth, iMaxHeight, pixelSize, bayer[ASICameraInfo.BayerPattern]); // checkExposureValues() must come after outputCameraInfo(). (void) checkExposureValues(&CG); #ifdef USE_HISTOGRAM // The histogram box needs to fit on the image. // If we're binning we'll decrease the size of the box accordingly. bool ok = true; if (CG.HB.sArgs[0] != '\0') { if (sscanf(CG.HB.sArgs, "%d %d %f %f", &CG.HB.histogramBoxSizeX, &CG.HB.histogramBoxSizeY, &CG.HB.histogramBoxPercentFromLeft, &CG.HB.histogramBoxPercentFromTop) != 4) { Log(0, "%s*** ERROR: Not enough histogram box parameters should be 4: '%s'%s\n", c(KRED), CG.HB.sArgs, c(KNRM)); ok = false; } else { if (CG.HB.histogramBoxSizeX < 1 || CG.HB.histogramBoxSizeY < 1) { Log(0, "%s*** ERROR: Histogram box size must be > 0; you entered X=%d, Y=%d%s\n", c(KRED), CG.HB.histogramBoxSizeX, CG.HB.histogramBoxSizeY, c(KNRM)); ok = false; } if (CG.HB.histogramBoxPercentFromLeft < 0.0 || CG.HB.histogramBoxPercentFromTop < 0.0) { Log(0, "%s*** ERROR: Histogram box percents must be > 0; you entered X=%.0f%%, Y=%.0f%%%s\n", c(KRED), (CG.HB.histogramBoxPercentFromLeft*100.0), (CG.HB.histogramBoxPercentFromTop*100.0), c(KNRM)); ok = false; } else { // scale user-input 0-100 to 0.0-1.0 CG.HB.histogramBoxPercentFromLeft /= 100; CG.HB.histogramBoxPercentFromTop /= 100; // Now check if the box fits the image. CG.HB.centerX = CG.width * CG.HB.histogramBoxPercentFromLeft; CG.HB.centerY = CG.height * CG.HB.histogramBoxPercentFromTop; CG.HB.leftOfBox = CG.HB.centerX - (CG.HB.histogramBoxSizeX / 2); CG.HB.rightOfBox = CG.HB.centerX + (CG.HB.histogramBoxSizeX / 2); CG.HB.topOfBox = CG.HB.centerY - (CG.HB.histogramBoxSizeY / 2); CG.HB.bottomOfBox = CG.HB.centerY + (CG.HB.histogramBoxSizeY / 2); if (CG.HB.leftOfBox < 0 || CG.HB.rightOfBox >= CG.width || CG.HB.topOfBox < 0 || CG.HB.bottomOfBox >= CG.height) { Log(0, "%s*** ERROR: Histogram box location must fit on image; upper left of box is %dx%d, lower right %dx%d%s\n", c(KRED), CG.HB.leftOfBox, CG.HB.topOfBox, CG.HB.rightOfBox, CG.HB.bottomOfBox, c(KNRM)); ok = false; } // else everything is hunky dory } } } else { Log(0, "%s*** ERROR: No values specified for histogram box%s\n", c(KRED), c(KNRM)); ok = false; } if (! ok) { closeUp(EXIT_ERROR_STOP); // force the user to fix it } #endif asiRetCode = ASIInitCamera(CG.cameraNumber); if (asiRetCode != ASI_SUCCESS) { Log(0, "*** ERROR: Unable to initialise camera: %s\n", getRetCode(asiRetCode)); closeUp(EXIT_ERROR_STOP); // Can't do anything so might as well exit. } // Handle "auto" imageType. if (CG.imageType == AUTO_IMAGE_TYPE) { // If it's a color camera, create color pictures. // If it's a mono camera use RAW16 if the image file is a .png, otherwise use RAW8. // There is no good way to handle Y8 automatically so it has to be set manually. if (CG.isColorCamera) CG.imageType = IMG_RGB24; else if (strcmp(CG.imageExt, "png") == 0) CG.imageType = IMG_RAW16; else // jpg CG.imageType = IMG_RAW8; } if (CG.imageType == IMG_RAW16) { CG.sType = "RAW16"; currentBpp = 2; CG.currentBitDepth = 16; } else if (CG.imageType == IMG_RGB24) { CG.sType = "RGB24"; currentBpp = 3; CG.currentBitDepth = 8; } else if (CG.imageType == IMG_RAW8) { // Color cameras should use Y8 instead of RAW8. Y8 is the mono mode for color cameras. if (CG.isColorCamera) { CG.imageType = IMG_Y8; CG.sType = "Y8 (not RAW8 for color cameras)"; } else { CG.sType = "RAW8"; } currentBpp = 1; CG.currentBitDepth = 8; } else if (CG.imageType == IMG_Y8) { CG.sType = "Y8"; currentBpp = 1; CG.currentBitDepth = 8; } else { Log(0, "*** ERROR: Unknown Image Type: %d\n", CG.imageType); closeUp(EXIT_ERROR_STOP); } //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- displaySettings(CG); // These configurations apply to both day and night. // Other calls to setControl() are done after we know if we're in daytime or nighttime. if (CG.asiBandwidth != NOT_CHANGED) setControl(CG.cameraNumber, ASI_BANDWIDTHOVERLOAD, CG.asiBandwidth, CG.asiAutoBandwidth ? ASI_TRUE : ASI_FALSE); if (CG.gamma != NOT_CHANGED) setControl(CG.cameraNumber, ASI_GAMMA, CG.gamma, ASI_FALSE); if (CG.offset != NOT_CHANGED) setControl(CG.cameraNumber, ASI_OFFSET, CG.offset, ASI_FALSE); if (CG.flip != NOT_CHANGED) setControl(CG.cameraNumber, ASI_FLIP, CG.flip, ASI_FALSE); if (! bSaveRun && pthread_create(&hthdSave, 0, SaveImgThd, 0) == 0) { bSaveRun = true; } // Initialization int originalITextX = CG.overlay.iTextX; int originalITextY = CG.overlay.iTextY; int originalFontsize = CG.overlay.fontsize; int originalLinewidth = CG.overlay.linewidth; // Have we displayed "not taking picture during day" message, if applicable? bool displayedNoDaytimeMsg = false; int gainChange = 0; // how much to change gain up or down // Display one-time messages. // If autogain is on, our adjustments to gain will get overwritten by the camera // so don't transition. // gainTransitionTime of 0 means don't adjust gain. // No need to adjust gain if day and night gain are the same. if (CG.dayAutoGain || CG.nightAutoGain || CG.gainTransitionTime == 0 || CG.dayGain == CG.nightGain || CG.takeDarkFrames) { adjustGain = false; Log(4, "Will NOT adjust gain at transitions\n"); } else { adjustGain = true; Log(4, "Will adjust gain at transitions\n"); } if (CG.overlay.ImgExtraText[0] != '\0' && CG.overlay.extraFileAge > 0) { Log(4, "Extra Text File Age Disabled So Displaying Anyway\n"); } // Start taking pictures if (! CG.videoOffBetweenImages) { asiRetCode = ASIStartVideoCapture(CG.cameraNumber); if (asiRetCode != ASI_SUCCESS) { Log(0, "*** ERROR: Unable to start video capture: %s\n", getRetCode(asiRetCode)); closeUp(EXIT_ERROR_STOP); } } while (bMain) { // Find out if it is currently DAY or NIGHT dayOrNight = calculateDayOrNight(CG.latitude, CG.longitude, CG.angle); std::string lastDayOrNight = dayOrNight; if (! CG.takeDarkFrames) currentAdjustGain = resetGainTransitionVariables(CG); if (CG.takeDarkFrames) { // We're doing dark frames so turn off autoexposure and autogain, and use // nightime gain, delay, max exposure, bin, and brightness to mimic a nightime shot. CG.currentSkipFrames = 0; CG.currentAutoExposure = false; CG.nightAutoExposure = false; CG.currentAutoGain = false; CG.currentGain = CG.nightGain; CG.currentMaxAutoGain = CG.nightMaxAutoGain; // not needed since we're not using auto gain, but set to be consistent gainChange = 0; CG.currentDelay_ms = CG.nightDelay_ms; CG.currentMaxAutoExposure_us = CG.currentExposure_us = CG.nightMaxAutoExposure_us; CG.currentBin = CG.nightBin; CG.currentBrightness = CG.nightBrightness; if (CG.isColorCamera) { CG.currentAutoAWB = false; CG.currentWBR = CG.nightWBR; CG.currentWBB = CG.nightWBB; } if (CG.isCooledCamera) { CG.currentEnableCooler = CG.nightEnableCooler; CG.currentTargetTemp = CG.nightTargetTemp; } CG.myModeMeanSetting.currentMean = NOT_SET; CG.myModeMeanSetting.modeMean = false; CG.HB.useHistogram = false; Log(1, "Taking dark frames...\n"); if (CG.notificationImages) { (void) displayNotificationImage("--expires 0 DarkFrames &"); } } else if (dayOrNight == "DAY") { if (justTransitioned == true) { // Just transitioned from night to day, so execute end of night script Log(1, "Processing end of night data\n"); snprintf(bufTemp, sizeof(bufTemp)-1, "%s/scripts/endOfNight.sh &", CG.allskyHome); system(bufTemp); justTransitioned = false; displayedNoDaytimeMsg = false; } if (! CG.daytimeCapture) { displayedNoDaytimeMsg = daytimeSleep(displayedNoDaytimeMsg, CG); // No need to do any of the code below so go back to the main loop. continue; } else { Log(1, "==========\n=== Starting daytime capture ===\n==========\n"); // We only skip initial frames if we are starting in daytime and using auto-exposure. if (numExposures == 0 && CG.dayAutoExposure) CG.currentSkipFrames = CG.daySkipFrames; // If we went from Night to Day, then currentExposure_us will be the last night // exposure so leave it if we're using auto-exposure so there's a seamless change from // Night to Day, i.e., if the exposure was fine a minute ago it will likely be fine now. // On the other hand, if this program just started or we're using manual exposures, // use what the user specified. if (numExposures == 0 || ! CG.dayAutoExposure) { CG.currentExposure_us = CG.dayExposure_us; } else { // If gain changes, we have to change the exposure time to get an equally // exposed image. // ZWO gain has unit 0.1dB, so we have to convert the gain values to a factor first // newExp = (oldExp * oldGain) / newGain // e.g. 20s = (10s * 2.0) / (1.0) // current values here are last night's values double oldGain = pow(10, CG.currentGain / 10.0 / 20.0); double newGain = pow(10, CG.dayGain / 10.0 / 20.0); Log(4, "Using the last night exposure (%s),", length_in_units(CG.currentExposure_us, true)); CG.currentExposure_us = (CG.currentExposure_us * oldGain) / newGain; Log(4," old (%'2f) and new (%'2f) Gain to calculate new exposure of %s\n", oldGain, newGain, length_in_units(CG.currentExposure_us, true)); } CG.currentMaxAutoExposure_us = CG.dayMaxAutoExposure_us; Log(4, "currentMaxAutoExposure_us set to daytime value of %s.\n", length_in_units(CG.currentMaxAutoExposure_us, true)); if (CG.currentExposure_us > CG.currentMaxAutoExposure_us) { Log(3, "Decreasing currentExposure_us from %s", length_in_units(CG.currentExposure_us, true)); Log(3, "to %s\n", length_in_units(CG.currentMaxAutoExposure_us, true)); CG.currentExposure_us = CG.currentMaxAutoExposure_us; } #ifdef USE_HISTOGRAM // Don't use camera auto-exposure since we mimic it ourselves. if (CG.dayAutoExposure) { CG.HB.useHistogram = true; Log(4, "Turning off ZWO auto-exposure to use Allsky auto-exposure.\n"); } else { CG.HB.useHistogram = false; } // With the histogram method we NEVER use ZWO auto exposure - either the user said // not to, or we turn it off ourselves. CG.currentAutoExposure = false; #else CG.currentAutoExposure = CG.dayAutoExposure; CG.HB.useHistogram = false; #endif CG.currentBrightness = CG.dayBrightness; if (CG.isColorCamera) { CG.currentAutoAWB = CG.dayAutoAWB; CG.currentWBR = CG.dayWBR; CG.currentWBB = CG.dayWBB; } CG.currentDelay_ms = CG.dayDelay_ms; CG.currentBin = CG.dayBin; CG.currentGain = CG.dayGain; // must come before determineGainChange() below CG.currentMaxAutoGain = CG.dayMaxAutoGain; if (currentAdjustGain) { // we did some nightime images so adjust gain numGainChanges = 0; gainChange = determineGainChange(CG); } else { gainChange = 0; } CG.currentAutoGain = CG.dayAutoGain; CG.myModeMeanSetting.currentMean = CG.myModeMeanSetting.dayMean; if (CG.isCooledCamera) { CG.currentEnableCooler = CG.dayEnableCooler; CG.currentTargetTemp = CG.dayTargetTemp; } } } else // NIGHT { if (justTransitioned == true) { // Just transitioned from day to night, so execute end of day script Log(1, "Processing end of day data\n"); snprintf(bufTemp, sizeof(bufTemp)-1, "%s/scripts/endOfDay.sh &", CG.allskyHome); system(bufTemp); justTransitioned = false; } Log(1, "==========\n=== Starting nighttime capture ===\n==========\n"); // We only skip initial frames if we are starting in nighttime and using auto-exposure. if (numExposures == 0 && CG.nightAutoExposure) CG.currentSkipFrames = CG.nightSkipFrames; // Setup the night time capture parameters if (numExposures == 0 || ! CG.nightAutoExposure) { CG.currentExposure_us = CG.nightExposure_us; } CG.currentAutoExposure = CG.nightAutoExposure; CG.currentBrightness = CG.nightBrightness; if (CG.isColorCamera) { CG.currentAutoAWB = CG.nightAutoAWB; CG.currentWBR = CG.nightWBR; CG.currentWBB = CG.nightWBB; } CG.currentDelay_ms = CG.nightDelay_ms; CG.currentBin = CG.nightBin; CG.currentMaxAutoExposure_us = CG.nightMaxAutoExposure_us; CG.currentGain = CG.nightGain; // must come before determineGainChange() below CG.currentMaxAutoGain = CG.nightMaxAutoGain; if (currentAdjustGain) { // we did some daytime images so adjust gain numGainChanges = 0; gainChange = determineGainChange(CG); } else { gainChange = 0; } CG.currentAutoGain = CG.nightAutoGain; CG.myModeMeanSetting.currentMean = CG.myModeMeanSetting.nightMean; if (CG.isCooledCamera) { CG.currentEnableCooler = CG.nightEnableCooler; CG.currentTargetTemp = CG.nightTargetTemp; } CG.HB.useHistogram = false; // only used during day } // ========== Done with dark frams / day / night settings if (CG.myModeMeanSetting.currentMean > 0.0) { CG.myModeMeanSetting.modeMean = true; /* TODO: FUTURE myModeMeanSetting.meanValue = CG.myModeMeanSetting.currentMean; if (! aegInit(cg, minExposure_us, CG.cameraMinGain, myRaspistillSetting, myModeMeanSetting)) { closeUp(EXIT_ERROR_STOP); } */ } else { CG.myModeMeanSetting.modeMean = false; } if (CG.isColorCamera) { setControl(CG.cameraNumber, ASI_WB_R, CG.currentWBR, CG.currentAutoAWB ? ASI_TRUE : ASI_FALSE); setControl(CG.cameraNumber, ASI_WB_B, CG.currentWBB, CG.currentAutoAWB ? ASI_TRUE : ASI_FALSE); } else if (! CG.currentAutoAWB && ! CG.takeDarkFrames) { // We only read the actual values if in auto white balance; since we're not, get them now. CG.lastWBR = CG.currentWBR; CG.lastWBB = CG.currentWBB; } if (CG.isCooledCamera) { asiRetCode = setControl(CG.cameraNumber, ASI_COOLER_ON, CG.currentEnableCooler ? ASI_TRUE : ASI_FALSE, ASI_FALSE); if (asiRetCode != ASI_SUCCESS) { Log(1, "%s", c(KYEL)); Log(1, " WARNING: Could not change cooler state: %s; continuing.\n", getRetCode(asiRetCode)); Log(1, "%s", c(KNRM)); } asiRetCode = setControl(CG.cameraNumber, ASI_TARGET_TEMP, CG.currentTargetTemp, ASI_FALSE); if (asiRetCode != ASI_SUCCESS) { Log(1, "%s", c(KYEL)); Log(1, " WARNING: Could not set cooler temperature: %s; continuing.\n", getRetCode(asiRetCode)); Log(1, "%s", c(KNRM)); } } setControl(CG.cameraNumber, ASI_GAIN, (long)CG.currentGain + gainChange, CG.currentAutoGain ? ASI_TRUE : ASI_FALSE); if (CG.currentAutoGain) setControl(CG.cameraNumber, ASI_AUTO_MAX_GAIN, CG.currentMaxAutoGain, ASI_FALSE); if (CG.currentAutoExposure) { setControl(CG.cameraNumber, ASI_AUTO_MAX_EXP, CG.currentMaxAutoExposure_us / US_IN_MS, ASI_FALSE); setControl(CG.cameraNumber, ASI_AUTO_TARGET_BRIGHTNESS, CG.currentBrightness, ASI_FALSE); } #ifndef USE_HISTOGRAM setControl(CG.cameraNumber, ASI_EXPOSURE, CG.currentExposure_us, CG.currentAutoExposure ? ASI_TRUE : ASI_FALSE); // If not using histogram algorithm, ASI_EXPOSURE is set in takeOneExposure() #endif if (numExposures == 0 || CG.dayBin != CG.nightBin) { // Adjusting variables for chosen binning. // Only need to do at the beginning and if bin changes. CG.height = originalHeight / CG.currentBin; CG.width = originalWidth / CG.currentBin; CG.overlay.iTextX = originalITextX / CG.currentBin; CG.overlay.iTextY = originalITextY / CG.currentBin; CG.overlay.fontsize = originalFontsize / CG.currentBin; CG.overlay.linewidth = originalLinewidth / CG.currentBin; CG.HB.currentHistogramBoxSizeX = CG.HB.histogramBoxSizeX / CG.currentBin; CG.HB.currentHistogramBoxSizeY = CG.HB.histogramBoxSizeY / CG.currentBin; bufferSize = CG.width * CG.height * currentBpp; // TODO: if not the first time, should we free the old pRgb? if (CG.imageType == IMG_RAW16) { pRgb.create(cv::Size(CG.width, CG.height), CV_16UC1); } else if (CG.imageType == IMG_RGB24) { pRgb.create(cv::Size(CG.width, CG.height), CV_8UC3); } else // RAW8 and Y8 { pRgb.create(cv::Size(CG.width, CG.height), CV_8UC1); } // TODO: ASISetStartPos(CG.cameraNumber, from_left_xxx, from_top_xxx); By default it's at the center. // TODO: width % 8 must be 0. height % 2 must be 0. // TODO: ASI120's (width*height) % 1024 must be 0 asiRetCode = ASISetROIFormat(CG.cameraNumber, CG.width, CG.height, CG.currentBin, (ASI_IMG_TYPE)CG.imageType); if (asiRetCode != ASI_SUCCESS) { if (asiRetCode == ASI_ERROR_INVALID_SIZE) { Log(0, "*** ERROR: your camera does not support bin %dx%d.\n", CG.currentBin, CG.currentBin); closeUp(EXIT_ERROR_STOP); } else { Log(0, "*** ERROR: ASISetROIFormat(%d, %dx%d, %d, %d) failed (%s)\n", CG.cameraNumber, CG.width, CG.height, CG.currentBin, CG.imageType, getRetCode(asiRetCode)); closeUp(EXIT_ERROR_STOP); } } } // Here and below, indent sub-messages with " > " so it's clear they go with the un-indented line. // This simply makes it easier to see things in the log file. #ifdef USE_HISTOGRAM int attempts = 0; int histogram[256]; #else int *histogram = NULL; #endif // Wait for switch day time -> night time or night time -> day time while (bMain && lastDayOrNight == dayOrNight) { // date/time is added to many log entries to make it easier to associate them // with an image (which has the date/time in the filename). exposureStartDateTime = getTimeval(); char exposureStart[128]; snprintf(exposureStart, sizeof(exposureStart), "%s", formatTime(exposureStartDateTime, "%F %T")); // Unfortunately our histogram method only does exposure, not gain, so we // can't say what gain we are going to use. Log(2, "-----\n"); Log(1, "STARTING EXPOSURE at: %s @ %s\n", exposureStart, length_in_units(CG.currentExposure_us, true)); // Get start time for overlay. Make sure it has the same time as exposureStart. if (CG.overlay.showTime) { sprintf(bufTime, "%s", formatTime(exposureStartDateTime, CG.timeFormat)); } asiRetCode = takeOneExposure(&CG, pRgb.data, histogram); if (asiRetCode == ASI_SUCCESS) { numErrors = 0; numExposures++; CG.lastFocusMetric = CG.overlay.showFocus ? (int)round(get_focus_metric(pRgb)) : -1; if (numExposures == 0 && CG.preview) { // Start the preview thread at the last possible moment. bDisplay = true; pthread_create(&threadDisplay, NULL, Display, (void *)&pRgb); } #ifdef USE_HISTOGRAM // We don't use this at night since the ZWO bug is only when it's light outside. if (CG.HB.useHistogram) { attempts = 0; int minAcceptableMean = MINMEAN; int maxAcceptableMean = MAXMEAN; //xxx int roundToMe = 5; // round exposures to this many microseconds long newExposure_us = 0; // histMinExposure_us is the min exposure used in the histogram calculation. // xxx TODO: dump histMinExposure_us? Set tempMinExposure_us = cameraMinExposure_us ? ... long histMinExposure_us = CG.cameraMinExposure_us; long tempMinExposure_us = histMinExposure_us; long tempMaxExposure_us = CG.cameraMaxExposure_us; if (CG.currentBrightness != CG.defaultBrightness) { // Adjust brightness based on Brightness. // The default value has no adjustment. // The only way we can do this easily is via adjusting the exposure. // We could apply a stretch to the image, but that's more difficult. // Sure would be nice to see how ZWO handles this variable. // We asked but got a useless reply. // Values below the default make the image darker; above make it brighter. float exposureAdjustment = 1.0; // Adjustments of DEFAULT_BRIGHTNESS up or down make the image this much darker/lighter. // Don't want the max brightness to give pure white. //xxx May have to play with this number, but it seems to work ok. // 100 * this number is the percent to change. const float adjustmentAmountPerMultiple = 0.12; // The amount doesn't change after being set, so only display once. static bool showedMessage = false; if (! showedMessage) { float numMultiples; // Determine the adjustment amount - only done once. // See how many multiples we're different. // If currentBrightness < default then numMultiples will be negative, // which is ok - it just means the multiplier will be less than 1. numMultiples = (float)(CG.currentBrightness - CG.defaultBrightness) / CG.defaultBrightness; exposureAdjustment = 1 + (numMultiples * adjustmentAmountPerMultiple); Log(4, " > >>> Adjusting exposure x %.2f (%.1f%%) for brightness\n", exposureAdjustment, (exposureAdjustment - 1) * 100); showedMessage = true; } // Now adjust the variables // xxxxxxxxx TODO: don't adjust histMinExposure_us; just histogram numbers. histMinExposure_us *= exposureAdjustment; minAcceptableMean *= exposureAdjustment; maxAcceptableMean *= exposureAdjustment; } // Keep track of whether or not we're bouncing around, for example, // one exposure is less than the min and the second is greater than the max. // When that happens we don't want to set the min to the second exposure // or else we'll never get low enough. // Negative is below lower limit, positive is above upper limit. // Adjust the min or maxAcceptableMean depending on the aggression. int priorMean = CG.lastMean; int priorMeanDiff = 0; int adjustment = 0; int lastMeanDiff = 0; // like priorMeanDiff but for next exposure if (CG.lastMean < minAcceptableMean) { priorMeanDiff = CG.lastMean - minAcceptableMean; // If we're skipping frames we want to get to a good exposure as fast as // possible so don't set an adjustment. /* if (CG.aggression != 100 && CG.currentSkipFrames <= 0) { // TODO: why are we adjusting the AcceptableMean? adjustment = priorMeanDiff * (1 - ((float)CG.aggression/100)); if (adjustment < 1) minAcceptableMean += adjustment; } */ } else if (CG.lastMean > maxAcceptableMean) { // TODO: why not adjust here if needed? priorMeanDiff = CG.lastMean - maxAcceptableMean; } if (adjustment != 0) { Log(4, " > !!! Adjusting %sAcceptableMean by %d to %d\n", adjustment < 0 ? "min" : "max", adjustment, adjustment < 0 ? minAcceptableMean : maxAcceptableMean); } int numPingPongs = 0; //x long lastExposure_us = CG.currentExposure_us; while ((CG.lastMean < minAcceptableMean || CG.lastMean > maxAcceptableMean) && ++attempts <= maxHistogramAttempts && CG.currentExposure_us <= CG.cameraMaxExposure_us) { int acceptable; float multiplier = 1.10; char const *acceptableType; if (CG.lastMean < minAcceptableMean) { acceptable = minAcceptableMean; acceptableType = "min"; } else { acceptable = maxAcceptableMean; acceptableType = "max"; multiplier = 1 / multiplier; } // if lastMean/acceptable is 9/90, it's 1/10th of the way there, so multiple exposure by 90/9 (10). // ZWO cameras don't appear to be linear so increase the multiplier amount some. float multiply; if (CG.lastMean == 0) { // TODO: is this correct? multiply = ((double)acceptable) * multiplier; } else { multiply = ((double)acceptable / CG.lastMean) * multiplier; } // Log(4, "multiply=%f, acceptable=%d, lastMean=%f, multiplier=%f\n", multiply, acceptable, CG.lastMean, multiplier); long exposureDiff_us = (CG.lastExposure_us * multiply) - CG.lastExposure_us; // Adjust by aggression setting. if (CG.aggression != 100 && CG.currentSkipFrames <= 0) { if (exposureDiff_us != 0) { Log(4, " > Next exposure change going from %s, ", length_in_units(exposureDiff_us, true)); exposureDiff_us *= (float)CG.aggression / 100; Log(4, "before aggression to %s after.\n", length_in_units(exposureDiff_us, true)); } } newExposure_us = CG.lastExposure_us + exposureDiff_us; if (newExposure_us > CG.currentMaxAutoExposure_us) { Log(4, " > === Calculated newExposure_us (%'ld) > currentMaxAutoExposure_us (%'ld); setting to max\n", newExposure_us, CG.currentMaxAutoExposure_us); newExposure_us = CG.currentMaxAutoExposure_us; } else { Log(4, " > Next exposure changing by %'ld us to %'ld (multiply by %.3f) [CG.lastExposure_us=%'ld, %sAcceptable=%d, lastMean=%d]\n", exposureDiff_us, newExposure_us, multiply, CG.lastExposure_us, acceptableType, acceptable, (int)CG.lastMean); } if (priorMeanDiff > 0 && lastMeanDiff < 0) { ++numPingPongs; Log(2, " >xxx lastMean was %d and went from %d above max of %d to %d below min", priorMean, priorMeanDiff, maxAcceptableMean, -lastMeanDiff); Log(2, " of %d, is now at %d; should NOT set temp min to currentExposure_us of %'ld\n", minAcceptableMean, (int)CG.lastMean, CG.currentExposure_us); } else { if (priorMeanDiff < 0 && lastMeanDiff > 0) { ++numPingPongs; Log(2, " >xxx mean was %d and went from %d below min of %d to %d above max", priorMean, -priorMeanDiff, minAcceptableMean, lastMeanDiff); Log(2, " of %d, is now at %d; OK to set temp max to currentExposure_us of %'ld\n", maxAcceptableMean, (int)CG.lastMean, CG.currentExposure_us); } else { numPingPongs = 0; } if (CG.lastMean < minAcceptableMean) { tempMinExposure_us = CG.currentExposure_us; } else if (CG.lastMean > maxAcceptableMean) { tempMaxExposure_us = CG.currentExposure_us; } } if (numPingPongs >= 3) { printf(" > xxx newExposure_us=%s\n", length_in_units(newExposure_us, true)); printf(" CG.lastExposure_us=%s\n", length_in_units(CG.lastExposure_us, true)); newExposure_us = (newExposure_us + CG.lastExposure_us) / 2; long n = newExposure_us; printf(" new newExposure_us=%s\n", length_in_units(n, true)); Log(3, " > Ping-Ponged %d times, setting exposure to mid-point of %s\n", numPingPongs, length_in_units(newExposure_us, true)); } //xxx newExposure_us = roundTo(newExposure_us, roundToMe); // Make sure newExposure_us is between min and max. newExposure_us = std::max(tempMinExposure_us, newExposure_us); newExposure_us = std::min(tempMaxExposure_us, newExposure_us); if (newExposure_us == CG.currentExposure_us) { break; } CG.currentExposure_us = newExposure_us; if (CG.currentExposure_us > CG.cameraMaxExposure_us) { break; } Log(2, " >> Retry %i @ %'ld us, min=%'ld us, max=%'ld us: lastMean (%d)\n", attempts, newExposure_us, tempMinExposure_us, tempMaxExposure_us, (int)CG.lastMean); priorMean = CG.lastMean; priorMeanDiff = lastMeanDiff; asiRetCode = takeOneExposure(&CG, pRgb.data, histogram); if (asiRetCode == ASI_SUCCESS) { //x lastExposure_us = CG.lastExposure_us; if (CG.lastMean < minAcceptableMean) lastMeanDiff = CG.lastMean - minAcceptableMean; else if (CG.lastMean > maxAcceptableMean) lastMeanDiff = CG.lastMean - maxAcceptableMean; else lastMeanDiff = 0; continue; } else { break; } } // end of "Retry" loop if (asiRetCode != ASI_SUCCESS) { Log(2," > Sleeping %s from failed exposure\n", length_in_units(CG.currentDelay_ms * US_IN_MS, false)); usleep(CG.currentDelay_ms * US_IN_MS); // Don't save the file or do anything below. continue; } if (CG.lastMean >= minAcceptableMean && CG.lastMean <= maxAcceptableMean) { // +++ at end makes it easier to see in log file Log(2, " > Good image: mean within range of %d to %d ++++++++++, mean %d\n", minAcceptableMean, maxAcceptableMean, (int)CG.lastMean); } else if (attempts > maxHistogramAttempts) { Log(2, " > max attempts reached - using exposure of %s with mean %d\n", length_in_units(CG.currentExposure_us, true), (int)CG.lastMean); } else if (attempts >= 1) { if (CG.currentExposure_us < CG.cameraMinExposure_us) { // If we call length_in_units() twice in same command line they both return the last value. Log(2, " > Stopped trying: new exposure of %s ", length_in_units(CG.currentExposure_us, false)); Log(2, "would be over min of %s\n", length_in_units(CG.cameraMinExposure_us, false)); long diff = (long)((float)CG.currentExposure_us * (1/(float)percentChange)); CG.currentExposure_us += diff; Log(3, " > Increasing next exposure by %d%% (%'ld us) to %'ld\n", percentChange, diff, CG.currentExposure_us); } else if (CG.currentExposure_us > CG.cameraMaxExposure_us) { Log(2, " > Stopped trying: new exposure of %s ", length_in_units(CG.currentExposure_us, false)); Log(2, "would be over max of %s\n", length_in_units(CG.cameraMaxExposure_us, false)); long diff = (long)((float)CG.currentExposure_us * (1/(float)percentChange)); CG.currentExposure_us -= diff; Log(3, " > Decreasing next exposure by %d%% (%'ld us) to %'ld\n", percentChange, diff, CG.currentExposure_us); } else if (CG.currentExposure_us == CG.cameraMinExposure_us) { Log(2, " > Stopped trying: hit min exposure limit of %s, mean %d\n", length_in_units(CG.cameraMinExposure_us, false), (int)CG.lastMean); // If currentExposure_us causes too low of a mean, increase exposure // so on the next loop we'll adjust it. if (CG.lastMean < minAcceptableMean) CG.currentExposure_us++; } else if (CG.currentExposure_us == CG.currentMaxAutoExposure_us) { Log(2, " > Stopped trying: hit max exposure limit of %s, mean %d\n", length_in_units(CG.currentMaxAutoExposure_us, false), (int)CG.lastMean); // If currentExposure_us causes too high of a mean, decrease exposure // so on the next loop we'll adjust it. if (CG.lastMean > maxAcceptableMean) CG.currentExposure_us--; } else if (newExposure_us == CG.currentExposure_us) { Log(2, " > Stopped trying: newExposure_us == currentExposure_us == %s\n", length_in_units(CG.currentExposure_us, false)); } else { Log(2, " > Stopped trying, using exposure of %s with mean %d, min=%d, max=%d\n", length_in_units(CG.currentExposure_us, false), (int)CG.lastMean, minAcceptableMean, maxAcceptableMean); } } else if (CG.currentExposure_us == CG.cameraMinExposure_us) { Log(3, " > Did not make any additional attempts - at min exposure limit of %s, mean %d\n", length_in_units(CG.cameraMinExposure_us, false), (int)CG.lastMean); } else if (CG.currentExposure_us == CG.cameraMaxExposure_us) { Log(3, " > Did not make any additional attempts - at max exposure limit of %s, mean %d\n", length_in_units(CG.cameraMaxExposure_us, false), (int)CG.lastMean); } } else { // Didn't use histogram method. // If we used auto-exposure, set the next exposure to what the camera driver // thinks the next exposure should be. // But temper it by the aggression value so we don't bounce up and down. if (CG.currentAutoExposure) { // If we're skipping frames we want to get to a good exposure as fast as // possible so don't set an adjustment. if (CG.aggression != 100 && CG.currentSkipFrames <= 0) { long exposureDiff_us, diff_us; diff_us = suggestedNextExposure_us - CG.currentExposure_us; exposureDiff_us = diff_us * (float)CG.aggression / 100; if (exposureDiff_us != 0) { Log(4, " > Next exposure full change is %s, ", length_in_units(diff_us, true)); Log(4, "after aggression: %s ", length_in_units(exposureDiff_us, true)); Log(4, "from %s ", length_in_units(CG.currentExposure_us, true)); CG.currentExposure_us += exposureDiff_us; Log(4, "to %s\n", length_in_units(CG.currentExposure_us, true)); } } else { CG.currentExposure_us = suggestedNextExposure_us; } } else { // Didn't use auto-exposure - don't change exposure } } #endif if (CG.currentSkipFrames > 0) { #ifdef USE_HISTOGRAM // If we're already at a good exposure, or the last exposure was longer // than the max, don't skip any more frames. // xxx TODO: should we have a separate variable to define "too long" instead of currentMaxAutoExposure_us? if ((CG.lastMean >= MINMEAN && CG.lastMean <= MAXMEAN) || CG.lastExposure_us > CG.currentMaxAutoExposure_us) { CG.currentSkipFrames = 0; } else #endif { CG.currentSkipFrames--; Log(2, " >>>> Skipping this frame. %d left to skip\n", CG.currentSkipFrames); // Do not save this frame or sleep after it. // We just started taking images so no need to check if DAY or NIGHT changed continue; } } // If takeDarkFrames is off, add overlay text to the image if (! CG.takeDarkFrames) { if (CG.overlay.overlayMethod == OVERLAY_METHOD_LEGACY) { (void) doOverlay(pRgb, CG, bufTime, gainChange); #ifdef USE_HISTOGRAM if (CG.overlay.showHistogramBox) { // Draw a rectangle where the histogram box is. // Put a black and white line one next to each other so they // can be seen in light and dark images. int lt = cv::LINE_AA, thickness = 2; int X1 = (CG.width * CG.HB.histogramBoxPercentFromLeft) - (CG.HB.histogramBoxSizeX / 2); int X2 = X1 + CG.HB.histogramBoxSizeX; int Y1 = (CG.height * CG.HB.histogramBoxPercentFromTop) - (CG.HB.histogramBoxSizeY / 2); int Y2 = Y1 + CG.HB.histogramBoxSizeY; cv::Scalar outerLine, innerLine; outerLine = cv::Scalar(0,0,0); innerLine = cv::Scalar(255,255,255); cv::rectangle(pRgb, cv::Point(X1, Y1), cv::Point(X2, Y2), outerLine, thickness, lt, 0); cv::rectangle(pRgb, cv::Point(X1+thickness, Y1+thickness), cv::Point(X2-thickness, Y2-thickness), innerLine, thickness, lt, 0); } #endif } if (currentAdjustGain) { // Determine if we need to change the gain on the next image. // This must come AFTER the "showGain" above. gainChange = determineGainChange(CG); setControl(CG.cameraNumber, ASI_GAIN, CG.currentGain + gainChange, CG.currentAutoGain ? ASI_TRUE : ASI_FALSE); } } #ifndef USE_HISTOGRAM if (CG.currentAutoExposure) { // Retrieve the current Exposure for smooth transition to night time // as long as auto-exposure is enabled during night time CG.currentExposure_us = CG.lastExposure_us; } #endif // Save the image if (! bSavingImg) { // For dark frames we already know the finalFilename. if (! CG.takeDarkFrames) { // Create the name of the file that goes in the images/<date> directory. snprintf(CG.finalFileName, sizeof(CG.finalFileName), "%s-%s.%s", CG.fileNameOnly, formatTime(exposureStartDateTime, "%Y%m%d%H%M%S"), CG.imageExt); snprintf(CG.fullFilename, sizeof(CG.fullFilename), "%s/%s", CG.saveDir, CG.finalFileName); } pthread_mutex_lock(&mtxSaveImg); pthread_cond_signal(&condStartSave); pthread_mutex_unlock(&mtxSaveImg); } else { // Hopefully the user can use the time it took to save a file to disk // to help determine why they are getting this warning. // Perhaps their disk is very slow or their delay is too short. Log(1, " > WARNING: currently saving an image; can't save new one at %s.\n", exposureStart); // TODO: wait for the prior image to finish saving. } #ifndef USE_HISTOGRAM if (CG.currentAutoExposure && dayOrNight == "DAY") { CG.currentExposure_us = CG.lastExposure_us; } #endif std::string s; if (CG.currentAutoExposure) { s = "auto"; } else { s = "manual"; #ifdef USE_HISTOGRAM if (CG.HB.useHistogram) s = "histogram"; #endif } // Delay applied before next exposure delayBetweenImages(CG, CG.lastExposure_us, s); dayOrNight = calculateDayOrNight(CG.latitude, CG.longitude, CG.angle); } } if (lastDayOrNight != dayOrNight) justTransitioned = true; } closeUp(EXIT_OK); }
[ "noreply@github.com" ]
noreply@github.com
e0d93c8475b074f1b9723633551fac44458376a9
678c865d545e0cafb5096b76f9c26c44f262798e
/include/tracer.h
fdbb72772516bebf3a2aa276c5ce0e4fd0bcd76e
[]
no_license
Holong/BSim
e9329b60ded5ee6f3474ba5f7e45e1fde115f683
33cdd400e66781f2af95635020a8b8cb3d177c4a
refs/heads/master
2021-01-18T14:19:37.351739
2014-06-05T03:45:05
2014-06-05T03:45:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,049
h
#ifndef __TRACER_H__ #define __TRACER_H__ #include <sys/ptrace.h> #include <unistd.h> class InfoRegs { private: unsigned long r15; unsigned long r14; unsigned long r13; unsigned long r12; unsigned long rbp; unsigned long rbx; unsigned long r11; unsigned long r10; unsigned long r9; unsigned long r8; unsigned long rax; unsigned long rcx; unsigned long rdx; unsigned long rsi; unsigned long rdi; unsigned long orig_rax; unsigned long rip; unsigned long cs; unsigned long eflags; unsigned long rsp; unsigned long ss; unsigned long fs_base; unsigned long gs_base; unsigned long ds; unsigned long es; unsigned long fs; unsigned long gs; public: InfoRegs(); void setRegsInfo(pid_t pid) throw (int); unsigned long getRIP(); }; class Tracer { private: pid_t childPid; int stat, res; int signo; char* fileName; char* absoluteName; char** argv; public: Tracer(char* programName, char* argv[]); void traceStart() throw (int); void traceSingleStep(InfoRegs& pInfoRegs) throw (int); pid_t getChildPid(); }; #endif
[ "kit22978@hanmail.net" ]
kit22978@hanmail.net
fcd0e30d68ef474c56f011c43ca1ea09a5e05f13
ddaaf88f97138f30a4a0e7561efeb9fcecffde47
/Hacker Rank/The_Grid_Search.cpp
7ce64fa35b97b4cb6e9680c77cace8ffffd02661
[ "Apache-2.0" ]
permissive
aryabharat/ONLINE_CODING
8605699e6be017ed67a1bfdcc4eab6dfdd76f416
3f3318c5e660d9b30c14618db8068816ba902d0f
refs/heads/master
2021-07-12T11:00:20.252085
2020-06-28T06:53:10
2020-06-28T06:53:10
153,991,660
2
0
null
null
null
null
UTF-8
C++
false
false
1,326
cpp
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int t; cin>>t; while(t--) { // cout<<"*******************************"<<endl; int br,bc; cin>>br>>bc; vector<string> big(br); for(int i=0;i<br;i++) cin >> big[i]; int sr,sc; cin>>sr>>sc; vector<string> small(sr); for(int i=0;i<sr;i++) cin>>small[i]; bool flag =false,f =false; for(int i=0;i<=br-sr;i++){ for(int j = 0;j<=bc-sc;j++){ flag = false; for(int k =0;k<sr;k++){ for(int l = 0;l<sc;l++){ if(big[i+k][j+l]!= small[k][l]) { flag = true; break; } } if(flag) break; } if(!flag) {f=true;break;} } if(f) break; } if(f) cout<<"YES"; else cout<<"NO"; cout<<"\n"; } /* Enter your code here. Read input from STDIN. Print output to STDOUT */ return 0; }
[ "noreply@github.com" ]
noreply@github.com
741cc3a6421b0790fb1b1675fa2797b79c12a964
62f520303b4b75aa1901124775af3063bc8a5a20
/stochastic2/hybrid-code/loss.hpp
f64bf61e9cfbb5e3f9663d1fbeddef563a35ecc4
[]
no_license
bssbbsmd/Collaborative_Multi-task_ranking
eb88c45159d38a5f55c7e9785661eef57c11707d
4cde375ec5175d8391b1f92819b9ca6192bd3644
refs/heads/master
2022-11-13T15:08:45.236173
2020-07-06T00:50:33
2020-07-06T00:50:33
104,147,100
2
2
null
null
null
null
UTF-8
C++
false
false
11,675
hpp
#ifndef __LOSS_HPP__ #define __LOSS_HPP__ #include <utility> #include <string> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <algorithm> #include <vector> #include <iostream> #include <fstream> #include <sstream> #include <omp.h> #include "elements.hpp" #include "model.hpp" #include "ratings.hpp" enum loss_option_t {L1_HINGE, L2_HINGE, LOGISTIC, SQUARED}; //sum of squares loss //if choice==0 evaluate personalized ranking, if choice==1, evaluate user targeting performance double compute_ndcg(const TestMatrix& test, const Model& model, int choice) { double ndcg_sum = 0.; std::vector<double> score; int n_valid_ids = 0; //compute the ndcg for personalized ranking if(choice == 0){ for(int uid=0; uid < model.n_users; ++uid) { double dcg = 0.; score.clear(); vector<pair<int, double>> user_pairs = test.itemwise_test_pairs[uid]; if(!user_pairs.empty()){ for(int i = 0; i< user_pairs.size(); ++i) { int iid = user_pairs[i].first; if (iid < model.n_items) { double prod = 0.; for(int k=0; k< model.rank; ++k) prod += model.U[uid * model.rank + k] * model.V[iid * model.rank + k]; //estimated socres score.push_back(prod); }else { score.push_back(-1e10); } } ndcg_sum += test.compute_user_ndcg(uid, score); n_valid_ids++; } } ndcg_sum = ndcg_sum/(double)n_valid_ids; } //computer the ndcg for the user targeting if(choice == 1){ for(int iid=0; iid < model.n_items; iid++){ double dcg = 0.; score.clear(); vector<pair<int, double>> item_pairs = test.userwise_test_pairs[iid]; if(!item_pairs.empty()){ for(int i=0; i < item_pairs.size(); i++){ int uid = item_pairs[i].first; if(uid < model.n_users){ double prod = 0.; for(int k=0; k< model.rank; ++k) prod += model.U[uid * model.rank + k] * model.V[iid * model.rank + k]; //estimated socres score.push_back(prod); }else { score.push_back(-1e10); } } ndcg_sum += test.compute_item_ndcg(iid, score); n_valid_ids++; } } ndcg_sum = ndcg_sum/(double)n_valid_ids; } return ndcg_sum; } /* double compute_loss(const Model& model, const TestMatrix& test, int choice) { double p = 0.; #pragma omp parallel for reduction(+:p) for(int i=0; i<test.ratings.size(); ++i) { double *user_vec = &(model.U[test.ratings[i].user_id * model.rank]); double *item_vec = &(model.V[test.ratings[i].item_id * model.rank]); double d = 0.; for(int j=0; j<model.rank; ++j) d += user_vec[j] * item_vec[j]; p += .5 * pow(test.ratings[i].score - d, 2.); } return p; } */ /* // binary classification loss double compute_loss(const Model& model, const std::vector<comparison>& TestComps, loss_option_t option) { double p = 0.; #pragma omp parallel for reduction(+:p) for(int i=0; i<TestComps.size(); ++i) { double *user_vec = &(model.U[TestComps[i].user_id * model.rank]); double *item1_vec = &(model.V[TestComps[i].item1_id * model.rank]); double *item2_vec = &(model.V[TestComps[i].item2_id * model.rank]); double d = 0., loss; for(int j=0; j<model.rank; ++j) { d += user_vec[j] * (item1_vec[j] - item2_vec[j]); } switch(option) { case SQUARED: loss = .5*pow(1.-d, 2.); break; case LOGISTIC: loss = log(1.+exp(-d)); break; case L1_HINGE: loss = std::max(0., 1.-d); break; case L2_HINGE: loss = pow(std::max(0., 1.-d), 2.); } p += loss; } return p; } */ /* double compute_loss_v2(const Model& model, std::vector<std::vector<int> >& Iu, std::vector<std::vector<int> >& noIu) { double p = 0.; #pragma omp parallel for reduction (+ : p) for (int uid = 0; uid < Iu.size(); ++uid) { for (int idx1 = 0; idx1 < Iu[uid].size(); ++idx1) { for (int idx2 = 0; idx2 < noIu[uid].size(); ++idx2) { int iid1 = Iu[uid][idx1]; int iid2 = noIu[uid][idx2]; double *user_vec = &(model.U[uid * model.rank]); double *item1_vec = &(model.V[iid1 * model.rank]); double *item2_vec = &(model.V[iid2 * model.rank]); double d = 0., loss; for(int j=0; j<model.rank; ++j) { d += user_vec[j] * (item1_vec[j] - item2_vec[j]); } p += log(1. + exp(-d) ); } } } return p; } double compute_pairwiseError(const RatingMatrix& TestRating, const RatingMatrix& PredictedRating) { std::vector<double> score(TestRating.n_items); double sum_correct = 0.; for(int uid=0; uid<TestRating.n_users; ++uid) { score.resize(TestRating.n_items,-1e10); double max_sc = -1.; int j = PredictedRating.idx[uid]; for(int i=TestRating.idx[uid]; i<TestRating.idx[uid+1]; ++i) { int iid = TestRating.ratings[i].item_id; while((j < PredictedRating.idx[uid+1]) && (PredictedRating.ratings[j].item_id < iid)) ++j; if ((PredictedRating.ratings[j].user_id == uid) && (PredictedRating.ratings[j].item_id == iid)) score[iid] = PredictedRating.ratings[j].score; if (TestRating.ratings[i].score > max_sc) max_sc = TestRating.ratings[i].score; } max_sc = max_sc - .1; unsigned long long cor_this = 0, discor_this = 0; for(int i=TestRating.idx[uid]; i<TestRating.idx[uid+1]-1; ++i) { for(int j=i+1; j<TestRating.idx[uid+1]; ++j) { int item1_id = TestRating.ratings[i].item_id; int item2_id = TestRating.ratings[j].item_id; double item1_sc = TestRating.ratings[i].score; double item2_sc = TestRating.ratings[j].score; if ((item1_sc > item2_sc) && (score[item1_id] > score[item2_id])) { ++cor_this; } if ((item1_sc < item2_sc) && (score[item1_id] >= score[item2_id])) { ++discor_this; } // ++n_comps_this; } } sum_correct += (double)cor_this / ((double)cor_this); } return sum_correct / (double)TestRating.n_users; } double compute_pairwiseError(const RatingMatrix& TestRating, const Model& PredictedModel) { double sum_correct = 0.; int neg_user = 0; #pragma omp parallel for reduction(+:sum_correct, neg_user) for(int uid=0; uid < TestRating.n_users; ++uid) { std::vector<double> score(TestRating.n_items,-1e10); //double max_sc = -1.; for(int i=TestRating.idx[uid]; i<TestRating.idx[uid+1]; ++i) { int iid = TestRating.ratings[i].item_id; if (iid < PredictedModel.n_items) { double prod = 0.; for(int k=0; k<PredictedModel.rank; ++k) prod += PredictedModel.U[uid * PredictedModel.rank + k] * PredictedModel.V[iid * PredictedModel.rank + k]; score[iid] = prod; } else { score[iid] = -1e10; } // if (TestRating.ratings[i].score > max_sc) max_sc = TestRating.ratings[i].score; } // max_sc = max_sc - .1; unsigned long cor_this = 0, discor_this = 0; for(int i=TestRating.idx[uid]; i < TestRating.idx[uid+1]-1; ++i) { for(int j=i+1; j<TestRating.idx[uid+1]; ++j) { int item1_id = TestRating.ratings[i].item_id; int item2_id = TestRating.ratings[j].item_id; double item1_sc = TestRating.ratings[i].score; double item2_sc = TestRating.ratings[j].score; if ((item1_sc > item2_sc) && (score[item1_id] > score[item2_id])) ++cor_this; //true positive if ((item1_sc < item2_sc) && (score[item1_id] >= score[item2_id])) ++discor_this; //false negative } } if(cor_this==0 && discor_this==0) { neg_user++; continue; } sum_correct += (double)cor_this / ((double)cor_this+(double) discor_this); } //comp_error.first = (double)error / (double)n_comps; //comp_error.second = (double)errorT / (double)n_compsT; return sum_correct / (double)(TestRating.n_users - neg_user); } double compute_ndcg(const RatingMatrix& TestRating, const std::string& Predict_filename) { double ndcg_sum; std::vector<double> score; std::string user_str, attribute_str; std::stringstream attribute_sstr; std::ifstream f; f.open(Predict_filename); if (f.is_open()) { for(int uid=0; uid<TestRating.n_users; ++uid) { getline(f, user_str); size_t pos1 = 0, pos2; score.clear(); for(int idx=TestRating.idx[uid]; idx<TestRating.idx[uid+1]; ++idx) { int iid = -1; double sc; while(iid < TestRating.ratings[idx].item_id) { pos2 = user_str.find(':', pos1); if (pos2 == std::string::npos) break; attribute_str = user_str.substr(pos1, pos2-pos1); attribute_sstr.clear(); attribute_sstr.str(attribute_str); attribute_sstr >> iid; --iid; pos1 = pos2+1; pos2 = user_str.find(' ', pos1); attribute_str = user_str.substr(pos1, pos2-pos1); attribute_sstr.clear(); attribute_sstr.str(attribute_str); attribute_sstr >> sc; pos1 = pos2+1; } if (iid == TestRating.ratings[idx].item_id) score.push_back(sc); else score.push_back(-1e10); } ndcg_sum += TestRating.compute_user_ndcg(uid, score); } } else { printf("Error in opening the extracted rating file!\n"); std::cout << Predict_filename << std::endl; exit(EXIT_FAILURE); } f.close(); } double compute_ndcg(const RatingMatrix& TestRating, const RatingMatrix& PredictedRating) { double ndcg_sum = 0.; std::vector<double> score; for(int uid=0; uid<TestRating.n_users; ++uid) { double dcg = 0.; score.clear(); int j = PredictedRating.idx[uid]; for(int i=TestRating.idx[uid]; i<TestRating.idx[uid+1]; ++i) { double prod = 0.; while((j < PredictedRating.idx[uid+1]) && (PredictedRating.ratings[j].item_id < TestRating.ratings[i].item_id)) ++j; if ((PredictedRating.ratings[j].user_id == TestRating.ratings[i].user_id) && (PredictedRating.ratings[j].item_id == TestRating.ratings[i].item_id)) score.push_back(PredictedRating.ratings[j].score); else score.push_back(-1e10); } ndcg_sum += TestRating.compute_user_ndcg(uid, score); } return ndcg_sum / (double)PredictedRating.n_users; } double compute_ndcg(const RatingMatrix& TestRating, const Model& PredictedModel) { if (!TestRating.is_dcg_max_computed) return -1.; double ndcg_sum = 0.; std::vector<double> score; for(int uid=0; uid<PredictedModel.n_users; ++uid) { double dcg = 0.; score.clear(); for(int i=TestRating.idx[uid]; i<TestRating.idx[uid+1]; ++i) { int iid = TestRating.ratings[i].item_id; if (iid < PredictedModel.n_items) { double prod = 0.; for(int k=0; k<PredictedModel.rank; ++k) prod += PredictedModel.U[uid * PredictedModel.rank + k] * PredictedModel.V[iid * PredictedModel.rank + k]; score.push_back(prod); } else { score.push_back(-1e10); } } ndcg_sum += TestRating.compute_user_ndcg(uid, score); } return ndcg_sum / (double)PredictedModel.n_users; } */ #endif
[ "jh900@tempvm.cs.rutgers.edu" ]
jh900@tempvm.cs.rutgers.edu
f3becb185683ba8f74abba271c89f0315d8f451f
cdaa7a05e191142dfb5392692cbe54b18829c4b6
/AoE_IMGUI/Player.h
467124a5f4b9e649b2f3a3b2c4e3452f33b3a648
[]
no_license
leocdi/Age-of-Empires-II-2013
7768e568ea41140ff24e8a86122d9c9e48cb93e2
50e624f498a867967f9a1200d1ce40870b29334d
refs/heads/master
2020-08-03T07:53:02.309834
2019-10-05T21:13:25
2019-10-05T21:13:25
211,181,249
0
0
null
2019-09-26T21:05:39
2019-09-26T21:05:39
null
UTF-8
C++
false
false
1,298
h
#pragma once #include <cstdint> #include <vector> class Unit; class ObjectManager; class Player { public: char pad_0000[16]; //0x0000 int32_t PriceCount; //0x0010 class PriceTable *priceTablePtr; //0x0014 class ObjectManager *objectManager; //0x0018 char pad_001C[8]; //0x001C class VictoryConditions *victoryConditions; //0x0024 char pad_0028[20]; //0x0028 class Ressources *Ressources; //0x003C char pad_0040[60]; //0x0040 int32_t Diplo0; //0x007C int32_t Diplo1; //0x0080 int32_t Diplo2; //0x0084 int32_t Diplo3; //0x0088 int32_t Diplo4; //0x008C int32_t Diplo5; //0x0090 int32_t Diplo6; //0x0094 int32_t Diplo7; //0x0098 int32_t Diplo8; //0x009C char pad_00A0[92]; //0x00A0 class Color *colorPtr; //0x00FC char pad_0100[16]; //0x0100 float camX; //0x0110 float camY; //0x0114 char pad_0118[68]; //0x0118 class Unit *LastSelectedUnitPtr; //0x015C class Unit *SelectedUnitsArray[60]; //0x0160 char pad_0250[4]; //0x0250 int32_t SelectedUnitsCount; //0x0254 char pad_0258[232]; //0x0258 int32_t WrongSelectedUnitsCount; //0x0340 char pad_0344[6028]; //0x0344 class PlayerName *pName; //0x1AD0 char pad_1AD4[12]; //0x1AD4 class Civilization *N00000C58; //0x1AE0 char pad_1AE4[1588]; //0x1AE4 std::vector<Unit*> getUnitsByBaseId(int baseId); }; //Size: 0x2118
[ "f-absen@hotmail.de" ]
f-absen@hotmail.de
d66a7f290b6a6f07df23c680a547a011162661f9
359f953e7f7acc8aef18a613691c3700dbbd7abc
/erizo/src/third_party/webrtc/src/webrtc/modules/rtp_rtcp/source/ulpfec_receiver_impl.h
8dbc8af687e7077f9563d0dae3c127ea77fe2946
[ "MIT" ]
permissive
gaecom/licode
9643b7192e68628fd387a8a311f453e168efe343
6a264369c11a2dd53d5721d6492242e086e89fad
refs/heads/master
2022-10-23T05:29:13.402785
2020-06-18T16:07:59
2020-06-18T16:07:59
273,394,449
1
0
MIT
2020-06-19T03:22:36
2020-06-19T03:22:35
null
UTF-8
C++
false
false
1,911
h
/* * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_ #define WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_ #include <memory> #include "webrtc/base/criticalsection.h" #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "webrtc/modules/rtp_rtcp/include/ulpfec_receiver.h" #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" #include "webrtc/typedefs.h" namespace webrtc { class UlpfecReceiverImpl : public UlpfecReceiver { public: explicit UlpfecReceiverImpl(RtpData* callback); virtual ~UlpfecReceiverImpl(); int32_t AddReceivedRedPacket(const RTPHeader& rtp_header, const uint8_t* incoming_rtp_packet, size_t packet_length, uint8_t ulpfec_payload_type) override; int32_t ProcessReceivedFec() override; FecPacketCounter GetPacketCounter() const override; private: rtc::CriticalSection crit_sect_; RtpData* recovered_packet_callback_; std::unique_ptr<ForwardErrorCorrection> fec_; // TODO(holmer): In the current version |received_packets_| is never more // than one packet, since we process FEC every time a new packet // arrives. We should remove the list. ForwardErrorCorrection::ReceivedPacketList received_packets_; ForwardErrorCorrection::RecoveredPacketList recovered_packets_; FecPacketCounter packet_counter_; }; } // namespace webrtc #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_ULPFEC_RECEIVER_IMPL_H_
[ "noreply@github.com" ]
noreply@github.com
84dda7021a3c2856c8f1b5dfc4c59ad0c9162377
76cd918cbb495c5a93a99ebbd8c6d4872cafe6a3
/Source/widgets/node_editors/node_editor.hpp
069179b4338383a7f0b74aa3ccdd18d2c554b497
[ "MIT" ]
permissive
ezhangle/CyberpunkSaveEditor
e3daf7cf2da405d6f11139d3d3ac41bb88a9c0f2
d6727f0dce8f718d7af811e30e5117eb5d33ebaa
refs/heads/main
2023-02-08T14:13:49.301010
2020-12-30T02:59:55
2020-12-30T02:59:55
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,265
hpp
#pragma once #include <memory> #include <functional> #include <vector> #include <map> #include <sstream> #include <iostream> #include "AppLib/IApp.hpp" #include "cserialization/node.hpp" #define NODE_EDITOR__DEFAULT_LEAF_EDITOR_NAME "<default_editor>" // it should be drawn only once per frame // ensuring that isn't easy class node_editor_widget : public node_listener_t { friend class node_editor_window; // inlined factory -start- template <class Derived, std::enable_if_t<std::is_base_of_v<node_editor_widget, Derived>, int> = 0> static inline std::shared_ptr<node_editor_widget> create(const std::shared_ptr<const node_t>& node) { return std::dynamic_pointer_cast<node_editor_widget>(std::make_shared<Derived>(node)); } using bound_create_t = decltype(std::bind(&create<node_editor_widget>, std::placeholders::_1)); using factory_map_t = std::map<std::string, std::function<std::shared_ptr<node_editor_widget>(const std::shared_ptr<const node_t>&)>>; static inline factory_map_t s_factory_map; public: template <class Derived, std::enable_if_t<std::is_base_of_v<node_editor_widget, Derived>, int> = 0> static inline void factory_register_for_node_name(const std::string& node_name) { s_factory_map[node_name] = std::bind(&create<Derived>, std::placeholders::_1); } static inline std::shared_ptr<node_editor_widget> create(const std::shared_ptr<const node_t>& node) { auto it = s_factory_map.find(node->name()); if (it == s_factory_map.end() && node->is_leaf()) it = s_factory_map.find(NODE_EDITOR__DEFAULT_LEAF_EDITOR_NAME); if (it != s_factory_map.end()) return it->second(node); return nullptr; } // inlined factory -end- private: std::weak_ptr<const node_t> m_weaknode; public: node_editor_widget(const std::shared_ptr<const node_t>& node) : m_weaknode(node) { node->add_listener(this); } ~node_editor_widget() override { auto node = m_weaknode.lock(); if (node) node->remove_listener(this); }; protected: bool m_dirty = false; bool m_has_unsaved_changes = false; bool m_is_drawing = false; // to filter events void on_node_event(const std::shared_ptr<const node_t>& node, node_event_e evt) override { if (m_is_drawing) m_has_unsaved_changes = true; else m_dirty = true; } public: bool has_changes() const { return m_has_unsaved_changes; } bool is_dirty() const { return m_dirty; } std::shared_ptr<const node_t> node() const { return m_weaknode.lock(); } std::shared_ptr<node_t> ncnode() { return std::const_pointer_cast<node_t>(m_weaknode.lock()); } void draw_widget(const ImVec2& size = ImVec2(0, 0), bool with_save_buttons=true) { ImGui::PushID((void*)this); auto node = m_weaknode.lock(); if (!node) { ImGui::Text("node no longer exists"); } else { if (with_save_buttons && m_has_unsaved_changes) { { scoped_imgui_button_hue _sibh(0.2f); if (ImGui::Button("save##node_editor", ImVec2(140, 26))) commit(); } ImGui::SameLine(); { scoped_imgui_button_hue _sibh(0.0f); if (ImGui::Button("discard and reload##node_editor", ImVec2(160, 26))) reload(); } } draw_content(size); if (ImGui::BeginPopupModal("Error##node_editor", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) { ImGui::Text("%s", s_error.c_str()); ImGui::Separator(); if (ImGui::Button("OK", ImVec2(ImGui::GetContentRegionAvail().x, 0))) { ImGui::CloseCurrentPopup(); s_error = ""; } ImGui::EndPopup(); } } ImGui::PopID(); } protected: void draw_content(const ImVec2& size = ImVec2(0, 0)) { m_is_drawing = true; draw_impl(size); m_is_drawing = false; } private: static inline std::string s_error; protected: static void error(std::string_view msg) { s_error = msg; ImGui::OpenPopup("Error##node_editor"); } public: bool commit() { if (!commit_impl()) { error(s_error.empty() ? "commit failed" : s_error); return false; } m_has_unsaved_changes = false; m_dirty = false; return true; } bool reload() { if (!reload_impl()) { error(s_error.empty() ? "reload failed" : s_error); return false; } m_has_unsaved_changes = false; m_dirty = false; return true; } private: // should return true if data has been modified virtual void draw_impl(const ImVec2& size) = 0; virtual bool commit_impl() = 0; virtual bool reload_impl() = 0; }; /* starter template // ------------------ class node_xxxeditor : public node_editor_widget { // attrs public: node_xxxeditor(const std::shared_ptr<const node_t>& node) : node_editor_widget(node) { reload(); } public: bool commit() override { } bool reload() override { } protected: void draw_impl(const ImVec2& size) override { } void on_dirty(size_t offset, size_t len, size_t patch_len) override { } }; */ // onlyn ode_editor_windows_mgr can instantiate these class node_editor_window { friend class node_editor_windows_mgr; struct create_tag {}; private: std::shared_ptr<node_editor_widget> editor; std::string m_window_title; bool m_take_focus = false; bool m_has_focus = false; bool m_opened = false; bool m_dirty_aknowledged = false; public: node_editor_window(create_tag&&, const std::shared_ptr<const node_t> node) { std::stringstream ss; ss << "node:" << node->name(); if (node->is_cnode()) ss << " idx:" << node->idx(); ss << "##node_editor_window_" << (uint64_t)node.get(); m_window_title = ss.str(); editor = node_editor_widget::create(node); } static std::shared_ptr<node_editor_window> create(const std::shared_ptr<const node_t> node) { return std::make_shared<node_editor_window>(create_tag{}, node); } public: void open() { m_opened = true; } bool is_opened() const { return m_opened; } void take_focus() { m_take_focus = true; } bool has_focus() const { return m_has_focus; } protected: void draw() { if (!m_opened) return; if (m_take_focus) { ImGui::SetNextWindowFocus(); m_take_focus = false; } auto node = editor ? editor->node() : nullptr; if (!node) { m_opened = false; return; } auto& io = ImGui::GetIO(); ImVec2 center(io.DisplaySize.x * 0.5f, io.DisplaySize.y * 0.5f); ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f)); std::stringstream ss; uint64_t nid = (uint64_t)node.get(); ss << "node:" << node->name(); if (node->is_cnode()) ss << " idx:" << node->idx(); ss << "##" << nid; m_window_title = ss.str(); if (ImGui::Begin(m_window_title.c_str(), &m_opened, ImGuiWindowFlags_AlwaysAutoResize)) { m_has_focus = ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows); if (editor->is_dirty()) { if (!m_dirty_aknowledged) { //ImGui::PushStyleColor ImVec4 color_red = ImColor::HSV(0.f, 1.f, 0.7f, 1.f).Value; // ImGuiCol_ModalWindowDimBg ImGui::PushStyleColor(ImGuiCol_Text, color_red); ImGui::Text("content modified outside of this editor", ImVec2(ImGui::GetContentRegionAvail().x - 100, 0)); ImGui::PopStyleColor(); ImGui::PushStyleColor(ImGuiCol_Button, ImColor::HSV(0.f, 0.6f, 0.6f).Value); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImColor::HSV(0.f, 0.7f, 0.7f).Value); ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImColor::HSV(0.f, 0.8f, 0.8f).Value); ImGui::SameLine(); if (ImGui::Button("reload", ImVec2(60, 0))) { editor->reload(); } ImGui::SameLine(); if (ImGui::Button("ok", ImVec2(40, 0))) { m_dirty_aknowledged = false; } ImGui::PopStyleColor(3); } } else { m_dirty_aknowledged = false; } editor->draw_widget(); } ImGui::End(); if (editor->has_changes()) { if (!m_opened) ImGui::OpenPopup("Unsaved changes##node_editor"); m_opened = true; } if (ImGui::BeginPopupModal("Unsaved changes##node_editor", NULL, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) { ImGui::Text("Unsaved changes in %s, would you like to save ?", m_window_title.c_str()); float button_width = ImGui::GetContentRegionAvail().x * 0.25f; ImGui::Separator(); if (ImGui::Button("NO", ImVec2(button_width, 0))) { m_opened = false; ImGui::CloseCurrentPopup(); } ImGui::SameLine(); if (ImGui::Button("YES", ImVec2(button_width, 0))) { if (editor->commit()) m_opened = false; ImGui::CloseCurrentPopup(); } ImGui::SameLine(); if (ImGui::Button("CANCEL", ImVec2(ImGui::GetContentRegionAvail().x, 0))) { m_opened = true; ImGui::CloseCurrentPopup(); } ImGui::EndPopup(); } } }; class node_editor_windows_mgr { public: static node_editor_windows_mgr& get() { static node_editor_windows_mgr s; return s; } node_editor_windows_mgr(const node_editor_windows_mgr&) = delete; node_editor_windows_mgr& operator=(const node_editor_windows_mgr&) = delete; private: node_editor_windows_mgr() = default; ~node_editor_windows_mgr() = default; private: std::map< std::weak_ptr<const node_t>, std::shared_ptr<node_editor_window>, std::owner_less<std::weak_ptr<const node_t>> > m_windows; public: node_editor_window* find_window(const std::shared_ptr<const node_t>& node) const { auto it = m_windows.find(node); if (it != m_windows.end()) return it->second.get(); return nullptr; } node_editor_window* open_window(const std::shared_ptr<const node_t>& node, bool take_focus = false) { if (!node) return nullptr; auto it = m_windows.find(node); if (it != m_windows.end()) { auto window = it->second; window->open(); if (take_focus) window->take_focus(); return window.get(); } auto window = node_editor_window::create(node); if (window) { window->open(); m_windows[node] = window; } return window.get(); } void draw_windows() { uint64_t id = (uint64_t)this; for (auto it = m_windows.begin(); it != m_windows.end();) { auto n = it->first.lock(); if (!n || !it->second) { m_windows.erase(it++); } else { (it++)->second->draw(); } } } };
[ "thispawn@gmail.com" ]
thispawn@gmail.com
732a17141c600fb3222668bf7945e50baeee9dd6
aac943a648a5a94ba17198c6a874ee56d99ce740
/aerolith/tags/client/0.3.1/imageqrcwriter.cpp
a2a120445b6b22c3950b9488f0ac7900d61348a9
[]
no_license
domino14/aerolithdesktop
3cc8c8cc86ad89088586f8bf80319ecde5cd6c5f
f0325245c05833b6b61b4d399529208ce185452f
refs/heads/master
2021-01-15T22:00:12.781172
2011-01-29T08:41:34
2011-01-29T08:41:34
32,114,008
0
0
null
null
null
null
UTF-8
C++
false
false
318
cpp
using namespace std; #include <fstream> int main() { ofstream o_f; o_f.open("client.qrc"); o_f << "<!DOCTYPE RCC><RCC version=\"1.0\">\n"; o_f << "<qresource>\n"; for (int i = 1; i <= 73; i++) o_f << "\t<file>images/face" << i << ".png</file>\n"; o_f << "</qresource>\n"; o_f << "</RCC>\n"; }
[ "cesar@93b1bf58-7229-3f38-526f-075f678e574b" ]
cesar@93b1bf58-7229-3f38-526f-075f678e574b
5c4a530d17751419df932438773f4d7c5e7da3cd
716447601880ba90b9e90fb348404fe877cf535c
/src/SimpleVAO.cpp
52871c2bbda2b28e2d64108ca12a0414afd852cb
[]
no_license
GeorgieChallis/NGL
5e3c5884d03a8e1b62eb79e3f6e57a3677b2ab7d
73aae66f1e8ff1743147946b0f33513580894058
refs/heads/master
2023-02-10T06:44:43.898038
2020-12-24T12:09:26
2020-12-24T12:09:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,740
cpp
#include "SimpleVAO.h" #include <iostream> namespace ngl { SimpleVAO::~SimpleVAO() { removeVAO(); } void SimpleVAO::draw() const { if(m_allocated == false) { msg->addWarning("Trying to draw an unallocated VOA"); } if(m_bound == false) { msg->addWarning("Warning trying to draw an unbound VOA"); } glDrawArrays(m_mode, 0, static_cast<GLsizei>(m_indicesCount)); } void SimpleVAO::removeVAO() { if(m_bound == true) { unbind(); } if( m_allocated ==true) { glDeleteBuffers(1,&m_buffer); } glDeleteVertexArrays(1,&m_id); m_allocated=false; } #ifdef PYTHONBUILD void SimpleVAO::setData(size_t _size, const std::vector<float> &_data) { if(m_bound == false) { msg->addWarning("trying to set VOA data when unbound"); } if( m_allocated ==true) { glDeleteBuffers(1,&m_buffer); } glGenBuffers(1, &m_buffer); // now we will bind an array buffer to the first one and load the data for the verts glBindBuffer(GL_ARRAY_BUFFER, m_buffer); glBufferData(GL_ARRAY_BUFFER,static_cast<GLsizeiptr>( _size), &_data[0],GL_STATIC_DRAW); m_allocated=true; } void SimpleVAO::setData(size_t _size, const std::vector<Vec3> &_data) { if(m_bound == false) { msg->addWarning("trying to set VOA data when unbound"); } if( m_allocated ==true) { glDeleteBuffers(1,&m_buffer); } glGenBuffers(1, &m_buffer); // now we will bind an array buffer to the first one and load the data for the verts glBindBuffer(GL_ARRAY_BUFFER, m_buffer); glBufferData(GL_ARRAY_BUFFER,static_cast<GLsizeiptr>( _size), &_data[0].m_x,GL_STATIC_DRAW); m_allocated=true; } #endif void SimpleVAO::setData(const VertexData &_data) { if(m_bound == false) { msg->addWarning("trying to set VOA data when unbound"); } if( m_allocated ==true) { glDeleteBuffers(1,&m_buffer); } glGenBuffers(1, &m_buffer); // now we will bind an array buffer to the first one and load the data for the verts glBindBuffer(GL_ARRAY_BUFFER, m_buffer); glBufferData(GL_ARRAY_BUFFER,static_cast<GLsizeiptr>( _data.m_size), &_data.m_data, _data.m_mode); m_allocated=true; } Real * SimpleVAO::mapBuffer(unsigned int _index, GLenum _accessMode) { NGL_UNUSED(_index); Real *ptr=nullptr; bind(); glBindBuffer(GL_ARRAY_BUFFER, m_id); ptr = static_cast<Real *>(glMapBuffer(GL_ARRAY_BUFFER, _accessMode)); // modern GL allows this but not on mac! //ptr = static_cast<Real *>(glMapNamedBuffer(m_id, _accessMode)); return ptr; } }
[ "jmacey@bournemouth.ac.uk" ]
jmacey@bournemouth.ac.uk
4345d54d6e2c924b382aeff37a6b1ff9dd1564e2
f6e82e4adf7b3ccc60c2b64e4270c47ef0b825f4
/node_la_cua_cay_nhi_phan_tim_kiem.cpp
eb6b57e0072f20bcaaad8bf5e48391cb4613f328
[]
no_license
UynUyn2k10103/Algorithm
2b1526f4b577483af00d0ffa0c0d7a26a5f5c413
e6c6b88907347c3b1bae021172171582cb5efbed
refs/heads/main
2023-07-13T08:29:12.711120
2021-08-22T16:58:05
2021-08-22T16:58:05
398,845,274
7
1
null
null
null
null
UTF-8
C++
false
false
2,059
cpp
#include <bits/stdc++.h> #define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ll long long #define ull unsigned long long #define fori(i,a,b) for (ll i = a; i < b; i++) #define forr(i,a,b) for (ll i = a - 1; i >= b; i--) #define pb push_back #define mp make_pair #define F first #define S second using namespace std; const ll mod = 1e9 + 7; const ll oo = 1e6 + 5; typedef struct node{ int infor; node *left; node *right; } *tree; bool isLeft(tree root, int value){ return value < root->infor; } bool isRight(tree root, int value){ return value > root->infor; } tree Insert(tree root, int value){ if(root == NULL){ root = new node(); root -> infor = value; root -> left = NULL; root -> right = NULL; return root; } if(isLeft(root, value)){ root->left = Insert(root->left, value); } else if(isRight(root, value)){ root -> right = Insert(root -> right, value); } return root; } // void showPreOrder(tree root){ // if(root == NULL) return; // cout << root -> infor << " "; // showPreOrder(root -> left); // showPreOrder(root -> right); // } // void showPostOrder(tree root){ // if (root == NULL) return; // showPostOrder(root -> left); // showPostOrder(root -> right); // cout << root -> infor <<' '; // } void showLeaf(tree root){ if(root == NULL) return; if(root->left == NULL && root->right == NULL) { cout << root->infor << " "; return; } showLeaf(root->left); showLeaf(root->right); } void xl (){ tree root = NULL; int n, value; cin >> n; fori(i, 0, n){ cin >> value; root = Insert(root, value); } //showPreOrder(root); //showPostOrder(root); showLeaf(root); } int main(){ fastIO(); int T; //T = 1; cin >> T; //cin.ignore(); while (T -- ){ xl(); cout << "\n"; } }
[ "noreply@github.com" ]
noreply@github.com
fedafae0189308543cd525b7b11a9d508423e750
b64a0a24aabca36f01308aa41d6fea71c49ae458
/05/sol.cc
2df0de3502d29caf7cfdcae6a7ea4f09f90b15da
[]
no_license
oskmeister/aoc18
860375e7bf6d1327bdb5cc199bb19d49720dd148
0b6f3fa758e826bed2b93430afdbcc17576c3165
refs/heads/master
2020-04-10T09:08:01.302794
2018-12-22T20:35:22
2018-12-22T20:35:46
160,927,425
0
0
null
null
null
null
UTF-8
C++
false
false
609
cc
#include <iostream> #include <algorithm> #include <string> using namespace std; string process(const std::string &input) { string str; bool changed = false; for (int i = 0; i < input.size(); ++i) { char a = input[i]; char b = input[i+1]; if (abs(a-b) == 32) { ++i; } else { str.push_back(input[i]); } } return str; } int main() { string input; cin >> input; for (;;) { string after = process(input); if (after == input) break; input = after; } cout << input.size() << endl; }
[ "osk@spotify.com" ]
osk@spotify.com
6a9e520ba48643659ff45ed39d1bce523fb565b3
6b40e9dccf2edc767c44df3acd9b626fcd586b4d
/NT/enduser/netmeeting/t120/h/crc.h
d7736b9b1e8ae1718ed260a0da4339fe6bf51dd1
[]
no_license
jjzhang166/WinNT5_src_20201004
712894fcf94fb82c49e5cd09d719da00740e0436
b2db264153b80fbb91ef5fc9f57b387e223dbfc2
refs/heads/Win2K3
2023-08-12T01:31:59.670176
2021-10-14T15:14:37
2021-10-14T15:14:37
586,134,273
1
0
null
2023-01-07T03:47:45
2023-01-07T03:47:44
null
UTF-8
C++
false
false
3,653
h
/* crc.h * * Copyright (c) 1994-1995 by DataBeam Corporation, Lexington, KY * * Abstract: * This file contains the CRC class definition. This class can use either * the table-driven or bit-shifting approach to generate its CRC. * * Public Instance Variable: * None * * Caveats: * None. * * Authors: * Marvin Nicholson */ #ifndef _CRC_ #define _CRC_ #include "databeam.h" #define CRC_TABLE_SIZE 256 class CRC { public: CRC (); ~CRC (); ULong OldCRCGenerator( PUChar block_adr, ULong block_len); ULong CRCGenerator( PUChar block_adr, ULong block_len); DBBoolean CheckCRC( PUChar block_adr, ULong block_len); Void GetOverhead( UShort maximum_packet, PUShort new_maximum_packet); private: UShort CRCTableValue( Int Index, ULong poly); Void CRCTableGenerator( ULong poly); UShort CRC_Table[CRC_TABLE_SIZE]; Int CRC_Width; ULong CRC_Poly; ULong CRC_Init; UShort CRC_Check_Value; DBBoolean Invert; UShort CRC_Register; }; typedef CRC * PCRC; #endif /* * CRC::CRC (); * * Functional Description * This is the constructor for this class. * * Formal Parameters * None. * * Return Value * None * * Side Effects * None * * Caveats * None */ /* * CRC::~CRC (); * * Functional Description * This is the destructor for this class. * * Formal Parameters * None. * * Return Value * None * * Side Effects * None * * Caveats * None */ /* * ULong CRC::OldCRCGenerator( * PUChar block_adr, * ULong block_len); * * Functional Description * This function generates the crc using bit-shifting methods. This method * is slower than the table-driven approach. * * Formal Parameters * block_adr (i) - Address of buffer to generate CRC on. * block_lengh (i) - Length of buffer * * Return Value * CRC value * * Side Effects * None * * Caveats * None */ /* * ULong CRC::CRCGenerator( * PUChar block_adr, * ULong block_len); * * Functional Description * This function generates the crc using the table-driven method. * * Formal Parameters * block_adr (i) - Address of buffer to generate CRC on. * block_lengh (i) - Length of buffer * * Return Value * CRC value * * Side Effects * None * * Caveats * None */ /* * DBBoolean CRC::CheckCRC( * PUChar block_adr, * ULong block_len); * * Functional Description * This function generates a CRC based on the block passed in. It assumes * that the CRC is attached to the end of the block. It compares the * CRC generated to the CRC at the end of the block and returns TRUE if * the CRC is correct. * * Formal Parameters * block_adr (i) - Address of buffer to generate CRC on. * block_lengh (i) - Length of buffer * * Return Value * TRUE - CRC in the block is correct * FALSE - CRC in the block is NOT correct * * Side Effects * None * * Caveats * None */ /* * Void CRC::GetOverhead( * UShort maximum_packet, * PUShort new_maximum_packet); * * Functional Description * This function is called to determine the overhead that will be added * to the packet by the CRC. * * Formal Parameters * maximum_packet (i) - Current max. packet size * new_maximum_packet (o) - Maximum length of packet including CRC. * * Return Value * None * * Side Effects * None * * Caveats * None */
[ "seta7D5@protonmail.com" ]
seta7D5@protonmail.com
a9fa41e5a2c0807bbf3413e97e5067e39c22696f
a78a81a9a6a863602c66a23cbb7e7830fe986e64
/Stack/ValidateStackSequences.cpp
5cc64d6a0f3029ac29e6916ed0a49abc0b528a8f
[]
no_license
PoWeiChiao/Cpp
9c271818d16182f5b56e47c0709ff10d01e06c4b
02fcb07d2b2e30f8fe627cdcb68512859d32e042
refs/heads/main
2023-06-05T05:46:56.349164
2021-06-30T12:59:44
2021-06-30T12:59:44
370,227,776
0
0
null
null
null
null
UTF-8
C++
false
false
652
cpp
#include <vector> // Given two sequences pushed and popped with distinct values, return true if and only if this could have been the result of a sequence of push and pop operations on an initially empty stack. using namespace std; class Solution { public: bool validateStackSequences(vector<int>& pushed, vector<int>& popped) { vector<int> stack; int j = 0; for (auto &it : pushed) { stack.push_back(it); while (!stack.empty() && j < popped.size() && popped[j] == stack.back()) { stack.pop_back(); j++; } } return stack.empty(); } };
[ "pwchiao@hotmail.com" ]
pwchiao@hotmail.com
d278617e6056d1d7798a82b3b2b31b28987a6289
7acd6c3e4f1c0842693f1693a295e074478806de
/Lab_6/Lab_6_Case_Study/Lab_6_Case_Study/Date.h
54886574961fb15e251bfcd9ada8f00e77f87a11
[]
no_license
ecodespace/EE361-Work
f1606ab90afad3b079982264d9970033e7f8dffa
7d995affa1f32247c9082e0480a1defbba9501f5
refs/heads/master
2021-01-10T12:33:20.697177
2016-04-04T15:19:43
2016-04-04T15:19:43
55,416,119
0
0
null
null
null
null
UTF-8
C++
false
false
432
h
// Exception Classes class MonthError {}; class DayError {}; class YearError {}; class Date { public: Date(); Date(int InitMonth, int InitDay, int InitYear); int GetMonth() const; int GetDay() const; int GetYear() const; bool operator<(const Date & otherDate) const; bool operator>(const Date & otherDate) const; bool operator==(const Date & otherDate) const; private: int month; int day; int year; };
[ "emzcampb@gmail.com" ]
emzcampb@gmail.com
422d226fe0039b387cb8464b981682284ce1670e
c41dcdb9b1555321b49ad1be54f79c8a793d493d
/C++/C++ Primer Exerices/Ch. 03/ex-3.40.cpp
b837e3c3d211192720e8b5a49e9ca0332614aa39
[]
no_license
katawful/Exercises
cd1c54689b7e932db45003e740da05bb2159a1e7
55b386af0ebd41b09d5b8e3cda36071705eeed83
refs/heads/master
2023-03-26T04:09:48.090503
2021-03-24T01:35:18
2021-03-24T01:35:18
259,482,009
0
0
null
null
null
null
UTF-8
C++
false
false
357
cpp
#include <iostream> #include <cstring> using std::cout; using std::endl; int main() { char cs1[] = "HELLO!"; char cs2[] = "WORLD!"; auto sz1 = strlen(cs1); auto sz2 = strlen(cs2); auto sz = sz1 + sz2 + 2; size_t cssz = sz; char csc[cssz]; strcpy(csc, cs1); strcat(csc, " "); strcat(csc, cs2); char *cp = csc; cout << csc << endl; return 0; }
[ "katisntgood@gmail.com" ]
katisntgood@gmail.com
3b65f9c08ac578c78b23ff950357a78c7df38cf1
dd21a05b5040b59f08f20ebf3fb1793ecbdee8e6
/lib/FastTrackFitter.cpp
45ab0e53ad78d582c844d1ed1c9eb9233df296fd
[ "MIT" ]
permissive
demelian/fastrack
5755121c4f7b77b976850ad3cd5177467526ec6c
e12fd3305394a115e321be12ad8562aee8121f1b
refs/heads/master
2022-11-15T11:30:51.112093
2019-03-22T16:14:32
2019-03-22T16:14:32
175,816,172
1
4
null
null
null
null
UTF-8
C++
false
false
29,699
cpp
#include<iostream> #include<cstring> #include<cmath> #include <math.h> #include "FastTrackFitter.h" #include<algorithm> float FastTrackFitter::calculateLikelihood(float w, int nHits, int* hArray, HIT_INFO* info) const { float chi2_sum = 0; unsigned int vl[256]; unsigned int layerKeys[128]; memset(&vl[0],0,sizeof(vl)); int nL = 0; for(int hitIdx = 0;hitIdx<nHits;hitIdx++) { if(info[hitIdx].m_status != 0) continue; int h = hArray[hitIdx]; unsigned int layerKey = 7*(m_hits->m_vol_id[h]-7) + (m_hits->m_lay_id[h]>>1); if(vl[layerKey] == 0) nL++; vl[layerKey]++; layerKeys[hitIdx] = layerKey; } for(int hitIdx=0;hitIdx<nHits;hitIdx++) { if(info[hitIdx].m_status != 0) continue; int nc = vl[layerKeys[hitIdx]]; chi2_sum += info[hitIdx].m_dchi2/nc; } float L = w*nL - chi2_sum; return L; } int FastTrackFitter::getTriplet(NEW_TRACK* pT, int* v) const { int it = 0; int h = pT->m_hits[it]; v[0] = h; ++it; int hitCounter = 1; while(it < pT->m_nHits) { int vol_id = m_hits->m_vol_id[h]; int lay_id = m_hits->m_lay_id[h]; int h2 = pT->m_hits[it]; int vol_id_2 = m_hits->m_vol_id[h2]; int lay_id_2 = m_hits->m_lay_id[h2]; if(vol_id == vol_id_2 && lay_id == lay_id_2) { ++it;continue; } h = h2; v[hitCounter++] = h; if(hitCounter == 3) break; ++it; } return hitCounter; } int FastTrackFitter::getLastTriplet(NEW_TRACK* pT, int* v) const { int it = pT->m_nHits-1; int h = pT->m_hits[it]; v[0] = h; --it; int hitCounter = 0; while(it >=0) { int vol_id = m_hits->m_vol_id[h]; int lay_id = m_hits->m_lay_id[h]; int h2 = pT->m_hits[it]; int vol_id_2 = m_hits->m_vol_id[h2]; int lay_id_2 = m_hits->m_lay_id[h2]; if(vol_id == vol_id_2 && lay_id == lay_id_2) { --it;continue; } h = h2; v[hitCounter++] = h; if(hitCounter == 3) break; --it; } return hitCounter; } bool FastTrackFitter::initialize(NEW_TRACK* pT) const { const double Cs = 0.000299997; //select 3 hits int vh3[3]; int n3 = getTriplet(pT, vh3); if(n3<3) return false; int h1 = vh3[0]; int h2 = vh3[1]; int h3 = vh3[2]; float x0 = m_hits->m_x[h1]; float y0 = m_hits->m_y[h1]; float z0 = m_hits->m_z[h1]; float dx1 = m_hits->m_x[h2]-x0; float dy1 = m_hits->m_y[h2]-y0; float dx2 = m_hits->m_x[h3]-x0; float dy2 = m_hits->m_y[h3]-y0; float dz2 = m_hits->m_z[h3]-z0; //conformal mapping double rn = dx2*dx2+dy2*dy2; double r2 = 1/rn; double u1 = 1/sqrt(dx1*dx1+dy1*dy1); double K = u1*r2; double a = dx1*K; double b = dy1*K; double u2 = a*dx2 + b*dy2; double v2 = a*dy2 - b*dx2; double A = v2/(u2-u1); double B = v2-A*u2; double Curv = B/sqrt(1+A*A);//curvature float ctg = dz2*sqrt(r2);//cot(theta) const DETECTOR_ELEMENT* pDE = m_geo.getDetectorElement(m_hits->m_vol_id[h1], m_hits->m_lay_id[h1], m_hits->m_mod_id[h1]); float Corr = m_params.tf_f[0]; //correction factor due to the non-uniform magnetic field float P[5]; P[0] = m_hits->m_m1[h1]; P[1] = m_hits->m_m2[h1]; P[2] = atan2(b+a*A, a-b*A);//phi0 P[3] = atan(1/ctg);//theta if(P[3]<0.0) P[3] += M_PI; float fC = Cs*Corr; float pt_inv = -Curv/fC;// 1/pT in GeV P[4] = pt_inv/sqrt(1+ctg*ctg);//full inverse momentum pT->m_endTrackState.initialize(P, pDE); return true; } bool FastTrackFitter::fitTrackCandidate(NEW_TRACK* pT, int stage) const { float maxDChi2 = 27.0; float maxFrac = 0.10; float llWeight = 5.0; if(stage<1 || stage>5) return false; m_stage = stage; int offset = 3*stage-3; maxDChi2 = m_params.tf_f[1+offset]; maxFrac = m_params.tf_f[2+offset]; llWeight = m_params.tf_f[3+offset]; //1. create track, sort hits pT->sortHits(m_hits); if(!initialize(pT)) return false; TRACK_STATE* pTS = &pT->m_endTrackState; bool result = true; pT->m_status = 0; int nOutliers=0; int nHits0 = pT->m_nHits; float OutlThr = maxFrac*nHits0; int hit_status[100]; for(int hitIdx=0;hitIdx<nHits0;hitIdx++) { int h = pT->m_hits[hitIdx]; int code = m_fte.fastExtrapolator(pTS, h, false); if(code == -20) {//not in bounds hit_status[hitIdx] = -1; nOutliers++; if(nOutliers >= OutlThr) { result = false; break; } memcpy(&pTS->m_Rk[0], &pTS->m_Re[0], sizeof(pTS->m_Re)); memcpy(&pTS->m_Ck[0], &pTS->m_Ce[0], sizeof(pTS->m_Ce)); continue; } if(code!=0) { result = false; break; } FIT_HIT fh(h); update(pTS, &fh, maxDChi2); if(!pTS->valid()) { result = false; break; } hit_status[hitIdx] = fh.m_status; if(fh.m_status!=0) nOutliers++; if(nOutliers >= OutlThr) { result = false; break; } } if(result) { if(nOutliers>0 && nOutliers < OutlThr) { pT->m_nHits = 0; for(int hitIdx=0;hitIdx<nHits0;hitIdx++) { if(hit_status[hitIdx] == 0) { pT->m_hits[pT->m_nHits++] = pT->m_hits[hitIdx]; } } pT->update(m_hits); } } if(result) { float L = llWeight*pT->m_nlayers - pTS->m_chi2; pT->m_ll = L; pT->m_chi2 = pTS->m_chi2; pT->m_ndof = pTS->m_ndof; pT->m_status = 1; } else { pT->m_endTrackState.m_initialized = false; } if(!result) return false; return true; } void FastTrackFitter::fitTrack(NEW_TRACK* pT, int stage) { float maxDChi2 = 100.0; float llWeight = 60.0; float fracOutl = 0.33; if( !((stage>=1 && stage <= 4) || (stage>=11 && stage <= 14))) { pT->m_status = 0; return; } int offset = stage < 11 ? 16+3*(stage-1) : 28+3*(stage-11); maxDChi2 = m_params.tf_f[offset]; llWeight = m_params.tf_f[offset+1]; fracOutl = m_params.tf_f[offset+2]; //1. create track, sort hits pT->sortHits(m_hits); pT->m_status = 0; if(pT->m_beginTrackState.valid()) { pT->m_endTrackState.initialize(pT->m_beginTrackState); } else { if(!initialize(pT)) return; } TRACK_STATE* pTS = &pT->m_endTrackState; bool result = true; pT->m_status = 0; int nOutliers=0; int nHits0 = pT->m_nHits; HIT_INFO info[MAX_HIT_ON_TRACK]; for(int hitIdx=0;hitIdx<nHits0;hitIdx++) { int h = pT->m_hits[hitIdx]; int code = m_fte.fastExtrapolator(pTS, h, false); if(code == -20) {//not in bounds nOutliers++; info[hitIdx].m_dchi2 = 0.0; info[hitIdx].m_status = -1; memcpy(&pTS->m_Rk[0], &pTS->m_Re[0], sizeof(pTS->m_Re)); memcpy(&pTS->m_Ck[0], &pTS->m_Ce[0], sizeof(pTS->m_Ce)); continue; } if(code!=0) { result = false; //std::cout<<"extrapolation failure, code = "<<code<<std::endl; break; } FIT_HIT fh(h); update(pTS, &fh, maxDChi2); if(!pTS->valid()) { result = false; break; } if(fh.m_status!=0 || std::isnan(fh.m_dchi2) ) nOutliers++; info[hitIdx].m_dchi2 = fh.m_dchi2; info[hitIdx].m_status = fh.m_status; } if(result) { //pTS->print(); //update track here .... if(nOutliers>0 && nOutliers<fracOutl*nHits0) { std::vector<int> newHits; std::vector<HIT_INFO> newInfo; for(int hitIdx=0;hitIdx<nHits0;hitIdx++) { if(info[hitIdx].m_status != 0) continue; newInfo.push_back(info[hitIdx]); newHits.push_back(pT->m_hits[hitIdx]); } pT->m_nHits=0; for(unsigned int k=0;k<newHits.size();k++) { info[pT->m_nHits] = newInfo[k]; pT->m_hits[pT->m_nHits++] = newHits[k]; } pT->update(m_hits); } pT->m_ll = calculateLikelihood(llWeight, pT->m_nHits, pT->m_hits, info); pT->m_status = 1; } } bool FastTrackFitter::getTrajectory(NEW_TRACK* pT, TRAJECTORY& vPoints) { float maxDChi2 = m_params.tf_f[40]; float minStep = m_params.tf_f[41]; float maxFrac = m_params.tf_f[42]; bool result = true; vPoints.m_nPoints = 0; if(!pT->m_endTrackState.valid()) { return false; } int nHits0 = pT->m_nHits; if(nHits0 == 0) return false; pT->sortHits(m_hits); pT->m_beginTrackState.initialize(pT->m_endTrackState); TRACK_STATE* pInit = &pT->m_beginTrackState; pInit->resetCovariance(); TRACK_STATE* pTS = pInit; int nOutliers=0; float maxOutl = maxFrac*nHits0; int kIdx = nHits0-1; const DETECTOR_ELEMENT* pDE0 = pT->m_endTrackState.m_pDE; for(;kIdx>0;kIdx--) { int h = pT->m_hits[kIdx]; const DETECTOR_ELEMENT* pNE = m_geo.getDetectorElement(m_hits->m_vol_id[h], m_hits->m_lay_id[h], m_hits->m_mod_id[h]); if(pNE == pDE0) break; } if(kIdx == 0) kIdx = nHits0-1; FIT_HIT fh(pT->m_hits[kIdx]); update(pTS, &fh, maxDChi2); if(fh.m_status!=0) nOutliers++; kIdx--; for(;kIdx>=0;kIdx--) { int h = pT->m_hits[kIdx]; int code = m_fte.fastExtrapolate(pTS, h, minStep, vPoints); if(code!=0) { result = false; break; } FIT_HIT fh(h); update(pTS, &fh, maxDChi2); if(!pTS->valid()) { result = false; break; } if(fh.m_status!=0) nOutliers++; if(nOutliers >= maxOutl) { result = false; break; } } if(result) { int firstHit = pT->m_hits[0]; bool searchInside = true; if(m_hits->m_vol_id[firstHit] == 8 && m_hits->m_lay_id[firstHit] == 2) searchInside = false; if(searchInside) m_fte.extrapolateInsideFast(pTS, vPoints); } return result; } void FastTrackFitter::backwardPropagation(NEW_TRACK* pT, TRAJECTORY& vPoints) { float maxDChi2 = m_params.tf_f[43]; float maxFrac = m_params.tf_f[44]; //1. create track state if(!pT->m_endTrackState.valid()) { return; } int nHits0 = pT->m_nHits; if(nHits0 == 0) return; pT->m_beginTrackState.initialize(pT->m_endTrackState); TRACK_STATE* pInit = &pT->m_beginTrackState; pInit->resetCovariance(); TRACK_STATE* pTS = pInit; bool result = true; int nOutliers=0; float maxOutl = maxFrac*nHits0; int kIdx = nHits0-1; const DETECTOR_ELEMENT* pDE0 = pT->m_endTrackState.m_pDE; for(;kIdx>0;kIdx--) { int h = pT->m_hits[kIdx]; const DETECTOR_ELEMENT* pNE = m_geo.getDetectorElement(m_hits->m_vol_id[h], m_hits->m_lay_id[h], m_hits->m_mod_id[h]); if(pNE == pDE0) break; } if(kIdx == 0) kIdx = nHits0-1; FIT_HIT fh(pT->m_hits[kIdx]); update(pTS, &fh, maxDChi2); if(fh.m_status!=0) nOutliers++; kIdx--; for(;kIdx>=0;kIdx--) { int h = pT->m_hits[kIdx]; int code = m_fte.fastExtrapolate(pTS, h, 0.0, vPoints); if(code!=0) { result = false; //std::cout<<"extrapolation failure, code = "<<code<<std::endl; break; } FIT_HIT fh(h); update(pTS, &fh, maxDChi2); if(!pTS->valid()) { result = false; break; } if(fh.m_status!=0) nOutliers++; if(nOutliers >= maxOutl) { result = false; break; } } vPoints.m_nPointsOnTrack = vPoints.m_nPoints; if(result) { int firstHit = pT->m_hits[0]; bool searchInside = true; if(m_hits->m_vol_id[firstHit] == 8 && m_hits->m_lay_id[firstHit] == 2) searchInside = false; if(searchInside) m_fte.extrapolateInsideFast(pTS, vPoints); } } void FastTrackFitter::addHitsBackward(NEW_TRACK* pT, std::vector<int>& vHits) { const int nMaxNoAdd = 3; float dQ_hole = m_params.tf_f[45]; float dQ_hit = m_params.tf_f[46]; float minQ = m_params.tf_f[47]; float maxDChi2_upd = m_params.tf_f[48]; int nBest = m_params.tf_i[0]; int globalBranchCounter = 0; if(pT->m_nHits >= MAX_HIT_ON_TRACK) return; if(!pT->m_beginTrackState.valid()) { std::cout<<"No valid begin track state found, skipping the extension refit !"<<std::endl; for(std::vector<int>::iterator it=vHits.begin(); it!=vHits.end();it++) { pT->m_hits[pT->m_nHits++] = (*it); if(pT->m_nHits >= MAX_HIT_ON_TRACK) break; } return; } //do branching exploration here ... //arrange hits in layers std::vector<int> hitArray[100]; std::vector<unsigned int> keyArray; for(std::vector<int>::iterator hIt=vHits.begin();hIt!=vHits.end();++hIt) { int h = (*hIt); if(m_hits->m_mask[h] == 2) continue; int vol_id = m_hits->m_vol_id[h]; int lay_id = m_hits->m_lay_id[h]; unsigned int layerKey = (vol_id-7) + (lay_id>>1); if(std::find(keyArray.begin(), keyArray.end(), layerKey) == keyArray.end()) { keyArray.push_back(layerKey); } hitArray[layerKey].push_back(h); } //std::cout<<"Processing new track extension ....."<<std::endl; std::vector<TRACK_CLONE*> vBranches; TRACK_CLONE* pClone = &m_tClones[globalBranchCounter++]; pClone->initialize(&pT->m_beginTrackState); vBranches.push_back(pClone); std::vector<TRACK_CLONE*> newBranches; int lIdx=0; bool errorFlag = false; int nNoAdd = 0; for(;lIdx<(int)keyArray.size();lIdx++) { std::vector<int>& vHL = hitArray[keyArray[lIdx]]; unsigned int nHits = vHL.size(); int nNewTotal=0; for(std::vector<TRACK_CLONE*>::iterator bIt=vBranches.begin();bIt!=vBranches.end();++bIt) { int bCounter = 0; //1. add "skip-all", "no-detect-in-this layer" branch TRACK_CLONE* nodBr = &m_tClones[globalBranchCounter++]; if(globalBranchCounter >= MAX_CLONE) { errorFlag = true; break; } nodBr->clone(**bIt); nNewTotal++; nodBr->addHole(dQ_hole); //std::cout<<"added hole, Q="<<nodBr->m_Q<<std::endl; newBranches.push_back(nodBr);bCounter++; nNoAdd++; //2. investigate hits //arrange hits into 1- or 2-hit clusters -> each successfully fitted (!) cluster results in a new branch for(unsigned int hIdx1=0;hIdx1<nHits;hIdx1++) { int h1 = vHL.at(hIdx1); TRACK_CLONE* newBr1 = &m_tClones[globalBranchCounter++]; if(globalBranchCounter >= MAX_CLONE) { errorFlag = true; break; } newBr1->clone(**bIt); int code = m_fte.fastExtrapolator(&newBr1->m_ts, h1); if(code!=0) { newBr1 = 0; continue; } FIT_HIT fh(h1); update(&newBr1->m_ts, &fh, maxDChi2_upd); if(fh.m_status!=0 || std::isnan(fh.m_dchi2)) { newBr1 = 0; continue; } //std::cout<<"new hit added"<<std::endl; float dQ = dQ_hit - fh.m_dchi2;// - log(2*3.1415926*fh.m_detr); newBr1->addHit(h1, dQ); newBranches.push_back(newBr1);bCounter++; nNewTotal++; nNoAdd = 0; int nNewBr = 0; float best_so_far = newBr1->m_Q; //std::cout<<"propagating a newly added branch .."<<std::endl; //try to add another hit for(unsigned int hIdx2=hIdx1+1;hIdx2<nHits;hIdx2++) { int h2 = vHL.at(hIdx2); if(m_hits->m_mod_id[h2] == m_hits->m_mod_id[h1]) continue; if(newBr1 == 0) { std::cout<<"ZERO BRANCH !!!!"<<std::endl; } TRACK_CLONE* newBr12 = &m_tClones[globalBranchCounter++]; if(globalBranchCounter >= MAX_CLONE) { errorFlag = true; break; } newBr12->clone(*newBr1); int code = m_fte.fastExtrapolator(&newBr12->m_ts, h2, true); if(code!=0) { newBr12 = 0; continue; } FIT_HIT fh2(h2); update(&newBr12->m_ts, &fh2, maxDChi2_upd); if(fh2.m_status!=0 || std::isnan(fh2.m_dchi2)) { newBr12 = 0; continue; } float dQ = dQ_hit - fh2.m_dchi2;// - log(2*3.1415926*fh2.m_detr); float newQ = dQ + newBr12->m_Q; if(best_so_far > newQ) { newBr12 = 0; continue; } else { best_so_far = newQ; } newBr12->addHit(h2, dQ); newBranches.push_back(newBr12);bCounter++; nNewTotal++; nNewBr++; //try to add the third hit for(unsigned int hIdx3=hIdx2+1;hIdx3<nHits;hIdx3++) { int h3 = vHL.at(hIdx3); if(m_hits->m_mod_id[h3] == m_hits->m_mod_id[h2]) continue; if(m_hits->m_mod_id[h3] == m_hits->m_mod_id[h1]) continue; if(newBr12 == 0) { std::cout<<"ZERO BRANCH !!!!"<<std::endl; } TRACK_CLONE* newBr123 = &m_tClones[globalBranchCounter++]; if(globalBranchCounter>=MAX_CLONE) { errorFlag = true; break; } newBr123->clone(*newBr12); int code = m_fte.fastExtrapolator(&newBr123->m_ts, h3, false); if(code!=0) { newBr123 = 0; continue; } FIT_HIT fh3(h3); update(&newBr123->m_ts, &fh3, maxDChi2_upd); if(fh3.m_status!=0 || std::isnan(fh3.m_dchi2)) { newBr123 = 0; continue; } float dQ = dQ_hit - fh3.m_dchi2;// - log(2*3.1415926*fh2->m_detr); newQ = dQ + newBr123->m_Q; if(best_so_far > newQ) { newBr123 = 0; continue; } else { best_so_far = newQ; } newBr123->addHit(h3, dQ); newBranches.push_back(newBr123); bCounter++; nNewTotal++; nNewBr++; } } if(errorFlag) break; } if(nNoAdd > nMaxNoAdd) { errorFlag = true; } if(errorFlag) break; } if(errorFlag) break; std::sort(newBranches.begin(), newBranches.end(), TRACK_CLONE::CompareQuality()); //delete old branches vBranches.clear(); int brIdx=0; for(std::vector<TRACK_CLONE*>::iterator bIt=newBranches.begin();bIt!=newBranches.end();++bIt, brIdx++) { if(brIdx <= nBest) vBranches.push_back(*bIt); } newBranches.clear(); if(vBranches.empty()) break; } if(!errorFlag && !vBranches.empty()) { TRACK_CLONE* bestBr = (*vBranches.begin()); if(bestBr->m_Q > minQ) { for(int k=0;k<bestBr->m_nHits;k++) { pT->m_hits[pT->m_nHits++] = bestBr->m_hits[k]; if(pT->m_nHits >= MAX_HIT_ON_TRACK) break; } pT->m_beginTrackState.initialize(bestBr->m_ts); } } } void FastTrackFitter::forwardPropagation(NEW_TRACK* pT, TRAJECTORY& vPoints) { TRACK_STATE* pTS = &pT->m_endTrackState; int lastHit = pT->m_hits[pT->m_nHits-1]; float theta = pTS->m_Rk[3]; bool searchOutside = true; int vol = m_hits->m_vol_id[lastHit]; int lay = m_hits->m_lay_id[lastHit]; if(vol == 12 && lay == 2) return; if(vol == 14 && lay == 12) return; if(vol == 9 && lay == 14) { if(theta < 0.08) return; } if(vol == 7 && lay == 2) { if(theta > M_PI-0.08) return; } if(searchOutside) m_fte.extrapolateOutsideFast(pTS, vPoints); } int FastTrackFitter::addHits(NEW_TRACK* pT, std::vector<int>& vHits) { float dQ_hole = m_params.tf_f[49]; float dQ_hit = m_params.tf_f[50]; float maxDChi2_upd = m_params.tf_f[51]; float minQ = m_params.tf_f[52]; int nBest = m_params.tf_i[1]; int globalBranchCounter = 0; if(pT->m_nHits >= MAX_HIT_ON_TRACK) return 0; if(!pT->m_endTrackState.valid()) { std::cout<<"No valid end track state found, skipping the extension refit !"<<std::endl; for(std::vector<int>::iterator it=vHits.begin(); it!=vHits.end();it++) { pT->m_hits[pT->m_nHits++] = (*it); if(pT->m_nHits >= MAX_HIT_ON_TRACK) break; } return 0; } int nAdded = 0; //do branching exploration here ... //arrange hits in layers along the trajectory std::vector<int> hitArray[100]; std::vector<unsigned int> keyArray; int nM = 0; for(std::vector<int>::iterator hIt=vHits.begin();hIt!=vHits.end();++hIt) { int h = (*hIt); if(m_hits->m_mask[h] == 2) continue; int vol_id = m_hits->m_vol_id[h]; int lay_id = m_hits->m_lay_id[h]; unsigned int layerKey = (vol_id-7) + (lay_id>>1); if(std::find(keyArray.begin(), keyArray.end(), layerKey) == keyArray.end()) { keyArray.push_back(layerKey); } hitArray[layerKey].push_back(h); nM++; } if(nM==0) return 0; std::vector<TRACK_CLONE*> vBranches; TRACK_CLONE* pClone = &m_tClones[globalBranchCounter++]; pClone->initialize(&pT->m_endTrackState); vBranches.push_back(pClone); std::vector<TRACK_CLONE*> newBranches; int lIdx=0; bool errorFlag = false; for(;lIdx<(int)keyArray.size();lIdx++) { std::vector<int>& vHL = hitArray[keyArray[lIdx]]; unsigned int nHits = vHL.size(); int nNewTotal=0; for(std::vector<TRACK_CLONE*>::iterator bIt=vBranches.begin();bIt!=vBranches.end();++bIt) { int bCounter = 0; //1. add "skip-all", "no-detect-in-this layer" branch TRACK_CLONE* nodBr = &m_tClones[globalBranchCounter++]; if(globalBranchCounter>=MAX_CLONE) { errorFlag = true; break; } nodBr->clone(**bIt); nNewTotal++; nodBr->addHole(dQ_hole); //std::cout<<"added hole, Q="<<nodBr->m_Q<<std::endl; newBranches.push_back(nodBr); bCounter++; float best_so_far = nodBr->m_Q; //2. investigate hits //arrange hits into 1- , 2- or 3-hit clusters -> each successfully fitted (!) cluster results in a new branch for(unsigned int hIdx1=0;hIdx1<nHits;hIdx1++) { int h1 = vHL.at(hIdx1); TRACK_CLONE* newBr1 = &m_tClones[globalBranchCounter++]; if(globalBranchCounter>=MAX_CLONE) { errorFlag = true; break; } newBr1->clone(**bIt); int code = m_fte.fastExtrapolator(&newBr1->m_ts, h1, true); if(code!=0) { newBr1 = 0; continue;//just forget about this branch } FIT_HIT fh(h1); update(&newBr1->m_ts, &fh, maxDChi2_upd); if(fh.m_status!=0 || std::isnan(fh.m_dchi2)) { newBr1 = 0; continue; } //std::cout<<"new hit added"<<std::endl; float dQ = dQ_hit - fh.m_dchi2;// - log(2*3.1415926*fh->m_detr); newBr1->addHit(h1, dQ); best_so_far = newBr1->m_Q; newBranches.push_back(newBr1); bCounter++; nNewTotal++; int nNewBr = 0; //try to add another hit for(unsigned int hIdx2=hIdx1+1;hIdx2<nHits;hIdx2++) { int h2 = vHL.at(hIdx2); if(m_hits->m_mod_id[h2] == m_hits->m_mod_id[h1]) continue; if(newBr1 == 0) { std::cout<<"ZERO BRANCH !!!!"<<std::endl; } TRACK_CLONE* newBr12 = &m_tClones[globalBranchCounter++]; if(globalBranchCounter>=MAX_CLONE) { errorFlag = true; break; } newBr12->clone(*newBr1); int code = m_fte.fastExtrapolator(&newBr12->m_ts, h2, true); if(code!=0) { newBr12 = 0; continue; } FIT_HIT fh2(h2); update(&newBr12->m_ts, &fh2, maxDChi2_upd); if(fh2.m_status!=0 || std::isnan(fh2.m_dchi2)) { newBr12 = 0; continue; } float dQ = dQ_hit - fh2.m_dchi2;// - log(2*3.1415926*fh2->m_detr); float newQ = dQ + newBr12->m_Q; if(best_so_far > newQ) { newBr12 = 0; continue; } else { best_so_far = newQ; } newBr12->addHit(h2, dQ); newBranches.push_back(newBr12); bCounter++; nNewTotal++; nNewBr++; //try to add the third hit for(unsigned int hIdx3=hIdx2+1;hIdx3<nHits;hIdx3++) { int h3 = vHL.at(hIdx3); if(m_hits->m_mod_id[h3] == m_hits->m_mod_id[h2]) continue; if(m_hits->m_mod_id[h3] == m_hits->m_mod_id[h1]) continue; if(newBr12 == 0) { std::cout<<"ZERO BRANCH !!!!"<<std::endl; } TRACK_CLONE* newBr123 = &m_tClones[globalBranchCounter++]; if(globalBranchCounter>=MAX_CLONE) { errorFlag = true; break; } newBr123->clone(*newBr12); int code = m_fte.fastExtrapolator(&newBr123->m_ts, h3, true); if(code!=0) { newBr123 = 0; continue; } FIT_HIT fh3(h3); update(&newBr123->m_ts, &fh3, maxDChi2_upd); if(fh3.m_status!=0 || std::isnan(fh3.m_dchi2)) { newBr123 = 0; continue; } float dQ = dQ_hit - fh3.m_dchi2;// - log(2*3.1415926*fh2->m_detr); newQ = dQ + newBr123->m_Q; if(best_so_far > newQ) { newBr123 = 0; continue; } else { best_so_far = newQ; } newBr123->addHit(h3, dQ); newBranches.push_back(newBr123); bCounter++; nNewTotal++; nNewBr++; } if(errorFlag) break; } if(errorFlag) break; } if(errorFlag) break; } //loop over branches if(errorFlag) break; std::sort(newBranches.begin(), newBranches.end(), TRACK_CLONE::CompareQuality()); //drop old branches vBranches.clear(); int brIdx=0; for(std::vector<TRACK_CLONE*>::iterator bIt=newBranches.begin();bIt!=newBranches.end();++bIt, brIdx++) { if(brIdx <= nBest && (*bIt)->m_Q > 2*minQ) vBranches.push_back(*bIt); } newBranches.clear(); if(vBranches.empty()) break; } if(!errorFlag && !vBranches.empty()) { TRACK_CLONE* bestBr = (*vBranches.begin()); if(bestBr->m_Q > minQ) { for(int k=0;k<bestBr->m_nHits;k++) { pT->m_hits[pT->m_nHits++] = bestBr->m_hits[k]; nAdded++; if(pT->m_nHits >= MAX_HIT_ON_TRACK) break; } pT->m_endTrackState.initialize(bestBr->m_ts); } } return nAdded; } void FastTrackFitter::update(TRACK_STATE* pTS, FIT_HIT* fh, float maxDChi2) const { int h = fh->m_h; int vol_id = m_hits->m_vol_id[h]; if(vol_id == 8) {//pixel float cost = fabs(pTS->m_Re[3]-0.5*M_PI); int nCells = m_hits->m_clusterLength[h]; bool drop = false; if(nCells < 7) drop = cost > m_params.tf_table1[nCells]; else drop = cost > m_params.tf_table1[8]; if(drop) {//reject this hit fh->m_status = -1; memcpy(&pTS->m_Rk[0], &pTS->m_Re[0], sizeof(pTS->m_Re)); memcpy(&pTS->m_Ck[0], &pTS->m_Ce[0], sizeof(pTS->m_Ce)); return; } } float m[3] = {m_hits->m_m1[h], m_hits->m_m2[h], 0.0}; double R[2][2]; R[0][1] = R[1][0] = 0.0; R[0][0] = m_params.tf_d[4]; R[1][1] = m_params.tf_d[5]; if(vol_id < 10) {//pixel R[0][0] = m_params.tf_d[0]; R[1][1] = m_params.tf_d[1]; } else if(vol_id < 16) { R[0][0] = m_params.tf_d[2]; R[1][1] = m_params.tf_d[3]; } float Ce[16]; memcpy(&Ce[0], &pTS->m_Ce[0], sizeof(pTS->m_Ce)); double CHT[5][2]; double D[2][2]; float resid[2]; if(pTS->m_pDE->m_isRect) { CHT[0][0] = Ce[0]; CHT[0][1] = Ce[1]; CHT[1][0] = Ce[1]; CHT[1][1] = Ce[2]; CHT[2][0] = Ce[3]; CHT[2][1] = Ce[4]; CHT[3][0] = Ce[6]; CHT[3][1] = Ce[7]; CHT[4][0] = Ce[10]; CHT[4][1] = Ce[11]; D[0][0] = Ce[0] + R[0][0]; D[0][1] = D[1][0] = Ce[1] + R[0][1]; D[1][1] = Ce[2] + R[1][1]; resid[0] = m[0] - pTS->m_Re[0]; resid[1] = m[1] - pTS->m_Re[1]; } else { float sc[2]; pTS->m_pDE->getResidualTransform(m[0], m[1], sc); float p1 = sc[0]*Ce[1]; float p2 = sc[1]*Ce[1]; CHT[0][0] = sc[1]*Ce[0] - p1; CHT[0][1] = sc[0]*Ce[0] + p2; CHT[1][0] = p2 - sc[0]*Ce[2]; CHT[1][1] = p1 + sc[1]*Ce[2]; CHT[2][0] = sc[1]*Ce[3] - sc[0]*Ce[4]; CHT[2][1] = sc[0]*Ce[3] + sc[1]*Ce[4]; CHT[3][0] = sc[1]*Ce[6] - sc[0]*Ce[7]; CHT[3][1] = sc[0]*Ce[6] + sc[1]*Ce[7]; CHT[4][0] = sc[1]*Ce[10] - sc[0]*Ce[11]; CHT[4][1] = sc[0]*Ce[10] + sc[1]*Ce[11]; float sc12 = sc[1]*sc[1]; float sc02 = sc[0]*sc[0]; float scx = sc[0]*sc[1]; float scG = 2*scx*Ce[1]; double RG00 = R[0][0]+Ce[0]; double RG11 = R[1][1]+Ce[2]; D[0][0] = sc12*RG00 + sc02*RG11 - scG; D[0][1] = scx*(RG00-RG11); D[1][1] = sc02*RG00 + sc12*RG11 + scG; D[0][1] += (sc12-sc02)*Ce[1]; D[1][0] = D[0][1]; float d[2] = {m[0] - pTS->m_Re[0], m[1] - pTS->m_Re[1]}; resid[0] = sc[1]*d[0] - sc[0]*d[1]; resid[1] = sc[0]*d[0] + sc[1]*d[1]; } double detr = 1.0/(D[0][0]*D[1][1] - D[0][1]*D[1][0]); //std::cout<<"detr="<<detr<<std::endl; double D_1[2][2]; D_1[0][0] = detr*D[1][1]; D_1[0][1] =-detr*D[1][0]; D_1[1][0] = D_1[0][1]; D_1[1][1] = detr*D[0][0]; float dchi2 = resid[0]*resid[0]*D_1[0][0] + resid[1]*(2*resid[0]*D_1[0][1] + resid[1]*D_1[1][1]); fh->m_dchi2 = dchi2; fh->m_detr = detr; if(dchi2>maxDChi2) {//outlier fh->m_status = -1; memcpy(&pTS->m_Rk[0], &pTS->m_Re[0], sizeof(pTS->m_Re)); memcpy(&pTS->m_Ck[0], &Ce[0], sizeof(pTS->m_Ce)); return; } double K[5][2]; for(int i=0;i<5;i++) for(int j=0;j<2;j++) { K[i][j] = CHT[i][0]*D_1[0][j] + CHT[i][1]*D_1[1][j]; } pTS->m_chi2 += dchi2; pTS->m_ndof += 2; fh->m_status = 0; for(int i=0;i<5;i++) pTS->m_Rk[i] = pTS->m_Re[i] + K[i][0]*resid[0] + K[i][1]*resid[1]; int idx = 0; for(int i=0;i<5;i++) { for(int j=0;j<=i;j++, idx++) { pTS->m_Ck[idx] = Ce[idx] - K[i][0]*CHT[j][0] - K[i][1]*CHT[j][1]; } } float& a = pTS->m_Rk[2]; if(a>M_PI) a=a-2*M_PI; else { if(a<-M_PI) a=a+2*M_PI; } float& b = pTS->m_Rk[3]; if(b<0) b+=M_PI; if(b>M_PI) b-=M_PI; } void FastTrackFitter::compareTrackStates(TRACK_STATE* p1, TRACK_STATE* p2) const { std::cout<<"estimated track params:"<<std::endl; for(int i=0;i<5;i++) { std::cout<<p1->m_Rk[i]<<" "<<p2->m_Rk[i]<<std::endl; } std::cout<<"extrapolated track params:"<<std::endl; for(int i=0;i<5;i++) { std::cout<<p1->m_Re[i]<<" "<<p2->m_Re[i]<<std::endl; } std::cout<<"estimated covariance :"<<std::endl; int idx1=0, idx2=0; for(int i=0;i<5;i++) { for(int j=0;j<=i;j++, idx1++) { std::cout<<p1->m_Ck[idx1]<<" "; } std::cout<<" vs "; for(int j=0;j<=i;j++, idx2++) { std::cout<<p2->m_Ck[idx2]<<" "; } std::cout<<std::endl; } std::cout<<"extrapolated covariance :"<<std::endl; idx1=0; idx2=0; for(int i=0;i<5;i++) { for(int j=0;j<=i;j++, idx1++) { std::cout<<p1->m_Ce[idx1]<<" "; } std::cout<<" vs "; for(int j=0;j<=i;j++, idx2++) { std::cout<<p2->m_Ce[idx2]<<" "; } std::cout<<std::endl; } }
[ "noreply@github.com" ]
noreply@github.com
28cec49d7d118ba8011a463611761a26fdd10fdc
7a09286e408f4d72968063b62eb4f063e648b8c8
/swagger/sdrangel/code/qt5/client/SWGAirspyReport.h
94bbd25097e1d58f358dcd2d64a6199d14783211
[]
no_license
cpicoto/sdrangel
975d15e9cf9a535a0c835d3ca611f8b0ea291dc3
8699bdcbc4b477e6c261877bc4c0617d35504d80
refs/heads/master
2020-05-02T00:34:21.280449
2019-03-24T18:59:06
2019-03-24T18:59:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,475
h
/** * SDRangel * This is the web REST/JSON API of SDRangel SDR software. SDRangel is an Open Source Qt5/OpenGL 3.0+ (4.3+ in Windows) GUI and server Software Defined Radio and signal analyzer in software. It supports Airspy, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay RSP1 and FunCube --- Limitations and specifcities: * In SDRangel GUI the first Rx device set cannot be deleted. Conversely the server starts with no device sets and its number of device sets can be reduced to zero by as many calls as necessary to /sdrangel/deviceset with DELETE method. * Preset import and export from/to file is a server only feature. * Device set focus is a GUI only feature. * The following channels are not implemented (status 501 is returned): ATV and DATV demodulators, Channel Analyzer NG, LoRa demodulator * The device settings and report structures contains only the sub-structure corresponding to the device type. The DeviceSettings and DeviceReport structures documented here shows all of them but only one will be or should be present at a time * The channel settings and report structures contains only the sub-structure corresponding to the channel type. The ChannelSettings and ChannelReport structures documented here shows all of them but only one will be or should be present at a time --- * * OpenAPI spec version: 4.5.0 * Contact: f4exb06@gmail.com * * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen.git * Do not edit the class manually. */ /* * SWGAirspyReport.h * * Airspy */ #ifndef SWGAirspyReport_H_ #define SWGAirspyReport_H_ #include <QJsonObject> #include "SWGSampleRate.h" #include <QList> #include "SWGObject.h" #include "export.h" namespace SWGSDRangel { class SWG_API SWGAirspyReport: public SWGObject { public: SWGAirspyReport(); SWGAirspyReport(QString* json); virtual ~SWGAirspyReport(); void init(); void cleanup(); virtual QString asJson () override; virtual QJsonObject* asJsonObject() override; virtual void fromJsonObject(QJsonObject &json) override; virtual SWGAirspyReport* fromJson(QString &jsonString) override; QList<SWGSampleRate*>* getSampleRates(); void setSampleRates(QList<SWGSampleRate*>* sample_rates); virtual bool isSet() override; private: QList<SWGSampleRate*>* sample_rates; bool m_sample_rates_isSet; }; } #endif /* SWGAirspyReport_H_ */
[ "f4exb06@gmail.com" ]
f4exb06@gmail.com
edbddedc7dee5deee03680797062c2a493b0220f
3047484a8ae42cc355a805c77a736155402792ac
/rapidxml/main5.cpp
c235d93b254b66d5740f8b3a7280392433f80eb6
[ "MIT", "BSL-1.0" ]
permissive
vitawebsitedesign/321
4f3890c85070c9d07039e6032d60a8935b61e8b8
f33e70155a34fa83f15bb48309f62da6bafefc33
refs/heads/master
2021-01-23T20:50:34.502337
2014-05-30T10:12:08
2014-05-30T10:12:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
23,327
cpp
#include <iostream> #include "rapidxml.hpp" #include "rapidxml_utils.hpp" #include "rapidxml_print.hpp" #include <string.h> #include <string> using namespace rapidxml; using namespace std; void IDchecker(int classamount, int i, string IDerror[],string genClass[],string quaClass[],string linkClass[], int classCount,string oto[][2],int io ,ofstream& ofs); void missInhertence(int genClasscount,int attCount ,int classCount,string genClass[], string att[][100], ofstream& ofs); void missGen(int genAssCount, string genAss[][3], ofstream& ofs); void checkMuti(bool qulification,char* pNode3name,char* pNode3value, ofstream& ofs); void nonremoveAtt(int attCount, char* pNodevalue,string attributes[], ofstream& ofs); void linkedMuti(bool linked, string muti[], ofstream& ofs); void multivaluedAtt(string muti[], ofstream& ofs, int m); void pluralCheck(char* pattern, ofstream& ofs, char* multi); void ArtiID(char* attribute, xml_node<> *node, ofstream& ofs); void ArtiID(char* attribute, xml_node<> *node, ofstream& ofs) { int size = strlen(attribute); if(((attribute[size - 2] == 'i'&& attribute[size-1] == 'd' ) || (attribute[size - 2] == 'I' && attribute[size-1] == 'D' )) && strcmp(node->name(),"identifier") ==0 && strcmp(node->value(),"")!=0 ) { cout<<"Warning: don't use artifical identifier "<<attribute<<endl; ofs<<"~Warning: don't use artifical identifier "<<attribute<<endl; } } void pluralCheck( char* pattern, ofstream& ofs, char* multi) { int Psize = strlen(pattern); bool nonMulti = false; if (strcmp(multi,"[0..1]") == 0 ||strcmp(multi,"") == 0) nonMulti = true; if(nonMulti && pattern[Psize -1] == 's' && pattern[Psize-2] != 's' ) { ofs<<"~Warning: "<<pattern<<" used without multivalued attribute tag"<<endl; cout<<"Warning: "<<pattern<<" used without multivalued attribute tag"<<endl; } else if(nonMulti && pattern[Psize -1] == 's' && pattern[Psize -2] == 'e' ) { ofs<<"~Warning: "<<pattern<<" used without multivalued attribute tag"<<endl; cout<<"Warning: "<<pattern<<" used without multivalued attribute tag"<<endl; } } void multivaluedAtt(string muti[], ofstream& ofs, int m) { int muliCount = 0; for(int i=0; i<m; i++) { for(int n = 0; n < muti[i].length() ; n++) { if(muti[i][n] != '0' && muti[i][n] != '1' && muti[i][n] != '[' && muti[i][n] != ']' && muti[i][n] != '.' ) { muliCount ++; break; } } if (muliCount > 1) { ofs<<"~Error: Can not have two or more multivalued attributes in a class."<<endl; cout<<"Error: Can not have two or more multivalued attributes in a class."<<endl; break; } } } void linkedMuti(bool linked, string muti[], ofstream& ofs) { if(linked && (muti[0] == "[1]" || muti[0] == "[0..1]" || muti[1] == "[1]" || muti[1] == "[0..1]") ) { ofs<<"~ Error: Link attribute or association class can not used for one-to-one or one-to-many association."<<endl; cout<<"~Error: Link attribute or association class can not used for one-to-one or one-to-many association."<<endl; } } void nonremoveAtt(int attCount, char* pNodevalue,string attributes[], ofstream& ofs) { for(int i =0; i < attCount; i++) { if(pNodevalue == attributes[i]) { ofs << "~Error: Attributes: "<<pNodevalue<<" used in qualification must be removed from a class on the other side of qualification" << endl; cout<<"Error: Attributes: "<<pNodevalue<<" used in qualification must be removed from a class on the other side of qualification"<<endl; break; } } } void checkMuti(bool qulification,char* pNode3name,char* pNode3value, ofstream& ofs) { if (qulification && strcmp(pNode3name,"multiplicity")==0 ) { char* star = strstr(pNode3value,"*"); if (star) { ofs <<"~Error: Wrong multiplicity: "<<pNode3value<<" on the other side of qualification"<<endl; cout<<"Error: Wrong multiplicity: "<<pNode3value<<" on the other side of qualification"<<endl; } } } void missGen(int genAssCount, string genAss[][3], ofstream& ofs) { int CountSameRow[genAssCount][genAssCount]; int SameRow[genAssCount]; for(int i =0; i< genAssCount; i++) { SameRow[i] = -1; } int count =0; for(int i = 0; i < genAssCount ; i++) { bool temp = true; bool exist = false; for(int n=0; n<genAssCount ; n++) { if(i == SameRow[n]) { temp =false; } } if(temp) { int m =0; bool flag =false; for(int j = i+1; j <genAssCount; j++) { if(genAss[i][0] == genAss[j][0] && genAss[i][1] == genAss[j][1]) { CountSameRow[i][m] = j; if(flag == false) { ofs<<"~Warning:"<<genAss[i][2]; cout<<"Warning:"<<genAss[i][2]; flag = true; } exist = true; ofs<<" and "<<genAss[CountSameRow[i][m]][2]; cout<<" and "<<genAss[CountSameRow[i][m]][2]; m++; SameRow[count] = j; count++; } } if(exist) { ofs<<" can be generated to one class "<<endl; cout<<" can be generated to one class"<<endl; } } } } void missInhertence(int genClasscount,int attCount ,int classCount,string genClass[], string att[][100], ofstream& ofs) { if(genClasscount>0){ int sameClass[genClasscount]; for(int jj = 0; jj < classCount ; jj++) { for(int kk =0 ;kk < genClasscount; kk++) { if (genClass[kk] == att[jj][0]) { sameClass[kk] = jj; } } } string value="tmp"; for (int m =0; m < attCount ; m++) { for(int n =0 ;n < attCount; n++) { if(att[sameClass[0]][m] == att[sameClass[1]][n] && att[sameClass[0]][m] != "") { value = att[sameClass[0]][m]; break; } } } int y=2; for( y;y<genClasscount ;y++) { for(int y1=1;y1<attCount;y1++) { if(value==att[y][y1]) break; } } if(y==genClasscount&& value!="tmp") { ofs <<"~Error: "<< value <<" can be in the parent class"<<endl; cout <<"Error: "<< value <<" can be in the parent class"<<endl; } } } void IDchecker(int classamount, int i, string IDerror[],string genClass[],string quaClass[],string linkClass[],int classCount,string oto[][2], int io ,ofstream& ofs) // one to ont is fixed { classamount = classamount + io*2; for(int j=0;j<i;j++) { string str1 = "~Error: The class: "; string str2 = " has no identifer"; string str; bool tmp = false; for(int k =0 ;k < classamount; k++) { if(IDerror[j] == genClass[k] || IDerror[j] == quaClass[k] || IDerror[j] == linkClass[k]) { tmp = true; break; } } for(int ii = 0; ii<io ; ii++) { if(IDerror[j] == oto[ii][0] ) { bool oneTone = true; for(int j=0;j<i;j++) { if(oto[ii][1] == IDerror[j]) oneTone = false; } if(oneTone) tmp = true; } else if(IDerror[j] == oto[ii][1] ) { bool oneTone = true; for(int j=0;j<i;j++) { if(oto[ii][0] == IDerror[j]) oneTone = false; } if(oneTone) tmp = true; } } if(tmp == false ) { str = str1 + IDerror[j] + str2; ofs<<str<<endl; cout<<str<<endl; } } } int main() { file<> fdoc("information.xml"); std::cout<<fdoc.data()<<std::endl; xml_document<> doc; doc.parse<0>(fdoc.data()); // std::cout<<doc.name()<<"............................................"<<std::endl; ofstream ofs; //ofs.open("errorMessage.txt", ios::app); ofs.open("../product/errorMessage.txt", ios::app); xml_node<> *root = doc.first_node(); string IDerror[100]; // store current classes without ID string classname[100]; // store all classes name string genClass[100]; // store classes which are gened string quaClass[100]; // store class which are qualified string att[100][100]; // store the class if have attributes string genAss[100][3]; // store gened class's attribute string linkClass[100]; // store linked classes string oto[100][2]; int io = 0; // count one to one cases; int genAssCount = 0; int classCount = 0; int attCount = 0; int i =0; // amount of classes with ID error int genClasscount = 0; int classamount = 0; int l = 0; // amount of linked classes int q = 0; // amount of qulification classes string attributes[100]; for(xml_node<> *pNode1=root->first_node(); pNode1; pNode1=pNode1->next_sibling()) { int IDcount = 0; int IDattCount = 0; bool qualification = false; bool linked = false; string muti[2]; string Cmuti[100]; int mm =0; int m = 0; int j = 0; for(xml_node<> *pNode2=pNode1->first_node(); pNode2; pNode2=pNode2->next_sibling()) { if(strcmp(pNode2->name(),"class_name")==0) { classname[i] = pNode2->value(); } if(strcmp(pNode2->name(),"attribute")==0) { IDattCount ++; } if(strcmp(pNode1->name(),"class") ==0 && strcmp(pNode2->name(),"class_name")==0 ) { att[classCount][0] = pNode2->value(); } if(strcmp(pNode1->name(),"generlisation") == 0) { if(strcmp(pNode2->name(),"class_name")==0) { genClass[j] = pNode2->value(); j++; genClasscount = j; classamount = j; } } if(strcmp(pNode1->name(),"association")==0 && strcmp(pNode2->name(),"nameOfAssociation")==0 && strcmp(pNode2->value(),"") != 0) { genAss[genAssCount][0] = pNode2->value(); } for(xml_node<> *pNode3=pNode2->first_node(); pNode3; pNode3=pNode3->next_sibling()) { if(strcmp(pNode3->name(),"")!=0) { char* tmp; if(strcmp(pNode3->name(),"identifier")==0 && pNode3->value()[0]=='I') IDcount++; else if(strcmp(pNode3->name(),"identifier")==0 && pNode3->value()[0]=='i') IDcount++; if(strcmp(pNode1->name(),"class")==0 && strcmp(pNode2->name(),"attribute")==0 && strcmp(pNode3->name(),"attribute_name")==0 ) { ArtiID(pNode3->value(),pNode3->next_sibling(), ofs); for(int i =0; i<100; i++) { if(attributes[i] == "") { attributes[i] = pNode3->value(); tmp = pNode3->value(); break; } } att[classCount][attCount] = pNode3->value(); attCount++; } if(strcmp(pNode1->name(),"class")==0 && strcmp(pNode2->name(),"attribute")==0 && strcmp(pNode3->name(),"multiplicity")==0) { pluralCheck( tmp, ofs, pNode3->value()); } if((strcmp(pNode1->name(),"association")==0 && strcmp(pNode2->name(),"class")==0 && strcmp(pNode3->name(),"qualification")==0 && strcmp(pNode3->value(),"") != 0) || (strcmp(pNode1->name(),"association")==0 && strcmp(pNode2->name(),"other_class")==0 && strcmp(pNode3->name(),"qualification")==0 && strcmp(pNode3->value(),"") != 0)) { qualification = true; nonremoveAtt(attCount, pNode3->value(), attributes, ofs); } if(strcmp(pNode1->name(),"association")==0 && strcmp(pNode2->name(),"class")==0 && strcmp(pNode3->name(),"class_name")==0) { genAss[genAssCount][1] = pNode3->value(); } if(strcmp(pNode1->name(),"association")==0 && strcmp(pNode2->name(),"other_class")==0 && strcmp(pNode3->name(),"class_name")==0) { genAss[genAssCount][2] = pNode3->value(); genAssCount++; } if(strcmp(pNode1->name(),"association")==0 && strcmp(pNode2->name(),"class")==0 && strcmp(pNode3->name(),"class_name")==0 && strcmp(pNode3->next_sibling()->name(),"multiplicity")==0 && (strcmp(pNode3->next_sibling()->value(),"[1]")==0 || strcmp(pNode3->next_sibling()->value(),"[0..1]")==0 )) { if(strcmp(pNode2->next_sibling()->name(),"other_class")==0)// { for( xml_node<> *tmp = pNode2->next_sibling()->first_node();tmp; tmp=tmp->next_sibling()) { if(tmp->next_sibling() != NULL) //cout<< tmp->name()<<" "<<tmp->value()<<" "<<tmp->next_sibling()->name()<<" "<<tmp->next_sibling()->value()<<endl; if( strcmp(tmp->name(),"class_name") ==0 && strcmp(tmp->next_sibling()->name(),"multiplicity")==0 && (strcmp(tmp->next_sibling()->value(),"[1]")==0 || strcmp(tmp->value(),"[0..1]")==0 )) { oto[io][0] = pNode3->value(); oto[io][1] = tmp->value(); io++; } } } } if(strcmp(pNode3->name(),"multiplicity") == 0 && strcmp(pNode3->value(),"")!=0) { muti[m] = pNode3->value(); m++; if(strcmp(pNode1->name(),"class") == 0) { Cmuti[mm] = pNode3->value(); mm++; } } checkMuti(qualification, pNode3->name(), pNode3->value(),ofs); if(strcmp(pNode1->name(),"association")==0 && strcmp(pNode2->name(),"other_class")==0 && strcmp(pNode3->name(),"class_name")==0 && strcmp(pNode3->value(),"") != 0 && qualification ) { quaClass[q] = pNode3->value(); q++; classamount = classamount + q; } } for(xml_node<> *pNode4=pNode3->first_node(); pNode4; pNode4=pNode4->next_sibling()) { if(strcmp(pNode2->name(),"Link") == 0 && strcmp(pNode3->name(),"association_class") == 0 && strcmp(pNode4->name(),"nameOfAssociationClass") == 0 && strcmp(pNode4->value(),"") != 0) { linkClass[l] = pNode4->value(); l++; classamount ++; linked = true; } if(strcmp(pNode2->name(),"Link") == 0 && strcmp(pNode3->name(),"association_class") == 0 && strcmp(pNode4->name(),"qualification") == 0 && strcmp(pNode4->value(),"") != 0) { qualification = true; nonremoveAtt(attCount, pNode4->value(), attributes, ofs); linked = true; } } // loop 4 } // loop3 } // loop 2 multivaluedAtt( Cmuti, ofs, mm); linkedMuti(linked, muti, ofs); if(strcmp(pNode1->name(),"class")==0) { if(IDcount == 0 && IDattCount != 0 ) { IDerror[i] = classname[i]; i++; } classCount++; } } // loop 1 IDchecker(classamount,i, IDerror,genClass,quaClass,linkClass, classCount, oto,io ,ofs); missInhertence(genClasscount,attCount,classCount,genClass, att, ofs); missGen(genAssCount,genAss,ofs); ofs.close(); return EXIT_SUCCESS; }
[ "mn626@uowmail.edu.au" ]
mn626@uowmail.edu.au
0791e4d5efd3f3a5331904bb4fbb88c9041f2422
d2a60fb991ff75d39d1f78e7438a92d4456e6c35
/Toolbar.h
2c3f82dbd59aa1a53dd02d149e06d1a5a2fcc944
[]
no_license
Commandoss/PaintPro
d021a50579d3441122296fbb1f779c47ec9aa9d2
4de4ad18fecf2c106f93e783d8a2a7ccf83838fc
refs/heads/main
2023-06-17T16:27:40.230028
2021-07-16T14:42:53
2021-07-16T14:42:53
379,709,025
0
0
null
null
null
null
UTF-8
C++
false
false
478
h
#pragma once #include "cWindow.h" class cToolbar: public cWindow { public: cToolbar(); cToolbar(const HWND hWndParraent, const int Width, const int Heigth, const std::wstring className, const int x, const int y); ~cToolbar(); bool create(const HWND hWndParraent, const int Width, const int Heigth, const std::wstring className, const int x, const int y) override; private: LRESULT CALLBACK window_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) override; };
[ "54144096+Commandoss@users.noreply.github.com" ]
54144096+Commandoss@users.noreply.github.com
1d773233686e4e7da61da290ee7d3e098de33c81
17d766a296cc6c72499bba01b82d58f7df747b64
/Check_leaf_levels.cpp
136b218a80f84c387bcdd3331748b3ad146f16e4
[]
no_license
Kullsno2/C-Cpp-Programs
1dd7a57cf7e4c70831c5b36566605dc35abdeb67
2b81ddc67f22ada291e85bfc377e59e6833e48fb
refs/heads/master
2021-01-22T21:45:41.214882
2015-11-15T11:15:46
2015-11-15T11:15:46
85,473,174
0
1
null
2017-03-19T12:12:00
2017-03-19T12:11:59
null
UTF-8
C++
false
false
893
cpp
#include<iostream> using namespace std ; struct node{ int data : 4; struct node * left ; struct node * right ; }; struct node * newnode(int data){ struct node * p = new node ; p->data = data ; p->left = p->right = NULL ; return p; } bool check_leaf_levels(struct node * root,int &leaf,int level){ if(root== NULL) return true ; if(root->left==NULL && root->right==NULL ){ if(leaf==-1){ leaf = level ; return true ; } return level==leaf ? true : false ; } return check_leaf_levels(root->left,leaf,level+1) && check_leaf_levels(root->right,leaf,level+1); } int main(){ struct node * head = newnode(12); head->left = newnode(5); // head->right = newnode(7); head->left->left = newnode(3); head->left->right = newnode(9); head->left->right->left = newnode(2); head->left->left->left = newnode(1); int leaf = -1 ; cout<<check_leaf_levels(head,leaf,0); }
[ "nanduvinodan2@gmail.com" ]
nanduvinodan2@gmail.com
9a9d5613a0cb282c4c777493f40736b3d9da791e
cbd8c7dc723607a02a8b013e9538f4f894a417d3
/이분탐색/10816_bm.cpp
af55557b12ff2b5d9f4f0818f1a5436c22b555ac
[]
no_license
gmladk04/python_challenge
9f7f1d3af3ffd176b3482c5520345f8f6f6a16ae
62b1dc0f86491fe9e3c5aaa7b74be99b3b90c5ac
refs/heads/master
2023-02-09T08:15:08.308471
2020-12-31T10:53:38
2020-12-31T10:53:38
298,964,860
2
0
null
null
null
null
UTF-8
C++
false
false
461
cpp
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector<int> m; int n; cin >> n; for (int i = 0; i < n; i++) { int num; cin >> num; m.push_back(num); } sort(m.begin(), m.end()); cin >> n; for (int i = 0; i < n; i++) { int num; cin >> num; cout << upper_bound(m.begin(),m.end(),num)-lower_bound(m.begin(),m.end(),num) << ' '; } cout << "\n"; }
[ "kbm0652@gmail.com" ]
kbm0652@gmail.com
220599c30f79ad61076bc7aec4e3fc938bd73a30
3a03b7e63e363dd5ea49fc441a913955c764c987
/Arrays/to read and display the -ve numbers in an array.cpp
9e23b9fe5d207b4cc900e0f42b4debc4449fd30d
[]
no_license
Tarunverma504/C-concepts
d8460082a59f48b3add44b3c517b4e3397dc71a1
2b7f39b8a71eeabdb861adf39ca20fd3f923fa40
refs/heads/master
2020-12-04T02:49:33.638450
2020-10-16T11:28:33
2020-10-16T11:28:33
231,577,319
0
2
null
2020-10-16T11:32:22
2020-01-03T11:51:22
C++
UTF-8
C++
false
false
260
cpp
// to read and display the -ve numbers in an array #include<stdio.h> int main() { int a[10],i,n; printf("Enter the number"); scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) { if(a[i]<0) { printf("%d ",a[i]); } } }
[ "vermatarun4305@gmail.com" ]
vermatarun4305@gmail.com
14feef9f7fd350a0218694d2306c8ea67cc05750
ce7e3fdfa41e6a574bd20217a3674230f7697797
/part-30-basic-user-input/main/src/application/vulkan/vulkan-buffer.hpp
1ff6aac5d6f810784b7e92da7d6692de7e310024
[ "MIT" ]
permissive
vuonglequoc/a-simple-triangle
c3ff13f1fa96bd1fbf4430db72363d47aaa74668
5a88b149df6ad607c2b8379ca918366191bebfd1
refs/heads/master
2023-06-16T12:25:23.224584
2023-01-20T21:34:45
2023-01-20T21:34:45
565,172,388
0
0
MIT
2022-11-12T15:09:56
2022-11-12T15:09:55
null
UTF-8
C++
false
false
1,310
hpp
#pragma once #include "../../core/graphics-wrapper.hpp" #include "../../core/internal-ptr.hpp" #include "vulkan-command-pool.hpp" #include "vulkan-device.hpp" #include "vulkan-physical-device.hpp" namespace ast { struct VulkanBuffer { VulkanBuffer(const ast::VulkanPhysicalDevice& physicalDevice, const ast::VulkanDevice& device, const vk::DeviceSize& size, const vk::BufferUsageFlags& bufferFlags, const vk::MemoryPropertyFlags& memoryFlags, const void* dataSource); const vk::Buffer& getBuffer() const; static ast::VulkanBuffer createDeviceLocalBuffer(const ast::VulkanPhysicalDevice& physicalDevice, const ast::VulkanDevice& device, const ast::VulkanCommandPool& commandPool, const vk::DeviceSize& size, const vk::BufferUsageFlags& bufferFlags, const void* dataSource); private: struct Internal; ast::internal_ptr<Internal> internal; }; } // namespace ast
[ "MarcelBraghetto@users.noreply.github.com" ]
MarcelBraghetto@users.noreply.github.com
f24bab6821f5f42ae4feb49139aabb8487188d71
88ae8695987ada722184307301e221e1ba3cc2fa
/chrome/updater/util/util.cc
35d42b031b2e614cda9817b113846941612f329c
[ "BSD-3-Clause" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
12,750
cc
// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/updater/util/util.h" #include <cctype> #include <string> #include <vector> #if BUILDFLAG(IS_WIN) #include <windows.h> #endif // BUILDFLAG(IS_WIN) #include "base/base_paths.h" #include "base/check_op.h" #include "base/command_line.h" #include "base/files/file.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/logging.h" #include "base/path_service.h" #include "base/ranges/algorithm.h" #include "base/strings/escape.h" #include "base/strings/strcat.h" #include "base/strings/string_util.h" #include "base/strings/utf_string_conversions.h" #include "base/system/sys_info.h" #include "base/task/thread_pool/thread_pool_instance.h" #include "base/version.h" #include "build/build_config.h" #include "chrome/updater/constants.h" #include "chrome/updater/tag.h" #include "chrome/updater/updater_branding.h" #include "chrome/updater/updater_scope.h" #include "chrome/updater/updater_version.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #if BUILDFLAG(IS_LINUX) #include "chrome/updater/util/linux_util.h" #elif BUILDFLAG(IS_MAC) #import "chrome/updater/util/mac_util.h" #endif #if BUILDFLAG(IS_POSIX) #include <pwd.h> #include <sys/stat.h> #include <unistd.h> #endif namespace updater { namespace { constexpr int64_t kLogRotateAtSize = 1024 * 1024 * 5; // 5 MiB. const char kHexString[] = "0123456789ABCDEF"; inline char IntToHex(int i) { CHECK_GE(i, 0) << i << " not a hex value"; CHECK_LE(i, 15) << i << " not a hex value"; return kHexString[i]; } // A fast bit-vector map for ascii characters. // // Internally stores 256 bits in an array of 8 ints. // Does quick bit-flicking to lookup needed characters. struct Charmap { bool Contains(unsigned char c) const { return ((map[c >> 5] & (1 << (c & 31))) != 0); } uint32_t map[8] = {}; }; // Everything except alphanumerics and !'()*-._~ // See RFC 2396 for the list of reserved characters. constexpr Charmap kQueryCharmap = {{0xffffffffL, 0xfc00987dL, 0x78000001L, 0xb8000001L, 0xffffffffL, 0xffffffffL, 0xffffffffL, 0xffffffffL}}; // Given text to escape and a Charmap defining which values to escape, // return an escaped string. If use_plus is true, spaces are converted // to +, otherwise, if spaces are in the charmap, they are converted to // %20. And if keep_escaped is true, %XX will be kept as it is, otherwise, if // '%' is in the charmap, it is converted to %25. std::string Escape(base::StringPiece text, const Charmap& charmap, bool use_plus, bool keep_escaped = false) { std::string escaped; escaped.reserve(text.length() * 3); for (unsigned int i = 0; i < text.length(); ++i) { unsigned char c = static_cast<unsigned char>(text[i]); if (use_plus && ' ' == c) { escaped.push_back('+'); } else if (keep_escaped && '%' == c && i + 2 < text.length() && base::IsHexDigit(text[i + 1]) && base::IsHexDigit(text[i + 2])) { escaped.push_back('%'); } else if (charmap.Contains(c)) { escaped.push_back('%'); escaped.push_back(IntToHex(c >> 4)); escaped.push_back(IntToHex(c & 0xf)); } else { escaped.push_back(c); } } return escaped; } std::string EscapeQueryParamValue(base::StringPiece text, bool use_plus) { return Escape(text, kQueryCharmap, use_plus); } } // namespace absl::optional<base::FilePath> GetVersionedInstallDirectory( UpdaterScope scope, const base::Version& version) { const absl::optional<base::FilePath> path = GetInstallDirectory(scope); if (!path) return absl::nullopt; return path->AppendASCII(version.GetString()); } absl::optional<base::FilePath> GetVersionedInstallDirectory( UpdaterScope scope) { return GetVersionedInstallDirectory(scope, base::Version(kUpdaterVersion)); } absl::optional<base::FilePath> GetUpdaterExecutablePath(UpdaterScope scope) { absl::optional<base::FilePath> path = GetVersionedInstallDirectory(scope); if (!path) { return absl::nullopt; } return path->Append(GetExecutableRelativePath()); } absl::optional<base::FilePath> GetCrashDatabasePath(UpdaterScope scope) { const absl::optional<base::FilePath> path( GetVersionedInstallDirectory(scope)); return path ? absl::optional<base::FilePath>(path->AppendASCII("Crashpad")) : absl::nullopt; } absl::optional<base::FilePath> EnsureCrashDatabasePath(UpdaterScope scope) { const absl::optional<base::FilePath> database_path( GetCrashDatabasePath(scope)); return database_path && base::CreateDirectory(*database_path) ? database_path : absl::nullopt; } TagParsingResult::TagParsingResult() = default; TagParsingResult::TagParsingResult(absl::optional<tagging::TagArgs> tag_args, tagging::ErrorCode error) : tag_args(tag_args), error(error) {} TagParsingResult::~TagParsingResult() = default; TagParsingResult::TagParsingResult(const TagParsingResult&) = default; TagParsingResult& TagParsingResult::operator=(const TagParsingResult&) = default; TagParsingResult GetTagArgsForCommandLine( const base::CommandLine& command_line) { std::string tag = command_line.HasSwitch(kTagSwitch) ? command_line.GetSwitchValueASCII(kTagSwitch) : command_line.GetSwitchValueASCII(kHandoffSwitch); if (tag.empty()) return {}; tagging::TagArgs tag_args; const tagging::ErrorCode error = tagging::Parse( tag, command_line.GetSwitchValueASCII(kAppArgsSwitch), &tag_args); VLOG_IF(1, error != tagging::ErrorCode::kSuccess) << "Tag parsing returned " << error << "."; return {tag_args, error}; } TagParsingResult GetTagArgs() { return GetTagArgsForCommandLine(*base::CommandLine::ForCurrentProcess()); } absl::optional<tagging::AppArgs> GetAppArgsForCommandLine( const base::CommandLine& command_line, const std::string& app_id) { const absl::optional<tagging::TagArgs> tag_args = GetTagArgsForCommandLine(command_line).tag_args; if (!tag_args || tag_args->apps.empty()) return absl::nullopt; const std::vector<tagging::AppArgs>& apps_args = tag_args->apps; std::vector<tagging::AppArgs>::const_iterator it = base::ranges::find_if( apps_args, [&app_id](const tagging::AppArgs& app_args) { return base::EqualsCaseInsensitiveASCII(app_args.app_id, app_id); }); return it != std::end(apps_args) ? absl::optional<tagging::AppArgs>(*it) : absl::nullopt; } absl::optional<tagging::AppArgs> GetAppArgs(const std::string& app_id) { return GetAppArgsForCommandLine(*base::CommandLine::ForCurrentProcess(), app_id); } std::string GetDecodedInstallDataFromAppArgsForCommandLine( const base::CommandLine& command_line, const std::string& app_id) { const absl::optional<tagging::AppArgs> app_args = GetAppArgsForCommandLine(command_line, app_id); if (!app_args) return std::string(); std::string decoded_installer_data; const bool result = base::UnescapeBinaryURLComponentSafe( app_args->encoded_installer_data, /*fail_on_path_separators=*/false, &decoded_installer_data); VLOG_IF(1, !result) << "Failed to decode encoded installer data: [" << app_args->encoded_installer_data << "]"; // `decoded_installer_data` is set to empty if // `UnescapeBinaryURLComponentSafe` fails. return decoded_installer_data; } std::string GetDecodedInstallDataFromAppArgs(const std::string& app_id) { return GetDecodedInstallDataFromAppArgsForCommandLine( *base::CommandLine::ForCurrentProcess(), app_id); } std::string GetInstallDataIndexFromAppArgsForCommandLine( const base::CommandLine& command_line, const std::string& app_id) { const absl::optional<tagging::AppArgs> app_args = GetAppArgsForCommandLine(command_line, app_id); return app_args ? app_args->install_data_index : std::string(); } std::string GetInstallDataIndexFromAppArgs(const std::string& app_id) { return GetInstallDataIndexFromAppArgsForCommandLine( *base::CommandLine::ForCurrentProcess(), app_id); } // The log file is created in DIR_LOCAL_APP_DATA or DIR_ROAMING_APP_DATA. absl::optional<base::FilePath> GetLogFilePath(UpdaterScope scope) { const absl::optional<base::FilePath> log_dir = GetInstallDirectory(scope); if (log_dir) { return log_dir->Append(FILE_PATH_LITERAL("updater.log")); } return absl::nullopt; } void InitLogging(UpdaterScope updater_scope) { absl::optional<base::FilePath> log_file = GetLogFilePath(updater_scope); if (!log_file) { LOG(ERROR) << "Error getting base dir."; return; } base::CreateDirectory(log_file->DirName()); // Rotate log if needed. int64_t size = 0; if (base::GetFileSize(*log_file, &size) && size >= kLogRotateAtSize) { base::ReplaceFile( *log_file, log_file->AddExtension(FILE_PATH_LITERAL(".old")), nullptr); } logging::LoggingSettings settings; settings.log_file_path = log_file->value().c_str(); settings.logging_dest = logging::LOG_TO_ALL; logging::InitLogging(settings); logging::SetLogItems(/*enable_process_id=*/true, /*enable_thread_id=*/true, /*enable_timestamp=*/true, /*enable_tickcount=*/false); VLOG(1) << "Log initialized for " << []() { base::FilePath file_exe; return base::PathService::Get(base::FILE_EXE, &file_exe) ? file_exe : base::FilePath(); }() << " -> " << settings.log_file_path; } // This function and the helper functions are copied from net/base/url_util.cc // to avoid the dependency on //net. GURL AppendQueryParameter(const GURL& url, const std::string& name, const std::string& value) { std::string query(url.query()); if (!query.empty()) query += "&"; query += (EscapeQueryParamValue(name, true) + "=" + EscapeQueryParamValue(value, true)); GURL::Replacements replacements; replacements.SetQueryStr(query); return url.ReplaceComponents(replacements); } #if BUILDFLAG(IS_WIN) std::wstring GetTaskNamePrefix(UpdaterScope scope) { std::wstring task_name = GetTaskDisplayName(scope); task_name.erase(base::ranges::remove_if(task_name, isspace), task_name.end()); return task_name; } std::wstring GetTaskDisplayName(UpdaterScope scope) { return base::StrCat({base::ASCIIToWide(PRODUCT_FULLNAME_STRING), L" Task ", IsSystemInstall(scope) ? L"System " : L"User ", kUpdaterVersionUtf16}); } base::CommandLine GetCommandLineLegacyCompatible() { absl::optional<base::CommandLine> cmd_line = CommandLineForLegacyFormat(::GetCommandLine()); return cmd_line ? *cmd_line : *base::CommandLine::ForCurrentProcess(); } #else // BUILDFLAG(IS_WIN) base::CommandLine GetCommandLineLegacyCompatible() { return *base::CommandLine::ForCurrentProcess(); } #endif // BUILDFLAG(IS_WIN) absl::optional<base::FilePath> WriteInstallerDataToTempFile( const base::FilePath& directory, const std::string& installer_data) { VLOG(2) << __func__ << ": " << directory << ": " << installer_data; if (!base::DirectoryExists(directory)) return absl::nullopt; if (installer_data.empty()) return absl::nullopt; base::FilePath path; base::File file = base::CreateAndOpenTemporaryFileInDir(directory, &path); if (!file.IsValid()) return absl::nullopt; const std::string installer_data_utf8_bom = base::StrCat({kUTF8BOM, installer_data}); if (file.Write(0, installer_data_utf8_bom.c_str(), installer_data_utf8_bom.length()) == -1) { VLOG(2) << __func__ << " file.Write failed"; return absl::nullopt; } return path; } void InitializeThreadPool(const char* name) { base::ThreadPoolInstance::Create(name); // Reuses the logic in base::ThreadPoolInstance::StartWithDefaultParams. const size_t max_num_foreground_threads = static_cast<size_t>(std::max(3, base::SysInfo::NumberOfProcessors() - 1)); base::ThreadPoolInstance::InitParams init_params(max_num_foreground_threads); #if BUILDFLAG(IS_WIN) init_params.common_thread_pool_environment = base::ThreadPoolInstance:: InitParams::CommonThreadPoolEnvironment::COM_MTA; #endif base::ThreadPoolInstance::Get()->Start(init_params); } } // namespace updater
[ "jengelh@inai.de" ]
jengelh@inai.de
cc096b3b0729947879c5c9ff9c5ec08846acf583
6180c9e8278145285dbc2bf880a32cb20ca5a5a0
/scenargie_simulator/2.2/source/dot11/dot11_mac_sta.h
994df17ec2cb186e46b1216e214558152a0ed31e
[]
no_license
superzaxi/DCC
0c529002e9f84a598247203a015f0f4ee0d61c22
cd3e5755410a1266d705d74c0b037cc1609000cf
refs/heads/main
2023-07-15T05:15:31.466339
2021-08-10T11:23:42
2021-08-10T11:23:42
384,296,263
0
0
null
null
null
null
UTF-8
C++
false
false
32,368
h
// Copyright (c) 2007-2017 by Space-Time Engineering, LLC ("STE"). // All Rights Reserved. // // This source code is a part of Scenargie Software ("Software") and is // subject to STE Software License Agreement. The information contained // herein is considered a trade secret of STE, and may not be used as // the basis for any other software, hardware, product or service. // // Refer to license.txt for more specific directives. #ifndef DOT11_MAC_STA_H #define DOT11_MAC_STA_H #include "scensim_engine.h" #include "scensim_netsim.h" #include "dot11_common.h" #include "dot11_headers.h" #include <queue> #include <map> #include <string> #include <iomanip> namespace Dot11 { using std::shared_ptr; using std::deque; using std::map; using std::cerr; using std::endl; using std::cout; using std::hex; using std::string; using ScenSim::SimulationEngineInterface; using ScenSim::SimulationEvent; using ScenSim::EventRescheduleTicket; using ScenSim::SimTime; using ScenSim::MILLI_SECOND; using ScenSim::INFINITE_TIME; using ScenSim::ZERO_TIME; using ScenSim::ParameterDatabaseReader; using ScenSim::NodeId; using ScenSim::InterfaceOrInstanceId; using ScenSim::RandomNumberGenerator; using ScenSim::RandomNumberGeneratorSeed; using ScenSim::PacketPriority; using ScenSim::EtherTypeField; using ScenSim::HashInputsToMakeSeed; using ScenSim::ConvertTimeToDoubleSecs; using ScenSim::ConvertToDb; using ScenSim::ConvertToNonDb; class Dot11Mac; //-------------------------------------------------------------------------------------------------- class AbstractChannelScanningController { public: virtual void ClearCurrentChannelAndAccessPoint() = 0; virtual void SetCurrentChannelAndAccessPoint( const vector<unsigned int>& bondedChannelList, const MacAddress newAccessPoint) = 0; virtual void ReceiveBeaconInfo( const unsigned int channelId, const BeaconFrame& aBeaconFrame, const double& frameRssiDbm) = 0; virtual void ReceiveProbeResponseInfo( const unsigned int channelId, const ProbeResponseFrame& probeResponseFrame, const double& frameRssiDbm) = 0; virtual void CalculateLinkStatus() = 0; virtual SimTime GetNextLinkCheckTime() const = 0; virtual SimTime GetNextScanStartTime() const = 0; virtual void StartScanSequence() = 0; virtual void GetChannelAndDurationToScan( bool& scanSequenceIsDone, unsigned int& channelId, SimTime& duration) = 0; virtual bool NoInRangeAccessPoints() const = 0; virtual bool ShouldSwitchAccessPoints() const = 0; virtual void GetAccessPointToSwitchTo( vector<unsigned int>& bondedChannelList, MacAddress& newAccessPoint) = 0; };//AbstractChannelScanningController// //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- class Dot11StaManagementController { public: Dot11StaManagementController( const shared_ptr<Dot11Mac>& initMacLayerPtr, const shared_ptr<SimulationEngineInterface>& simulationEngineInterfacePtr, const ParameterDatabaseReader& theParameterDatabaseReader, const NodeId& theNodeId, const InterfaceOrInstanceId& theInterfaceId, const RandomNumberGeneratorSeed& interfaceSeed); void SetChannelScanningController( const shared_ptr<AbstractChannelScanningController>& scanningControllerPtr); void ProcessManagementFrame(const Packet& managementFrame); void GetCurrentAccessPointAddress( bool& hasAnAccessPoint, MacAddress& currentAccessPointAddress) const; void SwitchToAccessPoint(const MacAddress& accessPointAddress); void ReceiveOutgoingFrameDeliveryResults( const Packet& frame, const bool wasAcked); private: static const SimTime scanningStartDelay = 100 * MILLI_SECOND; // "Legacy" Delete enum StaManagementStateType { NotAssociated, ChannelScanning, WaitingForAuthentication, WaitingForAssociationResponse, WaitingForReassociationResponse, Associated, StartingUpBackgroundChannelScanning, BackgroundChannelScanning, EndingBackgroundChannelScanning, }; shared_ptr<SimulationEngineInterface> simEngineInterfacePtr; NodeId theNodeId; InterfaceOrInstanceId theInterfaceId; string ssidString; shared_ptr<Dot11Mac> macLayerPtr; shared_ptr<AbstractChannelScanningController> scanningControllerPtr; unsigned int powerSavingListenIntervalBeacons; AssociationId theAssociationId; //static const int SEED_HASH = 58579017; //RandomNumberGenerator aRandomNumberGenerator; StaManagementStateType theStaManagementState; MacAddress currentApAddress; MacAddress lastApAddress; unsigned int lastChannelId; MacAddress lastAccessPointAddress; SimTime authenticationTimeoutInterval; SimTime associateFailureTimeoutInterval; bool isAuthenticated; //------------------------------------------------------ class InitializationEvent : public SimulationEvent { public: InitializationEvent(Dot11StaManagementController* initStaControllerPtr) : staControllerPtr(initStaControllerPtr) { } void ExecuteEvent() { staControllerPtr->StartChannelScanning(); } private: Dot11StaManagementController* staControllerPtr; };//InitializationEvent// EventRescheduleTicket initializationEventTicket; //------------------------------------------------------ class ChannelScanTimeoutEvent : public SimulationEvent { public: ChannelScanTimeoutEvent(Dot11StaManagementController* initStaControllerPtr) : staControllerPtr(initStaControllerPtr) { } void ExecuteEvent() { staControllerPtr->ChannelScanTimedOut(); } private: Dot11StaManagementController* staControllerPtr; };//ChannelScanTimeoutEvent// shared_ptr<ChannelScanTimeoutEvent> scanTimeoutEventPtr; EventRescheduleTicket scanTimeoutEventTicket; //------------------------------------------------------ class BackgroundScanStartEvent : public SimulationEvent { public: BackgroundScanStartEvent(Dot11StaManagementController* initStaControllerPtr) : staControllerPtr(initStaControllerPtr) { } void ExecuteEvent() { staControllerPtr->InitiateBackgroundChannelScanning(); } private: Dot11StaManagementController* staControllerPtr; };//ChannelScanTimeoutEvent// shared_ptr<ChannelScanTimeoutEvent> startBackgroundScanTimeoutEventPtr; EventRescheduleTicket startBackgroundScanTimeoutEventTicket; SimTime backgroundScanningEventTime; //------------------------------------------------------ class AuthenticationTimeoutEvent : public SimulationEvent { public: AuthenticationTimeoutEvent(Dot11StaManagementController* initStaControllerPtr) : staControllerPtr(initStaControllerPtr) { } void ExecuteEvent() { staControllerPtr->AuthenticationTimeout(); } private: Dot11StaManagementController* staControllerPtr; };//AuthenticationTimeoutEvent// shared_ptr<AuthenticationTimeoutEvent> authenticationTimeoutEventPtr; EventRescheduleTicket authenticationTimeoutEventTicket; //------------------------------------------------------ class AssociateFailureEvent : public SimulationEvent { public: AssociateFailureEvent(Dot11StaManagementController* initStaControllerPtr) : staControllerPtr(initStaControllerPtr) { } void ExecuteEvent() { staControllerPtr->ProcessAssociateFailure(); } private: Dot11StaManagementController* staControllerPtr; };//AssociateFailureEvent// shared_ptr<AssociateFailureEvent> associateFailureEventPtr; EventRescheduleTicket associateFailureEventTicket; //------------------------------------------------------ class CheckLinkStatusEvent : public SimulationEvent { public: CheckLinkStatusEvent(Dot11StaManagementController* initStaControllerPtr) : staControllerPtr(initStaControllerPtr) { } void ExecuteEvent() { staControllerPtr->CheckLinkStatus(); } private: Dot11StaManagementController* staControllerPtr; };//CheckLinkStatusEvent// shared_ptr<CheckLinkStatusEvent> linkStatusCheckEventPtr; EventRescheduleTicket linkStatusCheckEventTicket; void StartChannelScanning(); void ChannelScanTimedOut(); void StartAuthentication(const MacAddress& accessPointAddress); void AuthenticationTimeout(); void ProcessBeaconFrame(const Packet& managementFrame); void AssociateWithAccessPoint( const unsigned int channelId, const MacAddress& accessPointAddress); void ProcessAssociateFailure(); void CheckLinkStatus(); void UpdateBackgroundScanEventStartTime(); void InitiateBackgroundChannelScanning(); void StartBackgroundChannelScanning(); void FinishChannelScanning(); void PerformBackgroundChannelScanning(); void FinishBackgroundChannelScanning(); void Disassociate(); void SwitchToAnotherAccessPoint( const vector<unsigned int>& newBondedChannelList, const MacAddress& newAccessPoint); };//Dot11StaManagementController// //-------------------------------------------------------------------------------------------------- inline void Dot11StaManagementController::SetChannelScanningController( const shared_ptr<AbstractChannelScanningController>& newScanningControllerPtr) { (*this).scanningControllerPtr = newScanningControllerPtr; }//SetChannelScanningController// inline void Dot11StaManagementController::SwitchToAccessPoint(const MacAddress& accessPointAddress) { assert(theStaManagementState == NotAssociated); if (!initializationEventTicket.IsNull()) { simEngineInterfacePtr->CancelEvent(initializationEventTicket); }//if// (*this).StartAuthentication(accessPointAddress); } inline void Dot11StaManagementController::GetCurrentAccessPointAddress( bool& hasAnAccessPoint, MacAddress& currentAccessPointAddress) const { if (theStaManagementState != Associated) { hasAnAccessPoint = false; return; } hasAnAccessPoint = true; currentAccessPointAddress = (*this).currentApAddress; }//GetCurrentAccessPointAddress// inline void Dot11StaManagementController::AuthenticationTimeout() { assert(theStaManagementState == WaitingForAuthentication); assert(!isAuthenticated); authenticationTimeoutEventTicket.Clear(); theStaManagementState = NotAssociated; currentApAddress = MacAddress::invalidMacAddress; (*this).StartChannelScanning(); }//AuthenticationTimeout// inline void Dot11StaManagementController::ProcessAssociateFailure() { assert((theStaManagementState == WaitingForReassociationResponse) || (theStaManagementState == WaitingForAssociationResponse)); associateFailureEventTicket.Clear(); theStaManagementState = NotAssociated; isAuthenticated = false; currentApAddress = MacAddress::invalidMacAddress; (*this).StartChannelScanning(); }//ProcessAssociateFailure// inline void Dot11StaManagementController::UpdateBackgroundScanEventStartTime() { assert(theStaManagementState != BackgroundChannelScanning); if (scanningControllerPtr->GetNextScanStartTime() != backgroundScanningEventTime) { if (scanningControllerPtr->GetNextScanStartTime() != INFINITE_TIME) { if (startBackgroundScanTimeoutEventTicket.IsNull()) { simEngineInterfacePtr->ScheduleEvent( startBackgroundScanTimeoutEventPtr, scanningControllerPtr->GetNextScanStartTime(), (*this).startBackgroundScanTimeoutEventTicket); } else { simEngineInterfacePtr->RescheduleEvent( startBackgroundScanTimeoutEventTicket, scanningControllerPtr->GetNextScanStartTime()); }//if// } else { assert(backgroundScanningEventTime != INFINITE_TIME); simEngineInterfacePtr->CancelEvent(startBackgroundScanTimeoutEventTicket); }//if// backgroundScanningEventTime = scanningControllerPtr->GetNextScanStartTime(); }//if// }//UpdateBackgroundScanEventStartTime// inline void Dot11StaManagementController::CheckLinkStatus() { assert(theStaManagementState == Associated); linkStatusCheckEventTicket.Clear(); scanningControllerPtr->CalculateLinkStatus(); if (scanningControllerPtr->NoInRangeAccessPoints()) { (*this).Disassociate(); return; }//if// if (scanningControllerPtr->ShouldSwitchAccessPoints()) { vector<unsigned int> newBondedChannelList; MacAddress newAccessPointAddress; scanningControllerPtr->GetAccessPointToSwitchTo(newBondedChannelList, newAccessPointAddress); (*this).SwitchToAnotherAccessPoint(newBondedChannelList, newAccessPointAddress); return; }//if// (*this).UpdateBackgroundScanEventStartTime(); simEngineInterfacePtr->ScheduleEvent( linkStatusCheckEventPtr, scanningControllerPtr->GetNextLinkCheckTime(), linkStatusCheckEventTicket); }//CheckLinkStatus// inline void Dot11StaManagementController::ReceiveOutgoingFrameDeliveryResults( const Packet& aFrame, const bool wasAcked) { const CommonFrameHeader& header = aFrame.GetAndReinterpretPayloadData<CommonFrameHeader>(); if (header.theFrameControlField.frameTypeAndSubtype == NULL_FRAME_TYPE_CODE) { if (theStaManagementState == StartingUpBackgroundChannelScanning) { // Perform Background Scanning even if power update did not get acked! // Justification: Can't even send a small packet to AP with retries, better // start looking for new AP immediately (could add "try again logic"). (*this).PerformBackgroundChannelScanning(); } else if (theStaManagementState == EndingBackgroundChannelScanning) { if (wasAcked) { (*this).theStaManagementState = Associated; assert(linkStatusCheckEventTicket.IsNull()); simEngineInterfacePtr->ScheduleEvent( linkStatusCheckEventPtr, scanningControllerPtr->GetNextLinkCheckTime(), (*this).linkStatusCheckEventTicket); } else { // Could not tell the AP, that I am awake, just try some more scanning, then try again. (*this).PerformBackgroundChannelScanning(); }//if// } else { assert(false); abort(); }//if// }//if// }//ReceiveOutgoingFrameDeliveryResults// class ChannelScanningController : public AbstractChannelScanningController { public: ChannelScanningController( const shared_ptr<SimulationEngineInterface>& simulationEngineInterfacePtr, const ParameterDatabaseReader& theParameterDatabaseReader, const NodeId& theNodeId, const InterfaceOrInstanceId& theInterfaceId, const unsigned int baseChannelNumber, const unsigned int numberOfChannels, const RandomNumberGeneratorSeed& interfaceSeed); virtual void ClearCurrentChannelAndAccessPoint() override { (*this).SetCurrentChannelAndAccessPoint( vector<unsigned int>(), MacAddress::invalidMacAddress); } virtual void SetCurrentChannelAndAccessPoint( const vector<unsigned int>& bondedChannelList, const MacAddress newAccessPoint) override; virtual void CalculateLinkStatus() override; virtual SimTime GetNextLinkCheckTime() const override { return (nextLinkCheckTime); } virtual SimTime GetNextScanStartTime() const override { return (nextScanStartTime); } virtual void StartScanSequence() override; virtual void GetChannelAndDurationToScan( bool& scanSequenceIsDone, unsigned int& channelId, SimTime& duration) override; virtual void ReceiveBeaconInfo( const unsigned int channelId, const BeaconFrame& aBeaconFrame, const double& frameRssiDbm) override; virtual void ReceiveProbeResponseInfo( const unsigned int channelId, const ProbeResponseFrame& probeResponseFrame, const double& frameRssiDbm) override { (*this).ReceiveBeaconInfo(channelId, probeResponseFrame, frameRssiDbm); } virtual bool NoInRangeAccessPoints() const override { return ((newAccessPointMacAddress == MacAddress::invalidMacAddress) && ((shouldDisassociateFromCurrentAp) || (currentAccessPointMacAddress == MacAddress::invalidMacAddress))); } virtual bool ShouldSwitchAccessPoints() const override { return ((newAccessPointMacAddress != MacAddress::invalidMacAddress) && (newAccessPointMacAddress != currentAccessPointMacAddress)); } virtual void GetAccessPointToSwitchTo( vector<unsigned int>& newBondedChannelList, MacAddress& newAccessPoint) override; private: shared_ptr<SimulationEngineInterface> simEngineInterfacePtr; double associationThresholdRssiDbm; double disassociationThresholdRssiDbm; double movingAverageCoefficient; double rssiImprovementThresholdDbm; SimTime nextScanStartTime; SimTime nextLinkCheckTime; unsigned int baseChannelNumber; unsigned int numberOfChannels; SimTime scanTimeoutInterval; SimTime linkStatusCheckInterval; unsigned int nextScanChannelId; vector<unsigned int> currentAccessPointBondedChannelList; MacAddress currentAccessPointMacAddress; vector<unsigned int> newBondedChannelList; MacAddress newAccessPointMacAddress; bool shouldDisassociateFromCurrentAp; static const int SEED_HASH = 5857901; RandomNumberGenerator aRandomNumberGenerator; struct ReceivedBeaconInformationEntry { static const unsigned int invalidPartitionIndex = UINT_MAX; vector<unsigned int> bondedChannelList; MacAddress accessPointAddress; string ssid; double lastRssiDbm; double averageRssiDbm; SimTime lastReceivedTime; ReceivedBeaconInformationEntry( const vector<unsigned int> initBondedChannelList, const MacAddress& initAccessPointAddress, const SsidField& ssidField, const double& initRssiDbm, const SimTime& initReceivedTime) : bondedChannelList(initBondedChannelList), accessPointAddress(initAccessPointAddress), ssid(ssidField.ssid, ssidField.length), lastRssiDbm(initRssiDbm), averageRssiDbm(initRssiDbm), lastReceivedTime(initReceivedTime) {} };//ReceivedBeaconInformationEntry// map<MacAddress, shared_ptr<ReceivedBeaconInformationEntry> > receivedBeaconInformation; //----------------------------------------------------- bool IsAssociated() const { return (currentAccessPointMacAddress != MacAddress::invalidMacAddress); } double GetCurrentAccessPointRssiDbm() const; };//ChannelScanningController// inline ChannelScanningController::ChannelScanningController( const shared_ptr<SimulationEngineInterface>& simulationEngineInterfacePtr, const ParameterDatabaseReader& theParameterDatabaseReader, const NodeId& theNodeId, const InterfaceOrInstanceId& theInterfaceId, const unsigned int initBaseChannelNumber, const unsigned int initNumberOfChannels, const RandomNumberGeneratorSeed& interfaceSeed) : simEngineInterfacePtr(simulationEngineInterfacePtr), movingAverageCoefficient(0.5), currentAccessPointMacAddress(MacAddress::invalidMacAddress), scanTimeoutInterval(500 * MILLI_SECOND), baseChannelNumber(initBaseChannelNumber), numberOfChannels(initNumberOfChannels), nextLinkCheckTime(INFINITE_TIME), nextScanChannelId(initBaseChannelNumber), newAccessPointMacAddress(MacAddress::invalidMacAddress), shouldDisassociateFromCurrentAp(false), rssiImprovementThresholdDbm(1.0), aRandomNumberGenerator(HashInputsToMakeSeed(interfaceSeed, SEED_HASH)) { if (theParameterDatabaseReader.ParameterExists( (parameterNamePrefix + "channel-scan-interval"), theNodeId, theInterfaceId)) { scanTimeoutInterval = theParameterDatabaseReader.ReadTime( (parameterNamePrefix + "channel-scan-interval"), theNodeId, theInterfaceId); if (scanTimeoutInterval < ZERO_TIME) { cerr << "Invalid scan timeout interval: " << ConvertTimeToDoubleSecs(scanTimeoutInterval) << endl; exit(1); } }//if// SimTime startTimeMaxJitter = scanTimeoutInterval; if (theParameterDatabaseReader.ParameterExists( (parameterNamePrefix + "channel-scan-start-time-max-jitter"), theNodeId, theInterfaceId)) { startTimeMaxJitter = theParameterDatabaseReader.ReadTime( (parameterNamePrefix + "channel-scan-start-time-max-jitter"), theNodeId, theInterfaceId); }//if// const SimTime scanningStartJitter = static_cast<SimTime>(startTimeMaxJitter * aRandomNumberGenerator.GenerateRandomDouble()); nextScanStartTime = simEngineInterfacePtr->CurrentTime() + scanningStartJitter; linkStatusCheckInterval = (scanTimeoutInterval * numberOfChannels); if (theParameterDatabaseReader.ParameterExists( (parameterNamePrefix + "link-status-check-interval"), theNodeId, theInterfaceId)) { linkStatusCheckInterval = theParameterDatabaseReader.ReadTime( (parameterNamePrefix + "link-status-check-interval"), theNodeId, theInterfaceId); }//if// associationThresholdRssiDbm = theParameterDatabaseReader.ReadDouble( (parameterNamePrefix + "preamble-detection-power-threshold-dbm"), theNodeId, theInterfaceId); if (theParameterDatabaseReader.ParameterExists( (parameterNamePrefix + "association-threshold-rssi-dbm"), theNodeId, theInterfaceId)) { associationThresholdRssiDbm = theParameterDatabaseReader.ReadDouble( (parameterNamePrefix + "association-threshold-rssi-dbm"), theNodeId, theInterfaceId); }//if// disassociationThresholdRssiDbm = associationThresholdRssiDbm - 3.0; if (theParameterDatabaseReader.ParameterExists( (parameterNamePrefix + "disassociation-threshold-rssi-dbm"), theNodeId, theInterfaceId)) { disassociationThresholdRssiDbm = theParameterDatabaseReader.ReadDouble( (parameterNamePrefix + "disassociation-threshold-rssi-dbm"), theNodeId, theInterfaceId); }//if// if (theParameterDatabaseReader.ParameterExists( (parameterNamePrefix + "beacon-rssi-moving-average-coefficient"), theNodeId, theInterfaceId)) { movingAverageCoefficient = theParameterDatabaseReader.ReadDouble( (parameterNamePrefix + "beacon-rssi-moving-average-coefficient"), theNodeId, theInterfaceId); if ((movingAverageCoefficient < 0.0) || (movingAverageCoefficient > 1.0)) { cerr << "Invalid range: dot11-beacon-rssi-moving-average-coefficient= " << movingAverageCoefficient << endl; exit(1); } }//if// }//ChannelScanningController()// inline void ChannelScanningController::SetCurrentChannelAndAccessPoint( const vector<unsigned int>& bondedChannelList, const MacAddress newAccessPointAddress) { (*this).currentAccessPointBondedChannelList = bondedChannelList; (*this).currentAccessPointMacAddress = newAccessPointAddress; (*this).newAccessPointMacAddress = MacAddress::invalidMacAddress; (*this).shouldDisassociateFromCurrentAp = false; (*this).nextLinkCheckTime = simEngineInterfacePtr->CurrentTime() + linkStatusCheckInterval; }//SetCurrentChannelAndAccessPoint// inline void ChannelScanningController::CalculateLinkStatus() { assert(IsAssociated()); bool neverReceivedABeacon = false; typedef map<MacAddress, shared_ptr<ReceivedBeaconInformationEntry> >::const_iterator BeaconIterType; BeaconIterType beaconIter = receivedBeaconInformation.find(currentAccessPointMacAddress); if (beaconIter == receivedBeaconInformation.end()) { neverReceivedABeacon = true; } else { const SimTime currentTime = simEngineInterfacePtr->CurrentTime(); const SimTime lastReceivedTime = beaconIter->second->lastReceivedTime; if ((lastReceivedTime + linkStatusCheckInterval) < currentTime) { neverReceivedABeacon = true; } }//if// if (neverReceivedABeacon) { (*this).shouldDisassociateFromCurrentAp = true; }//if// (*this).nextLinkCheckTime = simEngineInterfacePtr->CurrentTime() + linkStatusCheckInterval; }//CalculateLinkStatus// inline void ChannelScanningController::StartScanSequence() { (*this).nextScanStartTime = INFINITE_TIME; (*this).nextScanChannelId = baseChannelNumber; if ((IsAssociated()) && (nextScanChannelId == currentAccessPointBondedChannelList.front())) { (*this).nextScanChannelId++; }//if// }//StartScanSequence// inline void ChannelScanningController::ReceiveBeaconInfo( const unsigned int channelId, const BeaconFrame& aBeaconFrame, const double& frameRssiDbm) { const SimTime currentTime = simEngineInterfacePtr->CurrentTime(); map<MacAddress, shared_ptr<ReceivedBeaconInformationEntry> >::const_iterator beaconIter = receivedBeaconInformation.find(aBeaconFrame.managementHeader.transmitterAddress); vector<unsigned int> beaconsBondedChannelList; for(unsigned int i = 0; (i < aBeaconFrame.htOperationFrameElement.GetNumberBondedChannels()); i++) { beaconsBondedChannelList.push_back(aBeaconFrame.htOperationFrameElement.bondedChannelList[i]); }//for// if (beaconIter == receivedBeaconInformation.end()) { // make a new entry shared_ptr<ReceivedBeaconInformationEntry> beaconEntryPtr( new ReceivedBeaconInformationEntry( beaconsBondedChannelList, aBeaconFrame.managementHeader.transmitterAddress, aBeaconFrame.ssidElement, frameRssiDbm, currentTime)); receivedBeaconInformation.insert( make_pair(aBeaconFrame.managementHeader.transmitterAddress, beaconEntryPtr)); // Don't make decisions based on single datapoint. } else { //update existing entry const shared_ptr<ReceivedBeaconInformationEntry> beaconEntryPtr = beaconIter->second; beaconEntryPtr->bondedChannelList = beaconsBondedChannelList; beaconEntryPtr->accessPointAddress = aBeaconFrame.managementHeader.transmitterAddress; beaconEntryPtr->ssid = string(aBeaconFrame.ssidElement.ssid, aBeaconFrame.ssidElement.length); beaconEntryPtr->lastRssiDbm = frameRssiDbm; beaconEntryPtr->lastReceivedTime = currentTime; beaconEntryPtr->averageRssiDbm = ConvertToDb( (movingAverageCoefficient * ConvertToNonDb(frameRssiDbm)) + ((1 - movingAverageCoefficient) * ConvertToNonDb(beaconEntryPtr->averageRssiDbm))); if (aBeaconFrame.managementHeader.transmitterAddress == currentAccessPointMacAddress) { (*this).shouldDisassociateFromCurrentAp = (beaconEntryPtr->averageRssiDbm < disassociationThresholdRssiDbm); }//if// }//if// }//ReceiveBeaconInfo// inline double ChannelScanningController::GetCurrentAccessPointRssiDbm() const { typedef map<MacAddress, shared_ptr<ReceivedBeaconInformationEntry> >::const_iterator IterType; IterType iter = receivedBeaconInformation.find(currentAccessPointMacAddress); if (iter == receivedBeaconInformation.end()) { return (-DBL_MAX); }//if// return ((iter->second)->averageRssiDbm); }//GetCurrentAccessPointRssiDbm// inline void ChannelScanningController::GetChannelAndDurationToScan( bool& scanSequenceIsDone, unsigned int& channelId, SimTime& duration) { scanSequenceIsDone = (nextScanChannelId >= (baseChannelNumber + numberOfChannels)); if (!scanSequenceIsDone) { channelId = nextScanChannelId; duration = scanTimeoutInterval; (*this).nextScanChannelId++; if ((IsAssociated()) && (nextScanChannelId == currentAccessPointBondedChannelList[0])) { (*this).nextScanChannelId++; }//if// } else { // Scanning is done, choose access point (stay with current or go to new one). (*this).newAccessPointMacAddress = MacAddress::invalidMacAddress; (*this).newBondedChannelList.clear(); channelId = baseChannelNumber; duration = ZERO_TIME; // for now, simply attempt to associate with the AP whose RSSI is highest typedef map<MacAddress, shared_ptr<ReceivedBeaconInformationEntry> >::const_iterator IterType; double maxRssiDbm = -DBL_MAX; MacAddress bestAccessPointMacAddress = MacAddress::invalidMacAddress; vector<unsigned int> bestApChannelList; for(IterType apIter = receivedBeaconInformation.begin(); apIter != receivedBeaconInformation.end(); ++ apIter) { const ReceivedBeaconInformationEntry& beaconInfo = *(apIter->second); if (beaconInfo.averageRssiDbm > maxRssiDbm) { maxRssiDbm = beaconInfo.averageRssiDbm; bestAccessPointMacAddress = beaconInfo.accessPointAddress; bestApChannelList = beaconInfo.bondedChannelList; }//if// }//for// if (currentAccessPointMacAddress == MacAddress::invalidMacAddress) { // Not connected, pick AP with best RSSI. if (maxRssiDbm >= associationThresholdRssiDbm) { (*this).newAccessPointMacAddress = bestAccessPointMacAddress; (*this).newBondedChannelList = bestApChannelList; }//if// } else { if (maxRssiDbm < associationThresholdRssiDbm) { (*this).shouldDisassociateFromCurrentAp = true; } else { const double rssiImprovementDbm = (maxRssiDbm - GetCurrentAccessPointRssiDbm()); if (rssiImprovementDbm >= rssiImprovementThresholdDbm) { (*this).newAccessPointMacAddress = bestAccessPointMacAddress; (*this).newBondedChannelList = bestApChannelList; }//if// }//if// }//if// }//if// }//GetChannelAndDurationToScan// inline void ChannelScanningController::GetAccessPointToSwitchTo( vector<unsigned int>& bondedChannelList, MacAddress& accessPointMacAddress) { assert(newAccessPointMacAddress != MacAddress::invalidMacAddress); bondedChannelList = (*this).newBondedChannelList; accessPointMacAddress = (*this).newAccessPointMacAddress; } }//namespace// #endif
[ "zaki@keio.jp" ]
zaki@keio.jp
cb271f65b326bac1476fa9b436cc3249e5b40ca2
bab2e2db125b2e9ce98b7559388b2b146b42197c
/MP5/thread.H
e7df8e0c68c206cd2fa8602db8cf8521ddb68713
[]
no_license
chaizhicup/Basic-Operating-System
ffa55b3e3cfdecbaf288970f9374ae0c2c0d487e
801f9894f696b9a3ae8102850152786a1f5db94c
refs/heads/master
2020-12-03T02:28:50.377942
2017-05-18T03:30:48
2017-05-18T03:30:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,313
h
/* File: thread.H Author: R. Bettati Department of Computer Science Texas A&M University Date : 11/10/25 Description: Thread Management. Defines the Thread Control Block data structure, and functions to create threads and to dispatch the execution of threads. */ #ifndef _thread_H_ // include file only once #define _thread_H_ /*--------------------------------------------------------------------------*/ /* DEFINES */ /*--------------------------------------------------------------------------*/ /* -- (none) -- */ /*--------------------------------------------------------------------------*/ /* INCLUDES */ /*--------------------------------------------------------------------------*/ #include "machine.H" /*--------------------------------------------------------------------------*/ /* DATA STRUCTURES */ /*--------------------------------------------------------------------------*/ /* -- THREAD FUNCTION (CALLED WHEN THREAD STARTS RUNNING) */ typedef void (*Thread_Function)(); class Scheduler; extern Scheduler* SYSTEM_SCHEDULER; /*--------------------------------------------------------------------------*/ /* THREAD CONTROL BLOCK */ /*--------------------------------------------------------------------------*/ class Thread { private: char * esp; /* The current stack pointer for the thread.*/ /* Keep it at offset 0, since the thread dispatcher relies on this location! */ int thread_id; /* thread identifier. Assigned upon creation. */ char * stack; /* pointer to the stack of the thread.*/ unsigned int stack_size;/* size of the stack (in byte) */ int priority; /* Maybe the scheduler wants to use priorities. */ char * cargo; /* pointer to additional data that may need to be stored, typically by schedulers. (for future use) */ static int nextFreePid; /* Used to assign unique id's to threads. */ void push(unsigned long _val); /* Push the given value on the stack of the thread. */ void setup_context(Thread_Function _tfunction); /* Sets up the initial context for the given kernel-only thread. The thread is supposed the call the function _tfunction upon start. */ public: Thread(Thread_Function _tf, char * _stack, unsigned int _stack_size); /* Create a thread that is set up to execute the given thread function. The thread is given a pointer to the stack to use. NOTE: _stack points to the beginning of the stack area, i.e., to the bottom of the stack. */ int ThreadId(); /* Returns the thread id of the thread. */ static void dispatch_to(Thread * _thread); /* This is the low-level dispatch function that invokes the context switch code. This function is used by the scheduler. NOTE: dispatch_to does not return until the scheduler context-switches back to the calling thread. */ static Thread * CurrentThread(); /* Returns the currently running thread. NULL if no thread has started yet. */ friend class Scheduler; }; #endif
[ "spencerrawls@tamu.edu" ]
spencerrawls@tamu.edu
3fb79006ee5b4980c630325b683bdd18458b0873
efefc2cfa5e32c3e09e3d5be8e83c427176ecfec
/advancingFront/Functions.cpp
56f88aa75eac025ff18e0c3386284cc6cc72e1a5
[]
no_license
Arnaud-Patra/Mesh-Generation
3991743099c643f2e44c081c06573eaab8d64bf9
18ec74c65c3f11bc9d8d086ba70ad4c4fa0f3f7b
refs/heads/master
2018-12-12T19:33:29.655312
2018-09-13T12:58:20
2018-09-13T12:58:20
119,638,685
0
0
null
null
null
null
UTF-8
C++
false
false
10,316
cpp
#include <iostream> #include <ctime> #include <cstdlib> #include <string> #include <vector> //for Mesh and Front #include <math.h> //For sqrt(3) #include <fstream> //readfile using namespace std; #include "Functions.hpp" AdvancingFront::AdvancingFront(){} AdvancingFront::~AdvancingFront(){} /* Discret is used at the initialisation to Discretise the bondaries and obstacles Input : a density of mesh (rho),the given points, maybe read it on a .txt. Output : initialisation of Mesh and Front point_given.size() = number of point in initialisation + 1 */ int AdvancingFront::Discret(float rho = 0.1){ //Rho = number of points/volume unit //***Initialisation*** //point initialisation : //*Reading file to construct point_given, a vector of points. string line; ifstream myfile("Points.txt"); float x, y; if (myfile.is_open()){ getline(myfile,line); using namespace boost::algorithm; vector<string> tokens; split(tokens, line, is_any_of(" ")); // here it is x = atof(tokens[0].c_str()); y = atof(tokens[1].c_str()); float * First_Point = new float[2]; float * Point_next = new float[2]; Point_next[0] = x; Point_next[1] = y; First_Point[0] = x; First_Point[1] = y; point_given.push_back(Point_next); int k = 0; while (getline(myfile,line)){ if (line == "****"){ //Seperation for obstacles. point_given.push_back(Point_next); //Goes back to the first point if (getline(myfile,line)){ vector<string> tokens; split(tokens, line, is_any_of(" ")); // here it is x = atof(tokens[0].c_str()); y = atof(tokens[1].c_str()); float * Point_next = new float[2]; Point_next[0] = x; Point_next[1] = y; First_Point[0] = x; First_Point[1] = y; point_given.push_back(Point_next); } }else{ vector<string> tokens; cout <<"line : "<< line <<endl; split(tokens, line, is_any_of(" ")); // here it is x = atof(tokens[0].c_str()); y = atof(tokens[1].c_str()); float * Point_next = new float[2]; cout << "(esle)x, y ="<<x<<" "<<y<<endl; Point_next[0] = x; Point_next[1] = y; point_given.push_back(Point_next); } } point_given.push_back(First_Point); } myfile.close(); for(int i = 0;i < point_given.size();++i){ //DEBUG float * P = point_given[i]; cout<< "P = "<<P[0]<<" "<<P[1]<<endl; } //***Discretisation*** //We take point_given(2*number of initial points) and constitue Front with it : // float d_rho = 1/sqrt(M_PI*rho); //DEBUG: defined in .hpp float * Start_Point = point_given[0]; int start = 0; for(int i = 0;i < point_given.size()-1;++i){ if(( point_given[i] == Start_Point)and (i!=start)){ //Cut for if for obstacles. Start_Point = point_given[i+1]; start = i+1; continue; } float * p0 = new float [2]; float * p1 = new float [2]; float * seg_Front; //This is the segment float x = 0; float y = 0; //We take the segment [p0,p1], then we discretise it. p0 = point_given[i]; p1 = point_given[i+1]; float dist = sqrt(pow(p1[0]-p0[0],2)+pow(p1[1]-p0[1],2)); // distance between p0 and p1 float n = round(dist/d_rho);//We should get the closest int from dist/d_rho and divide the segment into n=round(dist/d_rho) parts. for(int j=1; j < n+1 ; ++j){ seg_Front = new float[4]; if (j == 1){ seg_Front[0] = p0[0]; seg_Front[1] = p0[1]; }else{ seg_Front[0] = x; //We create the new segment with the last point we created and the next one. seg_Front[1] = y; } seg_Front[2] = ((1-j/n)*p0[0]+(j/n)*p1[0]); seg_Front[3] = ((1-j/n)*p0[1]+(j/n)*p1[1]); x = seg_Front[2]; y = seg_Front[3]; Front.push_back( seg_Front ); Mesh.push_back( seg_Front ); } } return 0; } /* NewPoint is the function that return a new point from a give segment. I did not take in account the d_rho, that impact the density of the Mesh. We could add it in the futur. */ void AdvancingFront::NewPoint(const float * seg, float ** return_new_point = nullptr){ //= nullptr){ float * a = new float[2]; //Creation of the new point float * b = new float[2]; float * c = new float[2]; b[0]= seg[0]; b[1]= seg[1]; c[0]= seg[2]; c[1]= seg[3]; //With a rotation matrix, we can obtain : a[0] = (c[0]+b[0])*0.5 + (c[1]-b[1])*0.5*sqrt(3); a[1] = (b[0]-c[0])*0.5*sqrt(3) + (c[1]+b[1])*0.5; float closest_Front = CheckNeighbors(a, rho);// We check if a neighbor is nearby. if (closest_Front != -1){ //The new point not is an existing point. We check if there is a collision. if (Collision(a, b, c) == 1){ //We have a collision. We don't take our new point and pass to the next segment of the Front. a = nullptr; //cout << "Collision trouvée"<< endl; //DEBUG }else{//No collision; a = existing point a[0] = Front[closest_Front][0]; a[1] = Front[closest_Front][1]; } } return_new_point[0] = a; //Given from new points. float * return_me_pointer = new float[1]; return_me_pointer[0] = closest_Front; return_new_point[1] = return_me_pointer; } /* CheckNeighbors is used to check if the new point is near from an existing point in the Front. We want to check if a point is near a. If so, we take this new point, with closest_Front. */ float AdvancingFront::CheckNeighbors(float * a, float rho = 0.1){ float closest_Front = -1 ;//The index of the futur closest front. If closest_Front = -1 : no neighbor was found. float r_test = d_rho/1.5; //r_test is the distance from the closest neighbor acceptable.1/2 of d_rho : Imperical value. for (int i=0; i<Front.size() ; ++i){ //We browse the Front to find if a point from it is close enouth. float * p_Front = Front[i]; //We take a point form the Front. Front is a n*4 so we only consider the first point of each segment. float dist_from_a = sqrt(pow(a[0]-p_Front[0],2)+pow(a[1]-p_Front[1],2)); //distance between the Front's point and the created point a. if(dist_from_a <r_test){ closest_Front = i; //We stock the index of the closest neighbor. //cout << ">> We have Neighbors, closest_Front = "<< closest_Front <<endl; //DEBUG //cout << "r_test = "<<r_test << endl; //cout << "dist_from_a = "<<dist_from_a<< endl; r_test = dist_from_a; // By doing this, if we find multiple neighbors to a, we'll get the closest } } return closest_Front; //closest_Front should be an int but some difficulties makes it difficult to keep it as an int. } /* b is the point from the segment from which we generated a. We check if [ab] creates a collision */ int AdvancingFront::Collision(float * a, float * b, float * c){ //float xa = a[0]; //float ya = a[1]; int coll_test = 0; //Test if there is a collision. If so, coll_test = 1 vector<float *> Mesh_copy; Mesh_copy = Mesh; while(!Mesh_copy.empty()){ float * P = new float[4]; P = Mesh_copy.back(); //P is a segment 1*4 [x1, y1, x2, y2] Mesh_copy.pop_back();//Remove the last element. for (int k = 0; k<2; k++){ if(k == 1){b = c;} if (Intersect_segment(a, b, P) == 1){ return 1; } } } return 0; } /* The function that tells us whether two segments intersect or not. 1 if there is an intersection, 0 if not. a and b are two points([2*1]) and P is a segment([4*1]). */ int AdvancingFront::Intersect_segment(float * a,float * b, float * P){ if (max(a[0], b[0]) < min(P[0], P[2])){ //Check if this interval exists // There is no mutual abscisses => no intersection possible. return 0; //This skips the iteration we are on and we get the next segment. } // We have the two lines formed by the segments : //f1(x) = A1*x + b1 = y //f2(x) = A2*x + b2 = y if ((P[0]-P[2])==0){ //the segment is vertical, we add a small value to a coordinate. P[0] = P[0]+(d_rho/100); }else if ((a[0]-b[0])==0){ a[0] = a[0]+(d_rho/100); } float A1 = (a[1]-b[1])/(a[0]-b[0]); float A2 = (P[1]-P[3])/(P[0]-P[2]); float b1 = a[1]-A1*a[0]; float b2 = P[1]-A2*P[0]; if (A1==A2){ //Segments are parallel, no intersection can be found, check next segment of the mesh. return 0; } float Xi = (b2-b1)/(A1-A2); //Abscisse of the point of intersection of the two lines, we just need to check if it is in the semgents. //Test if Xi in in Ii. This is the only test we need because we already have an intersection. if ( (Xi < max(min(a[0], b[0]), min(P[0], P[2]))) or (Xi > min(max(a[0], b[0]), max(P[0], P[2]))) ){ //intersection out of bound return 0; }else{ //intersection found, we have a collision. return 1; //We found one collision, that is enouth, we can exit this function. } return 0; } /* This function round the values indide a segment seg at the n decimal. It only works with 4*1 segments. */ void AdvancingFront::Round(float * seg = nullptr, int n =2){ int rnd = pow(10,n); seg[0] = roundf(seg[0] * rnd) / rnd; seg[1] = roundf(seg[1] * rnd) / rnd; seg[2] = roundf(seg[2] * rnd) / rnd; seg[3] = roundf(seg[3] * rnd) / rnd; } /* We write in ReturnPoints.txt every segments from Mesh form the last added to the first. */ void AdvancingFront::WritePoints(){ ofstream myfile("ReturnPoints.txt"); // /media/sf_Shared/Matlab read point/ // while(!Mesh.empty()){ //DEBUG for(int k = 0; Mesh.size(); ++k){ float * Point = Mesh.back(); Mesh.pop_back(); myfile << Point[0] <<","<< Point[1] << "," << Point[2] <<","<< Point[3]<< "\n"; } /* if(Mesh.empty()){ myfile << Point[0] <<","<< Point[1]<< "\n"; } //DEBUG : should not be useful. }*/ myfile.close(); }
[ "noreply@github.com" ]
noreply@github.com
768c8e6a56e73bcad57e24a45a90675d0eb26669
ad80b255ef083d41f4b7ad28904055395c05bd1e
/ChangeSymbols/ChangeSymbols.cpp
b9d19deeb96668902e53ef0fa13658d1c6dc99fa
[]
no_license
kveron/ChangeSymbols
91be88efd022d2ce7f1f2b28c4ed847ce822b878
707cec4a8dff3c3884d18eceacbb26baa7ceba6b
refs/heads/main
2023-09-01T06:26:33.204913
2021-10-29T21:23:22
2021-10-29T21:23:22
422,715,421
0
0
null
null
null
null
UTF-8
C++
false
false
693
cpp
#include <iostream> #include <algorithm> #include <cctype> #include <string> int main() { std::string symbols; std::cin >> symbols; std::transform(symbols.begin(), symbols.end(), symbols.begin(), [](unsigned char c) { return std::tolower(c); }); std::string new_symbols = symbols; for (size_t i = 0; i < symbols.length(); i++) { new_symbols[i] = '('; for (size_t j = 0; j < symbols.length(); j++) { if (symbols[i] == symbols[j] && i != j) { new_symbols[i] = ')'; break; } } } std::cout << new_symbols << std::endl; system("pause"); return 0; }
[ "nsarakiy@gmail.com" ]
nsarakiy@gmail.com
6b323ac2c24d94e7f58cb526a8eac6fc590e7df2
84cb6172f8afd975707c486b11ac8c812960a8a1
/LibrayCodes/GraphAlgorithms-Basics.cpp
527bff8ca0a7812632ca6fc9586c51e715d98624
[]
no_license
numan947/Curiously-Bored
d4d761923102831cac83c828e2e6a44daa5d5ac7
7bfffec3989d6cb75697bf7f569da01c3adb1a19
refs/heads/master
2021-07-10T22:01:27.716481
2020-07-02T19:16:16
2020-07-02T19:16:16
152,405,037
2
0
null
null
null
null
UTF-8
C++
false
false
11,390
cpp
#include <bits/stdc++.h> using namespace std; #define MAX 100 #define INF 100000 /** * Basic Traversal Related Algorithms: * 1. DFS * 2. BFS * 3. Finding SCC in Undirected Graph * 4. Flood Fill * 5. Topological Sort * 6. Bipartite Graph Checking * 7. Graph Property Checking Using DFS * 8. Finding Articulation Points and Bridges in a Graph * 9. Finding SCC in Directed Graph */ /** * Depth First Search: Searches the deepest nodes first */ //AdjList[u][v].fi = neighbour of the u //AdjList[u][v].se = weight of the edge that connects u to the neighbour vector<pair<int,int> >AdjList[MAX]; //possible states of a vertex #define UNVISITED 0 //we didn't encounter this vertex yet #define EXPLORED 1 //we encountered the vertex, but didn't completed exploring all the outgoing edges #define VISITED 2 //we explored all the outgoing edges of a vertex //essentially stores the state of a vertex in dfs vector<int>dfs_num; void dfs(int u) { dfs_num[u] = VISITED; for(int j=0;j<AdjList[u].size();j++){ pair<int,int> v = AdjList[u][j]; if(dfs_num[v.first]==UNVISITED) dfs(v.first); } } /** * int main() * { * dfs_num.assign(N,0); * for(int i=0;i<N;i++) * if(dfs_num[i]==UNVISITED) * dfs(i); * } */ /** * Breadth First Search: Searches the nodes layer by layer, can find SSSP in unweighted path */ //d[v] = contains distance from a source node u vector<int>dst; vector<int>bfs_parent; //number of nodes in the graph int N; //s is the source vertex void bfs(int s) { bfs_parent.assign(N,-1); dst.assign(N,INF); queue<int>q; dst[s] = 0; bfs_parent[s] = s; q.push(s); while(!q.empty()) { int u = q.front(); q.pop(); for(int j=0;j<AdjList[u].size();j++) { pair<int,int> v = AdjList[u][j]; if(dst[v.first]==INF){ bfs_parent[v.first] = u; dst[v.first] = 1+ dst[u]; q.push(v.first); } } } } /** * * Finding SCC + Number of SCC * Can be solved using: DFS, BFS, UFDS * */ int FindNumberOfScc() { dfs_num.assign(N,0); int numScc = 0; for(int i=0;i<N;i++) if(!dfs_num[i]){ numScc++; dfs(i); } return numScc; } /** * Flood Fill: Finding Number of Vertices in a * Connected Component in an Implicit Graph */ int dr[] = {1,1,0,-1,-1,-1,0,1}; int dc[] = {0,1,1,1,0,-1,-1,-1}; char grid[MAX][MAX]; int R,C;//boundary of the implicit graph grid int FloodFill(int r, int c, char newColor, char colorToMatch) { if(r<0||r>=R||c<0||c>=C) return 0; if(grid[r][c]!=colorToMatch) return 0; //current vertex int ans = 1; //so that we don't get stuck in an infinite loop grid[r][c] = newColor; for(int i=0;i<8;i++) { //check if more vertex are reachable usgin 8-directional movement ans+= FloodFill(r+dr[i],c+dc[i],newColor,colorToMatch); } return ans; } /** * Topological Sort: A Linear Ordering of the Vertices in a Graph G, * where Node u comes before Node v, if there is an edge from u to v (u->v) * Every DAG has at least 1 and possibly more Topological Ordering * * We can slightly modify dfs(u) to find out the topological order of a a Graph */ vector<int>TopologicalOrder; void dfs_top_ord(int u) { //Tarjan's Simplified TopSort Algorithm dfs_num[u]= VISITED; for(int i=0;i<AdjList[u].size();i++) { pair<int,int> v = AdjList[u][i]; if(dfs_num[v.first]==UNVISITED) dfs(i); } //all u->v edges are explored, so add u to the list; //reversing the list, we can get the Topological Order TopologicalOrder.push_back(u); } //kahn's algorithm can also detect cycle in graph map<int,int>InDegree; //keeps track of the InDegrees void topsort_kahn() { // may need priority Q, if condition like this is given: // In the case there is no relation between two beverages Dilbert should start drinking the one that // appears first in the input queue<int>q; for(int i=0;i<N;i++){ if(!InDegree[i]){ q.push(i); } } int cnt = 0;//keeps track of number of visited vertices while(!q.empty()){ int u = q.front(); q.pop(); TopologicalOrder.push_back(u); cnt++; for(int i=0;i<AdjList[u].size();i++){ int v = AdjList[u][i].first; if(--InDegree[v]==0){ q.push(v); } } } if(cnt!=N){ //There is a cycle in the graph } } /** * Bipartite Graph Checking: This is basically to find out if, the Graph * can be Bi-Colored. * * Can be solved using both DFS and BFS * * There are atmost (N*N)/4 edges in a Graph, if it is bicolorable * This can be used for trivial reject */ vector<int>color; bool is_bicolorable_bfs(int s) { color.assign(N,INF); queue<int>q; color[s] = 0; q.push(s); while(!q.empty()){ int u = q.front(); q.pop(); for(int j=0;j<AdjList[u].size();j++){ pair<int,int>v = AdjList[u][j]; if(color[v.first]==INF){ color[v.first] = 1-color[u]; q.push(v.first); } else if(color[v.first] == color[u]) return false; } } return true; } /** * Graph Property Checking: * * Tree Edge: An edge from EXPLORED -> UNVISITED * * Back Edge: An edge from EXPLORED1 -> EXPLORED2, where EXPLORED2 is not parent of EXPLORED1 * (for undirected graph) * * Cross Edge: An edge from EXPLORED -> VISITED * */ //stores the immediate parent of a vertex vector<int>dfs_parent; void dfs_prop_check(int u) { //just got to this vertex, mark it as EXPLORED dfs_num[u] = EXPLORED; for(int j=0;j<AdjList[u].size();j++){ pair<int,int> v = AdjList[u][j]; //Tree Edge : EXPLORED -> UNVISITED if(dfs_num[v.first]==UNVISITED){ dfs_parent[v.first] = u; dfs_prop_check(v.first); } //REVERSE EDGE: Can be a Back Edge else if(dfs_num[v.first]==EXPLORED) { //Back Edge: EXPLORED -> EXPLORED if(dfs_parent[u]!=v.first){ //THIS IS BACK EDGE } else{ //THIS IS JUST A REVERSE EDGE TO PARENT OF u, i.e v is parent of u } } else if(dfs_num[v.first]==VISITED){ //Cross Edge: EXPLORED -> VISITED } } //all edges of u is explore now, so, mark u as VISITED dfs_num[u] = VISITED; } /** * Finding Articulation Points and Bridges: Undirected Graph * * Articulation Points: * These are the vertices in a graph, which, if deleted, * makes the rest of the graph disconnected * * Bridges: * These are the edges in a graph, which, if deleted, * makes the rest of the graph disconnected * * * Naive Algorithm: * Run O(V+E) DFS --> count number of connected components in a the Graph, it's usually just 1 * * For each vertex v in V: * remove vertex v and incident edges * Run O(V+E) DFS and check if connected components increases * if yes --> vertex v is a Articulation Point, same logic can be applied to Bridges * * Efficient Algorithm: * * Aside from dfs_num, maintain dfs_low. * * dfs_num[u] = time of first visit of u vertex, an iteration * counter is enough to act as time. * * dfs_low[u] = the lowest dfs_num rechable from current DFS spanning subtree of u. * * Initially, dfs_num[u] = dfs_low[u] = time_of_visiting_u_for_the_first_time * * So, dfs_low[u] can only be smaller if there is a back edge in the graph. * * When we are in a node u, with v as its neighbour, * if dfs_low[v] >= dfs_num[u] ==> u vertex is an Articualtion Point * * if dfs_low[v]>dfs_num[u] ==> u-v edge is a Bridge * * SPECIAL CASE: ==> Not detected by the algorithm * The root of the dfs spanning tree is an Articualtion Point, * only if it has more than one children in the dfs spanning tree. * */ vector<int>dfs_low; int current_time; //initially 0 int dfsRoot; //initially the vertex that is passed as u in the function int rootChildren; //initially 0 before passing root to the function void ArticulationPointAndBridge(int u) { dfs_low[u] = dfs_num[u] = current_time++; for(int i=0;i<AdjList[u].size();i++){ pair<int,int>v = AdjList[u][i]; if(dfs_num[v.first]==UNVISITED){ dfs_parent[v.first] = u; if(dfsRoot==u) rootChildren++; ArticulationPointAndBridge(v.first); if(dfs_low[v.first]>=dfs_num[u]){ //u is an articulation point } if(dfs_low[v.first]>dfs_num[u]){ //u-v is a bridge } //update dfs_low[u], as the dfs_low[v.first] is the lowest we can reach from u dfs_low[u] = min(dfs_low[u],dfs_low[v.first]); } else if(dfs_parent[u]!=v.first){ //this is the back edge, we can reach dfs_num[v.first] from u, //and v.first should have smaller time dfs_low[u] = min(dfs_low[u],dfs_num[v.first]); } } } /** * SCC in Directed Graph: * * Two Known Algorithms for Finding SCCs in Directed Graphs: * * 1. Kosaraju * 2. Tarjan * * Tarjan is similar to ArticulationPoint/Bridge finding algorithm. * * In addition to dfs_num and dfs_low, we keep a vector and use it as a stack. * We add u to the back of the vector ==> this vector keeps track of the explored vertices. * * Updating dfs_low is different from that of ArticulationPoint and Bridges: * * Here we only update dfs_low, if the vertex in consideration is visited: * dfs_low[u] = min(dfs_low[u],dfs_low[v.first]) ==> only if v is already visited * * Now, if we still have a vertex in the dfs spanning tre, with dfs_low[u] == dfs_num[u], * then, it must be the root of an SCC. * * The memebers of that SCC are found by popping the vector from end until we reach u. * * */ int numSCC; //initially zero vector<int>S; //keeps track of currently explored vertices to find out the SCC members vector<int>visited; //keeps track of visited, so that overlapping SCCs don't update void tarjanSCC(int u) { dfs_low[u] = dfs_num[u] = current_time++; S.push_back(u); visited[u] = VISITED; for(int i=0;i<AdjList[u].size();i++){ pair<int,int>v = AdjList[u][i]; //if v is not visited, visit it first if(dfs_num[v.first]==UNVISITED) tarjanSCC(v.first); //if v is visited, try to update the dfs_low[u] if(visited[v.first]==VISITED) dfs_low[u] = min(dfs_low[u],dfs_low[v.first]); //check if cycle is created yet, if current vertex is inside a cycle, and not the root of //that cycle, dfs_num[u] != dfs_low[u], otherwise, dfs_low[u] == dfs_num[u], as dfs explores //all outgoing edges of the node if(dfs_low[u]==dfs_num[u]){ while(1){ int v = S.back(); visited[v] = UNVISITED; S.pop_back(); if(u==v) break; } } } }
[ "mahmudulhasan947@gmail.com" ]
mahmudulhasan947@gmail.com
01300827ef0d701c7053530756453e1f5a06ac5d
308561a8a5a55d76d82204e8f1206e76324a79db
/Portal6/Login.h
c104c7ac3a0b90314f30cbc6be074e593af7983b
[]
no_license
huukhangapcs/Student-Management-CS162--2019-
a41b4abe540b49e21fb99ad05883a0fe30e4b468
84a3fbe7b3f216690db0ea0a07fbdca5a96141f5
refs/heads/master
2020-11-28T19:58:59.059482
2019-12-24T09:07:17
2019-12-24T09:07:17
229,908,771
0
0
null
null
null
null
UTF-8
C++
false
false
328
h
#ifndef _LOGIN_H_ #define _LOGIN_H_ #include<iostream> #include<Windows.h> #include<string> #include"Gotoxy.h" #include"DesignAffect.h" #include"InputData.h" #include"InputPassword.h" #include"CheckLogin.h" using namespace std; void Intro(); void MainMenuAffect(int loginType); void Login(string &Usn); #endif
[ "noreply@github.com" ]
noreply@github.com
16f91d8652f93b811182e7d972a33baccd3da045
10cf0093f67d6635bb5bc7ceb9eef90127902789
/LeetCode/Q337_HouseRobberIII.cpp
8cd67fd845a0da32d60ddeffa8db85ab25adaa17
[]
no_license
yuukidach/OnlineJudge
2c8f636638b48b44f2a67e1f1ce5ee030e96fa42
a645717dd18202dbe7b0a5bb4b6a83e64a50a6ae
refs/heads/master
2023-06-07T13:04:58.054156
2021-07-15T15:21:22
2021-07-15T15:21:22
253,027,435
0
0
null
null
null
null
UTF-8
C++
false
false
717
cpp
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: vector<int> interval_rob(TreeNode *root) { vector<int> cnt(2, 0); if (root == NULL) return cnt; vector<int> a = interval_rob(root->left); vector<int> b = interval_rob(root->right); cnt[0] = max(a[0], a[1]) + max(b[0], b[1]); cnt[1] = root->val + a[0] + b[0]; return cnt; } int rob(TreeNode* root) { int res = 0; vector<int> cnt; cnt = interval_rob(root); return max(cnt[0],cnt[1]); } };
[ "chendamailbox@foxmail.com" ]
chendamailbox@foxmail.com
c0f2b141745246fbd5417d4aa4efab657b4a259c
e6a6ce66b7e6adee1043c92bf6089ca562c6e4e8
/src_hyp2018ana/HistManCheck.h
42ea7531a8d7fe1c3e52421939e54c33d204961a
[]
no_license
HidemitsuAsano/E31ana
267c4f7a8717234e0fd67f03844e46ad61ed7da9
4c179ab966e9f791e1f113b6618491dede44e088
refs/heads/master
2023-04-04T23:18:25.517277
2023-03-17T00:46:31
2023-03-17T00:46:31
121,988,232
0
0
null
null
null
null
UTF-8
C++
false
false
449
h
#ifndef HistManCheck_h #define HistManCheck_h 1 #include "ConfMan.h" #include "EventHeader.h" #include "BeamLineHitMan.h" #include "BeamLineTrackMan.h" #include "BeamSpectrometer.h" #include "CDSTrackingMan.h" #include "TFile.h" #include "TH1.h" #include "TH2.h" #include "ELossTools.h" #include "TrackTools.h" #include "MyTools.h" #include "SlewingData.h" class HistManCheck { public: HistManCheck(); virtual ~HistManCheck(){}; }; #endif
[ "hasano@scphys.kyoto-u.ac.jp" ]
hasano@scphys.kyoto-u.ac.jp
e99e85fbd7ff7d52790a1e3f3eab8a968e2099d7
c32ee8ade268240a8064e9b8efdbebfbaa46ddfa
/Libraries/m2sdk/CFDictionary.h
a6c71203cd84620b04dfd0f96e4dc2532c97ec20
[]
no_license
hopk1nz/maf2mp
6f65bd4f8114fdeb42f9407a4d158ad97f8d1789
814cab57dc713d9ff791dfb2a2abeb6af0e2f5a8
refs/heads/master
2021-03-12T23:56:24.336057
2015-08-22T13:53:10
2015-08-22T13:53:10
41,209,355
19
21
null
2015-08-31T05:28:13
2015-08-22T13:56:04
C++
UTF-8
C++
false
false
219
h
// auto-generated file (rttidump-exporter by h0pk1nz) #pragma once /** CFDictionary (VTable=0x01EA5AE0) */ class CFDictionary { public: virtual void vfn_0001_27807C94() = 0; virtual void vfn_0002_27807C94() = 0; };
[ "hopk1nz@gmail.com" ]
hopk1nz@gmail.com
f9f3b6560cad675ac66badbb729f8396dc0321a6
35baa4a4648003fdd85732850897d043b830761e
/binarytreefrominandpreorder.cpp
8746a9614ba6a913c6731756e53779b0d2bb0655
[]
no_license
deepanshuoct12/interviewbit-solution
0c091e7ddab2d1be3cc207a70b5c9498c23b33d2
87254a250233c571611cc70b91749574d0544b5a
refs/heads/master
2023-01-03T11:46:16.244384
2020-11-02T21:29:57
2020-11-02T21:29:57
279,698,381
0
0
null
null
null
null
UTF-8
C++
false
false
795
cpp
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ TreeNode* helper(vector<int> &pre,vector<int> &in,int s,int e,int &i) { if(s>e) return NULL; TreeNode* root = new TreeNode(pre[i]); int index=-1; for(int j=s;j<=e;j++) { if(pre[i]==in[j]) { index=j; break; } } i++; root->left=helper(pre,in,s,index-1,i); root->right=helper(pre,in,index+1,e,i); return root; } TreeNode* Solution::buildTree(vector<int> &A, vector<int> &B) { int i=0; TreeNode* ans=helper(A,B,0,A.size()-1,i); return ans; }
[ "noreply@github.com" ]
noreply@github.com
bff6ad4967a6c96477759a12ceebd9831de80920
55d560fe6678a3edc9232ef14de8fafd7b7ece12
/libs/sort/benchmark/single/benchmark_numbers.cpp
505618fd166a3c0a4ed06f1e63404904fd6ecc25
[ "BSL-1.0" ]
permissive
stardog-union/boost
ec3abeeef1b45389228df031bf25b470d3d123c5
caa4a540db892caa92e5346e0094c63dea51cbfb
refs/heads/stardog/develop
2021-06-25T02:15:10.697006
2020-11-17T19:50:35
2020-11-17T19:50:35
148,681,713
0
0
BSL-1.0
2020-11-17T19:50:36
2018-09-13T18:38:54
C++
UTF-8
C++
false
false
9,767
cpp
//---------------------------------------------------------------------------- /// @file benchmark_numbers.cpp /// @brief Benchmark of several sort methods with integer objects /// /// @author Copyright (c) 2017 Francisco José Tapia (fjtapia@gmail.com )\n /// Distributed under the Boost Software License, Version 1.0.\n /// ( See accompanying file LICENSE_1_0.txt or copy at /// http://www.boost.org/LICENSE_1_0.txt ) /// /// This program use for comparison purposes, the Threading Building /// Blocks which license is the GNU General Public License, version 2 /// as published by the Free Software Foundation. /// /// @version 0.1 /// /// @remarks //----------------------------------------------------------------------------- #include <algorithm> #include <iostream> #include <iomanip> #include <random> #include <stdlib.h> #include <vector> #include <boost/sort/common/time_measure.hpp> #include <boost/sort/common/file_vector.hpp> #include <boost/sort/common/int_array.hpp> #include <boost/sort/sort.hpp> #define NELEM 100000000 using namespace std; namespace bsort = boost::sort; namespace bsc = boost::sort::common; using bsc::time_point; using bsc::now; using bsc::subtract_time; using bsc::fill_vector_uint64; using bsc::write_file_uint64; using bsort::spinsort; using bsort::flat_stable_sort; using bsort::spreadsort::spreadsort; using bsort::pdqsort; void Generator_random (void); void Generator_sorted (void); void Generator_sorted_end (size_t n_last); void Generator_sorted_middle (size_t n_last); void Generator_reverse_sorted (void); void Generator_reverse_sorted_end (size_t n_last); void Generator_reverse_sorted_middle (size_t n_last); template<class IA, class compare> int Test (std::vector<IA> &B, compare comp = compare ()); int main (int argc, char *argv[]) { cout << "\n\n"; cout << "************************************************************\n"; cout << "** **\n"; cout << "** B O O S T S O R T **\n"; cout << "** S I N G L E T H R E A D **\n"; cout << "** I N T E G E R B E N C H M A R K **\n"; cout << "** **\n"; cout << "** SORT OF 100 000 000 NUMBERS OF 64 BITS **\n"; cout << "** **\n"; cout << "************************************************************\n"; cout << std::endl; cout<<"[ 1 ] std::sort [ 2 ] pdqsort [ 3 ] std::stable_sort \n"; cout<<"[ 4 ] spinsort [ 5 ] flat_stable_sort [ 6 ] spreadsort\n\n"; cout<<" | | | | | | |\n"; cout<<" | [ 1 ]| [ 2 ]| [ 3 ]| [ 4 ]| [ 5 ]| [ 6 ]|\n"; cout<<"--------------------+------+------+------+------+------+------+\n"; std::string empty_line = " | | | | | | |\n"; cout<<"random |"; Generator_random (); cout<<empty_line; cout<<"sorted |"; Generator_sorted (); cout<<"sorted + 0.1% end |"; Generator_sorted_end (NELEM / 1000); cout<<"sorted + 1% end |"; Generator_sorted_end (NELEM / 100); cout<<"sorted + 10% end |"; Generator_sorted_end (NELEM / 10); cout<<empty_line; cout<<"sorted + 0.1% mid |"; Generator_sorted_middle (NELEM / 1000); cout<<"sorted + 1% mid |"; Generator_sorted_middle (NELEM / 100); cout<<"sorted + 10% mid |"; Generator_sorted_middle (NELEM / 10); cout<<empty_line; cout<<"reverse sorted |"; Generator_reverse_sorted (); cout<<"rv sorted + 0.1% end|"; Generator_reverse_sorted_end (NELEM / 1000); cout<<"rv sorted + 1% end|"; Generator_reverse_sorted_end (NELEM / 100); cout<<"rv sorted + 10% end|"; Generator_reverse_sorted_end (NELEM / 10); cout<<empty_line; cout<<"rv sorted + 0.1% mid|"; Generator_reverse_sorted_middle (NELEM / 1000); cout<<"rv sorted + 1% mid|"; Generator_reverse_sorted_middle (NELEM / 100); cout<<"rv sorted + 10% mid|"; Generator_reverse_sorted_middle (NELEM / 10); cout<<"--------------------+------+------+------+------+------+------+\n"; cout<<endl<<endl ; return 0; } void Generator_random (void) { vector<uint64_t> A; A.reserve (NELEM); A.clear (); if (fill_vector_uint64 ("input.bin", A, NELEM) != 0) { std::cout << "Error in the input file\n"; return; }; Test<uint64_t, std::less<uint64_t>> (A); } ; void Generator_sorted (void) { vector<uint64_t> A; A.reserve (NELEM); A.clear (); for (size_t i = 0; i < NELEM; ++i) A.push_back (i); Test<uint64_t, std::less<uint64_t>> (A); } void Generator_sorted_end (size_t n_last) { vector<uint64_t> A; A.reserve (NELEM); A.clear (); if (fill_vector_uint64 ("input.bin", A, NELEM + n_last) != 0) { std::cout << "Error in the input file\n"; return; }; std::sort (A.begin (), A.begin () + NELEM); Test<uint64_t, std::less<uint64_t>> (A); } ; void Generator_sorted_middle (size_t n_last) { vector<uint64_t> A, B, C; A.reserve (NELEM); A.clear (); if (fill_vector_uint64 ("input.bin", A, NELEM + n_last) != 0) { std::cout << "Error in the input file\n"; return; }; for (size_t i = NELEM; i < A.size (); ++i) B.push_back (std::move (A[i])); A.resize ( NELEM); for (size_t i = 0; i < (NELEM >> 1); ++i) std::swap (A[i], A[NELEM - 1 - i]); std::sort (A.begin (), A.end ()); size_t step = NELEM / n_last + 1; size_t pos = 0; for (size_t i = 0; i < B.size (); ++i, pos += step) { C.push_back (B[i]); for (size_t k = 0; k < step; ++k) C.push_back (A[pos + k]); }; while (pos < A.size ()) C.push_back (A[pos++]); A = C; Test<uint64_t, std::less<uint64_t>> (A); } ; void Generator_reverse_sorted (void) { vector<uint64_t> A; A.reserve (NELEM); A.clear (); for (size_t i = NELEM; i > 0; --i) A.push_back (i); Test<uint64_t, std::less<uint64_t>> (A); } void Generator_reverse_sorted_end (size_t n_last) { vector<uint64_t> A; A.reserve (NELEM); A.clear (); if (fill_vector_uint64 ("input.bin", A, NELEM + n_last) != 0) { std::cout << "Error in the input file\n"; return; }; std::sort (A.begin (), A.begin () + NELEM); for (size_t i = 0; i < (NELEM >> 1); ++i) std::swap (A[i], A[NELEM - 1 - i]); Test<uint64_t, std::less<uint64_t>> (A); } void Generator_reverse_sorted_middle (size_t n_last) { vector<uint64_t> A, B, C; A.reserve (NELEM); A.clear (); if (fill_vector_uint64 ("input.bin", A, NELEM + n_last) != 0) { std::cout << "Error in the input file\n"; return; }; for (size_t i = NELEM; i < A.size (); ++i) B.push_back (std::move (A[i])); A.resize ( NELEM); for (size_t i = 0; i < (NELEM >> 1); ++i) std::swap (A[i], A[NELEM - 1 - i]); std::sort (A.begin (), A.end ()); size_t step = NELEM / n_last + 1; size_t pos = 0; for (size_t i = 0; i < B.size (); ++i, pos += step) { C.push_back (B[i]); for (size_t k = 0; k < step; ++k) C.push_back (A[pos + k]); }; while (pos < A.size ()) C.push_back (A[pos++]); A = C; Test<uint64_t, std::less<uint64_t>> (A); }; template<class IA, class compare> int Test (std::vector<IA> &B, compare comp) { //---------------------------- begin -------------------------------- double duration; time_point start, finish; std::vector<IA> A (B); std::vector<double> V; //-------------------------------------------------------------------- A = B; start = now (); std::sort (A.begin (), A.end (), comp); finish = now (); duration = subtract_time (finish, start); V.push_back (duration); A = B; start = now (); pdqsort (A.begin (), A.end (), comp); finish = now (); duration = subtract_time (finish, start); V.push_back (duration); A = B; start = now (); std::stable_sort (A.begin (), A.end (), comp); finish = now (); duration = subtract_time (finish, start); V.push_back (duration); A = B; start = now (); spinsort(A.begin (), A.end (), comp); finish = now (); duration = subtract_time (finish, start); V.push_back (duration); A = B; start = now (); flat_stable_sort (A.begin (), A.end (), comp); finish = now (); duration = subtract_time (finish, start); V.push_back (duration); A = B; start = now (); spreadsort (A.begin (), A.end ()); finish = now (); duration = subtract_time (finish, start); V.push_back (duration); //----------------------------------------------------------------------- // printing the vector //----------------------------------------------------------------------- std::cout<<std::setprecision(2)<<std::fixed; for ( uint32_t i =0 ; i < V.size() ; ++i) { std::cout<<std::right<<std::setw(5)<<V[i]<<" |"; }; std::cout<<std::endl; return 0; };
[ "james.pack@stardog.com" ]
james.pack@stardog.com
6b7e6ef50c0456d10ebcdc9132cb54014168a9e4
cc153bdc1238b6888d309939fc683e6d1589df80
/qcril-hal/include/modules/sms/RilUnsolNewImsSmsStatusReportMessage.h
076796e292ff7000995b5cbac74e440036d2e6ca
[ "Apache-2.0" ]
permissive
ml-think-tanks/msm8996-vendor
bb9aa72dabe59a9bd9158cd7a6e350a287fa6a35
b506122cefbe34508214e0bc6a57941a1bfbbe97
refs/heads/master
2022-10-21T17:39:51.458074
2020-06-18T08:35:56
2020-06-18T08:35:56
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,690
h
/****************************************************************************** # Copyright (c) 2018 Qualcomm Technologies, Inc. # All Rights Reserved. # Confidential and Proprietary - Qualcomm Technologies, Inc. #******************************************************************************/ #pragma once #include "framework/UnSolicitedMessage.h" #include "framework/Message.h" #include "framework/add_message_id.h" class RilUnsolNewImsSmsStatusReportMessage : public UnSolicitedMessage, public add_message_id<RilUnsolNewImsSmsStatusReportMessage> { private: uint32_t mMsgRef; RIL_RadioTechnologyFamily mRadioTech; std::vector<uint8_t> mGsmPayload; RIL_CDMA_SMS_Message mCdmaPayload; public: static constexpr const char *MESSAGE_NAME = "com.qualcomm.qti.qcril.sms.unsol_new_ims_sms_status_report"; RilUnsolNewImsSmsStatusReportMessage() = delete; ~RilUnsolNewImsSmsStatusReportMessage(); explicit inline RilUnsolNewImsSmsStatusReportMessage(uint32_t msgRef, RIL_RadioTechnologyFamily tech) : UnSolicitedMessage(get_class_message_id()), mMsgRef(msgRef), mRadioTech(tech) { mName = MESSAGE_NAME; memset(&mCdmaPayload, 0, sizeof(mCdmaPayload)); } template<typename T> inline void setGsmPayload(T&& pdu) { if (mRadioTech == RADIO_TECH_3GPP) { mGsmPayload = std::forward<T>(pdu); } } void setCdmaPayload(const RIL_CDMA_SMS_Message& payload); std::shared_ptr<UnSolicitedMessage> clone() override; string dump() override; uint32_t getMessageRef(); RIL_RadioTechnologyFamily getRadioTech(); std::vector<uint8_t>& getGsmPayload(); RIL_CDMA_SMS_Message& getCdmaPayload(); };
[ "deepakjeganathan@gmail.com" ]
deepakjeganathan@gmail.com
591399de9a706701183ea220320579ddd7680857
2332918000f2e57f7d191996f5db22e5797629e1
/GetLine.h
da58ffda8103087c68d0f4682190711d75544bab
[]
no_license
raul-cerda/Textbook-Indexer
5a9c9ba9c3f4e6e3e144f95e50b881ef7140dc99
b41379c039946d1b0d143b6d9298297c757b1dd2
refs/heads/master
2022-11-10T21:35:53.164005
2020-07-04T19:10:02
2020-07-04T19:10:02
277,170,453
0
0
null
null
null
null
UTF-8
C++
false
false
221
h
#ifndef GetLine_h #define GetLine_h #include <iostream> #include <string> using namespace std; bool GetLine(istream& stream, string& text); bool GetLine(istream& stream, string& text, const string& delimiter); #endif
[ "noreply@github.com" ]
noreply@github.com
64835675d6a40f32cdd9dfb684f39af689fbf773
67a4062458f12e443d8d26b048cab6c579fb4549
/bus/busApp.h
247307a427d5198e5173afbf08206b3f67596f47
[]
no_license
sagar110599/bus_booking_system
7b148256011105599937082cc57f41a73d73c67f
cc443621e697c133b784f788ac5977e0310940b3
refs/heads/master
2021-02-12T01:30:21.561656
2020-03-03T05:25:20
2020-03-03T05:25:20
244,547,910
0
0
null
null
null
null
UTF-8
C++
false
false
419
h
/*************************************************************** * Name: busApp.h * Purpose: Defines Application Class * Author: () * Created: 2019-07-09 * Copyright: () * License: **************************************************************/ #ifndef BUSAPP_H #define BUSAPP_H #include <wx/app.h> class busApp : public wxApp { public: virtual bool OnInit(); }; #endif // BUSAPP_H
[ "sagardama99@gmail.com" ]
sagardama99@gmail.com
5bec1ac59564d79941e42750a8916a866c5fd38d
b4e0d678ee83c5c74af39235ac9f66a0cbd8c25e
/TankGame/World.cpp
99036a0bd94a82c5d8c6d86c8dc6923efee72010
[]
no_license
rmtrailor/Tank-Game
125726edf8880c6382a345cf263a75e1e5f9b9ff
2fc7f6c05d5a78f7d9e8682aef27b10844c18d0e
refs/heads/master
2020-04-17T03:57:58.497882
2016-08-24T08:09:03
2016-08-24T08:09:03
66,336,022
0
0
null
null
null
null
UTF-8
C++
false
false
10,208
cpp
#include "World.h" #include "Ogre.h" #include "OgreMath.h" #include "OgreSceneManager.h" #include "OgreSceneNode.h" #include "OgreOverlayManager.h" #include "OgreOverlay.h" #include "OgreFontManager.h" #include "OgreTextAreaOverlayElement.h" #include <ois/ois.h> #include "TankCamera.h" #include "InputHandler.h" #include "AIManager.h" #include "Player.h" #include "CollisionManager.h" #include "Tank.h" #include "ProjectileManager.h" #include "ItemHandler.h" #include <stdlib.h> #include <time.h> /** * Constructor */ World::World(Ogre::SceneManager *sceneManager, InputHandler *input) : mSceneManager(sceneManager), mInputHandler(input) { mSceneManager->setAmbientLight(Ogre::ColourValue(1, 1, 1)); mSceneManager->setSkyBox(true, "sky", 1000, false); Ogre::ResourceManager::ResourceMapIterator iter = Ogre::FontManager::getSingleton().getResourceIterator(); while (iter.hasMoreElements()) { iter.getNext()->load(); } Ogre::OverlayManager& om = Ogre::OverlayManager::getSingleton(); Ogre::Overlay *overlay = om.getByName("HUD"); overlay->show(); MAX_TANKS = 12; MAX_POINTS = 5; srand (time(NULL)); initialized = false; } /** * Tick function * * @param time Time tick */ void World::Think(float time) { if (checkWin()) { return; } mProjectileManager->Think(time); mPlayer->checkMovement(time); mCamera->Think(time); checkTanks(time); mItemHandler->Think(time); updateHUD(); } /** * Initialize the game world. */ void World::init() { if (initialized) { return; } mTanks = new Tank*[MAX_TANKS]; mProjectileManager = new ProjectileManager(this); createTanks(); mAIManager->addTanks(mTanks); mAIManager->setNumTanks(MAX_TANKS); initPlayer(); mCamera->addPlayer(player); placeFloor(); placeWalls(); mItemHandler = new ItemHandler(mSceneManager, this, mPlayer); initScores(); initialized = true; } /** * Creates the tanks in the match. */ void World::createTanks() { //float x, z; for (int i = 0; i < MAX_TANKS; i++) { mTanks[i] = new Tank(0, 0, SceneManager(), i, mTanks, this, mProjectileManager); setTankPosition(mTanks[i]); } } /** * Checks each tank * * @param time Tick time */ void World::checkTanks(float time) { for (int i = 0; i < MAX_TANKS; i++) { if (mTanks[i] != nullptr) { if (mTanks[i]->isDead()) { mTanks[i]->addRespawnTime(time); // If respawn check true then we can respawn the tank if (mTanks[i]->respawnCheck()) { mTanks[i]->resetMesh(); setTankPosition(mTanks[i]); if (i == 0) { mCamera->getRenderCamera()->setPosition(player->getSceneNode()->getPosition().x + 10, 4, player->getSceneNode()->getPosition().z); mCamera->getRenderCamera()->lookAt(player->getSceneNode()->getPosition().x, 2, player->getSceneNode()->getPosition().z); player->getCannonNode()->attachObject(mCamera->getRenderCamera()); } } } } } } /** * Sets a tank's position. * * @param tank Pointer to the tank */ void World::setTankPosition(Tank *tank) { if (tank->getID() == 0) { tank->getSceneNode()->setPosition(0, 0, 0); tank->getCannonNode()->setPosition(0, 2.5, 0); } else { float x = rand() % 500; float z = rand() % 500; tank->getSceneNode()->setPosition(x, 0, z); tank->getCannonNode()->setPosition(x, 2.5, z); } } /** * Updates the HUD for any changed information. */ void World::updateHUD() { std::string health = "Health: " + std::to_string(mTanks[0]->getHealth()); Ogre::OverlayManager::getSingleton().getOverlayElement("HUD/Panel/Text1")->setCaption(health); std::string ammo = "Ammo: " + std::to_string(mPlayer->getAmmo()); Ogre::OverlayManager::getSingleton().getOverlayElement("HUD/Panel/Text2")->setCaption(ammo); for (int i = 0; i < MAX_TANKS; i++) { std::string tank = "HUD/Panel4/Text" + std::to_string(i + 1); std::string score; if (i == 0) { score = "Player: " + std::to_string(scores[i]); } else { score = "Bot " + std::to_string(i) + " " + std::to_string(scores[i]); } Ogre::OverlayManager::getSingleton().getOverlayElement(tank)->setCaption(score); } } /** * Initializes the player tank. */ void World::initPlayer() { player = mTanks[0]; mPlayer = new Player(player, mCamera, mInputHandler, mProjectileManager, this); mCamera->getRenderCamera()->setPosition(player->getSceneNode()->getPosition().x + 10, 4, player->getSceneNode()->getPosition().z); mCamera->getRenderCamera()->lookAt(player->getSceneNode()->getPosition().x, 2, player->getSceneNode()->getPosition().z); // Attach the camera to the player to make the camera move with the player's tank cannon player->getCannonNode()->attachObject(mCamera->getRenderCamera()); currCameraState = CameraState::player; std::string health = "Health: " + std::to_string(mTanks[0]->getHealth()); Ogre::OverlayManager::getSingleton().getOverlayElement("HUD/Panel/Text1")->setCaption(health); } /** * Initializes the scores for each tank. */ void World::initScores() { scores = new int[MAX_TANKS]; for (int i = 0; i < MAX_TANKS; i++) { scores[i] = 0; } } /** * Checks if any Tank has reached the score limit * * @return True if a tank has won */ bool World::checkWin() { for (int i = 0; i < MAX_TANKS; i++) { if (scores[i] >= MAX_POINTS) { std::string prompt; if (i == 0) { prompt = "Player Won!"; } else { prompt = "Bot " + std::to_string(i) + " won!"; } Ogre::OverlayManager::getSingleton().getOverlayElement("HUD/Panel3/Text2")->setCaption(prompt); return true; } } return false; } /** * Reattaches the camera to the player after they respawn. */ void World::reattachCameraToPlayer() { if (currCameraState != CameraState::player) { mCamera->getRenderCamera()->setOrientation(player->getSceneNode()->getOrientation()); mCamera->getRenderCamera()->setPosition(player->getSceneNode()->getPosition().x + 10, 4, player->getSceneNode()->getPosition().z); mCamera->getRenderCamera()->lookAt(player->getSceneNode()->getPosition().x, 2, player->getSceneNode()->getPosition().z); player->getCannonNode()->attachObject(mCamera->getRenderCamera()); currCameraState = CameraState::player; } } /** * Set camera to world camera. */ void World::setCameraToWorld() { if (currCameraState != CameraState::world) { mCamera->getRenderCamera()->detachFromParent(); mCamera->getRenderCamera()->setPosition(100, 100, 100); mCamera->getRenderCamera()->lookAt(100, 0, 100); currCameraState = CameraState::world; } } /** * Places the floor tiles. */ void World::placeFloor() { mFloorNodes = new Ogre::SceneNode*[25]; int count = 0; float z = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { Ogre::Entity *floorMesh = SceneManager()->createEntity("test-floor.mesh"); mFloorNodes[count] = SceneManager()->getRootSceneNode()->createChildSceneNode(); mFloorNodes[count]->attachObject(floorMesh); mFloorNodes[count]->scale(6, 0, 6); mFloorNodes[count]->setPosition((float) i * 20 * 6, -0.5, (float) j * 20 * 6); count++; } } } /** * Places the walls. */ void World::placeWalls() { int i = 0; mWallNodes = new Ogre::SceneNode*[4]; mWallMeshes = new Ogre::Entity*[4]; for (i; i < 1; i++) { mWallMeshes[i] = SceneManager()->createEntity("Wall.mesh"); mWallNodes[i] = SceneManager()->getRootSceneNode()->createChildSceneNode(); mWallNodes[i]->attachObject(mWallMeshes[i]); mWallNodes[i]->scale(1, 10, 180); mWallNodes[i]->setPosition(-55, 0.5, 250); } for (int j = 0; i < 2; i++, j++) { mWallMeshes[i] = SceneManager()->createEntity("Wall.mesh"); mWallNodes[i] = SceneManager()->getRootSceneNode()->createChildSceneNode(); mWallNodes[i]->attachObject(mWallMeshes[i]); mWallNodes[i]->scale(1, 10, 180); mWallNodes[i]->setPosition(500, 0.5, 200); } for (int j = 0; i < 3; i++, j++) { mWallMeshes[i] = SceneManager()->createEntity("Wall.mesh"); mWallNodes[i] = SceneManager()->getRootSceneNode()->createChildSceneNode(); mWallNodes[i]->attachObject(mWallMeshes[i]); mWallNodes[i]->rotate(Ogre::Quaternion(Ogre::Degree(90), Ogre::Vector3(0, 1, 0)), Ogre::Node::TransformSpace::TS_WORLD); mWallNodes[i]->scale(1, 10, 180); mWallNodes[i]->setPosition(300, 0.5, -9); } for (int j = 0; i < 4; i++, j++) { mWallMeshes[i] = SceneManager()->createEntity("Wall.mesh"); mWallNodes[i] = SceneManager()->getRootSceneNode()->createChildSceneNode(); mWallNodes[i]->attachObject(mWallMeshes[i]); mWallNodes[i]->rotate(Ogre::Quaternion(Ogre::Degree(90), Ogre::Vector3(0, 1, 0)), Ogre::Node::TransformSpace::TS_WORLD); mWallNodes[i]->scale(1, 10, 180); mWallNodes[i]->setPosition(300, 0.5, 500); } }
[ "rmtrailor@dons.usfca.edu" ]
rmtrailor@dons.usfca.edu
fff2cf14460007ab1f28ff9beb454f48d5ccd743
c681508bf3ad18a832389c402a5029acf6e8c72f
/sparse-iter/control/magma_cvpass.cpp
0fca18e8f8e46b15a8a53ca2911186a075b56501
[]
no_license
xulunfan/magma
6f058ed0e288ecfc88a4ecc3711ad17faf74cb18
b4e228e14cc1046861c8f38803743d784b06b9bf
refs/heads/master
2021-01-21T15:50:21.484822
2016-02-10T15:08:42
2016-02-10T15:08:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,569
cpp
/* -- MAGMA (version 2.0.0) -- Univ. of Tennessee, Knoxville Univ. of California, Berkeley Univ. of Colorado, Denver @date February 2016 @generated from sparse-iter/control/magma_zvpass.cpp normal z -> c, Tue Feb 9 16:05:50 2016 @author Hartwig Anzt */ // in this file, many routines are taken from // the IO functions provided by MatrixMarket #include "magmasparse_internal.h" /** Purpose ------- Passes a vector to MAGMA. Arguments --------- @param[in] m magma_int_t number of rows @param[in] n magma_int_t number of columns @param[in] val magmaFloatComplex* array containing vector entries @param[out] v magma_c_matrix* magma vector @param[in] queue magma_queue_t Queue to execute in. @ingroup magmasparse_caux ********************************************************************/ extern "C" magma_int_t magma_cvset( magma_int_t m, magma_int_t n, magmaFloatComplex *val, magma_c_matrix *v, magma_queue_t queue ) { v->num_rows = m; v->num_cols = n; v->nnz = m*n; v->memory_location = Magma_CPU; v->val = val; v->major = MagmaColMajor; v->storage_type = Magma_DENSE; return MAGMA_SUCCESS; } /** Purpose ------- Passes a MAGMA vector back. Arguments --------- @param[in] v magma_c_matrix magma vector @param[out] m magma_int_t number of rows @param[out] n magma_int_t number of columns @param[out] val magmaFloatComplex* array containing vector entries @param[in] queue magma_queue_t Queue to execute in. @ingroup magmasparse_caux ********************************************************************/ extern "C" magma_int_t magma_cvget( magma_c_matrix v, magma_int_t *m, magma_int_t *n, magmaFloatComplex **val, magma_queue_t queue ) { magma_c_matrix v_CPU={Magma_CSR}; magma_int_t info =0; if ( v.memory_location == Magma_CPU ) { *m = v.num_rows; *n = v.num_cols; *val = v.val; } else { CHECK( magma_cmtransfer( v, &v_CPU, v.memory_location, Magma_CPU, queue )); CHECK( magma_cvget( v_CPU, m, n, val, queue )); } cleanup: magma_cmfree( &v_CPU, queue ); return info; }
[ "maxhutch@gmail.com" ]
maxhutch@gmail.com
3304b7cc26b139997a7b2e7139274c955a1afa23
8c7cfbb9d8268f2c1cb49e1f4f154458cf56d3e9
/Homework/C++ Programming/2220 Virtual World (eden)/world.h
e4c9285958d40b9a1690cc2c7518e98b01028823
[]
no_license
MegaShow/college-programming
bde5c83f353f727f9bc84426b8c16534848965dd
dc3351e0811b4c3b0738e599c014176c845bd21c
refs/heads/master
2021-07-10T03:57:18.254204
2019-10-26T16:07:21
2019-10-26T16:07:21
114,732,791
3
7
null
2019-10-26T16:07:22
2017-12-19T07:23:03
Jupyter Notebook
UTF-8
C++
false
false
2,088
h
// MegaShow #ifndef WORLD_H_ #define WORLD_H_ #include <iostream> #include <set> #include <map> #include <algorithm> struct person { static int num; const int id; person() :id(num) { num++; } }; int person::num = 0; class group { private: int type; std::map<int, std::set<int> > member; public: group(int _type) :type(_type) {} void displayGroup() { std::map<int, std::set<int> >::iterator it; for(it = member.begin(); it != member.end(); it++) { std::cout << "Person_" << it->first << ":"; std::set<int>::iterator init = it->second.begin(); if(init != it->second.end()) { std::cout << " " << *init; init++; } else { std::cout << " null"; } while(init != it->second.end()) { std::cout << ", " << *init; init++; } std::cout << std::endl; } } bool addMember(person &p) { std::set<int> pset; if(type) { std::map<int, std::set<int> >::iterator it; for(it = member.begin(); it != member.end(); it++) { pset.insert(it->first); it->second.insert(p.id); } } //member[p.id] = *p; std::pair<std::map<int, std::set<int> >::iterator, bool> ret = member.insert(std::map<int, std::set<int> >::value_type(p.id, pset)); return ret.second; } bool deleteMember(person &p) { return member.erase(p.id); } bool makeFriend(person &p1, person &p2) { if(member[p1.id].find(p2.id) != member[p1.id].end()) return false; member[p1.id].insert(p2.id); member[p2.id].insert(p1.id); return true; } bool breakRelation(person &p1, person &p2) { if(member[p1.id].find(p2.id) == member[p1.id].end()) return false; member[p1.id].erase(p2.id); member[p2.id].erase(p1.id); return true; } }; #endif
[ "megaxiu@outlook.com" ]
megaxiu@outlook.com
8cb36d0745ffb7caa5c86de0367701b93e450283
d7ef1300dc1b4d6174788605bf2f19ece12a1708
/other/old_scripts/scripts/MC_true_zarah/K0s_analysis_part1+true_401.cxx
31efd767cfd5c7d6ed2d1f732980db78c00ee1c5
[]
no_license
libov/zeus
388a2d49eb83f098c06008cb23b6ab42ae42e0e5
a0ca857ede59c74cace29924503d78670e10fe7b
refs/heads/master
2021-01-01T05:51:48.516178
2014-12-03T09:14:02
2014-12-03T09:14:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
18,423
cxx
////////////////////////////////////////////////// ////////////// K0s analysis ///////////////// ////////////// with V0lite ///////////////// ////////////// (part1) ///////////////// ////////////////////////////////////////////////// // // // // // Libov Vladyslav // // T.S. National University of Kiev // // April 2008 // // // // // ////////////////////////////////////////////////// ////////// /////////// ////////// Part1: peparing small trees /////////// ////////// /////////// ////////////////////////////////////////////////// // // // 1. Event selection // // 2. K0s selection (loose) // // 3. Writing data to small tree // // easy to analyze // // // ////////////////////////////////////////////////// // Modified 05 September: add true info #ifndef __CINT__ #include <TChain.h> #include <TH1F.h> #include <TFile.h> #include <TTree.h> #include <TClonesArray.h> #include <TROOT.h> #include <TSystem.h> #include <iostream> using namespace std; #include<Daughter.h> #include<Mother.h> #endif void analysis() { Int_t goa=0, nevents=0, Nv0lite=0, Sincand=0, Tt1_id[80], Tt2_id[80], Tq1[80], Tq2[80], Trk_ntracks=0, Trk_id[300], Tt1_layout[80], Tt2_layout[80], Tt1_layinn[80], Tt2_layinn[80]; Float_t Tinvmass_k0[80], Tinvmass_lambda[80], Tinvmass_alambda[80], Tinvmass_ee[80], Tsecvtx_collin3[80], Tsecvtx_collin2[80], Tsecvtx[80][3], reso_mass=0, Tp1[80][3], Tp2[80][3], Tpk[80][3], corr=0, Siq2el[10], Siyel[10], Siyjb[10], Sizuhmom[4][10], Sicalpos[3][10], Sisrtpos[2][10], Sisrtene[10], Siecorr[3][10], Sith[10], Siprob[10]; Int_t Trk_prim_vtx[300], Trk_sec_vtx[300], Trk_vtx[300], Runnr=0, year=0, k0_cand=0; const Int_t low_2004=47010, up_2004=51245, low_2005=52244, up_2005=57123, low_2006=58181, up_2006=59947, low_2006p=60005, up_2006p=61746, low_2007=61747, up_2007=62638; const Float_t corr_2004=1.005, corr_2005=1.009, corr_2006=1.0077, corr_2007=1.0065; Float_t Xvtx=0, Yvtx=0, Zvtx=0; Int_t Tltw[14]; Float_t Cal_et=0; Int_t Kt_njet_a=0; Float_t Kt_etjet_a[20], Kt_etajet_a[20], Kt_phijet_a[20]; Int_t Fmck_nstor=0, // Number of stored (e.g. those survived pT cut) // FMCKIN particles Fmck_prt[500], // particle code FMCPRT Fmck_daug[500]; // Daughter of Float_t Fmck_m[500]; // particle mass Int_t Fmck_id[500]; // particle FMCKIN ID Float_t Fmck_px[500], // particle px Fmck_py[500], // particle py Fmck_pz[500]; // particle pz //TChain *myChain=new TChain("resonance"); TChain *myChain=new TChain("orange"); // PATH to NTUPLES gSystem->Load("libzio.so"); gSystem->Load("libdcap.so"); //------------------------------------------------------------------------------------------// myChain->Add("zeus://acs/mc/ntup/05/v01/dijetPHP/root/dwze25.f13548.lfdir.e0506.uncut_0029.root"); myChain->Add("zeus://acs/mc/ntup/05/v01/dijetPHP/root/dwze25.f13548.lfdir.e0506.uncut_0030.root"); myChain->Add("zeus://acs/mc/ntup/05/v01/dijetPHP/root/dwze25.f13548.lfdir.e0506.uncut_0031.root"); //input //------------------------------------------------------------------------------------------// // V0lite myChain->SetBranchAddress("Nv0lite",&Nv0lite); //myChain->SetBranchAddress("Tinvmass_k0",Tinvmass_k0); //myChain->SetBranchAddress("Tinvmass_lambda",Tinvmass_lambda); //myChain->SetBranchAddress("Tinvmass_alambda",Tinvmass_alambda); myChain->SetBranchAddress("Tinvmass_ee",Tinvmass_ee); myChain->SetBranchAddress("Tsecvtx_collin3",Tsecvtx_collin3); myChain->SetBranchAddress("Tsecvtx_collin2",Tsecvtx_collin2); myChain->SetBranchAddress("Tpk",Tpk); myChain->SetBranchAddress("Tp1",Tp1); myChain->SetBranchAddress("Tp2",Tp2); //myChain->SetBranchAddress("Tq1",Tq1); //myChain->SetBranchAddress("Tq2",Tq2); myChain->SetBranchAddress("Tt1_id",Tt1_id); myChain->SetBranchAddress("Tt2_id",Tt2_id); myChain->SetBranchAddress("Tt1_layout",Tt1_layout); myChain->SetBranchAddress("Tt2_layout",Tt2_layout); myChain->SetBranchAddress("Tt1_layinn",Tt1_layinn); myChain->SetBranchAddress("Tt2_layinn",Tt2_layinn); // Tracking, Trk_vtx myChain->SetBranchAddress("Trk_ntracks",&Trk_ntracks); myChain->SetBranchAddress("Trk_id",Trk_id); myChain->SetBranchAddress("Trk_prim_vtx",Trk_prim_vtx); myChain->SetBranchAddress("Trk_sec_vtx",Trk_sec_vtx); myChain->SetBranchAddress("Trk_vtx",Trk_vtx); //Vertex myChain->SetBranchAddress("Xvtx",&Xvtx); myChain->SetBranchAddress("Yvtx",&Yvtx); myChain->SetBranchAddress("Zvtx",&Zvtx); //Sira, Si_kin myChain->SetBranchAddress("Sincand",&Sincand); myChain->SetBranchAddress("Siq2el",Siq2el); myChain->SetBranchAddress("Siyel",Siyel); myChain->SetBranchAddress("Siyjb",Siyjb); myChain->SetBranchAddress("Sizuhmom",Sizuhmom); //myChain->SetBranchAddress("Siecorr",Siecorr); //myChain->SetBranchAddress("Sith",Sith); myChain->SetBranchAddress("Sicalpos",Sicalpos); myChain->SetBranchAddress("Sisrtpos",Sisrtpos); myChain->SetBranchAddress("Sisrtene",Sisrtene); myChain->SetBranchAddress("Siprob",Siprob); // Event myChain->SetBranchAddress("Runnr",&Runnr); // CAL block - calorimeter info myChain->SetBranchAddress("Cal_et",&Cal_et); // ktJETSA_A myChain->SetBranchAddress("Kt_njet_a",&Kt_njet_a); myChain->SetBranchAddress("Kt_etjet_a",Kt_etjet_a); myChain->SetBranchAddress("Kt_etajet_a",Kt_etajet_a); myChain->SetBranchAddress("Kt_phijet_a",Kt_phijet_a); // FMCKIN (common ntuple additional block) myChain->SetBranchAddress("Fmck_nstor",&Fmck_nstor); myChain->SetBranchAddress("Fmck_prt",Fmck_prt); myChain->SetBranchAddress("Fmck_m",Fmck_m); myChain->SetBranchAddress("Fmck_daug",Fmck_daug); myChain->SetBranchAddress("Fmck_id",Fmck_id); myChain->SetBranchAddress("Fmck_px",Fmck_px); myChain->SetBranchAddress("Fmck_py",Fmck_py); myChain->SetBranchAddress("Fmck_pz",Fmck_pz); // Trigger stuff //myChain->SetBranchAddress("Tltw", Tltw); cout<<"Calculating number of events..."<<endl; nevents=myChain->GetEntries(); cout<<nevents<<" events in this chain..."<<endl; // TREE VARIABLES DEFINITION // these variables are written to tree for further analysis Int_t nv0=0, // number K0s candidates that passed soft selection id1[80], // id of the first track id2[80], // id of the second track runnr=0, // number of run is1_sec[80], // =1 if 1st track flagged as secondary is2_sec[80], // =1 if 2nd track flagged as secondary is1_prim[80], // =1 if 1st track flagged as primary is2_prim[80], // =1 if 2nd track flagged as primary sincand, // Number of Sinistra electron candidates layout1[80], //outer superlayer of 1st pion layout2[80], //outer superlayer of 2nd pion layinn1[80], //inner superlayer of 1st pion layinn2[80]; //inner superlayer of 2nd pion Float_t p1[80][3], // momenta of 1st track p2[80][3], // momenta of 2nd track coll2[80], // angle 2D coll3[80], // collinearity angle 3D q2el, // Q^2 from electron method (1st Sinistra candidate) yel, // y from electron method (1st Sinistra candidate) yjb, // y from Jaquet-Blondel method (1st Sinistra candidate) box_x, // x position of scattered electron box_y, // y position of electron e_pz, // E-pz calculated both from hadronic system and electron siprob, // probability of 1st Sinistra candidate mass_lambda[80],// invariant mass assuming proton(larger momenuma) and pion mass_ee[80]; // invariant mass assuming electron and positron Int_t tlt[6][16]; // 3rd-level trigger: tlt[m][k] // m=3 SPP, m=4 DIS ... k=1 bit 1 (e.g. HPP01) k=2 bit 2 .. Float_t xvtx=0, // coordinates of primary vertex; 0 if none yvtx=0, // zvtx=0; // Float_t cal_et=0; // Transverse Energy =SUM(CALTRU_E*sin(thetai)) Int_t njet=0; // Number of jets (kT jet finder A) Float_t etjet[20], // Transverse energy of jets etajet[20], // eta of jets phijet[20]; // phi of jets Int_t ntrue=0, // Number of stored (e.g. those survived pT cut) // FMCKIN particles fmcprt[50], // FMCPRT daug_of[50]; // Daughter of Float_t mass[50]; // mass Int_t fmckin_id[50]; // FMCKIN ID of the particle Float_t px[50], // px of the particle py[50], // py of the particle pz[50]; // pz of the particle //-------------------------------------------------------------------------------------------// Int_t err=0; Int_t with_V0=0, ev_pass_DIS=0; TH1F *hdebug=new TH1F("hdebug","",10,0,10); cout<<"Start add branches"<<endl; TTree *tree=new TTree("resonance","K0sK0s"); tree->Branch("nv0",&nv0,"nv0/I"); tree->Branch("p1",p1,"p1[nv0][3]/F"); tree->Branch("p2",p2,"p2[nv0][3]/F"); tree->Branch("coll2",coll2,"coll2[nv0]/F"); tree->Branch("coll3",coll3,"coll3[nv0]/F"); tree->Branch("id1",id1,"id1[nv0]/I"); tree->Branch("id2",id2,"id2[nv0]/I"); tree->Branch("is1_sec",is1_sec,"is1_sec[nv0]/I"); tree->Branch("is2_sec",is2_sec,"is2_sec[nv0]/I"); tree->Branch("is1_prim",is1_prim,"is1_prim[nv0]/I"); tree->Branch("is2_prim",is2_prim,"is2_prim[nv0]/I"); tree->Branch("runnr",&runnr,"runnr/I"); tree->Branch("q2el",&q2el,"q2el/F"); tree->Branch("yel",&yel,"yel/F"); tree->Branch("yjb",&yel,"yjb/F"); tree->Branch("siprob",&siprob,"siprob/F"); tree->Branch("sincand",&sincand,"sincand/I"); tree->Branch("box_x",&box_x,"box_x/F"); tree->Branch("box_y",&box_y,"box_y/F"); tree->Branch("e_pz",&e_pz,"e_pz/F"); tree->Branch("mass_lambda",mass_lambda,"mass_lambda[nv0]/F"); tree->Branch("mass_ee",mass_ee,"mass_ee[nv0]/F"); tree->Branch("layout1",layout1,"layout1[nv0]/I"); tree->Branch("layout2",layout2,"layout2[nv0]/I"); tree->Branch("layinn1",layinn1,"layinn1[nv0]/I"); tree->Branch("layinn2",layinn2,"layinn2[nv0]/I"); //tree->Branch("tlt",tlt,"tlt[6][16]/I"); tree->Branch("xvtx",&xvtx,"xvtx/F"); tree->Branch("yvtx",&yvtx,"yvtx/F"); tree->Branch("zvtx",&zvtx,"zvtx/F"); tree->Branch("cal_et",&cal_et,"cal_et/F"); tree->Branch("njet",&njet,"njet/I"); tree->Branch("etjet",&etjet,"etjet[njet]/F"); tree->Branch("etajet",&etajet,"etajet[njet]/F"); tree->Branch("phijet",&phijet,"phijet[njet]/F"); tree->Branch("ntrue",&ntrue,"ntrue/I"); tree->Branch("fmcprt",&fmcprt,"fmcprt[ntrue]/I"); tree->Branch("mass",&mass,"mass[ntrue]/F"); tree->Branch("daug_of",&daug_of,"daug_of[ntrue]/I"); tree->Branch("fmckin_id",&fmckin_id,"fmckin_id[ntrue]/I"); tree->Branch("px",&px,"px[ntrue]/F"); tree->Branch("py",&py,"py[ntrue]/F"); tree->Branch("pz",&pz,"pz[ntrue]/F"); //------ Loop over events -------// char name[256]; Int_t file_num=0; bool fire; cout<<"Start looping..."<<endl; for(Int_t i=0;i<nevents;i++) { if (goa==10000) { cout<<i<<" events processed"<<" Runnr:"<<Runnr<<endl; goa=0; } goa++; //cout<<"Getting entry "<<i<<" ..."<<endl; myChain->GetEntry(i); //cout<<"event "<<i<<endl; //------DIS event selection------// hdebug->Fill(1); //if (Siq2el[0]<1) continue; // Q^2>1 GeV^2 hdebug->Fill(2); // E-pz calculation float Empz_had = Sizuhmom[0][3] - Sizuhmom[0][2]; float Empz_e = Siecorr[0][2]*(1-TMath::Cos( Sith[0] )); float EminPz_Evt = Empz_e + Empz_had; //if ((EminPz_Evt<38)||(EminPz_Evt>60)) continue; // 38 < E-pz < 60 GeV hdebug->Fill(3); // electron position calculation (box cut) float x_srtd=Sicalpos[0][0]; // position of electron in calorimeter float y_srtd=Sicalpos[0][1]; if (Sisrtene[0]>0) { x_srtd=Sisrtpos[0][0]; // position of electron in SRDT y_srtd=Sisrtpos[0][1]; } //if (TMath::Abs(x_srtd)<12) // box cut: electron required to be outside 12x6 cm^2 box { //if (TMath::Abs(y_srtd)<6) continue; } hdebug->Fill(4); //if (Siyel[0]>0.95) continue; // y from electron method < 0.95 hdebug->Fill(5); //if (Siyjb[0]<0.01) continue; // y from Jacquet-Blondel method > 0.01 hdebug->Fill(6); ev_pass_DIS++; //------ (soft) K0s selection------// Int_t cand_k0=0, list_k0[180]; if (Nv0lite<1) continue; with_V0++; if (Nv0lite>75) cout<<Nv0lite<<endl; //this loop is now sensless but it will become necessary if we restrict to at least 2K0s for(Int_t j=0;j<Nv0lite;j++) { Daughter t1(Tp1[j][0],Tp1[j][1],Tp1[j][2]); Daughter t2(Tp2[j][0],Tp2[j][1],Tp2[j][2]); if ((t1.GetPt()<0.1)||(t2.GetPt()<0.1)) continue; if ((Tt1_layout[j]<3)||(Tt2_layout[j]<3)) continue; Mother K0s_cand(t1,t2); Float_t p1=t1.GetP(); Float_t p2=t2.GetP(); Float_t mass_pi_p=0; if (p1>=p2) //first track proton(antiproton); second track pion_minus(pion_plus) { mass_pi_p=K0s_cand.GetMass_m(6,4); //if(Tq1[j]>0) cout<<"Lambda"<<endl; //if(Tq1[j]<0) cout<<"ALambda"<<endl; } if (p1<p2) //first track pion_minus(pion_plus); first track proton(antiproton); { mass_pi_p=K0s_cand.GetMass_m(4,6); //if(Tq1[j]>0) cout<<"ALambda"<<endl; //if(Tq1[j]<0) cout<<"Lambda"<<endl; } //cout<<mass_pi_p<<" "<<Tinvmass_lambda[j]<<" "<<Tinvmass_alambda[j]<<endl; //if (mass_pi_p<1.116) continue; //mass_lambda=mass_pi_p; //mass_ee=Tinvmass_ee[j]; //if (Tinvmass_ee[j]<0.05) continue; Int_t take1=1, take2=1; for (Int_t n=0; n<Trk_ntracks; n++) { unsigned int idx=Trk_id[n]; if (idx == Tt1_id[j]) { take1=Trk_prim_vtx[n]; continue; } if (idx == Tt2_id[j]) { take2=Trk_prim_vtx[n]; continue; } } //if ((take1==1)||(take2==1)) continue; list_k0[cand_k0]=j; cand_k0++; } //end k0 selection if (Trk_ntracks>295) cout<<Trk_ntracks<<endl; if (cand_k0<1) continue; nv0=cand_k0; if (nv0>75) cout<<nv0<<endl; Int_t id=0; //---- Tree filling -----// for(Int_t k=0;k<nv0;k++) { id=list_k0[k]; p1[k][0]=Tp1[id][0]; p1[k][1]=Tp1[id][1]; p1[k][2]=Tp1[id][2]; p2[k][0]=Tp2[id][0]; p2[k][1]=Tp2[id][1]; p2[k][2]=Tp2[id][2]; coll2[k]=Tsecvtx_collin2[id]; coll3[k]=Tsecvtx_collin3[id]; id1[k]=Tt1_id[id]; id2[k]=Tt2_id[id]; Int_t t1_prim=1, t2_prim=1, t1_sec=0, t2_sec=0, t1_vertex_id=-1, t2_vertex_id=-1; for (Int_t n=0; n<Trk_ntracks; n++) { unsigned int idx=Trk_id[n]; if (idx == Tt1_id[id]) { t1_prim=Trk_prim_vtx[n]; t1_sec=Trk_sec_vtx[n]; t1_vertex_id=Trk_vtx[n]; continue; } if (idx == Tt2_id[id]) { t2_prim=Trk_prim_vtx[n]; t2_sec=Trk_sec_vtx[n]; t2_vertex_id=Trk_vtx[n]; continue; } } is1_sec[k]=t1_sec; is2_sec[k]=t2_sec; is1_prim[k]=t1_prim; is2_prim[k]=t2_prim; Daughter temp1(Tp1[id][0],Tp1[id][1],Tp1[id][2]); Daughter temp2(Tp2[id][0],Tp2[id][1],Tp2[id][2]); Mother K0s_candtemp(temp1,temp2); Float_t ptemp1=temp1.GetP(); Float_t ptemp2=temp2.GetP(); Float_t mass_pi_ptemp=0; if (ptemp1>ptemp2) //first track proton(antiproton); second track pion_minus(pion_plus) { mass_pi_ptemp=K0s_candtemp.GetMass_m(6,4); } if (ptemp1<ptemp2) //first track pion_minus(pion_plus); first track proton(antiproton); { mass_pi_ptemp=K0s_candtemp.GetMass_m(4,6); } mass_lambda[k]=mass_pi_ptemp; mass_ee[k]=Tinvmass_ee[id]; layout1[k]=Tt1_layout[id]; layout2[k]=Tt2_layout[id]; layinn1[k]=Tt1_layinn[id]; layinn2[k]=Tt2_layinn[id]; } runnr=Runnr; if (Sincand>0) { q2el=Siq2el[0]; siprob=Siprob[0]; } if (Sincand==0) { q2el=0; siprob=0; } sincand=Sincand; //cout<<Sincand<<" "<<Siyel[0]<<" "<<Siyjb[0]<<endl; yel=Siyel[0]; yjb=Siyjb[0]; box_x=x_srtd; box_y=y_srtd; e_pz=EminPz_Evt; cal_et=Cal_et; /* // trigger defining for (int m=0;m<6;m++) { for (int k=0;k<16;k++) { fire = (Bool_t)(Tltw[m+6-1] & (1 << k) ); //tlt[m][k]=2; tlt[m][k]=0; if (fire) { tlt[m][k]=1; //cout<<m<<", bit"<<k+1<<" fired"<<endl; } } } */ xvtx=Xvtx; yvtx=Yvtx; zvtx=Zvtx; njet=Kt_njet_a; for (int jet=0;jet<njet;jet++) { etjet[jet]=Kt_etjet_a[jet]; etajet[jet]=Kt_etajet_a[jet]; phijet[jet]=Kt_phijet_a[jet]; } bool kshort=false, pi_plus=false, pi_minus=false, pi=false, f0980=false, daug_of_kshort=false; ntrue=0; for (int k=0;k<Fmck_nstor;k++) { // particle k identification kshort=false; pi_plus=false; pi_minus=false; f0980=false; daug_of_kshort=false; kshort=(Fmck_prt[k]==62); pi_plus=(Fmck_prt[k]==54); pi_minus=(Fmck_prt[k]==55); pi=(pi_plus||pi_minus); f0980=(Fmck_prt[k]==81); if (pi) { Int_t parent_fmckin=0; parent_fmckin=Fmck_daug[k]; // Fmckin id of mother of k //cout<<"Parent of pi+/pi-: "<<parent_fmckin<<endl; for (int jj=0;jj<Fmck_nstor;jj++) { //cout<<Fmck_id[jj]<<endl; if (Fmck_id[jj]!=parent_fmckin) continue; // skip if not of mother of k //cout<<Fmck_prt[jj]<<endl; // now jj is index of mother of particle k daug_of_kshort=(Fmck_prt[jj]==62); //cout<<"Parent of pi+/pi-: "<<parent_fmckin<<endl; break; } } if (f0980||kshort||((pi_plus||pi_minus)&&daug_of_kshort)) { fmcprt[ntrue]=Fmck_prt[k]; mass[ntrue]=Fmck_m[k]; daug_of[ntrue]=Fmck_daug[k]; fmckin_id[ntrue]=Fmck_id[k]; px[ntrue]=Fmck_px[k]; py[ntrue]=Fmck_py[k]; pz[ntrue]=Fmck_pz[k]; ntrue++; } } tree->Fill(); } //------- End of events loop ---------// tree->Print(); Int_t temp=sprintf(name,"batch401.root");//output TFile *f2 =new TFile(name,"recreate"); cout<<"File created"<<endl; tree->Write(); cout<<"Tree wrote"<<endl; f2->Close(); cout<<"File Closed"<<endl; delete tree; cout<<"Tree deleted, O.K.!"<<endl; cout<<ev_pass_DIS<<" events passed DIS selection"<<endl; cout<<with_V0<<" events with at least 1 V0"<<endl; cout<<"Done!!!"<<endl; } #ifndef __CINT__ int main(int argc, char **argv) { analysis(); return 0; } #endif
[ "libov@mail.desy.de" ]
libov@mail.desy.de
107375202fcfb27296b1d8fe68c0bff56540749c
cbf9d42397cc2bda21d2451d576c6e0307666243
/src/RodinExternal/MMG/MeshPrinter.h
8e7cabcedf18df7063457ab419dc3aba45d22824
[ "BSL-1.0" ]
permissive
cbritopacheco/rodin
272bd34b8d91ec825934a617d1fea751786a9632
a64520db90ac444b7ce61ca353aa9fe85e4868d0
refs/heads/master
2023-08-21T20:19:35.539806
2023-08-14T20:36:37
2023-08-14T20:36:37
422,234,328
24
5
BSL-1.0
2023-08-14T18:42:04
2021-10-28T14:22:55
C++
UTF-8
C++
false
false
720
h
/* * Copyright Carlos BRITO PACHECO 2021 - 2022. * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE or copy at * https://www.boost.org/LICENSE_1_0.txt) */ #ifndef RODIN_EXTERNAL_MMG_MESHPRINTER_H #define RODIN_EXTERNAL_MMG_MESHPRINTER_H #include "Rodin/IO/Printer.h" #include "Mesh.h" namespace Rodin::External::MMG { class MeshPrinter : public IO::Printer<MMG::Mesh> { public: MeshPrinter(const MMG::Mesh& mesh) : m_mesh(mesh) {} void print(std::ostream& os) override; const MMG::Mesh& getObject() const override { return m_mesh; } private: const MMG::Mesh& m_mesh; }; } #endif
[ "carlos.brito524@gmail.com" ]
carlos.brito524@gmail.com
973673df87120a554e4b8ebcb24776c27303a949
dd1b4089f638d801698e34b830b2767149b665f6
/VetoSim/Script/AddVETO_July/Reconstruction/Reconstruct.h
a43173342eeca6f8d94248ae31242a440e928cd5
[]
no_license
ChristiaanAlwin/NeuLAND_Veto
d1c1b41cfb1f4ade2de664188da615b2541d3e7b
ed06682b03b1bd6b2c7ecc2f3be7c62036ef45ee
refs/heads/master
2021-01-05T19:02:08.598882
2020-02-17T13:55:17
2020-02-17T13:55:17
241,109,623
2
0
null
null
null
null
UTF-8
C++
false
false
8,099
h
void R3BNeuLANDTracker::Reconstruct() { // This function actually performs the reconstrcution of the NeuLAND Vertices. // It is basically the AdvanchedMethod()-function of the old tracker which has // undergone some cosmetic changes (and a few upgrades). // The general procedure is that we loop over all clusters. As a first change, we // will now only take clusters that haven't been eliminated. From the clusters // that have not been eliminated, we will test them pairswise whether they can come // from elastic scattering yes/no. Clusters that can come from elastic scattering are marked. // Then the UNmarked clusters are sorted by their relativistic beta. Then the // sorted & UNmarked clusters are divided into groups. The first staring point // of each group becomes a vertex. This is how we do the reconstruction. // =========================================================================================== // The first step: marking the clusters: Double_t c = 29.9792458; Double_t Mneutron = 939.565379; // Neutron mass [MeV]. Int_t NClusters = fArrayClusters->GetEntries(); R3BNeuLANDCluster* cluster1; R3BNeuLANDCluster* cluster2; Bool_t WeMarked = kFALSE; Bool_t Elastic = kFALSE; // Set the counter for the vertices to zero: fNVertices = 0; // loop over pairs of clusters: for (Int_t k1 = 0; k1<NClusters; ++k1) { // load the first cluster: cluster1 = (R3BNeuLANDCluster*) fArrayClusters->At(k1); // Only do something if this cluster has at least size 2 // And if it is not eliminated: if ((cluster1->GetSize()>1)&&(!(cluster1->IsEliminated()))) { // Now we only want to mark only once per k1-turn. Reset: WeMarked = kFALSE; // Loop over all clusters we haven't done yet: for (Int_t k2 = k1+1; k2<NClusters; ++k2) { // But we should only do something if we haven't marked // something yet inside this loop: if (!WeMarked) { // load the second cluster: cluster2 = (R3BNeuLANDCluster*) fArrayClusters->At(k2); // Test for elastic scattering: Elastic = IsElastic(cluster1,cluster2); // If this worked, then mark if the second cluster was // not eliminated: if ((Elastic)&&(!(cluster2->IsEliminated()))) { WeMarked = kTRUE; cluster2->Mark(); } // Done, so close all loops: } } } } // So now we marked the clusters. The next step is to sort them according to // their relativistic beta. For that, we put all UNmarked & not eliminated // clusters inside an std::vector and then sort them. // NOTE: If I read the code correctly, then all marked clusters should NOT // be in the vector, only unmarked clusters! for (Int_t k = 0; k<NClusters; ++k) { // load the cluster: cluster1 = (R3BNeuLANDCluster*) fArrayClusters->At(k); // Check if teh cluster is eliminated: if (cluster1->IsEliminated()==kFALSE) { // Now check if the cluster is marked. // NOTE: unmarked clusters should be put in the vector! if (cluster1->IsMarked()==kFALSE) { fVectorClusters.push_back(cluster1); } } } // so now we have our vector with clusters. Sort them: fNClustersSorted = fVectorClusters.size(); if (fNClustersSorted>1) { std::sort(fVectorClusters.begin(), fVectorClusters.end(), AuxSortClustersBeta); // NOTE: AuxSortClustersBeta is the auxillary sorting function that we wrote just for that! } // So now we have our vector with sorted clusters. If a cluster from this vector passes our tests, // it can become a neutron vertex. But no more vertices are created then there are neutrons. // Check that we have clusters to work with: if (fNClustersSorted>0) { // Define an array to keep track of the clusters that we already used: Bool_t* Used = new Bool_t[fNClustersSorted]; // And a variable to keep track whether we reconstructed or not: Bool_t FoundCluster = kFALSE; // We also need some other variables: Double_t time = 0.0; Double_t xx = 0.0; Double_t yy = 0.0; Double_t zz = 0.0; Double_t Travel_Dist = 0.0; Double_t BeamTime = 0.0; Double_t beta = 0.0; Double_t gamma = 0.0; Double_t Ekin = 0.0; // Set is to false: for (Int_t k = 0; k<fNClustersSorted; ++k) { Used[k] = kFALSE; } // Now redo our procedure as often as we need for the number of neutrons: for (Int_t kneutron = 0; kneutron<fNeutronNumber; ++kneutron) { // Reset: FoundCluster = kFALSE; // loop over all clusters in the vector: for (Int_t kcluster = 0; kcluster<fNClustersSorted; ++kcluster) { // Load the cluster: cluster1 = (R3BNeuLANDCluster*) fVectorClusters.at(kcluster); // As a first test: check if the cluster // is used already for the previous vertex, or if we already // found a cluster for this vertex: if ((Used[kcluster]==kFALSE)&&(FoundCluster==kFALSE)) { // Then it is not used. As the next step, check if there // is enough energy in the cluster: if (cluster1->GetE()>2.5) { // Now there is enough energy in the cluster. // Now also check if the beta of the cluster is OK: xx = cluster1->GetStartX(); yy = cluster1->GetStartY(); zz = cluster1->GetStartZ(); Travel_Dist = TMath::Sqrt((xx - fTarget_Xpos)*(xx - fTarget_Xpos) + (yy - fTarget_Ypos)*(yy - fTarget_Ypos) + (zz - fTarget_Zpos)*(zz - fTarget_Zpos)); BeamTime = TMath::Sqrt((fTarget_Xpos - fBeam_Xpos)*(fTarget_Xpos - fBeam_Xpos) + (fTarget_Ypos - fBeam_Ypos)*(fTarget_Ypos - fBeam_Ypos) + (fTarget_Zpos - fBeam_Zpos)*(fTarget_Zpos - fBeam_Zpos)); BeamTime= BeamTime/(fBeamBeta*c); time = cluster1->GetStartT() - BeamTime; beta = Travel_Dist/(time*c); // We now know the beta, check for it: if (TMath::Abs(beta-fBeamBeta)<(0.05*600./fBeamEnergy)) { // Then we also passed the beta-test. Hence we can now use this // cluster to create a vertex. First reconstruct the energy: if (beta<0.0) {beta = 0.0; cout << "### ERROR: beta smaller then zero!\n";} if (beta>=1.0) {beta = 0.999; cout << "### ERROR: superliminal vertex found!\n";} gamma = 1.0/TMath::Sqrt(1.0 - beta*beta); Ekin = (gamma - 1.0)*Mneutron; // Now create the vertex: new ((*fArrayVertices)[fNVertices]) R3BNeuLANDVertex(cluster1,Ekin); // Update the counters: fNVertices = fNVertices + 1; Used[kcluster] = kTRUE; FoundCluster = kTRUE; // That's it. We now succesfully creatd our vertices! // close the loops: } } } } } if (fNVertices>fNeutronNumber) {cout << "### ERROR: Too many verices in event " << fEventCounter << "\n";} // One more thing: every new goes with a delete: delete Used; } // Finished the reconstruction! }
[ "Christiaan90518@gmail.com" ]
Christiaan90518@gmail.com
5d3590af92d09d2dea3ed549d5cc3ea3f7383762
16a1bc97195d09349cb7d9783d410f683411a99b
/src/KeepLane.h
91f74c3bfb986b6a0b4f91db8f3c70b8e9cd59f3
[ "MIT" ]
permissive
hanna-becker/CarND-Path-Planning-Project
643ed95e9fd24823f13b47002cd1c51103086ff5
b2a0f18a45a924be8e3c2e73980c8b3c2427cbcb
refs/heads/master
2020-04-29T13:15:22.874614
2019-03-30T13:29:12
2019-03-30T13:39:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
342
h
#ifndef PATH_PLANNING_OFF_H #define PATH_PLANNING_OFF_H #include "State.h" class KeepLane : public State { public: explicit KeepLane(int &intendedLaneId); ~KeepLane() = default; void changeLaneLeft(FSM *m, int &currentLaneId) override; void changeLaneRight(FSM *m, int &currentLaneId) override; }; #endif //PATH_PLANNING_OFF_H
[ "hanna.e.becker@gmail.com" ]
hanna.e.becker@gmail.com
22e7b40c6eab25704a512083911aeaa8e9c569fb
3f757e7690a84cc91e7fbe54d99bc1359716c672
/Engine/Game.h
6f1f730f6e7572fd7f1d0041248587f8802083ab
[]
no_license
scottxen/chili_snake
af62cefc91cb5b8ef7bf47a233e262e2f28106b4
f49e0eb78e6b3c73015f0d586d9947e0cc3af88a
refs/heads/master
2020-04-05T13:10:53.607278
2018-11-09T16:31:51
2018-11-09T16:31:51
156,890,344
0
0
null
null
null
null
UTF-8
C++
false
false
2,181
h
/****************************************************************************************** * Chili DirectX Framework Version 16.07.20 * * Game.h * * Copyright 2016 PlanetChili.net <http://www.planetchili.net> * * * * This file is part of The Chili DirectX Framework. * * * * The Chili DirectX Framework is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * The Chili DirectX Framework is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with The Chili DirectX Framework. If not, see <http://www.gnu.org/licenses/>. * ******************************************************************************************/ #pragma once #include "Keyboard.h" #include "Mouse.h" #include "Graphics.h" #include "Board.h" #include "Snake.h" #include "Goal.h" #include <random> class Game { public: Game( class MainWindow& wnd ); Game( const Game& ) = delete; Game& operator=( const Game& ) = delete; void Go(); void Restart(); private: void ComposeFrame(); void UpdateModel(); /********************************/ /* User Functions */ /********************************/ private: MainWindow& wnd; Graphics gfx; /********************************/ /* User Variables */ Board brd; Snake snek; Location delta_loc = { 1,0 }; std::mt19937 rng; Goal goal; int snekMoveCounter = 0; bool gameStarted = false; bool gameIsOver = false; int snekMovePeriod = 20; int frameCount = 0; static constexpr Location boardLocation { 20, 20 }; /********************************/ };
[ "iain.s.caldwell@gmail.com" ]
iain.s.caldwell@gmail.com
e418c026f6b000f3ba234a9d1bb8fe90f0f3efc6
6b559f93b401b84d31e18a040864f2b1ea049682
/SendTask.cc
bc295940e3347ad42c61b629f56dc8e7423c4e6f
[]
no_license
fU9ANg/card
f4c499d608e378b04610ce4eb844b092c551b560
4add80c7081149808145e262cefaac358e5af8ef
refs/heads/master
2021-01-13T01:44:45.512409
2013-12-23T12:40:39
2013-12-23T12:40:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,767
cc
#include "SendTask.h" int SendTask::work () { while (true) { Buffer* p = NULL; if (GLOBAL->sendqueue.dequeue (p, 3) != 0) { continue; } int fd = p->getfd (); if (0 == fd) { cout << "[SEND] -- fd of Buffer == 0" << endl; GLOBAL->bufpool.free (p); continue; } // #if 0 cout << "Send cType: " << ((MSG_HEAD*)p->ptr())->cType <<endl; printf ("address: %p\n", p); if (((MSG_HEAD*)p->ptr())->cType == 187) { cout << "-----------------------BEGIN-------------------------------------" << endl; cout << "CTYPE: " << ((MSG_HEAD*) (p->ptr()))->cType << endl; cout << "LEN: " << *(unsigned int*) ((char*)p->ptr() + MSG_HEAD_LEN) << endl; cout << "STUDENT_ID: " << *(unsigned int*) ((char*)p->ptr() + MSG_HEAD_LEN + sizeof (unsigned int)) << endl; cout << "STATUS: " << *(unsigned int*) ((char*)p->ptr() + MSG_HEAD_LEN + sizeof (int) + sizeof (int)) << endl; cout << "STUDENT_ID: " << *(unsigned int*) ((char*)p->ptr() + MSG_HEAD_LEN + sizeof (int) + sizeof (int) + sizeof (int)) << endl; cout << "STATUS: " << *(unsigned int*) ((char*)p->ptr() + MSG_HEAD_LEN + sizeof (int) + sizeof (int)+ sizeof (int) + sizeof (int)) << endl; cout << "-------------------------END-----------------------------------" << endl; } #endif // send fck message to clients // must be need written bytes data finished debugProtocol (p); int bytes_left = p->size (); int written_bytes; char* ptr = (char*) p->ptr(); while (bytes_left > 0) { written_bytes = send (fd, ptr, bytes_left, 0); if (written_bytes <= 0) { if (errno == EINTR) { if (written_bytes < 0) { written_bytes = 0; continue; } } else if (errno == EAGAIN) { if (written_bytes < 0) { written_bytes = 0; usleep (50); continue; } } else { break; } } bytes_left -= written_bytes; ptr += written_bytes; } ///printf("Send data...finished. packetLength=%ld, from FD=[%d]\n", p->size(), fd); LOG(INFO) << "Send data ... finished. packet len=" << p->size() << ", from FD=" << fd << endl; p->reset (); GLOBAL->bufpool.free (p); } return (0); } SendTask::SendTask () { // TODO: } SendTask::~SendTask () { // TODO: }
[ "bb.newlife@gmail.com" ]
bb.newlife@gmail.com
e7c84ce1e053e6dc09d273578de67c329d86d4e1
b21a7616ec39e53c4c5d596c32fc2e6c6f3d5273
/Reverse/HW-02/09/solve.cpp
009d424b06120b1976d91d1c87ad72a1e281c9f0
[]
no_license
vladrus13/ITMO
d34fbd5feee0626c0fe5722b79dd928ee2a3f36a
c4ff564ea5f73e02354c0ae9248fee75df928b4e
refs/heads/master
2022-02-23T03:13:36.794460
2022-02-10T22:24:16
2022-02-10T22:24:16
177,217,313
17
9
null
2020-08-07T15:06:37
2019-03-22T22:33:18
Java
UTF-8
C++
false
false
1,695
cpp
/// what about the useless text at the beginning // of the program? /// I like to do useless things. // The program is made by vladrus13 (2018) // Do you want to optimize? #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <algorithm> #include <vector> #include <cmath> #include <deque> #include <string> #include <vector> #include <cmath> #include <queue> #include <map> #include <string> #include <set> #include <queue> #include <iomanip> #include <bitset> #include <cassert> #include <random> #include <stdexcept> #include <stdio.h> typedef long double ld; typedef int64_t ll; typedef uint64_t ull; typedef int32_t int32; using namespace std; //#pragma comment (linker, "/STACK:5000000000") #define INF (int)2e9; #define MOD (int)1e9+7; ////////////////////////////////////////////////////////////////// // SYSTEM STARTS ////////////////////////////////////////////////////////////////// // UTILS ///////////////////////////////////////////////////////////////// // MAIN void check(string s) { int accum = 117; for (int i = 0; i < s.size(); i++) { accum = ((s[i] + 1) * accum) % 256; } if (accum == 118) { cout << s << endl; } } void rec(string s, int length) { if (length == 0) { check(s); } else { for (char i = 'a'; i <= 'z'; i++) { rec(s + i, length - 1); } } } int main() { // begin of my useless prog #ifdef _DEBUG freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else freopen("nfc.in", "r", stdin); freopen("nfc.out", "w", stdout); #endif ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); for (int len = 1; len < 6; len++) { rec("", len); } }
[ "vladrus13rus@yandex.ru" ]
vladrus13rus@yandex.ru
003933d1cbd6aab623ddf3716454f69021148987
2248658cdf230eba7cbfe6e362d7999632f61414
/Project/GDNative/src/gdlibrary.cpp
b8596d01607d57191770e1201c0cc55984b38d61
[]
no_license
blockspacer/ThornBack
7e0bbe6869a7fd9726bc342f71c3d6739ef4d867
c71aa1463080879b5632fd2ebfa2ae3fd1959b4b
refs/heads/master
2020-12-06T21:28:43.970783
2019-10-09T07:20:26
2019-10-09T07:20:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
723
cpp
#include <Godot.hpp> #include "Chunk.h" #include "ChunkLoader.h" #include "WorldData.h" #include "BlockLibrary.h" #include "ItemLibrary.h" extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) { godot::Godot::gdnative_init(o); } extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) { godot::Godot::gdnative_terminate(o); } extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) { godot::Godot::nativescript_init(handle); godot::register_class<godot::Chunk>(); godot::register_class<godot::ChunkLoader>(); godot::register_class<godot::WorldData>(); godot::register_class<godot::BlockLibrary>(); godot::register_class<godot::ItemLibrary>(); }
[ "misabiko@gmail.com" ]
misabiko@gmail.com
a12eea34bc25f9ae8d2f33ccfb1a6968251c1408
6ac6480a447558cdcefb829f7ed418776e1339a8
/Jaffe/src/Layers/accuracy_layer.cpp
e018fb944cda413b2255bafa3152b5853fb1bf7d
[]
no_license
bluuuuer/Jaffe
d1018b6369c503f66300047b4dabd85eee16fb0e
c468440b17b41152d7a1db578722a644728a25a1
refs/heads/master
2021-01-10T14:12:52.526933
2016-04-02T13:05:44
2016-04-02T13:05:44
54,958,942
2
2
null
2016-04-02T12:36:33
2016-03-29T08:28:42
C++
UTF-8
C++
false
false
499
cpp
#include "loss_layers.h" namespace jaffe { template class JAccuracyLayer <int>; template class JAccuracyLayer <float>; template <typename Dtype> bool JAccuracyLayer<Dtype>::Init(const vector<string> param){ SetParam(param); return true; } template <typename Dtype> bool JAccuracyLayer<Dtype>::SetParam(const vector<string> param){ return m_param->SetParam(param); } template <typename Dtype> bool JAccuracyLayer<Dtype>::Show(){ return m_param->Show(); } } // namespace jaffe
[ "xuwei1993@qq.com" ]
xuwei1993@qq.com
a943ad237d35e8491bb3a6c8352daf93d79a1252
cbd2a87e64c0338e5c0a0ef4f98dccfb8452c687
/test/nmea/Test_nmea_vtg.cpp
2b89d2fbd427217c72738f3f117ca750e5a32c60
[ "BSD-3-Clause", "BSD-4-Clause" ]
permissive
mb12/marnav
194c87279e8aa329d530ee9b7125b7fdc64bf4f2
4eb797488c734c183c2a4e4c22158891cd80d2e8
refs/heads/master
2021-01-24T23:34:31.791011
2016-01-11T10:52:25
2016-01-11T10:52:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,476
cpp
#include <gtest/gtest.h> #include <marnav/nmea/vtg.hpp> #include <marnav/nmea/nmea.hpp> #include "type_traits_helper.hpp" namespace { using namespace marnav; class Test_nmea_vtg : public ::testing::Test { }; TEST_F(Test_nmea_vtg, contruction) { EXPECT_NO_THROW(nmea::vtg vtg); } TEST_F(Test_nmea_vtg, properties) { nmea_sentence_traits<nmea::vtg>(); } TEST_F(Test_nmea_vtg, parse) { auto s = nmea::make_sentence("$GPVTG,,T,,M,,N,,K,N*2C"); ASSERT_NE(nullptr, s); auto vtg = nmea::sentence_cast<nmea::vtg>(s); ASSERT_NE(nullptr, vtg); } TEST_F(Test_nmea_vtg, parse_invalid_number_of_arguments) { EXPECT_ANY_THROW(nmea::vtg::parse("@@", {7, "@"})); EXPECT_ANY_THROW(nmea::vtg::parse("@@", {10, "@"})); } TEST_F(Test_nmea_vtg, empty_to_string) { nmea::vtg vtg; EXPECT_STREQ("$GPVTG,,,,,,,,,*7E", nmea::to_string(vtg).c_str()); } TEST_F(Test_nmea_vtg, set_speed_kn) { nmea::vtg vtg; vtg.set_speed_kn(12.5); EXPECT_STREQ("$GPVTG,,,,,12.5,N,,,*28", nmea::to_string(vtg).c_str()); } TEST_F(Test_nmea_vtg, set_speed_kmh) { nmea::vtg vtg; vtg.set_speed_kmh(22.5); EXPECT_STREQ("$GPVTG,,,,,,,22.5,K,*2E", nmea::to_string(vtg).c_str()); } TEST_F(Test_nmea_vtg, set_track_magn) { nmea::vtg vtg; vtg.set_track_magn(12.5); EXPECT_STREQ("$GPVTG,,,12.5,M,,,,,*2B", nmea::to_string(vtg).c_str()); } TEST_F(Test_nmea_vtg, set_track_true) { nmea::vtg vtg; vtg.set_track_true(12.5); EXPECT_STREQ("$GPVTG,12.5,T,,,,,,,*32", nmea::to_string(vtg).c_str()); } }
[ "mario.konrad@gmx.net" ]
mario.konrad@gmx.net
acbaf90358ef0e4e82c2279c6362f6ab5a280050
18e2f5b9de8c2a8ba8dba0e9e96f8dbdb1c7e01d
/charts/doogie-0.7.8/src/download.cc
4096a2ffa1f17a310a9b4c307395b6f96745f529
[ "MIT" ]
permissive
hyq5436/playground
f544b2d77042c85d2e6e321e044918eaa65e3743
828b9d2266dbb7d0311e2e73b295fcafb101d94f
refs/heads/master
2021-06-19T16:35:12.188195
2021-01-27T03:07:59
2021-01-27T03:07:59
172,729,316
2
0
null
null
null
null
UTF-8
C++
false
false
4,177
cc
#include "download.h" #include "sql.h" namespace doogie { QList<Download> Download::Downloads() { QList<Download> ret; QSqlQuery query; if (!Sql::Exec(&query, "SELECT * FROM download ORDER BY start_time")) { return ret; } while (query.next()) ret.append(Download(query.record())); return ret; } bool Download::ClearDownloads(QList<qlonglong> exclude_ids) { QString sql = "DELETE FROM download"; if (!exclude_ids.isEmpty()) { sql += " WHERE id NOT IN ("; for (int i = 0; i < exclude_ids.size(); i++) { if (i > 0) sql += ","; sql += QString::number(exclude_ids[i]); } sql += ")"; } QSqlQuery query; return Sql::Exec(&query, sql); } Download::Download() {} Download::Download(CefRefPtr<CefDownloadItem> item, CefRefPtr<CefDownloadItemCallback> update_callback) : update_callback_(update_callback) { FromCef(item); } Download::Download(CefRefPtr<CefDownloadItem> item, const QString& suggested_file_name) { FromCef(item); suggested_file_name_ = suggested_file_name; } void Download::Cancel() { if (update_callback_) update_callback_->Cancel(); current_state_ = Canceled; } void Download::Pause() { if (update_callback_) update_callback_->Pause(); } void Download::Resume() { if (update_callback_) update_callback_->Resume(); } bool Download::Persist() { QSqlQuery query; if (Exists()) { if (end_time_.isNull()) return true; return Sql::ExecParam( &query, "UPDATE download SET end_time = ?, success = ? " "WHERE id = ?", { end_time_.toSecsSinceEpoch(), current_state_ == Complete, db_id_ }); } auto ok = Sql::ExecParam( &query, "INSERT INTO download ( " " mime_type, orig_url, url, path, " " success, start_time, size " ") VALUES (?, ?, ?, ?, ?, ?, ?)", { mime_type_, orig_url_, url_, path_, current_state_ == Complete, start_time_.toSecsSinceEpoch(), total_bytes_ }); if (!ok) return false; db_id_ = query.lastInsertId().toLongLong(); return true; } bool Download::Delete() { if (!Exists()) return false; QSqlQuery query; return Sql::ExecParam(&query, "DELETE FROM download WHERE id = ?", { db_id_ }); } Download::Download(const QSqlRecord& record) { db_id_ = record.value("id").toLongLong(); mime_type_ = record.value("mime_type").toString(); orig_url_ = record.value("orig_url").toString(); url_ = record.value("url").toString(); path_ = record.value("path").toString(); start_time_ = QDateTime::fromSecsSinceEpoch( record.value("start_time").toLongLong(), Qt::UTC); auto end_secs = record.value("end_time").toLongLong(); if (end_secs > 0) { end_time_ = QDateTime::fromSecsSinceEpoch(end_secs, Qt::UTC); } total_bytes_ = record.value("total_bytes").toLongLong(); // We have to set as complete or canceled when coming from the DB current_state_ = record.value("success").toBool() ? Complete : Canceled; } void Download::FromCef(CefRefPtr<CefDownloadItem> item) { live_id_ = item->GetId(); mime_type_ = QString::fromStdString(item->GetMimeType().ToString()); orig_url_ = QString::fromStdString(item->GetOriginalUrl().ToString()); url_ = QString::fromStdString(item->GetURL().ToString()); suggested_file_name_ = QString::fromStdString(item->GetSuggestedFileName().ToString()); path_ = QString::fromStdString(item->GetFullPath().ToString()); current_state_ = item->IsCanceled() ? Download::Canceled : (item->IsComplete() ? Download::Complete : (item->IsInProgress() ? Download::InProgress : Download::Unknown)); start_time_ = QDateTime::fromSecsSinceEpoch(item->GetStartTime().GetTimeT(), Qt::UTC); if (item->GetEndTime().GetTimeT() > 0) { end_time_ = QDateTime::fromSecsSinceEpoch(item->GetEndTime().GetTimeT(), Qt::UTC); } bytes_received_ = item->GetReceivedBytes(); total_bytes_ = item->GetTotalBytes(); current_bytes_per_sec_ = item->GetCurrentSpeed(); } } // namespace doogie
[ "hyq5436@hotmail.com" ]
hyq5436@hotmail.com
6e8571887f6e3e24671fc4427c13b4a6b2b9996f
52b28b80e514bccd0e9506a2a9b83adbb83320ad
/WPFLib/include/AVUIMaterial.h
55fa87240ee2f65a1f33e5b6d6d01bab67fa9e55
[]
no_license
RobinKa/wpfg
8bb3e9e433bc7d3deae888189cf7961d8fc27023
0986c0cb277d55d7ddb50401f167abf9740e90d9
refs/heads/master
2023-01-03T02:54:09.452491
2020-10-26T18:50:11
2020-10-26T18:50:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
200
h
#pragma once #include <AVUIAnimatable.h> namespace AVUI { class Material : public Animatable { public: Material() { }; DECLARE_ELEMENT(Material, Animatable); }; }; // namespace AVUI
[ "kevin.waldock@gmail.com" ]
kevin.waldock@gmail.com
841e77243f68f96a56773e8d08b754b10f4c9bb4
5e97a5692efe90ac05e4ad7139106e71e193edbf
/cs3505/MidTerm1/fraction.h
0ff9b133d772156874d38d3663bdffbea53e98d6
[]
no_license
CarlosMa15/Linux
f5657b5bf5feaf4f9eda652540d6c9f0d8d7834d
ee34569d59842815efb1bb861baa63f90da98ac7
refs/heads/master
2022-04-22T16:01:30.146840
2020-04-27T00:29:36
2020-04-27T00:29:36
259,150,587
0
0
null
null
null
null
UTF-8
C++
false
false
422
h
/* Midterm 1 fraction class */ #ifndef FRACTION_H #define FRACTION_H class fraction { friend class measurement; private: int numerator; int denominator; void reduce(); public: fraction(int numerator, int denominator); const fraction operator+(const fraction & rhs) const; const fraction operator-(const fraction & rhs) const; const fraction operator/(const fraction & rhs) const; }; #endif
[ "noreply@github.com" ]
noreply@github.com
cbe17093a11af1fb2abb2852d7d1955b2cc24d7c
627e0149d1055372e22694892639c740d15eaf8d
/interface/LandSShapesProducer.hh
f4aa4b3428e5d2c2db040e5d6210685fa735398d
[]
no_license
xealits/TopTaus-1
55318b1eadffb705f0ec5a195f8d0244ece5ef55
8d31bb1eb75979af5bb49a9c09a6e499b659dbd6
refs/heads/master
2021-01-18T06:56:49.291723
2013-07-02T14:43:05
2013-07-02T14:43:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,397
hh
#ifndef _LandSShapesProducer_hh #define _LandSShapesProducer_hh /** \class LandSShapesProducer LandSShapesProducer.cc "UserCode/LIP/TopTaus/interface/LandSShapesProducer.hh" \brief executable for performing multivariable likelihood fit in order to improve estimation of N_fakes \author Pietro Vischia \version $Id: LandSShapesProducer.hh,v 1.14 2012/12/17 18:01:51 vischia Exp $ TODO List: - generalize to array of samples, simplifying the approach and maintainability - de-zero the zeroed bins (Pedro suggestion: essentially RooFit (->combine tool) does not like zero bins -> set them to 1E-06 - multidimensional shapes - MVA shapes (creating an external reweighter and not this code) - Define enum for classifying, replacing isSignal_, isFromData_, isDD_ - Define a class for all the sample properties, like names, files, trees, classifications, colours and so on */ #if !defined(__CINT__) || defined(__MAKECINT__) #ifndef __CINT__ #include "RooGlobalFunc.h" #endif // System headers #include <string> #include <fstream> // RooFit headers #include "RooRealVar.h" #include "RooDataSet.h" #include "RooDataHist.h" #include "RooHistPdf.h" #include "RooKeysPdf.h" #include "RooGaussian.h" #include "RooAddPdf.h" #include "RooProdPdf.h" #include "RooFitResult.h" #include "RooPlot.h" #include "RooNLLVar.h" #include "RooAddition.h" //#include "RooMinuit.h" // ROOT headers #include "TString.h" #include "TStyle.h" #include "TFile.h" #include "TTree.h" #include "TCanvas.h" #include "TH1.h" #include "TH2.h" #include "TLegend.h" #endif #include "LIP/TopTaus/interface/Utilities.hh" #include "LIP/TopTaus/interface/FitVar.hh" class LandSShapesProducer: protected utilities::EditorialUtils, utilities::StatUtils { public : // Constructor LandSShapesProducer(string, bool); // Destructor ~LandSShapesProducer(); /** @short performs the variable fit to a given set of variables */ void Produce(); private: void Init(); void SetOptions(); void InitMassPoint(size_t); void InitPerVariableAmbient(size_t); void BuildDatasets(size_t); // void BuildPDFs(size_t); void DrawTemplates(size_t); void UnrollMultiDimensionalShape(); void StorePerMassSignalShapes(); void DrawSignalShapesComparison(); // void BuildConstrainedModels(size_t); // void DoPerVariableFit(size_t); // void DrawPerVariableFit(size_t); // void DoPerVariableLikelihoodFit(size_t); // void DoCombinedLikelihoodFit(); // Data members // Parameter set string parSet_; // Output paths string outFolder_; string outputFileName_; vector<string> massPointName_; string resultsFileName_; // not used. txt. ofstream resultsFile_; streambuf* streamToFile_; // Style TStyle* myStyle_; // Fit settings // bool includeSignal_; // bool standaloneTTbar_; // Display/produce settings // Can't do simultaneously at the moment because of renormalization of histograms, // so must revise the code for dropping the need of that bool produceOnly_; bool doMultiDimensionalShapes_; bool unsplitUncertainties_; // Input paths // Condense in sampleclass->GetBaseDir vector<TString> baseDir_; vector<Int_t> isFromData_; vector<Int_t> isDDbkg_; vector<Int_t> isSignal_; double displayMin_; double displayMax_; vector<TString> inputFileName_; // Build from mass ranges vector<string> sampleName_; vector<string> fancySampleName_; vector<Int_t> sampleColour_; // Non for data. vector<Int_t> sampleFillStyle_; // Non for data. // Condense in sampleclass->GetMinitreeName vector<TString> minitree_; vector<TString> systComponents_; vector<TString> systFancyComponents_; // Input files vector<TFile*> inputFile_; double osCutEff_; // For DD rescaling // Input base trees vector<TTree*> inputTree_; // Input syst trees vector<vector<TTree*> > systTree_; vector<string> uncSources_; size_t currentMassPoint_; size_t nMassPoints_; // Variables parameters size_t nVars_; size_t nSamples_; size_t nSysts_; vector<FitVar*> fitVars_; vector<string> vars_; vector<double> mins_; vector<double> maxs_; vector<int> bins_; vector<double> hmin_; vector<double> hmax_; vector<Int_t> unbinned_; vector<Int_t> smoothOrder_; TCanvas* canvas_; // RooFit stuff // Per-var stuff string identifier_; RooRealVar* myvar_ ; RooRealVar* myvarMultiD_ ; RooRealVar* myvar_weights_ ; RooRealVar* isOSvar_ ; vector<string> myDSName_ ; vector<vector<string> > mySystDSName_ ; // must have dummy name for zero component (data) vector<RooDataHist*> histo_ ; vector<vector<RooDataHist*> > systHisto_ ; vector<RooDataSet*> myDS_ ; vector<vector<RooDataSet*> >mySystDS_ ; vector<vector<TH1*> > masterHist_; vector<vector<TString> > masterHistNames_; vector<TH1*> masterShapes_; vector<vector<TH1*> > signalShapesToCompare_; vector<vector<TH1*> > signalShapesToCompareHH_; vector<vector<TH1*> > signalShapesToCompareWH_; vector<TH1*> perMassPointSignalShapesToCompare_; vector<TH1*> perMassPointSignalShapesToCompareHH_; vector<TH1*> perMassPointSignalShapesToCompareWH_; TH1* ddbkgHistUp_; // These are for showing the error bands. Not for LandS TH1* ddbkgHistDown_;// These are for showing the error bands. Not for LandS vector<TH1*> hist_; vector<TH1*> histStatUp_; vector<TH1*> histStatDown_; vector<vector<TH1*> > systHist_; vector<TH2D*> th2_; vector<TH2D*> th2StatUp_; vector<TH2D*> th2StatDown_; vector<vector<TH2D*> > th2Syst_; vector<TH1D*> unrolled_; vector<TH1D*> unrolledStatUp_; vector<TH1D*> unrolledStatDown_; vector<vector<TH1D*> > unrolledSyst_; TLegend* leg_; double sumWeights_; }; #endif //_TauDileptonPDFBuilderFitter_hh
[ "" ]
6121eb147a3c2289112ef6a7c8d74a200394733f
7d391a176f5b54848ebdedcda271f0bd37206274
/src/BabylonCpp/include/babylon/shaders/glow_blur_post_process_fragment_fx.h
cde2a48f8c5b98575b8eb7d8fb522d2bb6b459cb
[ "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
pthom/BabylonCpp
c37ea256f310d4fedea1a0b44922a1379df77690
52b04a61467ef56f427c2bb7cfbafc21756ea915
refs/heads/master
2021-06-20T21:15:18.007678
2019-08-09T08:23:12
2019-08-09T08:23:12
183,211,708
2
0
Apache-2.0
2019-04-24T11:06:28
2019-04-24T11:06:28
null
UTF-8
C++
false
false
1,904
h
#ifndef BABYLON_SHADERS_GLOW_BLUR_POST_PROCESS_FRAGMENT_FX_H #define BABYLON_SHADERS_GLOW_BLUR_POST_PROCESS_FRAGMENT_FX_H namespace BABYLON { extern const char* glowBlurPostProcessPixelShader; const char* glowBlurPostProcessPixelShader = "// Samplers\n" "varying vec2 vUV;\n" "uniform sampler2D textureSampler;\n" "\n" "// Parameters\n" "uniform vec2 screenSize;\n" "uniform vec2 direction;\n" "uniform float blurWidth;\n" "\n" "// Transform color to luminance.\n" "float getLuminance(vec3 color)\n" "{\n" " return dot(color, vec3(0.2126, 0.7152, 0.0722));\n" "}\n" "\n" "void main(void)\n" "{\n" " float weights[7];\n" " weights[0] = 0.05;\n" " weights[1] = 0.1;\n" " weights[2] = 0.2;\n" " weights[3] = 0.3;\n" " weights[4] = 0.2;\n" " weights[5] = 0.1;\n" " weights[6] = 0.05;\n" "\n" " vec2 texelSize = vec2(1.0 / screenSize.x, 1.0 / screenSize.y);\n" " vec2 texelStep = texelSize * direction * blurWidth;\n" " vec2 start = vUV - 3.0 * texelStep;\n" "\n" " vec4 baseColor = vec4(0., 0., 0., 0.);\n" " vec2 texelOffset = vec2(0., 0.);\n" "\n" " for (int i = 0; i < 7; i++)\n" " {\n" " // alpha blur.\n" " vec4 texel = texture2D(textureSampler, start + texelOffset);\n" " baseColor.a += texel.a * weights[i];\n" "\n" " // Highest Luma for outline.\n" " float luminance = getLuminance(baseColor.rgb);\n" " float luminanceTexel = getLuminance(texel.rgb);\n" " float choice = step(luminanceTexel, luminance);\n" " baseColor.rgb = choice * baseColor.rgb + (1.0 - choice) * texel.rgb;\n" "\n" " texelOffset += texelStep;\n" " }\n" "\n" " gl_FragColor = baseColor;\n" "}\n"; } // end of namespace BABYLON #endif // end of BABYLON_SHADERS_GLOW_BLUR_POST_PROCESS_FRAGMENT_FX_H
[ "sam.dauwe@gmail.com" ]
sam.dauwe@gmail.com
9a74c9685e34af47abaea906088a8e21c56005b4
f72f8d6ae5b98a8fc89ed633f687cfd0a5ae054f
/ffscript/BasicOperators.hpp
7ec4a0d00bde68315577ff74829032f186a9bdcc
[ "MIT" ]
permissive
VincentPT/xscript
20469bd934b3b0a551ce9b1143f1b6a1a068f1f4
11489c2de3ccb279d634e5787b6ed038fd8cc05b
refs/heads/master
2023-08-28T19:36:04.840095
2023-07-23T16:30:45
2023-07-23T16:30:45
397,819,881
0
1
null
null
null
null
UTF-8
C++
false
false
3,690
hpp
/****************************************************************** * File: BasicOperators.hpp * Description: define function template for basic operators such as * operator+, operator-,... * Author: Vincent Pham * * Copyright (c) 2018 VincentPT. ** Distributed under the MIT License (http://opensource.org/licenses/MIT) ** * **********************************************************************/ #pragma once #include "ffscript.h" namespace ffscript { namespace basic { namespace operators { template <class RT, class T1, class T2> RT add(T1 a, T2 b) { return a + b; } template <class RT, class T1, class T2> RT sub(T1 a, T2 b) { return a - b; } template <class RT, class T1, class T2> RT mul(T1 a, T2 b) { return a * b; } template <class RT, class T1, class T2> RT div(T1 a, T2 b) { return a / b; } template <class RT, class T1, class T2> RT mod(T1 a, T2 b) { return a % b; } template <class RT, class T> RT neg(T a) { return -a; } template <class RT, class T1, class T2> RT assign(T1 & a, T2 b) { return a = (T1)b; } #pragma region bitwise operators template <class RT, class T1, class T2> RT bitwise_and(T1 a, T2 b) { return a & b; } template <class RT, class T1, class T2> RT bitwise_or (T1 a, T2 b) { return a | b; } template <class RT, class T1, class T2> RT bitwise_xor (T1 a, T2 b) { return a ^ b; } template <class RT, class T> RT bitwise_not(T a) { return ~a; } template <class RT, class T1, class T2> RT bitwise_shiftLeft(T1 a, T2 b) { return a << b; } template <class RT, class T1, class T2> RT bitwise_shiftRight(T1 a, T2 b) { return a >> b; } #pragma endregion template <class T> T post_inc(T& a) { return a++; } template <class T> T pre_inc(T& a) { return ++a; } template <class T> T post_dec(T& a) { return a--; } template <class T> T pre_dec(T& a) { return --a; } #pragma region compound operators template <class T1, class T2> void mul_comp(T1& a, T2 b) { a *= (T1)b; } template <class T1, class T2> void div_comp(T1& a, T2 b) { a /= (T1)b; } template <class T1, class T2> void add_comp(T1& a, T2 b) { a += (T1)b; } template <class T1, class T2> void sub_comp(T1& a, T2 b) { a -= (T1)b; } template <class T1, class T2> void mod_comp(T1& a, T2 b) { a %= (T1)b; } template <class T1, class T2> void and_comp(T1& a, T2 b) { a &= b; } template <class T1, class T2> void or_comp(T1& a, T2 b) { a |= b; } template <class T1, class T2> void xor_comp(T1& a, T2 b) { a ^= b; } template <class T1, class T2> void shiftLeft_comp(T1& a, T2 b) { a <<= b; } template <class T1, class T2> void shiftRight_comp(T1& a, T2 b) { a >>= b; } #pragma endregion #pragma region compare functions template <class T1, class T2> bool less(T1 a, T2 b) { return a < b; } template <class T1, class T2> bool less_or_equal(T1 a, T2 b) { return a <= b; } template <class T1, class T2> bool great(T1 a, T2 b) { return (a > b); } template <class T1, class T2> bool great_or_equal(T1 a, T2 b) { return a >= b; } template <class T1, class T2> bool equal(T1 a, T2 b) { return a == b; } template <class T1, class T2> bool not_equal(T1 a, T2 b) { return a != b; } #pragma endregion #pragma region logic functions template <class T1, class T2> bool logic_and(T1 a, T2 b) { return (a && b); } template <class T1, class T2> bool logic_or(T1 a, T2 b) { return (a || b); } template <class T> bool logic_not(T a) { return !a; } #pragma endregion } } }
[ "minhpta@outlook.com" ]
minhpta@outlook.com
61d4beda062f88ce202e9d2f586c656d2bd79a73
760556dc5611c0ee3238ffe350a9386e051fa85d
/runtime-src/Classes/texture/lua_dynamic_texure_manual.cpp
cc6f6d3db2882f131c051501ca724d4f3057e80f
[]
no_license
wuqiang22/cocos2d_framework
701dea9a636d4a39f14b3681da5c1a2834f75469
d27e07ff50f3589e6924ab4363ecf772541ed605
refs/heads/master
2020-12-25T15:19:02.003720
2017-11-01T11:16:03
2017-11-01T11:16:03
59,203,029
0
0
null
null
null
null
UTF-8
C++
false
false
11,079
cpp
#include "lua_dynamic_texure_manual.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" #include "CCLuaValue.h" #include "texture/DynamicTexture.h" int lua_dynamictexture_create(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S, 1, "cc.DynamicTexture", 0, &tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if (!ok) { tolua_error(tolua_S, "invalid arguments in function 'lua_dynamictexture_create'", nullptr); return 0; } cocos2d::DynamicTexture* ret = cocos2d::DynamicTexture::create(); object_to_luaval<cocos2d::DynamicTexture>(tolua_S, "cc.DynamicTexture", (cocos2d::DynamicTexture*)ret); return 1; } else if (argc == 2){ int arg0,arg1; ok &= luaval_to_int32(tolua_S, 2, (int *)&arg0, "cc.DynamicTexture:create"); if (!ok) { tolua_error(tolua_S, "invalid arguments in function 'lua_dynamictexture_create'", nullptr); return 0; } ok &= luaval_to_int32(tolua_S, 3, (int *)&arg1, "cc.DynamicTexture:create"); if (!ok) { tolua_error(tolua_S, "invalid arguments in function 'lua_dynamictexture_create'", nullptr); return 0; } cocos2d::DynamicTexture* ret = cocos2d::DynamicTexture::create(arg0,arg1); object_to_luaval<cocos2d::DynamicTexture>(tolua_S, "cc.DynamicTexture", (cocos2d::DynamicTexture*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.DynamicTexture:create", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S, "#ferror in function 'lua_dynamictexture_create'.", &tolua_err); #endif return 0; } int lua_dynamictexture_addStringTexture(lua_State* tolua_S) { int argc = 0; cocos2d::DynamicTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif cobj = (cocos2d::DynamicTexture*)tolua_tousertype(tolua_S, 1, 0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S, "invalid 'cobj' in function 'lua_dynamictexture_addStringTexture'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; do { if (argc == 2) { cocos2d::Texture2D* arg0; ok &= luaval_to_object<cocos2d::Texture2D>(tolua_S, 2, "cc.Texture2D", &arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3, &arg1, "cc.DynamicTexture:addStringTexture"); if (!ok) { break; } bool ret = cobj->addStringTexture(arg0, arg1); tolua_pushboolean(tolua_S, ret); return 1; } else if (argc == 3) { cocos2d::Texture2D* arg0; ok &= luaval_to_object<cocos2d::Texture2D>(tolua_S, 2, "cc.Texture2D", &arg0); if (!ok) { break; } std::string arg1; ok &= luaval_to_std_string(tolua_S, 3, &arg1, "cc.DynamicTexture:addStringTexture"); if (!ok) { break; } bool arg2; ok &= luaval_to_boolean(tolua_S, 4, &arg2, "cc.DynamicTexture:addStringTexture"); if (!ok) { break; } bool ret = cobj->addStringTexture(arg0, arg1,arg2); tolua_pushboolean(tolua_S, ret); return 1; } } while (0); luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.DynamicTexture:addStringTexture", argc, 2); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S, "#ferror in function 'lua_dynamictexture_addStringTexture'.", &tolua_err); #endif return 0; } int lua_dynamictexture_getSubTextureInfo(lua_State* tolua_S) { int argc = 0; cocos2d::DynamicTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S, 1, "cc.DynamicTexture", 0, &tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::DynamicTexture*)tolua_tousertype(tolua_S, 1, 0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S, "invalid 'cobj' in function 'lua_dynamictexture_getSubTextureInfo'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1) { std::string arg0; ok &= luaval_to_std_string(tolua_S, 2, &arg0, "cc.DynamicTexture:getSubTextureInfo"); if (!ok) { tolua_error(tolua_S, "invalid arguments in function 'lua_dynamictexture_getSubTextureInfo'", nullptr); return 0; } cocos2d::Rect ret = cobj->getSubTextureInfo(arg0); rect_to_luaval(tolua_S, ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.DynamicTexture:getSubTextureInfo", argc, 1); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S, "#ferror in function 'lua_dynamictexture_getSubTextureInfo'.", &tolua_err); #endif return 0; } int lua_dynamictexture_getTexture(lua_State* tolua_S) { int argc = 0; cocos2d::DynamicTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertype(tolua_S, 1, "cc.DynamicTexture", 0, &tolua_err)) goto tolua_lerror; #endif cobj = (cocos2d::DynamicTexture*)tolua_tousertype(tolua_S, 1, 0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S, "invalid 'cobj' in function 'lua_dynamictexture_getTexture'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; if (argc == 0) { if (!ok) { tolua_error(tolua_S, "invalid arguments in function 'lua_dynamictexture_getTexture'", nullptr); return 0; } cocos2d::Texture2D* ret = cobj->getTexture(); object_to_luaval<cocos2d::Texture2D>(tolua_S, "cc.Texture2D", (cocos2d::Texture2D*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.DynamicTexture:getTexture", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S, "#ferror in function 'lua_dynamictexture_getTexture'.", &tolua_err); #endif return 0; } int lua_dynamictexture_isTextureEnd(lua_State* tolua_S) { int argc = 0; cocos2d::DynamicTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif cobj = (cocos2d::DynamicTexture*)tolua_tousertype(tolua_S, 1, 0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S, "invalid 'cobj' in function 'lua_dynamictexture_isTextureEnd'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; do { if (argc == 0) { bool ret = cobj->isTextureEnd(); tolua_pushboolean(tolua_S, ret); return 1; } } while (0); luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.DynamicTexture:isTextureEnd", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S, "#ferror in function 'lua_dynamictexture_isTextureEnd'.", &tolua_err); #endif return 0; } int lua_dynamictexture_generateTexture(lua_State* tolua_S) { int argc = 0; cocos2d::DynamicTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif cobj = (cocos2d::DynamicTexture*)tolua_tousertype(tolua_S, 1, 0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S, "invalid 'cobj' in function 'lua_dynamictexture_generateTexture'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; do { if (argc == 0) { bool ret = cobj->generateTexture(); tolua_pushboolean(tolua_S, ret); return 1; } } while (0); luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.DynamicTexture:generateTexture", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S, "#ferror in function 'lua_dynamictexture_generateTexture'.", &tolua_err); #endif return 0; } int lua_dynamictexture_dump(lua_State* tolua_S) { int argc = 0; cocos2d::DynamicTexture* cobj = nullptr; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif cobj = (cocos2d::DynamicTexture*)tolua_tousertype(tolua_S, 1, 0); #if COCOS2D_DEBUG >= 1 if (!cobj) { tolua_error(tolua_S, "invalid 'cobj' in function 'lua_dynamictexture_dump'", nullptr); return 0; } #endif argc = lua_gettop(tolua_S) - 1; do { if (argc == 0) { cobj->dump(); return 1; } } while (0); luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.DynamicTexture:dump", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S, "#ferror in function 'lua_dynamictexture_dump'.", &tolua_err); #endif return 0; } int lua_dynamictexture_createWithTexture(lua_State* tolua_S) { int argc = 0; bool ok = true; #if COCOS2D_DEBUG >= 1 tolua_Error tolua_err; #endif #if COCOS2D_DEBUG >= 1 if (!tolua_isusertable(tolua_S, 1, "cc.DynamicTexture", 0, &tolua_err)) goto tolua_lerror; #endif argc = lua_gettop(tolua_S) - 1; if (argc == 1){ cocos2d::Texture2D* arg0; ok &= luaval_to_object<cocos2d::Texture2D>(tolua_S, 2, "cc.Texture2D", &arg0); if (!ok) { tolua_error(tolua_S, "invalid arguments in function 'lua_dynamictexture_createWithTexture'", nullptr); return 0; } cocos2d::Texture2D* ret = cocos2d::DynamicTexture::createWithTexture(arg0); object_to_luaval<cocos2d::Texture2D>(tolua_S, "cc.Texture2D", (cocos2d::Texture2D*)ret); return 1; } luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.DynamicTexture:createWithTexture", argc, 0); return 0; #if COCOS2D_DEBUG >= 1 tolua_lerror: tolua_error(tolua_S, "#ferror in function 'lua_dynamictexture_createWithTexture'.", &tolua_err); #endif return 0; } int lua_register_DynamicTexture(lua_State* tolua_S) { tolua_usertype(tolua_S, "cc.DynamicTexture"); tolua_cclass(tolua_S, "DynamicTexture", "cc.DynamicTexture", "cc.Node", nullptr); tolua_beginmodule(tolua_S, "DynamicTexture"); tolua_function(tolua_S, "create", lua_dynamictexture_create); tolua_function(tolua_S, "createWithTexture", lua_dynamictexture_createWithTexture); tolua_function(tolua_S, "addStringTexture", lua_dynamictexture_addStringTexture); tolua_function(tolua_S, "getSubTextureInfo", lua_dynamictexture_getSubTextureInfo); tolua_function(tolua_S, "getTexture", lua_dynamictexture_getTexture); tolua_function(tolua_S, "generateTexture", lua_dynamictexture_generateTexture); tolua_function(tolua_S, "isTextureEnd", lua_dynamictexture_isTextureEnd); tolua_function(tolua_S, "dump", lua_dynamictexture_dump); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::DynamicTexture).name(); g_luaType[typeName] = "cc.DynamicTexture"; g_typeCast["DynamicTexture"] = "cc.DynamicTexture"; return 1; } TOLUA_API int register_dynamictexture_manual(lua_State* tolua_S) { tolua_open(tolua_S); tolua_module(tolua_S, "cc", 0); tolua_beginmodule(tolua_S, "cc"); lua_register_DynamicTexture(tolua_S); tolua_endmodule(tolua_S); return 1; }
[ "noreply@github.com" ]
noreply@github.com
9836a599d96a2ae13c3ba35c4567f0849eaf3e35
b6e50646d41bcb6f8cd59edee91a1b5dff57ea1a
/CMSIS/DSP/Testing/Include/Tests/FastMathF64.h
ff0a7fac8b9cd4048997628365512fd2ab06f48a
[ "Apache-2.0" ]
permissive
GorgonMeducer/CMSIS_5
229e01ac840843f7ea38a9e7885be6b91241c6b3
8490bc82a793137b948d3c8abce0879a54b4322c
refs/heads/develop
2022-05-10T10:11:05.507721
2022-04-21T14:05:22
2022-04-21T14:05:22
220,259,540
1
1
Apache-2.0
2019-11-07T14:46:33
2019-11-07T14:46:33
null
UTF-8
C++
false
false
694
h
#include "Test.h" #include "Pattern.h" #include "dsp/fast_math_functions.h" class FastMathF64:public Client::Suite { public: FastMathF64(Testing::testID_t id); virtual void setUp(Testing::testID_t,std::vector<Testing::param_t>& paramsArgs,Client::PatternMgr *mgr); virtual void tearDown(Testing::testID_t,Client::PatternMgr *mgr); private: #include "FastMathF64_decl.h" Client::Pattern<float64_t> input; Client::LocalPattern<float64_t> output; // Reference patterns are not loaded when we are in dump mode Client::RefPattern<float64_t> ref; };
[ "Christophe.Favergeon@arm.com" ]
Christophe.Favergeon@arm.com
87b008853dd985de653a32f7bfdf63bac2b2a127
33035c05aad9bca0b0cefd67529bdd70399a9e04
/src/boost_numeric_odeint_util_stepper_traits.hpp
2838c7f28b4755976530b61a5f4149697c804da8
[ "LicenseRef-scancode-unknown-license-reference", "BSL-1.0" ]
permissive
elvisbugs/BoostForArduino
7e2427ded5fd030231918524f6a91554085a8e64
b8c912bf671868e2182aa703ed34076c59acf474
refs/heads/master
2023-03-25T13:11:58.527671
2021-03-27T02:37:29
2021-03-27T02:37:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
56
hpp
#include <boost/numeric/odeint/util/stepper_traits.hpp>
[ "k@kekyo.net" ]
k@kekyo.net
9bf5b17d902544afb903afc2b3199f91ff90e935
dd80a584130ef1a0333429ba76c1cee0eb40df73
/external/chromium_org/remoting/protocol/third_party_client_authenticator.cc
ec5eb59149bfb62033d2e8c70d54a33f966d8598
[ "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
2,648
cc
// Copyright 2013 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 "remoting/protocol/third_party_client_authenticator.h" #include "base/base64.h" #include "base/bind.h" #include "base/callback.h" #include "base/logging.h" #include "remoting/base/constants.h" #include "remoting/base/rsa_key_pair.h" #include "remoting/protocol/channel_authenticator.h" #include "remoting/protocol/v2_authenticator.h" #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" #include "url/gurl.h" namespace remoting { namespace protocol { ThirdPartyClientAuthenticator::ThirdPartyClientAuthenticator( scoped_ptr<TokenFetcher> token_fetcher) : ThirdPartyAuthenticatorBase(WAITING_MESSAGE), token_fetcher_(token_fetcher.Pass()) { } ThirdPartyClientAuthenticator::~ThirdPartyClientAuthenticator() { } void ThirdPartyClientAuthenticator::ProcessTokenMessage( const buzz::XmlElement* message, const base::Closure& resume_callback) { std::string token_url = message->TextNamed(kTokenUrlTag); std::string token_scope = message->TextNamed(kTokenScopeTag); if (token_url.empty() || token_scope.empty()) { LOG(ERROR) << "Third-party authentication protocol error: " "missing token verification URL or scope."; token_state_ = REJECTED; rejection_reason_ = PROTOCOL_ERROR; resume_callback.Run(); return; } token_state_ = PROCESSING_MESSAGE; // |token_fetcher_| is owned, so Unretained() is safe here. token_fetcher_->FetchThirdPartyToken( GURL(token_url), token_scope, base::Bind( &ThirdPartyClientAuthenticator::OnThirdPartyTokenFetched, base::Unretained(this), resume_callback)); } void ThirdPartyClientAuthenticator::AddTokenElements( buzz::XmlElement* message) { DCHECK_EQ(token_state_, MESSAGE_READY); DCHECK(!token_.empty()); buzz::XmlElement* token_tag = new buzz::XmlElement(kTokenTag); token_tag->SetBodyText(token_); message->AddElement(token_tag); token_state_ = ACCEPTED; } void ThirdPartyClientAuthenticator::OnThirdPartyTokenFetched( const base::Closure& resume_callback, const std::string& third_party_token, const std::string& shared_secret) { token_ = third_party_token; if (token_.empty() || shared_secret.empty()) { token_state_ = REJECTED; rejection_reason_ = INVALID_CREDENTIALS; } else { token_state_ = MESSAGE_READY; underlying_ = V2Authenticator::CreateForClient( shared_secret, MESSAGE_READY); } resume_callback.Run(); } } // namespace protocol } // namespace remoting
[ "karun.matharu@gmail.com" ]
karun.matharu@gmail.com
6ab37507c4622931cc754288bf17447f64ba9f41
f4f72c74f34450dcde3d101f7200922966feb3d2
/CmsswAnalysis/plugins/HFDumpSignal.cc
7dde838a249f46447ce59f913a5f00f7ab9df211
[]
no_license
heistera/Bmm
338952adf8d8f90182b04c0526e4142c5d1ce334
f147b3d43b7d31beabc9cb74622134dda8d27d13
refs/heads/master
2020-12-07T02:16:44.400307
2015-06-23T07:19:19
2015-06-23T07:19:19
23,543,249
0
0
null
null
null
null
UTF-8
C++
false
false
22,978
cc
#include <iostream> #include "HFDumpSignal.h" #include "Bmm/RootAnalysis/rootio/TAna01Event.hh" #include "Bmm/RootAnalysis/rootio/TAnaTrack.hh" #include "Bmm/RootAnalysis/rootio/TAnaCand.hh" #include "Bmm/RootAnalysis/rootio/TGenCand.hh" #include "Bmm/RootAnalysis/rootio/TAnaVertex.hh" #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/Common/interface/Wrapper.h" #include "DataFormats/Candidate/interface/Candidate.h" #include "DataFormats/MuonReco/interface/Muon.h" #include "DataFormats/MuonReco/interface/MuonFwd.h" #include "DataFormats/MuonReco/interface/MuonSelectors.h" #include "DataFormats/JetReco/interface/BasicJetCollection.h" #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/GeometryVector/interface/GlobalVector.h" #include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h" #include "TrackingTools/IPTools/interface/IPTools.h" #include "TrackingTools/Records/interface/TransientTrackRecord.h" #include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h" #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h" #include <SimDataFormats/Vertex/interface/SimVertex.h> #include <SimDataFormats/Vertex/interface/SimVertexContainer.h> #include "SimDataFormats/Track/interface/SimTrack.h" #include "SimDataFormats/Track/interface/SimTrackContainer.h" #include "DataFormats/Candidate/interface/CandidateFwd.h" #include "DataFormats/Candidate/interface/CandMatchMap.h" #include "DataFormats/Candidate/interface/Candidate.h" // -- Yikes! extern TAna01Event *gHFEvent; using namespace std; using namespace reco; using namespace edm; // ---------------------------------------------------------------------- HFDumpSignal::HFDumpSignal(const edm::ParameterSet& iConfig) : fVerbose(iConfig.getUntrackedParameter<int>("verbose", 0)), fJetMatch(iConfig.getUntrackedParameter<double>("jetmatch", 0.5)), fJetEtMin(iConfig.getUntrackedParameter<double>("jetetmin", 1)), fMuonLabel(iConfig.getUntrackedParameter<string>("muonLabel", string("globalMuons"))), fJetsLabel(iConfig.getUntrackedParameter<string>("jetsLabel", string("ak5TrackJets"))), fTracksLabel(iConfig.getUntrackedParameter<string>("tracksLabel", string("trackCandidates"))), fVertexLabel(iConfig.getUntrackedParameter<string>("vertexLabel", string("offlinePrimaryVerticesWithBS"))), fSimVertexLabel(iConfig.getUntrackedParameter<string>("simvertexLabel", string("g4SimHits"))), fVertexMinNdof(iConfig.getUntrackedParameter<double>("vertexMinNdof", 4.)) { using namespace std; fAllowGlobalOnly=iConfig.getUntrackedParameter<bool>("allowGlobalOnly", false); cout << "----------------------------------------------------------------------" << endl; cout << "--- HFDumpSignal constructor" << endl; cout << "--- " << fMuonLabel.c_str() << endl; if (fAllowGlobalOnly){ cout << "!!! global-only muons allowed, not required to be tracker muons !!!!!" << endl; }else{ cout << "all muons will be required to be tracker muons " << endl; } cout << "----------------------------------------------------------------------" << endl; } // ---------------------------------------------------------------------- HFDumpSignal::~HFDumpSignal() { } // ---------------------------------------------------------------------- void HFDumpSignal::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { int RunNumber=iEvent.id().run(); int nn=iEvent.id().event(); bool inspect=(RunNumber==133874)&&((nn==32751514)||(nn==20949710)||(nn==11880401)); nevt++; //muon collection edm::Handle<reco::MuonCollection> muons; iEvent.getByLabel( fMuonLabel.c_str(), muons); if( !muons.isValid()) { cout<<"****** no "<<fMuonLabel<<endl; return; } //primary vertex Handle<reco::VertexCollection> primaryVertex; iEvent.getByLabel(fVertexLabel.c_str(),primaryVertex); if( !primaryVertex.isValid()) { cout<<"****** no "<<fVertexLabel<<endl; return; } // use beamspot, or 0 if not available math::XYZPoint bs = math::XYZPoint(0.,0.,0.); edm::Handle<reco::BeamSpot> beamSpotCollection; iEvent.getByLabel("offlineBeamSpot", beamSpotCollection); if (beamSpotCollection.isValid()){ bs = beamSpotCollection->position();} else { cout<<"****no beamspot "<<endl;} // use simvertexes math::XYZPoint simv0 = math::XYZPoint(0.,0.,0.); bool simvFound =false; Handle<SimVertexContainer> simVtxs; // iEvent.getByLabel( fSimVertexLabel.c_str(), simVtxs); if( iEvent.getByLabel( fSimVertexLabel.c_str(), simVtxs) && simVtxs.isValid()){ simvFound = (simVtxs->size() != 0); if(simvFound) simv0=(*simVtxs)[0].position(); } // TrackJets Handle<BasicJetCollection> jetsH; iEvent.getByLabel(fJetsLabel.c_str(),jetsH); // bool jetvalid=true; if( !jetsH.isValid()) { cout<<"****** no "<<fJetsLabel<<endl; } //tracks (jet constituents) Handle<reco::CandidateView> candidates1Handle; iEvent.getByLabel(fTracksLabel.c_str(), candidates1Handle); if( !candidates1Handle.isValid()) { cout<<"****** no "<<fTracksLabel<<endl; } //transient track builder edm::ESHandle<TransientTrackBuilder> builder; iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder); ///////////////////// refitted track stuff /////////////////////// Handle<reco::TrackCollection> generalTracksH; Handle<reco::TrackCollection> refittedTracksH; std::map<double ,const reco::Track *> g2r; //FIXME bool useRefittedTracks=false; bool hasRefittedTracks=iEvent.getByLabel("TrackRefitter",refittedTracksH) && refittedTracksH.isValid(); bool hasTracks=iEvent.getByLabel("generalTracks",generalTracksH) && generalTracksH.isValid(); if( hasRefittedTracks && hasTracks &&(generalTracksH->size() == refittedTracksH->size()) ){ //std::cout << "HFDumpSignal: found refitted tracks " << generalTracksH->size() << " = " << refittedTracksH->size() << std::endl; for(unsigned int i=0; i<generalTracksH->size(); i++){ g2r[generalTracksH->at(i).pt()] = &(refittedTracksH->at(i)); } //FIXME useRefittedTracks=true; }else if(hasTracks){ for(unsigned int i=0; i<generalTracksH->size(); i++){ g2r[generalTracksH->at(i).pt()] = &(generalTracksH->at(i)); // map to itself if no refitted tracks available } }else{ cout << "HFDumpSignal: no tracks, what are we doing here? " << endl; } ///////////////////// refitted track stuff /////////////////////// TAnaTrack *pTrack; int index = 0; if (fVerbose > 0) cout << "==>HFDumpSignal> nMuons =" << muons->size() << endl; if(inspect){ int muindex=0; cout << "==>HFDumpSignal> nMuons =" << muons->size() << endl; for ( reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++ muon ) { cout << muindex << ") g=" << muon->isGlobalMuon() << " t=" << muon->isTrackerMuon() << ":"; muindex++; cout << Form(" ( %8.1f %4.1f %4.1f ) ", muon->pt(), muon->phi(), muon->eta()); if(muon->isGlobalMuon()&&muon->isTrackerMuon()){ reco::TrackRef InnerTrack=muon->innerTrack(); cout << Form("%3d %2d %5.1f %5.1f %6.4f %6.4f %2d ", int((muon->globalTrack())->hitPattern().numberOfValidStripHits()+(muon->globalTrack())->hitPattern().numberOfValidPixelHits()), int((muon->globalTrack())->hitPattern().pixelLayersWithMeasurement()), float((muon->globalTrack())->chi2()/(muon->globalTrack())->ndof()), float(muon->innerTrack()->normalizedChi2()), float(0), float(0), int((muon->globalTrack())->hitPattern().numberOfValidMuonHits())); } cout << endl; } } for ( reco::MuonCollection::const_iterator muon = muons->begin(); muon != muons->end(); ++ muon ) { //if (muon->isGlobalMuon()&&muon->isTrackerMuon()) { // add only if global and tracker muons if (muon->isGlobalMuon()&& (muon->isTrackerMuon() || fAllowGlobalOnly)) { // add all global muons for tests // reco::TrackRef gt=muon->innerTrack(); if (fVerbose > 0) cout << "==>HFDumpSignal> found global muon " << endl; pTrack = gHFEvent->addSigTrack(); /* this goes/went into HFDUmpMuons! if (muon->isTrackerMuon()){ pTrack->fKaID = 1; pTrack->fMuType = 0;}else{ pTrack->fKaID = 0; pTrack->fMuType = 5;} if (muon->isGlobalMuon()){ pTrack->fMCID = 1;}else{pTrack->fMCID=0;} pTrack->fMuType = 0; //0=RECO, 1=L1, 2=HLTL2, 3=HLTL3 pTrack->fMuID = (muon->track()).index(); //index of muon track in RECO track block pTrack->fIndex = index; //index in muon block pTrack->fGenIndex = -1; //not used here pTrack->fQ = muon->charge(); //charge pTrack->fPlab.SetPtEtaPhi(muon->pt(), muon->eta(), muon->phi() ); pTrack->fChi2 = (muon->globalTrack())->chi2(); pTrack->fDof = int((muon->globalTrack())->ndof()); pTrack->fHits = (muon->globalTrack())->numberOfValidHits(); pTrack->fMuonSelector = 0; bool laststation = muon::isGoodMuon(*muon, muon::TMLastStationAngTight); bool tightmuon = muon::isGoodMuon(*muon, muon::GlobalMuonPromptTight); bool matched = muon->numberOfMatches()>1; if (laststation) pTrack->fMuonSelector +=1; if (tightmuon) pTrack->fMuonSelector +=2; if (matched) pTrack->fMuonSelector +=4; if (muon->isTrackerMuon()) pTrack->fMuonSelector +=8; pTrack->fMuonCSCHits = (muon->globalTrack())->hitPattern().numberOfValidMuonCSCHits(); pTrack->fMuonDTHits = (muon->globalTrack())->hitPattern().numberOfValidMuonDTHits(); pTrack->fMuonRPCHits = (muon->globalTrack())->hitPattern().numberOfValidMuonRPCHits(); pTrack->fMuonHits = (muon->globalTrack())->hitPattern().numberOfValidMuonHits(); pTrack->fBPIXHits = (muon->globalTrack())->hitPattern().numberOfValidPixelBarrelHits(); pTrack->fFPIXHits = (muon->globalTrack())->hitPattern().numberOfValidPixelEndcapHits(); pTrack->fPixelHits = (muon->globalTrack())->hitPattern().numberOfValidPixelHits(); pTrack->fStripHits = (muon->globalTrack())->hitPattern().numberOfValidStripHits(); pTrack->fTECHits = (muon->globalTrack())->hitPattern().numberOfValidStripTECHits(); pTrack->fTIBHits = (muon->globalTrack())->hitPattern().numberOfValidStripTIBHits(); pTrack->fTIDHits = (muon->globalTrack())->hitPattern().numberOfValidStripTIDHits(); pTrack->fTOBHits = (muon->globalTrack())->hitPattern().numberOfValidStripTOBHits(); pTrack->fBPIXLayers = (muon->globalTrack())->hitPattern().pixelBarrelLayersWithMeasurement(); pTrack->fFPIXLayers = (muon->globalTrack())->hitPattern().pixelEndcapLayersWithMeasurement(); pTrack->fPixelLayers = (muon->globalTrack())->hitPattern().pixelLayersWithMeasurement(); pTrack->fStripLayers = (muon->globalTrack())->hitPattern().stripLayersWithMeasurement(); pTrack->fTECLayers = (muon->globalTrack())->hitPattern().stripTECLayersWithMeasurement(); pTrack->fTIBLayers = (muon->globalTrack())->hitPattern().stripTIBLayersWithMeasurement(); pTrack->fTIDLayers = (muon->globalTrack())->hitPattern().stripTIDLayersWithMeasurement(); pTrack->fTOBLayers = (muon->globalTrack())->hitPattern().stripTOBLayersWithMeasurement(); pTrack->fTrChi2norm = muon->innerTrack()->normalizedChi2(); // chi2 of the tracker track pTrack->fExpectedHitsInner = (muon->innerTrack())->trackerExpectedHitsInner().numberOfHits(); pTrack->fExpectedHitsOuter = (muon->innerTrack())->trackerExpectedHitsOuter().numberOfHits(); pTrack->fLostHits = (muon->innerTrack())->hitPattern().numberOfLostTrackerHits(); pTrack->fValidHitInFirstPixelBarrel=(muon->innerTrack())->hitPattern().hasValidHitInFirstPixelBarrel(); pTrack->fDxybs = muon->innerTrack()->dxy(bs); // Dxy relative to the beam spot pTrack->fDzbs = muon->innerTrack()->dz(bs); // dz relative to bs or o if not available // find the nearest primary vertex double dmin=9999.; double ztrack=muon->vertex().Z(); const reco::Vertex* pVertex =&(*primaryVertex->begin()); // if selection below fails, take the first one for (reco::VertexCollection::const_iterator iv = primaryVertex->begin(); iv != primaryVertex->end(); ++iv) { if (iv->ndof()>fVertexMinNdof){ if (fabs(ztrack-iv->z()) < dmin){ dmin=fabs(ztrack-iv->z()); pVertex=&(*iv); } } } // impact parameter of the tracker track relative to the PV pTrack->fDxypv = muon->innerTrack()->dxy(pVertex->position()); pTrack->fDzpv = muon->innerTrack()->dz(pVertex->position()); pTrack->fDxyE = muon->innerTrack()->dxyError(); // error on Dxy pTrack->fDzE = muon->innerTrack()->dzError(); pTrack->fMuonIsosumPT = muon->isolationR03().sumPt; // muon isolations pTrack->fMuonIsoEcal = muon->isolationR03().emEt; pTrack->fMuonIsoHcal = muon->isolationR03().hadEt; pTrack->fMuonCalocomp = muon->caloCompatibility(); pTrack->fMuonCalocomp = muon->caloCompatibility(); pTrack->fVertex.SetXYZ(muon->vertex().X(), muon->vertex().Y(), muon->vertex().Z() ); pTrack->fMuonVertexChi2=muon->vertexChi2(); pTrack->fDxysimv = -9999; // first sim vertex pTrack->fDzsimv = -9999; if(simvFound) { pTrack->fDxysimv = muon->innerTrack()->dxy(simv0); pTrack->fDzsimv = muon->innerTrack()->dz(simv0); } if(hasRefittedTracks){ if(useRefittedTracks){ //const reco::Track* refitted = g2r[muon->innerTrack()->pt()]; const reco::Track refitted = generalTracksH->at((muon->innerTrack()).index()); pTrack->fDxypv = refitted.dxy(bs); pTrack->fDxysimv = refitted.dxy(simv0); }else{ pTrack->fDxypv = -99999.; pTrack->fDxysimv = -99999.; } } // pTrack->fLip = -9999; pTrack->fLipE = -9999; pTrack->fTip = -9999; pTrack->fTipE = -9999; // 3d and transverse impact parameters pTrack->fTip3d = -9999; pTrack->fTip3dE = -9999; // 3d and transverse impact parameters pTrack->fIndxj = -9999; // index of the closest jets after selection pTrack->fMuonPtrel = -9999; // ptrel to this jet, can be racalculated latter pTrack->fDxypvnm = -9999; // dx pTrack->fDxypvnm = muon->innerTrack()->dxy(vpnm);y relative to vertex without the muon */ //calculate signed transverse ip //get closest jet, use it to calculate 3dIP if(jetsH.isValid()) { const BasicJetCollection *jets = jetsH.product(); if(candidates1Handle.isValid() ){ //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% if ( (muon->track()).index() <= candidates1Handle->size() ) { double rmin = fJetMatch; BasicJet* matchedjet=0; bool found = false; int indj=0; if (fVerbose > 0) cout<<" trackjets "<<jets->size()<<endl; for ( BasicJetCollection::const_iterator it = jets->begin(); it != jets->end(); it ++ ) { TVector3 jetcand; jetcand.SetPtEtaPhi(it->pt(), it->eta(), it->phi()); double r = (pTrack->fPlab).DeltaR(jetcand); if (r<rmin && it->et() > fJetEtMin) { rmin = r; matchedjet = (*it).clone(); found = true; //FIXME pTrack->fIndxj=indj; } indj++; } if (found) {//found a track jet if (fVerbose > 0) cout << "==>HFDumpSignal> found a trackjet close to muon " << endl; //subtract muon TLorentzVector vect; vect.SetPtEtaPhiE(matchedjet->pt(), matchedjet->eta(), matchedjet->phi(), matchedjet->energy()); bool foundmuon = false; std::vector< const reco::Candidate * > Constituent = matchedjet->getJetConstituentsQuick(); if (fVerbose > 0) cout<<" matchedjet tracks "<<Constituent.size()<<endl; //5555555555555555555555555555555555555555555 //jet constituents for (unsigned int i=0; i< Constituent.size(); i++) { unsigned int idx = 99999; const reco::Candidate * consti = Constituent[i]; if (consti) { //get index of consti in all tracks for (unsigned int j = 0; j < candidates1Handle->size(); ++ j ) { const Candidate &p2 = (*candidates1Handle)[j]; const Candidate * p1 = &p2; if (consti->pt() == p1->pt() && consti->phi() == p1->phi() && consti->eta() == p1->eta() ) idx = j; } //check whether the index of consti in tracks is the same as the index of the muon track if (idx == (muon->track()).index()) { foundmuon = true; if (fVerbose) cout << "muon " << idx << " pt " << consti->pt() << " phi " << consti->phi() << " eta " << consti->eta() << endl; } } } // jet const if (foundmuon) { TLorentzVector muvect; muvect.SetPtEtaPhiM(muon->track()->pt(), muon->track()->eta(), muon->track()->phi(), mmuon); vect = vect - muvect; //FIXME pTrack->fMuonPtrel=muvect.Perp(vect.Vect()); //Ptrel in respct to the corrected jets direction } //define direction GlobalVector direction(vect.X(),vect.Y(),vect.Z()); const TransientTrack & transientTrack = builder->build(&(*(muon->track()))); /*FIXME pTrack->fTip3d = IPTools::signedImpactParameter3D(transientTrack,direction,*pVertex).second.value(); pTrack->fTip3dE = IPTools::signedImpactParameter3D(transientTrack, direction, *pVertex).second.error(); pTrack->fTip = IPTools::signedTransverseImpactParameter(transientTrack, direction, *pVertex).second.value(); pTrack->fTipE = IPTools::signedTransverseImpactParameter(transientTrack, direction, *pVertex).second.error(); FIXME*/ } //found trackjet in dR } // tracks=muon check } // tracks valid } // trackjets valid //// find a vertex to which muon belongs and remove it from vertex track list, get myVertex // match by dR<0.1 double drmin=0.1; bool findmuon=false; double dzmax=10000.; vector<TransientTrack> mytracks; const Vertex* pvr0=0; if( primaryVertex.isValid()){ int ipv=0; for (reco::VertexCollection::const_iterator pv = primaryVertex->begin(); pv!= primaryVertex->end(); ++pv){ pvr0=0; double ddz= muon->innerTrack()->dz(pv->position()); if(abs(ddz)<dzmax) { dzmax=ddz; pvr0 =&(*pv); } for(std::vector<TrackBaseRef>::const_iterator pvt = pv->tracks_begin(); pvt != pv->tracks_end(); pvt++) { TVector3 trkcand; TrackRef pvtr=pvt->castTo<TrackRef>(); trkcand.SetPtEtaPhi(pvtr->pt(), pvtr->eta(), pvtr->phi()); double ddr = (pTrack->fPlab).DeltaR(trkcand); if (fVerbose > 0) cout<<"ipv "<<ipv<<" "<<ddr<<"= dr pvtr pt"<< pvtr->pt()<<" pTrack->fPlabpb "<< pTrack->fPlab.Perp()<<endl; if(ddr<drmin) { // found muon findmuon=true; } else { // fill mytracks TransientTrack transientTrack = builder->build(pvtr); if (beamSpotCollection.isValid()) { reco::BeamSpot vertexBeamSpot_= *beamSpotCollection; transientTrack.setBeamSpot(vertexBeamSpot_); } mytracks.push_back(transientTrack); } //ddr } //pvt // build vertex wo muon if(findmuon) { if (fVerbose > 0) cout<<" muon is found in PV"<<endl; AdaptiveVertexFitter* theFitter=new AdaptiveVertexFitter(); // this can be used for rererecos when bs is well defined // if (beamSpotCollection.isValid()) { //reco::BeamSpot vertexBeamSpot_= *beamSpotCollection; // TransientVertex myVertex = theFitter->vertex(mytracks, vertexBeamSpot_); //fit with beam-constraint // } TransientVertex myVertex = theFitter->vertex(mytracks); // fit without beam-constraint if(myVertex.isValid()&&myVertex.degreesOfFreedom()>1){ // require at least 2 degree of freedom //FIXME math::XYZPoint vpnm = math::XYZPoint(myVertex.position().x(),myVertex.position().y(),myVertex.position().z()); //FIXME pTrack->fDxypvnm = muon->innerTrack()->dxy(vpnm); // transverse IP without muon // using z beam direction GlobalVector direction(0.,0.,1.); const TransientTrack & transientTrack = builder->build(&(*(muon->track()))); const Vertex vv(myVertex); //PV without muon /* FIXME pTrack->fTip3d = IPTools::signedImpactParameter3D(transientTrack,direction,vv).second.value(); pTrack->fTip3dE = IPTools::signedImpactParameter3D(transientTrack, direction, vv).second.error(); pTrack->fLip = IPTools::signedTransverseImpactParameter(transientTrack, direction, vv).second.value(); pTrack->fLipE = IPTools::signedTransverseImpactParameter(transientTrack, direction, vv).second.error(); FIXME */ } // valid myvertex delete theFitter; break; // break after the first found vertex with muon }//foundmuon ipv++; } //pv } //pv valid // use vertex closest in z if muon not found in pv collection // in this case the pTrack->fLip stays indefined in order to distinguish if(!findmuon&&pvr0) { //FIXME math::XYZPoint vpnm = math::XYZPoint(pvr0->position().x(),pvr0->position().y(),pvr0->position().z()); //FIXME pTrack->fDxypvnm = muon->innerTrack()->dxy(vpnm); // transverse IP for closest Iin z //FIXME pTrack->fLip =-99999.; // different from default -9999 } if (fVerbose > 0) { pTrack->dump(); /* FIXME cout << " dump muon" << endl; cout << "pTrack->fTip3d=" << pTrack->fTip3d << "+-" << pTrack->fTip3dE << endl; cout << "pTrack->fTip=" << pTrack->fTip << "+-" << pTrack->fTipE << endl; cout << "pTrack->fLip=" << pTrack->fLip << "+-" << pTrack->fLipE << endl; cout << "pTrack->fDxypv= " <<pTrack->fDxypv << endl; cout << "pTrack->fDxypvnm= " <<pTrack->fDxypvnm << endl; cout << "pTrack->fDxysimv= " <<pTrack->fDxysimv << endl; FIXME */ } }//is global muon //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% index++; } //muon if (fVerbose > 0) cout<<" --->HFDumpSignal "<< index << endl; } // ------------ method called once each job just before starting event loop ------------ //void HFDumpSignal::beginJob(const edm::EventSetup& setup) { void HFDumpSignal::beginJob() { nevt=0; } // ------------ method called once each job just after ending the event loop ------------ void HFDumpSignal::endJob() { cout << "HFDumpSignal> Summary: Events processed: " << nevt << endl; } //define this as a plug-in DEFINE_FWK_MODULE(HFDumpSignal);
[ "urs.langenegger@psi.ch" ]
urs.langenegger@psi.ch
f67036819575d28162a8fa957d61720f00b69fa9
4ea4caa41cc1c7a701561a28cc537e6def0b4a07
/Learn.DesignPattern/Learn.DesignPattern/src/FactoryPattern.cpp
764eff20003561d63c0b794b764ca7bde81e286f
[]
no_license
wqshare/LearnDesignPattern
0204cf272f200129db240f4d3fa807887756f53e
2fb96e7088a640dda58d25df7e5785374dfbee74
refs/heads/master
2020-04-01T16:34:02.901274
2014-10-11T02:20:00
2014-10-11T02:20:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
29
cpp
#include "FactoryPattern.h"
[ "wqshare_1@163.com" ]
wqshare_1@163.com
4b2709bd501394cb1522686e77179fb6984c4d1a
67c17a7d44f99d0a1073eba6f8e04972646453cf
/Simon/simonmodel.h
3a868dc61e8c167a820a9f2ac338bcae0fc895ed
[]
no_license
jordancdavis/Simon
11d193d049c2e35bcde16becfcbf125fd3a6aa09
db69f383d8beff1d341c2ca03c375785978b0201
refs/heads/master
2021-01-10T09:21:53.961902
2016-03-24T03:03:57
2016-03-24T03:03:57
53,250,445
0
0
null
null
null
null
UTF-8
C++
false
false
1,171
h
/* * @ author Karla Kraiss & Jordan Davis * 3/2/2016 * description * */ #ifndef SIMONMODEL_H #define SIMONMODEL_H #include <QObject> #include <time.h> #include <QDebug> #include <QTime> #include <QTimer> #include <cstdlib> #include <ctime> class SimonModel : public QObject { private: Q_OBJECT int clickCount; int flashPauseDuration; int gameSpeed; int hintsRemaining; bool gameInProgress; bool isPlayersTurn; bool reachedNextLevel; bool allowHint; QTimer* buttonFlashTimer; QTimer* flashPauseTimer; public: explicit SimonModel(QObject *parent = 0); QList<int> computerMoves; void playComputer(); int getNextColor(); void getNextSequenceFromSimon(); void getNextSequenceFromPlayer(); signals: void flashColor(int); void flashDone(); void startToRestart(); void simonsTurn(); void playersTurn(); void updateProgress(int, int); void endGame(); void provideHints(int, int); public slots: void ColorClicked(int); void StartClicked(); void flashButtonTimerFinished(); void flashPauseTimerFinished(); void GiveHint(); }; #endif // SIMONMODEL_H
[ "jordancdavis14@gmail.com" ]
jordancdavis14@gmail.com
28d55f929def92f401d4a3b4b445171d71ec4a58
0b4cab24e8e2df80cd9a8889018cfd19a60e834c
/LibCore/NetLib/src/NetHandlerTransit.cpp
c3a92c2ed1d473c89f39229f53b914f80851e357
[]
no_license
woopengcheng/LibCore
77b2afb917edb4f5fd7b173e88d39a7114030379
e3ebdc70f2429b9deafe387cecd505900ca7ac69
refs/heads/master
2021-06-13T04:05:29.411325
2017-06-05T05:26:39
2017-06-05T05:26:39
28,578,832
3
0
null
null
null
null
UTF-8
C++
false
false
13,131
cpp
extern "C" { #include "zmq.h" } #include "RakPeerInterface.h" #include "BitStream.h" #include "RakNetTypes.h" #include "MessageIdentifiers.h" #include "NetLib/inc/NetHandlerTransit.h" #include "NetLib/inc/NetHelper.h" #include "NetLib/inc/ByteOrder.h" #include "NetLib/inc/ISession.h" #include "NetLib/inc/NetReactorUDP.h" #include "NetLib/inc/NetReactorRakNet.h" #include "NetLib/inc/INetReactor.h" #include "NetLib/inc/NetThread.h" #include "Timer/inc/TimerHelp.h" #ifdef WIN32 #include "Winsock.h" #endif namespace Net { NetHandlerTransit::NetHandlerTransit( INetReactor * pNetReactor , ISession * pSession ) : INetHandler(pNetReactor, pSession) , m_pZmqContext(NULL) , m_pZmqMsg(NULL) , m_pZmqSocket(NULL) { m_objRecvBuf.Init(DEFAULT_CIRCLE_BUFFER_SIZE); m_objSendBuf.Init(DEFAULT_CIRCLE_BUFFER_SIZE); if (m_pSession && m_pNetReactor) { m_pSession->SetReactorType(m_pNetReactor->GetReactorType()); } } NetHandlerTransit::~NetHandlerTransit( void ) { m_objSendBuf.Cleanup(); m_objRecvBuf.Cleanup(); if (m_pNetReactor->GetReactorType() == REACTOR_TYPE_ZMQ) { MsgAssert(zmq_close(m_pZmqSocket), "error in zmq_close" << zmq_strerror(errno)); MsgAssert(zmq_term(m_pZmqContext), "error in zmq_term:" << zmq_strerror(errno)); SAFE_DELETE(m_pZmqMsg); } } CErrno NetHandlerTransit::OnMsgRecving( void ) { char szBuf[DEFAULT_CIRCLE_BUFFER_SIZE]; NetSocket socket = m_pSession->GetSocket(); INT32 nBufSize = 0; UINT32 unMaxBufSize = sizeof(szBuf); do { switch (m_pSession->GetReactorType()) { case REACTOR_TYPE_UDP: { UDPContext * pContext = (UDPContext *)m_pSession->GetContext(); if (pContext) { INT32 nRecLen = sizeof(pContext->GetPeerAddr()); nBufSize = NetHelper::RecvMsg(socket, szBuf, sizeof(szBuf), (sockaddr*)&(pContext->GetPeerAddr()), &nRecLen); } }break; case REACTOR_TYPE_UDS: { UDSContext * pContext = (UDSContext *)m_pSession->GetContext(); if (pContext) { INT32 nRecvFD = 0; nBufSize = NetHelper::RecvMsg(socket, szBuf, sizeof(szBuf), nRecvFD); pContext->SetTransferFD(nRecvFD); } }break; case REACTOR_TYPE_RAKNET: { nBufSize = RecvMsgRakNet(szBuf, sizeof(szBuf)); }break; case REACTOR_TYPE_ZMQ: { INT32 nResult = zmq_msg_init(m_pZmqMsg); if (nResult != 0) { gErrorStream("error in zmq_msg_init: %s\n" << zmq_strerror(errno)); return CErrno::Failure(); } nBufSize = NetHelper::RecvMsg(m_pZmqSocket , m_pZmqMsg , szBuf, sizeof(szBuf)); }break; default: { nBufSize = NetHelper::RecvMsg(socket, szBuf, sizeof(szBuf)); }break; } if( nBufSize < 0 && NetHelper::IsSocketEagain() && m_pNetReactor->GetReactorType() != REACTOR_TYPE_ZMQ) return CErrno::Success(); if( nBufSize <= 0 ) return CErrno::Failure(); CErrno result = OnMsgRecving(szBuf , nBufSize); if( !result.IsSuccess() ) return result; if (m_pNetReactor->GetReactorType() == REACTOR_TYPE_ZMQ) { INT32 nResult = zmq_msg_close(m_pZmqMsg); if (nResult != 0) { gErrorStream("error in zmq_msg_close: %s" << zmq_strerror(errno)); return CErrno::Failure(); } } }while(0); return CErrno::Success(); } CErrno NetHandlerTransit::OnMsgRecving(const char * pBuf , UINT32 unSize) { return RecvToCircleBuffer( pBuf , unSize); } CErrno NetHandlerTransit::RecvToCircleBuffer(const char * pBuf, UINT32 unSize) { if(m_objRecvBuf.GetSpace() > unSize) { if (m_pSession) { m_pSession->OnRecvMsg(); } m_objRecvBuf.PushBuffer(pBuf , unSize); ParaseRecvMsg(); } else { MsgAssert_Re(0 , CErrno::Failure() , "buffer full."); this->m_objRecvBuf.SkipBytes(m_objRecvBuf.GetDataLength()); return CErrno::Failure(); } return CErrno::Success(); } CErrno NetHandlerTransit::ParaseRecvMsg() { while(m_objRecvBuf.GetDataLength() > 0) { UINT32 unMsgLength = 0; INT32 nRecvBuf = (size_t)m_objRecvBuf.TryGetBuffer((char*)&unMsgLength , sizeof(UINT32)); if(nRecvBuf < sizeof(UINT32)) { gErrorStream( "parase msg header failed."); return CErrno::Failure(); } // Convert<UINT32>::ToHostOrder(unMsgLength); if(unMsgLength > MAX_MESSAGE_LENGTH || unMsgLength <= 0) { gErrorStream( "error package len ,discard connection"); return CErrno::Failure(); } if(m_objRecvBuf.GetDataLength() < unMsgLength) return CErrno::Success(); char szBuf[MAX_MESSAGE_LENGTH]; m_objRecvBuf.GetBuffer(szBuf , unMsgLength); HandleMsg(szBuf, unMsgLength); } return CErrno::Success(); } CErrno NetHandlerTransit::OnMsgSending( void ) { if (m_pSession) { m_pSession->SetCanWrite(TRUE); } FlushSendBuffer(); return CErrno::Success(); } INT32 NetHandlerTransit::FlushSendBuffer( void ) { INT32 nSendBytes = 0; if (m_pSession) { m_pSession->OnSendMsg(); } while(true) { if(!m_objSendBuf.IsVaild() || m_objSendBuf.GetDataLength() <= 0 || !m_pSession->IsCanWrite()) break; char szBuf[DEFAULT_CIRCLE_BUFFER_SIZE]; INT32 nLength = m_objSendBuf.TryGetBuffer(szBuf,sizeof(szBuf)); INT32 nSendLength = Send(szBuf, nLength); // #ifndef WIN32 // INT32 nSendLength = ::send(m_pSession->GetSocket(),szBuf,nLength,MSG_DONTWAIT); // #else // INT32 nSendLength = ::send(m_pSession->GetSocket(),szBuf,nLength,0); // #endif if( nSendLength > 0 ) { nSendBytes += nSendLength; m_objSendBuf.SkipBytes(nSendLength); } else if(nSendLength < 0 && NetHelper::IsSocketEagain()) { if (m_pSession) { m_pSession->SetCanWrite(FALSE); } break; } else { gErrorStream("send error , close it."); m_pSession->SetClosed(TRUE); break; } } return nSendBytes; } INT32 NetHandlerTransit::SendMsg(const char * pBuf, UINT32 unSize) { if(m_objSendBuf.IsVaild() && m_objSendBuf.GetDataLength() >= 0) { if(m_objSendBuf.GetSpace() > unSize) { m_objSendBuf.PushBuffer(pBuf , unSize); FlushSendBuffer(); } else { FlushSendBuffer(); if(m_objSendBuf.GetSpace() > unSize) { m_objSendBuf.PushBuffer(pBuf , unSize); } else if(m_objSendBuf.GetDataLength() == 0) { INT32 nSendBytes = Send(pBuf , unSize); if( nSendBytes <= 0) { gErrorStream("sendbuffer.length=0,direct send failed"); return -1; } else if(nSendBytes != unSize) { gErrorStream("sendbuffer.length=0,direct send failed"); return -1; } return (nSendBytes > 0) ? nSendBytes : -1; } else { gErrorStream("sendbuff not empty"); return -1; } } return unSize; } return Send(pBuf , unSize); } INT32 NetHandlerTransit::SendUDS(const char * pBuf, UINT32 unSize) { UDSContext * pContext = (UDSContext *)(m_pSession->GetContext()); if (pContext == NULL) { return -1; } INT32 send_fd = send_fd = pContext->GetTransferFD(); #ifdef _LINUX int ret; struct msghdr msg; struct cmsghdr *p_cmsg; struct iovec vec; char cmsgbuf[CMSG_SPACE(sizeof(send_fd))]; int *p_fds; char sendchar = 0; msg.msg_control = cmsgbuf; msg.msg_controllen = sizeof(cmsgbuf); p_cmsg = CMSG_FIRSTHDR(&msg); p_cmsg->cmsg_level = SOL_SOCKET; p_cmsg->cmsg_type = SCM_RIGHTS; p_cmsg->cmsg_len = CMSG_LEN(sizeof(send_fd)); p_fds = (int *)CMSG_DATA(p_cmsg); *p_fds = send_fd; // 通过传递辅助数据的方式传递文件描述符 msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = &vec; msg.msg_iovlen = 1; //主要目的不是传递数据,故只传1个字符 msg.msg_flags = 0; vec.iov_base = &sendchar; vec.iov_len = sizeof(sendchar); ret = sendmsg(sock_fd, &msg, 0); if (ret != 1) ERR_EXIT("sendmsg"); #endif return -1; } INT32 NetHandlerTransit::SendRakNet(const char * pBuf, UINT32 unSize) { RakNet::BitStream bs; bs.Write((RakNet::MessageID)ID_DEFAULT_RAKNET_USER_PACKET); bs.Write(unSize); bs.Write(pBuf); RakNet::RakPeerInterface * pRakPeerInstance = ((NetReactorRakNet *)(this->GetNetReactor()))->GetRakPeerInterface(); if (pRakPeerInstance) { UINT32 unResult = pRakPeerInstance->Send(&bs, HIGH_PRIORITY, RELIABLE_ORDERED, 0, pRakPeerInstance->GetSystemAddressFromIndex(0), false); if (unResult == 0) return -1; return unResult; } return -1; } INT32 NetHandlerTransit::SendZMQ(const char * pBuf, UINT32 unSize) { int nResult = zmq_msg_init_data(m_pZmqMsg, (void *)pBuf, unSize, NULL, NULL); if (nResult != 0) { gErrorStream("error in zmq_msg_init_size: %s\n" << zmq_strerror(errno)); return -1; } int nCount = zmq_sendmsg(m_pZmqSocket, m_pZmqMsg, 0); if (nCount < 0) { gErrorStream("error in zmq_sendmsg: %s\n" << zmq_strerror(errno)); return -1; } nResult = zmq_msg_close(m_pZmqMsg); if (nResult != 0) { printf("error in zmq_msg_close: %s\n", zmq_strerror(errno)); return -1; } return nCount; } INT32 NetHandlerTransit::Send(const char * pBuf, UINT32 unSize) { if (m_pSession) { switch (m_pSession->GetReactorType()) { case REACTOR_TYPE_IOCP: { return SendIOCP(pBuf, unSize); }break; case REACTOR_TYPE_ZMQ: { return SendZMQ(pBuf, unSize); }break; case REACTOR_TYPE_UDP: { return SendTo(pBuf , unSize); }break; case REACTOR_TYPE_UDS: { return SendUDS(pBuf, unSize); }break; case REACTOR_TYPE_RAKNET: { return SendRakNet(pBuf, unSize); }break; default: { return SendCommon(pBuf, unSize); }break; } } return -1; } INT32 NetHandlerTransit::SendIOCP(const char * pBuf, UINT32 unSize) { return NetHelper::WSASend(this, pBuf , unSize); } INT32 NetHandlerTransit::SendCommon(const char * pBuf, UINT32 unSize) { if (m_pSession && !m_pSession->IsCanWrite()) { return -1; } UINT32 unTotalSendBytes = 0; while ((unSize > unTotalSendBytes)) { #ifdef WIN32 int nSendBytes = ::send(m_pSession->GetSocket(), &pBuf[unTotalSendBytes], unSize - unTotalSendBytes, 0); #else int nSendBytes = ::send(m_pSession->GetSocket(), &pBuf[unTotalSendBytes], unSize - unTotalSendBytes, MSG_DONTWAIT); #endif if (nSendBytes > 0) { unTotalSendBytes += nSendBytes; } else if (nSendBytes < 0 && NetHelper::IsSocketEagain()) { m_pSession->SetCanWrite(FALSE); break; } else { gErrorStream("send error , close it.addr:" << m_pSession->GetAddress() << "=port:" << m_pSession->GetPort()); m_pSession->SetClosed(TRUE); break; } Timer::sleep(1); } return unTotalSendBytes; } INT32 NetHandlerTransit::SendTo(const char * pBuf, UINT32 unSize) { if (m_pSession && !m_pSession->IsCanWrite()) { return -1; } UDPContext * pContext = (UDPContext *)m_pSession->GetContext(); if (!pContext) { return -1; } UINT32 unTotalSendBytes = 0; while ((unSize > unTotalSendBytes)) { #ifdef WIN32 int nSendBytes = ::sendto(m_pSession->GetSocket(), &pBuf[unTotalSendBytes], unSize - unTotalSendBytes, 0 , (sockaddr*)&(pContext->GetPeerAddr()) , sizeof(pContext->GetPeerAddr())); #else int nSendBytes = ::send(m_pSession->GetSocket(), &pBuf[unTotalSendBytes], unSize - unTotalSendBytes, MSG_DONTWAIT, (sockaddr*)&(pContext->GetPeerAddr()), sizeof(pContext->GetPeerAddr())); #endif if (nSendBytes > 0) { unTotalSendBytes += nSendBytes; } else if (nSendBytes < 0 && NetHelper::IsSocketEagain()) { m_pSession->SetCanWrite(FALSE); break; } else { gErrorStream("send error , close it.addr:" << m_pSession->GetAddress() << "=port:" << m_pSession->GetPort()); m_pSession->SetClosed(TRUE); break; } Timer::sleep(1); } return unTotalSendBytes; } CErrno NetHandlerTransit::HandleMsg(const char* pBuffer, UINT32 unLength) { MsgHeader * pHeader = (MsgHeader*)pBuffer; return HandleMsg(m_pSession, pHeader->unMsgID, pBuffer + sizeof(MsgHeader), pHeader->unMsgLength - sizeof(MsgHeader)); } CErrno NetHandlerTransit::HandleMsg(ISession * pSession, UINT32 unMsgID, const char* pBuffer, UINT32 unLength) { return CErrno::Success(); } CErrno NetHandlerTransit::OnClose(void) { if (m_pSession) { m_pSession->OnClose(); } return CErrno::Success(); } CErrno NetHandlerTransit::Update( void ) { return INetHandler::Update(); } CErrno NetHandlerTransit::Init( void ) { return INetHandler::Init(); } CErrno NetHandlerTransit::Cleanup( void ) { return INetHandler::Cleanup(); } }
[ "woopengcheng@163.com" ]
woopengcheng@163.com
097b4de69dd13070fff8da20e43e6de278367224
0fb8dfce2ebfb34f7087e4be6ae53244cd4c832f
/Chapter3_VectorGeometry/src/geometryhelpers/DemoTriangleIntersection.h
572cb7a4f4615f69a8eb75afdae0ac651ee55f8c
[]
no_license
bendova/3DMath
8c2e7904c82a6eb41cd41bac821c4937c0e38e6d
1bdfd3a3c096881ca114c9706ec22062d7768f54
refs/heads/master
2021-01-17T09:33:21.243225
2016-03-20T15:18:41
2016-03-20T15:18:41
33,807,881
0
0
null
null
null
null
UTF-8
C++
false
false
1,197
h
#ifndef _MY_CODE_DEMO_TRIANGLE_INTERSECTION_H_ #define _MY_CODE_DEMO_TRIANGLE_INTERSECTION_H_ #include "MathUtil.h" #include "../PolygonMath.h" #include "vectormath/DataTypes.h" namespace MyCode { class TriangleRenderer; using namespace VectorMath; class DemoTriangleIntersection { public: DemoTriangleIntersection(TriangleRenderer& renderer); ~DemoTriangleIntersection(); private: void AddIntersectionAreas(); void AddTriangleArea(const float scaleFactor, const float offsetX, const float offsetZ); void AddRombusArea(const float scaleFactor, const float offsetX, const float offsetZ); void AddTrapezeArea(const float scaleFactor, const float offsetX, const float offsetZ); void AddPentagonArea(const float scaleFactor, const float offsetX, const float offsetZ); void AddHexagonArea(const float scaleFactor, const float offsetX, const float offsetZ); void ApplyScaleFactor(Triangle& t, const float scaleFactor); void ApplyOffset(Triangle& t, const float offsetX, const float offsetY, const float offsetZ); Color mColorA; Color mColorB; Color mColorIntersection; TriangleRenderer& mTriangleRenderer; }; } #endif //_MY_CODE_DEMO_TRIANGLE_INTERSECTION_H_
[ "mariusvalentin.stan@gmail.com" ]
mariusvalentin.stan@gmail.com
1980afc2ed84af4bff7a0f9df76c1809e07564b7
a95e053a60cacdb5e50bcb9db0573adea7b79a02
/CSCI 2270/Datastructure Lecture Notes/hash.cpp
c14f7151103c06d3273f1e6813c0c85b57820ad7
[]
no_license
Doubletake27/CSCI1320
acfdc8f7c91cc8a4264b99407289e480bda0f538
12faba6a65430e74fa1d1f70d8d592165536fbdd
refs/heads/master
2021-06-15T20:47:51.334728
2021-03-03T18:27:29
2021-03-03T18:27:29
155,876,241
0
0
null
null
null
null
UTF-8
C++
false
false
582
cpp
#include <iostream> using namespace std; struct Student{ string name; int sid; }; hashSum(string key, int keyLength, int size){ int sum = 0; for(int i = 0; i < keyLength; i++){ sum += key[i]; } return (sum%size); } int main(){ int hashSize = 4; Student hashTable[hashSize]; Student sIn; sIn.name = "anna"; sIn.sid = 823; int index = hashSum(sIn.name,4,hashSize); cout << " index for " << sIn.name << " = " << index << endl; hashTable[index] = sIn; Student sOut = hashTable[hashSum("anna",4,hashSize)]; return 0; } // md5sum can be useful
[ "henry.meyerson@gmail.com" ]
henry.meyerson@gmail.com
2bcb8adda7cbd6a2a87fc22863453954e83520c1
daffb5f31e4f2e1690f4725fad5df9f2382416e3
/AtCoder/DP_Edu/J/main.cpp
7177f6e8eda95052eb43aeac2bbba8f2714282eb
[]
no_license
cuom1999/CP
1ad159819fedf21a94c102d7089d12d22bb6bfa2
4e37e0d35c91545b3d916bfa1de5076a18f29a75
refs/heads/master
2023-06-02T01:57:00.252932
2021-06-21T03:41:34
2021-06-21T03:41:34
242,620,572
0
0
null
null
null
null
UTF-8
C++
false
false
1,340
cpp
#include <bits/stdc++.h> #define ld long double #define sf scanf #define pf printf #define pb push_back #define mp make_pair #define PI ( acos(-1.0) ) #define IN freopen("input.txt","r",stdin) #define OUT freopen("output.txt","w",stdout) #define FOR(i,a,b) for(int i=a ; i<=b ; i++) #define FORD(i,a,b) for(int i=a ; i>=b ; i--) #define INF 1000000000 #define ll long long int #define eps (1e-8) #define sq(x) ( (x)*(x) ) #define all(x) x.begin(),x.end() #define flog2(n) 64 - __builtin_clzll(n) - 1 #define popcnt(n) __builtin_popcountll(n) using namespace std; typedef pair < int, int > pii; typedef pair < ll, ll > pll; ld d[305][305][305]; int cnt[5]; int n; ld calc (int i, int j, int k) { if (i < 0 || j < 0 || k < 0) return 0; if (d[i][j][k] != -1) return d[i][j][k]; int sum = i + j + k; return d[i][j][k] = n * 1.0 / sum + calc(i, j + 1, k - 1) * k * 1.0 / sum + calc(i + 1, j - 1, k) * j * 1.0 / sum + calc(i - 1, j, k) * i * 1.0 / sum; } int main() {IN; ios::sync_with_stdio(0); cin.tie(NULL); cin >> n; FOR (i, 1, n) { int x; cin >> x; cnt[x]++; } FOR (i, 0, n) { FOR (j, 0, n) { FOR (k, 0, n) { d[i][j][k] = -1; } } } d[0][0][0] = 0; cout << fixed << setprecision(11) << calc(cnt[1], cnt[2], cnt[3]) << endl; return 0; }
[ "lephuocdinh99@gmail.com" ]
lephuocdinh99@gmail.com
c94237b13b94fb77a25e04038efd8fc124121423
88f2dfa4fc224ad0ce4a1ba4af7458e85ad5f58e
/River.h
e9999508d40adca05be379e9d6c45e0dc2c0e0bb
[]
no_license
omerb01/Matam-Assignment4
df61f39e6dc365666d84e0a31efc210ee9b46b31
9cbf181e058a7309e1ebe7e98744ac2e77a314c4
refs/heads/master
2021-09-05T06:25:53.298920
2018-01-24T19:46:57
2018-01-24T19:46:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
923
h
// // Created by Omer on 22/01/2018. // #ifndef ASSIGNMENT4_RIVER_H #define ASSIGNMENT4_RIVER_H #include "Area.h" using std::vector; namespace mtm { class River : public Area { public: /** * Constructor * @param name The name of the area * @throws AreaInvalidArguments If the name is empty */ explicit River(const std::string &name); /** * Disable copy constructor */ River(const River &) = delete; /** * Disable assignment operator */ River &operator=(const River &) = delete; /** * Destructor */ ~River() override; /** * overrides from Area */ void groupArrive(const string &group_name, const string &clan_name, map<string, Clan> &clan_map) override; }; } #endif //ASSIGNMENT4_RIVER_H
[ "omer.be@campus.technion.ac.il" ]
omer.be@campus.technion.ac.il
85b1fd8804467d22c44fdaa7e5b07d50a71f6857
d85d62509c9fc276ff153e393a607f2042fe0b6c
/include/model/PathStrip.h
f461fcacd305c3b8b8a8ef5e022fe9c438cf126e
[ "MIT" ]
permissive
dezGusty/serpents
b188110217c235f162c2bf8f668f9784c270ea76
2663eb20c45e27ba80319e934c58c932d9311ad8
refs/heads/master
2020-12-25T17:56:15.573033
2014-09-11T19:22:04
2014-09-11T19:22:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,584
h
#pragma once // This file is part of Gusty's Serpents // Copyright (C) 2009 Augustin Preda (thegusty999@gmail.com) // // Gusty's Serpents is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // // Class to represent paths on a planar surface. #include "utils/GGeneralUtils.h" #include "BodyPartBase.h" namespace Serpents { #if 0 /// /// Class to define a segment in the path on which a serpent will be placed along. /// class PathStrip { public: /// Constructor (default). PathStrip(); /// Constructor (for a more convenient use). PathStrip( double xhead, double yhead, double xtail, double ytail ); /// Copy constr. PathStrip( PathStrip & ); /// Destructor. No pointers used, to nothing to do. ~PathStrip(void); /// Get the length for the given segment. (Pitagora) double getLength(); /// /// Get the coordinates of a sub-segment. It is imperative that partialSegmentSize be smaller than /// getLength(), otherwise the maximum allowed location will be returned. To retrieve the point on the line, witout being /// limited by the length, specify true for allowGreaterSize /// GUtils::DPOINT getLocationFromHead( double partialSegmentSize, bool allowGreaterSize = false ); GUtils::DPOINT getHeadLocation(){ return headLocation; } GUtils::DPOINT getTailLocation(){ return tailLocation; } protected: GUtils::DPOINT headLocation; GUtils::DPOINT tailLocation; friend class SerpentPath; }; typedef std::vector<PathStrip*> PathStripList; /// /// Class to define the path on which a serpent will be placed along. /// class SerpentPath { public: SerpentPath(); ~SerpentPath(); /// /// Make the calculations for the coordinates for all bodyparts. The result is an array of bodyparts. /// This is the place where the unused path strips are eliminated. /// virtual void getAndSetPositionOfAllParts( BodyPartPtrList &parts); /// Add a stript to the end of the path. This will be used in general to generate new (unspawned) bodyparts virtual void addStrip( int numParts = 1 ); /// /// Move the head of the strip list. A pathstrip will be added (the list is automatically extended). /// It will be eliminated when the bodyparts are re-placed in their position. /// virtual void moveHeadStrip( double x, double y, double minLength = -1 ); /// Remove a stript from the end of the path. virtual void removeStrip(); /// Get the coordinates for the entry at a given index. virtual GUtils::DPOINT getCoords( int index ); /// Get a single strip. virtual PathStrip* getStrip( int index ){ return pathStrips[index];} /// Getter for the length. virtual int getLength(){ return (int)pathStrips.size(); } protected: bool partArrangementWasCompleted; PathStripList pathStrips; GUtils::DPOINT absoluteTail; }; #endif } // namespace Serpents
[ "thegusty999@gmail.com" ]
thegusty999@gmail.com
0c1ca7890eea6a0d06e0d30c0329a533d540a99c
b4534c657f7fafc5be0e0fecf9b06485c46df452
/1487/a/a.cpp
f5a37c6cd78cddaaf73deb7fb205be3c073cf0b9
[]
no_license
Tan-YiFan/Codeforces-Exercises
37e5d33a6c0bc84ebe411619fcd5f6ea843c3418
e6bc55301af9c0545b5244dd64dac53b937ce272
refs/heads/master
2023-04-11T02:54:11.584330
2021-04-25T03:40:32
2021-04-25T03:40:32
338,828,946
0
0
null
null
null
null
UTF-8
C++
false
false
473
cpp
#include <bits/stdc++.h> using namespace std; constexpr int N = 100 + 3; int T; int n; int a[N]; int main() { for (cin >> T; T; T--) { cin >> n; int m = 101; for (int i = 1; i <= n; i++) { cin >> a[i]; m = min(a[i], m); } int ans = n; for (int i = 1; i <= n; i++) { if (a[i] == m) { ans--; } } cout << ans << endl; } }
[ "15711657500@163.com" ]
15711657500@163.com
13f2bb177e97401d1279b1650d9e8387419bd649
16c9854f72eeb150a4d9c0662df033948c72f1d4
/Assignment 1/Functions ch 6.cpp
092810996c726a3d4e659a3d0443286801a1d3b4
[]
no_license
omar-faruk01/Object-Oriented-Progamming
229d4fac3694d9a0952b3f20a82661a2b1fcdb48
61423731c170c290a515fa0ce0a83e5f2bdc53e2
refs/heads/main
2023-04-15T18:58:33.031420
2021-05-02T01:24:56
2021-05-02T01:24:56
329,083,048
0
0
null
2021-01-24T00:11:22
2021-01-12T18:56:15
C++
UTF-8
C++
false
false
1,603
cpp
//========================================================== // // Title: Mean and Standard Deviation // Course: CSC 2111 // Lab Number: Structured Programming Self-Assessment // Author: Omar Faruk // Date: 01/15/21 // Description: // Creating an application that prints the mean and standard // deviation using two functions with calculations. // //========================================================== #include <cstdlib> // For several general-purpose functions #include <fstream> // For file handling #include <iomanip> // For formatted output #include <iostream> // For cin, cout, and system #include <string> // For string data type using namespace std; // So "std::cout" may be abbreviated to "cout" double getMean(double x1, double x2, double x3, double x4, double x5) { double mean = (x1 + x2 + x3 + x4 + x5) / 5; return mean; } double getStdDev(double x1, double x2, double x3, double x4, double x5, double mean) { double stdDev = sqrt((pow(x1 - mean, 2) + pow(x2 - mean, 2) + pow(x3 - mean, 2) + pow(x4 - mean, 2) + pow(x5 - mean, 2)) / 5); return stdDev; } int main() { // Declare variables double x1, x2, x3, x4, x5; double mean = 0, std_dev = 0; // Input of 5 numbers cout << "Enter 5 numbers: "; cin >> x1 >> x2 >> x3 >> x4 >> x5; // Assigning function return to variable mean = getMean(x1, x2, x3, x4, x5); std_dev = getStdDev(x1, x2, x3, x4, x5, mean); // Output of meean & std dev cout << "\nThe mean is " << mean << "." << "\nThe standard deviation is " << std_dev << "." << endl; }
[ "noreply@github.com" ]
noreply@github.com