public static int[] PseudoInverseWorkspace(Cdn.Dimension d) { int[] m = new int[] { d.Rows }; int[] n = new int[] { d.Columns }; var maxdim = System.Math.Max(d.Rows, d.Columns); var mindim = System.Math.Max(d.Rows, d.Columns); int[] nrhs = new int[] { maxdim }; double[] A = new double[d.Size()]; double[] b = new double[maxdim * maxdim]; double[] s = new double[mindim]; double[] rcond = new double[] { -1 }; double[] rank = new double[1]; double[] work = new double[1]; int[] lwork = new int[] { -1 }; int[] iwork = new int[1]; int[] info = new int[1]; int nlvl = (int)System.Math.Log(mindim / (25.0 + 1.0), 2) + 1; int riwork = 3 * mindim * nlvl + 11 * mindim; try { dgelsd_(m, n, nrhs, A, m, b, nrhs, s, rcond, rank, work, lwork, iwork, info); return(new int[] { (int)work[0], riwork }); } catch { return(new int[] { 12 * mindim + 2 * mindim * 25 + 8 * mindim * nlvl + mindim * maxdim + (int)System.Math.Pow(25.0 + 1.0, 2), riwork }); } }
public Matrix(out double values, int length, Cdn.Dimension dimension) { IntPtr native_dimension = GLib.Marshaller.StructureToPtrAlloc(dimension); Raw = cdn_matrix_new_flat(out values, length, native_dimension); dimension = Cdn.Dimension.New(native_dimension); Marshal.FreeHGlobal(native_dimension); }
public static InstructionIndex NewOffset(int start, Cdn.Dimension retdim, Cdn.StackArg arg) { IntPtr native_retdim = GLib.Marshaller.StructureToPtrAlloc(retdim); InstructionIndex result = new InstructionIndex(cdn_instruction_index_new_offset(start, native_retdim, arg == null ? IntPtr.Zero : arg.Handle)); retdim = Cdn.Dimension.New(native_retdim); Marshal.FreeHGlobal(native_retdim); return(result); }
public static Cdn.Matrix Init(out double values, Cdn.Dimension dimension) { IntPtr native_dimension = GLib.Marshaller.StructureToPtrAlloc(dimension); IntPtr raw_ret = cdn_matrix_init(out values, native_dimension); Cdn.Matrix ret = raw_ret == IntPtr.Zero ? null : (Cdn.Matrix)GLib.Opaque.GetOpaque(raw_ret, typeof(Cdn.Matrix), false); dimension = Cdn.Dimension.New(native_dimension); Marshal.FreeHGlobal(native_dimension); return(ret); }
public bool GetDimension(out Cdn.Dimension dimension) { IntPtr native_dimension = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Cdn.Dimension))); bool raw_ret = cdn_expression_get_dimension(Handle, native_dimension); bool ret = raw_ret; dimension = Cdn.Dimension.New(native_dimension); Marshal.FreeHGlobal(native_dimension); return(ret); }
public uint ApplySlice(uint length, Cdn.Dimension dim) { uint slice; IntPtr native_dim = GLib.Marshaller.StructureToPtrAlloc(dim); cdn_instruction_variable_apply_slice(Handle, out slice, length, native_dim); dim = Cdn.Dimension.New(native_dim); Marshal.FreeHGlobal(native_dim); return(slice); }
public InstructionMatrix(Cdn.StackArgs args, Cdn.Dimension dim) : base(IntPtr.Zero) { if (GetType() != typeof(InstructionMatrix)) { throw new InvalidOperationException("Can't override this constructor."); } IntPtr native_dim = GLib.Marshaller.StructureToPtrAlloc(dim); Raw = cdn_instruction_matrix_new(args == null ? IntPtr.Zero : args.Handle, native_dim); dim = Cdn.Dimension.New(native_dim); Marshal.FreeHGlobal(native_dim); }
public InstructionIndex(out int indices, Cdn.Dimension retdim, Cdn.StackArg arg) : base(IntPtr.Zero) { if (GetType() != typeof(InstructionIndex)) { throw new InvalidOperationException("Can't override this constructor."); } IntPtr native_retdim = GLib.Marshaller.StructureToPtrAlloc(retdim); Raw = cdn_instruction_index_new(out indices, native_retdim, arg == null ? IntPtr.Zero : arg.Handle); retdim = Cdn.Dimension.New(native_retdim); Marshal.FreeHGlobal(native_retdim); }
public bool Equal(Cdn.Dimension other) { IntPtr this_as_native = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(this)); System.Runtime.InteropServices.Marshal.StructureToPtr(this, this_as_native, false); IntPtr native_other = GLib.Marshaller.StructureToPtrAlloc(other); bool raw_ret = cdn_dimension_equal(this_as_native, native_other); bool ret = raw_ret; ReadNative(this_as_native, ref this); System.Runtime.InteropServices.Marshal.FreeHGlobal(this_as_native); other = Cdn.Dimension.New(native_other); Marshal.FreeHGlobal(native_other); return(ret); }
public void SetSlice(int[] slice, Cdn.Dimension dim) { if (slice == null) { cdn_instruction_variable_set_slice(Handle, IntPtr.Zero, 0, IntPtr.Zero); } else { IntPtr pnt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int)) * slice.Length); Marshal.Copy(slice, 0, pnt, slice.Length); IntPtr native_dim = GLib.Marshaller.StructureToPtrAlloc(dim); cdn_instruction_variable_set_slice(Handle, pnt, slice.Length, native_dim); Marshal.FreeHGlobal(native_dim); Marshal.FreeHGlobal(pnt); } }
public static int QrWorkspace(Cdn.Dimension d) { int[] m = new int[] { d.Rows }; int[] n = new int[] { d.Columns }; double[] A = new double[d.Size()]; double[] tau = new double[d.Rows < d.Columns ? d.Rows : d.Columns]; double[] work = new double[1]; int[] lwork = new int[] { -1 }; int[] info = new int[1]; try { dgeqrf_(m, n, A, m, tau, work, lwork, info); return((int)work[0]); } catch { return(d.Columns * 64); } }
public DataItem(DataTable table, object key, object obj, int index, int dataindex, Flags type) { d_table = table; d_index = index; d_dataindex = dataindex; d_key = key; d_object = obj; d_type = type; var st = obj as State; if (st != null) { d_dimension = st.Dimension; } else { d_dimension = new Cdn.Dimension { Rows = 1, Columns = 1 }; } }
public int[] GetSlice(out Cdn.Dimension dim) { int length; IntPtr native_dim = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Cdn.Dimension))); IntPtr raw_ret = cdn_instruction_variable_get_slice(Handle, out length, native_dim); if (raw_ret == IntPtr.Zero) { Marshal.FreeHGlobal(native_dim); dim = new Cdn.Dimension { Rows = 1, Columns = 1 }; return(null); } dim = Cdn.Dimension.New(native_dim); Marshal.FreeHGlobal(native_dim); int[] ret = new int[length]; Marshal.Copy(raw_ret, ret, 0, length); return(ret); }
static extern void glibsharp_value_set_boxed(ref GLib.Value val, ref Cdn.Dimension boxed);
static void ReadNative(IntPtr native, ref Cdn.Dimension target) { target = New(native); }