Plotting – How to compare and visualize two time-dependent two-dimensional vector fields?

Suppose we have two 2D vector fields in $ (x, y) $, $ boldsymbol {f} $ Y $ boldsymbol {g} $, which are defined by two InterpolatingFunction the obtained from NDSolve. I wonder what is the efficient and reasonable method to "compare" and visualize to show which effect represented by the fields is "bigger" than the other in a certain region of $ (x, y) $ airplane?

For two scalars, the proportion of them can reveal their relative magnitude. But is it reasonable to compare the norm of the two vector fields with a relation of $ || boldsymbol {f} || / || boldsymbol {g} || $, which must be in contour $ (x, y) $ airplane? Another challenge is that the fields depend on time, since I also want to show the change of their relative magnitude with time.

Consider the following PDEs about $ u (x, y, t) $ Y $ v (x, y, t) $,

L = 4;
sol = NDSolve({D(u(t, x, y), t, t) == 
D(u(t, x, y), x, x) + D(u(t, x, y), y, y) + Sin(u(t, x, y)), 
u(t, -L, y) == u(t, L, y), u(t, x, -L) == u(t, x, L), 
u(0, x, y) == Exp(-(x^2 + y^2)), Derivative(1, 0, 0)(u)(0, x, y) == 0}, 
u, {t, 0, 4}, {x, -L, L}, {y, -L, L})

NDSolve({D(v(t,x,y),t,t)==D(v(t,x,y),x,x)+D(v(t,x,y),y,y)/2+(1-v(t,x,y)^2)(1+2v(t,x,y)),
v(0,x,y)==E^-(x^2+y^2),v(t,-L,y)==v(t,L,y),v(t,x,-L)==v(t,x,L),(v^(1,0,0))(0,x,y)==0},
v,{t, 0, 4}, {x, -L, L}, {y, -L, L})

and these two vector fields

f = u(t, x, y)*Grad(v(t, x, y), {x, y}) + Grad(u(t, x, y), {x, y})

g = Grad(u(t, x, y), {x, y})*u(t, x, y)

Thanks in advance.

c ++ – Assign user to define vector size

Hello, I am solving an ex. C ++ basics where you ask to make a function that receives a vector of real numbers as a parameter and reads real numbers from the keyboard, save them in the vector and calculate their average.
the function should return the average.

Anyway, my problem is how to get user to assign vector size, WITHOUT using dynamic memory.

#include 

using namespace std;

float VetorCalculaMedia(int n, float vet())
{

    float soma = 0;
    for( int i=0; i> vet(i);
    }
    for (int i=0; i> n;
    float vet(n);
    **cout << "The media is: " << VetorCalculaMedia(n, vet(n)) << endl;**
    return 0;
}

in bold the error is & # 39; Cannot convert float to float * & # 39;

continuity: can linear maps be continuous / differentiable in non-complete vector spaces?

Leave $ E, F $ be normative vector spaces, and leave $ mathcal {L} (E, F) $ be the set of linear maps of $ E $ to $ F $.

All the definitions of continuous (and differentiable) linear maps I've seen require that $ E $ Y $ F $ be Banach spaces (i.e. full normative vector spaces).

Why is this necessary? Yes $ E $ or $ F $ it's not banach, aren't there linear maps of $ E $ to $ F $ what are continuous / differentiable?

c ++ – Number of occurrences of the subsequence [1,2,3] in a vector (version 2)

I am trying to implement this exercise but I have no idea how to start; Could someone suggest me some way?

PRE: Receive a vector of integers (formed only by the numbers 1, 2 and 3) and its length

POS: Returns the number of occurrences of the subsequence (1,2,3) (consecutive elements in the sequence) in that vector.
     Sequences such as 1,2,2,3 or 1,1,2,2,2,2,3,1,2,2,3, etc. must be taken into account, where several numbers 1 can appear together, several 2 and various 3.

Example 1
Input: (1,2,3,1,2,2,3)
Output: 2

Example 2
Input (1,2,2,2,2,2,3,1,2,3)
Output: 2
* /

int ocurrencias123Repetidos(int* vector, int largo) {
int contUno = 0;
int contDos = 0;
for (int i = 0; i < largo; i++)
{
    if (vector(i) == 1 && vector(i) < vector(i + 1) && vector(i + 1) != 3 && contUno == 0) {
        contUno++;
    }
    if (vector(i) == 2 && vector(i) < vector(i + 1) && contUno == 1) {
        contUno++;
    }
    else if (vector(i + 1) == 1) {
        contUno = 0;
    }
    if (contUno == 2) {
        contDos++;
        contUno = 0;
    }
}
return contDos;

}

Is there any property of the vector that is invariable under the absolute value of its elements?

If I take an absolute value of all the elements of a vector, what properties would be invariable? Will it be a completely different vector since we can't go back to the original map?

c ++: implementation of backpack algorithm 0/1 with possibility vector

The following code uses a dynamic approach to solve backpack problem 0/1. (Be the maximum profit The function I have used is not as good as the one I have defined here and I am still working on that 😅. Is there any possible optimization for the following code?

#include "algorithms.h"

struct Item {
    int index = 1;
    int profit = 1;
    int weight = 1;
    Item() = delete;
    explicit Item(int i, int _profit, int w) {
        index = i;
        profit = _profit;
        weight = w;
    }
    bool operator<(const Item& item) {
        return this->profit < item.profit;
    }
    bool operator<=(const Item& item) {
        return this->profit <= item.profit;
    }
    bool operator>(const Item& item) {
        return this->profit > item.profit;
    }
    bool operator>=(const Item& item) {
        return this->profit >= item.profit;
    }
    friend std::ostream& operator<<(std::ostream& out, const Item item) {
        out << item.index;
        return out;
    }
};

long weight(const std::vector& item_list, const std::vector& item_switch) {
    long sum = 0;
    for (int i = 0; i < item_switch.size(); i++) {
        sum += item_switch(i) * item_list(i).weight;
    }
    return sum;
}

long profit(const std::vector& item_list, const std::vector& item_switch) {
    long sum = 0;
    for (int i = 0; i < item_switch.size(); i++) {
        sum += item_switch(i) * item_list(i).profit;
    }
    return sum;
}

void increment(std::vector& vec) {
    auto it_bit = vec.end();
    it_bit--;
    while (*it_bit == 1) {
        *it_bit = 0;
        if (it_bit == vec.begin()) {
            return;
        }
        it_bit--;
    }
    *it_bit = 1;
}

int main() {
    long M = 25;
    Item i1(1, 10, 9);
    Item i2(2, 12, 8);
    Item i3(3, 14, 12);
    Item i4(4, 16, 14);
    std::vector items = { i1,i2,i3,i4 };
    std::vector enable(4,0);
    std::vector> possible;
    for (int i = 1; i <= 16; i++) {
        if (weight(items, enable) <= M) {
            possible.push_back(enable);
        }
        increment(enable);
    }
    long pr = 0;
    for (int i = 0; i < possible.size(); i++) {
        long temp = profit(items, possible(i));
        if (temp > pr) {
            pr = temp;
        }
    }
    std::cout << pr;
    return 0;
}

PS I didn't implement the good suggestion here regarding object creation since during task submission I am supposed to make objects at runtime.

Fit a list or vector model to the data

I have a dataset in the following form:

{
    {y11,y12,y13},
    {y21,y22,y23},
    ... etc ...
{

and I also have a function of the form:

f(t_,a_,b_,c_) := {
    (y1(a,b,c) /. soln)(t),
    (y2(a,b,c) /. soln)(t),
    (y3(a,b,c) /. soln)(t)
};

which returns a list like {y1,y2,y3} and take parameters a, bY c and a variable t. soln is the solution of a ParametricNDSolve.

I would like to fit this function to my data. NonlinearModelFit obviously doesn't work.

Finding if the convex cone of a vector list is null

Given a list of vectors, I want to find out if there is such a vector that its dot product with those in the list is all (semi) positive, or at least above a certain small negative value.

I will create your image in an amazing cartoon portrait for $ 10

Hello !

I will draw an awesome portrait caricature from your photo.

Because I:

It is very easy to work with him. I'm creative. I finish it on time. After the third order, you will become a volunteer for the same customer satisfaction. It is my priority.

by: Nazim12498
Created: –
Category: Art and Design
Views: 79


.