Call to MKL_SDNSCSR of intell MKL failing - fortran

I just dowloaded MKL in intend to try its sparse BLAS, the first thing I tried was the conversion of full matrix to sparse one with MKL_SDNSCSR
Here my code:
implicit none
real::A(2,5)
integer::job(8)
INTEGER:: info,n=2,m=5
INTEGER ja(10), ia(6)
REAL acsr(10)
A(1,:)=(/1, 0 ,1,0,2/)
A(2,:)=(/2,0,0,0,1/)
job=0
job(1)=0
job(2)=1
job(3)=1
job(4)=2
job(5)=10
job(6)=1
print*,A
print*,job
call mkl_sdnscsr(job,n,m,A,m,acsr,ja,ia,info)
end
It gives the following error:
Intel MKL ERROR: Parameter 1 was incorrect on entry to MKL_SDNSCSR.
What did I did wrong?
Best

I see no problems with this example. I tried the MKL v.2020 on win64.
here is the output I obtained:
1.000000 2.000000 0.0000000E+00 0.0000000E+00 1.000000
0.0000000E+00 0.0000000E+00 0.0000000E+00 2.000000 1.000000
0 1 1 2 10 1
0 0

Related

Two Dimensional Array Representing a Weight Matrix

I'm a bit stumped in how a 2d array(Matrix) such as this
0.0 1.8 9.1 4.0 3.5
1.8 0.0 8.1 5.2 8.6
9.1 8.1 0.0 2.9 8.1
4.0 5.2 2.9 0.0 2.0
3.5 8.6 8.1 2.0 0.0
is supposed to represent a graph. The values represent the weights but then what represents the nodes and edges. I'm trying to brute force find all possible tree's (Which I'm not asking for help on that, just trying to understand how this is supposed to represent this
If you have a (weighted, undirected) graph with 5 vertices---call them v1, v2, v3, v4, v5---the graph can be represented by your matrix.
v1 v2 v3 v4 v5
v1 0.0 1.8 9.1 4.0 3.5
v2 1.8 0.0 8.1 5.2 8.6
v3 9.1 8.1 0.0 2.9 8.1
v4 4.0 5.2 2.9 0.0 2.0
v5 3.5 8.6 8.1 2.0 0.0
The number in, say, (v2, v4), represents an edge connecting v2 and v4 with a weight of 5.2. The zero entry could represent non-edges, or edges with zero weight. Non-weighted graphs are usually represented with a boolean value in each entry, 1 representing an edge, 0 representing no edge. The graph is (well, can be) undirected if the matrix is symmetric.
NB: the picture in your question cannot be represented by the given matrix: the matrix represents a graph with 5 vertices, and the graph represented by the picture has 8 vertices.
A 2D array (=matrix) is a common way to represent a graph. It is also called Adjacency Matrix.
In graph theory, an adjacency matrix is a square
matrix used to represent a finite graph. The elements of the matrix
indicate whether pairs of vertices are adjacent or not in the graph.
A matrix M that is NxN represents a graph with N vertices (nodes).
When M[i][j] = 0 there is no edge between vertices i and j.
When M[i][j] = 1 there exist an edge between vertices i and j.
Sometimes it is easy to have a different number than 1 to represent the weight of this specific edge (same as in your case).

It is some kind of OpenGL in TCL, but what language is this?

This is TCL and OpenGL, but I don't know which language it exactly is, and so cannot find the documentation for it. In particular, I need to understand all the attributes on the OGL line.
global Qu
gl matrixmode projection
gl pushmatrix
gl loadidentity
gl ortho 0 50. 0 50. -1. 1.
gl matrixmode modelview
gl pushmatrix
gl loadidentity
gl color 1 1 1 1
if {$Qu(Speed) >= 30 } {
OGL drawtex sans-bold "Speed 3" -center -pos 25 47 0 -dir 2 0 0 -up 0 2 0
OGL drawtex sans "[format %#.3g $Qu(Speed)]" -center -pos 25 44 0 -dir 3 0 0 -up 0 3 0
}
The function of this code is to display the speed as two lines of text on screen, when speed>=30.
Well the first lines from gl matrixmode projection to gl color 1 1 1 1 are pretty easy OpenGL functions ( deprecated OpenGL actually ). The other line seems self explaining, however you can try to change them slightly to see what effects each parameter has.
I think its as follow ( Only a guess ):
OGL drawtext: Command for drawing a text
sans-bold: Font family or file name.
"Speed 3": Simple text
"[format %#.3g $Qu(Speed)]": Formatted text which inserts the speed into the string.
-center: Text is centered around it's position.
-pos, -dir and -up: Position, direction and up vector

OpenGL - drawing indices from OBJ using GL_TRIANGLE_STRIP

I was trying to create an OBJ parser which will read OBJ files and render it using GL_TRIANGLE_STRIP. I know OBJ files behaves as TRIANGLES that's why as I read the faces, I rearrange them into STRIPS.
Example I have faces like this
f 5 1 4
f 5 4 8
f 3 7 8
it will be in this order after I rearrange them minus 1 because OBJ files are 1 based indexes.
f 4 0 3
f 3 0 4
f 0 4 3
f 3 4 7
f 4 7 2
f 2 7 6
f 7 6 7
I send this indices to OpenGL and draw them using glDrawElements but the output I get is wrong. Take a look here for the image.
I based the arrangement on the OpenGL documentation on using GL_TRIANGLE_STRIP and I'm stuck on this step as using GL_TRIANGLES works for me. What would cause the incorrect output?
The .obj file contains indexes suitable for rendering in GL_TRIANGLES mode. You render them in GL_TRIANGLES_STRIP mode. You are completely wrong here. Render them in GL_TRIANGLES mode and be happy.
Rendering the same index data in other mode is almost always incorrect. GL_TRIANGLES mode uses three indices per triangle, while GL_TRIANGLE_STRIP uses one index per triangle on average (it is compressed format). So unless you have compressed your index data in approximately three times, you cannot use your indices to draw as GL_TRIANGLE_STRIP.
See wikipedia article for details. Below you can see result of rendering indices {0, 1, 2, 3, 4, 5, 6} in GL_TRIANGLE_STRIP. Obviously, if you render them in GL_TRIANGLES mode, you'll see only 2 triangles instead of 5.

opengl and mtl parameters

I am trying to parse line items from "mtl" file and use the values as parameters to opengl functions.
I could use values of ambience (Ka), specular(Ks) and diffuse(Kd) using glMaterialfv. But I don't know the use for Ni (optical density), d (dissolve), illum (illumination) values given in the mtl file.
Which opengl function should be used with these values?
Any help with these line items?
....
Ni 1.000000
d 1.000000
illum 2
...
Dissolve means transparency. 1.0 means fully opaque object, 0.0 means fully transparent. You can control rendering of transparent objects by using functions like glBlendFunc().
For a full definition of mtl files, including illum, please see http://people.sc.fsu.edu/~jburkardt/data/mtl/mtl.html.
Ni seems to be unsupported and can be ignored.

Simple wireframe format?

I'm looking for a simple file format to use for wireframe models. I am aware of VRML, u3D, etc, but these seem heavyweight for my needs. My criterea are:
Must have a clear spec. Either open or very well established/documented.
I only need (want) simple models - vertices and edges. I don't want to handle faces or objects. If the format supports more, that's fine so long as I can ignore them.
End-user tools are not a requirement, but would be great. If not, it must be human readable (and editable for simple models).
It would be nice (but not necessary) to be able to annotate or at least label nodes.
It shouldn't matter what language I'm using, but probable options are Java/C++ & OpenGL
Or am I just better writing vertices/edge lists to a text file and be done with it?
Wavefront OBJ is a very simple text file format for storing 3d models and it's supported by all 3d modeling applications (eg. maya, 3dsmax, lightwave) so you can export and import your models very easily.
You can read more and the specs here:
http://www.fileformat.info/format/wavefrontobj/
I would recommend against making your own file format. The Wavefront OBJ is as simple as it gets and well specified.
Here's an example of a 2x2 plane. v is for vertex coordinates, f for description of faces (which vertices are connected):
v -0.500000 -0.000000 0.500000
v 0.000000 -0.000000 0.500000
v 0.500000 -0.000000 0.500000
v -0.500000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v -0.500000 0.000000 -0.500000
v 0.000000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
v -0.500000 -0.000000 0.500000
v 0.000000 -0.000000 0.500000
v 0.500000 -0.000000 0.500000
v -0.500000 0.000000 0.000000
v 0.000000 0.000000 0.000000
v 0.500000 0.000000 0.000000
v -0.500000 0.000000 -0.500000
v 0.000000 0.000000 -0.500000
v 0.500000 0.000000 -0.500000
f 1/1 2/2 5/5 4/4
f 2/2 3/3 6/6 5/5
f 4/4 5/5 8/8 7/7
f 5/5 6/6 9/9 8/8
f 10/10 11/11 14/14 13/13
f 11/11 12/12 15/15 14/14
f 13/13 14/14 17/17 16/16
f 14/14 15/15 18/18 17/17
I don't know of any formats that actively target wireframe views. (Edge/vertex only) You'll almost always have to deal with faces at the very least. The fortunate part there is that unless you have a very specific need for nothing but an edge list wireframe rendering can be done with just about any API from a face list.
As for the format, OBJ is good and simple, if a little outdated. It's also likely the easiest format to find documentation for. Microsoft's X files are great for quick and dirty rendering, but I've always been somewhat partial to the Quake formats. They tend to be very game-oriented, though, and as such include a lot of info you probably don't want.
If none of those meet your needs, maybe look into COLLADA. It probably won't work for you by itself, but you could write a quick exporter into your own format that only contains edge/vertex info, and at that point you essentially have support for every modeling package on the planet :)
Might just be easier to do those lists in a text file. That's the first thing that came to mind for me!
POV-Ray's RAW triangle format is what I consider to be the simplest. You really can't get any simpler in my opinion. I implemented a load for this in a matter of minutes - it is a really really simple format.
OBJ is the most widespread and simplest, but it breaks down if you need more than vertex position, normal, and a single texture coordinate. It's not extensible at all. It's also text based so it has trouble with large meshes.
GTO has been emerging as a new interchange format. It's simple, fast, and extensible, and there is a production-proven open source code to read and write them:
Gto File Format
This has been used in production in several VFX and game studios, and yet it's about the same amount of work to write a loader as an OBJ file (and one of the samples is an OBJ to GTO converter).
Check it out, and help stop the spread of the Collada bloat-virus.