Skip to content

Commit

Permalink
break out scs_version, make matlab scs_version
Browse files Browse the repository at this point in the history
  • Loading branch information
bodonoghue committed Feb 21, 2015
1 parent 1e28987 commit 824dbdf
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 19 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# MAKEFILE for scs
include scs.mk

OBJECTS = src/scs.o src/util.o src/cones.o src/cs.o src/linAlg.o src/ctrlc.o
OBJECTS = src/scs.o src/util.o src/cones.o src/cs.o src/linAlg.o src/ctrlc.o src/scs_version.o

SRC_FILES = $(wildcard src/*.c)
INC_FILES = $(wildcard include/*.h)
Expand Down Expand Up @@ -31,7 +31,8 @@ src/util.o : src/util.c include/util.h include/constants.h
src/cones.o : src/cones.c include/cones.h
src/cs.o : src/cs.c include/cs.h
src/linAlg.o: src/linAlg.c include/linAlg.h
src/ctrl.o : src/ctrl.c incluce/ctrl.h
src/ctrl.o : src/ctrl.c include/ctrl.h
src/scs_version.o: src/scs_version.c include/constants.h

$(DIRSRC)/private.o: $(DIRSRC)/private.c $(DIRSRC)/private.h
$(INDIRSRC)/indirect/private.o: $(INDIRSRC)/private.c $(INDIRSRC)/private.h
Expand Down
3 changes: 1 addition & 2 deletions include/scs.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ scs_int scs_solve(Work * w, const Data * d, const Cone * k, Sol * sol, Info * in
void scs_finish(Work * w);
/* scs calls scs_init, scs_solve, and scs_finish */
scs_int scs(const Data * d, const Cone * k, Sol * sol, Info * info);

const char * scs_version(void);

/* the following structs are not exposed to user */

Expand Down Expand Up @@ -110,6 +110,5 @@ struct residuals {
scs_float tau;
scs_float kap;
};

#endif

12 changes: 7 additions & 5 deletions matlab/make_scs.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
flags.INCS = '';
flags.LOCS = '';

common_scs = '../src/linAlg.c ../src/cones.c ../src/cs.c ../src/util.c ../src/scs.c ../src/ctrlc.c ../linsys/common.c scs_mex.c';
common_scs = '../src/linAlg.c ../src/cones.c ../src/cs.c ../src/util.c ../src/scs.c ../src/ctrlc.c ../linsys/common.c ../src/scs_version.c scs_mex.c';
if (~isempty (strfind (computer, '64')))
flags.arr = '-largeArrayDims';
else
Expand All @@ -26,13 +26,15 @@
end

if (flags.COMPILE_WITH_OPENMP)
flags.link = strcat(flags.link, ' -lgomp')
flags.link = strcat(flags.link, ' -lgomp');
end


compile_direct(flags, common_scs);
compile_indirect(flags, common_scs);

% compile scs_version
mex -O -I../include ../src/scs_version.c scs_version_mex.c -output scs_version

%%
clear data cones
disp('Example run:');
Expand All @@ -42,6 +44,6 @@
data.b = randn(m,1);
data.c = randn(n,1);
cones.l = m;
[x,y,info] = scs_indirect(data,cones,[]);
[x,y,info] = scs_direct(data,cones,[]);
[x,y,s,info] = scs_indirect(data,cones,[]);
[x,y,s,info] = scs_direct(data,cones,[]);
disp('SUCCESSFULLY INSTALLED SCS')
4 changes: 2 additions & 2 deletions matlab/scs.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function [ x, y, info ] = scs( varargin )
% scs 1.1.0
function [ x, y, s, info ] = scs( varargin )
% for version call: scs_version()
data = varargin{1};
K = varargin{2};
if nargin >= 3
Expand Down
2 changes: 1 addition & 1 deletion matlab/scs_mex.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ scs_int parseWarmStart(const mxArray * p_mex, scs_float ** p, scs_int l) {
}

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
/* matlab usage: scs(data,cone,settings); */
/* matlab usage: [x,y,s,info] = scs(data,cone,settings); */
scs_int i, ns, status;
Data *d;
Cone *k;
Expand Down
14 changes: 14 additions & 0 deletions matlab/scs_version_mex.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "mex.h"
#include "scs.h"

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
/* matlab usage: ver = scs_version() */
if (nrhs != 0) {
mexErrMsgTxt("scs_version doesn't take inout arguments.");
}
if (nlhs > 1) {
mexErrMsgTxt("scs_version returns 1 output argument only.");
}
plhs[0] = mxCreateString(scs_version());
return;
}
2 changes: 1 addition & 1 deletion python/scsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static PyObject * finishWithErr(Data * d, Cone * k, struct ScsPyData * ps, char
}

static PyObject *version(PyObject* self) {
return Py_BuildValue("s", SCS_VERSION);
return Py_BuildValue("s", scs_version());
}

static PyObject *csolve(PyObject* self, PyObject *args, PyObject *kwargs) {
Expand Down
7 changes: 1 addition & 6 deletions src/scs.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ static scs_int scs_isnan(scs_float x) {
return (x == NAN || x != x);
}

const char * scsVersion(void) {
return SCS_VERSION;
}

static void freeWork(Work * w) {
if (w) {
if (w->u)
Expand Down Expand Up @@ -74,8 +70,7 @@ static void printInitHeader(const Data * d, const Cone * k) {
for (i = 0; i < _lineLen_; ++i) {
scs_printf("-");
}
scs_printf("\n\tSCS v%s - Splitting Conic Solver\n\t(c) Brendan O'Donoghue, Stanford University, 2012\n",
scsVersion());
scs_printf("\n\tSCS v%s - Splitting Conic Solver\n\t(c) Brendan O'Donoghue, Stanford University, 2012\n", scs_version());
for (i = 0; i < _lineLen_; ++i) {
scs_printf("-");
}
Expand Down
6 changes: 6 additions & 0 deletions src/scs_version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "constants.h"

const char * scs_version(void) {
return SCS_VERSION;
}

0 comments on commit 824dbdf

Please sign in to comment.