Sha256: cad8ad8bf49ed4c56313613ef921bb35340ae73a6a83feeb3c97a8032bbe812d

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

/////////////////////////////////////////////////////////////////////
// = NMatrix
//
// A linear algebra library for scientific computation in Ruby.
// NMatrix is part of SciRuby.
//
// NMatrix was originally inspired by and derived from NArray, by
// Masahiro Tanaka: http://narray.rubyforge.org
//
// == Copyright Information
//
// SciRuby is Copyright (c) 2010 - 2013, Ruby Science Foundation
// NMatrix is Copyright (c) 2013, Ruby Science Foundation
//
// Please see LICENSE.txt for additional copyright notices.
//
// == Contributing
//
// By contributing source code to SciRuby, you agree to be bound by
// our Contributor Agreement:
//
// * https://github.com/SciRuby/sciruby/wiki/Contributor-Agreement
//
// == util.h
//
// Header file for utility functions and data.

#ifndef UTIL_H
#define UTIL_H

/*
 * Standard Includes
 */

/*
 * Project Includes
 */

#include "types.h"

/*
 * Macros
 */

/*
 * Types
 */

/*
 * Data
 */

/*
 * Functions
 */
namespace nm {
  template <typename Type>
  inline Type gcf(Type x, Type y) {
    Type t;

    if (x < 0) x = -x;
    if (y < 0) y = -y;

    if (x == 0) return y;
    if (y == 0) return x;

    while (x > 0) {
      t = x;
      x = y % x;
      y = t;
    }

    return y;
  }
} // end of namespace nm


#endif // UTIL_H

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nmatrix-0.0.9 ext/nmatrix/util/util.h
nmatrix-0.0.8 ext/nmatrix/util/util.h
nmatrix-0.0.7 ext/nmatrix/util/util.h
nmatrix-0.0.6 ext/nmatrix/util/util.h
nmatrix-0.0.5 ext/nmatrix/util/util.h
nmatrix-0.0.4 ext/nmatrix/util/util.h