source: trunk/Clp/examples/hello.cpp @ 819

Last change on this file since 819 was 387, checked in by forrest, 16 years ago

silly

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 KB
Line 
1/* Copyright (C) 2004, International Business Machines Corporation
2   and others.  All Rights Reserved.
3
4   This sample program is designed to illustrate programming
5   techniques using CoinLP, has not been thoroughly tested
6   and comes without any warranty whatsoever.
7
8   You may copy, modify and distribute this sample program without
9   any restrictions whatsoever and without any payment to anyone.
10*/
11
12/* This shows how to provide a simple picture of a matrix.
13   The default matrix will print Hello World
14*/
15
16#include "ClpSimplex.hpp"
17
18int main (int argc, const char *argv[])
19{
20  ClpSimplex  model;
21  int status;
22  // Keep names
23  if (argc<2) {
24    status=model.readMps("hello.mps",true);
25  } else {
26    status=model.readMps(argv[1],true);
27  }
28  if (status)
29    exit(10);
30
31  int numberColumns = model.numberColumns();
32  int numberRows = model.numberRows();
33 
34  if (numberColumns>80||numberRows>80) {
35    printf("model too large\n");
36    exit(11);
37  }
38  printf("This prints x wherever a non-zero elemnt exists in matrix\n\n\n");
39
40  char x[81];
41
42  int iRow;
43  // get row copy
44  CoinPackedMatrix rowCopy = *model.matrix();
45  rowCopy.reverseOrdering();
46  const int * column = rowCopy.getIndices();
47  const int * rowLength = rowCopy.getVectorLengths();
48  const CoinBigIndex * rowStart = rowCopy.getVectorStarts();
49 
50  x[numberColumns]='\0';
51  for (iRow=0;iRow<numberRows;iRow++) {
52    memset(x,' ',numberColumns);
53    for (int k=rowStart[iRow];k<rowStart[iRow]+rowLength[iRow];k++) {
54      int iColumn = column[k];
55      x[iColumn]='x';
56    }
57    printf("%s\n",x);
58  }
59  printf("\n\n");
60  return 0;
61}   
Note: See TracBrowser for help on using the repository browser.