Can gamlasso accept sparse model matrices class "dgCMatrix"? - sparse-matrix

Can gamlasso from the plsmselect package accept sparse model matrices class "dgCMatrix"?

Right now the plsmselect package does not accept sparse model matrices. We'll try to implement this for future versions.

Related

What is the purpose of `BRepLib::BuildCurves3d` calls in the OpenCASCADE tutorial?

As an OpenCASCADE newbie, I am reading the OpenCASCADE tutorial:
https://www.opencascade.com/doc/occt-7.4.0/overview/html/occt__tutorial.html
There are following two curious calls:
BRepLib::BuildCurves3d(threadingWire1);
BRepLib::BuildCurves3d(threadingWire2);
The tutorial explains the need for these two calls in this way:
Remember that these wires were built out of a surface and 2D curves. One important data item is missing as far as these wires are concerned: there is no information on the 3D curves. Fortunately, you do not need to compute this yourself, which can be a difficult task since the mathematics can be quite complex. When a shape contains all the necessary information except 3D curves, Open CASCADE Technology provides a tool to build them automatically. In the BRepLib tool package, you can use the BuildCurves3d method to compute 3D curves for all the edges of a shape.
which I did not find entirely clear.
Imagine that I have constructed some TopoDS_Shape object.
How can I, in general, figure out whether BRepLib::BuildCurves3d call is necessary or not?
With this code you can get the 3D curve of an edge (take from BRepExtrema_DistanceSS.cxx):
Standard_Real aFirst, aLast;
Handle(Geom_Curve) pCurv = BRep_Tool::Curve(E, aFirst, aLast);
If you have not created the 3D curves, pCurv will be a null handle. Using it will result in segmentation faults.
I have been excited about where the 3D curves are actually used. Therefore I have tried several algorithms. These are the algorithms I have tried where the 3D curves are not used:
Visualizing
Export to BREP
Export to STEP
Length Measurement
Checking Whether a Wire Is Closed or Ordered
The only algorithm I have found where the 3D curves are used are extrema/distance computations with BRepExtrema_DistShapeShape. You will not be able to use this class if you have not created the 3D curves.

how to bind methods to (nested) numpy dtype?

I am wishing to associate object methods with dtypes in a numpy structured array. That is the underlying object instance state of my collection of object is already packed into a numpy (nested dtype) record_arrays..
I already have a set of Python objects, that are constructed on top of views of these numpy structured array dtypes that then operate on this underlying continuously packed object instance data.
That is: I am wishing to use object oriented programming methods, while working with the underlying instance state in it's native packed, structured format.
-> Currently working with these numpy structured arrays using Python object methods, requires that explicitly instantiate a Python object on top of it's associated array view each time I re-reference it within the array..
Might it be possible to more directly associate object methods with a numpy structured array (nested) dtype, so that one could avoid having to reconstruct the object instance each time ??
Your description is confusing. Some basic code might help make it clearer. But I'll throw out some possibly relevant observations.
A numpy array has a (large) continuous data buffer (flat list of bytes), which it divides into 'records'. 'shape' and 'strides' are used to step through the records. 'dtype' determines how it 'views' each record.
While these arrays are a Python object type, and dtype is also a class, in general numpy programmers don't put a lot of effort into constructing added array object classes. The arrays may be attributes of larger objects (dictionaries, lists, tuples, or custom classes).
matrix and masked_arrays are examples of subclassing ndarray. I have not seen many user defined subclasses; in part because the amount of work to make them fully functional isn't worth it. recarray is a subclass that allows you to access fields of a structured array with attribute syntax. It may be worth looking at its 'getattr` method. Getting general array operations to return the correct array class or subclass is a bit tricky.
np.lib.index_tricks defines a few classes that let you use indexing syntax inplace of function syntax (ie. they define custom __getitem__ methods).
I am not aware of ways to subclass dtype. The most general base dtype is 'object'. That just stores a pointer to a Python object that is stored elsewhere. That pointer can point to anything - a number, None, a list, another array, etc. In structured arrays, dtype is a compound type, consisting of 'list' of sub-dtypes (which may be nested). But ultimately the structured dtype consists of multiple basic dtypes (ints, floats, strings, object).

Structured grid with irregular shape in PETSc (DM context)

I have a finite diference problem in structured grid in PETSc, and DM context helps me to create the matrix really easy, DM give me a whole matrix of rectangular domain that is good to me because I'm using this reference system, but I have an irregular shape in my problem, it means that I'm not using a lot of entries in this matrix. How can I do to don't allocate this space in the matrix assembling and tell KSP context not to use this entries to solve the problem?
My code is something like this:
DMDACreate2d()
DMCreateMatrix()
DMDAGetCorners()
! loop along the local matrix
DO i,1,width_y
DO i,1,width_y
IF (IsInsideProblemDomian) THEN
SetMatStencil()
MatSetValuesStencil()
END IF
END DO
END DO
MatAssemblyBegin()
MatAssemblyBegin()

unsure of the best data type to use

I am creating a Sudoku project in vb.net, to such an end I need to store a list of all the possibilities for each square where the squares are indexed by one number. for example the computer needs to know that for square [8] the numbers {1,3,5,9} are possible etc... I began by using a jagged array however there is no apparent 'remove' method which needs to be called a lot. this makes my code looks ugly with all the redim statements in it and so I was curious as to whether a list or arraylist would be best suited to my purposes? I have discovered arraylists have a remove method but I have also read that array lists are all but deprecated and i want to know if there is a nicer solution to this.

Sort ArrayBuffer[A] in scala?

I have an array in Scala with the class ArrayBuffer[Actor], where Actor is a class that implements the Ordered[Actor] trait. How do I sort this array without coding it manually?
I know there is an object called Sorting, but it doesnt seem to work since ArrayBuffer doesn't implement/extend the right classes.
How do I sort ArrayBuffer[A] type arrays?
If you are using Scala 2.8, you could use the sortWith method of the ArrayBuffer[T] class, which is inherited from the SeqLike trait.
The following code snippet sorts an ArrayBuffer[T] object in ascending order:
def ascendingSort[T <% Ordered[T]](xs: ArrayBuffer[T]) = xs.sortWith(_ < _)
Note that this does not mutate the actual ArrayBuffer, but creates a new one with the elements in the right order.
If you are using Scala 2.7, you could use the stableSort method of the Sorting object. This takes the elements of the ArrayBuffer and produces an array of elements sorted in the right order (given by a closure as an argument, ascending as a default).
For example:
val a = new scala.collection.mutable.ArrayBuffer[Int]()
a += 5
a += 2
a += 3
scala.util.Sorting.stableSort(a)
The important question is what do you want to do with the ArrayBuffer. Usually, a Buffer is used internally in different algorithms in order to increase the performance of intermediate results. If you are using it for that, have a look at the ways of sorting the collection you want to return at the end of your algorithm. The Sorting object already provides a way of transforming an ArrayBuffer into a sorted Array.
From the scaladoc of the Buffer class:
Buffers are used to create sequences of elements incrementally
As you are using it with Actors, it might be used for some kind of actor queue - in which case, you might want to have a look at the Queue collection.
Hope it helps,
-- Flaviu Cipcigan
Btw, the Actor class here is my own class used for "Actors" in a world created using my new game engine for scala ("Awesome Game Engine for Scala ~ AGES"), so it has nothing to do with the concurrency actor class. Also, implementations of lists in scala are a jungle, everything is either deprecated or implemented in a lot of different ways...ArrayBuffer works for my need (my need being a variable size array for containing actors).
Hope this clarifies :)

Resources