Hartshorne, Exercise III 4.2 a): A morphism $\mathcal{O}^r \to f_* \mathscr{M}$ that is an iso over the generic point.

I’m having some trouble with Exercise III 4.2 a) in Hartshorne’s Algebraic geometry. It is

Let $ f: X \to Y$ be a finite surjective morphism of integral noetherian schemes. Show that there is a coherent sheaf $ \mathscr{M}$ on $ X$ , and a morphism of sheaves $ \alpha: \mathcal{O}^r_Y \to f_* \mathscr{M}$ for some $ r > 0$ , such that $ \alpha$ is an isomorphism at the generic point.

I solved the affine case: If $ Y = \text{Spec } A$ , then $ X = \text{Spec }B$ and $ f$ comes from a homomorphism of integral domains $ A \to B$ , where $ B$ is finitely generated as an $ A$ -algebra. This means there is a surjection $ A^n \to B$ of $ A$ -modules. Localizing is exact, so at the generic point this is still a surjection $ Q(A)^n \to B_{(0)}$ . But $ Q(A)$ is a field, so we can choose a basis $ Q(A)^r \subset Q(A)^n$ , which gives an isomorphism $ Q(A)^r \to B_{(0)}$ . The corresponding map $ A^r \to B$ is the desired morphism.

So the “obvious” generalization would be to take the structure sheaf $ \mathscr{M} = \mathcal{O}_X$ . But this cannot work, as the following counterexample illustrates:

Consider $ f: \mathbb{P}^1 \to \mathbb{P}^1$ , defined by $ [x:y] \mapsto [x^2:y^2]$ . Giving a morphism $ \alpha: \mathcal{O}_Y^r \to f_* \mathscr{M}$ is the same as choosing $ r$ elements from $ \Gamma(X, \mathscr{M})$ . But $ \Gamma(X, \mathcal{O}_X) = k$ , so we can only choose $ k$ -linearly dependent elements. No morphism $ \mathcal{O}_Y^r \to f_*\mathcal{O}_X$ can give an isomorphism at the generic point $ \eta$ , because $ (f_*\mathcal{O}_X)_\eta \cong \mathcal{O}_{Y,\eta}^2$ , and the image of $ \mathcal{O}_Y^r \to f_*\mathcal{O}_X $ will only be $ 1$ -dimensional at $ \eta$ .

I’m a bit clueless at this point. Maybe one has to glue the affine case together and yields an invertible sheaf $ \mathscr{M}$ ? But I don’t think that replacing $ \mathcal{O}_X$ by $ \mathcal{O}_X(d)$ really changes anything in the example. How to proceed here?

my over curious wife

i am having problems with my wifes untrusting nature, she was tracking me on google timeline and when i shut that off on her she started using ip addresss lookup services to do it. then i got a new phone and called her with it onceand before i got home she had already tracked me by ip address. so how did she do that with only my phone number? it wasnt on an account(google) she knew about< so i cant find a way she did it.

➽➽➽ TEXTCAPTCHASOLVER.COM – Boost Your SER Linkbuilding with over 25% MORE LINKS!

Heya Guys,

Most of You know me pretty well and use my kickass proven world famous link indexing services InstantLinkIndexer and Indexification, and captcha solving service CaptchaTronix trusted by thousands of IMers.

I provide groundbreaking reliable SEO services with 100% positive feedback, totally smashing down competition, making my customers absolutely happy and relaxed trusting their business to me!

Now I am here to present You my next masterpiece

TextCaptchaSolver.com

How do You like BOOSTING Your Linkbuilding Campaigns with up to 25% more links??

What if I tell You that You can do it for as low as $ 9.97 a month? Don’t believe me? Keep reading…

Image captchas are being solved since years and there are various software and services doing it, but what about text captchas?? There’s nothing reliable on the market that provides text captcha breaking! WELL, UNTIL NOW!!! Our service specializes in providing robust and highly accurate text captcha solving! INCREDIBLE! GROUNDBREAKING! UNBELIEVABLE!

Boost Your Linkbuilding Campaigns with up to 25% more links!

