## c++ – Sizeof(SIMD vector) issue in macros

I want to define several macros to calculate the size of a type. The following is an example running normally.

#include <stdio.h>

#define A sizeof(long long) / sizeof(int)
#define B 36 / A

int main(){
printf("%zu %zun", A, B); // print out: 2 1
}


While it becomes strange when using SIMD vectors, for example (the definition of A)

#include <x86intrin.h>
#include <stdio.h>

#define A sizeof(__m128i) / sizeof(int)
#define B 36 / A

int main(){
printf("%zu %zun", A, B); // print out 4 0
}


What’s the issue?

## Passing vectors into a Fortran function and getting out a vector

I am writing a Fortran function that needs to receive two vectors of reals, and as an output, returns a vector. The function could be for example the sum of the two vectors:

function sumtwovectors( n, v1, v2 )

implicit none
real(kind=8), dimension(100000)             :: sumtwovectors
integer, intent(in)                         :: n
real(kind=8), dimension(100000), intent(in) :: v1, v2

integer :: i

if (n .gt. 100000) then
sumtwovectors(:) = -99
return
endif

do i = 1, n
sumtwovectors(i) = v1(i) + v2(i)
enddo

return

end function sumtwovectors


which is then compiled without error into a dll with

gfortran -c sumtwovectors.f90 -o sumtwovectors.o
gfortran -shared -mrtd -o test.dll sumtwovectors.o


This dll should be NET-compatible, so I load it into Mathematica ( path contains the path where the dll is stored):

InstallNET();
sumtwovectors = DefineDLLFunction("sumtovectors_", path, "double()", {"short*", "double()", "double()"})


but when I run this, I have an error:

sumtwovectors(3, {1, 3, 2}, {3, 4, 5})

NET::netexcptn: A .NET exception occurred: System.Runtime.InteropServices.MarshalDirectiveException: Impossible de marshaler 'return value' : Combinaison de types managés/non managés non valide.
à Wolfram.NETLink.DynamicDLLNamespace.DLLWrapper1.sumtovectors_(Int16& , Double() , Double() ).

1. How can I make this work in Mathematica? I tried enclosing the two list into MakeNETObject() but to no avail.
2. Instead of having a maximum size (1000000), could it work with no defined maximum size?

## network – Can IP header TTL values be exploited as an attack vector? If so, what can protect against that?

Could this header be exploited and set to a really high value thus

No; each device in the path decrements the TTL, but decrementing a big number is no more expensive than decrementing a large number. Knowing most packets rarely exceed their TTL, increasing the TTL won’t cause the packet to traverse the network any longer than it would otherwise.

The one aggressive use the TTL can be put to is firewalking. By sending packets with carefully crafted TTLs to a destination behind the firewall, you can map out what the firewall and devices behind it are permitting.

## rotation – UE4 – Event Tick and getting Forward Vector

I’m trying to make a game where my character rotates towards cursor (that works). He can choose between a few weapons (also works). One of the weapons works like a machine gun. My idea was to make a simple solution with:

Event tick -> gate (opened by pulling LBM and closed by releasing it) -> gate (closed after firing and opened after some delay) -> spawning projectile which leads to a sequence that closes / opens the second gate.

It doesn’t work perfectly. The projectile spawns with the right scale and location, but the rotation is always pointing straight forward.

If the exactly same blueprint is attached to anything else (straight up to the LMB pull or a timer), it works perfectly. However, doing the LMB pull defeats the whole purpose, as it’s not a machine gun any more, and timer… is less then perfect I believe. I liked my solution using gates but it just doesn’t want to work.

For example, this bit works with no problem (even though the spawning and rotation code is literally copy pasted):

Does anyone have an idea on how to fix this?

## linear algebra – Existence of invariant vector

I was reading the following paper, there is an statement in a proof that I’m trying to figure out. I am refering to the justification of (3.5) in page 11. The problem is the following, given a matrix $$S$$, with zero diagonal entries, there always exist a vector $$q$$ such that:
$$sum_{k}q(k)S(k,j)=q(j)sum_{k}S(j,k)$$
Why such vector always exist?

## Varieties satisfying the extension of vector bundles property

