gov.nist.microanalysis.EPQLibrary
Class MACCache

java.lang.Object
  extended by gov.nist.microanalysis.EPQLibrary.MACCache

public class MACCache
extends java.lang.Object

Implements a simple class for caching mass absorption coefficient values. Calculating MACs can be CPU intensive and since they are required so often by NISTMonte, this class offers a substancial performance optimization.

Copyright: Pursuant to title 17 Section 105 of the United States Code this software is not subject to copyright protection and is in the public domain

Company: National Institute of Standards and Technology

Version:
1.0
Author:
Nicholas W. M. Ritchie

Field Summary
static double NOT_IN_CACHE
          The value returned by getMAC(...) when the Material/energy combination is not currently stored in the cache.
 
Constructor Summary
MACCache(double maxE)
          MACCache - Create a new MACCache object.
 
Method Summary
 void addMAC(Material mat, double energy, double mac)
          addMAC - Add a MAC to the cache.
 void clear()
           
 double getMAC(Material mat, double energy)
          getMAC - get a MAC from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_IN_CACHE

public static final double NOT_IN_CACHE
The value returned by getMAC(...) when the Material/energy combination is not currently stored in the cache. Note: NOT_IN_CACHE = Double.MAX_VALUE so regular == operators work (This is not the case for Double.NaN).

See Also:
Constant Field Values
Constructor Detail

MACCache

public MACCache(double maxE)
MACCache - Create a new MACCache object.

Method Detail

clear

public void clear()

getMAC

public double getMAC(Material mat,
                     double energy)
getMAC - get a MAC from the cache. Returns a number less than zero when the MAC is not in the cache.

Parameters:
mat - Material - The absorber material
energy - double - The x-ray energy
Returns:
double - The MAC or a value equal to MACCache.NOT_IN_CACHE when the MAC is not in the cache.

addMAC

public void addMAC(Material mat,
                   double energy,
                   double mac)
addMAC - Add a MAC to the cache. The MAC is associated with the specified Material and energy.

Parameters:
mat - Material - The absorber material.
energy - double - The x-ray energy
mac - double - The MAC to be associated in the cache with mat and energy.