Yep, You heard it right!!! Not being able to solve text captchas You’ve been loosing many backlinks as Your linkbuilding tools aren’t able to submit to those sites. Why missing these?? THAT IS NO LONGER!!! Empowering Your tools with our service lets You get up to 25% more backlinks! ABSOLUTELY PROVEN!!! The sites using text based captchas vary from 10% to up to 25% from any submit list, and the good news is that You can take advantage of them! Squeeze the max out of your linkbuilding campaigns for just few bucks, it is as simple as that!

Untap NEW Linkbuilding sources and Skyrocket Your SEO!

Using our service lets You create backlinks on brand new, fresh and unspammed websites, simply because they use text based captchas that were being skipped so far! How do You like that?? That directly impacts Your SEO and provides You better ranking as You are doing linkbuilding on higher quality and less spammed websites! That means You’re on the crest of the forming wave, not underneath it!

Get Better and Better Results over the Time, GUARANTEED!

We are always improving our state-of-the-art Artificial Intelligence of our system, training it for solving more and more text based captchas on the fly. We record every single question sent to our service and our team of reviewers go through the collection and manually fill correct answer in our ever growing database of questions. We are collective mind for text captchas! All this ensures You getting better and better results! Leave Text Captha Solving to Us! And enjoy GUARANTEED very high success rates!

Here’s exactly what You get with Your account

✪ 100% Automated Text Captcha Solving
✪ 99% Success Rate on Mathematical Equations

✪ 97% Success Rate on the most widely used text captcha provider TextCaptcha.com
✪ 70%-80% Success Rate on General Text Questions
✪ Lightening Fast Solving Times – 0.05 sec. on average
✪ Constant Improvements & Updates
No IP Limiations! Use Your account from anywhere!
✪ Easy Remote API Access, Documentation & Code Samples
SEO Linkbuilding Tools Integration
Blazing Fast, Reliable and Stable Servers!
✪ Fantastic Statistics & Charts
✪ Free Lifetime 24/7 Customer Service & Support

Fully Integrated with GSA Search Engine Ranker & GSA Captcha Breaker for ease of setup and use! All You need to do is paste Your license key!

All sounds pretty good, but whats the price?
Well, here comes the best part!
Alike all my products I provide You my new service at lowest possible price – the lowest prices on the market!

I provide the most Flexible Plans among all Text Captcha Solvers online!
I have a solution suitable & affordable for Starters and Large Corporations alike!

AVAILABLE PACKAGES:
5000 Daily Solves $ 9.97 only
10 000 Daily Solves $ 14.97 only
20 000 Daily Solves $ 19.97 only
35 000 Daily Solves $ 27.77 only
50 000 Daily Solves $ 35.77 only
75 000 Daily Solves $ 42.97 only
100 000 Daily Solves $ 69.77 only
200 000 Daily Solves $ 132.77 only
And that’s not all! I can provide any kind of custom packages to meet everyone’s needs!

CLICK HERE TO START SOLVING RIGHT NOW >>

Instant Account Activation! Purchase with confidence even if it is 2:00 AM!

Wait, that’s not all!

I provide 1 Week Trial at the Starter plan!

Simply post “I want Trial” in the thread and patiently wait for a PM!

Wait, that’s not all at all!
I provide Special 10% Recurring DISCOUNT on the listed prices to GSA users!
Simply post “Give me 10% Discount” in the thread and patiently wait for a PM!
Want some teasers?
Here’s what few people tell about us and more to come in the thread

image

image

image

image

NOT CONVINCED YET? BROWSE THE THREAD FOR REVIEWS & FEEDBACK

Note: Feel free to ask me any questions You might have here in this thread. For support / issues reporting on my service it is always best to use my Ticketing system at my website as that ensures fastest response times!

Stop Loosing valuable backlinks!
Get Your TEXTCAPTCHASOLVER.COM account Right NOW!
And Boost Your Linkbuilding campaigns to the sky!

A problem about the field of rational functions over finite field

