Skip to content

Instantly share code, notes, and snippets.

<ivysettings>
<settings defaultResolver="ibibliothengoogle"/>
<resolvers>
<chain name="ibibliothengoogle" returnFirst="true">
<ibiblio name="ibiblio" m2compatible="true" />
<packager name="google" buildRoot="${user.home}/.ivy2/packager/build"
resourceCache="${user.home}/.ivy2/packager/cache">
<ivy pattern="
http://ivyroundup.googlecode.com/svn/trunk/repo/modules/[organisation]/[module]/[revision]/ivy.xml
"/>
<!-- =================================
target: clean
================================= -->
<target name="clean" description="--> clean the project">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${src.dir}" />
<fileset dir="${build.dir}" />
</delete>
</target>
class NextQuarterAdjuster implements DateAdjuster {
private final Set<MonthOfYear> _futureQuarters =
Sets.newHashSet(MonthOfYear.MARCH,
MonthOfYear.JUNE,
MonthOfYear.SEPTEMBER,
MonthOfYear.DECEMBER);
@Override
public LocalDate adjustDate(LocalDate date) {
LocalDate result = date;
do {
class NextExpiryAdjuster implements DateAdjuster {
private static final DateAdjuster s_thirdWedAdjuster =
DateAdjusters.dayOfWeekInMonth(3, DayOfWeek.WEDNESDAY);
private static final DateAdjuster s_nextQuarterAdjuster =
new NextQuarterAdjuster();
private final Set<MonthOfYear> _futureQuarters =
Sets.newHashSet(MonthOfYear.MARCH, MonthOfYear.JUNE,
MonthOfYear.SEPTEMBER, MonthOfYear.DECEMBER);
@Override
public LocalDate adjustDate(final LocalDate date) {
@KirkWylie
KirkWylie / naive-dgemv.java
Created October 10, 2011 16:18
A naive implementation of DGEMV() in Java
public double[] method(double[][] A, double[] x, int m, int n) {
double[] y = new double[m];
for (int i = 0; i < m; i++) {
for (int j = 0; j < n; j++) {
y[i] += A[i][j] * x[j];
}
}
return y;
}
@KirkWylie
KirkWylie / YieldCurve.R
Created November 3, 2011 16:37
Yield Curve Plotting Using OpenGamma and R
##
# Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
#
# Please see distribution for license.
##
# Loads the time-series for yield curve data points to construct a 3D "curve over time" graph.
# Curve tickers
tickers <- c ("US00O/N Index", "US0001W Index", "US0002W Index", "US0001M Index", "US0002M Index", "US0003M Index", "USSW2 Curncy", "USSW3 Curncy", "USSW4 Curncy", "USSW5 Curncy", "USSW6 Curncy", "USSW7 Curncy", "USSW8 Curncy", "USSW9 Curncy", "USSW10 Curncy", "USSW15 Curncy", "USSW20 Curncy", "USSW25 Curncy", "USSW30 Curncy")
@KirkWylie
KirkWylie / gist:1446838
Created December 8, 2011 12:24
Sparse Matrix Vector Multiply
final int[] rowPtr = A.getRowPtr(); // get the row pointer
final int[] colIdx = A.getColumnIndex(); // get the column index
final double[] values = A.getNonZeroElements(); // get the nonzero elements
final int rows = A.getNumberOfRows(); // get the number of rows
double[] result = new double[rows]; // allocate memory for the result vector
int ptr = 0; // this indicates where we have got to in the data variable "values"
for (int i = 0; i < rows; i++) { // loop over rows
for (int j = rowPtr[i]; j < rowPtr[i + 1]; j++) { // accessing this many elements in row[i]
result[i] += values[ptr] * x[colIdx[ptr]]; // accumulate the result.