We know if we have a regular variety $$X$$ with $$U$$ an open sub-scheme such that $$codim(Xsetminus U)geq 2$$, then any reflexive sheaf has a unique extension from $$U$$ to $$X$$. My question is when a vector bundle on $$U$$ extends to a vector bundle on $$X$$? More precisely I have two types of questions:

1. What type of restrictions, the assumption that $$X$$ is variety such that every vector bundle on all $$U$$‘s ($$codim(Xsetminus U)geq 2$$) extends to a vector bundle on $$X$$, imposes on $$X$$. (What are all these $$X$$‘s).

2. What type of restrictions, the assumption that $$X$$ is variety such that every vector bundle on some $$U$$ ($$codim(Xsetminus U)geq 2$$) extends to a vector bundle on $$X$$, imposes on $$X$$ and $$Xsetminus U$$?

## c++ – ¿Cómo anotar un punto de tenis con dos o más países en vector?

include <iostream>

include <vector>

using namespace std;

class tenista

{
private:

string nombre;

vector<string> equipos;
vector<string> paises;
vector<int> puntos;

public:
tenista(string nombre)
{
this->nombre = nombre;
}
string getNombre()

{
return nombre;
}
void anotarpunto(string nombreEquipo, string nombrePais)
int posicion = -1;
for (int i = 0; i < 3; i++)
{

{

}return


No puedo hacer bien el agregar punto, ¿qué podría agregar?, lo he tratado de hacer con un for pero no me
resulta, en equipos puede ser igual o más equipos, debo hacer retornar puntos pero tengo que tener hecho eso primero según yo

## An inequality about unit vector orthogonal to $(1,1,…,1)$

Does there exist a constant $$alpha>0$$ such that the following holds?
$$liminf_{ntoinfty}inf_{xinmathbb{R}^n, sum_{i=1}^nx_i^2=1, sum_{i=1}^nx_i=0}frac{sum_{i
This is related to the Laplacian of a special graph with adjacency matrix $$A_{ij}=1$$ when $$|i-j|leq n/4$$ and 0 otherwise. This conjecture essentially says that the second smallest eigenvalue of the unnormalized Laplacian will grow linearly in $$n$$. This is definitely true if the graph is fully connected.

## linear algebra – Vector differentiation of Mean Squared Error

I have a set of notes where it states the following,

S = $$(mathbf{y}- mathbf{X} boldsymbol{theta})^{text{T}}(mathbf{y}- mathbf{X} boldsymbol{theta})$$

$$frac{partial S}{partial boldsymbol{theta}} = -2mathbf{X}^{text{T}}(mathbf{y}-mathbf{X}boldsymbol{theta})$$

(Assume $$mathbf{X}$$ is a matrix, $$mathbf{y}$$ and $$boldsymbol{theta}$$ are vectors all of suitable dimensions). So essentially, S is the squared error, $$mathbf{X}$$ is the design matrix and $$mathbf{y}$$ is a vector of observations and I need to find the $$theta$$ that minimises S, but I’m having trouble with differentiation. My working is as follows,

$$(mathbf{y}- mathbf{X} boldsymbol{theta})^{text{T}}(mathbf{y}- mathbf{X} boldsymbol{theta})= (mathbf{y}^{text{T}} – boldsymbol{theta}^{text{T}}mathbf{X}^{text{T}})(mathbf{y}-mathbf{X}boldsymbol{theta}) = mathbf{y}^{text{T}}mathbf{y} -mathbf{y}^{text{T}} mathbf{X} boldsymbol{theta}- boldsymbol{theta}^{text{T}}mathbf{X}^{text{T}} mathbf{y} +boldsymbol{theta}^{text{T}}mathbf{X}^{text{T}} mathbf{X}boldsymbol{theta} \ text{Diff. w.r.t.} boldsymbol{theta} text{ yields}; \ frac{partial {S}}{partial boldsymbol{theta}} = – mathbf{y}^{text{T}} mathbf{X} – mathbf{X}^{text{T}} mathbf{y} +2mathbf{X}^{text{T}} mathbf{X}boldsymbol{theta}$$

## equation solving – How to work with a function in vector form

Thanks for contributing an answer to Mathematica Stack Exchange!