C++ Quantlib output to console window - c++

I am learning how to use quantlib to price derivatives. What is the best way to output some of the Quantlib specific classes to console window? For example
shared_ptr<YieldTermStructure> forwardCurve(new InterpolatedDiscountCurve<LogLinear>(dates,discountFactor,Actual360()));
Handle<YieldTermStructure> forwardingTermStructure(forwardCurve);
shared_ptr<IborIndex> euribor(new Euribor(3*Months,forwardingTermStructure));
What will be the best way for me to output forwardCurve to and euribor to console window? Then I can see the intermediate result of the code to see if they are as expected.
Many thanks.

There's no predefined way to output those classes to console, but you can use their inspector to output the relevant data (so, e.g., you can call forwardCurve->times() and forwardCurve->discounts() to inspect the values you're interpolating) or you can call their methods to see the results of their calculations (e.g., forwardCurve->discount(d) to retrieve the discount factor at a given date, or euribor->fixing(d) to retrieve the expected index fixing). The returned values can be written to console.
As an alternative, you might consider stepping through the code inside a debugger. In modern IDEs, this will give you the same information more easily.

Related

How to preserve n lines of console for the same output?

I'm using console intensively to report the status of my program.
There are different modules that print different messages of different importance.
What I want is to preserve the first two lines of the console to print some important information while allowing the other information to be printed in the rest of the console. Even if the other information exceeded one page of console and had to scroll down, I want the first two lines to stay there.
Is there some way to do this?
Currently, I'm printing using printf with colors.
I'm working on Linux and I'm using guake terminal (zsh). I'm using both C and C++ in my code so both are fine for me.

How to make SAS Enterprise Guide show only the latest data created in Output Data?

Also how to make SAS Enterprise Guide to go to Output Data tab after a successful run instead of Results tab?
It's going to go to Results if you produce results, I don't think there's any way around that. You will get all of the datasets produced in that program in the Output Data tab, as well.
However, I'm going to venture a guess here: you're using EG like a single window programming environment, right? You have a single long program? If so, then the answer is simple: split your program up. EG is intended to have lots of small programs, each of which have a very specific goal and output. Think of it as steps: each program node is just one step, could be even just one data step. Then you link several programs together, in sequence, and run them all as a process flow (or an ordered list).
If you treat it that way, then it works very much like you say: you can have one program that has one output dataset and no results window, if your last program in a process flow just produces one dataset and no results.

Plotting progress in cplex optimization

I would like to able to plot the progress of a MIP solved by cplex. Specifically I would like to plot lower and upper bounds as functions of cpu-time. But copying an pasting from the node log does not seem to be a smartest way of proceeding. Is it possible to access these information and to print them out/to file during the optimization?
I am using the concert technology C++ interface.
You can add a "MIP info callback" using the API routine CPXsetinfocallbackfunc or its analogue in Concert.
(Copying-and-pasting the log it dumps to the terminal is perfectly fine for getting a rough idea of what's going on, but be aware that the results can be highly variable.)
Callbacks are what you are looking for. You can find a nice introduction here:
http://eaton.math.rpi.edu/cplex90html/usrcplex/callbacks.html

Windows C/C++ Drive Init/Partition/Format

I am trying to build an application for Windows XP 64bit which is able to detect drives of a particular model in the system, and if they are not initialized & formatted perform these processes.
I would also like to be able to query and set the partition information(including the volume label).
I have started putting together code using DeviceIoControl, but I have not been able to figure out how to set/get partition/volume labels or format drives with the method, I have got SMART access working.
Is there any other method that is any easier to use?
Zac
Sounds like you are looking for Disk Management Control Codes.
If I were doing this I would use my own code only to detect things. I would do the partitioning and formatting through diskpart and/or format commands instead. diskpart accepts file argument with a script to execute.

alternative for jasperreport in c++

from a c++ program i need to print a simple label. the label contains a text, an image and a barcode.(in my project the label is more complex, this is just for example)
my customer need a way to customize che label layout.
in the past in java I solve this problem using a report created with jasperreport. my customer customize the report with ireport and then i fill the data with an hashtable datasource (i never connect to an sql database)
anybody know a way to obtain something like this in java
really sorry for my scholastic english
Offhand, it's a bit hard to say -- most report generators assume some sort of database (SQL or at least accessible via ODBC) as the data source. I'd probably look into some that are free and include source code so you can change the data source (though I've no idea how difficult a modification that will be).
The other problem is that printing anything but plain text is somewhat non-portable; you'll need different code for Linux, Mac/OS or Windows. For Windows, one possibility would be Report Generator from CodeProject.com. If you want something more portable, you could use something like Xport to create XHTML output to be viewed in/printed from a browser (or any number of other programs that understand [X]HTML (there's also a commercial version). Of course, you could generate output in any number of other formats that support graphics, such as Postscript/PDF, LaTex, etc. This lets you use portable code to generate the report, but usually requires some non-portable code to invoke a viewer.