Let $ p$ be a prime number, and let $ F_{p}$ be the finite field with $ p$ elements. Let $ F=F_{p}(t)$ be the field of rational functions over $ F_{p}$ . Consider all subfields of $ F$ such that $ F/C$ is an finite Galois extension. 1.Show that among such subfields, there is a smallest one $ C_{0}$ , i.e.$ C_{0}$ is contained in any other $ C$ . 2.What is the degree of $ F/C_{0}$ ?

N-Queen problem comparisons over multiple algorithms

I am comparing various algorithms for solving N-queen & I need to know the limits of number of queens for the following Algorithms for solving N-Queen in reasonable time: –

  1. Hill climbing (Plain)
  2. Hill climbing with min conflict Heuristic with randomization for tie breaker
  3. Hill climbing with min conflict Heuristic without randomization for tie breaker
  4. Alphaa beta pruning
  5. Genetic Algorithm
  6. Backtracking.

Limits can be dozens, hundreds, millions, Not a solution etc.

As per my understanding theoretically it should be as –

  1. Hill climbing (Plain) — Not a solution
  2. Hill climbing with min conflict Heuristic with randomization for tie breaker — dozens
  3. Hill climbing with min conflict Heuristic without randomization for tie breaker — hundreds
  4. Alpha beta pruning — not a solution
  5. Genetic Algorithm — millions
  6. Backtracking. — dozens

let me know if its correct.

Get over 2 MILLION+ PLR articles + Extra 1000 MRR ebook for $120

WOW!!!,.WHAT A GREAT OFFER!!!,Do you need High QUALITY editable write-up on all topics for your blog,site,books etc?,If yes,then this is the right package for you.With this package,you don’t need to pay anyone to do any article writing for you. I purchased this collection for over $ 100 but i am giving it out[ over TWO MILLION+ FRESH PLR ARTICLES + EXTRA 1000 MRR EBOOKS] for just $ 5 only for very limited time.This is the HOTTEST PLR collection in seoclerks now as you cannot find this anywhere.This PLR articles covers almost all NICHES you can ever think about.These articles require minimal editing and can be posted to sites,blogs,books etc without any fear of rights infringements. FEATURES INCLUDE: ❶All Niches, ❷100% unique content, ❸SEO optimized ❹copyscape pass ❺100% premium. This offer is only for the first 5 customers after which i will remove it completely.so what are you still waiting for? ★TAKE THIS ADVANTAGE,HURRY NOW AND PLACE YOUR ORDER AND GRAB YOUR COPY FAST BEFORE IT EXPIRES OUT★. Its highly recommended to feel free to message us if you have any questions about this service before placing any order. ★FREE BONUS★. Thank you and God bless you all. Below are some of the articles i am giving out for your viewing and perusal with majority of them written this year 2014 while few are in 2013.

by: Luthermartin
Created: —
Category: eBook
Viewed: 249


C++ protocol for sending arrays over TCP

As someone who has programmed in C for a long time, I have just written my first C++ program and feel it would be very valuable to get a review of the code, to see what features of C++ I could make more use of.

The program provides a protocol for sending and receiving arrays of data over TCP. The idea is to

i) Send/receive the dimension of the array. ii) Send/receive the shape of the array. iii) Send/receive the data of the array. 

To run the code you can do the following

g++ protocol.cpp -o protocol 

Then in separate terminals, for example

./protocol server int32 float32 

and

./protocol client int32 float32 

The program itself is below

