range-check in c++ vector^raw array

[[safe c++]] points out that static array or dynamic array are both (unfortunately) silent about access beyond their limits. Vector has operator[] and at() —

[[]] says c++ new array type supports .size()…


#include <iostream>
#include <vector>
using namespace std;

int main(){
    vector<int> v;
    v.push_back(15);
    size_t sz = v.size();
    try{
        cout<<v[0]<<" "<<v[sz]<<" <- operator[]: out-of-range treated as non-error!"<<endl;
        cout<<v.at(sz)<<" <- at(): throws:)"<<endl;
    }catch(exception & ex){
        cerr<<"Must catch by ref (what() virtual) " << ex.what()<<endl;
    }
}

matlab [] vs ()

paren and brackets are by far the most versatile constructs in matlab. Each has rich contextual meanings. Here is an incomplete sketch.

–Matlab doc on “special characters” —

Brackets are used to form vectors and matrices.

Parentheses are used to enclose subscripts of vectors

http://stackoverflow.com/questions/5966817/difference-between-square-brackets-and-curly-brackets-in-matlab

A right angle (square) bracket creates a vector or matrix, whereas curly brackets creates a cell array.

When working with numbers, I'd say that 99% of the time, you will use square brackets. Cell arrays allow you to store different types of data at each location, e.g. a 10×5 matrix at (1,1), a string array at (1,2).

selling an existing IR swap@@

I guess technically we can’t sell an IRS as it’s not a product like an orange (or a house, or an option) with an owner. A IRS is a long-term bilateral agreement. Analog? I can’t “sell” my insurance policy to someone else.

A liquid swap market lets us offset our Libor exposure —

Suppose I’m a Payer in Deal 1 with Citi, to receive Libor and pay fixed 4.5%. Five hours (or 5 days or 5 months) later, I could become a Receiver in a JPM deal (Deal 2) to pay Libor and receive fixed 4.6%. Therefore I get rid of my Libor exposure, as long as the reset dates are identical between Deal 1 and Deal 2. But strictly speaking I haven’t Sold an existing swap. Both are long-term commitments that could in theory be unwound (painful) but never “sold” IMO.

By market convention, the counterparty paying the fixed rate is called the “payer” (while receiving the floating rate), and the counterparty receiving the fixed rate is called the “receiver” (while paying the floating rate).

non-intrusive test – if current process has admin privilege

Just run qq(openfiles) command.

See https://groups.google.com/forum/#!topic/alt.msdos.batch.nt/1dnlamNqZ7U

==============================

Information in this message is confidential. It is intended solely for the person or the entity to whom it is addressed. If you are not the intended recipient, you are not to disseminate, distribute or copy this communication. Please notify the sender and delete the message and any other record of it from your system immediately.

==============================

c++ bad_alloc handling — briefly

Q: What can you do when you get an std::bad_alloc exception?
A: Scott Meyers suggested overloading operator new and new-handler. I guess in financial apps it’s rarely needed. But we should really read the [[safe c++]] book written by a hedge fund coder.

A: I used to keep 60MB files in my C: drive, to be deleted when I run out of disk — same idea expressed in Item 7 in [[effC++]]

A: if it’s stack, it’s often due to deep recursion. You can set stack size —

gcc -Wl,–stack=xxxxx -Wl,–heap=yyyyy …