wolfram mathematica - Passing a java function as a parameter -
i'm using wolfram mathematica 9.0 in java application. problem need generate long expression (something 1.2 * (x-1) + 1.25 * (x-1.5) + ...etc.) function , takes long time build stringbuilder. there ways pass java function without converting wolfram expression?
upd
this function talking about. builds wolfram function exxpression. usually, arr length more 100000.
public static string buildcdfexpressionforwolfram(double [] arr){ stringbuilder strbuilder = new stringbuilder(); int n = arr.length; strbuilder.append("("); for(int = 0; < n; i++){ strbuilder.append("heavisidetheta[x"); if(arr[i] > 0) { strbuilder.append("-"); strbuilder.append(arr[i]); } else if(arr[i] < 0){ strbuilder.append("+"); strbuilder.append(-arr[i]); } strbuilder.append("]"); if(i != n - 1){ strbuilder.append("+"); } } strbuilder.append(") / " + n); return strbuilder.tostring(); }
what happens if reduce amount of append
call ?
public static string buildcdfexpressionforwolfram(double [] arr){ stringbuilder strbuilder = new stringbuilder("("); int n = arr.length; for(int = 0; < n; i++){ if(arr[i] > 0) { strbuilder.append("heavisidetheta[x-"+arr[i]+"]"); } else if(arr[i] < 0){ strbuilder.append("heavisidetheta[x+-"+arr[i]+"]"); } if(i != n - 1){ strbuilder.append("+"); } } strbuilder.append(") / " + n); return strbuilder.tostring(); }
Comments
Post a Comment