#include <stdlib.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <endian.h> #include <unistd.h> #include <iostream> #include <cstring>  int is_system_le() {     // Test if the system is little endian.     short int word = 0x0001;     char *b = (char *) &word;      // In the little endian case, 1 will be read as 1 in a character.     if (b[0]) {         return 1;     } else {         return 0;     } }  template <class int_T, class data_T> class Array {  public:     // Fields.     int_T size;     int_T dim;     int_T *shape;     data_T *data;      // Methods.     Array(int size, int dim);     ~Array(void);      int allocate(void); };  template <class int_T, class data_T> Array<int_T, data_T>::Array(int size, int dim) {     // Set fields.     this->size = size;     this->dim = dim; }  template <class int_T, class data_T> int Array<int_T, data_T>::allocate() {     // Create memory necessary for the array.     this->shape = new int[dim];     this->data = new data_T[size];      return 0; }  template <class int_T, class data_T> Array<int_T, data_T>::~Array() {     // Delete the created memory.     delete[] shape;     delete[] data; }  class Protocol {  public:     // Class constants.     static const int CHUNK_BYTES = 1024;      // Fields.     std::string socket_type;     int verbose;      // Methods.     Protocol(std::string socket_type, int verbose);     ~Protocol(void);      int plisten(std::string host, int port);     int pconnect(std::string host, int port);     int pclose();      template <class int_T, class data_T>     int psend(         Array<int_T, data_T> *arr,         std::string int_format,         std::string data_format     );      template <class int_T, class data_T>     int preceive(         Array<int_T, data_T> *arr,         std::string int_format,         std::string data_format     );   private:     // Fields.     int sock;     int conn;      // Methods.     template <class int_T, class data_T>     int psend_tcp(         Array<int_T, data_T> *arr,         std::string int_format,         std::string data_format     );      template <class int_T, class data_T>     int preceive_tcp(         Array<int_T, data_T> *arr,         std::string int_format,         std::string data_format     ); };  // Member functions. Protocol::Protocol(std::string socket_type, int verbose) {     if (verbose) {         std::cout << "Protocol object created." << std::endl;     }     this->socket_type = socket_type;     this->verbose = verbose; }  Protocol::~Protocol(void) {     if (verbose) {         std::cout << "Protocol object deleted." << std::endl;     } }  int Protocol::plisten(std::string host, int port) {     // Listen for a connection on the host/port.     if (socket_type.compare("server") != 0) {         throw "Error: Can only listen with server sockets.";     }      // Create the socket.     sock = socket(AF_INET, SOCK_STREAM, 0);      // Set up host address structure (don't understand this).     struct sockaddr_in server_addr;     server_addr.sin_family = AF_INET;     server_addr.sin_port = htons(port);     server_addr.sin_addr.s_addr = inet_addr(host.c_str());     memset(server_addr.sin_zero, '', sizeof(server_addr.sin_zero));      // Bind to host port.     bind(sock, (struct sockaddr *) &server_addr, sizeof(server_addr));      // Listen for connection.     if (verbose) {         std::cout << "Listening for connections." << std::endl;     }     listen(sock, 1);      // Accept a connection.     struct sockaddr_in client_addr;     socklen_t client_addr_len = sizeof(client_addr);     conn = accept(sock, (struct sockaddr *) &client_addr, &client_addr_len);     if (verbose) {         std::cout << "Accepted connection." << std::endl;     }      return 0; }   int Protocol::pconnect(std::string host, int port) {     // Connect to an actual socket.     if (socket_type.compare("client") != 0) {         throw "Error: Can only connect with client sockets.";     }      // Create the socket.     sock = socket(AF_INET, SOCK_STREAM, 0);      // Set up host address structure (don't understand this).     struct sockaddr_in server_addr;     server_addr.sin_family = AF_INET;     server_addr.sin_port = htons(port);     server_addr.sin_addr.s_addr = inet_addr(host.c_str());     memset(server_addr.sin_zero, '', sizeof(server_addr.sin_zero));      // Try to connect.     if (verbose) {         std::cout << "Trying to connect." << std::endl;     }     connect(         sock,         (struct sockaddr *) &server_addr,         sizeof(server_addr)     );     if (verbose) {         std::cout << "Accepted connection." << std::endl;     }      return 0; }   int Protocol::pclose() {     // Close a created server or client socket.     if (socket_type.compare("server") == 0) {         if (verbose) {             std::cout << "Closing server socket." << std::endl;         }          close(sock);     } else if (socket_type.compare("client") == 0) {         if (verbose) {             std::cout << "Closing client socket." << std::endl;         }         shutdown(sock, SHUT_WR);         close(sock);     }      return 0; }  template <class int_T, class data_T> int Protocol::psend(Array<int_T, data_T> *arr, std::string int_format, std::string data_format) {     // Send data in arr across the network.     int ack;      ack = psend_tcp(arr, int_format, data_format);      if (ack != 0) {         throw "Did not receive good acknowledgement after sending data.";     }      return 0; }  template <class int_T, class data_T> int Protocol::psend_tcp(Array<int_T, data_T> *arr, std::string int_format, std::string data_format) {     // Send data in arr across the network using TCP.      // This can certainly be cleaned up by using templates and factoring out     // the function for sending chunked data over the network.      // Note we always use little endian.     uint8_t buffer[1024];     size_t buffer_byte_size;      // Server sends over conn, client over sock.     int send_sock;     if (socket_type.compare("server") == 0) {         send_sock = conn;     } else if (socket_type.compare("client") == 0) {         send_sock = sock;     }      // i) Send the integer dimensions.     if (int_format.compare("int32") == 0) {         int32_t little_endian_int = (int32_t) htole32((uint32_t) arr->dim);         memcpy(             &buffer[0],             &little_endian_int,             sizeof(little_endian_int)         );         buffer_byte_size = sizeof(int32_t);     } else if (int_format.compare("int64") == 0) {         int64_t little_endian_int = (int64_t) htole64((uint64_t) arr->dim);         memcpy(             &buffer[0],             &little_endian_int,             sizeof(little_endian_int)         );         buffer_byte_size = sizeof(int64_t);     }      if (verbose) {         std::cout << "Sending dimensions: " << int_format << std::endl;     }     send(send_sock, buffer, buffer_byte_size, 0);      // ii) Send the integer shape. May need to be done in multiple chunks.     if (int_format.compare("int32") == 0) {         buffer_byte_size = sizeof(int32_t);     } else if (int_format.compare("int64") == 0) {         buffer_byte_size = sizeof(int64_t);     }      // Make sure our arr->shape is stored in int_format. In future can maybe     // auto-fix by converting it.     if (sizeof(int_T) != buffer_byte_size) {         throw "Error: Array integers not in int_format so cannot send.";     }      // Make sure our host system is little endian as we don't bother converting     // here. We could theoretically write to a buffer at convert.     if (!is_system_le()) {         throw "Currently rely on the system being little endian.";     }     int reps = arr->dim * buffer_byte_size/CHUNK_BYTES;     int leftover = arr->dim * buffer_byte_size % CHUNK_BYTES;     if (verbose) {         std::cout << "Sending shape: " << int_format << std::endl;     }     for (int i=0; i<reps; i++) {         memcpy(             &buffer[0],             &arr->shape[i*CHUNK_BYTES/buffer_byte_size],             CHUNK_BYTES         );         send(send_sock, buffer, CHUNK_BYTES, 0);     }      // Send leftover bytes.     memcpy(         &buffer[0],         &arr->shape[reps*CHUNK_BYTES/buffer_byte_size],         leftover     );     send(send_sock, buffer, leftover, 0);      // iii) Send the array data (I'm not sure if we can be sure of float and     //      double size). Requires converting to data_format.     if (data_format.compare("int32") == 0) {         buffer_byte_size = sizeof(int32_t);     } else if (data_format.compare("int64") == 0) {         buffer_byte_size = sizeof(int64_t);     } else if (data_format.compare("float32") == 0) {         buffer_byte_size = sizeof(float);     } else if (data_format.compare("float64") == 0) {         buffer_byte_size = sizeof(double);     }      if (sizeof(data_T) != buffer_byte_size) {         throw "Error: Array data not in data_format so cannot send.";     }      reps = arr->size * buffer_byte_size/CHUNK_BYTES;     leftover = arr->size * buffer_byte_size % CHUNK_BYTES;     if (verbose) {         std::cout << "Sending data: " << data_format << std::endl;     }     for (int i=0; i<reps; i++) {         memcpy(             &buffer[0],             &arr->data[i*CHUNK_BYTES/buffer_byte_size],             CHUNK_BYTES         );         send(send_sock, buffer, CHUNK_BYTES, 0);     }      // Send lefotver bytes.     memcpy(         &buffer[0],         &arr->data[reps*CHUNK_BYTES/buffer_byte_size],         leftover     );     send(send_sock, buffer, leftover, 0);      // Receive acknowledgement.     recv(send_sock, buffer, 1, 0);      return buffer[0]; }  template <class int_T, class data_T> int Protocol::preceive(Array<int_T, data_T> *arr, std::string int_format, std::string data_format) {     // Put the received value into arr.     preceive_tcp(arr, int_format, data_format);      return 0; }  template <class int_T, class data_T> int Protocol::preceive_tcp(Array <int_T, data_T> *arr, std::string int_format, std::string data_format) {     // Receive network data over TCP.      // Note we always use little endian.     uint8_t buffer[1024];     size_t buffer_byte_size;      // Server receives over conn, client over sock.     int send_sock;     if (socket_type.compare("server") == 0) {         send_sock = conn;     } else if (socket_type.compare("client") == 0) {         send_sock = sock;     }      // i) Receive integer dimension.     if (int_format.compare("int32") == 0) {         buffer_byte_size = sizeof(int32_t);     } else {         buffer_byte_size = sizeof(int64_t);     }      if (buffer_byte_size != sizeof(int_T)) {         throw "Tried to receive data into an array with wrong integer format";     }     recv(send_sock, buffer, buffer_byte_size, 0);      if (int_format.compare("int32") == 0) {         int32_t little_endian_int = (int32_t) le32toh(((uint32_t *) buffer)[0]);         arr->dim = (int) little_endian_int;     } else if (int_format.compare("int64") == 0) {         int64_t little_endian_int = (int64_t) le64toh(((uint64_t *) buffer)[0]);         arr->dim = (int) little_endian_int;     }      if (verbose) {         std::cout << "Received dimensions: " << arr->dim << std::endl;     }      // ii) Receive integer shape (may need to be done in chunks).     arr->shape = new int[arr->dim];     //arr->shape = (int_T *) malloc(arr->dim*sizeof(int_T));      int reps = arr->dim * buffer_byte_size/CHUNK_BYTES;     int leftover = arr->dim * buffer_byte_size % CHUNK_BYTES;     for (int i=0; i<reps; i++) {         recv(send_sock, &arr->shape[i*CHUNK_BYTES/buffer_byte_size], CHUNK_BYTES, 0);     }      // Recieve lefotver bytes.     recv(send_sock, &arr->shape[reps*CHUNK_BYTES/buffer_byte_size], leftover, 0);      if (verbose) {         std::cout << "Received shape:" << std::endl;         std::cout << " [";         for (int i=0; i<arr->dim; i++) {             std::cout << arr->shape[i];             if (i != arr->dim - 1) {                 std::cout << ",";             }         }         std::cout << "]" << std::endl;     }      // iii) Recieve data.     if (data_format.compare("int32") == 0) {         buffer_byte_size = sizeof(int32_t);     } else if (data_format.compare("int64") == 0) {         buffer_byte_size = sizeof(int64_t);     } else if (data_format.compare("float32") == 0) {         buffer_byte_size = sizeof(float);     } else {         buffer_byte_size = sizeof(double);     }      if (sizeof(data_T) != buffer_byte_size) {         // Should check on full type not just bytes. Unfortunately don't know         // how to do this in C++.         throw "Error: Array data not in data_format so cannot receive.";     }      // Determine the size from the shape.     arr->size = 1;     for (int i=0; i<arr->dim; i++) {         arr->size *= arr->shape[i];     }      arr->data = new data_T[arr->size];     //arr->data = (data_T *) malloc(arr->size * sizeof(data_T));     reps = arr->size * buffer_byte_size/CHUNK_BYTES;     leftover = arr->size * buffer_byte_size % CHUNK_BYTES;     for (int i=0; i<reps; i++) {         recv(             send_sock,             &arr->data[i*CHUNK_BYTES/buffer_byte_size],             CHUNK_BYTES,             0         );     }      // Receive leftover bytes.     recv(         send_sock,         &arr->data[reps*CHUNK_BYTES/buffer_byte_size],         leftover,         0     );      if (verbose) {         std::cout << "Received data:" << std::endl;         if ((arr->size < 50) & (arr->dim == 2)) {             for (int i=0; i<arr->shape[0]; i++) {                 for (int j=0; j<arr->shape[1]; j++) {                     std::cout << arr->data[i*arr->shape[1] + j] << ", ";                 }                 std::cout << std::endl;             }         }     }      // No acknowledgement necessary for TCP however send anyway.     buffer[0] = 0;     send(send_sock, buffer, 1, 0);      return 0; }  int main(int argc, char *argv[]) {     // Declare the protocol.     std::string socket_type;     if (argc == 1) {         std::cout << "No socket type provided so using server." << std::endl;         socket_type = "server";     } else {         std::cout << "Using protocol type " << argv[1] << "." << std::endl;         socket_type = argv[1];     }     Protocol cp(socket_type, 1);      std::cout << "Total chunk bytes: " << cp.CHUNK_BYTES << std::endl;     std::cout << "Socket Type: " << cp.socket_type << std::endl;     std::cout << "Verbose: " << cp.verbose << std::endl;      if (cp.socket_type.compare("server") == 0) {         try {             cp.plisten("127.0.0.1", 65432);         } catch (const char *msg) {             std::cerr << msg << std::endl;         }          // Now send some random data (5 x 2 array).         Array<int, float> arr(10, 2);         arr.allocate();          arr.shape[0] = 5;         arr.shape[1] = 2;          for (int i=0; i<10; i++) {             if (!strcmp(argv[3], "float32") || !strcmp(argv[3], "float64")) {                 arr.data[i] = i + i*0.1;             } else {                 arr.data[i] = i;             }         }         cp.psend(&arr, argv[2], argv[3]);     } else {         try {             cp.pconnect("127.0.0.1", 65432);         } catch (const char *msg) {             std::cerr << msg << std::endl;         }          // Now receive some random data.         Array<int, float> arr(-1, -1);         cp.preceive(&arr, argv[2], argv[3]);     }      cp.pclose();      return 0; } 

