The Matrix Template Library
Generic Components for High Performance Scientific Computing
  Search | Support |  Download 

Contents

Navigating This Site
What's New
Download MTL
Search in MTL Pages
>MTL Home

On-Line Documentation
Introduction
Programmer's Reference
Examples
Performance Results
Recent Tests
To-do list
Coding Standards

Related Work
Related Projects at OSL
Projects Using MTL
Generic Programming
Scientific Computing

MTL Publications
Papers
Presentations

Contact
Support
Contribute!
Mailing Lists
User Comments/Eval
License Information
Source code for max_index.cc
 Show this file without HTML

// -*- c++ -*-
//
// $COPYRIGHT$
//
//===========================================================================

#include "mtl/mtl.h"
#include "mtl/utils.h" 
#include "mtl/linalg_vec.h"

using namespace mtl;
using namespace std;
//begin
typedef external_vec Vec;
//end

/*
  Sample Output 

  [5,-3,-4,6,0,]
  Largest element in the vector x is at location 3

 */

int
main()
{
  //begin
  const int N = 5;
  float dx[] = { 5.0, -3.0,-4.0, 6.0 , 0.0 };
  Vec x(dx, N);
  
  int imax = max_index(x);
  //end

  print_vector(x);

  cout << "Largest element in the vector x is at location "
       << imax << endl;
  return 0;
}
If you have comments or suggestions, email mtl-devel@osl.iu.edu
Author: Andrew Lumsdaine, Jeremy Siek Lie-Quan Lee
E-Mail: lums@osl.iu.edu, jsiek@osl.iu.edu, llee@osl.iu.edu
Created: July 27, 1998
Modified: Mon 27-Aug-2012 EST
Copyright ©1997-2013