Blog

Archive for the ‘NMath’ Category

Announcing NMath 5.3 and NMath Stats 3.6

Tuesday, May 7th, 2013

CenterSpace is proud to announce the immediate availability of new versions of our .NET math libraries, NMath 5.3 and NMath Stats 3.6. This release adds many new features and performance enhancements.

Version 5.3 of NMath adds:

  • IEnumerable<T> support for matrix classes, facilitating their use with LINQ.
  • An in-place solve option for LU factorization.
  • Improved support for NMath configuration within ASP.NET web applications.
  • Matrix and vector visualizers for debugging in Visual Studio 2012.
  • Performance increases in several areas, due to an upgrade to Intel MKL 11.0 Update 3.
  • …a complete changelog is located here.

Version 3.6 of NMath Stats adds:

Upgrades are provided free of charge to customers with current annual maintenance contracts. Maintenance contracts are available through our webstore.

We will shortly also be announcing the general availability of the new Premium Edition of NMath and NMath Stats, which provides GPU acceleration of linear algebra (dense systems) and 1D and 2D FFT. We’ve gotten great feedback from users in our beta program, and are excited to make this option available to everyone. We think you will be too, when you see how easy it is to add GPU acceleration to your existing NMath applications. Check out our whitepaper, NMath Premium: GPU-Accelerated Math Libraries for .NET, and watch this space for more information soon.

Share

NMath Charts in WPF

Tuesday, March 5th, 2013

The NMathChart adapter class makes it easy to generate visualizations of NMath data in as little as one line of code.  The Chart class that is created is a Windows Forms control, but this control can be included in a Windows Presentation Foundation application by using the WindowsFormsHost element.

To do so:

  1. Add references to these namespaces:

    System.Windows.Forms
    System.Windows.Forms.Integration

  2. In the XAML markup for your WPF window (MainWindow.xaml for example), add a WindowsFormsHost element at the desired location, e.g:

    <Grid>
      <WindowsFormsHost Name="ChartHost"/>
    </Grid>

  3. In the code-behind for the window (MainWindow.xaml.cs for example), set the Child property of the WindowsFormsHost to a Chart. For example:

    public MainWindow()
    {
      InitializeComponent();
      ChartHost.Child = NMathChart.ToChart(NMathFunctions.CosFunction, 
                                            -Math.PI, Math.PI, 100 );
    }

To see this in action, check out the sample code in the new Visualization Examples solution included in NMath 5.3. For more information about visualization of NMath data types, see:

Share

NMath 5.3, NMath Stats 3.6 are coming

Wednesday, February 27th, 2013

NMath 5.3 and NMath Stats 3.6 are nearing release!  Here are a few of the things that you can look forward to in the new releases:

  • IEnumerable<T> support for matrix classes, facilitating their use with LINQ.
  • An in-place solve option for LU factorization.
  • Improved support for NMath configuration within ASP.NET web applications.
  • Matrix and vector visualizers for debugging in Visual Studio 2012.
  • Performance increases in several areas, due to an upgrade to Intel MKL 10.3 Update 12.
  • A variety of new options, performance improvements, and bug fixes.

And new Stats capabilities:

  • New LogisticRegression and related classes for performing binomial logistic regression.
  • New classes for process control statistics, such as Cp, Cpm, Cp, Pp, and Ppk.

In addition, NMath Premium edition offers GPU acceleration of linear algebra and 1D and 2D FFT.  Check out the NMath Premium page on our website for more information, or download our detailed whitepaper, “NMath Premium: GPU-Accelerated Math Libraries for .NET.”

Upgrades will be available free of charge for customers with current annual maintenance contracts, so it’s a great time to check that your maintenance is up to date. Since new product licenses include a one year Maintenance Contract, anyone purchasing new licenses now will receive the upgrades free.

Product licenses and maintenance contract renewals are available through our web store, or feel free to contact sales@centerspace.net with any questions.

Share

Building ASP.NET web applications with NMath

Thursday, February 21st, 2013

NMath can be used to create ASP.NET web applications, just like any other .NET application. However, there are a few additional considerations for building and deploying ASP.NET applications.

Referencing NMath

To use NMath types in your application, add a reference to NMath.dll, just as you would with other types of .NET applications. If you are using web projects in Visual Studio, you can simply right-click the References folder and select the Add Reference… command. If you specify Copy Local = true in the reference’s properties, then the assembly will be copied to the /bin directory of the web application, facilitating deployment to a web server.

