Skip to content

urbanjost/M_factor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

M_factor

M_factor

This is a growing collection of Fortran procedures related to factorization of integers and polynomials, and prime factorization.

Introduction

Division is basically the reverse operation of multiplication. But it gets a little more difficult when your factors can only be whole numbers.

The factors are any of the numbers (or symbols) that form a product when multiplied together.

So, for example an Integer Factor is one of two or more integers that can be exactly divided into another integer.

Another equivalent way to define "factor" is that it is quantity which is multiplied by another quantity.

This is in contrast to statistics, where a factor can mean any independent variable.

There are a few basic example programs included as well ...

  • lcm - display least common multiple of a list of whole numbers
  • factors - display prime factors of numbers
  • gcd - display greatest common divisor of a list of whole numbers

All the procedures are gathered into the Fortran module M_factor.f90. So far ...

Name

M_factor(3fm) - module for least common multiple, greatest common divisor, and prime factors

Synopsis

       use M_factor, only : least_common_multiple, greatest_common_divisor
       use M_factor, only : prime_factors, i_is_prime
  • least_common_multiple

    Least common multiple of two integers or vector m(:), matrix m(:,:) or cuboid m(:, :, :)

  • greatest_common_divisor

    greatest common divisor of two integers or vector m(:), matrix m(:,:) or cuboid m(:, :, :)

  • prime_factors

    decompose a number into its prime factors

  • i_is_prime

    Determine if a number is prime using Sieve of Erasthosthenes

Description

This module is a collection of procedures that perform common functions found in arithmetic and number theory such as Least Common Multiples, Greatest Common Divisors, and Prime Factors of INTEGER variables. The INTEGER values are typically limited to values up to the magnitude (2**31)-1= 2147483647.

Examples

The individual man(1) pages for each procedure contain examples and a full description of the procedure parameters.


gmake

Building the Module using make(1)

 git clone https://github.com/urbanjost/M_factor.git
 cd M_factor/src
 # change Makefile if not using one of the listed compilers
 
 # for gfortran
 make clean
 make F90=gfortran gfortran
 
 # for ifort
 make clean
 make F90=ifort ifort

 # for nvfortran
 make clean
 make F90=nvfortran nvfortran

This will compile the Fortran module and basic example program that exercise the routine.


-

Build and Test with FPM

Alternatively, download the github repository and build it with fpm ( as described at Fortran Package Manager )

     git clone https://github.com/urbanjost/M_factor.git
     cd M_factor
     fpm run "*"
     fpm run --example "*"
     fpm test

or just list it as a dependency in your fpm.toml project file.

        [dependencies]
        M_factor        = { git = "https://github.com/urbanjost/M_factor.git" }

docs

Documentation

User

  • A single page that uses javascript to combine all the HTML descriptions of the man-pages is at BOOK_M_factor.

  • a simple index to the man-pages in HTML form for the routines and programs

  • man-pages There are man-pages in the repository download in the docs/ directory that may be installed on ULS (Unix-Like Systems).

  • CHANGELOG provides a history of significant changes

Developer


-

Pedigree

References