functions – why this simple code is not giving the right answer under Compile

I have two sets of inputs that are to be fed to a simple function. The inputs are essentially a set of triangles and the normal for each triangle. The function will compute the gradient about the points (shown in blue). The notebook can be downloaded from the following Dropbox Link

https://www.dropbox.com/s/yas32nfccd2dzj4/debug%20code.nb?dl=0

enter image description here

The two sets of triangles are supposed to be similar (only separated by a translation in space). I compute the area gradient about point pt1

 grad1 = Block({ptTri, normal, cross, target, facept, 
 openS = {0., 0., 0.}, closedS = {0., 0., 0.}, source = pt1},
 Do(
 ptTri = opentr1((i));
 normal = normOpentr1((i));
 cross = If(ptTri((1)) == source,
 {target, facept} = {ptTri((2)), ptTri((-1))};
 Cross(normal, facept - target),
 {target, facept} = {ptTri((1)), ptTri((-1))};
 Cross(normal, target - facept)
 );
 openS += (0.5*cross), {i, 1, Length@normOpentr1});

Do(
ptTri = closedtri1((j));
normal = normClosedtr1((j));
cross = If(ptTri((1)) == source,
{target, facept} = {ptTri((2)), ptTri((-1))};
Cross(normal, facept - target),
{target, facept} = {ptTri((1)), ptTri((-1))};
Cross(normal, target - facept)
);
closedS += (0.5*cross), {j, 1, Length@normClosedtr1});
0.7*closedS + 1*openS
)

(*{0.110728, 0.0466838, 0.752509}*)

Likewise if I compute the area gradient about the second point pt2 I get the same answer.

grad2 = Block({ptTri, normal, cross, target, facept, 
openS = {0., 0., 0.}, closedS = {0., 0., 0.}, source = pt2},
Do(
ptTri = opentr2((i));
normal = normOpentr2((i));
cross = If(ptTri((1)) == source,
 {target, facept} = {ptTri((2)), ptTri((-1))};
 Cross(normal, facept - target),
 {target, facept} = {ptTri((1)), ptTri((-1))};
 Cross(normal, target - facept)
 );
openS += (0.5*cross);, {i, 1, Length@normOpentr2});
Do(
ptTri = closedtr2((j));
normal = normClosedtr2((j));
cross = If(ptTri((1)) == source,
{target, facept} = {ptTri((2)), ptTri((-1))};
Cross(normal, facept - target),
{target, facept} = {ptTri((1)), ptTri((-1))};
Cross(normal, target - facept)
);
closedS += (0.5*cross),{j, 1, Length@normClosedtr2});
0.7*closedS + 1*openS
)

(*{0.110728, 0.0466838, 0.752509}*)

The two answers are quite similar as the difference between grad1 and grad2 is {1.83187*10^-15, -5.55112*10^-16,4.44089*10^-16}

HOWEVER

the same code when under Compile does not give the same answers for the two datasets.

With({epcc = 0.7, epco = 1.},
surfaceGradFn2 = 
Compile({{point, _Real, 1}, {opentr, _Real, 3}, {normalO, _Real,2}, {closedtr, _Real, 3}, {normalC, 
_Real, 2}},
Block({ptTri, source = point, normal, target, facept, cross, 
 openS = {0., 0., 0.}, closedS = {0., 0., 0.}, nO = normalO, 
 nC = normalC, OT = opentr, CT = closedtr},
Do(
 ptTri = OT((i));
 normal = nO((i));
 cross = If(ptTri((1)) == source,
   {target, facept} = {ptTri((2)), ptTri((-1))};
   Cross(normal, facept - target),
   {target, facept} = {ptTri((1)), ptTri((-1))};
   Cross(normal, target - facept)
   );
 openS += (0.5*cross);
 , {i, 1, Length@nO});
Do(
 ptTri = CT((j));
 normal = nC((j));
 cross = If(ptTri((1)) == source,
   {target, facept} = {ptTri((2)), ptTri((-1))};
   Cross(normal, facept - target),
   {target, facept} = {ptTri((1)), ptTri((-1))};
   Cross(normal, target - facept)
   );
 closedS += (0.5*cross);
 , {j, 1, Length@nC});

epcc*closedS + epco*openS
), CompilationTarget -> "C")
);

Though the structure of the code is the same I guess, the outputs are completely different.

 surfaceGradFn2(pt1, opentr1, normOpentr1, closedtri1, normClosedtr1)
 (*{-0.0157582, 0.386426, 0.582118} -> this answer is now different but I gave the same inputs as before *)

 surfaceGradFn2(pt2, opentr2, normOpentr2, closedtr2, normClosedtr2)
 (* {0.110728, 0.0466838, 0.752509} -> answer is same as before with the same inputs *)

What am I doing wrong here? Why does not the compiled code work while the non-compiled version works? I wish to have the compiled version of the code working.

also, please ignore what the code intends to do. If you may, kindly look at why the compiled output is different.Thanks and grateful for your help.

14000 MAC are being giving away! Come and Join the BIKI Bounty Campaign! The lasted Bounty paid have proof | Proxies123.com

Earnings Disclaimer:  All the posts published herein are merely based on individual views, and they do not expressly or by implications represent those of Proxies123.com or its owner. It is hereby made clear that Proxies123.com does not endorse, support, adopt or vouch any views, programs and/or business opportunities posted herein. Proxies123.com also does not give and/or offer any investment advice to any members and/or it’s readers. All members and readers are advised to independently consult their own consultants, lawyers and/or families before making any investment and/or business decisions. This forum is merely a place for general discussions. It is hereby agreed by all members and/or readers that Proxies123.com is in no way responsible and/or liable for any damages and/or losses suffered by anyone of you.

Giving Money Back to customers with Paypal(India)

Advertising

y u no do it?

Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

Starts at just $1 per CPM or $0.10 per CPC.

Real Commissions by giving away Funnels/Site Builders/ eCarts

www.GetGroovePagesFree.com
I have never made aff commissions as easy as this – by literally giving away what most of us use already. Unlimited commissions on two levels – your direct referral 40% and 10% on their referrals!!!
I’m literally just letting people that I know who use Kajabi / ClickFunnels etc about it and they are switching!

For the first time in a long time – I’m Stoked!


Check out my signature below – sign up for free – then log in and get your AFF code and you are set – I would recommend watching the video on pay breakdown though.

This is not a shady Aff program – it has legitimate long term players running a real brick and mortar behind this!!

The No.1 New Page and Funnel Building Platform is now Also Included Free!
NO CREDIT CARD EVER! NO FEES EVER. IT’S JUST FREE!

Everything you need to sell products and services online

There is simply no platform that can match our features, speed, ease of use, and of course–value. Try it once and you’ll be hooked.
SEMrush

  • Unlimited Products and Funnels
  • Flexible Pricing Structures
  • Powerful checkout options
  • The most powerful Affiliate software on earth.
  • Dynamic thank you pages
  • Upsells, Downsells, and Order Bumps
  • 1-Click Upsell
  • Robust Integrations
  • Use your own PayPal, Stipe, Authnet, NMI, or BrainTree
  • No Monthly Fees
  • ZERO transactions fees
  • It’s Just Free!

FREE Unlimited Product Funnels!
There’s no credit card needed. Ever!

  • Free Account For Life
  • Full Access to GrooveSell
  • GrooveSell has no upsells
  • The most powerful Affiliate Software. Period.

Secure Order
It’s safe. We used the best encryption known to man.

Guarantee
Even if it’s FREE we still guarantee it’s the best platform you’ll every use

www.GetGroovePagesFree.com

 

plotting – Why code is running and not giving any output for NSolve?

I am trying to solve the given equation in the code and want to plot ‘N1’ with ‘P1’. But the code is not giving me any output and still showing running. What is the problem with it?
If anyone can figure it out will be appreciated.

dela = -1.5;(*Subscript((CapitalDelta), L) ; Laser-Lower polariton 
detuning*)
g1 = 0.0003; (* Subscript(g, 0) ; vacuum optomechanical strength *)
del0 = -0.006; (* (Delta) ;  exciton-photon detuning*)
ome = 3.014; (* (CapitalOmega) ; Rabi splitting *)
omem = 0.125; (* Subscript((CapitalOmega), m) ; mechanical 
resonator's frequency *)
kexc = 0.002;  (* Subscript((Kappa), exc  ;  )exciton decay rate*)
kk = .2;   (* (Kappa); cavity decay rate *)
gma = 0.00001;  (* (CapitalGamma) ; phonon dcay rate *)
nth = 0;
kal = (kk + kexc)/2 - del0*(kk - kexc)/(2*ome);
g0 = g1*(1 - del0/ome)/2;
kb = 0.1;
sol = NSolve({-I*(P1/Sqrt(2)*(1 - del0/(2*ome)))*(Conjugate(a1) - 
     a1) - I*(P1*g1/(2*Sqrt(2)*ome))*(alab - Conjugate(alab) + 
     Conjugate(betab) - betab) + kal*N1 + 
  kb*(alab*a1 + Conjugate(alab)*Conjugate(a1) + 
     betab*Conjugate(a1) + 
     Conjugate(betab)*
      a1 + (N1 - 2*(Abs(a1))^2)*(b1 + Conjugate(b1))) == 0, 
I*dela*alab + I*omem*alab - 
  I*g0*((2*N1 - Abs(a1)^2 - Np + 2*2*(Abs(b1))^2 + b1^2)*
      Conjugate(a1) - (Conjugate(betab) + 2*alab)*b1 - 
     alab*Conjugate(b1)) + I*(P1/Sqrt(2)*(1 - del0/(2*ome)))*b1 - 
  I*(P1*g1/(2*Sqrt(2)*ome))*(N1 - Np + (Conjugate(a1))^2 - 
     b1^2) + (kal + gma)*alab/2 + 
  kb/2*(Conjugate(betab)*b1 + 
     alab*Conjugate(b1) + (Np - 2*(Abs(b1))^2)*Conjugate(a1) + 
     2*alab*b1 - b1^2*Conjugate(a1)) == 
 0, -I*g0*((N1 - 2*(Abs(a1))^2)*(Conjugate(b1) - b1) + 
     Conjugate(alab)*Conjugate(a1) - alab*a1 + 
     Conjugate(betab)*a1 - betab*Conjugate(a1)) - 
  I*(P1*g1/(2*Sqrt(2)*ome))*(Conjugate(betab) - alab + 
     Conjugate(alab) - betab) + gma*Np - gma*nth == 0,
-I*dela*betab + I*omem*betab - 
  I*g0*((2*N1 - (Abs(a1))^2 + Np - 2*(Abs(b1))^2)*
      a1 - (2*betab - a1*b1 + Conjugate(alab))*b1 + 
     betab*Conjugate(b1)) - I*(P1/Sqrt(2)*(1 - del0/(2*ome)))*b1 -
   I*(P1*g1/(2*Sqrt(2)*ome))*(N1 + Np + a1^2 + b1^2 + 1) + (kal + 
     gma)*betab/2 + 
  kb/2*((2*betab - a1*b1 + Conjugate(alab))*
      b1 + (Np - 2*(Abs(b1))^2)*a1 + betab*Conjugate(b1)) == 0,
-I*dela*a1 - I*g0*(Conjugate(alab) + betab) - 
  I*(P1/Sqrt(2)*(1 - del0/(2*ome))) - 
  I*(P1*g1/(2*Sqrt(2)*ome))*(b1 + Conjugate(b1)) + kal*a1/2 + 
  kb*(Conjugate(alab) + betab)/2 == 0,
I*omem*b1 - I*g0*N1 - 
  I*(P1*g1/(2*Sqrt(2)*ome))*(a1 + Conjugate(a1)) + gma*b1/2 == 
 0}, {N1, alab, Np, betab, a1, b1});
 Plot({Evaluate(N1) /. sol}, {P1, 0, 20})

Native English writer here, giving away 5 free 500 word articles for review

Hello, I am an experienced copywriter and content writer who has been writing for many years. I provide the highest quality content you can find, and users in other digital marketing forums enjoy my services and speak highly of me.

As I am new to the forum, I will give away 5 free 500 word articles in exchange for a review to users who have more than 500 posts.

Health.

Sitemap on WordPress Yoast SEO with nginx web server giving 404 error

I installed yoast seo on a wordpress website that is on the nginx web server, but when i clicked the xml sitemap link it shows 404 not found error. Any suggestions to solve this?

android studio – Problems with Recycler View – 100% in AVD, giving CRASH when run in SMARTPHONE;

Guys, I'm new here, I have an application that I develop based on a course, the problem is that it has a recycler view that when I run the application on the AVD it works 100%, but when I run it on the smartphone it blocks the application, I am really looking for help, because I have tried everything possible;

ACTIVITY CODE CALLING THE RECYCLER

Public class RequisicoesActivity extends AppCompatActivity {

//Componentes
private RecyclerView recyclerRequisicoes;
private TextView textResultado;

private FirebaseAuth autenticacao;
private DatabaseReference firebaseRef;
private List listaRequisicoes = new ArrayList<>();
private RequisicoesAdapter adapter;
private Usuario motorista;

private LocationManager locationManager;
private LocationListener locationListener;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_requisicoes);

    inicializarComponentes();

    //Recuperar localizacao do usuário
    recuperarLocalizacaoUsuario();

}

@Override
protected void onStart() {
    super.onStart();
    verificaStatusRequisicao();
}

private void verificaStatusRequisicao(){

    Usuario usuarioLogado = UsuarioFirebase.getDadosUsuarioLogado();
    DatabaseReference firebaseRef = ConfiguracaoFirebase.getFirebaseDatabase();

    DatabaseReference requisicoes = firebaseRef.child("requisicoes");

    Query requisicoesPesquisa = requisicoes.orderByChild("motorista/id")
            .equalTo( usuarioLogado.getId() );

    requisicoesPesquisa.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for( DataSnapshot ds: dataSnapshot.getChildren() ){

                Requisicao requisicao = ds.getValue( Requisicao.class );

                if( requisicao.getStatus().equals(Requisicao.STATUS_A_CAMINHO)
                        || requisicao.getStatus().equals(Requisicao.STATUS_VIAGEM)
                        || requisicao.getStatus().equals(Requisicao.STATUS_FINALIZADA)){
                    motorista = requisicao.getMotorista();
                    abrirTelaCorrida(requisicao.getId(), motorista, true);
                }

            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

}

private void recuperarLocalizacaoUsuario() {

    locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

    locationListener = new LocationListener() {
        @Override
        public void onLocationChanged(Location location) {

            //recuperar latitude e longitude
            String latitude = String.valueOf(location.getLatitude());
            String longitude = String.valueOf(location.getLongitude());

            //Atualizar GeoFire
            UsuarioFirebase.atualizarDadosLocalizacao(
                    location.getLatitude(),
                    location.getLongitude()
            );

            if( !latitude.isEmpty() && !longitude.isEmpty() ){
                motorista.setLatitude(latitude);
                motorista.setLongitude(longitude);

                adicionaEventoCliqueRecyclerView();
                locationManager.removeUpdates(locationListener);
                adapter.notifyDataSetChanged();
            }

        }

        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {

        }

        @Override
        public void onProviderEnabled(String provider) {

        }

        @Override
        public void onProviderDisabled(String provider) {

        }
    };

    //Solicitar atualizações de localização
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED ) {
        locationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER,
                0,
                0,
                locationListener
        );
    }


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()){
        case R.id.menuSair :
            autenticacao.signOut();
            finish();
            break;
    }

    return super.onOptionsItemSelected(item);
}

private void abrirTelaCorrida(String idRequisicao, Usuario motorista, boolean requisicaoAtiva){
    Intent i = new Intent(RequisicoesActivity.this, CorridaActivity.class );
    i.putExtra("idRequisicao", idRequisicao );
    i.putExtra("motorista", motorista );
    i.putExtra("requisicaoAtiva", requisicaoAtiva );
    startActivity( i );
}

private void inicializarComponentes(){

    getSupportActionBar().setTitle("Requisições");

    //Configura componentes
    recyclerRequisicoes = findViewById(R.id.recyclerRequisicoes);
    textResultado = findViewById(R.id.textResultado);

    //Configurações iniciais
    motorista = UsuarioFirebase.getDadosUsuarioLogado();
    autenticacao = ConfiguracaoFirebase.getFirebaseAutenticacao();
    firebaseRef = ConfiguracaoFirebase.getFirebaseDatabase();

    //Configurar RecyclerView
    adapter = new RequisicoesAdapter(listaRequisicoes, getApplicationContext(), motorista );
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
    recyclerRequisicoes.setLayoutManager( layoutManager );
    recyclerRequisicoes.setHasFixedSize(true);
    recyclerRequisicoes.setAdapter( adapter );

    recuperarRequisicoes();

}

private void adicionaEventoCliqueRecyclerView(){

    //Adiciona evento de clique no recycler
    recyclerRequisicoes.addOnItemTouchListener(
            new RecyclerItemClickListener(
                    getApplicationContext(),
                    recyclerRequisicoes,
                    new RecyclerItemClickListener.OnItemClickListener() {
                        @Override
                        public void onItemClick(View view, int position) {
                            Requisicao requisicao = listaRequisicoes.get(position);
                            abrirTelaCorrida(requisicao.getId(), motorista, false);
                        }

                        @Override
                        public void onLongItemClick(View view, int position) {

                        }

                        @Override
                        public void onItemClick(AdapterView parent, View view, int position, long id) {

                        }
                    }
            )
    );

}

private void recuperarRequisicoes(){

    DatabaseReference requisicoes = firebaseRef.child("requisicoes");

    Query requisicaoPesquisa = requisicoes.orderByChild("status")
            .equalTo(Requisicao.STATUS_AGUARDANDO);

    requisicaoPesquisa.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            if( dataSnapshot.getChildrenCount() > 0 ){
                textResultado.setVisibility( View.GONE );
                recyclerRequisicoes.setVisibility( View.VISIBLE );
            }else {
                textResultado.setVisibility( View.VISIBLE );
                recyclerRequisicoes.setVisibility( View.GONE );
            }

            listaRequisicoes.clear();
            for ( DataSnapshot ds: dataSnapshot.getChildren() ){
                Requisicao requisicao = ds.getValue( Requisicao.class );
                listaRequisicoes.add( requisicao );
            }

            adapter.notifyDataSetChanged();

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

}

}

XML – RECYCLER

LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
android: layout_width = "match_parent"
android: layout_height = "wrap_content"
android: orientation = "vertical"
android: padding = "16dp">




ACTIVITY ADAPTER CODE

public class RequisicoesAdapter extends RecyclerView.Adapter {

private List requisicoes;
private Context context;
private Usuario motorista;

public RequisicoesAdapter(List requisicoes, Context context, Usuario motorista) {
    this.requisicoes = requisicoes;
    this.context = context;
    this.motorista = motorista;
}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View item = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_requisicoes, parent, false);
    return new MyViewHolder( item ) ;
}

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {

    Requisicao requisicao = requisicoes.get( position );
    Usuario passageiro = requisicao.getPassageiro();

    holder.nome.setText( passageiro.getNome() );

    if(motorista!= null){

        LatLng localPassageiro = new LatLng(
                Double.parseDouble(passageiro.getLatitude()),
                Double.parseDouble(passageiro.getLongitude())
        );

        LatLng localMotorista = new LatLng(
                Double.parseDouble(motorista.getLatitude()),
                Double.parseDouble(motorista.getLongitude())
        );
        float distancia = Local.calcularDistancia(localPassageiro, localMotorista);
        String distanciaFormatada = Local.formatarDistancia(distancia);
        holder.distancia.setText(distanciaFormatada + "- aproximadamente");

    }

}

@Override
public int getItemCount() {
    return requisicoes.size();
}

public class MyViewHolder extends RecyclerView.ViewHolder{

    TextView nome, distancia;

    public MyViewHolder(View itemView) {
        super(itemView);

        nome = itemView.findViewById(R.id.textRequisicaoNome);
        distancia = itemView.findViewById(R.id.textRequisicaoDistancia);

    }
}

}
AID CODE – ACTIVITY

RecyclerItemClickListener public class implements RecyclerView.OnItemTouchListener {

    private OnItemClickListener mListener;
    GestureDetector mGestureDetector;

    @Override
    public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
        View childView = rv.findChildViewUnder(e.getX(), e.getY());
        if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
            mListener.onItemClick(childView, rv.getChildAdapterPosition(childView));
            return true;
        }
        return false;
    }

    @Override
    public void onTouchEvent(RecyclerView rv, MotionEvent e) {

    }

    @Override
    public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

    }

    public interface OnItemClickListener extends AdapterView.OnItemClickListener {
        void onItemClick(View view, int position);

        void onLongItemClick(View view, int position);
    }

    public RecyclerItemClickListener(Context context, final RecyclerView recyclerView, OnItemClickListener listener) {
        mListener = listener;
        mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onSingleTapUp(MotionEvent e) {
                return true;
            }

            @Override
            public void onLongPress(MotionEvent e) {
                View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
                if (child != null && mListener != null) {
                    mListener.onLongItemClick(child, recyclerView.getChildAdapterPosition(child));
                }
            }
        });

    }
}

THANKS FROM WHO CAN HELP ME

Why is Trump not popular with Canadians despite giving Canada billions in aid?

Trump is a despicable human being. The world hates it. Only the mentally retarded or the mentally ill will say that Trump has handled the CoronaVirus crisis well. If you handled it well, you don't have to blame China or WHO for not telling you what you needed to know.

unity – Random.range giving me the same value at the same time

I created a random address on the x and y axes where to move, so my problem is that when I try to randomize it I sometimes get the same value at the same time on the x and y axes. How can I not let this happen, I just want an axis to have a value, not both?


ERROR

enter the image description here


HOW I WANT IT TO HAPPEN

enter the image description here


CODE

public Vector2 randomDirection;

void Awake()
{
}

void Update()
{
    randomDirection = new Vector2(Random.Range(-1, 2), Random.Range(-1, 2));
}