If you are not using web projects in Visual Studio (e.g. using the “Open Web Site” command in Visual Studio, or using other development tools), then you can alternatively specify the reference in the web.config file, like this:

<configuration>
<system.web>
<compilation>
<assemblies>
<add assembly=”NMath, Version=<Version>, Culture=neutral, PublicKeyToken=<Token>”/>
</assemblies>
</compilation>
</system.web>
</configuration>

We recommend that you do not add references to the kernel assemblies, as the appropriate kernel assembly for your platform is loaded at runtime and the appropriate native DLL is linked to the kernel.  Instead, place the kernel assemblies in the same location as the native DLLs, as described below.

Note: when the web server launches an ASP.NET application for the first time, the assemblies in the /bin directory are loaded into memory. If the /bin directory contains a mixture of 32-bit and 64-bit assemblies (for example, both NMathKernelx86.dll and NMathKernelx64.dll), then depending on the configuration of the web server, the application may fail to start and instead throw an exception like this: “An attempt was made to load a program with an incorrect format.”

Kernel Assemblies and Native DLLs

For ASP.NET applications, Microsoft recommends that the /bin directory contain only .NET assemblies, not native DLLs.

If the deployment web server may not have NMath installed directly, then we recommend that the appropriate kernel assembly (NMathKernelx86.dll or NMathKernelx64.dll) and the appropriate native DLLs (e.g. nmath_native_x86.dll or nmath_native_x64.dll) be placed in a folder within the web application root directory, such as /NativeBin. This folder should then be copied to the deployment web server along with the rest of your application.

NMath Configuration

NMath settings can be configured as described in Chapter 1.5 of the NMath User’s Guide. However, when deploying web applications — especially to a shared hosting environment — it’s quite common not to know the details about the physical structure of the file system, and to have restricted access to the system’s environment variables. The references to resources within web apps are typically relative to the root of the virtual directory for the website, regardless of where they might physically reside on disk.

For this reason, starting in NMath 5.3, the ASP.NET ~ operator can be used to specify the location of the NMath native libraries and the log file, relative to the web application root. That is, these can be specified in the web.config file like this:

<add key=”NMathNativeLocation” value=”~/NativeBin” />
<add key=”NMathLogLocation” value=”~/Logs” />

It is not sufficient to use relative paths (e.g. “bin/”), since the executing assembly is usually the ASP.NET worker process, and depending on the web server configuration, the working directory will usually be a subdirectory of the Windows system directory (e.g. c:\windows\system32).

The ~ operator can only be used in ASP.NET applications; specifying this in a Windows application will cause the path to be resolved incorrectly.

Share

Setting the NMath License Key

Wednesday, August 1st, 2012

NMath license information is stored in a license key which must be found at runtime. When you purchase one or more developer seats of NMath, you will be issued a license key describing the terms of your license. As described in a previous post, beginning with the release of NMath 5.2 and NMath Stats 3.5, NMath includes a new configuration system for controlling the setting of the NMath license key.

An NMath license file is no longer used.

Evaluation

If no license key is found at runtime, a default evaluation license key is used which provides a free 30-day evaluation period for NMath on the current machine.

Development

At development time, you will typically have NMath installed on your machine. To enter your license key into the registry:

  1. Open CenterSpace Software | License NMath from your Start menu.
  2. Enter your name, email, and license key, and click OK.

You can also specify your license key using various other mechanisms–by environment variable, by configuration app setting, and programmatically–in which case, any keys in the registry are ignored. These other mechanisms may be preferable in group development environments, and at deployment. (See below.)

Deployment

During deployment, NMath will typically not be installed on the deployment machine. In this case, three mechanisms are supported for setting your NMath license key:

  • by setting the NMATH_LICENSE_KEY environment variable
  • by setting the NMathLicenseKey configuration app setting
  • by programmatically setting the LicenseKey property on class NMathConfiguration

Settings are applied in that order, and resetting the license key takes precedent over any earlier values. For example, here the environment variable is used:

 > set NMATH_LICENSE_KEY="<your key here>"

This code uses an app config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="NMathLicenseKey" value="<your key here>" />
  </appSettings>
</configuration>

And this code accomplishes the same thing programmatically:

NMathConfiguration.LicenseKey = "<your key here>";

Note that if you forget to set your license key on a deployment machine, your code NMath code will work initially, using the default evaluation license, but this license will expire in 30 days.

Share