Notes

1) One of the issues I had was that I felt it would be nicer for the Protocol::preceive method to return an Array instance but I didn’t know how to pass the template to the method when none of the arguments used it. Instead I went for passing a pointer to an instance.

2) This had another issue that I wanted the Array constructor to allocate the memory necessary for holding the shape and data information. However the size of this memory is not known before the method is run. Hence I ended up not including this in my constructor. I would be interested in hearing if there is a way around this.

3) Note that a quirk of the program is that I have Protocol::psend and Protocol::psend_tcp methods (similarly for receiving). This is for a fairly good reason that I copied the logic of this program from a Python program I wrote that also allowed sending and receiving over UDP. I wanted to leave them like this in case I wanted to add this feature in future.

4) I thought it may be a good idea to wrap some of the C libraries (to do with sockets) in a namespace as I got quite a few name clashes (hence why I have the prefix p in all my methods). When I tried to do this however I ended up getting a compiler error so gave up and moved on.

OOP benefit to using attribute entirely over ‘temp table’

I’m having trouble phrasing my question, but when I’m writing in python OOP and say for instance I have an attribute that is a DataFrame object and I want to do transformations on that DataFrame object, is it better to do the transformation on the attribute, so…

self.DF = self.DF.groupby('var').agg({}) 

or is it better to save the DataFrame in a sort of temporary variable and do transformation on that and then save back to the attribute at the end, like…

tempDF = self.DF.copy() tempDF = tempDF.groupby('var').agg({}) self.DF = tempDF 

Is there any benefit to doing one way or the other?

Is it more advantageous to go over the speed limit in a slow speed limit or a fast? [on hold]

My fiancé and I have been discussing this problem for weeks, and I can’t seem to wrap my head around it, I’m not great at math so I did my best and my best is not good enough. The story problem goes like this: if you are going on a trip that has a 60 mph speed limit for half of the trip in a 30 mph speed limit for the other half, and you drive say 10 miles over the speed limit but only in one or the other, which one gains to more time? Best as I can tell, it is more advantageous to speed in the slower speed limit, however, she seems to believe it’s exactly the same regardless