How to: Call Julia from C#

Posted by: Sushila Patels Weblog, on 05 Feb 2016 | View original | Bookmarked: 0 time(s)

This is basic sample that shows how to call Julia code from C#

Step 1:

  • Set up the 64 bit solution
  • Build / Configuration Manager
  • Active solution platform /New X64/ Copy settings from Win32

Step 2:

  • Code as below

class Program

  {

[DllImport("kernel32.dll")]

public static extern bool SetDllDirectory(string pathName);

[DllImport("libjulia.dll")]

public static extern void jl_init(string julia_home_dir);

[DllImport("libjulia.dll")]

public static extern void jl_eval_string(string str);

static void Main(string[] args)

    {

  SetDllDirectory(@"C:\Julia-0.5.0-dev\bin\");

  jl_init(@"C:\Julia-0.5.0-dev\bin\");

jl_eval_string("print(sqrt(2.0))");

                   jl_eval_string("println(map(round, [1.2,3.5,1.7]))");

  }

}

Output

 src=

Category: C# | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1136 | Hits: 4

Similar Posts

  • Decouple javascript function call to multiple callbacks without changing nor caller neither callee more
  • How to abort a AJAX call before calling the same again more
  • Html Encoding Nuggets With ASP.NET MVC 2 more
  • Ambiguous References in DefaultWsdlHelpGenerator.aspx more
  • Windows Trick-or-treat Foundation more
  • Dynamic in C# 4.0: Creating Wrappers with DynamicObject more
  • My History of Visual Studio (Part 6) more
  • Response: "Agile is treating the symptoms, not the disease" by Ted Neward more
  • Principles, Patterns, and Practices of Mediocre Programming more
  • Facebook Developer Toolkit 3.0 ASP.NET MVC Sample more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD