Constraints in TextWaves for ThreadSafe FuncFit

Currently you have to create a matrix and a 1D wave containing the information of the constraints text wave. Please add the possibility to use constraint text waves for ThreadSafe FuncFits. The current solution is impractical, especially if you want to change the parameters or understand them directly from the source code.

Unfortunately, the code that parses those text waves uses Igor's interpreter, which is not thread safe. That was my solution to recognizing the various symbols that you can use there. The interpreter is ancient code rife with globals, and is unlikely ever to be threadsafe.

My only offering is that you can call CurveFit to generate the required waves using the /C flag. Note that this is a "flag" which means one of the flags right after CurveFit or FuncFit. There is also the /C "parameter" down at the end of the command that specifies the constraint specification.

The format of the waves required is described in DisplayHelpTopic "Constraint Matrix and Vector". It is not entirely opaque, just mostly :)

I have tried it this way and it works well, but it is just complicated. This was the reason of my wish.

Alternatively, would it not be possible to implement the "/C" as a separate function that converts a text wave into the two needed waves (without performing a fit)?

Quick and dirty version:

function f_constr_txt_to_matrix(wave/T w_T_Constraints, variable number_of_Ks)
    string importstring=""
    variable v_num_rows=Dimsize(w_T_Constraints,0)
    variable index
    for (index=0;index<v_num_rows;index+=1)
        importstring+=w_T_Constraints[index]
        importstring+=";"
    endfor
    importstring=replacestring("K",importstring,"")
    variable v_items=itemsinList(importstring)
    make/O/N=(v_items) temporary_wave
    for (index=0;index<v_items;index+=1)
        temporary_wave[index]=str2num(StringFromList(index,importstring))
    endfor
    make/O/N=(v_items,number_of_Ks) M_FitConstraint=0
    make/O/N=(v_items) W_FitConstraint
    string tempstring  
    string s_replace
    variable v_row=0
    variable v_read
    for (index=0;index<v_items;index+=1)
        tempstring=StringFromList(index,importstring)
        if (StringMatch(tempstring,"*>*")==1)
            s_replace=num2str(temporary_wave[index])+" >"
            tempstring=replacestring(s_replace,tempstring,"")
            v_read=str2num(tempstring)
            M_FitConstraint[v_row][temporary_wave[index]]=-1
            if (v_read==0)
                W_FitConstraint[v_row]=v_read
            else
                W_FitConstraint[v_row]=(-1)*v_read
            endif
        else
            s_replace=num2str(temporary_wave[index])+" <"
            tempstring=replacestring(s_replace,tempstring,"")
            v_read=str2num(tempstring)
            M_FitConstraint[v_row][temporary_wave[index]]=1
            W_FitConstraint[v_row]=v_read
        endif
        v_row+=1
    endfor
    killwaves temporary_wave   
end